WordPress.org

Make WordPress Core

Ticket #33900: 33900.diff

File 33900.diff, 1.7 KB (added by jeremyfelt, 3 years ago)
  • src/wp-includes/functions.php

     
    42424242 *
    42434243 * @since 4.3.0
    42444244 *
    4245  * @global wpdb $wpdb WordPress database abstraction object.
     4245 * @global wpdb       $wpdb         WordPress database abstraction object.
     4246 * @global WP_Network $current_site The current network.
    42464247 *
    42474248 * @return int The ID of the main network.
    42484249 */
    42494250function get_main_network_id() {
    4250         global $wpdb;
     4251        global $wpdb, $current_site;
    42514252
    42524253        if ( ! is_multisite() ) {
    42534254                return 1;
     
    42554256
    42564257        if ( defined( 'PRIMARY_NETWORK_ID' ) ) {
    42574258                $main_network_id = PRIMARY_NETWORK_ID;
    4258         } elseif ( 1 === (int) get_current_site()->id ) {
     4259        } elseif ( isset( $current_site->id ) && 1 === (int) $current_site->id ) {
    42594260                // If the current network has an ID of 1, assume it is the main network.
    42604261                $main_network_id = 1;
    42614262        } else {
  • src/wp-includes/load.php

     
    808808}
    809809
    810810/**
     811 * Retrieves the current network ID.
     812 *
     813 * @since 4.6.0
     814 *
     815 * @global WP_Network $current_site The current network.
     816 *
     817 * @return int The ID of the current network.
     818 */
     819function get_current_network_id() {
     820        global $current_site;
     821
     822        if ( ! is_multisite() ) {
     823                return 1;
     824        }
     825
     826        if ( ! isset( $current_site->id ) ) {
     827                return get_main_network_id();
     828        }
     829
     830        return absint( $current_site->id );
     831}
     832
     833/**
    811834 * Attempt an early load of translations.
    812835 *
    813836 * Used for errors encountered during the initial loading process, before