From 8f37374c3d76866c75263d340824968f0a70f5a6 Mon Sep 17 00:00:00 2001 From: Konstantin Obenland Date: Tue, 11 Aug 2015 16:24:07 +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. git-svn-id: https://develop.svn.wordpress.org/trunk@33606 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/general-template.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index 6ed04e27ad..8f2cdf67aa 100644 --- a/src/wp-includes/general-template.php +++ b/src/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 ); } /**