Make WordPress Core

Ticket #25030: 25030.6.diff

File 25030.6.diff, 1.8 KB (added by jeremyfelt, 8 years ago)
  • src/wp-includes/functions.php

     
    15541554        }
    15551555
    15561556        // If multisite (and if not the main site in a post-MU network)
    1557         if ( is_multisite() && ! ( is_main_site() && defined( 'MULTISITE' ) ) ) {
     1557        if ( is_multisite() && ! ( is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) {
    15581558
    15591559                if ( ! get_site_option( 'ms_files_rewriting' ) ) {
    15601560                        // If ms-files rewriting is disabled (networks created post-3.5), it is fairly straightforward:
     
    32683268}
    32693269
    32703270/**
     3271 * Checks either the current site or a supplied network id against the primary network id
     3272 * to determine if this is the main network.
     3273 *
     3274 * @since 3.7.0
     3275 * @package WordPress
     3276 *
     3277 * @param string $network_id optional network id to test (default current site)
     3278 *
     3279 * @return bool True if not multisite or if $network_id is the main network
     3280 */
     3281function is_main_network( $network_id = false ) {
     3282        global $current_site, $wpdb;
     3283
     3284        if ( ! is_multisite() )
     3285                return true;
     3286
     3287        if ( ! $network_id )
     3288                $network_id = $current_site->id;
     3289
     3290        if ( defined( 'PRIMARY_NETWORK_ID' ) && PRIMARY_NETWORK_ID )
     3291                return $network_id == PRIMARY_NETWORK_ID;
     3292
     3293        if ( 1 == $current_site->id )
     3294                return $network_id == $current_site->id;
     3295
     3296        $primary_network_id = wp_cache_get( 'primary_network_id', 'site-options' );
     3297
     3298        if ( $primary_network_id )
     3299                return $network_id == $primary_network_id;
     3300
     3301        $primary_network_id = $wpdb->get_var( "SELECT id FROM $wpdb->site ORDER BY id LIMIT 1" );
     3302        wp_cache_set( 'primary_network_id', $primary_network_id, 'site-options' );
     3303
     3304        return $network_id == $primary_network_id;
     3305}
     3306
     3307/**
    32713308 * Whether global terms are enabled.
    32723309 *
    32733310 *