From dfa53a1da762e239bb0be2f4cc4ba1425c743230 Mon Sep 17 00:00:00 2001 From: Konstantin Obenland Date: Tue, 11 Aug 2015 16:25:27 +0000 Subject: [PATCH] Site Icon: Improvements to Site Icon API. * Only call `get_blog_option()` when there is a blog id and we're in Mulitsite. If there is no blog id the request is for the current blog. * Check return value of `wp_get_attachment_image_src()` before getting the URL since it could be `false`. * Use `{bool}` rather than `!!` to return a boolean value. Props MikeHansenMe, obenland. Fixes #33326. Built from https://develop.svn.wordpress.org/trunk@33606 git-svn-id: http://core.svn.wordpress.org/trunk@33573 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/general-template.php | 13 ++++++------- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 6ed04e27ad..8f2cdf67aa 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -730,23 +730,22 @@ function get_bloginfo( $show = '', $filter = 'raw' ) { * @return string Site Icon URL. */ function get_site_icon_url( $size = 512, $url = '', $blog_id = 0 ) { - if ( function_exists( 'get_blog_option' ) ) { - if ( ! $blog_id ) { - $blog_id = get_current_blog_id(); - } + if ( $blog_id && is_multisite() ) { $site_icon_id = get_blog_option( $blog_id, 'site_icon' ); } else { $site_icon_id = get_option( 'site_icon' ); } - if ( $site_icon_id ) { + if ( $site_icon_id ) { if ( $size >= 512 ) { $size_data = 'full'; } else { $size_data = array( $size, $size ); } $url_data = wp_get_attachment_image_src( $site_icon_id, $size_data ); - $url = $url_data[0]; + if ( $url_data ) { + $url = $url_data[0]; + } } return $url; @@ -770,7 +769,7 @@ function site_icon_url( $size = 512, $url = '', $blog_id = 0 ) { * @return bool */ function has_site_icon( $blog_id = 0 ) { - return !! get_site_icon_url( 512, '', $blog_id ); + return (bool) get_site_icon_url( 512, '', $blog_id ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 9b8870c5a5..6778d617ec 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.3-RC2-33605'; +$wp_version = '4.3-RC2-33606'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.