Make WordPress Core


Ignore:
Timestamp:
09/02/2011 10:13:55 PM (13 years ago)
Author:
azaozz
Message:

Avoid losing widgets when switching themes - take one, props aaroncampbell, see #17979

File:
1 edited

Legend:

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

    r18325 r18630  
    12491249    global $wp_theme_directories;
    12501250
     1251    $old_theme = get_current_theme();
     1252
    12511253    update_option('template', $template);
    12521254    update_option('stylesheet', $stylesheet);
     1255
    12531256    if ( count($wp_theme_directories) > 1 ) {
    12541257        update_option('template_root', get_raw_theme_root($template, true));
    12551258        update_option('stylesheet_root', get_raw_theme_root($stylesheet, true));
    12561259    }
     1260
    12571261    delete_option('current_theme');
    12581262    $theme = get_current_theme();
     1263
    12591264    if ( is_admin() && false === get_option( "theme_mods_$stylesheet" ) ) {
    12601265        $default_theme_mods = (array) get_option( "mods_$theme" );
    12611266        add_option( "theme_mods_$stylesheet", $default_theme_mods );
    12621267    }
    1263     do_action('switch_theme', $theme);
     1268
     1269    update_option( 'theme_switched', $old_theme );
     1270    do_action( 'switch_theme', $theme );
    12641271}
    12651272
Note: See TracChangeset for help on using the changeset viewer.