Check for an active blog before generating the my-sites.php URL.

If a super admin does not have an active blog assigned to their account, `$wp_admin_bar->user->active_blog` will be set as `null`. We can then fall back to `admin_url()` to generate the My Sites URL.

Props SergeyBiryukov, deconf.

Fixes #31755.

Built from https://develop.svn.wordpress.org/trunk@31981


git-svn-id: http://core.svn.wordpress.org/trunk@31960 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Jeremy Felt 2015-04-02 05:27:30 +00:00
parent 633241e60d
commit d7fec56e26
2 changed files with 8 additions and 2 deletions

View File

@ -329,10 +329,16 @@ function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
if ( count( $wp_admin_bar->user->blogs ) < 1 && ! is_super_admin() )
return;
if ( $wp_admin_bar->user->active_blog ) {
$my_sites_url = get_admin_url( $wp_admin_bar->user->active_blog->blog_id, 'my-sites.php' );
} else {
$my_sites_url = admin_url( 'my-sites.php' );
}
$wp_admin_bar->add_menu( array(
'id' => 'my-sites',
'title' => __( 'My Sites' ),
'href' => get_admin_url( $wp_admin_bar->user->active_blog->blog_id, 'my-sites.php' ),
'href' => $my_sites_url,
) );
if ( is_super_admin() ) {

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-beta3-31980';
$wp_version = '4.2-beta3-31981';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.