WordPress.org

Make WordPress Core

Changeset 19332


Ignore:
Timestamp:
11/18/11 06:00:29 (4 years ago)
Author:
azaozz
Message:

When restoring sidebars after switching back to an old theme, make sure the saved data matches the theme's current sidebars, fixes #19092

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/widgets.php

    r19054 r19332  
    11651165    global $wp_registered_widget_updates, $wp_registered_sidebars, $sidebars_widgets, $wp_registered_widgets; 
    11661166 
     1167    $_sidebars_widgets = array(); 
     1168    $sidebars = array_keys($wp_registered_sidebars); 
    11671169    $old_sidebars_widgets = get_theme_mod( 'sidebars_widgets' ); 
    11681170    if ( is_array( $old_sidebars_widgets ) ) { 
    11691171        // time() that sidebars were stored is in $old_sidebars_widgets['time'] 
    1170         $_sidebars_widgets = $old_sidebars_widgets['data']; 
     1172        $old_sidebars = $old_sidebars_widgets['data']; 
     1173 
     1174        // make sure the saved sidebars match 
     1175        foreach ( $sidebars as $sidebar_id ) { 
     1176            $_sidebars_widgets[$sidebar_id] = isset($old_sidebars[$sidebar_id]) ? $old_sidebars[$sidebar_id] : array(); 
     1177        } 
     1178 
    11711179        remove_theme_mod( 'sidebars_widgets' ); 
    11721180    } else { 
    11731181        if ( empty( $sidebars_widgets ) ) 
    11741182            return; 
    1175  
    1176         $sidebars = array_keys($wp_registered_sidebars); 
    11771183 
    11781184        unset( $sidebars_widgets['array_version'] ); 
Note: See TracChangeset for help on using the changeset viewer.