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
This commit is contained in:
Jeremy Felt 2016-10-19 04:47:30 +00:00
parent 1c3b96537f
commit 1560fbcbc5
26 changed files with 102 additions and 115 deletions

View File

@ -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' );

View File

@ -518,7 +518,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
$actions['edit'] = '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a>';
$actions['backend'] = "<a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a>';
if ( get_current_site()->blog_id != $blog['blog_id'] ) {
if ( get_network()->site_id != $blog['blog_id'] ) {
if ( $blog['deleted'] == '1' ) {
$actions['activate'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] ), 'activateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Activate' ) . '</a>';
} else {

View File

@ -329,7 +329,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( '.' . get_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_network()->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>';

View File

@ -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;
}

View File

@ -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%/';
}

View File

@ -161,12 +161,12 @@ function wp_install_defaults( $user_id ) {
}
$first_post = sprintf( $first_post,
sprintf( '<a href="%s">%s</a>', esc_url( network_home_url() ), get_current_site()->site_name )
sprintf( '<a href="%s">%s</a>', 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!' );
}

View File

@ -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
<?php } else {
?>
<p><?php printf( __( 'If you do not want to use your %s site any more, you can delete it using the form below. When you click <strong>Delete My Site Permanently</strong> you will be sent an email with a link in it. Click on this link to delete your site.'), $current_site->site_name); ?></p>
<p><?php printf( __( 'If you do not want to use your %s site any more, you can delete it using the form below. When you click <strong>Delete My Site Permanently</strong> you will be sent an email with a link in it. Click on this link to delete your site.'), get_network()->site_name); ?></p>
<p><?php _e( 'Remember, once deleted your site cannot be restored.' ) ?></p>
<form method="post" name="deletedirect">

View File

@ -104,7 +104,7 @@ if ( isset( $_GET['updated'] ) ) {
<tr>
<th scope="row"><label for="site_name"><?php _e( 'Network Title' ) ?></label></th>
<td>
<input name="site_name" type="text" id="site_name" class="regular-text" value="<?php echo esc_attr( $current_site->site_name ) ?>" />
<input name="site_name" type="text" id="site_name" class="regular-text" value="<?php echo esc_attr( get_network()->site_name ) ?>" />
</td>
</tr>

View File

@ -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 ) ) {
<th scope="row"><label for="site-address"><?php _e( 'Site Address (URL)' ) ?></label></th>
<td>
<?php if ( is_subdomain_install() ) { ?>
<input name="blog[domain]" type="text" class="regular-text" id="site-address" aria-describedby="site-address-desc" autocapitalize="none" autocorrect="off"/><span class="no-break">.<?php echo preg_replace( '|^www\.|', '', $current_site->domain ); ?></span>
<input name="blog[domain]" type="text" class="regular-text" id="site-address" aria-describedby="site-address-desc" autocapitalize="none" autocorrect="off"/><span class="no-break">.<?php echo preg_replace( '|^www\.|', '', get_network()->domain ); ?></span>
<?php } else {
echo $current_site->domain . $current_site->path ?><input name="blog[domain]" type="text" class="regular-text" id="site-address" aria-describedby="site-address-desc" autocapitalize="none" autocorrect="off" />
echo get_network()->domain . get_network()->path ?><input name="blog[domain]" type="text" class="regular-text" id="site-address" aria-describedby="site-address-desc" autocapitalize="none" autocorrect="off" />
<?php }
echo '<p class="description" id="site-address-desc">' . __( 'Only lowercase letters (a-z), numbers, and hyphens are allowed.' ) . '</p>';
?>

View File

@ -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 ) )

View File

@ -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' );

View File

@ -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, '&hellip;' );

View File

@ -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;

View File

@ -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 {

View File

@ -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 ];

View File

@ -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, '/' );

View File

@ -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 );
}
/**

View File

@ -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(

View File

@ -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);
}
}

View File

@ -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 );
}
/**

View File

@ -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;
}
/**

View File

@ -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.' ),

View File

@ -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 );

View File

@ -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.

View File

@ -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

View File

@ -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 '<label for="blogname">' . __('Site Name:') . '</label>';
@ -112,15 +112,15 @@ function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
<?php }
if ( !is_subdomain_install() )
echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="'. esc_attr($blogname) .'" maxlength="60" /><br />';
echo '<span class="prefix_address">' . $current_network->domain . $current_network->path . '</span><input name="blogname" type="text" id="blogname" value="'. esc_attr($blogname) .'" maxlength="60" /><br />';
else
echo '<input name="blogname" type="text" id="blogname" value="'.esc_attr($blogname).'" maxlength="60" /><span class="suffix_address">.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ) . '</span><br />';
echo '<input name="blogname" type="text" id="blogname" value="'.esc_attr($blogname).'" maxlength="60" /><span class="suffix_address">.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_network->domain ) ) . '</span><br />';
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 '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_current_site()->site_name ) . '</h2>';
echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_network()->site_name ) . '</h2>';
if ( $errors->get_error_code() ) {
echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>';
@ -532,7 +532,7 @@ function signup_user( $user_name = '', $user_email = '', $errors = '' ) {
<h2><?php
/* translators: %s: name of the network */
printf( __( 'Get your own %s account in seconds' ), get_current_site()->site_name );
printf( __( 'Get your own %s account in seconds' ), get_network()->site_name );
?></h2>
<form id="setupform" method="post" action="wp-signup.php" novalidate="novalidate">
<input type="hidden" name="stage" value="validate-user-signup" />