WordPress.org

Make WordPress Core

Changeset 18654


Ignore:
Timestamp:
09/08/11 19:25:20 (3 years ago)
Author:
azaozz
Message:

Use theme mods instead of transients for storing the previous theme's widgets config, props aaroncampbell, see #17979

Location:
trunk/wp-includes
Files:
2 edited

Legend:

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

    r18639 r18654  
    12471247 */ 
    12481248function switch_theme($template, $stylesheet) { 
    1249     global $wp_theme_directories; 
     1249    global $wp_theme_directories, $sidebars_widgets; 
     1250 
     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 ) ); 
    12501254 
    12511255    $old_theme = get_current_theme(); 
  • trunk/wp-includes/widgets.php

    r18639 r18654  
    12021202            $sidebars_widgets = wp_get_sidebars_widgets(); 
    12031203 
    1204         $key = md5( $old_theme ); 
    1205         // Store widgets for 1 week so we can restore if needed 
    1206         set_transient( 'old_widgets_' . $key, $sidebars_widgets, 604800 ); 
    1207  
    12081204        retrieve_widgets(); 
    12091205        update_option( 'theme_switched', false ); 
     
    12151211    global $wp_registered_widget_updates, $wp_registered_sidebars, $sidebars_widgets, $wp_registered_widgets; 
    12161212 
    1217     $key = md5( get_current_theme() ); 
    1218     if ( false !== ( $_sidebars_widgets = get_transient( "old_widgets_{$key}" ) ) ) { 
    1219         delete_transient( "old_widgets_{$key}" ); 
     1213    $old_sidebars_widgets = get_theme_mod( 'sidebars_widgets' ); 
     1214    if ( is_array( $old_sidebars_widgets ) ) { 
     1215        // time() that sidebars were stored is in $old_sidebars_widgets['time'] 
     1216        $_sidebars_widgets = $old_sidebars_widgets['data']; 
     1217        remove_theme_mod( 'sidebars_widgets' ); 
    12201218    } else { 
    12211219        if ( ! is_array( $sidebars_widgets ) ) 
Note: See TracChangeset for help on using the changeset viewer.