WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/18/2016 08:04:36 PM (5 years ago)
Author:
westonruter
Message:

Customize: Implement customized state persistence with changesets.

Includes infrastructure developed in the Customize Snapshots feature plugin.

See https://make.wordpress.org/core/2016/10/12/customize-changesets-technical-design-decisions/

Props westonruter, valendesigns, utkarshpatel, stubgo, lgedeon, ocean90, ryankienstra, mihai2u, dlh, aaroncampbell, jonathanbardo, jorbin.
See #28721.
See #31089.
Fixes #30937.
Fixes #31517.
Fixes #30028.
Fixes #23225.
Fixes #34142.
Fixes #36485.

File:
1 edited

Legend:

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

    r38766 r38810  
    9494        $this->manager = $manager;
    9595
    96         // Skip useless hooks when the user can't manage widgets anyway.
     96        // See https://github.com/xwp/wp-customize-snapshots/blob/962586659688a5b1fd9ae93618b7ce2d4e7a421c/php/class-customize-snapshot-manager.php#L420-L449
     97        add_filter( 'customize_dynamic_setting_args',          array( $this, 'filter_customize_dynamic_setting_args' ), 10, 2 );
     98        add_action( 'widgets_init',                            array( $this, 'register_settings' ), 95 );
     99        add_action( 'customize_register',                      array( $this, 'schedule_customize_register' ), 1 );
     100
     101        // Skip remaining hooks when the user can't manage widgets anyway.
    97102        if ( ! current_user_can( 'edit_theme_options' ) ) {
    98103            return;
    99104        }
    100105
    101         add_filter( 'customize_dynamic_setting_args',          array( $this, 'filter_customize_dynamic_setting_args' ), 10, 2 );
    102         add_action( 'widgets_init',                            array( $this, 'register_settings' ), 95 );
    103106        add_action( 'wp_loaded',                               array( $this, 'override_sidebars_widgets_for_theme_switch' ) );
    104107        add_action( 'customize_controls_init',                 array( $this, 'customize_controls_init' ) );
    105         add_action( 'customize_register',                      array( $this, 'schedule_customize_register' ), 1 );
    106108        add_action( 'customize_controls_enqueue_scripts',      array( $this, 'enqueue_scripts' ) );
    107109        add_action( 'customize_controls_print_styles',         array( $this, 'print_styles' ) );
     
    277279        $this->old_sidebars_widgets = wp_get_sidebars_widgets();
    278280        add_filter( 'customize_value_old_sidebars_widgets_data', array( $this, 'filter_customize_value_old_sidebars_widgets_data' ) );
     281        $this->manager->set_post_value( 'old_sidebars_widgets_data', $this->old_sidebars_widgets ); // Override any value cached in changeset.
    279282
    280283        // retrieve_widgets() looks at the global $sidebars_widgets
Note: See TracChangeset for help on using the changeset viewer.