Make WordPress Core

Ticket #25030: 25030.4.diff

File 25030.4.diff, 1.6 KB (added by jeremyfelt, 12 years ago)
  • src/wp-includes/functions.php

     
    15501550        }
    15511551
    15521552        // If multisite (and if not the main site in a post-MU network)
    1553         if ( is_multisite() && ! ( is_main_site() && defined( 'MULTISITE' ) ) ) {
     1553        if ( is_multisite() && ! ( is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) {
    15541554
    15551555                if ( ! get_site_option( 'ms_files_rewriting' ) ) {
    15561556                        // If ms-files rewriting is disabled (networks created post-3.5), it is fairly straightforward:
     
    32643264}
    32653265
    32663266/**
     3267 * Checks either current site or a supplied site ID against the defined main site ID
     3268 * to determine if this is the main network.
     3269 *
     3270 * @since 3.7.0
     3271 * @package WordPress
     3272 *
     3273 * @param string $network_id optional network id to test (default current site)
     3274 *
     3275 * @return bool True if not multisite or if $network_id is the main network
     3276 */
     3277function is_main_network( $network_id = '' ) {
     3278        global $current_site, $wpdb;
     3279
     3280        if ( ! is_multisite() )
     3281                return true;
     3282
     3283        if ( ! $network_id )
     3284                $network_id = $current_site->id;
     3285
     3286        if ( defined( 'PRIMARY_NETWORK_ID' ) )
     3287                return $network_id == PRIMARY_NETWORK_ID;
     3288
     3289        if ( 1 == $current_site->id && 1 == $network_id )
     3290                return $network_id == $current_site->id;
     3291
     3292        // This query should be cached
     3293        if ( $network_id == $wpdb->get_var( "SELECT id FROM $wpdb->site ORDER BY id LIMIT 1" ) )
     3294                return true;
     3295
     3296        return false;
     3297}
     3298
     3299/**
    32673300 * Whether global terms are enabled.
    32683301 *
    32693302 *