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

Prevent sending back DB-persisted setting values in customize_save_response unless changeset is being published #317

Merged
merged 2 commits into from
Nov 18, 2016
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
15 changes: 13 additions & 2 deletions php/class-wp-customize-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,19 @@ public function filter_customize_save_response_for_conflicts( $response ) {
* @return array
*/
public function filter_customize_save_response_to_export_saved_values( $response ) {
// Short circuit if there there were invalidities.
if ( isset( $response['setting_validities'] ) && count( array_filter( $response['setting_validities'], 'is_array' ) ) > 0 ) {
$has_invalidities = (
isset( $response['setting_validities'] )
&&
count( array_filter( $response['setting_validities'], 'is_array' ) ) > 0
);
$changeset_status_publish = (
empty( $response['changeset_status'] ) // Prior to 4.7, this filter only would run on actual saves.
||
'publish' === $response['changeset_status']
);

// Short circuit if there there were invalidities or the changeset status was not publish.
if ( $has_invalidities || ! $changeset_status_publish ) {
return $response;
}

Expand Down