Customize: Dismiss all autosaved auto-drafts for user and not just the one suggested when dismissing restoration notification.

Amends [41597].
See #39896.

Built from https://develop.svn.wordpress.org/trunk@41603


git-svn-id: http://core.svn.wordpress.org/trunk@41438 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2017-09-26 20:33:46 +00:00
parent eb38b0da9b
commit cb8173e053
4 changed files with 21 additions and 10 deletions

View File

@ -5510,7 +5510,7 @@
wp.ajax.post( 'dismiss_customize_changeset_autosave', {
wp_customize: 'on',
customize_theme: api.settings.theme.stylesheet,
customize_changeset_uuid: api.settings.changeset.latestAutoDraftUuid || api.settings.changeset.uuid,
customize_changeset_uuid: api.settings.changeset.uuid,
nonce: api.settings.nonce.dismiss_autosave
} );
} );

File diff suppressed because one or more lines are too long

View File

@ -3054,15 +3054,26 @@ final class WP_Customize_Manager {
}
$changeset_post_id = $this->changeset_post_id();
if ( empty( $changeset_post_id ) ) {
wp_send_json_error( 'missing_changeset', 404 );
}
if ( 'auto-draft' === get_post_status( $changeset_post_id ) ) {
if ( ! update_post_meta( $changeset_post_id, '_customize_restore_dismissed', true ) ) {
wp_send_json_error( 'auto_draft_dismissal_failure', 500 );
} else {
if ( empty( $changeset_post_id ) || 'auto-draft' === get_post_status( $changeset_post_id ) ) {
$changeset_autodraft_posts = $this->get_changeset_posts( array(
'post_status' => 'auto-draft',
'exclude_restore_dismissed' => true,
'posts_per_page' => -1,
) );
$dismissed = 0;
foreach ( $changeset_autodraft_posts as $autosave_autodraft_post ) {
if ( $autosave_autodraft_post->ID === $changeset_post_id ) {
continue;
}
if ( update_post_meta( $autosave_autodraft_post->ID, '_customize_restore_dismissed', true ) ) {
$dismissed++;
}
}
if ( $dismissed > 0 ) {
wp_send_json_success( 'auto_draft_dismissed' );
} else {
wp_send_json_error( 'no_autosave_to_delete', 404 );
}
} else {
$revision = wp_get_post_autosave( $changeset_post_id );

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-alpha-41602';
$wp_version = '4.9-alpha-41603';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.