WordPress.org

Make WordPress Core

Ticket #33900: 33900.2.diff

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

     
    42554255                return 1;
    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;
    42634265        } 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        if ( ! is_multisite() ) {
     821                return 1;
     822        }
     823
     824        $current_site = get_current_site();
     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