Site Icon: Wrap site icon retrieval with switch_to_blog() as needed.

When the site icon for another site is requested, retrieving its ID via `get_blog_option()` is not enough. `switch_to_blog()` is used to set proper context when required.

Adds multsite tests for `has_site_icon()`.

Props imath.
Fixes #34312.

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


git-svn-id: http://core.svn.wordpress.org/trunk@35536 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Jeremy Felt 2015-11-08 02:04:27 +00:00
parent d1c09d96bf
commit f3c2c7350c
2 changed files with 9 additions and 5 deletions

View File

@ -758,12 +758,12 @@ function get_bloginfo( $show = '', $filter = 'raw' ) {
* @return string Site Icon URL.
*/
function get_site_icon_url( $size = 512, $url = '', $blog_id = 0 ) {
if ( $blog_id && is_multisite() ) {
$site_icon_id = get_blog_option( $blog_id, 'site_icon' );
} else {
$site_icon_id = get_option( 'site_icon' );
if ( is_multisite() && (int) $blog_id !== get_current_blog_id() ) {
switch_to_blog( $blog_id );
}
$site_icon_id = get_option( 'site_icon' );
if ( $site_icon_id ) {
if ( $size >= 512 ) {
$size_data = 'full';
@ -773,6 +773,10 @@ function get_site_icon_url( $size = 512, $url = '', $blog_id = 0 ) {
$url = wp_get_attachment_image_url( $site_icon_id, $size_data );
}
if ( is_multisite() && ms_is_switched() ) {
restore_current_blog();
}
/**
* Filter the site icon URL.
*

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-beta3-35571';
$wp_version = '4.4-beta3-35572';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.