mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-16 23:00:21 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@38810 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -93,16 +93,18 @@ final class WP_Customize_Widgets {
|
||||
public function __construct( $manager ) {
|
||||
$this->manager = $manager;
|
||||
|
||||
// Skip useless hooks when the user can't manage widgets anyway.
|
||||
// See https://github.com/xwp/wp-customize-snapshots/blob/962586659688a5b1fd9ae93618b7ce2d4e7a421c/php/class-customize-snapshot-manager.php#L420-L449
|
||||
add_filter( 'customize_dynamic_setting_args', array( $this, 'filter_customize_dynamic_setting_args' ), 10, 2 );
|
||||
add_action( 'widgets_init', array( $this, 'register_settings' ), 95 );
|
||||
add_action( 'customize_register', array( $this, 'schedule_customize_register' ), 1 );
|
||||
|
||||
// Skip remaining hooks when the user can't manage widgets anyway.
|
||||
if ( ! current_user_can( 'edit_theme_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
add_filter( 'customize_dynamic_setting_args', array( $this, 'filter_customize_dynamic_setting_args' ), 10, 2 );
|
||||
add_action( 'widgets_init', array( $this, 'register_settings' ), 95 );
|
||||
add_action( 'wp_loaded', array( $this, 'override_sidebars_widgets_for_theme_switch' ) );
|
||||
add_action( 'customize_controls_init', array( $this, 'customize_controls_init' ) );
|
||||
add_action( 'customize_register', array( $this, 'schedule_customize_register' ), 1 );
|
||||
add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
||||
add_action( 'customize_controls_print_styles', array( $this, 'print_styles' ) );
|
||||
add_action( 'customize_controls_print_scripts', array( $this, 'print_scripts' ) );
|
||||
@@ -276,6 +278,7 @@ final class WP_Customize_Widgets {
|
||||
|
||||
$this->old_sidebars_widgets = wp_get_sidebars_widgets();
|
||||
add_filter( 'customize_value_old_sidebars_widgets_data', array( $this, 'filter_customize_value_old_sidebars_widgets_data' ) );
|
||||
$this->manager->set_post_value( 'old_sidebars_widgets_data', $this->old_sidebars_widgets ); // Override any value cached in changeset.
|
||||
|
||||
// retrieve_widgets() looks at the global $sidebars_widgets
|
||||
$sidebars_widgets = $this->old_sidebars_widgets;
|
||||
|
||||
Reference in New Issue
Block a user