wp_admin_bar_site_menu( WP_Admin_Bar $wp_admin_bar )
- Since
- 3.3.0
- Source
wp-includes/admin-bar.php:366
Adds the "Site Name" menu.
Parameters
$wp_admin_barWP_Admin_Bar- The WP_Admin_Bar instance.
Uses · 19
- is_user_logged_in()Determines whether the current visitor is a logged in user.
- is_user_member_of_blog()Finds out whether a user is a member of a given blog.
- current_user_can()Returns whether the current user has the specified capability.
- get_bloginfo()Retrieves information about the current site.
- get_home_url()Retrieves the URL for a given site where the front end is accessible.
- is_network_admin()Determines whether the current request is for the network administrative interface.
- __()Retrieves the translation of $text.
- esc_html()Escaping for HTML blocks.
- get_network()Retrieves network data given a network ID or network object.
- is_user_admin()Determines whether the current request is for a user admin screen.
- wp_html_excerpt()Safely extracts not more than the first $count characters from HTML string.
- is_admin()Determines whether the current request is for an administrative interface page.
Show all 19
- home_url()Retrieves the URL for the current site where the front end is accessible.
- admin_url()Retrieves the URL to the admin area for the current site.
- is_blog_admin()Determines whether the current request is for a site's administrative interface.
- is_multisite()Determines whether Multisite is enabled.
- network_admin_url()Retrieves the URL to the admin area for the network.
- get_current_blog_id()Retrieves the current site ID.
- wp_admin_bar_appearance_menu()Adds appearance submenu items to the "Site Name" menu.
Source
function wp_admin_bar_site_menu( $wp_admin_bar ) { // Don't show for logged out users. if ( ! is_user_logged_in() ) { return; } // Show only when the user is a member of this site, or they're a super admin. if ( ! is_user_member_of_blog() && ! current_user_can( 'manage_network' ) ) { return; } $blogname = get_bloginfo( 'name' ); if ( ! $blogname ) { $blogname = preg_replace( '#^(https?://)?(www.)?#', '', get_home_url() ); } if ( is_network_admin() ) { /* translators: %s: Site title. */ $blogname = sprintf( __( 'Network Admin: %s' ), esc_html( get_network()->site_name ) ); } elseif ( is_user_admin() ) { /* translators: %s: Site title. */ $blogname = sprintf( __( 'User Dashboard: %s' ), esc_html( get_network()->site_name ) ); } $title = wp_html_excerpt( $blogname, 40, '…' ); $wp_admin_bar->add_node( array( 'id' => 'site-name', 'title' => $title, 'href' => ( is_admin() || ! current_user_can( 'read' ) ) ? home_url( '/' ) : admin_url(), 'meta' => array( 'menu_title' => $title, ), ) ); // Create submenu items. if ( is_admin() ) { // Add an option to visit the site. $wp_admin_bar->add_node( array( 'parent' => 'site-name', 'id' => 'view-site', 'title' => __( 'Visit Site' ), 'href' => home_url( '/' ), ) ); if ( is_blog_admin() && is_multisite() && current_user_can( 'manage_sites' ) ) { $wp_admin_bar->add_node( array( 'parent' => 'site-name', 'id' => 'edit-site', 'title' => __( 'Manage Site' ), 'href' => network_admin_url( 'site-info.php?id=' . get_current_blog_id() ), ) ); } } elseif ( current_user_can( 'read' ) ) { // We're on the front end, link to the Dashboard. $wp_admin_bar->add_node( array( 'parent' => 'site-name', 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => admin_url(), ) ); // Add the appearance submenu items. wp_admin_bar_appearance_menu( $wp_admin_bar ); // Add a Plugins link. if ( current_user_can( 'activate_plugins' ) ) { $wp_admin_bar->add_node( array( 'parent' => 'site-name',History
Introduced in 3.3.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.7.7 tag, from
src/wp-includes/admin-bar.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.