WordPress.org

Make WordPress Core

Changeset 31981


Ignore:
Timestamp:
04/02/2015 05:26:22 AM (5 years ago)
Author:
jeremyfelt
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/admin-bar.php

    r31533 r31981  
    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
Note: See TracChangeset for help on using the changeset viewer.