From 1560fbcbc5461cf2ac00c2216404d6437a04335d Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Wed, 19 Oct 2016 04:47:30 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@38814 git-svn-id: http://core.svn.wordpress.org/trunk@38757 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-header.php | 4 +- .../includes/class-wp-ms-sites-list-table.php | 2 +- .../includes/class-wp-ms-users-list-table.php | 2 +- wp-admin/includes/ms.php | 4 +- wp-admin/includes/schema.php | 2 +- wp-admin/includes/upgrade.php | 4 +- wp-admin/ms-delete-site.php | 6 +-- wp-admin/network/settings.php | 2 +- wp-admin/network/site-new.php | 16 +++---- wp-admin/network/sites.php | 6 +-- wp-admin/network/users.php | 2 +- wp-includes/admin-bar.php | 4 +- wp-includes/class-wp-xmlrpc-server.php | 2 +- wp-includes/functions.php | 15 ++----- wp-includes/http.php | 2 +- wp-includes/link-template.php | 12 +++--- wp-includes/load.php | 8 ++-- wp-includes/ms-blogs.php | 10 ++--- wp-includes/ms-default-constants.php | 12 +++--- wp-includes/ms-deprecated.php | 2 +- wp-includes/ms-functions.php | 42 +++++++++---------- wp-includes/ms-load.php | 2 +- wp-includes/option.php | 36 +++++++--------- wp-includes/version.php | 2 +- wp-login.php | 4 +- wp-signup.php | 14 +++---- 26 files changed, 102 insertions(+), 115 deletions(-) diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index b5bbec0e98..9799d0f8d4 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -33,9 +33,9 @@ get_admin_page_title(); $title = esc_html( strip_tags( $title ) ); if ( is_network_admin() ) - $admin_title = sprintf( __( 'Network Admin: %s' ), esc_html( get_current_site()->site_name ) ); + $admin_title = sprintf( __( 'Network Admin: %s' ), esc_html( get_network()->site_name ) ); elseif ( is_user_admin() ) - $admin_title = sprintf( __( 'User Dashboard: %s' ), esc_html( get_current_site()->site_name ) ); + $admin_title = sprintf( __( 'User Dashboard: %s' ), esc_html( get_network()->site_name ) ); else $admin_title = get_bloginfo( 'name' ); 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 9ce3ffee9b..6c7bcc3b44 100644 --- a/wp-admin/includes/class-wp-ms-sites-list-table.php +++ b/wp-admin/includes/class-wp-ms-sites-list-table.php @@ -518,7 +518,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table { $actions['edit'] = '' . __( 'Edit' ) . ''; $actions['backend'] = "" . __( 'Dashboard' ) . ''; - if ( get_current_site()->blog_id != $blog['blog_id'] ) { + if ( get_network()->site_id != $blog['blog_id'] ) { if ( $blog['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 da00131bcd..d219efc38e 100644 --- a/wp-admin/includes/class-wp-ms-users-list-table.php +++ b/wp-admin/includes/class-wp-ms-users-list-table.php @@ -329,7 +329,7 @@ class WP_MS_Users_List_Table extends WP_List_Table { $path = ( $val->path === '/' ) ? '' : $val->path; echo ''; - echo '' . str_replace( '.' . get_current_site()->domain, '', $val->domain . $path ) . ''; + echo '' . str_replace( '.' . get_network()->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 b2e4f86e88..7f1e51b55b 100644 --- a/wp-admin/includes/ms.php +++ b/wp-admin/includes/ms.php @@ -88,7 +88,7 @@ function wpmu_delete_blog( $blog_id, $drop = false ) { update_blog_status( $blog_id, 'deleted', 1 ); - $current_site = get_current_site(); + $current_network = get_network(); // If a full blog object is not available, do not destroy anything. if ( $drop && ! $blog ) { @@ -96,7 +96,7 @@ function wpmu_delete_blog( $blog_id, $drop = false ) { } // 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 ) ) ) { + if ( $drop && ( 1 == $blog_id || is_main_site( $blog_id ) || ( $blog->path == $current_network->path && $blog->domain == $current_network->domain ) ) ) { $drop = false; } diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index 8ddc13940a..cd66e1924b 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -527,7 +527,7 @@ function populate_options() { // 3.0 multisite if ( is_multisite() ) { /* translators: site tagline */ - $options[ 'blogdescription' ] = sprintf(__('Just another %s site'), get_current_site()->site_name ); + $options[ 'blogdescription' ] = sprintf(__('Just another %s site'), get_network()->site_name ); $options[ 'permalink_structure' ] = '/%year%/%monthnum%/%day%/%postname%/'; } diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 6b04963aa8..f37fcccf9d 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -161,12 +161,12 @@ function wp_install_defaults( $user_id ) { } $first_post = sprintf( $first_post, - sprintf( '%s', esc_url( network_home_url() ), get_current_site()->site_name ) + sprintf( '%s', esc_url( network_home_url() ), get_network()->site_name ) ); // Back-compat for pre-4.4 $first_post = str_replace( 'SITE_URL', esc_url( network_home_url() ), $first_post ); - $first_post = str_replace( 'SITE_NAME', get_current_site()->site_name, $first_post ); + $first_post = str_replace( 'SITE_NAME', get_network()->site_name, $first_post ); } else { $first_post = __( 'Welcome to WordPress. This is your first post. Edit or delete it, then start writing!' ); } diff --git a/wp-admin/ms-delete-site.php b/wp-admin/ms-delete-site.php index a790fa2691..3e77bbdbe9 100644 --- a/wp-admin/ms-delete-site.php +++ b/wp-admin/ms-delete-site.php @@ -18,7 +18,7 @@ if ( ! current_user_can( 'delete_site' ) ) if ( isset( $_GET['h'] ) && $_GET['h'] != '' && get_option( 'delete_blog_hash' ) != false ) { if ( hash_equals( get_option( 'delete_blog_hash' ), $_GET['h'] ) ) { wpmu_delete_blog( $wpdb->blogid ); - wp_die( sprintf( __( 'Thank you for using %s, your site has been deleted. Happy trails to you until we meet again.' ), $current_site->site_name ) ); + wp_die( sprintf( __( 'Thank you for using %s, your site has been deleted. Happy trails to you until we meet again.' ), get_network()->site_name ) ); } else { wp_die( __( "I'm sorry, the link you clicked is stale. Please select another option." ) ); } @@ -70,7 +70,7 @@ Webmaster $content = str_replace( '###USERNAME###', $user->user_login, $content ); $content = str_replace( '###URL_DELETE###', $url_delete, $content ); - $content = str_replace( '###SITE_NAME###', $current_site->site_name, $content ); + $content = str_replace( '###SITE_NAME###', get_network()->site_name, $content ); wp_mail( get_option( 'admin_email' ), "[ " . wp_specialchars_decode( get_option( 'blogname' ) ) . " ] ".__( 'Delete My Site' ), $content ); ?> @@ -79,7 +79,7 @@ Webmaster -

Delete My Site Permanently you will be sent an email with a link in it. Click on this link to delete your site.'), $current_site->site_name); ?>

+

Delete My Site Permanently you will be sent an email with a link in it. Click on this link to delete your site.'), get_network()->site_name); ?>

diff --git a/wp-admin/network/settings.php b/wp-admin/network/settings.php index 07f2a26e3f..5d81cdf369 100644 --- a/wp-admin/network/settings.php +++ b/wp-admin/network/settings.php @@ -104,7 +104,7 @@ if ( isset( $_GET['updated'] ) ) { - + diff --git a/wp-admin/network/site-new.php b/wp-admin/network/site-new.php index 62346499bc..0be051ec87 100644 --- a/wp-admin/network/site-new.php +++ b/wp-admin/network/site-new.php @@ -86,11 +86,11 @@ if ( isset($_REQUEST['action']) && 'add-site' == $_REQUEST['action'] ) { } if ( is_subdomain_install() ) { - $newdomain = $domain . '.' . preg_replace( '|^www\.|', '', $current_site->domain ); - $path = $current_site->path; + $newdomain = $domain . '.' . preg_replace( '|^www\.|', '', get_network()->domain ); + $path = get_network()->path; } else { - $newdomain = $current_site->domain; - $path = $current_site->path . $domain . '/'; + $newdomain = get_network()->domain; + $path = get_network()->path . $domain . '/'; } $password = 'N/A'; @@ -126,7 +126,7 @@ if ( isset($_REQUEST['action']) && 'add-site' == $_REQUEST['action'] ) { } $wpdb->hide_errors(); - $id = wpmu_create_blog( $newdomain, $path, $title, $user_id, $meta, $current_site->id ); + $id = wpmu_create_blog( $newdomain, $path, $title, $user_id, $meta, get_current_network_id() ); $wpdb->show_errors(); if ( ! is_wp_error( $id ) ) { if ( ! is_super_admin( $user_id ) && !get_user_option( 'primary_blog', $user_id ) ) { @@ -138,7 +138,7 @@ if ( isset($_REQUEST['action']) && 'add-site' == $_REQUEST['action'] ) { sprintf( /* translators: %s: network name */ __( '[%s] New Site Created' ), - $current_site->site_name + get_network()->site_name ), sprintf( /* translators: 1: user login, 2: site url, 3: site name/title */ @@ -198,9 +198,9 @@ if ( ! empty( $messages ) ) { - .domain ); ?> + .domain ); ?> domain . $current_site->path ?> + echo get_network()->domain . get_network()->path ?> ' . __( 'Only lowercase letters (a-z), numbers, and hyphens are allowed.' ) . '

'; ?> diff --git a/wp-admin/network/sites.php b/wp-admin/network/sites.php index 31bf3e9724..c9cac56c27 100644 --- a/wp-admin/network/sites.php +++ b/wp-admin/network/sites.php @@ -87,7 +87,7 @@ if ( isset( $_GET['action'] ) ) { header( 'Content-Type: text/html; charset=utf-8' ); } - if ( $current_site->blog_id == $id ) { + if ( get_network()->site_id == $id ) { wp_die( __( 'Sorry, you are not allowed to change the current site.' ) ); } @@ -126,7 +126,7 @@ if ( isset( $_GET['action'] ) ) { wp_die( __( 'Sorry, you are not allowed to access this page.' ), '', array( 'response' => 403 ) ); $updated_action = 'not_deleted'; - if ( $id != '0' && $id != $current_site->blog_id && current_user_can( 'delete_site', $id ) ) { + if ( $id != '0' && $id != get_network()->site_id && current_user_can( 'delete_site', $id ) ) { wpmu_delete_blog( $id, true ); $updated_action = 'delete'; } @@ -137,7 +137,7 @@ if ( isset( $_GET['action'] ) ) { $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2']; foreach ( (array) $_POST['allblogs'] as $key => $val ) { - if ( $val != '0' && $val != $current_site->blog_id ) { + if ( $val != '0' && $val != get_network()->site_id ) { switch ( $doaction ) { case 'delete': if ( ! current_user_can( 'delete_site', $val ) ) diff --git a/wp-admin/network/users.php b/wp-admin/network/users.php index 3f9b688dcc..46b1ee5618 100644 --- a/wp-admin/network/users.php +++ b/wp-admin/network/users.php @@ -72,7 +72,7 @@ if ( isset( $_GET['action'] ) ) { $userfunction = 'all_spam'; $blogs = get_blogs_of_user( $user_id, true ); foreach ( (array) $blogs as $details ) { - if ( $details->userblog_id != $current_site->blog_id ) // main blog not a spam ! + if ( $details->userblog_id != get_network()->site_id ) // main blog not a spam ! update_blog_status( $details->userblog_id, 'spam', '1' ); } update_user_status( $user_id, 'spam', '1' ); diff --git a/wp-includes/admin-bar.php b/wp-includes/admin-bar.php index e95cc4d81b..83deb9609e 100644 --- a/wp-includes/admin-bar.php +++ b/wp-includes/admin-bar.php @@ -312,10 +312,10 @@ function wp_admin_bar_site_menu( $wp_admin_bar ) { if ( is_network_admin() ) { /* translators: %s: site name */ - $blogname = sprintf( __( 'Network Admin: %s' ), esc_html( get_current_site()->site_name ) ); + $blogname = sprintf( __( 'Network Admin: %s' ), esc_html( get_network()->site_name ) ); } elseif ( is_user_admin() ) { /* translators: %s: site name */ - $blogname = sprintf( __( 'User Dashboard: %s' ), esc_html( get_current_site()->site_name ) ); + $blogname = sprintf( __( 'User Dashboard: %s' ), esc_html( get_network()->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 59a7c226f0..6010532386 100644 --- a/wp-includes/class-wp-xmlrpc-server.php +++ b/wp-includes/class-wp-xmlrpc-server.php @@ -628,7 +628,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 != get_current_site()->id ) + if ( $blog->site_id != get_current_network_id() ) continue; $blog_id = $blog->userblog_id; diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 40d4a300e1..f7879575db 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -4302,23 +4302,18 @@ function wp_suspend_cache_invalidation( $suspend = true ) { * * @since 3.0.0 * - * @global object $current_site - * * @param int $site_id Optional. Site ID to test. Defaults to current site. * @return bool True if $site_id is the main site of the network, or if not * running Multisite. */ function is_main_site( $site_id = null ) { - // This is the current network's information; 'site' is old terminology. - global $current_site; - if ( ! is_multisite() ) return true; if ( ! $site_id ) $site_id = get_current_blog_id(); - return (int) $site_id === (int) $current_site->blog_id; + return (int) $site_id === (int) get_network()->site_id; } /** @@ -4334,10 +4329,8 @@ function is_main_network( $network_id = null ) { return true; } - $current_network_id = (int) get_current_site()->id; - if ( null === $network_id ) { - $network_id = $current_network_id; + $network_id = get_current_network_id(); } $network_id = (int) $network_id; @@ -4357,11 +4350,11 @@ function get_main_network_id() { return 1; } - $current_site = get_current_site(); + $current_network = get_network(); if ( defined( 'PRIMARY_NETWORK_ID' ) ) { $main_network_id = PRIMARY_NETWORK_ID; - } elseif ( isset( $current_site->id ) && 1 === (int) $current_site->id ) { + } elseif ( isset( $current_network->id ) && 1 === (int) $current_network->id ) { // If the current network has an ID of 1, assume it is the main network. $main_network_id = 1; } else { diff --git a/wp-includes/http.php b/wp-includes/http.php index ff89672ec1..862e456ae3 100644 --- a/wp-includes/http.php +++ b/wp-includes/http.php @@ -617,7 +617,7 @@ function ms_allowed_http_request_hosts( $is_external, $host ) { static $queried = array(); if ( $is_external ) return $is_external; - if ( $host === get_current_site()->domain ) + if ( $host === get_network()->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 c1ec8b33a9..c07349190e 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -3255,12 +3255,12 @@ function network_site_url( $path = '', $scheme = null ) { if ( ! is_multisite() ) return site_url($path, $scheme); - $current_site = get_current_site(); + $current_network = get_network(); if ( 'relative' == $scheme ) - $url = $current_site->path; + $url = $current_network->path; else - $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme ); + $url = set_url_scheme( 'http://' . $current_network->domain . $current_network->path, $scheme ); if ( $path && is_string( $path ) ) $url .= ltrim( $path, '/' ); @@ -3297,16 +3297,16 @@ function network_home_url( $path = '', $scheme = null ) { if ( ! is_multisite() ) return home_url($path, $scheme); - $current_site = get_current_site(); + $current_network = get_network(); $orig_scheme = $scheme; if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) $scheme = is_ssl() && ! is_admin() ? 'https' : 'http'; if ( 'relative' == $scheme ) - $url = $current_site->path; + $url = $current_network->path; else - $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme ); + $url = set_url_scheme( 'http://' . $current_network->domain . $current_network->path, $scheme ); if ( $path && is_string( $path ) ) $url .= ltrim( $path, '/' ); diff --git a/wp-includes/load.php b/wp-includes/load.php index 2aa4451067..887a6b152a 100644 --- a/wp-includes/load.php +++ b/wp-includes/load.php @@ -814,8 +814,6 @@ function get_current_blog_id() { * * @since 4.6.0 * - * @global WP_Network $current_site The current network. - * * @return int The ID of the current network. */ function get_current_network_id() { @@ -823,13 +821,13 @@ function get_current_network_id() { return 1; } - $current_site = get_current_site(); + $current_network = get_network(); - if ( ! isset( $current_site->id ) ) { + if ( ! isset( $current_network->id ) ) { return get_main_network_id(); } - return absint( $current_site->id ); + return absint( $current_network->id ); } /** diff --git a/wp-includes/ms-blogs.php b/wp-includes/ms-blogs.php index 7627d11de1..b399cfaf9c 100644 --- a/wp-includes/ms-blogs.php +++ b/wp-includes/ms-blogs.php @@ -81,15 +81,15 @@ function get_blogaddress_by_name( $blogname ) { * @return int|null The site ID, or null if no site is found for the given slug. */ function get_id_from_blogname( $slug ) { - $current_site = get_current_site(); + $current_network = get_network(); $slug = trim( $slug, '/' ); if ( is_subdomain_install() ) { - $domain = $slug . '.' . preg_replace( '|^www\.|', '', $current_site->domain ); - $path = $current_site->path; + $domain = $slug . '.' . preg_replace( '|^www\.|', '', $current_network->domain ); + $path = $current_network->path; } else { - $domain = $current_site->domain; - $path = $current_site->path . $slug . '/'; + $domain = $current_network->domain; + $path = $current_network->path . $slug . '/'; } $site_ids = get_sites( array( diff --git a/wp-includes/ms-default-constants.php b/wp-includes/ms-default-constants.php index 98719f8ba5..5a54b88dc3 100644 --- a/wp-includes/ms-default-constants.php +++ b/wp-includes/ms-default-constants.php @@ -47,19 +47,19 @@ function ms_upload_constants() { * @since 3.0.0 */ function ms_cookie_constants( ) { - $current_site = get_current_site(); + $current_network = get_network(); /** * @since 1.2.0 */ if ( !defined( 'COOKIEPATH' ) ) - define( 'COOKIEPATH', $current_site->path ); + define( 'COOKIEPATH', $current_network->path ); /** * @since 1.5.0 */ if ( !defined( 'SITECOOKIEPATH' ) ) - define( 'SITECOOKIEPATH', $current_site->path ); + define( 'SITECOOKIEPATH', $current_network->path ); /** * @since 2.6.0 @@ -76,10 +76,10 @@ function ms_cookie_constants( ) { * @since 2.0.0 */ if ( !defined('COOKIE_DOMAIN') && is_subdomain_install() ) { - if ( !empty( $current_site->cookie_domain ) ) - define('COOKIE_DOMAIN', '.' . $current_site->cookie_domain); + if ( !empty( $current_network->cookie_domain ) ) + define('COOKIE_DOMAIN', '.' . $current_network->cookie_domain); else - define('COOKIE_DOMAIN', '.' . $current_site->domain); + define('COOKIE_DOMAIN', '.' . $current_network->domain); } } diff --git a/wp-includes/ms-deprecated.php b/wp-includes/ms-deprecated.php index 686efccc59..930c36c2c6 100644 --- a/wp-includes/ms-deprecated.php +++ b/wp-includes/ms-deprecated.php @@ -28,7 +28,7 @@ function get_dashboard_blog() { if ( $blog = get_site_option( 'dashboard_blog' ) ) return get_blog_details( $blog ); - return get_blog_details( get_current_site()->blog_id ); + return get_blog_details( get_network()->site_id ); } /** diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index ca8176124f..697da4b010 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -546,8 +546,8 @@ function wpmu_validate_user_signup($user_name, $user_email) { function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) { global $wpdb, $domain; - $current_site = get_current_site(); - $base = $current_site->path; + $current_network = get_network(); + $base = $current_network->path; $blog_title = strip_tags( $blog_title ); @@ -580,7 +580,7 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) { $errors->add('blogname', __( 'Site name must be at least 4 characters.' ) ); // do not allow users to create a blog that conflicts with a page on the main blog. - if ( !is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_site->blog_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) ) + if ( !is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_network->site_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) ) $errors->add( 'blogname', __( 'Sorry, you may not use that site name.' ) ); // all numeric? @@ -612,7 +612,7 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) { $mydomain = "$domain"; $path = $base.$blogname.'/'; } - if ( domain_exists($mydomain, $path, $current_site->id) ) + if ( domain_exists($mydomain, $path, $current_network->id) ) $errors->add( 'blogname', __( 'Sorry, that site already exists!' ) ); if ( username_exists( $blogname ) ) { @@ -789,7 +789,7 @@ function wpmu_signup_blog_notification( $domain, $path, $title, $user, $user_ema } // Send email with activation link. - if ( !is_subdomain_install() || get_current_site()->id != 1 ) + if ( !is_subdomain_install() || get_current_network_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 @@ -1334,7 +1334,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; @@ -1363,7 +1363,7 @@ function install_blog( $blog_id, $blog_title = '' ) { if ( 'https' === parse_url( get_site_option( 'siteurl' ), PHP_URL_SCHEME ) ) { $siteurl = set_url_scheme( $siteurl, 'https' ); } - if ( 'https' === parse_url( get_home_url( $current_site->blog_id ), PHP_URL_SCHEME ) ) { + if ( 'https' === parse_url( get_home_url( get_network()->site_id ), PHP_URL_SCHEME ) ) { $home = set_url_scheme( $home, 'https' ); } @@ -1375,7 +1375,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( get_current_site()->blog_id, 'upload_path' ) ); + update_option( 'upload_path', get_blog_option( get_network()->site_id, 'upload_path' ) ); update_option( 'blogname', wp_unslash( $blog_title ) ); update_option( 'admin_email', '' ); @@ -1430,7 +1430,7 @@ function install_blog_defaults($blog_id, $user_id) { * @return bool */ function wpmu_welcome_notification( $blog_id, $user_id, $password, $title, $meta = array() ) { - $current_site = get_current_site(); + $current_network = get_network(); /** * Filters whether to bypass the welcome email after site activation. @@ -1470,7 +1470,7 @@ We hope you enjoy your new site. Thanks! $url = get_blogaddress_by_id($blog_id); $user = get_userdata( $user_id ); - $welcome_email = str_replace( 'SITE_NAME', $current_site->site_name, $welcome_email ); + $welcome_email = str_replace( 'SITE_NAME', $current_network->site_name, $welcome_email ); $welcome_email = str_replace( 'BLOG_TITLE', $title, $welcome_email ); $welcome_email = str_replace( 'BLOG_URL', $url, $welcome_email ); $welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email ); @@ -1500,8 +1500,8 @@ We hope you enjoy your new site. Thanks! $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; $message = $welcome_email; - if ( empty( $current_site->site_name ) ) - $current_site->site_name = 'WordPress'; + if ( empty( $current_network->site_name ) ) + $current_network->site_name = 'WordPress'; /** * Filters the subject of the welcome email after site activation. @@ -1510,7 +1510,7 @@ We hope you enjoy your new site. Thanks! * * @param string $subject Subject of the email. */ - $subject = apply_filters( 'update_welcome_subject', sprintf( __( 'New %1$s Site: %2$s' ), $current_site->site_name, wp_unslash( $title ) ) ); + $subject = apply_filters( 'update_welcome_subject', sprintf( __( 'New %1$s Site: %2$s' ), $current_network->site_name, wp_unslash( $title ) ) ); wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers ); return true; } @@ -1531,7 +1531,7 @@ We hope you enjoy your new site. Thanks! * @return bool */ function wpmu_welcome_user_notification( $user_id, $password, $meta = array() ) { - $current_site = get_current_site(); + $current_network = get_network(); /** * Filters whether to bypass the welcome email after user activation. @@ -1564,7 +1564,7 @@ function wpmu_welcome_user_notification( $user_id, $password, $meta = array() ) * @param array $meta Signup meta data. */ $welcome_email = apply_filters( 'update_welcome_user_email', $welcome_email, $user_id, $password, $meta ); - $welcome_email = str_replace( 'SITE_NAME', $current_site->site_name, $welcome_email ); + $welcome_email = str_replace( 'SITE_NAME', $current_network->site_name, $welcome_email ); $welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email ); $welcome_email = str_replace( 'PASSWORD', $password, $welcome_email ); $welcome_email = str_replace( 'LOGINLINK', wp_login_url(), $welcome_email ); @@ -1578,8 +1578,8 @@ function wpmu_welcome_user_notification( $user_id, $password, $meta = array() ) $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; $message = $welcome_email; - if ( empty( $current_site->site_name ) ) - $current_site->site_name = 'WordPress'; + if ( empty( $current_network->site_name ) ) + $current_network->site_name = 'WordPress'; /** * Filters the subject of the welcome email after user activation. @@ -1588,7 +1588,7 @@ function wpmu_welcome_user_notification( $user_id, $password, $meta = array() ) * * @param string $subject Subject of the email. */ - $subject = apply_filters( 'update_welcome_user_subject', sprintf( __( 'New %1$s User: %2$s' ), $current_site->site_name, $user->user_login) ); + $subject = apply_filters( 'update_welcome_user_subject', sprintf( __( 'New %1$s User: %2$s' ), $current_network->site_name, $user->user_login) ); wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers ); return true; } @@ -1877,7 +1877,7 @@ function global_terms( $term_id, $deprecated = '' ) { * @return array The current site's domain */ function redirect_this_site( $deprecated = '' ) { - return array( get_current_site()->domain ); + return array( get_network()->domain ); } /** @@ -2024,7 +2024,7 @@ function add_new_user_to_blog( $user_id, $password, $meta ) { if ( !empty( $meta[ 'add_to_blog' ] ) ) { $blog_id = $meta[ 'add_to_blog' ]; $role = $meta[ 'new_role' ]; - remove_user_from_blog($user_id, get_current_site()->blog_id); // remove user from main blog. + remove_user_from_blog($user_id, get_network()->site_id); // remove user from main blog. add_user_to_blog( $blog_id, $user_id, $role ); update_user_meta( $user_id, 'primary_blog', $blog_id ); } @@ -2038,7 +2038,7 @@ function add_new_user_to_blog( $user_id, $password, $meta ) { * @param PHPMailer $phpmailer The PHPMailer instance, passed by reference. */ function fix_phpmailer_messageid( $phpmailer ) { - $phpmailer->Hostname = get_current_site()->domain; + $phpmailer->Hostname = get_network()->domain; } /** diff --git a/wp-includes/ms-load.php b/wp-includes/ms-load.php index a516327399..31bf9ca31a 100644 --- a/wp-includes/ms-load.php +++ b/wp-includes/ms-load.php @@ -97,7 +97,7 @@ function ms_site_check() { if ( file_exists( WP_CONTENT_DIR . '/blog-inactive.php' ) ) { return WP_CONTENT_DIR . '/blog-inactive.php'; } else { - $admin_email = str_replace( '@', ' AT ', get_site_option( 'admin_email', 'support@' . get_current_site()->domain ) ); + $admin_email = str_replace( '@', ' AT ', get_site_option( 'admin_email', 'support@' . get_network()->domain ) ); wp_die( /* translators: %s: admin email link */ sprintf( __( 'This site has not been activated yet. If you are having problems activating your site, please contact %s.' ), diff --git a/wp-includes/option.php b/wp-includes/option.php index 4c1796f067..1554a1d8ec 100644 --- a/wp-includes/option.php +++ b/wp-includes/option.php @@ -1069,8 +1069,7 @@ function update_site_option( $option, $value ) { * * @see get_option() * - * @global wpdb $wpdb - * @global object $current_site + * @global wpdb $wpdb * * @param int $network_id ID of the network. Can be null to default to the current network ID. * @param string $option Name of option to retrieve. Expected to not be SQL-escaped. @@ -1078,7 +1077,7 @@ function update_site_option( $option, $value ) { * @return mixed Value set for the option. */ function get_network_option( $network_id, $option, $default = false ) { - global $wpdb, $current_site; + global $wpdb; if ( $network_id && ! is_numeric( $network_id ) ) { return false; @@ -1087,8 +1086,8 @@ function get_network_option( $network_id, $option, $default = false ) { $network_id = (int) $network_id; // Fallback to the current network if a network ID is not specified. - if ( ! $network_id && is_multisite() ) { - $network_id = $current_site->id; + if ( ! $network_id ) { + $network_id = get_current_network_id(); } /** @@ -1186,8 +1185,7 @@ function get_network_option( $network_id, $option, $default = false ) { * * @see add_option() * - * @global wpdb $wpdb - * @global object $current_site + * @global wpdb $wpdb * * @param int $network_id ID of the network. Can be null to default to the current network ID. * @param string $option Name of option to add. Expected to not be SQL-escaped. @@ -1195,7 +1193,7 @@ function get_network_option( $network_id, $option, $default = false ) { * @return bool False if option was not added and true if option was added. */ function add_network_option( $network_id, $option, $value ) { - global $wpdb, $current_site; + global $wpdb; if ( $network_id && ! is_numeric( $network_id ) ) { return false; @@ -1204,8 +1202,8 @@ function add_network_option( $network_id, $option, $value ) { $network_id = (int) $network_id; // Fallback to the current network if a network ID is not specified. - if ( ! $network_id && is_multisite() ) { - $network_id = $current_site->id; + if ( ! $network_id ) { + $network_id = get_current_network_id(); } wp_protect_special_option( $option ); @@ -1296,15 +1294,14 @@ function add_network_option( $network_id, $option, $value ) { * * @see delete_option() * - * @global wpdb $wpdb - * @global object $current_site + * @global wpdb $wpdb * * @param int $network_id ID of the network. Can be null to default to the current network ID. * @param string $option Name of option to remove. Expected to not be SQL-escaped. * @return bool True, if succeed. False, if failure. */ function delete_network_option( $network_id, $option ) { - global $wpdb, $current_site; + global $wpdb; if ( $network_id && ! is_numeric( $network_id ) ) { return false; @@ -1313,8 +1310,8 @@ function delete_network_option( $network_id, $option ) { $network_id = (int) $network_id; // Fallback to the current network if a network ID is not specified. - if ( ! $network_id && is_multisite() ) { - $network_id = $current_site->id; + if ( ! $network_id ) { + $network_id = get_current_network_id(); } /** @@ -1378,8 +1375,7 @@ function delete_network_option( $network_id, $option ) { * * @see update_option() * - * @global wpdb $wpdb - * @global object $current_site + * @global wpdb $wpdb * * @param int $network_id ID of the network. Can be null to default to the current network ID. * @param string $option Name of option. Expected to not be SQL-escaped. @@ -1387,7 +1383,7 @@ function delete_network_option( $network_id, $option ) { * @return bool False if value was not updated and true if value was updated. */ function update_network_option( $network_id, $option, $value ) { - global $wpdb, $current_site; + global $wpdb; if ( $network_id && ! is_numeric( $network_id ) ) { return false; @@ -1396,8 +1392,8 @@ function update_network_option( $network_id, $option, $value ) { $network_id = (int) $network_id; // Fallback to the current network if a network ID is not specified. - if ( ! $network_id && is_multisite() ) { - $network_id = $current_site->id; + if ( ! $network_id ) { + $network_id = get_current_network_id(); } wp_protect_special_option( $option ); diff --git a/wp-includes/version.php b/wp-includes/version.php index ca7405a23a..c26a03d971 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-alpha-38813'; +$wp_version = '4.7-alpha-38814'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. diff --git a/wp-login.php b/wp-login.php index b66bd6fb2d..28e09ffbe8 100644 --- a/wp-login.php +++ b/wp-login.php @@ -98,7 +98,7 @@ function login_header( $title = 'Log In', $message = '', $wp_error = '' ) { if ( is_multisite() ) { $login_header_url = network_home_url(); - $login_header_title = get_current_site()->site_name; + $login_header_title = get_network()->site_name; } else { $login_header_url = __( 'https://wordpress.org/' ); $login_header_title = __( 'Powered by WordPress' ); @@ -332,7 +332,7 @@ function retrieve_password() { $message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . ">\r\n"; if ( is_multisite() ) { - $blogname = get_current_site()->site_name; + $blogname = get_network()->site_name; } else { /* * The blogname option is escaped with esc_html on the way into the database diff --git a/wp-signup.php b/wp-signup.php index 99bd2afb9f..6cf96b5cf0 100644 --- a/wp-signup.php +++ b/wp-signup.php @@ -100,7 +100,7 @@ function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) { $errors = new WP_Error(); } - $current_site = get_current_site(); + $current_network = get_network(); // Blog name if ( !is_subdomain_install() ) echo ''; @@ -112,15 +112,15 @@ function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) { ' . $current_site->domain . $current_site->path . '
'; + echo '' . $current_network->domain . $current_network->path . '
'; else - echo '.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ) . '
'; + echo '.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_network->domain ) ) . '
'; if ( ! is_user_logged_in() ) { if ( ! is_subdomain_install() ) { - $site = $current_site->domain . $current_site->path . __( 'sitename' ); + $site = $current_network->domain . $current_network->path . __( 'sitename' ); } else { - $site = __( 'domain' ) . '.' . $site_domain . $current_site->path; + $site = __( 'domain' ) . '.' . $site_domain . $current_network->path; } /* translators: %s: site address */ @@ -304,7 +304,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' ), get_current_site()->site_name ) . '

'; + echo '

' . sprintf( __( 'Get another %s site in seconds' ), get_network()->site_name ) . '

'; if ( $errors->get_error_code() ) { echo '

' . __( 'There was a problem, please correct the form below and try again.' ) . '

'; @@ -532,7 +532,7 @@ function signup_user( $user_name = '', $user_email = '', $errors = '' ) {

site_name ); + printf( __( 'Get your own %s account in seconds' ), get_network()->site_name ); ?>