Multisite: Maintain switched state in site icon/logo functions.

Adjusts `get_custom_logo()`, `get_site_icon_url()`, and `has_custom_logo()` so that when called in a switched state, the original switched stack is not adjusted.

Props achbed, flixos90.
Fixes #38253.

Built from https://develop.svn.wordpress.org/trunk@38786


git-svn-id: http://core.svn.wordpress.org/trunk@38729 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Jeremy Felt 2016-10-13 22:28:28 +00:00
parent 456f8015b7
commit 295e48baa9
2 changed files with 15 additions and 7 deletions

View File

@ -783,8 +783,11 @@ function get_bloginfo( $show = '', $filter = 'raw' ) {
* @return string Site Icon URL. * @return string Site Icon URL.
*/ */
function get_site_icon_url( $size = 512, $url = '', $blog_id = 0 ) { function get_site_icon_url( $size = 512, $url = '', $blog_id = 0 ) {
if ( is_multisite() && (int) $blog_id !== get_current_blog_id() ) { $switched_blog = false;
if ( is_multisite() && ! empty( $blog_id ) && (int) $blog_id !== get_current_blog_id() ) {
switch_to_blog( $blog_id ); switch_to_blog( $blog_id );
$switched_blog = true;
} }
$site_icon_id = get_option( 'site_icon' ); $site_icon_id = get_option( 'site_icon' );
@ -798,7 +801,7 @@ function get_site_icon_url( $size = 512, $url = '', $blog_id = 0 ) {
$url = wp_get_attachment_image_url( $site_icon_id, $size_data ); $url = wp_get_attachment_image_url( $site_icon_id, $size_data );
} }
if ( is_multisite() && ms_is_switched() ) { if ( $switched_blog ) {
restore_current_blog(); restore_current_blog();
} }
@ -848,13 +851,16 @@ function has_site_icon( $blog_id = 0 ) {
* @return bool Whether the site has a custom logo or not. * @return bool Whether the site has a custom logo or not.
*/ */
function has_custom_logo( $blog_id = 0 ) { function has_custom_logo( $blog_id = 0 ) {
if ( is_multisite() && (int) $blog_id !== get_current_blog_id() ) { $switched_blog = false;
if ( is_multisite() && ! empty( $blog_id ) && (int) $blog_id !== get_current_blog_id() ) {
switch_to_blog( $blog_id ); switch_to_blog( $blog_id );
$switched_blog = true;
} }
$custom_logo_id = get_theme_mod( 'custom_logo' ); $custom_logo_id = get_theme_mod( 'custom_logo' );
if ( is_multisite() && ms_is_switched() ) { if ( $switched_blog ) {
restore_current_blog(); restore_current_blog();
} }
@ -871,9 +877,11 @@ function has_custom_logo( $blog_id = 0 ) {
*/ */
function get_custom_logo( $blog_id = 0 ) { function get_custom_logo( $blog_id = 0 ) {
$html = ''; $html = '';
$switched_blog = false;
if ( is_multisite() && (int) $blog_id !== get_current_blog_id() ) { if ( is_multisite() && ! empty( $blog_id ) && (int) $blog_id !== get_current_blog_id() ) {
switch_to_blog( $blog_id ); switch_to_blog( $blog_id );
$switched_blog = true;
} }
$custom_logo_id = get_theme_mod( 'custom_logo' ); $custom_logo_id = get_theme_mod( 'custom_logo' );
@ -896,7 +904,7 @@ function get_custom_logo( $blog_id = 0 ) {
); );
} }
if ( is_multisite() && ms_is_switched() ) { if ( $switched_blog ) {
restore_current_blog(); restore_current_blog();
} }

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.7-alpha-38785'; $wp_version = '4.7-alpha-38786';
/** /**
* 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.