Make WordPress Core


Ignore:
Timestamp:
10/19/2016 04:46:14 AM (8 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/option.php

    r38687 r38814  
    10701070 * @see get_option()
    10711071 *
    1072  * @global wpdb   $wpdb
    1073  * @global object $current_site
     1072 * @global wpdb $wpdb
    10741073 *
    10751074 * @param int      $network_id ID of the network. Can be null to default to the current network ID.
     
    10791078 */
    10801079function get_network_option( $network_id, $option, $default = false ) {
    1081     global $wpdb, $current_site;
     1080    global $wpdb;
    10821081
    10831082    if ( $network_id && ! is_numeric( $network_id ) ) {
     
    10881087
    10891088    // Fallback to the current network if a network ID is not specified.
    1090     if ( ! $network_id && is_multisite() ) {
    1091         $network_id = $current_site->id;
     1089    if ( ! $network_id ) {
     1090        $network_id = get_current_network_id();
    10921091    }
    10931092
     
    11871186 * @see add_option()
    11881187 *
    1189  * @global wpdb   $wpdb
    1190  * @global object $current_site
     1188 * @global wpdb $wpdb
    11911189 *
    11921190 * @param int    $network_id ID of the network. Can be null to default to the current network ID.
     
    11961194 */
    11971195function add_network_option( $network_id, $option, $value ) {
    1198     global $wpdb, $current_site;
     1196    global $wpdb;
    11991197
    12001198    if ( $network_id && ! is_numeric( $network_id ) ) {
     
    12051203
    12061204    // Fallback to the current network if a network ID is not specified.
    1207     if ( ! $network_id && is_multisite() ) {
    1208         $network_id = $current_site->id;
     1205    if ( ! $network_id ) {
     1206        $network_id = get_current_network_id();
    12091207    }
    12101208
     
    12971295 * @see delete_option()
    12981296 *
    1299  * @global wpdb   $wpdb
    1300  * @global object $current_site
     1297 * @global wpdb $wpdb
    13011298 *
    13021299 * @param int    $network_id ID of the network. Can be null to default to the current network ID.
     
    13051302 */
    13061303function delete_network_option( $network_id, $option ) {
    1307     global $wpdb, $current_site;
     1304    global $wpdb;
    13081305
    13091306    if ( $network_id && ! is_numeric( $network_id ) ) {
     
    13141311
    13151312    // Fallback to the current network if a network ID is not specified.
    1316     if ( ! $network_id && is_multisite() ) {
    1317         $network_id = $current_site->id;
     1313    if ( ! $network_id ) {
     1314        $network_id = get_current_network_id();
    13181315    }
    13191316
     
    13791376 * @see update_option()
    13801377 *
    1381  * @global wpdb   $wpdb
    1382  * @global object $current_site
     1378 * @global wpdb $wpdb
    13831379 *
    13841380 * @param int      $network_id ID of the network. Can be null to default to the current network ID.
     
    13881384 */
    13891385function update_network_option( $network_id, $option, $value ) {
    1390     global $wpdb, $current_site;
     1386    global $wpdb;
    13911387
    13921388    if ( $network_id && ! is_numeric( $network_id ) ) {
     
    13971393
    13981394    // Fallback to the current network if a network ID is not specified.
    1399     if ( ! $network_id && is_multisite() ) {
    1400         $network_id = $current_site->id;
     1395    if ( ! $network_id ) {
     1396        $network_id = get_current_network_id();
    14011397    }
    14021398
Note: See TracChangeset for help on using the changeset viewer.