Skip to content

Commit 111203b

Browse files
committed
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
1 parent b8b3329 commit 111203b

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/wp-includes/admin-bar.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,16 @@ function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
329329
if ( count( $wp_admin_bar->user->blogs ) < 1 && ! is_super_admin() )
330330
return;
331331

332+
if ( $wp_admin_bar->user->active_blog ) {
333+
$my_sites_url = get_admin_url( $wp_admin_bar->user->active_blog->blog_id, 'my-sites.php' );
334+
} else {
335+
$my_sites_url = admin_url( 'my-sites.php' );
336+
}
337+
332338
$wp_admin_bar->add_menu( array(
333339
'id' => 'my-sites',
334340
'title' => __( 'My Sites' ),
335-
'href' => get_admin_url( $wp_admin_bar->user->active_blog->blog_id, 'my-sites.php' ),
341+
'href' => $my_sites_url,
336342
) );
337343

338344
if ( is_super_admin() ) {

0 commit comments

Comments
 (0)