@@ -645,6 +645,14 @@ public function save_settings_with_publish_snapshot( $new_status, $old_status, $
645
645
return false ;
646
646
}
647
647
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
+
648
656
if ( ! did_action ( 'customize_register ' ) ) {
649
657
/*
650
658
* 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, $
676
684
// undefine( 'DOING_AJAX' )... just kidding. This is the end of the unfortunate hack and it should be fixed in Core.
677
685
unset( $ _REQUEST ['action ' ] );
678
686
}
679
- $ snapshot_content = $ this ->post_type ->get_post_content ( $ post );
680
687
681
688
if ( method_exists ( $ this ->customize_manager , 'validate_setting_values ' ) ) {
682
689
/** 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, $
703
710
if ( ! isset ( $ setting_params ['value ' ] ) || is_null ( $ setting_params ['value ' ] ) ) {
704
711
if ( ! is_array ( $ setting_params ) ) {
705
712
if ( ! empty ( $ setting_params ) ) {
706
- $ setting_params = array ( 'value ' => $ setting_params );
713
+ $ setting_params = array (
714
+ 'value ' => $ setting_params ,
715
+ );
707
716
} else {
708
717
$ setting_params = array ();
709
718
}
@@ -714,7 +723,6 @@ public function save_settings_with_publish_snapshot( $new_status, $old_status, $
714
723
}
715
724
716
725
// Unrecognized setting error.
717
- $ this ->customize_manager ->set_post_value ( $ setting_id , $ setting_params ['value ' ] );
718
726
$ setting = $ this ->customize_manager ->get_setting ( $ setting_id );
719
727
if ( ! ( $ setting instanceof \WP_Customize_Setting ) ) {
720
728
$ setting_params ['publish_error ' ] = 'unrecognized_setting ' ;
0 commit comments