Multisite: Use get_current_blog_id() in get_site() for current site.

The global `$current_blog` is not switched in `switch_to_blog()` and can
not be used to properly retrieve current switched site information.

See #37607.


git-svn-id: https://develop.svn.wordpress.org/trunk@38217 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jeremy Felt
2016-08-08 22:32:47 +00:00
parent 0bbd0f3a5f
commit 0df4e1f026
2 changed files with 46 additions and 5 deletions
+2 -5
View File
@@ -478,15 +478,12 @@ function clean_blog_cache( $blog ) {
*
* @since 4.6.0
*
* @global WP_Site $current_blog The current site.
*
* @param WP_Site|int|null $site Optional. Site to retrieve. Default is the current site.
* @return WP_Site|null The site object or null if not found.
*/
function get_site( &$site = null ) {
global $current_blog;
if ( empty( $site ) && isset( $current_blog ) ) {
$site = $current_blog;
if ( empty( $site ) ) {
$site = get_current_blog_id();
}
if ( $site instanceof WP_Site ) {