WordPress.org

Make WordPress Core

Ticket #17979: 17979.13.diff

File 17979.13.diff, 1.9 KB (added by lancewillett, 6 years ago)

Combines patch on #18598 with removing unneeded wp_get_sidebars_widgets() from switch_theme()

  • wp-includes/theme.php

     
    12481248function switch_theme($template, $stylesheet) { 
    12491249        global $wp_theme_directories, $sidebars_widgets; 
    12501250 
    1251         if ( ! is_array( $sidebars_widgets ) ) 
    1252                 $sidebars_widgets = wp_get_sidebars_widgets(); 
    1253         set_theme_mod( 'sidebars_widgets', array( 'time' => time(), 'data' => $sidebars_widgets ) ); 
     1251        if ( is_array( $sidebars_widgets ) ) 
     1252                set_theme_mod( 'sidebars_widgets', array( 'time' => time(), 'data' => $sidebars_widgets ) ); 
    12541253 
    12551254        $old_theme = get_current_theme(); 
    12561255 
  • wp-includes/widgets.php

     
    998998        if ( $deprecated !== true ) 
    999999                _deprecated_argument( __FUNCTION__, '2.8.1' ); 
    10001000 
    1001         global $wp_registered_widgets, $wp_registered_sidebars, $_wp_sidebars_widgets; 
     1001        global $wp_registered_widgets, $wp_registered_sidebars, $_wp_sidebars_widgets, $sidebars_widgets; 
    10021002 
    10031003        // If loading from front page, consult $_wp_sidebars_widgets rather than options 
    10041004        // to see if wp_convert_widget_settings() has made manipulations in memory. 
     
    12191219                $_sidebars_widgets = $old_sidebars_widgets['data']; 
    12201220                remove_theme_mod( 'sidebars_widgets' ); 
    12211221        } else { 
    1222                 if ( ! is_array( $sidebars_widgets ) ) 
    1223                         $sidebars_widgets = wp_get_sidebars_widgets(); 
    1224  
    12251222                $sidebars = array_keys($wp_registered_sidebars); 
    12261223 
    12271224                unset( $sidebars_widgets['array_version'] ); 
     
    12341231                        return; 
    12351232 
    12361233                $_sidebars_widgets = array( 
    1237                         'wp_inactive_widgets' => $sidebars_widgets['wp_inactive_widgets'] 
     1234                        'wp_inactive_widgets' => !empty( $sidebars_widgets['wp_inactive_widgets'] ) ? $sidebars_widgets['wp_inactive_widgets'] : array() 
    12381235                ); 
    12391236 
    12401237                unset( $sidebars_widgets['wp_inactive_widgets'] );