WordPress.org

Make WordPress Core

Changeset 33606


Ignore:
Timestamp:
08/11/2015 04:24:07 PM (5 years ago)
Author:
obenland
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/general-template.php

    r33605 r33606  
    731731 */
    732732function get_site_icon_url( $size = 512, $url = '', $blog_id = 0 ) {
    733     if ( function_exists( 'get_blog_option' ) ) {
    734         if ( ! $blog_id ) {
    735             $blog_id = get_current_blog_id();
    736         }
     733    if ( $blog_id && is_multisite() ) {
    737734        $site_icon_id = get_blog_option( $blog_id, 'site_icon' );
    738735    } else {
     
    740737    }
    741738
    742     if ( $site_icon_id  ) {
     739    if ( $site_icon_id ) {
    743740        if ( $size >= 512 ) {
    744741            $size_data = 'full';
     
    747744        }
    748745        $url_data = wp_get_attachment_image_src( $site_icon_id, $size_data );
    749         $url = $url_data[0];
     746        if ( $url_data ) {
     747            $url = $url_data[0];
     748        }
    750749    }
    751750
     
    771770 */
    772771function has_site_icon( $blog_id = 0 ) {
    773     return !! get_site_icon_url( 512, '', $blog_id );
     772    return (bool) get_site_icon_url( 512, '', $blog_id );
    774773}
    775774
Note: See TracChangeset for help on using the changeset viewer.