Use get_current_site() instead of the $current_site global when possible.
props jeremyfelt. fixes #25158. Built from https://develop.svn.wordpress.org/trunk@26120 git-svn-id: http://core.svn.wordpress.org/trunk@26032 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
fdc8f7dcff
commit
74f77b85a6
|
@ -12,7 +12,9 @@ if ( ! defined( 'WP_ADMIN' ) )
|
|||
|
||||
// In case admin-header.php is included in a function.
|
||||
global $title, $hook_suffix, $current_screen, $wp_locale, $pagenow, $wp_version,
|
||||
$current_site, $update_title, $total_update_count, $parent_file;
|
||||
$update_title, $total_update_count, $parent_file;
|
||||
|
||||
$current_site = get_current_site();
|
||||
|
||||
// Catch plugins that include admin-header.php before admin.php completes.
|
||||
if ( empty( $current_screen ) )
|
||||
|
|
|
@ -21,7 +21,9 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
|||
}
|
||||
|
||||
function prepare_items() {
|
||||
global $s, $mode, $wpdb, $current_site;
|
||||
global $s, $mode, $wpdb;
|
||||
|
||||
$current_site = get_current_site();
|
||||
|
||||
$mode = ( empty( $_REQUEST['mode'] ) ) ? 'list' : $_REQUEST['mode'];
|
||||
|
||||
|
@ -168,7 +170,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
|||
}
|
||||
|
||||
function display_rows() {
|
||||
global $current_site, $mode;
|
||||
global $mode;
|
||||
|
||||
$status_list = array(
|
||||
'archived' => array( 'site-archived', __( 'Archived' ) ),
|
||||
|
@ -202,7 +204,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
|||
}
|
||||
echo "<tr class='$class'>";
|
||||
|
||||
$blogname = ( is_subdomain_install() ) ? str_replace( '.'.$current_site->domain, '', $blog['domain'] ) : $blog['path'];
|
||||
$blogname = ( is_subdomain_install() ) ? str_replace( '.' . get_current_site()->domain, '', $blog['domain'] ) : $blog['path'];
|
||||
|
||||
list( $columns, $hidden ) = $this->get_column_info();
|
||||
|
||||
|
@ -251,7 +253,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
|||
|
||||
$actions['edit'] = '<span class="edit"><a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a></span>';
|
||||
$actions['backend'] = "<span class='backend'><a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a></span>';
|
||||
if ( $current_site->blog_id != $blog['blog_id'] ) {
|
||||
if ( get_current_site()->blog_id != $blog['blog_id'] ) {
|
||||
if ( get_blog_status( $blog['blog_id'], 'deleted' ) == '1' )
|
||||
$actions['activate'] = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=activateblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to activate the site %s' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Activate' ) . '</a></span>';
|
||||
else
|
||||
|
|
|
@ -133,7 +133,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
|||
}
|
||||
|
||||
function display_rows() {
|
||||
global $current_site, $mode;
|
||||
global $mode;
|
||||
|
||||
$alt = '';
|
||||
$super_admins = get_super_admins();
|
||||
|
@ -223,7 +223,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
|||
|
||||
$path = ( $val->path == '/' ) ? '' : $val->path;
|
||||
echo '<span class="site-' . $val->site_id . '" >';
|
||||
echo '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . str_replace( '.' . $current_site->domain, '', $val->domain . $path ) . '</a>';
|
||||
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>';
|
||||
echo ' <small class="row-actions">';
|
||||
$actions = array();
|
||||
$actions['edit'] = '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . __( 'Edit' ) . '</a>';
|
||||
|
|
|
@ -52,7 +52,7 @@ add_filter( 'wp_handle_upload_prefilter', 'check_upload_size' );
|
|||
* @return void
|
||||
*/
|
||||
function wpmu_delete_blog( $blog_id, $drop = false ) {
|
||||
global $wpdb, $current_site;
|
||||
global $wpdb;
|
||||
|
||||
$switch = false;
|
||||
if ( get_current_blog_id() != $blog_id ) {
|
||||
|
@ -82,6 +82,8 @@ function wpmu_delete_blog( $blog_id, $drop = false ) {
|
|||
|
||||
update_blog_status( $blog_id, 'deleted', 1 );
|
||||
|
||||
$current_site = get_current_site();
|
||||
|
||||
// Don't destroy the initial, main, or root blog.
|
||||
if ( $drop && ( 1 == $blog_id || is_main_site( $blog_id ) || ( $blog->path == $current_site->path && $blog->domain == $current_site->domain ) ) )
|
||||
$drop = false;
|
||||
|
|
|
@ -327,7 +327,7 @@ $wp_queries = wp_get_db_schema( 'all' );
|
|||
* @uses $wp_db_version
|
||||
*/
|
||||
function populate_options() {
|
||||
global $wpdb, $wp_db_version, $current_site, $wp_current_db_version;
|
||||
global $wpdb, $wp_db_version, $wp_current_db_version;
|
||||
|
||||
$guessurl = wp_guess_url();
|
||||
/**
|
||||
|
@ -495,7 +495,7 @@ function populate_options() {
|
|||
// 3.0 multisite
|
||||
if ( is_multisite() ) {
|
||||
/* translators: blog tagline */
|
||||
$options[ 'blogdescription' ] = sprintf(__('Just another %s site'), $current_site->site_name );
|
||||
$options[ 'blogdescription' ] = sprintf(__('Just another %s site'), get_current_site()->site_name );
|
||||
$options[ 'permalink_structure' ] = '/%year%/%monthnum%/%day%/%postname%/';
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ if ( !function_exists('wp_install_defaults') ) :
|
|||
* @param int $user_id User ID.
|
||||
*/
|
||||
function wp_install_defaults( $user_id ) {
|
||||
global $wpdb, $wp_rewrite, $current_site, $table_prefix;
|
||||
global $wpdb, $wp_rewrite, $table_prefix;
|
||||
|
||||
// Default category
|
||||
$cat_name = __('Uncategorized');
|
||||
|
@ -135,7 +135,7 @@ function wp_install_defaults($user_id) {
|
|||
$first_post = __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' );
|
||||
|
||||
$first_post = str_replace( "SITE_URL", esc_url( network_home_url() ), $first_post );
|
||||
$first_post = str_replace( "SITE_NAME", $current_site->site_name, $first_post );
|
||||
$first_post = str_replace( "SITE_NAME", get_current_site()->site_name, $first_post );
|
||||
} else {
|
||||
$first_post = __('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!');
|
||||
}
|
||||
|
|
|
@ -243,8 +243,6 @@ function wp_admin_bar_my_account_menu( $wp_admin_bar ) {
|
|||
* @param WP_Admin_Bar $wp_admin_bar
|
||||
*/
|
||||
function wp_admin_bar_site_menu( $wp_admin_bar ) {
|
||||
global $current_site;
|
||||
|
||||
// Don't show for logged out users.
|
||||
if ( ! is_user_logged_in() )
|
||||
return;
|
||||
|
@ -259,9 +257,9 @@ function wp_admin_bar_site_menu( $wp_admin_bar ) {
|
|||
$blogname = preg_replace( '#^(https?://)?(www.)?#', '', get_home_url() );
|
||||
|
||||
if ( is_network_admin() ) {
|
||||
$blogname = sprintf( __('Network Admin: %s'), esc_html( $current_site->site_name ) );
|
||||
$blogname = sprintf( __('Network Admin: %s'), esc_html( get_current_site()->site_name ) );
|
||||
} elseif ( is_user_admin() ) {
|
||||
$blogname = sprintf( __('Global Dashboard: %s'), esc_html( $current_site->site_name ) );
|
||||
$blogname = sprintf( __('Global Dashboard: %s'), esc_html( get_current_site()->site_name ) );
|
||||
}
|
||||
|
||||
$title = wp_html_excerpt( $blogname, 40, '…' );
|
||||
|
|
|
@ -459,7 +459,6 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
* - 'xmlrpc' - url of xmlrpc endpoint
|
||||
*/
|
||||
function wp_getUsersBlogs( $args ) {
|
||||
global $current_site;
|
||||
// If this isn't on WPMU then just use blogger_getUsersBlogs
|
||||
if ( !is_multisite() ) {
|
||||
array_unshift( $args, 1 );
|
||||
|
@ -481,7 +480,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
|
||||
foreach ( $blogs as $blog ) {
|
||||
// Don't include blogs that aren't hosted at this site
|
||||
if ( $blog->site_id != $current_site->id )
|
||||
if ( $blog->site_id != get_current_site()->id )
|
||||
continue;
|
||||
|
||||
$blog_id = $blog->userblog_id;
|
||||
|
|
|
@ -545,11 +545,11 @@ function allowed_http_request_hosts( $is_external, $host ) {
|
|||
* @return bool
|
||||
*/
|
||||
function ms_allowed_http_request_hosts( $is_external, $host ) {
|
||||
global $wpdb, $current_site;
|
||||
global $wpdb;
|
||||
static $queried = array();
|
||||
if ( $is_external )
|
||||
return $is_external;
|
||||
if ( $host === $current_site->domain )
|
||||
if ( $host === get_current_site()->domain )
|
||||
return true;
|
||||
if ( isset( $queried[ $host ] ) )
|
||||
return $queried[ $host ];
|
||||
|
|
|
@ -2187,11 +2187,11 @@ function plugins_url($path = '', $plugin = '') {
|
|||
* @return string Site url link with optional path appended.
|
||||
*/
|
||||
function network_site_url( $path = '', $scheme = null ) {
|
||||
global $current_site;
|
||||
|
||||
if ( ! is_multisite() )
|
||||
return site_url($path, $scheme);
|
||||
|
||||
$current_site = get_current_site();
|
||||
|
||||
if ( 'relative' == $scheme )
|
||||
$url = $current_site->path;
|
||||
else
|
||||
|
@ -2218,11 +2218,10 @@ function network_site_url( $path = '', $scheme = null ) {
|
|||
* @return string Home url link with optional path appended.
|
||||
*/
|
||||
function network_home_url( $path = '', $scheme = null ) {
|
||||
global $current_site;
|
||||
|
||||
if ( ! is_multisite() )
|
||||
return home_url($path, $scheme);
|
||||
|
||||
$current_site = get_current_site();
|
||||
$orig_scheme = $scheme;
|
||||
|
||||
if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) )
|
||||
|
|
|
@ -64,8 +64,9 @@ function get_blogaddress_by_name( $blogname ) {
|
|||
* @return int A blog id
|
||||
*/
|
||||
function get_id_from_blogname( $slug ) {
|
||||
global $wpdb, $current_site;
|
||||
global $wpdb;
|
||||
|
||||
$current_site = get_current_site();
|
||||
$slug = trim( $slug, '/' );
|
||||
|
||||
$blog_id = wp_cache_get( 'get_id_from_blogname_' . $slug, 'blog-details' );
|
||||
|
|
|
@ -45,7 +45,7 @@ function ms_upload_constants() {
|
|||
* @since 3.0.0
|
||||
*/
|
||||
function ms_cookie_constants( ) {
|
||||
global $current_site;
|
||||
$current_site = get_current_site();
|
||||
|
||||
/**
|
||||
* @since 1.2.0
|
||||
|
|
|
@ -536,8 +536,9 @@ function wpmu_validate_user_signup($user_name, $user_email) {
|
|||
* @return array Contains the new site data and error messages.
|
||||
*/
|
||||
function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {
|
||||
global $wpdb, $domain, $current_site;
|
||||
global $wpdb, $domain;
|
||||
|
||||
$current_site = get_current_site();
|
||||
$base = $current_site->path;
|
||||
|
||||
$blog_title = strip_tags( $blog_title );
|
||||
|
@ -709,13 +710,11 @@ function wpmu_signup_user( $user, $user_email, $meta = array() ) {
|
|||
* @return bool
|
||||
*/
|
||||
function wpmu_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key, $meta = array() ) {
|
||||
global $current_site;
|
||||
|
||||
if ( !apply_filters('wpmu_signup_blog_notification', $domain, $path, $title, $user, $user_email, $key, $meta) )
|
||||
return false;
|
||||
|
||||
// Send email with activation link.
|
||||
if ( !is_subdomain_install() || $current_site->id != 1 )
|
||||
if ( !is_subdomain_install() || get_current_site()->id != 1 )
|
||||
$activate_url = network_site_url("wp-activate.php?key=$key");
|
||||
else
|
||||
$activate_url = "http://{$domain}{$path}wp-activate.php?key=$key"; // @todo use *_url() API
|
||||
|
@ -1123,7 +1122,7 @@ function insert_blog($domain, $path, $site_id) {
|
|||
* @param string $blog_title The title of the new site.
|
||||
*/
|
||||
function install_blog( $blog_id, $blog_title = '' ) {
|
||||
global $wpdb, $wp_roles, $current_site;
|
||||
global $wpdb, $wp_roles;
|
||||
|
||||
// Cast for security
|
||||
$blog_id = (int) $blog_id;
|
||||
|
@ -1151,7 +1150,7 @@ function install_blog($blog_id, $blog_title = '') {
|
|||
if ( get_site_option( 'ms_files_rewriting' ) )
|
||||
update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" );
|
||||
else
|
||||
update_option( 'upload_path', get_blog_option( $current_site->blog_id, 'upload_path' ) );
|
||||
update_option( 'upload_path', get_blog_option( get_current_site()->blog_id, 'upload_path' ) );
|
||||
|
||||
update_option( 'blogname', wp_unslash( $blog_title ) );
|
||||
update_option( 'admin_email', '' );
|
||||
|
@ -1205,7 +1204,7 @@ function install_blog_defaults($blog_id, $user_id) {
|
|||
* @return bool
|
||||
*/
|
||||
function wpmu_welcome_notification( $blog_id, $user_id, $password, $title, $meta = array() ) {
|
||||
global $current_site;
|
||||
$current_site = get_current_site();
|
||||
|
||||
if ( !apply_filters('wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta) )
|
||||
return false;
|
||||
|
@ -1269,7 +1268,7 @@ We hope you enjoy your new site. Thanks!
|
|||
* @return bool
|
||||
*/
|
||||
function wpmu_welcome_user_notification( $user_id, $password, $meta = array() ) {
|
||||
global $current_site;
|
||||
$current_site = get_current_site();
|
||||
|
||||
if ( !apply_filters('wpmu_welcome_user_notification', $user_id, $password, $meta) )
|
||||
return false;
|
||||
|
@ -1560,8 +1559,7 @@ function global_terms( $term_id, $deprecated = '' ) {
|
|||
* @return array The current site's domain
|
||||
*/
|
||||
function redirect_this_site( $deprecated = '' ) {
|
||||
global $current_site;
|
||||
return array( $current_site->domain );
|
||||
return array( get_current_site()->domain );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1689,11 +1687,10 @@ function add_existing_user_to_blog( $details = false ) {
|
|||
* @param array $meta
|
||||
*/
|
||||
function add_new_user_to_blog( $user_id, $password, $meta ) {
|
||||
global $current_site;
|
||||
if ( !empty( $meta[ 'add_to_blog' ] ) ) {
|
||||
$blog_id = $meta[ 'add_to_blog' ];
|
||||
$role = $meta[ 'new_role' ];
|
||||
remove_user_from_blog($user_id, $current_site->blog_id); // remove user from main blog.
|
||||
remove_user_from_blog($user_id, get_current_site()->blog_id); // remove user from main blog.
|
||||
add_user_to_blog( $blog_id, $user_id, $role );
|
||||
update_user_meta( $user_id, 'primary_blog', $blog_id );
|
||||
}
|
||||
|
@ -1705,8 +1702,7 @@ function add_new_user_to_blog( $user_id, $password, $meta ) {
|
|||
* @since MU
|
||||
*/
|
||||
function fix_phpmailer_messageid( $phpmailer ) {
|
||||
global $current_site;
|
||||
$phpmailer->Hostname = $current_site->domain;
|
||||
$phpmailer->Hostname = get_current_site()->domain;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -71,8 +71,6 @@ function wp_get_active_network_plugins() {
|
|||
* @return bool|string Returns true on success, or drop-in file to include.
|
||||
*/
|
||||
function ms_site_check() {
|
||||
global $wpdb, $current_site;
|
||||
|
||||
$blog = get_blog_details();
|
||||
|
||||
/**
|
||||
|
@ -101,7 +99,7 @@ function ms_site_check() {
|
|||
if ( file_exists( WP_CONTENT_DIR . '/blog-inactive.php' ) )
|
||||
return WP_CONTENT_DIR . '/blog-inactive.php';
|
||||
else
|
||||
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}" ) ) ) );
|
||||
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 ) ) ) );
|
||||
}
|
||||
|
||||
if ( $blog->archived == '1' || $blog->spam == '1' ) {
|
||||
|
|
|
@ -31,7 +31,7 @@ if ( force_ssl_admin() && ! is_ssl() ) {
|
|||
* @param WP_Error $wp_error Optional. WordPress Error Object
|
||||
*/
|
||||
function login_header( $title = 'Log In', $message = '', $wp_error = '' ) {
|
||||
global $error, $interim_login, $current_site, $action;
|
||||
global $error, $interim_login, $action;
|
||||
|
||||
// Don't index any of these forms
|
||||
add_action( 'login_head', 'wp_no_robots' );
|
||||
|
@ -90,7 +90,7 @@ function login_header($title = 'Log In', $message = '', $wp_error = '') {
|
|||
|
||||
if ( is_multisite() ) {
|
||||
$login_header_url = network_home_url();
|
||||
$login_header_title = $current_site->site_name;
|
||||
$login_header_title = get_current_site()->site_name;
|
||||
} else {
|
||||
$login_header_url = __( 'http://wordpress.org/' );
|
||||
$login_header_title = __( 'Powered by WordPress' );
|
||||
|
@ -262,7 +262,7 @@ function wp_login_viewport_meta() {
|
|||
* @return bool|WP_Error True: when finish. WP_Error on error
|
||||
*/
|
||||
function retrieve_password() {
|
||||
global $wpdb, $current_site, $wp_hasher;
|
||||
global $wpdb, $wp_hasher;
|
||||
|
||||
$errors = new WP_Error();
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ do_action( 'before_signup_form' );
|
|||
* @param array $errors
|
||||
*/
|
||||
function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
|
||||
global $current_site;
|
||||
$current_site = get_current_site();
|
||||
// Blog name
|
||||
if ( !is_subdomain_install() )
|
||||
echo '<label for="blogname">' . __('Site Name:') . '</label>';
|
||||
|
@ -226,7 +226,6 @@ function validate_user_form() {
|
|||
* @param array $errors
|
||||
*/
|
||||
function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) {
|
||||
global $current_site;
|
||||
$current_user = wp_get_current_user();
|
||||
|
||||
if ( ! is_wp_error($errors) ) {
|
||||
|
@ -258,7 +257,7 @@ function signup_another_blog($blogname = '', $blog_title = '', $errors = '') {
|
|||
$blog_title = $filtered_results['blog_title'];
|
||||
$errors = $filtered_results['errors'];
|
||||
|
||||
echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), $current_site->site_name ) . '</h2>';
|
||||
echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_current_site()->site_name ) . '</h2>';
|
||||
|
||||
if ( $errors->get_error_code() ) {
|
||||
echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>';
|
||||
|
@ -396,7 +395,7 @@ function confirm_another_blog_signup( $domain, $path, $blog_title, $user_name, $
|
|||
* @param array $errors
|
||||
*/
|
||||
function signup_user( $user_name = '', $user_email = '', $errors = '' ) {
|
||||
global $current_site, $active_signup;
|
||||
global $active_signup;
|
||||
|
||||
if ( !is_wp_error($errors) )
|
||||
$errors = new WP_Error();
|
||||
|
@ -429,7 +428,7 @@ function signup_user($user_name = '', $user_email = '', $errors = '') {
|
|||
|
||||
?>
|
||||
|
||||
<h2><?php printf( __( 'Get your own %s account in seconds' ), $current_site->site_name ) ?></h2>
|
||||
<h2><?php printf( __( 'Get your own %s account in seconds' ), get_current_site()->site_name ) ?></h2>
|
||||
<form id="setupform" method="post" action="wp-signup.php">
|
||||
<input type="hidden" name="stage" value="validate-user-signup" />
|
||||
<?php
|
||||
|
|
Loading…
Reference in New Issue