Make WordPress Core

Ticket #37218: 37218.3.diff

File 37218.3.diff, 1.0 KB (added by spacedmonkey, 9 years ago)
  • src/wp-includes/functions.php

     
    42794279 *
    42804280 * @since 4.3.0
    42814281 *
    4282  * @global wpdb $wpdb WordPress database abstraction object.
    42834282 *
    42844283 * @return int The ID of the main network.
    42854284 */
    42864285function get_main_network_id() {
    4287         global $wpdb;
    42884286
    42894287        if ( ! is_multisite() ) {
    42904288                return 1;
     
    42984296                // If the current network has an ID of 1, assume it is the main network.
    42994297                $main_network_id = 1;
    43004298        } else {
    4301                 $main_network_id = wp_cache_get( 'primary_network_id', 'site-options' );
    4302 
    4303                 if ( false === $main_network_id ) {
    4304                         $main_network_id = (int) $wpdb->get_var( "SELECT id FROM {$wpdb->site} ORDER BY id LIMIT 1" );
    4305                         wp_cache_add( 'primary_network_id', $main_network_id, 'site-options' );
     4299                $_networks = get_networks( array( 'fields' => 'ids', 'number' => 1 ) );
     4300                if ( ! empty( $_networks ) ) {
     4301                        $main_network_id = array_shift( $_networks );
    43064302                }
    43074303        }
    43084304