Multisite: use `get_current_blog_id()` where applicable, in lieu of plucking the `$blog_id` global from outer space.
See #37699. Built from https://develop.svn.wordpress.org/trunk@38457 git-svn-id: http://core.svn.wordpress.org/trunk@38398 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
049c36d11f
commit
e5225324a2
|
@ -91,13 +91,14 @@ class WP_Themes_List_Table extends WP_List_Table {
|
|||
return;
|
||||
}
|
||||
|
||||
$blog_id = get_current_blog_id();
|
||||
if ( is_multisite() ) {
|
||||
if ( current_user_can( 'install_themes' ) && current_user_can( 'manage_network_themes' ) ) {
|
||||
printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> or <a href="%2$s">install</a> more themes.' ), network_admin_url( 'site-themes.php?id=' . $GLOBALS['blog_id'] ), network_admin_url( 'theme-install.php' ) );
|
||||
printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> or <a href="%2$s">install</a> more themes.' ), network_admin_url( 'site-themes.php?id=' . $blog_id ), network_admin_url( 'theme-install.php' ) );
|
||||
|
||||
return;
|
||||
} elseif ( current_user_can( 'manage_network_themes' ) ) {
|
||||
printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> more themes.' ), network_admin_url( 'site-themes.php?id=' . $GLOBALS['blog_id'] ) );
|
||||
printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> more themes.' ), network_admin_url( 'site-themes.php?id=' . $blog_id ) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -729,14 +729,10 @@ class WP_Object_Cache {
|
|||
* Sets up object properties; PHP 5 style constructor.
|
||||
*
|
||||
* @since 2.0.8
|
||||
*
|
||||
* @global int $blog_id Global blog ID.
|
||||
*/
|
||||
public function __construct() {
|
||||
global $blog_id;
|
||||
|
||||
$this->multisite = is_multisite();
|
||||
$this->blog_prefix = $this->multisite ? $blog_id . ':' : '';
|
||||
$this->blog_prefix = $this->multisite ? get_current_blog_id() . ':' : '';
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -104,7 +104,7 @@ class WP_User_Query {
|
|||
*/
|
||||
public static function fill_query_vars( $args ) {
|
||||
$defaults = array(
|
||||
'blog_id' => $GLOBALS['blog_id'],
|
||||
'blog_id' => get_current_blog_id(),
|
||||
'role' => '',
|
||||
'role__in' => array(),
|
||||
'role__not_in' => array(),
|
||||
|
|
|
@ -2357,7 +2357,6 @@ function update_usermeta( $user_id, $meta_key, $meta_value ) {
|
|||
* @see get_users()
|
||||
*
|
||||
* @global wpdb $wpdb WordPress database abstraction object.
|
||||
* @global int $blog_id The site ID of the site for those that use more than one site.
|
||||
*
|
||||
* @param int $id Site ID.
|
||||
* @return array List of users that are part of that site ID
|
||||
|
@ -2365,9 +2364,10 @@ function update_usermeta( $user_id, $meta_key, $meta_value ) {
|
|||
function get_users_of_blog( $id = '' ) {
|
||||
_deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' );
|
||||
|
||||
global $wpdb, $blog_id;
|
||||
if ( empty($id) )
|
||||
$id = (int) $blog_id;
|
||||
global $wpdb;
|
||||
if ( empty( $id ) ) {
|
||||
$id = get_current_blog_id();
|
||||
}
|
||||
$blog_prefix = $wpdb->get_blog_prefix($id);
|
||||
$users = $wpdb->get_results( "SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY {$wpdb->usermeta}.user_id" );
|
||||
return $users;
|
||||
|
|
|
@ -470,18 +470,15 @@ function wp_using_ext_object_cache( $using = null ) {
|
|||
*
|
||||
* @since 3.0.0
|
||||
* @access private
|
||||
*
|
||||
* @global int $blog_id Blog ID.
|
||||
*/
|
||||
function wp_start_object_cache() {
|
||||
global $blog_id;
|
||||
|
||||
$first_init = false;
|
||||
if ( ! function_exists( 'wp_cache_init' ) ) {
|
||||
if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {
|
||||
require_once ( WP_CONTENT_DIR . '/object-cache.php' );
|
||||
if ( function_exists( 'wp_cache_init' ) )
|
||||
if ( function_exists( 'wp_cache_init' ) ) {
|
||||
wp_using_ext_object_cache( true );
|
||||
}
|
||||
}
|
||||
|
||||
$first_init = true;
|
||||
|
@ -495,18 +492,20 @@ function wp_start_object_cache() {
|
|||
wp_using_ext_object_cache( true );
|
||||
}
|
||||
|
||||
if ( ! wp_using_ext_object_cache() )
|
||||
if ( ! wp_using_ext_object_cache() ) {
|
||||
require_once ( ABSPATH . WPINC . '/cache.php' );
|
||||
}
|
||||
|
||||
/*
|
||||
* If cache supports reset, reset instead of init if already
|
||||
* initialized. Reset signals to the cache that global IDs
|
||||
* have changed and it may need to update keys and cleanup caches.
|
||||
*/
|
||||
if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) )
|
||||
wp_cache_switch_to_blog( $blog_id );
|
||||
elseif ( function_exists( 'wp_cache_init' ) )
|
||||
if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) ) {
|
||||
wp_cache_switch_to_blog( get_current_blog_id() );
|
||||
} elseif ( function_exists( 'wp_cache_init' ) ) {
|
||||
wp_cache_init();
|
||||
}
|
||||
|
||||
if ( function_exists( 'wp_cache_add_global_groups' ) ) {
|
||||
wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'site-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites' ) );
|
||||
|
|
|
@ -766,17 +766,19 @@ function update_blog_option( $id, $option, $value, $deprecated = null ) {
|
|||
function switch_to_blog( $new_blog, $deprecated = null ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( empty( $new_blog ) )
|
||||
$new_blog = $GLOBALS['blog_id'];
|
||||
$blog_id = get_current_blog_id();
|
||||
if ( empty( $new_blog ) ) {
|
||||
$new_blog = $blog_id;
|
||||
}
|
||||
|
||||
$GLOBALS['_wp_switched_stack'][] = $GLOBALS['blog_id'];
|
||||
$GLOBALS['_wp_switched_stack'][] = $blog_id;
|
||||
|
||||
/*
|
||||
* If we're switching to the same blog id that we're on,
|
||||
* set the right vars, do the associated actions, but skip
|
||||
* the extra unnecessary work
|
||||
*/
|
||||
if ( $new_blog == $GLOBALS['blog_id'] ) {
|
||||
if ( $new_blog == $blog_id ) {
|
||||
/**
|
||||
* Fires when the blog is switched.
|
||||
*
|
||||
|
@ -792,7 +794,7 @@ function switch_to_blog( $new_blog, $deprecated = null ) {
|
|||
|
||||
$wpdb->set_blog_id( $new_blog );
|
||||
$GLOBALS['table_prefix'] = $wpdb->get_blog_prefix();
|
||||
$prev_blog_id = $GLOBALS['blog_id'];
|
||||
$prev_blog_id = $blog_id;
|
||||
$GLOBALS['blog_id'] = $new_blog;
|
||||
|
||||
if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
|
||||
|
@ -800,11 +802,11 @@ function switch_to_blog( $new_blog, $deprecated = null ) {
|
|||
} else {
|
||||
global $wp_object_cache;
|
||||
|
||||
if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
|
||||
if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) {
|
||||
$global_groups = $wp_object_cache->global_groups;
|
||||
else
|
||||
} else {
|
||||
$global_groups = false;
|
||||
|
||||
}
|
||||
wp_cache_init();
|
||||
|
||||
if ( function_exists( 'wp_cache_add_global_groups' ) ) {
|
||||
|
@ -848,12 +850,14 @@ function switch_to_blog( $new_blog, $deprecated = null ) {
|
|||
function restore_current_blog() {
|
||||
global $wpdb;
|
||||
|
||||
if ( empty( $GLOBALS['_wp_switched_stack'] ) )
|
||||
if ( empty( $GLOBALS['_wp_switched_stack'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$blog = array_pop( $GLOBALS['_wp_switched_stack'] );
|
||||
$blog_id = get_current_blog_id();
|
||||
|
||||
if ( $GLOBALS['blog_id'] == $blog ) {
|
||||
if ( $blog_id == $blog ) {
|
||||
/** This filter is documented in wp-includes/ms-blogs.php */
|
||||
do_action( 'switch_blog', $blog, $blog );
|
||||
// If we still have items in the switched stack, consider ourselves still 'switched'
|
||||
|
@ -862,7 +866,7 @@ function restore_current_blog() {
|
|||
}
|
||||
|
||||
$wpdb->set_blog_id( $blog );
|
||||
$prev_blog_id = $GLOBALS['blog_id'];
|
||||
$prev_blog_id = $blog_id;
|
||||
$GLOBALS['blog_id'] = $blog;
|
||||
$GLOBALS['table_prefix'] = $wpdb->get_blog_prefix();
|
||||
|
||||
|
@ -871,10 +875,11 @@ function restore_current_blog() {
|
|||
} else {
|
||||
global $wp_object_cache;
|
||||
|
||||
if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
|
||||
if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) {
|
||||
$global_groups = $wp_object_cache->global_groups;
|
||||
else
|
||||
} else {
|
||||
$global_groups = false;
|
||||
}
|
||||
|
||||
wp_cache_init();
|
||||
|
||||
|
|
|
@ -1966,15 +1966,12 @@ function maybe_add_existing_user_to_blog() {
|
|||
*
|
||||
* @since MU
|
||||
*
|
||||
* @global int $blog_id
|
||||
*
|
||||
* @param array $details
|
||||
* @return true|WP_Error|void
|
||||
*/
|
||||
function add_existing_user_to_blog( $details = false ) {
|
||||
global $blog_id;
|
||||
|
||||
if ( is_array( $details ) ) {
|
||||
$blog_id = get_current_blog_id();
|
||||
$result = add_user_to_blog( $blog_id, $details[ 'user_id' ], $details[ 'role' ] );
|
||||
/**
|
||||
* Fires immediately after an existing user is added to a site.
|
||||
|
|
|
@ -965,8 +965,6 @@ function setup_userdata($for_user_id = '') {
|
|||
* @since 2.3.0
|
||||
* @since 4.5.0 Added the 'display_name_with_login' value for 'show'.
|
||||
*
|
||||
* @global int $blog_id
|
||||
*
|
||||
* @param array|string $args {
|
||||
* Optional. Array or string of arguments to generate a drop-down of users.
|
||||
* See WP_User_Query::prepare_query() for additional available arguments.
|
||||
|
@ -1016,7 +1014,7 @@ function wp_dropdown_users( $args = '' ) {
|
|||
'include' => '', 'exclude' => '', 'multi' => 0,
|
||||
'show' => 'display_name', 'echo' => 1,
|
||||
'selected' => 0, 'name' => 'user', 'class' => '', 'id' => '',
|
||||
'blog_id' => $GLOBALS['blog_id'], 'who' => '', 'include_selected' => false,
|
||||
'blog_id' => get_current_blog_id(), 'who' => '', 'include_selected' => false,
|
||||
'option_none_value' => -1
|
||||
);
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.7-alpha-38456';
|
||||
$wp_version = '4.7-alpha-38457';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue