Multisite: Revert [38388].
Restore `get_current_site()` to a multisite only function. Providing this in single site may be a possibility in the future, but should have a dedicated ticket and discussion. See #37699. Built from https://develop.svn.wordpress.org/trunk@38636 git-svn-id: http://core.svn.wordpress.org/trunk@38579 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2ec9f4b369
commit
58f107fa95
|
@ -4309,19 +4309,23 @@ function wp_suspend_cache_invalidation( $suspend = true ) {
|
||||||
*
|
*
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*
|
*
|
||||||
|
* @global object $current_site
|
||||||
|
*
|
||||||
* @param int $site_id Optional. Site ID to test. Defaults to 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
|
* @return bool True if $site_id is the main site of the network, or if not
|
||||||
* running Multisite.
|
* running Multisite.
|
||||||
*/
|
*/
|
||||||
function is_main_site( $site_id = null ) {
|
function is_main_site( $site_id = null ) {
|
||||||
if ( ! is_multisite() ) {
|
// This is the current network's information; 'site' is old terminology.
|
||||||
return true;
|
global $current_site;
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! $site_id ) {
|
if ( ! is_multisite() )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if ( ! $site_id )
|
||||||
$site_id = get_current_blog_id();
|
$site_id = get_current_blog_id();
|
||||||
}
|
|
||||||
return (int) $site_id === (int) get_current_site()->blog_id;
|
return (int) $site_id === (int) $current_site->blog_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3257,15 +3257,13 @@ function network_site_url( $path = '', $scheme = null ) {
|
||||||
|
|
||||||
$current_site = get_current_site();
|
$current_site = get_current_site();
|
||||||
|
|
||||||
if ( 'relative' == $scheme ) {
|
if ( 'relative' == $scheme )
|
||||||
$url = $current_site->path;
|
$url = $current_site->path;
|
||||||
} else {
|
else
|
||||||
$url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme );
|
$url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme );
|
||||||
}
|
|
||||||
|
|
||||||
if ( $path && is_string( $path ) ) {
|
if ( $path && is_string( $path ) )
|
||||||
$url .= ltrim( $path, '/' );
|
$url .= ltrim( $path, '/' );
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the network site URL.
|
* Filters the network site URL.
|
||||||
|
@ -3305,15 +3303,13 @@ function network_home_url( $path = '', $scheme = null ) {
|
||||||
if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) )
|
if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) )
|
||||||
$scheme = is_ssl() && ! is_admin() ? 'https' : 'http';
|
$scheme = is_ssl() && ! is_admin() ? 'https' : 'http';
|
||||||
|
|
||||||
if ( 'relative' == $scheme ) {
|
if ( 'relative' == $scheme )
|
||||||
$url = $current_site->path;
|
$url = $current_site->path;
|
||||||
} else {
|
else
|
||||||
$url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme );
|
$url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme );
|
||||||
}
|
|
||||||
|
|
||||||
if ( $path && is_string( $path ) ) {
|
if ( $path && is_string( $path ) )
|
||||||
$url .= ltrim( $path, '/' );
|
$url .= ltrim( $path, '/' );
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the network home URL.
|
* Filters the network home URL.
|
||||||
|
|
|
@ -1068,22 +1068,3 @@ function wp_doing_ajax() {
|
||||||
function is_wp_error( $thing ) {
|
function is_wp_error( $thing ) {
|
||||||
return ( $thing instanceof WP_Error );
|
return ( $thing instanceof WP_Error );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the current network.
|
|
||||||
*
|
|
||||||
* Returns an object containing the 'id', 'domain', 'path', and 'site_name'
|
|
||||||
* properties of the network being viewed.
|
|
||||||
*
|
|
||||||
* @see wpmu_current_site()
|
|
||||||
*
|
|
||||||
* @since MU
|
|
||||||
*
|
|
||||||
* @global WP_Network $current_site
|
|
||||||
*
|
|
||||||
* @return WP_Network
|
|
||||||
*/
|
|
||||||
function get_current_site() {
|
|
||||||
global $current_site;
|
|
||||||
return $current_site;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1088,11 +1088,13 @@ function get_networks( $args = array() ) {
|
||||||
*
|
*
|
||||||
* @since 4.6.0
|
* @since 4.6.0
|
||||||
*
|
*
|
||||||
|
* @global WP_Network $current_site
|
||||||
|
*
|
||||||
* @param WP_Network|int|null $network Optional. Network to retrieve. Default is the current network.
|
* @param WP_Network|int|null $network Optional. Network to retrieve. Default is the current network.
|
||||||
* @return WP_Network|null The network object or null if not found.
|
* @return WP_Network|null The network object or null if not found.
|
||||||
*/
|
*/
|
||||||
function get_network( $network = null ) {
|
function get_network( $network = null ) {
|
||||||
$current_site = get_current_site();
|
global $current_site;
|
||||||
if ( empty( $network ) && isset( $current_site ) ) {
|
if ( empty( $network ) && isset( $current_site ) ) {
|
||||||
$network = $current_site;
|
$network = $current_site;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1332,7 +1332,8 @@ function insert_blog($domain, $path, $site_id) {
|
||||||
* @param string $blog_title The title of the new site.
|
* @param string $blog_title The title of the new site.
|
||||||
*/
|
*/
|
||||||
function install_blog( $blog_id, $blog_title = '' ) {
|
function install_blog( $blog_id, $blog_title = '' ) {
|
||||||
global $wpdb, $wp_roles;
|
global $wpdb, $wp_roles, $current_site;
|
||||||
|
|
||||||
// Cast for security
|
// Cast for security
|
||||||
$blog_id = (int) $blog_id;
|
$blog_id = (int) $blog_id;
|
||||||
|
|
||||||
|
@ -1360,7 +1361,7 @@ function install_blog( $blog_id, $blog_title = '' ) {
|
||||||
if ( 'https' === parse_url( get_site_option( 'siteurl' ), PHP_URL_SCHEME ) ) {
|
if ( 'https' === parse_url( get_site_option( 'siteurl' ), PHP_URL_SCHEME ) ) {
|
||||||
$siteurl = set_url_scheme( $siteurl, 'https' );
|
$siteurl = set_url_scheme( $siteurl, 'https' );
|
||||||
}
|
}
|
||||||
if ( 'https' === parse_url( get_home_url( get_current_site()->blog_id ), PHP_URL_SCHEME ) ) {
|
if ( 'https' === parse_url( get_home_url( $current_site->blog_id ), PHP_URL_SCHEME ) ) {
|
||||||
$home = set_url_scheme( $home, 'https' );
|
$home = set_url_scheme( $home, 'https' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1497,9 +1498,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_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
|
||||||
$message = $welcome_email;
|
$message = $welcome_email;
|
||||||
|
|
||||||
if ( empty( $current_site->site_name ) ) {
|
if ( empty( $current_site->site_name ) )
|
||||||
$current_site->site_name = 'WordPress';
|
$current_site->site_name = 'WordPress';
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the subject of the welcome email after site activation.
|
* Filters the subject of the welcome email after site activation.
|
||||||
|
@ -1591,6 +1591,25 @@ function wpmu_welcome_user_notification( $user_id, $password, $meta = array() )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current network.
|
||||||
|
*
|
||||||
|
* Returns an object containing the 'id', 'domain', 'path', and 'site_name'
|
||||||
|
* properties of the network being viewed.
|
||||||
|
*
|
||||||
|
* @see wpmu_current_site()
|
||||||
|
*
|
||||||
|
* @since MU
|
||||||
|
*
|
||||||
|
* @global WP_Network $current_site
|
||||||
|
*
|
||||||
|
* @return WP_Network
|
||||||
|
*/
|
||||||
|
function get_current_site() {
|
||||||
|
global $current_site;
|
||||||
|
return $current_site;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a user's most recent post.
|
* Get a user's most recent post.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1070,6 +1070,7 @@ function update_site_option( $option, $value ) {
|
||||||
* @see get_option()
|
* @see get_option()
|
||||||
*
|
*
|
||||||
* @global wpdb $wpdb
|
* @global wpdb $wpdb
|
||||||
|
* @global object $current_site
|
||||||
*
|
*
|
||||||
* @param int $network_id ID of the network. Can be null to default to the current network ID.
|
* @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.
|
* @param string $option Name of option to retrieve. Expected to not be SQL-escaped.
|
||||||
|
@ -1077,7 +1078,7 @@ function update_site_option( $option, $value ) {
|
||||||
* @return mixed Value set for the option.
|
* @return mixed Value set for the option.
|
||||||
*/
|
*/
|
||||||
function get_network_option( $network_id, $option, $default = false ) {
|
function get_network_option( $network_id, $option, $default = false ) {
|
||||||
global $wpdb;
|
global $wpdb, $current_site;
|
||||||
|
|
||||||
if ( $network_id && ! is_numeric( $network_id ) ) {
|
if ( $network_id && ! is_numeric( $network_id ) ) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1087,7 +1088,7 @@ function get_network_option( $network_id, $option, $default = false ) {
|
||||||
|
|
||||||
// Fallback to the current network if a network ID is not specified.
|
// Fallback to the current network if a network ID is not specified.
|
||||||
if ( ! $network_id && is_multisite() ) {
|
if ( ! $network_id && is_multisite() ) {
|
||||||
$network_id = get_current_site()->id;
|
$network_id = $current_site->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1186,6 +1187,7 @@ function get_network_option( $network_id, $option, $default = false ) {
|
||||||
* @see add_option()
|
* @see add_option()
|
||||||
*
|
*
|
||||||
* @global wpdb $wpdb
|
* @global wpdb $wpdb
|
||||||
|
* @global object $current_site
|
||||||
*
|
*
|
||||||
* @param int $network_id ID of the network. Can be null to default to the current network ID.
|
* @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.
|
* @param string $option Name of option to add. Expected to not be SQL-escaped.
|
||||||
|
@ -1193,7 +1195,7 @@ function get_network_option( $network_id, $option, $default = false ) {
|
||||||
* @return bool False if option was not added and true if option was added.
|
* @return bool False if option was not added and true if option was added.
|
||||||
*/
|
*/
|
||||||
function add_network_option( $network_id, $option, $value ) {
|
function add_network_option( $network_id, $option, $value ) {
|
||||||
global $wpdb;
|
global $wpdb, $current_site;
|
||||||
|
|
||||||
if ( $network_id && ! is_numeric( $network_id ) ) {
|
if ( $network_id && ! is_numeric( $network_id ) ) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1203,7 +1205,7 @@ function add_network_option( $network_id, $option, $value ) {
|
||||||
|
|
||||||
// Fallback to the current network if a network ID is not specified.
|
// Fallback to the current network if a network ID is not specified.
|
||||||
if ( ! $network_id && is_multisite() ) {
|
if ( ! $network_id && is_multisite() ) {
|
||||||
$network_id = get_current_site()->id;
|
$network_id = $current_site->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
wp_protect_special_option( $option );
|
wp_protect_special_option( $option );
|
||||||
|
@ -1295,13 +1297,14 @@ function add_network_option( $network_id, $option, $value ) {
|
||||||
* @see delete_option()
|
* @see delete_option()
|
||||||
*
|
*
|
||||||
* @global wpdb $wpdb
|
* @global wpdb $wpdb
|
||||||
|
* @global object $current_site
|
||||||
*
|
*
|
||||||
* @param int $network_id ID of the network. Can be null to default to the current network ID.
|
* @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.
|
* @param string $option Name of option to remove. Expected to not be SQL-escaped.
|
||||||
* @return bool True, if succeed. False, if failure.
|
* @return bool True, if succeed. False, if failure.
|
||||||
*/
|
*/
|
||||||
function delete_network_option( $network_id, $option ) {
|
function delete_network_option( $network_id, $option ) {
|
||||||
global $wpdb;
|
global $wpdb, $current_site;
|
||||||
|
|
||||||
if ( $network_id && ! is_numeric( $network_id ) ) {
|
if ( $network_id && ! is_numeric( $network_id ) ) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1311,7 +1314,7 @@ function delete_network_option( $network_id, $option ) {
|
||||||
|
|
||||||
// Fallback to the current network if a network ID is not specified.
|
// Fallback to the current network if a network ID is not specified.
|
||||||
if ( ! $network_id && is_multisite() ) {
|
if ( ! $network_id && is_multisite() ) {
|
||||||
$network_id = get_current_site()->id;
|
$network_id = $current_site->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1376,6 +1379,7 @@ function delete_network_option( $network_id, $option ) {
|
||||||
* @see update_option()
|
* @see update_option()
|
||||||
*
|
*
|
||||||
* @global wpdb $wpdb
|
* @global wpdb $wpdb
|
||||||
|
* @global object $current_site
|
||||||
*
|
*
|
||||||
* @param int $network_id ID of the network. Can be null to default to the current network ID.
|
* @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.
|
* @param string $option Name of option. Expected to not be SQL-escaped.
|
||||||
|
@ -1383,7 +1387,7 @@ function delete_network_option( $network_id, $option ) {
|
||||||
* @return bool False if value was not updated and true if value was updated.
|
* @return bool False if value was not updated and true if value was updated.
|
||||||
*/
|
*/
|
||||||
function update_network_option( $network_id, $option, $value ) {
|
function update_network_option( $network_id, $option, $value ) {
|
||||||
global $wpdb;
|
global $wpdb, $current_site;
|
||||||
|
|
||||||
if ( $network_id && ! is_numeric( $network_id ) ) {
|
if ( $network_id && ! is_numeric( $network_id ) ) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1393,7 +1397,7 @@ function update_network_option( $network_id, $option, $value ) {
|
||||||
|
|
||||||
// Fallback to the current network if a network ID is not specified.
|
// Fallback to the current network if a network ID is not specified.
|
||||||
if ( ! $network_id && is_multisite() ) {
|
if ( ! $network_id && is_multisite() ) {
|
||||||
$network_id = get_current_site()->id;
|
$network_id = $current_site->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
wp_protect_special_option( $option );
|
wp_protect_special_option( $option );
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.7-alpha-38635';
|
$wp_version = '4.7-alpha-38636';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue