From f2df6bb98ad3bf9dbc561aea01209ce366cbdf19 Mon Sep 17 00:00:00 2001 From: duck_ Date: Sun, 6 Nov 2011 12:21:12 +0000 Subject: [PATCH] Hide Site Name menu if the user isn't a member and isn't a super admin. Always show My Sites if the user has a site, and don't remove the current site from the list. Fixes #19122. git-svn-id: http://svn.automattic.com/wordpress/trunk@19184 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/admin-bar.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/wp-includes/admin-bar.php b/wp-includes/admin-bar.php index 8f3a097f93..0cfbfaf265 100644 --- a/wp-includes/admin-bar.php +++ b/wp-includes/admin-bar.php @@ -210,9 +210,14 @@ function wp_admin_bar_my_account_menu( $wp_admin_bar ) { function wp_admin_bar_site_menu( $wp_admin_bar ) { global $current_site; + // 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( get_current_user_id(), get_current_blog_id() ) && ! is_super_admin() ) + return; + $blogname = get_bloginfo('name'); if ( empty( $blogname ) ) @@ -272,8 +277,8 @@ function wp_admin_bar_my_sites_menu( $wp_admin_bar ) { if ( ! is_user_logged_in() || ! is_multisite() ) return; - // Show only when there are more than two items in the menu. - if ( count( $wp_admin_bar->user->blogs ) <= 1 && ! is_super_admin() ) + // Show only when the user has at least one site, or they're a super admin. + if ( count( $wp_admin_bar->user->blogs ) < 1 && ! is_super_admin() ) return; $wp_admin_bar->add_menu( array( @@ -331,11 +336,6 @@ function wp_admin_bar_my_sites_menu( $wp_admin_bar ) { $blue_wp_logo_url = includes_url('images/wpmini-blue.png'); foreach ( (array) $wp_admin_bar->user->blogs as $blog ) { - // Skip the current blog (unless we're in the network/user admin). - if ( $blog->userblog_id == get_current_blog_id() && ! is_network_admin() && ! is_user_admin() ) { - continue; - } - // @todo Replace with some favicon lookup. //$blavatar = 'Blavatar'; $blavatar = '' . esc_attr__( 'Blavatar' ) . '';