Make WordPress Core


Ignore:
Timestamp:
10/02/2017 01:43:48 AM (7 years ago)
Author:
jeremyfelt
Message:

Multisite: Use get_current_blog_id() instead of $wpdb->blogid.

get_current_blog_id() is more appropriate for determining the ID of the current site in most cases. This eliminates the need for the global $wpdb in several functions and is better than the implicit global used in admin pages.

Props bnap00, spacedmonkey.
Fixes #41684.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/user/multisite.php

    r41255 r41661  
    121121
    122122        $this->assertTrue( is_blog_user() );
    123         $this->assertTrue( is_blog_user( $wpdb->blogid ) );
     123        $this->assertTrue( is_blog_user( get_current_blog_id() ) );
    124124
    125125        $blog_ids = array();
     
    150150
    151151        wp_set_current_user( $user1_id );
     152        $site_id = get_current_blog_id();
    152153
    153154        $this->assertTrue( is_user_member_of_blog() );
    154155        $this->assertTrue( is_user_member_of_blog( 0, 0 ) );
    155         $this->assertTrue( is_user_member_of_blog( 0, $wpdb->blogid ) );
     156        $this->assertTrue( is_user_member_of_blog( 0, $site_id ) );
    156157        $this->assertTrue( is_user_member_of_blog( $user1_id ) );
    157         $this->assertTrue( is_user_member_of_blog( $user1_id, $wpdb->blogid ) );
     158        $this->assertTrue( is_user_member_of_blog( $user1_id, $site_id ) );
    158159
    159160        $blog_ids = self::factory()->blog->create_many( 1 );
Note: See TracChangeset for help on using the changeset viewer.