Make WordPress Core


Ignore:
Timestamp:
06/09/2016 08:33:35 PM (9 years ago)
Author:
jeremyfelt
Message:

Multisite: Introduce get_current_network_id()

Similar to get_current_blog_id, this can be used to get the ID of the $current_site global. If not available, it will fallback to the main network ID. In single site, this will return 1.

Props spacedmonkey, flixos90.
Fixes #33900.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r37663 r37670  
    42564256    }
    42574257
     4258    $current_site = get_current_site();
     4259
    42584260    if ( defined( 'PRIMARY_NETWORK_ID' ) ) {
    42594261        $main_network_id = PRIMARY_NETWORK_ID;
    4260     } elseif ( 1 === (int) get_current_site()->id ) {
     4262    } elseif ( isset( $current_site->id ) && 1 === (int) $current_site->id ) {
    42614263        // If the current network has an ID of 1, assume it is the main network.
    42624264        $main_network_id = 1;
Note: See TracChangeset for help on using the changeset viewer.