Make WordPress Core


Ignore:
Timestamp:
09/15/2017 11:14:49 AM (8 years ago)
Author:
flixos90
Message:

Multisite: Introduce get_main_site_id().

This function can be used to easily get the main site ID of a given network via the optional $network_id parameter, which defaults to the current network. The existing is_main_site() now uses the new function internally and now accepts an optional $network_id parameter as well.

The main purpose of the new function at this point is to ensure that the WP_Network::$blog_id property is always set. Magic getters in the class have been adjusted to auto-fill the property when it is accessed and empty. Furthermore the function encapsulates logic that was previously part of ms_load_current_site_and_network() and has been replaced with a call to the function now.

Props spacedmonkey, jeremyfelt, johnjamesjacoby, flixos90.
Fixes #29684.

File:
1 edited

Legend:

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

    r41242 r41380  
    584584        $this->assertEquals( $original_count + 1, $result );
    585585    }
     586
     587    /**
     588     * @ticket 29684
     589     */
     590    public function test_network_blog_id_set() {
     591        $network = get_network( self::$different_network_id );
     592
     593        $this->assertSame( (string) self::$different_site_ids[0], $network->blog_id );
     594    }
    586595}
    587596
Note: See TracChangeset for help on using the changeset viewer.