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
This commit is contained in:
Konstantin Obenland 2015-08-11 16:25:27 +00:00
parent 731c255aee
commit dfa53a1da7
2 changed files with 7 additions and 8 deletions

View File

@ -730,23 +730,22 @@ 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 ( function_exists( 'get_blog_option' ) ) { if ( $blog_id && is_multisite() ) {
if ( ! $blog_id ) {
$blog_id = get_current_blog_id();
}
$site_icon_id = get_blog_option( $blog_id, 'site_icon' ); $site_icon_id = get_blog_option( $blog_id, 'site_icon' );
} else { } else {
$site_icon_id = get_option( 'site_icon' ); $site_icon_id = get_option( 'site_icon' );
} }
if ( $site_icon_id ) { if ( $site_icon_id ) {
if ( $size >= 512 ) { if ( $size >= 512 ) {
$size_data = 'full'; $size_data = 'full';
} else { } else {
$size_data = array( $size, $size ); $size_data = array( $size, $size );
} }
$url_data = wp_get_attachment_image_src( $site_icon_id, $size_data ); $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; return $url;
@ -770,7 +769,7 @@ function site_icon_url( $size = 512, $url = '', $blog_id = 0 ) {
* @return bool * @return bool
*/ */
function has_site_icon( $blog_id = 0 ) { function has_site_icon( $blog_id = 0 ) {
return !! get_site_icon_url( 512, '', $blog_id ); return (bool) get_site_icon_url( 512, '', $blog_id );
} }
/** /**

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @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. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.