Make WordPress Core

Changeset 26120


Ignore:
Timestamp:
11/13/2013 03:22:48 AM (11 years ago)
Author:
SergeyBiryukov
Message:

Use get_current_site() instead of the $current_site global when possible.

props jeremyfelt.
fixes #25158.

Location:
trunk/src
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/admin-header.php

    r26072 r26120  
    1313// In case admin-header.php is included in a function.
    1414global $title, $hook_suffix, $current_screen, $wp_locale, $pagenow, $wp_version,
    15     $current_site, $update_title, $total_update_count, $parent_file;
     15    $update_title, $total_update_count, $parent_file;
     16
     17$current_site = get_current_site();
    1618
    1719// Catch plugins that include admin-header.php before admin.php completes.
  • trunk/src/wp-admin/includes/class-wp-ms-sites-list-table.php

    r25125 r26120  
    2222
    2323    function prepare_items() {
    24         global $s, $mode, $wpdb, $current_site;
     24        global $s, $mode, $wpdb;
     25
     26        $current_site = get_current_site();
    2527
    2628        $mode = ( empty( $_REQUEST['mode'] ) ) ? 'list' : $_REQUEST['mode'];
     
    169171
    170172    function display_rows() {
    171         global $current_site, $mode;
     173        global $mode;
    172174
    173175        $status_list = array(
     
    203205            echo "<tr class='$class'>";
    204206
    205             $blogname = ( is_subdomain_install() ) ? str_replace( '.'.$current_site->domain, '', $blog['domain'] ) : $blog['path'];
     207            $blogname = ( is_subdomain_install() ) ? str_replace( '.' . get_current_site()->domain, '', $blog['domain'] ) : $blog['path'];
    206208
    207209            list( $columns, $hidden ) = $this->get_column_info();
     
    252254                            $actions['edit']    = '<span class="edit"><a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a></span>';
    253255                            $actions['backend'] = "<span class='backend'><a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a></span>';
    254                             if ( $current_site->blog_id != $blog['blog_id'] ) {
     256                            if ( get_current_site()->blog_id != $blog['blog_id'] ) {
    255257                                if ( get_blog_status( $blog['blog_id'], 'deleted' ) == '1' )
    256258                                    $actions['activate']    = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to activate the site %s' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Activate' ) . '</a></span>';
  • trunk/src/wp-admin/includes/class-wp-ms-users-list-table.php

    r23563 r26120  
    134134
    135135    function display_rows() {
    136         global $current_site, $mode;
     136        global $mode;
    137137
    138138        $alt = '';
     
    224224                                    $path   = ( $val->path == '/' ) ? '' : $val->path;
    225225                                    echo '<span class="site-' . $val->site_id . '" >';
    226                                     echo '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . str_replace( '.' . $current_site->domain, '', $val->domain . $path ) . '</a>';
     226                                    echo '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . str_replace( '.' . get_current_site()->domain, '', $val->domain . $path ) . '</a>';
    227227                                    echo ' <small class="row-actions">';
    228228                                    $actions = array();
  • trunk/src/wp-admin/includes/ms.php

    r26115 r26120  
    5353 */
    5454function wpmu_delete_blog( $blog_id, $drop = false ) {
    55     global $wpdb, $current_site;
     55    global $wpdb;
    5656
    5757    $switch = false;
     
    8282
    8383    update_blog_status( $blog_id, 'deleted', 1 );
     84
     85    $current_site = get_current_site();
    8486
    8587    // Don't destroy the initial, main, or root blog.
  • trunk/src/wp-admin/includes/schema.php

    r25938 r26120  
    328328 */
    329329function populate_options() {
    330     global $wpdb, $wp_db_version, $current_site, $wp_current_db_version;
     330    global $wpdb, $wp_db_version, $wp_current_db_version;
    331331
    332332    $guessurl = wp_guess_url();
     
    496496    if ( is_multisite() ) {
    497497        /* translators: blog tagline */
    498         $options[ 'blogdescription' ] = sprintf(__('Just another %s site'), $current_site->site_name );
     498        $options[ 'blogdescription' ] = sprintf(__('Just another %s site'), get_current_site()->site_name );
    499499        $options[ 'permalink_structure' ] = '/%year%/%monthnum%/%day%/%postname%/';
    500500    }
  • trunk/src/wp-admin/includes/upgrade.php

    r26024 r26120  
    101101 * @param int $user_id User ID.
    102102 */
    103 function wp_install_defaults($user_id) {
    104     global $wpdb, $wp_rewrite, $current_site, $table_prefix;
     103function wp_install_defaults( $user_id ) {
     104    global $wpdb, $wp_rewrite, $table_prefix;
    105105
    106106    // Default category
     
    136136
    137137        $first_post = str_replace( "SITE_URL", esc_url( network_home_url() ), $first_post );
    138         $first_post = str_replace( "SITE_NAME", $current_site->site_name, $first_post );
     138        $first_post = str_replace( "SITE_NAME", get_current_site()->site_name, $first_post );
    139139    } else {
    140140        $first_post = __('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!');
  • trunk/src/wp-includes/admin-bar.php

    r26072 r26120  
    244244 */
    245245function wp_admin_bar_site_menu( $wp_admin_bar ) {
    246     global $current_site;
    247 
    248246    // Don't show for logged out users.
    249247    if ( ! is_user_logged_in() )
     
    260258
    261259    if ( is_network_admin() ) {
    262         $blogname = sprintf( __('Network Admin: %s'), esc_html( $current_site->site_name ) );
     260        $blogname = sprintf( __('Network Admin: %s'), esc_html( get_current_site()->site_name ) );
    263261    } elseif ( is_user_admin() ) {
    264         $blogname = sprintf( __('Global Dashboard: %s'), esc_html( $current_site->site_name ) );
     262        $blogname = sprintf( __('Global Dashboard: %s'), esc_html( get_current_site()->site_name ) );
    265263    }
    266264
  • trunk/src/wp-includes/class-wp-xmlrpc-server.php

    r25133 r26120  
    460460     */
    461461    function wp_getUsersBlogs( $args ) {
    462         global $current_site;
    463462        // If this isn't on WPMU then just use blogger_getUsersBlogs
    464463        if ( !is_multisite() ) {
     
    482481        foreach ( $blogs as $blog ) {
    483482            // Don't include blogs that aren't hosted at this site
    484             if ( $blog->site_id != $current_site->id )
     483            if ( $blog->site_id != get_current_site()->id )
    485484                continue;
    486485
  • trunk/src/wp-includes/http.php

    r25302 r26120  
    546546 */
    547547function ms_allowed_http_request_hosts( $is_external, $host ) {
    548     global $wpdb, $current_site;
     548    global $wpdb;
    549549    static $queried = array();
    550550    if ( $is_external )
    551551        return $is_external;
    552     if ( $host === $current_site->domain )
     552    if ( $host === get_current_site()->domain )
    553553        return true;
    554554    if ( isset( $queried[ $host ] ) )
  • trunk/src/wp-includes/link-template.php

    r26081 r26120  
    21882188*/
    21892189function network_site_url( $path = '', $scheme = null ) {
    2190     global $current_site;
    2191 
    21922190    if ( ! is_multisite() )
    21932191        return site_url($path, $scheme);
     2192
     2193    $current_site = get_current_site();
    21942194
    21952195    if ( 'relative' == $scheme )
     
    22192219*/
    22202220function network_home_url( $path = '', $scheme = null ) {
    2221     global $current_site;
    2222 
    22232221    if ( ! is_multisite() )
    22242222        return home_url($path, $scheme);
    22252223
     2224    $current_site = get_current_site();
    22262225    $orig_scheme = $scheme;
    22272226
  • trunk/src/wp-includes/ms-blogs.php

    r25615 r26120  
    6565 */
    6666function get_id_from_blogname( $slug ) {
    67     global $wpdb, $current_site;
    68 
     67    global $wpdb;
     68
     69    $current_site = get_current_site();
    6970    $slug = trim( $slug, '/' );
    7071
  • trunk/src/wp-includes/ms-default-constants.php

    r23005 r26120  
    4646 */
    4747function ms_cookie_constants(  ) {
    48     global $current_site;
     48    $current_site = get_current_site();
    4949
    5050    /**
  • trunk/src/wp-includes/ms-functions.php

    r25862 r26120  
    536536 * @return array Contains the new site data and error messages.
    537537 */
    538 function wpmu_validate_blog_signup($blogname, $blog_title, $user = '') {
    539     global $wpdb, $domain, $current_site;
    540 
     538function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {
     539    global $wpdb, $domain;
     540
     541    $current_site = get_current_site();
    541542    $base = $current_site->path;
    542543
     
    710711 */
    711712function wpmu_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key, $meta = array() ) {
    712     global $current_site;
    713 
    714713    if ( !apply_filters('wpmu_signup_blog_notification', $domain, $path, $title, $user, $user_email, $key, $meta) )
    715714        return false;
    716715
    717716    // Send email with activation link.
    718     if ( !is_subdomain_install() || $current_site->id != 1 )
     717    if ( !is_subdomain_install() || get_current_site()->id != 1 )
    719718        $activate_url = network_site_url("wp-activate.php?key=$key");
    720719    else
     
    11231122 * @param string $blog_title The title of the new site.
    11241123 */
    1125 function install_blog($blog_id, $blog_title = '') {
    1126     global $wpdb, $wp_roles, $current_site;
     1124function install_blog( $blog_id, $blog_title = '' ) {
     1125    global $wpdb, $wp_roles;
    11271126
    11281127    // Cast for security
     
    11521151        update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" );
    11531152    else
    1154         update_option( 'upload_path', get_blog_option( $current_site->blog_id, 'upload_path' ) );
     1153        update_option( 'upload_path', get_blog_option( get_current_site()->blog_id, 'upload_path' ) );
    11551154
    11561155    update_option( 'blogname', wp_unslash( $blog_title ) );
     
    12061205 */
    12071206function wpmu_welcome_notification( $blog_id, $user_id, $password, $title, $meta = array() ) {
    1208     global $current_site;
     1207    $current_site = get_current_site();
    12091208
    12101209    if ( !apply_filters('wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta) )
     
    12701269 */
    12711270function wpmu_welcome_user_notification( $user_id, $password, $meta = array() ) {
    1272     global $current_site;
     1271    $current_site = get_current_site();
    12731272
    12741273    if ( !apply_filters('wpmu_welcome_user_notification', $user_id, $password, $meta) )
     
    15611560 */
    15621561function redirect_this_site( $deprecated = '' ) {
    1563     global $current_site;
    1564     return array( $current_site->domain );
     1562    return array( get_current_site()->domain );
    15651563}
    15661564
     
    16901688 */
    16911689function add_new_user_to_blog( $user_id, $password, $meta ) {
    1692     global $current_site;
    16931690    if ( !empty( $meta[ 'add_to_blog' ] ) ) {
    16941691        $blog_id = $meta[ 'add_to_blog' ];
    16951692        $role = $meta[ 'new_role' ];
    1696         remove_user_from_blog($user_id, $current_site->blog_id); // remove user from main blog.
     1693        remove_user_from_blog($user_id, get_current_site()->blog_id); // remove user from main blog.
    16971694        add_user_to_blog( $blog_id, $user_id, $role );
    16981695        update_user_meta( $user_id, 'primary_blog', $blog_id );
     
    17061703 */
    17071704function fix_phpmailer_messageid( $phpmailer ) {
    1708     global $current_site;
    1709     $phpmailer->Hostname = $current_site->domain;
     1705    $phpmailer->Hostname = get_current_site()->domain;
    17101706}
    17111707
  • trunk/src/wp-includes/ms-load.php

    r25991 r26120  
    7272 */
    7373function ms_site_check() {
    74     global $wpdb, $current_site;
    75 
    7674    $blog = get_blog_details();
    7775
     
    102100            return WP_CONTENT_DIR . '/blog-inactive.php';
    103101        else
    104             wp_die( sprintf( __( 'This site has not been activated yet. If you are having problems activating your site, please contact <a href="mailto:%1$s">%1$s</a>.' ), str_replace( '@', ' AT ', get_site_option( 'admin_email', "support@{$current_site->domain}" ) ) ) );
     102            wp_die( sprintf( __( 'This site has not been activated yet. If you are having problems activating your site, please contact <a href="mailto:%1$s">%1$s</a>.' ), str_replace( '@', ' AT ', get_site_option( 'admin_email', 'support@' . get_current_site()->domain ) ) ) );
    105103    }
    106104
  • trunk/src/wp-login.php

    r25991 r26120  
    3131 * @param WP_Error $wp_error Optional. WordPress Error Object
    3232 */
    33 function login_header($title = 'Log In', $message = '', $wp_error = '') {
    34     global $error, $interim_login, $current_site, $action;
     33function login_header( $title = 'Log In', $message = '', $wp_error = '' ) {
     34    global $error, $interim_login, $action;
    3535
    3636    // Don't index any of these forms
     
    9191    if ( is_multisite() ) {
    9292        $login_header_url   = network_home_url();
    93         $login_header_title = $current_site->site_name;
     93        $login_header_title = get_current_site()->site_name;
    9494    } else {
    9595        $login_header_url   = __( 'http://wordpress.org/' );
     
    263263 */
    264264function retrieve_password() {
    265     global $wpdb, $current_site, $wp_hasher;
     265    global $wpdb, $wp_hasher;
    266266
    267267    $errors = new WP_Error();
  • trunk/src/wp-signup.php

    r25868 r26120  
    8888 * @param array $errors
    8989 */
    90 function show_blog_form($blogname = '', $blog_title = '', $errors = '') {
    91     global $current_site;
     90function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
     91    $current_site = get_current_site();
    9292    // Blog name
    9393    if ( !is_subdomain_install() )
     
    226226 * @param array $errors
    227227 */
    228 function signup_another_blog($blogname = '', $blog_title = '', $errors = '') {
    229     global $current_site;
     228function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) {
    230229    $current_user = wp_get_current_user();
    231230
     
    259258    $errors = $filtered_results['errors'];
    260259
    261     echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), $current_site->site_name ) . '</h2>';
     260    echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_current_site()->site_name ) . '</h2>';
    262261
    263262    if ( $errors->get_error_code() ) {
     
    396395 * @param array $errors
    397396 */
    398 function signup_user($user_name = '', $user_email = '', $errors = '') {
    399     global $current_site, $active_signup;
     397function signup_user( $user_name = '', $user_email = '', $errors = '' ) {
     398    global $active_signup;
    400399
    401400    if ( !is_wp_error($errors) )
     
    430429    ?>
    431430
    432     <h2><?php printf( __( 'Get your own %s account in seconds' ), $current_site->site_name ) ?></h2>
     431    <h2><?php printf( __( 'Get your own %s account in seconds' ), get_current_site()->site_name ) ?></h2>
    433432    <form id="setupform" method="post" action="wp-signup.php">
    434433        <input type="hidden" name="stage" value="validate-user-signup" />
Note: See TracChangeset for help on using the changeset viewer.