WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/14/2014 10:45:40 PM (6 years ago)
Author:
nacin
Message:

Customizer: Properly handle widget settings when activating a previewed theme.

props westonruter, ocean90, gcorne.
fixes #27767.

File:
1 edited

Legend:

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

    r27967 r28124  
    14021402}
    14031403
    1404 // look for "lost" widgets, this has to run at least on each theme change
    1405 function retrieve_widgets($theme_changed = false) {
     1404/**
     1405 * Look for "lost" widgets, this has to run at least on each theme change.
     1406 *
     1407 * @since 2.8.0
     1408 *
     1409 * @param mixed $theme_changed Whether the theme was changed as a boolean. A value
     1410 *                             of 'customize' defers updates for the customizer.
     1411 * @return array
     1412 */
     1413function retrieve_widgets( $theme_changed = false ) {
    14061414    global $wp_registered_sidebars, $sidebars_widgets, $wp_registered_widgets;
    14071415
     
    14131421        // time() that sidebars were stored is in $old_sidebars_widgets['time']
    14141422        $_sidebars_widgets = $old_sidebars_widgets['data'];
    1415         remove_theme_mod( 'sidebars_widgets' );
     1423
     1424        if ( 'customize' === $theme_changed ) {
     1425            remove_theme_mod( 'sidebars_widgets' );
     1426        }
    14161427
    14171428        foreach ( $_sidebars_widgets as $sidebar => $widgets ) {
     
    14961507
    14971508    $sidebars_widgets['wp_inactive_widgets'] = array_merge($lost_widgets, (array) $sidebars_widgets['wp_inactive_widgets']);
    1498     wp_set_sidebars_widgets($sidebars_widgets);
     1509    if ( 'customize' === $theme_changed ) {
     1510        wp_set_sidebars_widgets( $sidebars_widgets );
     1511    }
    14991512
    15001513    return $sidebars_widgets;
Note: See TracChangeset for help on using the changeset viewer.