Make WordPress Core

Changeset 41603


Ignore:
Timestamp:
09/26/2017 08:32:46 PM (6 years ago)
Author:
westonruter
Message:

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

Amends [41597].
See #39896.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/customize-controls.js

    r41597 r41603  
    55115511                                wp_customize: 'on',
    55125512                                customize_theme: api.settings.theme.stylesheet,
    5513                                 customize_changeset_uuid: api.settings.changeset.latestAutoDraftUuid || api.settings.changeset.uuid,
     5513                                customize_changeset_uuid: api.settings.changeset.uuid,
    55145514                                nonce: api.settings.nonce.dismiss_autosave
    55155515                            } );
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r41597 r41603  
    30553055
    30563056        $changeset_post_id = $this->changeset_post_id();
    3057         if ( empty( $changeset_post_id ) ) {
    3058             wp_send_json_error( 'missing_changeset', 404 );
    3059         }
    3060 
    3061         if ( 'auto-draft' === get_post_status( $changeset_post_id ) ) {
    3062             if ( ! update_post_meta( $changeset_post_id, '_customize_restore_dismissed', true ) ) {
    3063                 wp_send_json_error( 'auto_draft_dismissal_failure', 500 );
     3057
     3058        if ( empty( $changeset_post_id ) || 'auto-draft' === get_post_status( $changeset_post_id ) ) {
     3059            $changeset_autodraft_posts = $this->get_changeset_posts( array(
     3060                'post_status' => 'auto-draft',
     3061                'exclude_restore_dismissed' => true,
     3062                'posts_per_page' => -1,
     3063            ) );
     3064            $dismissed = 0;
     3065            foreach ( $changeset_autodraft_posts as $autosave_autodraft_post ) {
     3066                if ( $autosave_autodraft_post->ID === $changeset_post_id ) {
     3067                    continue;
     3068                }
     3069                if ( update_post_meta( $autosave_autodraft_post->ID, '_customize_restore_dismissed', true ) ) {
     3070                    $dismissed++;
     3071                }
     3072            }
     3073            if ( $dismissed > 0 ) {
     3074                wp_send_json_success( 'auto_draft_dismissed' );
    30643075            } else {
    3065                 wp_send_json_success( 'auto_draft_dismissed' );
     3076                wp_send_json_error( 'no_autosave_to_delete', 404 );
    30663077            }
    30673078        } else {
Note: See TracChangeset for help on using the changeset viewer.