Skip to content
This repository was archived by the owner on Dec 27, 2022. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions php/class-customize-snapshot-manager-back-compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,14 @@ public function save_settings_with_publish_snapshot( $new_status, $old_status, $
return false;
}

// Populate customized state with values from snapshot.
$snapshot_content = $this->post_type->get_post_content( $post );
foreach ( $snapshot_content as $setting_id => $setting_params ) {
if ( array_key_exists( 'value', $setting_params ) ) {
$this->customize_manager->set_post_value( $setting_id, $setting_params['value'] );
}
}

if ( ! did_action( 'customize_register' ) ) {
/*
* When running from CLI or Cron, we have to remove the action because
Expand Down Expand Up @@ -676,7 +684,6 @@ public function save_settings_with_publish_snapshot( $new_status, $old_status, $
// undefine( 'DOING_AJAX' )... just kidding. This is the end of the unfortunate hack and it should be fixed in Core.
unset( $_REQUEST['action'] );
}
$snapshot_content = $this->post_type->get_post_content( $post );

if ( method_exists( $this->customize_manager, 'validate_setting_values' ) ) {
/** This action is documented in wp-includes/class-wp-customize-manager.php */
Expand All @@ -703,7 +710,9 @@ public function save_settings_with_publish_snapshot( $new_status, $old_status, $
if ( ! isset( $setting_params['value'] ) || is_null( $setting_params['value'] ) ) {
if ( ! is_array( $setting_params ) ) {
if ( ! empty( $setting_params ) ) {
$setting_params = array( 'value' => $setting_params );
$setting_params = array(
'value' => $setting_params,
);
} else {
$setting_params = array();
}
Expand All @@ -714,7 +723,6 @@ public function save_settings_with_publish_snapshot( $new_status, $old_status, $
}

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