関数 is_main_network()
定義ファイル :/blog/wp-includes/functions.php 18
is_main_network()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | /** * Determine whether a network is the main network of the Multisite install. * * @since 3.7.0 * * @param int $network_id Optional. Network ID to test. Defaults to current network. * @return bool True if $network_id is the main network, or if not running Multisite. */ function is_main_network( $network_id = null ) { global $wpdb; if ( ! is_multisite() ) return true; $current_network_id = (int) get_current_site()->id; if ( ! $network_id ) $network_id = $current_network_id; $network_id = (int) $network_id; if ( defined( 'PRIMARY_NETWORK_ID' ) ) return $network_id === (int) PRIMARY_NETWORK_ID; if ( 1 === $current_network_id ) return $network_id === $current_network_id; $primary_network_id = (int) wp_cache_get( 'primary_network_id', 'site-options' ); if ( $primary_network_id ) return $network_id === $primary_network_id; $primary_network_id = (int) $wpdb->get_var( "SELECT id FROM $wpdb->site ORDER BY id LIMIT 1" ); wp_cache_add( 'primary_network_id', $primary_network_id, 'site-options' ); return $network_id === $primary_network_id; } |