WordPress.org

Make WordPress Core

Changeset 38388


Ignore:
Timestamp:
08/26/16 21:34:36 (9 months ago)
Author:
wonderboymusic
Message:

Multisite: move get_current_site() to load.php so that it can be used in more places, instead of importing global $current_site.

See #37699.

Location:
trunk/src/wp-includes
Files:
6 edited

Legend:

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

    r38386 r38388  
    42764276 * @since 3.0.0 
    42774277 * 
    4278  * @global object $current_site 
    4279  * 
    42804278 * @param int $site_id Optional. Site ID to test. Defaults to current site. 
    42814279 * @return bool True if $site_id is the main site of the network, or if not 
     
    42834281 */ 
    42844282function is_main_site( $site_id = null ) { 
    4285     // This is the current network's information; 'site' is old terminology. 
    4286     global $current_site; 
    4287  
    4288     if ( ! is_multisite() ) 
     4283    if ( ! is_multisite() ) { 
    42894284        return true; 
    4290  
    4291     if ( ! $site_id ) 
     4285    } 
     4286 
     4287    if ( ! $site_id ) { 
    42924288        $site_id = get_current_blog_id(); 
    4293  
    4294     return (int) $site_id === (int) $current_site->blog_id; 
     4289    } 
     4290    return (int) $site_id === (int) get_current_site()->blog_id; 
    42954291} 
    42964292 
  • trunk/src/wp-includes/link-template.php

    r38369 r38388  
    32643264    $current_site = get_current_site(); 
    32653265 
    3266     if ( 'relative' == $scheme ) 
     3266    if ( 'relative' == $scheme ) { 
    32673267        $url = $current_site->path; 
    3268     else 
     3268    } else { 
    32693269        $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme ); 
    3270  
    3271     if ( $path && is_string( $path ) ) 
     3270    } 
     3271 
     3272    if ( $path && is_string( $path ) ) { 
    32723273        $url .= ltrim( $path, '/' ); 
     3274    } 
    32733275 
    32743276    /** 
     
    33103312        $scheme = is_ssl() && ! is_admin() ? 'https' : 'http'; 
    33113313 
    3312     if ( 'relative' == $scheme ) 
     3314    if ( 'relative' == $scheme ) { 
    33133315        $url = $current_site->path; 
    3314     else 
     3316    } else { 
    33153317        $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme ); 
    3316  
    3317     if ( $path && is_string( $path ) ) 
     3318    } 
     3319 
     3320    if ( $path && is_string( $path ) ) { 
    33183321        $url .= ltrim( $path, '/' ); 
     3322    } 
    33193323 
    33203324    /** 
  • trunk/src/wp-includes/load.php

    r38363 r38388  
    10601060    return ( $thing instanceof WP_Error ); 
    10611061} 
     1062 
     1063/** 
     1064 * Get the current network. 
     1065 * 
     1066 * Returns an object containing the 'id', 'domain', 'path', and 'site_name' 
     1067 * properties of the network being viewed. 
     1068 * 
     1069 * @see wpmu_current_site() 
     1070 * 
     1071 * @since MU 
     1072 * 
     1073 * @global WP_Network $current_site 
     1074 * 
     1075 * @return WP_Network 
     1076 */ 
     1077function get_current_site() { 
     1078    global $current_site; 
     1079    return $current_site; 
     1080} 
  • trunk/src/wp-includes/ms-blogs.php

    r38232 r38388  
    10841084 * @since 4.6.0 
    10851085 * 
    1086  * @global WP_Network $current_site 
    1087  * 
    10881086 * @param WP_Network|int|null $network Optional. Network to retrieve. Default is the current network. 
    10891087 * @return WP_Network|null The network object or null if not found. 
    10901088 */ 
    10911089function get_network( $network = null ) { 
    1092     global $current_site; 
     1090    $current_site = get_current_site(); 
    10931091    if ( empty( $network ) && isset( $current_site ) ) { 
    10941092        $network = $current_site; 
  • trunk/src/wp-includes/ms-functions.php

    r38201 r38388  
    13331333 */ 
    13341334function install_blog( $blog_id, $blog_title = '' ) { 
    1335     global $wpdb, $wp_roles, $current_site; 
    1336  
     1335    global $wpdb, $wp_roles; 
    13371336    // Cast for security 
    13381337    $blog_id = (int) $blog_id; 
     
    13621361            $siteurl = set_url_scheme( $siteurl, 'https' ); 
    13631362        } 
    1364         if ( 'https' === parse_url( get_home_url( $current_site->blog_id ), PHP_URL_SCHEME ) ) { 
     1363        if ( 'https' === parse_url( get_home_url( get_current_site()->blog_id ), PHP_URL_SCHEME ) ) { 
    13651364            $home = set_url_scheme( $home, 'https' ); 
    13661365        } 
     
    14991498    $message = $welcome_email; 
    15001499 
    1501     if ( empty( $current_site->site_name ) ) 
     1500    if ( empty( $current_site->site_name ) ) { 
    15021501        $current_site->site_name = 'WordPress'; 
     1502    } 
    15031503 
    15041504    /** 
     
    15901590    wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers ); 
    15911591    return true; 
    1592 } 
    1593  
    1594 /** 
    1595  * Get the current network. 
    1596  * 
    1597  * Returns an object containing the 'id', 'domain', 'path', and 'site_name' 
    1598  * properties of the network being viewed. 
    1599  * 
    1600  * @see wpmu_current_site() 
    1601  * 
    1602  * @since MU 
    1603  * 
    1604  * @global WP_Network $current_site 
    1605  * 
    1606  * @return WP_Network 
    1607  */ 
    1608 function get_current_site() { 
    1609     global $current_site; 
    1610     return $current_site; 
    16111592} 
    16121593 
  • trunk/src/wp-includes/option.php

    r38334 r38388  
    10711071 * 
    10721072 * @global wpdb   $wpdb 
    1073  * @global object $current_site 
    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 ) ) { 
     
    10891088    // Fallback to the current network if a network ID is not specified. 
    10901089    if ( ! $network_id && is_multisite() ) { 
    1091         $network_id = $current_site->id; 
     1090        $network_id = get_current_site()->id; 
    10921091    } 
    10931092 
     
    11881187 * 
    11891188 * @global wpdb   $wpdb 
    1190  * @global object $current_site 
    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 ) ) { 
     
    12061204    // Fallback to the current network if a network ID is not specified. 
    12071205    if ( ! $network_id && is_multisite() ) { 
    1208         $network_id = $current_site->id; 
     1206        $network_id = get_current_site()->id; 
    12091207    } 
    12101208 
     
    12981296 * 
    12991297 * @global wpdb   $wpdb 
    1300  * @global object $current_site 
    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 ) ) { 
     
    13151312    // Fallback to the current network if a network ID is not specified. 
    13161313    if ( ! $network_id && is_multisite() ) { 
    1317         $network_id = $current_site->id; 
     1314        $network_id = get_current_site()->id; 
    13181315    } 
    13191316 
     
    13801377 * 
    13811378 * @global wpdb   $wpdb 
    1382  * @global object $current_site 
    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 ) ) { 
     
    13981394    // Fallback to the current network if a network ID is not specified. 
    13991395    if ( ! $network_id && is_multisite() ) { 
    1400         $network_id = $current_site->id; 
     1396        $network_id = get_current_site()->id; 
    14011397    } 
    14021398 
Note: See TracChangeset for help on using the changeset viewer.