Ticket #25030: 25030.8.diff
File 25030.8.diff, 2.7 KB (added by , 12 years ago) |
---|
-
src/wp-includes/functions.php
1554 1554 } 1555 1555 1556 1556 // 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' ) ) ) { 1558 1558 1559 1559 if ( ! get_site_option( 'ms_files_rewriting' ) ) { 1560 1560 // If ms-files rewriting is disabled (networks created post-3.5), it is fairly straightforward: … … 3246 3246 } 3247 3247 3248 3248 /** 3249 * Is main site?3249 * Whether a site is the main site of the current network. 3250 3250 * 3251 *3252 3251 * @since 3.0.0 3253 * @package WordPress3254 3252 * 3255 * @param int $ blog_id optional blog id to test (default current blog)3256 * @return bool True if not multisite or $blog_id is main site3253 * @param int $site_id Optional. Site ID to test. Defaults to current site. 3254 * @return bool True if $site_id is the main site of the network, or if not running multisite. 3257 3255 */ 3258 function is_main_site( $blog_id = '' ) { 3256 function is_main_site( $site_id = null ) { 3257 // This is the current network's information; 'site' is old terminology. 3259 3258 global $current_site; 3260 3259 3261 3260 if ( ! is_multisite() ) 3262 3261 return true; 3263 3262 3264 if ( ! $ blog_id )3265 $ blog_id = get_current_blog_id();3263 if ( ! $site_id ) 3264 $site_id = get_current_blog_id(); 3266 3265 3267 return $blog_id ==$current_site->blog_id;3266 return (int) $site_id === (int) $current_site->blog_id; 3268 3267 } 3269 3268 3270 3269 /** 3270 * Whether a network is the main network of the multisite install. 3271 * 3272 * @since 3.7.0 3273 * 3274 * @param int $network_id Optional. Network ID to test. Defaults to current network. 3275 * @return bool True if $network_id is the main network, or if not running multisite. 3276 */ 3277 function is_main_network( $network_id = null ) { 3278 global $current_site, $wpdb; 3279 3280 $current_network_id = (int) $current_site->id; 3281 3282 if ( ! is_multisite() ) 3283 return true; 3284 3285 if ( ! $network_id ) 3286 $network_id = $current_network_id; 3287 $network_id = (int) $network_id; 3288 3289 if ( defined( 'PRIMARY_NETWORK_ID' ) && 0 !== (int) PRIMARY_NETWORK_ID ) 3290 return $network_id === (int) PRIMARY_NETWORK_ID; 3291 3292 if ( 1 === $current_network_id ) 3293 return $network_id === $current_network_id; 3294 3295 $primary_network_id = (int) wp_cache_get( 'primary_network_id', 'site-options' ); 3296 3297 if ( $primary_network_id ) 3298 return $network_id === $primary_network_id; 3299 3300 $primary_network_id = (int) $wpdb->get_var( "SELECT id FROM $wpdb->site ORDER BY id LIMIT 1" ); 3301 wp_cache_add( 'primary_network_id', $primary_network_id, 'site-options' ); 3302 3303 return $network_id === $primary_network_id; 3304 } 3305 3306 /** 3271 3307 * Whether global terms are enabled. 3272 3308 * 3273 3309 *