From f3c2c7350cdba3a81a07fb59379f834d8aed01dd Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Sun, 8 Nov 2015 02:04:27 +0000 Subject: [PATCH] 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 --- wp-includes/general-template.php | 12 ++++++++---- wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 05b86f2c11..aea94f7dff 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -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. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 787fa3f6b4..62e4fc3191 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.