diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php
index 6df3ad2f72..95af173f26 100644
--- a/wp-admin/admin-header.php
+++ b/wp-admin/admin-header.php
@@ -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 ) )
diff --git a/wp-admin/includes/class-wp-ms-sites-list-table.php b/wp-admin/includes/class-wp-ms-sites-list-table.php
index edc1146a97..4bad0d87a5 100644
--- a/wp-admin/includes/class-wp-ms-sites-list-table.php
+++ b/wp-admin/includes/class-wp-ms-sites-list-table.php
@@ -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 "
";
- $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'] = '' . __( 'Edit' ) . '';
$actions['backend'] = "" . __( 'Dashboard' ) . '';
- 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'] = '' . __( 'Activate' ) . '';
else
diff --git a/wp-admin/includes/class-wp-ms-users-list-table.php b/wp-admin/includes/class-wp-ms-users-list-table.php
index ab1ee3620e..bccb01028e 100644
--- a/wp-admin/includes/class-wp-ms-users-list-table.php
+++ b/wp-admin/includes/class-wp-ms-users-list-table.php
@@ -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 '';
- echo '' . str_replace( '.' . $current_site->domain, '', $val->domain . $path ) . '';
+ echo '' . str_replace( '.' . get_current_site()->domain, '', $val->domain . $path ) . '';
echo ' ';
$actions = array();
$actions['edit'] = '' . __( 'Edit' ) . '';
diff --git a/wp-admin/includes/ms.php b/wp-admin/includes/ms.php
index d7b47f2741..facc29209a 100644
--- a/wp-admin/includes/ms.php
+++ b/wp-admin/includes/ms.php
@@ -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;
diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php
index ef626c3c6b..90ab600b72 100644
--- a/wp-admin/includes/schema.php
+++ b/wp-admin/includes/schema.php
@@ -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%/';
}
diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php
index 513cea79d8..71a534e628 100644
--- a/wp-admin/includes/upgrade.php
+++ b/wp-admin/includes/upgrade.php
@@ -100,8 +100,8 @@ 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;
+function wp_install_defaults( $user_id ) {
+ 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 SITE_NAME. 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!');
}
diff --git a/wp-includes/admin-bar.php b/wp-includes/admin-bar.php
index 8184b846a0..9498381c1e 100644
--- a/wp-includes/admin-bar.php
+++ b/wp-includes/admin-bar.php
@@ -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, '…' );
diff --git a/wp-includes/class-wp-xmlrpc-server.php b/wp-includes/class-wp-xmlrpc-server.php
index d3ebdb8bb3..1ab005b8d8 100644
--- a/wp-includes/class-wp-xmlrpc-server.php
+++ b/wp-includes/class-wp-xmlrpc-server.php
@@ -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;
diff --git a/wp-includes/http.php b/wp-includes/http.php
index e30fa41ade..0b4b109d9f 100644
--- a/wp-includes/http.php
+++ b/wp-includes/http.php
@@ -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 ];
diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php
index 880f7e142f..45e3ba2870 100644
--- a/wp-includes/link-template.php
+++ b/wp-includes/link-template.php
@@ -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' ) ) )
diff --git a/wp-includes/ms-blogs.php b/wp-includes/ms-blogs.php
index 25baf15f68..708814ebbe 100644
--- a/wp-includes/ms-blogs.php
+++ b/wp-includes/ms-blogs.php
@@ -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' );
diff --git a/wp-includes/ms-default-constants.php b/wp-includes/ms-default-constants.php
index 53dfc9b55c..8cbd2c35af 100644
--- a/wp-includes/ms-default-constants.php
+++ b/wp-includes/ms-default-constants.php
@@ -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
diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php
index fd92b2c5d6..1e15684b4c 100644
--- a/wp-includes/ms-functions.php
+++ b/wp-includes/ms-functions.php
@@ -535,9 +535,10 @@ function wpmu_validate_user_signup($user_name, $user_email) {
* @param string $blog_title The blog title provided by the user.
* @return array Contains the new site data and error messages.
*/
-function wpmu_validate_blog_signup($blogname, $blog_title, $user = '') {
- global $wpdb, $domain, $current_site;
+function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {
+ 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
@@ -1122,8 +1121,8 @@ function insert_blog($domain, $path, $site_id) {
* @param int $blog_id The value returned by insert_blog().
* @param string $blog_title The title of the new site.
*/
-function install_blog($blog_id, $blog_title = '') {
- global $wpdb, $wp_roles, $current_site;
+function install_blog( $blog_id, $blog_title = '' ) {
+ 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;
}
/**
diff --git a/wp-includes/ms-load.php b/wp-includes/ms-load.php
index ae31689eef..09746dbd75 100644
--- a/wp-includes/ms-load.php
+++ b/wp-includes/ms-load.php
@@ -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 %1$s.' ), 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 %1$s.' ), str_replace( '@', ' AT ', get_site_option( 'admin_email', 'support@' . get_current_site()->domain ) ) ) );
}
if ( $blog->archived == '1' || $blog->spam == '1' ) {
diff --git a/wp-login.php b/wp-login.php
index 7d489935af..5db804f766 100644
--- a/wp-login.php
+++ b/wp-login.php
@@ -30,8 +30,8 @@ if ( force_ssl_admin() && ! is_ssl() ) {
* @param string $wp_error Optional. The error to pass. Default empty.
* @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;
+function login_header( $title = 'Log In', $message = '', $wp_error = '' ) {
+ 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();
diff --git a/wp-signup.php b/wp-signup.php
index 0ecee1e1d6..d4e4a75404 100644
--- a/wp-signup.php
+++ b/wp-signup.php
@@ -87,8 +87,8 @@ do_action( 'before_signup_form' );
* @param string $blog_title The new site title
* @param array $errors
*/
-function show_blog_form($blogname = '', $blog_title = '', $errors = '') {
- global $current_site;
+function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
+ $current_site = get_current_site();
// Blog name
if ( !is_subdomain_install() )
echo '';
@@ -225,8 +225,7 @@ function validate_user_form() {
* @param string $blog_title The new blog title
* @param array $errors
*/
-function signup_another_blog($blogname = '', $blog_title = '', $errors = '') {
- global $current_site;
+function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) {
$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 '' . sprintf( __( 'Get another %s site in seconds' ), $current_site->site_name ) . '
';
+ echo '' . sprintf( __( 'Get another %s site in seconds' ), get_current_site()->site_name ) . '
';
if ( $errors->get_error_code() ) {
echo '' . __( 'There was a problem, please correct the form below and try again.' ) . '
';
@@ -395,8 +394,8 @@ function confirm_another_blog_signup( $domain, $path, $blog_title, $user_name, $
* @param string $user_email The user's email
* @param array $errors
*/
-function signup_user($user_name = '', $user_email = '', $errors = '') {
- global $current_site, $active_signup;
+function signup_user( $user_name = '', $user_email = '', $errors = '' ) {
+ global $active_signup;
if ( !is_wp_error($errors) )
$errors = new WP_Error();
@@ -429,7 +428,7 @@ function signup_user($user_name = '', $user_email = '', $errors = '') {
?>
- site_name ) ?>
+ site_name ) ?>