Edit File by line
/home/barbar84/public_h.../wp-inclu...
File: admin-bar.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Toolbar API: Top-level Toolbar functionality
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Toolbar
[5] Fix | Delete
* @since 3.1.0
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Instantiate the admin bar object and set it up as a global for access elsewhere.
[10] Fix | Delete
*
[11] Fix | Delete
* UNHOOKING THIS FUNCTION WILL NOT PROPERLY REMOVE THE ADMIN BAR.
[12] Fix | Delete
* For that, use show_admin_bar(false) or the {@see 'show_admin_bar'} filter.
[13] Fix | Delete
*
[14] Fix | Delete
* @since 3.1.0
[15] Fix | Delete
* @access private
[16] Fix | Delete
*
[17] Fix | Delete
* @global WP_Admin_Bar $wp_admin_bar
[18] Fix | Delete
*
[19] Fix | Delete
* @return bool Whether the admin bar was successfully initialized.
[20] Fix | Delete
*/
[21] Fix | Delete
function _wp_admin_bar_init() {
[22] Fix | Delete
global $wp_admin_bar;
[23] Fix | Delete
[24] Fix | Delete
if ( ! is_admin_bar_showing() ) {
[25] Fix | Delete
return false;
[26] Fix | Delete
}
[27] Fix | Delete
[28] Fix | Delete
/* Load the admin bar class code ready for instantiation */
[29] Fix | Delete
require_once ABSPATH . WPINC . '/class-wp-admin-bar.php';
[30] Fix | Delete
[31] Fix | Delete
/* Instantiate the admin bar */
[32] Fix | Delete
[33] Fix | Delete
/**
[34] Fix | Delete
* Filters the admin bar class to instantiate.
[35] Fix | Delete
*
[36] Fix | Delete
* @since 3.1.0
[37] Fix | Delete
*
[38] Fix | Delete
* @param string $wp_admin_bar_class Admin bar class to use. Default 'WP_Admin_Bar'.
[39] Fix | Delete
*/
[40] Fix | Delete
$admin_bar_class = apply_filters( 'wp_admin_bar_class', 'WP_Admin_Bar' );
[41] Fix | Delete
if ( class_exists( $admin_bar_class ) ) {
[42] Fix | Delete
$wp_admin_bar = new $admin_bar_class;
[43] Fix | Delete
} else {
[44] Fix | Delete
return false;
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
$wp_admin_bar->initialize();
[48] Fix | Delete
$wp_admin_bar->add_menus();
[49] Fix | Delete
[50] Fix | Delete
return true;
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
/**
[54] Fix | Delete
* Renders the admin bar to the page based on the $wp_admin_bar->menu member var.
[55] Fix | Delete
*
[56] Fix | Delete
* This is called very early on the {@see 'wp_body_open'} action so that it will render
[57] Fix | Delete
* before anything else being added to the page body.
[58] Fix | Delete
*
[59] Fix | Delete
* For backward compatibility with themes not using the 'wp_body_open' action,
[60] Fix | Delete
* the function is also called late on {@see 'wp_footer'}.
[61] Fix | Delete
*
[62] Fix | Delete
* It includes the {@see 'admin_bar_menu'} action which should be used to hook in and
[63] Fix | Delete
* add new menus to the admin bar. That way you can be sure that you are adding at most
[64] Fix | Delete
* optimal point, right before the admin bar is rendered. This also gives you access to
[65] Fix | Delete
* the `$post` global, among others.
[66] Fix | Delete
*
[67] Fix | Delete
* @since 3.1.0
[68] Fix | Delete
* @since 5.4.0 Called on 'wp_body_open' action first, with 'wp_footer' as a fallback.
[69] Fix | Delete
*
[70] Fix | Delete
* @global WP_Admin_Bar $wp_admin_bar
[71] Fix | Delete
*/
[72] Fix | Delete
function wp_admin_bar_render() {
[73] Fix | Delete
global $wp_admin_bar;
[74] Fix | Delete
static $rendered = false;
[75] Fix | Delete
[76] Fix | Delete
if ( $rendered ) {
[77] Fix | Delete
return;
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
if ( ! is_admin_bar_showing() || ! is_object( $wp_admin_bar ) ) {
[81] Fix | Delete
return;
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
/**
[85] Fix | Delete
* Load all necessary admin bar items.
[86] Fix | Delete
*
[87] Fix | Delete
* This is the hook used to add, remove, or manipulate admin bar items.
[88] Fix | Delete
*
[89] Fix | Delete
* @since 3.1.0
[90] Fix | Delete
*
[91] Fix | Delete
* @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance, passed by reference
[92] Fix | Delete
*/
[93] Fix | Delete
do_action_ref_array( 'admin_bar_menu', array( &$wp_admin_bar ) );
[94] Fix | Delete
[95] Fix | Delete
/**
[96] Fix | Delete
* Fires before the admin bar is rendered.
[97] Fix | Delete
*
[98] Fix | Delete
* @since 3.1.0
[99] Fix | Delete
*/
[100] Fix | Delete
do_action( 'wp_before_admin_bar_render' );
[101] Fix | Delete
[102] Fix | Delete
$wp_admin_bar->render();
[103] Fix | Delete
[104] Fix | Delete
/**
[105] Fix | Delete
* Fires after the admin bar is rendered.
[106] Fix | Delete
*
[107] Fix | Delete
* @since 3.1.0
[108] Fix | Delete
*/
[109] Fix | Delete
do_action( 'wp_after_admin_bar_render' );
[110] Fix | Delete
[111] Fix | Delete
$rendered = true;
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
/**
[115] Fix | Delete
* Add the WordPress logo menu.
[116] Fix | Delete
*
[117] Fix | Delete
* @since 3.3.0
[118] Fix | Delete
*
[119] Fix | Delete
* @param WP_Admin_Bar $wp_admin_bar
[120] Fix | Delete
*/
[121] Fix | Delete
function wp_admin_bar_wp_menu( $wp_admin_bar ) {
[122] Fix | Delete
if ( current_user_can( 'read' ) ) {
[123] Fix | Delete
$about_url = self_admin_url( 'about.php' );
[124] Fix | Delete
} elseif ( is_multisite() ) {
[125] Fix | Delete
$about_url = get_dashboard_url( get_current_user_id(), 'about.php' );
[126] Fix | Delete
} else {
[127] Fix | Delete
$about_url = false;
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
$wp_logo_menu_args = array(
[131] Fix | Delete
'id' => 'wp-logo',
[132] Fix | Delete
'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . __( 'About WordPress' ) . '</span>',
[133] Fix | Delete
'href' => $about_url,
[134] Fix | Delete
);
[135] Fix | Delete
[136] Fix | Delete
// Set tabindex="0" to make sub menus accessible when no URL is available.
[137] Fix | Delete
if ( ! $about_url ) {
[138] Fix | Delete
$wp_logo_menu_args['meta'] = array(
[139] Fix | Delete
'tabindex' => 0,
[140] Fix | Delete
);
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
$wp_admin_bar->add_node( $wp_logo_menu_args );
[144] Fix | Delete
[145] Fix | Delete
if ( $about_url ) {
[146] Fix | Delete
// Add "About WordPress" link.
[147] Fix | Delete
$wp_admin_bar->add_node(
[148] Fix | Delete
array(
[149] Fix | Delete
'parent' => 'wp-logo',
[150] Fix | Delete
'id' => 'about',
[151] Fix | Delete
'title' => __( 'About WordPress' ),
[152] Fix | Delete
'href' => $about_url,
[153] Fix | Delete
)
[154] Fix | Delete
);
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
// Add WordPress.org link.
[158] Fix | Delete
$wp_admin_bar->add_node(
[159] Fix | Delete
array(
[160] Fix | Delete
'parent' => 'wp-logo-external',
[161] Fix | Delete
'id' => 'wporg',
[162] Fix | Delete
'title' => __( 'WordPress.org' ),
[163] Fix | Delete
'href' => __( 'https://wordpress.org/' ),
[164] Fix | Delete
)
[165] Fix | Delete
);
[166] Fix | Delete
[167] Fix | Delete
// Add documentation link.
[168] Fix | Delete
$wp_admin_bar->add_node(
[169] Fix | Delete
array(
[170] Fix | Delete
'parent' => 'wp-logo-external',
[171] Fix | Delete
'id' => 'documentation',
[172] Fix | Delete
'title' => __( 'Documentation' ),
[173] Fix | Delete
'href' => __( 'https://wordpress.org/support/' ),
[174] Fix | Delete
)
[175] Fix | Delete
);
[176] Fix | Delete
[177] Fix | Delete
// Add forums link.
[178] Fix | Delete
$wp_admin_bar->add_node(
[179] Fix | Delete
array(
[180] Fix | Delete
'parent' => 'wp-logo-external',
[181] Fix | Delete
'id' => 'support-forums',
[182] Fix | Delete
'title' => __( 'Support' ),
[183] Fix | Delete
'href' => __( 'https://wordpress.org/support/forums/' ),
[184] Fix | Delete
)
[185] Fix | Delete
);
[186] Fix | Delete
[187] Fix | Delete
// Add feedback link.
[188] Fix | Delete
$wp_admin_bar->add_node(
[189] Fix | Delete
array(
[190] Fix | Delete
'parent' => 'wp-logo-external',
[191] Fix | Delete
'id' => 'feedback',
[192] Fix | Delete
'title' => __( 'Feedback' ),
[193] Fix | Delete
'href' => __( 'https://wordpress.org/support/forum/requests-and-feedback' ),
[194] Fix | Delete
)
[195] Fix | Delete
);
[196] Fix | Delete
}
[197] Fix | Delete
[198] Fix | Delete
/**
[199] Fix | Delete
* Add the sidebar toggle button.
[200] Fix | Delete
*
[201] Fix | Delete
* @since 3.8.0
[202] Fix | Delete
*
[203] Fix | Delete
* @param WP_Admin_Bar $wp_admin_bar
[204] Fix | Delete
*/
[205] Fix | Delete
function wp_admin_bar_sidebar_toggle( $wp_admin_bar ) {
[206] Fix | Delete
if ( is_admin() ) {
[207] Fix | Delete
$wp_admin_bar->add_node(
[208] Fix | Delete
array(
[209] Fix | Delete
'id' => 'menu-toggle',
[210] Fix | Delete
'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . __( 'Menu' ) . '</span>',
[211] Fix | Delete
'href' => '#',
[212] Fix | Delete
)
[213] Fix | Delete
);
[214] Fix | Delete
}
[215] Fix | Delete
}
[216] Fix | Delete
[217] Fix | Delete
/**
[218] Fix | Delete
* Add the "My Account" item.
[219] Fix | Delete
*
[220] Fix | Delete
* @since 3.3.0
[221] Fix | Delete
*
[222] Fix | Delete
* @param WP_Admin_Bar $wp_admin_bar
[223] Fix | Delete
*/
[224] Fix | Delete
function wp_admin_bar_my_account_item( $wp_admin_bar ) {
[225] Fix | Delete
$user_id = get_current_user_id();
[226] Fix | Delete
$current_user = wp_get_current_user();
[227] Fix | Delete
[228] Fix | Delete
if ( ! $user_id ) {
[229] Fix | Delete
return;
[230] Fix | Delete
}
[231] Fix | Delete
[232] Fix | Delete
if ( current_user_can( 'read' ) ) {
[233] Fix | Delete
$profile_url = get_edit_profile_url( $user_id );
[234] Fix | Delete
} elseif ( is_multisite() ) {
[235] Fix | Delete
$profile_url = get_dashboard_url( $user_id, 'profile.php' );
[236] Fix | Delete
} else {
[237] Fix | Delete
$profile_url = false;
[238] Fix | Delete
}
[239] Fix | Delete
[240] Fix | Delete
$avatar = get_avatar( $user_id, 26 );
[241] Fix | Delete
/* translators: %s: Current user's display name. */
[242] Fix | Delete
$howdy = sprintf( __( 'Howdy, %s' ), '<span class="display-name">' . $current_user->display_name . '</span>' );
[243] Fix | Delete
$class = empty( $avatar ) ? '' : 'with-avatar';
[244] Fix | Delete
[245] Fix | Delete
$wp_admin_bar->add_node(
[246] Fix | Delete
array(
[247] Fix | Delete
'id' => 'my-account',
[248] Fix | Delete
'parent' => 'top-secondary',
[249] Fix | Delete
'title' => $howdy . $avatar,
[250] Fix | Delete
'href' => $profile_url,
[251] Fix | Delete
'meta' => array(
[252] Fix | Delete
'class' => $class,
[253] Fix | Delete
),
[254] Fix | Delete
)
[255] Fix | Delete
);
[256] Fix | Delete
}
[257] Fix | Delete
[258] Fix | Delete
/**
[259] Fix | Delete
* Add the "My Account" submenu items.
[260] Fix | Delete
*
[261] Fix | Delete
* @since 3.1.0
[262] Fix | Delete
*
[263] Fix | Delete
* @param WP_Admin_Bar $wp_admin_bar
[264] Fix | Delete
*/
[265] Fix | Delete
function wp_admin_bar_my_account_menu( $wp_admin_bar ) {
[266] Fix | Delete
$user_id = get_current_user_id();
[267] Fix | Delete
$current_user = wp_get_current_user();
[268] Fix | Delete
[269] Fix | Delete
if ( ! $user_id ) {
[270] Fix | Delete
return;
[271] Fix | Delete
}
[272] Fix | Delete
[273] Fix | Delete
if ( current_user_can( 'read' ) ) {
[274] Fix | Delete
$profile_url = get_edit_profile_url( $user_id );
[275] Fix | Delete
} elseif ( is_multisite() ) {
[276] Fix | Delete
$profile_url = get_dashboard_url( $user_id, 'profile.php' );
[277] Fix | Delete
} else {
[278] Fix | Delete
$profile_url = false;
[279] Fix | Delete
}
[280] Fix | Delete
[281] Fix | Delete
$wp_admin_bar->add_group(
[282] Fix | Delete
array(
[283] Fix | Delete
'parent' => 'my-account',
[284] Fix | Delete
'id' => 'user-actions',
[285] Fix | Delete
)
[286] Fix | Delete
);
[287] Fix | Delete
[288] Fix | Delete
$user_info = get_avatar( $user_id, 64 );
[289] Fix | Delete
$user_info .= "<span class='display-name'>{$current_user->display_name}</span>";
[290] Fix | Delete
[291] Fix | Delete
if ( $current_user->display_name !== $current_user->user_login ) {
[292] Fix | Delete
$user_info .= "<span class='username'>{$current_user->user_login}</span>";
[293] Fix | Delete
}
[294] Fix | Delete
[295] Fix | Delete
$wp_admin_bar->add_node(
[296] Fix | Delete
array(
[297] Fix | Delete
'parent' => 'user-actions',
[298] Fix | Delete
'id' => 'user-info',
[299] Fix | Delete
'title' => $user_info,
[300] Fix | Delete
'href' => $profile_url,
[301] Fix | Delete
'meta' => array(
[302] Fix | Delete
'tabindex' => -1,
[303] Fix | Delete
),
[304] Fix | Delete
)
[305] Fix | Delete
);
[306] Fix | Delete
[307] Fix | Delete
if ( false !== $profile_url ) {
[308] Fix | Delete
$wp_admin_bar->add_node(
[309] Fix | Delete
array(
[310] Fix | Delete
'parent' => 'user-actions',
[311] Fix | Delete
'id' => 'edit-profile',
[312] Fix | Delete
'title' => __( 'Edit Profile' ),
[313] Fix | Delete
'href' => $profile_url,
[314] Fix | Delete
)
[315] Fix | Delete
);
[316] Fix | Delete
}
[317] Fix | Delete
[318] Fix | Delete
$wp_admin_bar->add_node(
[319] Fix | Delete
array(
[320] Fix | Delete
'parent' => 'user-actions',
[321] Fix | Delete
'id' => 'logout',
[322] Fix | Delete
'title' => __( 'Log Out' ),
[323] Fix | Delete
'href' => wp_logout_url(),
[324] Fix | Delete
)
[325] Fix | Delete
);
[326] Fix | Delete
}
[327] Fix | Delete
[328] Fix | Delete
/**
[329] Fix | Delete
* Add the "Site Name" menu.
[330] Fix | Delete
*
[331] Fix | Delete
* @since 3.3.0
[332] Fix | Delete
*
[333] Fix | Delete
* @param WP_Admin_Bar $wp_admin_bar
[334] Fix | Delete
*/
[335] Fix | Delete
function wp_admin_bar_site_menu( $wp_admin_bar ) {
[336] Fix | Delete
// Don't show for logged out users.
[337] Fix | Delete
if ( ! is_user_logged_in() ) {
[338] Fix | Delete
return;
[339] Fix | Delete
}
[340] Fix | Delete
[341] Fix | Delete
// Show only when the user is a member of this site, or they're a super admin.
[342] Fix | Delete
if ( ! is_user_member_of_blog() && ! current_user_can( 'manage_network' ) ) {
[343] Fix | Delete
return;
[344] Fix | Delete
}
[345] Fix | Delete
[346] Fix | Delete
$blogname = get_bloginfo( 'name' );
[347] Fix | Delete
[348] Fix | Delete
if ( ! $blogname ) {
[349] Fix | Delete
$blogname = preg_replace( '#^(https?://)?(www.)?#', '', get_home_url() );
[350] Fix | Delete
}
[351] Fix | Delete
[352] Fix | Delete
if ( is_network_admin() ) {
[353] Fix | Delete
/* translators: %s: Site title. */
[354] Fix | Delete
$blogname = sprintf( __( 'Network Admin: %s' ), esc_html( get_network()->site_name ) );
[355] Fix | Delete
} elseif ( is_user_admin() ) {
[356] Fix | Delete
/* translators: %s: Site title. */
[357] Fix | Delete
$blogname = sprintf( __( 'User Dashboard: %s' ), esc_html( get_network()->site_name ) );
[358] Fix | Delete
}
[359] Fix | Delete
[360] Fix | Delete
$title = wp_html_excerpt( $blogname, 40, '&hellip;' );
[361] Fix | Delete
[362] Fix | Delete
$wp_admin_bar->add_node(
[363] Fix | Delete
array(
[364] Fix | Delete
'id' => 'site-name',
[365] Fix | Delete
'title' => $title,
[366] Fix | Delete
'href' => ( is_admin() || ! current_user_can( 'read' ) ) ? home_url( '/' ) : admin_url(),
[367] Fix | Delete
)
[368] Fix | Delete
);
[369] Fix | Delete
[370] Fix | Delete
// Create submenu items.
[371] Fix | Delete
[372] Fix | Delete
if ( is_admin() ) {
[373] Fix | Delete
// Add an option to visit the site.
[374] Fix | Delete
$wp_admin_bar->add_node(
[375] Fix | Delete
array(
[376] Fix | Delete
'parent' => 'site-name',
[377] Fix | Delete
'id' => 'view-site',
[378] Fix | Delete
'title' => __( 'Visit Site' ),
[379] Fix | Delete
'href' => home_url( '/' ),
[380] Fix | Delete
)
[381] Fix | Delete
);
[382] Fix | Delete
[383] Fix | Delete
if ( is_blog_admin() && is_multisite() && current_user_can( 'manage_sites' ) ) {
[384] Fix | Delete
$wp_admin_bar->add_node(
[385] Fix | Delete
array(
[386] Fix | Delete
'parent' => 'site-name',
[387] Fix | Delete
'id' => 'edit-site',
[388] Fix | Delete
'title' => __( 'Edit Site' ),
[389] Fix | Delete
'href' => network_admin_url( 'site-info.php?id=' . get_current_blog_id() ),
[390] Fix | Delete
)
[391] Fix | Delete
);
[392] Fix | Delete
}
[393] Fix | Delete
} elseif ( current_user_can( 'read' ) ) {
[394] Fix | Delete
// We're on the front end, link to the Dashboard.
[395] Fix | Delete
$wp_admin_bar->add_node(
[396] Fix | Delete
array(
[397] Fix | Delete
'parent' => 'site-name',
[398] Fix | Delete
'id' => 'dashboard',
[399] Fix | Delete
'title' => __( 'Dashboard' ),
[400] Fix | Delete
'href' => admin_url(),
[401] Fix | Delete
)
[402] Fix | Delete
);
[403] Fix | Delete
[404] Fix | Delete
// Add the appearance submenu items.
[405] Fix | Delete
wp_admin_bar_appearance_menu( $wp_admin_bar );
[406] Fix | Delete
}
[407] Fix | Delete
}
[408] Fix | Delete
[409] Fix | Delete
/**
[410] Fix | Delete
* Adds the "Customize" link to the Toolbar.
[411] Fix | Delete
*
[412] Fix | Delete
* @since 4.3.0
[413] Fix | Delete
*
[414] Fix | Delete
* @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance.
[415] Fix | Delete
* @global WP_Customize_Manager $wp_customize
[416] Fix | Delete
*/
[417] Fix | Delete
function wp_admin_bar_customize_menu( $wp_admin_bar ) {
[418] Fix | Delete
global $wp_customize;
[419] Fix | Delete
[420] Fix | Delete
// Don't show for users who can't access the customizer or when in the admin.
[421] Fix | Delete
if ( ! current_user_can( 'customize' ) || is_admin() ) {
[422] Fix | Delete
return;
[423] Fix | Delete
}
[424] Fix | Delete
[425] Fix | Delete
// Don't show if the user cannot edit a given customize_changeset post currently being previewed.
[426] Fix | Delete
if ( is_customize_preview() && $wp_customize->changeset_post_id()
[427] Fix | Delete
&& ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $wp_customize->changeset_post_id() )
[428] Fix | Delete
) {
[429] Fix | Delete
return;
[430] Fix | Delete
}
[431] Fix | Delete
[432] Fix | Delete
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
[433] Fix | Delete
if ( is_customize_preview() && $wp_customize->changeset_uuid() ) {
[434] Fix | Delete
$current_url = remove_query_arg( 'customize_changeset_uuid', $current_url );
[435] Fix | Delete
}
[436] Fix | Delete
[437] Fix | Delete
$customize_url = add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() );
[438] Fix | Delete
if ( is_customize_preview() ) {
[439] Fix | Delete
$customize_url = add_query_arg( array( 'changeset_uuid' => $wp_customize->changeset_uuid() ), $customize_url );
[440] Fix | Delete
}
[441] Fix | Delete
[442] Fix | Delete
$wp_admin_bar->add_node(
[443] Fix | Delete
array(
[444] Fix | Delete
'id' => 'customize',
[445] Fix | Delete
'title' => __( 'Customize' ),
[446] Fix | Delete
'href' => $customize_url,
[447] Fix | Delete
'meta' => array(
[448] Fix | Delete
'class' => 'hide-if-no-customize',
[449] Fix | Delete
),
[450] Fix | Delete
)
[451] Fix | Delete
);
[452] Fix | Delete
add_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' );
[453] Fix | Delete
}
[454] Fix | Delete
[455] Fix | Delete
/**
[456] Fix | Delete
* Add the "My Sites/[Site Name]" menu and all submenus.
[457] Fix | Delete
*
[458] Fix | Delete
* @since 3.1.0
[459] Fix | Delete
*
[460] Fix | Delete
* @param WP_Admin_Bar $wp_admin_bar
[461] Fix | Delete
*/
[462] Fix | Delete
function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
[463] Fix | Delete
// Don't show for logged out users or single site mode.
[464] Fix | Delete
if ( ! is_user_logged_in() || ! is_multisite() ) {
[465] Fix | Delete
return;
[466] Fix | Delete
}
[467] Fix | Delete
[468] Fix | Delete
// Show only when the user has at least one site, or they're a super admin.
[469] Fix | Delete
if ( count( $wp_admin_bar->user->blogs ) < 1 && ! current_user_can( 'manage_network' ) ) {
[470] Fix | Delete
return;
[471] Fix | Delete
}
[472] Fix | Delete
[473] Fix | Delete
if ( $wp_admin_bar->user->active_blog ) {
[474] Fix | Delete
$my_sites_url = get_admin_url( $wp_admin_bar->user->active_blog->blog_id, 'my-sites.php' );
[475] Fix | Delete
} else {
[476] Fix | Delete
$my_sites_url = admin_url( 'my-sites.php' );
[477] Fix | Delete
}
[478] Fix | Delete
[479] Fix | Delete
$wp_admin_bar->add_node(
[480] Fix | Delete
array(
[481] Fix | Delete
'id' => 'my-sites',
[482] Fix | Delete
'title' => __( 'My Sites' ),
[483] Fix | Delete
'href' => $my_sites_url,
[484] Fix | Delete
)
[485] Fix | Delete
);
[486] Fix | Delete
[487] Fix | Delete
if ( current_user_can( 'manage_network' ) ) {
[488] Fix | Delete
$wp_admin_bar->add_group(
[489] Fix | Delete
array(
[490] Fix | Delete
'parent' => 'my-sites',
[491] Fix | Delete
'id' => 'my-sites-super-admin',
[492] Fix | Delete
)
[493] Fix | Delete
);
[494] Fix | Delete
[495] Fix | Delete
$wp_admin_bar->add_node(
[496] Fix | Delete
array(
[497] Fix | Delete
'parent' => 'my-sites-super-admin',
[498] Fix | Delete
'id' => 'network-admin',
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function