From 111203b0f6b47322bb125f6d9750a67c5c5987b8 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Thu, 2 Apr 2015 05:26:22 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@31981 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/admin-bar.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/admin-bar.php b/src/wp-includes/admin-bar.php index f35125ec68..80d817fbce 100644 --- a/src/wp-includes/admin-bar.php +++ b/src/wp-includes/admin-bar.php @@ -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() ) {