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

Commit 4b69f1f

Browse files
committed
Remove customize_changeset_status param only if auto save is triggered for editbox
1 parent 93ad522 commit 4b69f1f

File tree

2 files changed

+9
-25
lines changed

2 files changed

+9
-25
lines changed

js/customize-snapshots.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
snapshot.data.uuid = snapshot.data.uuid || api.settings.changeset.uuid;
4646
snapshot.data.title = snapshot.data.title || snapshot.data.uuid;
4747

48+
snapshot.editBoxAutoSaveTriggered = false;
49+
4850
if ( api.state.has( 'changesetStatus' ) && api.state( 'changesetStatus' ).get() ) {
4951
api.state( 'snapshot-exists' ).set( true );
5052
}
@@ -608,6 +610,7 @@
608610
return;
609611
}
610612
snapshot.updatePending = true;
613+
snapshot.editBoxAutoSaveTriggered = true;
611614
snapshot.updateSnapshot( status ).done( function() {
612615
snapshot.updatePending = snapshot.dirtyEditControlValues;
613616
if ( ! snapshot.updatePending ) {
@@ -1078,12 +1081,12 @@
10781081
},
10791082

10801083
/**
1081-
* Remove 'customize_changeset_status' if its already set; replace with customize_snapshots_create_revision param.
1084+
* Remove 'customize_changeset_status' if it is being auto saved for edit box to avoid revisions.
10821085
*
10831086
* @return {void}
10841087
*/
10851088
prefilterAjax: function prefilterAjax() {
1086-
var removeParam, isSameStatus;
1089+
var snapshot = this, removeParam;
10871090

10881091
if ( ! api.state.has( 'changesetStatus' ) ) {
10891092
return;
@@ -1102,13 +1105,13 @@
11021105
};
11031106

11041107
$.ajaxPrefilter( function( options, originalOptions ) {
1105-
if ( ! originalOptions.data ) {
1108+
if ( ! originalOptions.data || ! snapshot.editBoxAutoSaveTriggered ) {
11061109
return;
11071110
}
1108-
isSameStatus = api.state( 'changesetStatus' ).get() === originalOptions.data.customize_changeset_status;
1109-
if ( 'customize_save' === originalOptions.data.action && isSameStatus && options.data ) {
1111+
1112+
if ( 'customize_save' === originalOptions.data.action && options.data ) {
11101113
options.data = removeParam( options.data, 'customize_changeset_status' );
1111-
options.data += '&customize_snapshots_create_revision=1';
1114+
snapshot.editBoxAutoSaveTriggered = false;
11121115
}
11131116
} );
11141117
}

php/class-customize-snapshot-manager.php

-19
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ function hooks() {
104104
add_action( 'admin_bar_menu', array( $this, 'remove_all_non_snapshot_admin_bar_links' ), 100000 );
105105
add_action( 'wp_before_admin_bar_render', array( $this, 'print_admin_bar_styles' ) );
106106
add_filter( 'removable_query_args', array( $this, 'filter_removable_query_args' ) );
107-
add_filter( 'wp_save_post_revision_post_has_changed', array( $this, '_filter_revision_post_has_changed' ), 20, 3 );
108107
add_action( 'save_post_customize_changeset', array( $this, 'create_initial_changeset_revision' ) );
109108
add_filter( 'wp_insert_post_data', array( $this, 'prepare_snapshot_post_content_for_publish' ) );
110109
}
@@ -357,24 +356,6 @@ public function create_initial_changeset_revision( $post_id ) {
357356
}
358357
}
359358

360-
/**
361-
* When a customize_save Ajax action is being made, ensure a revision is allowed if customize_snapshots_create_revision query param is present.
362-
*
363-
* @see \WP_Customize_Manager::_filter_revision_post_has_changed()
364-
*
365-
* @param bool $post_has_changed Whether the post has changed.
366-
* @param \WP_Post $last_revision The last revision post object.
367-
* @param \WP_Post $post The post object.
368-
* @return bool Whether a revision should be made.
369-
*/
370-
public function _filter_revision_post_has_changed( $post_has_changed, $last_revision, $post ) {
371-
unset( $last_revision );
372-
if ( 'customize_changeset' === $post->post_type && ! empty( $_POST['customize_snapshots_create_revision'] ) ) {
373-
$post_has_changed = true;
374-
}
375-
return $post_has_changed;
376-
}
377-
378359
/**
379360
* Prepare snapshot post content for publishing.
380361
*

0 commit comments

Comments
 (0)