Make WordPress Core


Ignore:
Timestamp:
11/08/2015 02:03:34 AM (11 years ago)
Author:
jeremyfelt
Message:

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.

File:
1 edited

Legend:

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

    r35571 r35572  
    759759 */
    760760function get_site_icon_url( $size = 512, $url = '', $blog_id = 0 ) {
    761         if ( $blog_id && is_multisite() ) {
    762                 $site_icon_id = get_blog_option( $blog_id, 'site_icon' );
    763         } else {
    764                 $site_icon_id = get_option( 'site_icon' );
    765         }
     761        if ( is_multisite() && (int) $blog_id !== get_current_blog_id() ) {
     762                switch_to_blog( $blog_id );
     763        }
     764
     765        $site_icon_id = get_option( 'site_icon' );
    766766
    767767        if ( $site_icon_id ) {
    … …  
    772772                }
    773773                $url = wp_get_attachment_image_url( $site_icon_id, $size_data );
     774        }
     775
     776        if ( is_multisite() && ms_is_switched() ) {
     777                restore_current_blog();
    774778        }
    775779
Note: See TracChangeset for help on using the changeset viewer.