Changeset 25147
- Timestamp:
- 08/28/2013 03:34:50 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r25101 r25147 3247 3247 3248 3248 /** 3249 * Is main site? 3250 * 3249 * Whether a site is the main site of the current network. 3251 3250 * 3252 3251 * @since 3.0.0 3253 * @package WordPress3254 * 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 site3257 */ 3258 function is_main_site( $blog_id = '' ) { 3252 * 3253 * @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. 3255 */ 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 … … 3262 3261 return true; 3263 3262 3264 if ( ! $blog_id ) 3265 $blog_id = get_current_blog_id(); 3266 3267 return $blog_id == $current_site->blog_id; 3263 if ( ! $site_id ) 3264 $site_id = get_current_blog_id(); 3265 3266 return (int) $site_id === (int) $current_site->blog_id; 3267 } 3268 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' ) ) 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; 3268 3304 } 3269 3305
Note: See TracChangeset
for help on using the changeset viewer.