WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/19/2016 04:46:14 AM (3 years ago)
Author:
jeremyfelt
Message:

Multisite: Use get_network() and get_current_network_id() for current network data.

get_network() falls back to the current network when called without any arguments. Between this and get_current_network_id(), we can replace almost all instances of the global $current_site and all instances of get_current_site().

This effectively deprecates get_current_site(), something that we'll do in a future ticket.

Props flixos90.
Fixes #37414.

File:
1 edited

Legend:

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

    r38636 r38814  
    815815 * @since 4.6.0
    816816 *
    817  * @global WP_Network $current_site The current network.
    818  *
    819817 * @return int The ID of the current network.
    820818 */
     
    824822    }
    825823
    826     $current_site = get_current_site();
    827 
    828     if ( ! isset( $current_site->id ) ) {
     824    $current_network = get_network();
     825
     826    if ( ! isset( $current_network->id ) ) {
    829827        return get_main_network_id();
    830828    }
    831829
    832     return absint( $current_site->id );
     830    return absint( $current_network->id );
    833831}
    834832
Note: See TracChangeset for help on using the changeset viewer.