Skip to content
This repository was archived by the owner on Dec 27, 2022. It is now read-only.

Commit efd1bdf

Browse files
committed
Populate back-compat customized state up front for parity with changesets
1 parent d0b5767 commit efd1bdf

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

php/class-customize-snapshot-manager-back-compat.php

+11-3
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,14 @@ public function save_settings_with_publish_snapshot( $new_status, $old_status, $
645645
return false;
646646
}
647647

648+
// Populate customized state with values from snapshot.
649+
$snapshot_content = $this->post_type->get_post_content( $post );
650+
foreach ( $snapshot_content as $setting_id => $setting_params ) {
651+
if ( array_key_exists( 'value', $setting_params ) ) {
652+
$this->customize_manager->set_post_value( $setting_id, $setting_params['value'] );
653+
}
654+
}
655+
648656
if ( ! did_action( 'customize_register' ) ) {
649657
/*
650658
* When running from CLI or Cron, we have to remove the action because
@@ -676,7 +684,6 @@ public function save_settings_with_publish_snapshot( $new_status, $old_status, $
676684
// undefine( 'DOING_AJAX' )... just kidding. This is the end of the unfortunate hack and it should be fixed in Core.
677685
unset( $_REQUEST['action'] );
678686
}
679-
$snapshot_content = $this->post_type->get_post_content( $post );
680687

681688
if ( method_exists( $this->customize_manager, 'validate_setting_values' ) ) {
682689
/** This action is documented in wp-includes/class-wp-customize-manager.php */
@@ -703,7 +710,9 @@ public function save_settings_with_publish_snapshot( $new_status, $old_status, $
703710
if ( ! isset( $setting_params['value'] ) || is_null( $setting_params['value'] ) ) {
704711
if ( ! is_array( $setting_params ) ) {
705712
if ( ! empty( $setting_params ) ) {
706-
$setting_params = array( 'value' => $setting_params );
713+
$setting_params = array(
714+
'value' => $setting_params,
715+
);
707716
} else {
708717
$setting_params = array();
709718
}
@@ -714,7 +723,6 @@ public function save_settings_with_publish_snapshot( $new_status, $old_status, $
714723
}
715724

716725
// Unrecognized setting error.
717-
$this->customize_manager->set_post_value( $setting_id, $setting_params['value'] );
718726
$setting = $this->customize_manager->get_setting( $setting_id );
719727
if ( ! ( $setting instanceof \WP_Customize_Setting ) ) {
720728
$setting_params['publish_error'] = 'unrecognized_setting';

0 commit comments

Comments
 (0)