| 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 | */ |
| 3277 | function 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 | /** |