| 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 $site_id optional site id to test (default current site) |
| 3274 | * |
| 3275 | * @return bool True if not multisite or if $site_id is the main network |
| 3276 | */ |
| 3277 | function is_main_network( $site_id = '' ) { |
| 3278 | global $current_site, $wpdb; |
| 3279 | |
| 3280 | // What are the repercussions of returning true to a network function when there is no network? |
| 3281 | if ( ! is_multisite() ) |
| 3282 | return true; |
| 3283 | |
| 3284 | if ( ! $site_id ) |
| 3285 | $site_id = $current_site->id; |
| 3286 | |
| 3287 | if ( defined( 'PRIMARY_NETWORK_ID' ) && $site_id == PRIMARY_NETWORK_ID ) |
| 3288 | return true; |
| 3289 | |
| 3290 | // What if the current site is 1 and PRIMARY_NETWORK_ID is not |
| 3291 | if ( 1 == $current_site->id && $site_id == $current_site->id ) |
| 3292 | return true; |
| 3293 | |
| 3294 | // This query should be cached |
| 3295 | if ( $site_id == $wpdb->get_var( "SELECT id FROM $wpdb->site ORDER BY id LIMIT 1" ) ) |
| 3296 | return true; |
| 3297 | |
| 3298 | return false; |
| 3299 | } |
| 3300 | |
| 3301 | /** |