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-admin/network/site-new.php

    r38721 r38814  
    8787
    8888    if ( is_subdomain_install() ) {
    89         $newdomain = $domain . '.' . preg_replace( '|^www\.|', '', $current_site->domain );
    90         $path      = $current_site->path;
     89        $newdomain = $domain . '.' . preg_replace( '|^www\.|', '', get_network()->domain );
     90        $path      = get_network()->path;
    9191    } else {
    92         $newdomain = $current_site->domain;
    93         $path      = $current_site->path . $domain . '/';
     92        $newdomain = get_network()->domain;
     93        $path      = get_network()->path . $domain . '/';
    9494    }
    9595
     
    127127
    128128    $wpdb->hide_errors();
    129     $id = wpmu_create_blog( $newdomain, $path, $title, $user_id, $meta, $current_site->id );
     129    $id = wpmu_create_blog( $newdomain, $path, $title, $user_id, $meta, get_current_network_id() );
    130130    $wpdb->show_errors();
    131131    if ( ! is_wp_error( $id ) ) {
     
    139139                /* translators: %s: network name */
    140140                __( '[%s] New Site Created' ),
    141                 $current_site->site_name
     141                get_network()->site_name
    142142            ),
    143143            sprintf(
     
    199199            <td>
    200200            <?php if ( is_subdomain_install() ) { ?>
    201                 <input name="blog[domain]" type="text" class="regular-text" id="site-address" aria-describedby="site-address-desc" autocapitalize="none" autocorrect="off"/><span class="no-break">.<?php echo preg_replace( '|^www\.|', '', $current_site->domain ); ?></span>
     201                <input name="blog[domain]" type="text" class="regular-text" id="site-address" aria-describedby="site-address-desc" autocapitalize="none" autocorrect="off"/><span class="no-break">.<?php echo preg_replace( '|^www\.|', '', get_network()->domain ); ?></span>
    202202            <?php } else {
    203                 echo $current_site->domain . $current_site->path ?><input name="blog[domain]" type="text" class="regular-text" id="site-address" aria-describedby="site-address-desc"  autocapitalize="none" autocorrect="off" />
     203                echo get_network()->domain . get_network()->path ?><input name="blog[domain]" type="text" class="regular-text" id="site-address" aria-describedby="site-address-desc"  autocapitalize="none" autocorrect="off" />
    204204            <?php }
    205205            echo '<p class="description" id="site-address-desc">' . __( 'Only lowercase letters (a-z), numbers, and hyphens are allowed.' ) . '</p>';
Note: See TracChangeset for help on using the changeset viewer.