Make WordPress Core

Changeset 41694


Ignore:
Timestamp:
10/03/2017 12:21:06 AM (7 years ago)
Author:
westonruter
Message:

Customize: Add button in Publish Settings to discard unsaved changes (including drafted and scheduled), reverting Customizer to the last published state.

Props westonruter, melchoyce.
Amends [41667].
See #39896, #21666.

Location:
trunk/src
Files:
3 edited

Legend:

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

    r41679 r41694  
    63326332
    63336333        api.section( 'publish_settings', function( section ) {
    6334             var updateButtonsState, previewLinkControl, previewLinkControlId = 'changeset_preview_link', updateSectionActive, isSectionActive;
     6334            var updateButtonsState, previewLinkControl, TrashControl, trashControlInstance, trashControlId = 'trash_changeset', previewLinkControlId = 'changeset_preview_link', updateSectionActive, isSectionActive;
     6335
     6336            TrashControl = api.Control.extend( {
     6337
     6338                // This is a temporary hack while waiting for richer JS templating and dynamic instantiation.
     6339                embed: function() {
     6340                    var control = this;
     6341                    control.templateSelector = 'customize-trash-changeset-control';
     6342                    return api.Control.prototype.embed.apply( control, arguments );
     6343                }
     6344            } );
     6345
     6346            trashControlInstance = new TrashControl( trashControlId, {
     6347                params: {
     6348                    type: 'button',
     6349                    section: section.id,
     6350                    active: true,
     6351                    priority: 30,
     6352                    content: '<li id="customize-control-' + trashControlId + '" class="customize-control"></li>'
     6353                }
     6354            } );
     6355            api.control.add( trashControlId, trashControlInstance );
     6356            trashControlInstance.deferred.embedded.done( function() {
     6357                trashControlInstance.container.find( 'button' ).on( 'click', function() {
     6358                    if ( confirm( api.l10n.trashConfirm ) ) {
     6359                        wp.customize.previewer.trash();
     6360                    }
     6361                } );
     6362            } );
    63356363
    63366364            previewLinkControl = new api.PreviewLinkControl( previewLinkControlId, {
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r41670 r41694  
    36403640        </script>
    36413641        <script type="text/html" id="tmpl-customize-trash-changeset-control">
    3642             <button type="button" class="button-link button-link-delete"><?php _e( 'Trash unpublished changes' ); ?></button>
     3642            <button type="button" class="button-link button-link-delete"><?php _e( 'Discard changes' ); ?></button>
    36433643        </script>
    36443644        <?php
  • trunk/src/wp-includes/script-loader.php

    r41667 r41694  
    575575        'themePreviewWait'   => __( 'Setting up your live preview. This may take a bit.' ),
    576576        'revertingChanges'   => __( 'Reverting unpublished changes&hellip;' ),
    577         'trashConfirm'       => __( 'Are you sure you would like to discard your unpublished changes?' ),
     577        'trashConfirm'       => __( 'Are you sure you&#8217;d like to discard your unpublished changes?' ),
    578578        /* translators: %s: URL to the Customizer to load the autosaved version */
    579579        'autosaveNotice'     => __( 'There is a more recent autosave of your changes than the one you are previewing. <a href="%s">Restore the autosave</a>' ),
Note: See TracChangeset for help on using the changeset viewer.