Make WordPress Core


Ignore:
Timestamp:
10/13/2016 10:27:15 PM (8 years ago)
Author:
jeremyfelt
Message:

Multisite: Maintain switched state in site icon/logo functions.

Adjusts get_custom_logo(), get_site_icon_url(), and has_custom_logo() so that when called in a switched state, the original switched stack is not adjusted.

Props achbed, flixos90.
Fixes #38253.

File:
1 edited

Legend:

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

    r38764 r38786  
    784784 */
    785785function get_site_icon_url( $size = 512, $url = '', $blog_id = 0 ) {
    786     if ( is_multisite() && (int) $blog_id !== get_current_blog_id() ) {
     786    $switched_blog = false;
     787
     788    if ( is_multisite() && ! empty( $blog_id ) && (int) $blog_id !== get_current_blog_id() ) {
    787789        switch_to_blog( $blog_id );
     790        $switched_blog = true;
    788791    }
    789792
     
    799802    }
    800803
    801     if ( is_multisite() && ms_is_switched() ) {
     804    if ( $switched_blog ) {
    802805        restore_current_blog();
    803806    }
     
    849852 */
    850853function has_custom_logo( $blog_id = 0 ) {
    851     if ( is_multisite() && (int) $blog_id !== get_current_blog_id() ) {
     854    $switched_blog = false;
     855
     856    if ( is_multisite() && ! empty( $blog_id ) && (int) $blog_id !== get_current_blog_id() ) {
    852857        switch_to_blog( $blog_id );
     858        $switched_blog = true;
    853859    }
    854860
    855861    $custom_logo_id = get_theme_mod( 'custom_logo' );
    856862
    857     if ( is_multisite() && ms_is_switched() ) {
     863    if ( $switched_blog ) {
    858864        restore_current_blog();
    859865    }
     
    872878function get_custom_logo( $blog_id = 0 ) {
    873879    $html = '';
    874 
    875     if ( is_multisite() && (int) $blog_id !== get_current_blog_id() ) {
     880    $switched_blog = false;
     881
     882    if ( is_multisite() && ! empty( $blog_id ) && (int) $blog_id !== get_current_blog_id() ) {
    876883        switch_to_blog( $blog_id );
     884        $switched_blog = true;
    877885    }
    878886
     
    897905    }
    898906
    899     if ( is_multisite() && ms_is_switched() ) {
     907    if ( $switched_blog ) {
    900908        restore_current_blog();
    901909    }
Note: See TracChangeset for help on using the changeset viewer.