WordPress.org

Make WordPress Core

Ticket #25439: 25439.diff

File 25439.diff, 1.2 KB (added by westonruter, 5 years ago)

Prompt user with AYS dialog if leaving the Customizer with unsaved changes. Commit: https://github.com/x-team/wordpress-develop/commit/82349c18f8a0b13a4cefba031d6da61e6205189a PR: https://github.com/x-team/wordpress-develop/pull/23

  • src/wp-admin/js/customize-controls.js

    diff --git src/wp-admin/js/customize-controls.js src/wp-admin/js/customize-controls.js
    index 4bfc252..831a9e6 100644
     
    11281128                        });
    11291129                });
    11301130
     1131                // Prompt user with AYS dialog if leaving the Customizer with unsaved changes
     1132                $( window ).on( 'beforeunload', function () {
     1133                        if ( ! api.state( 'saved' )() ) {
     1134                                return api.l10n.saveAlert;
     1135                        }
     1136                } );
     1137
    11311138                // Pass events through to the parent.
    11321139                api.bind( 'saved', function() {
    11331140                        parent.send( 'saved' );
  • src/wp-includes/script-loader.php

    diff --git src/wp-includes/script-loader.php src/wp-includes/script-loader.php
    index df42718..c0d42b6 100644
    function wp_default_scripts( &$scripts ) { 
    381381        did_action( 'init' ) && $scripts->localize( 'customize-controls', '_wpCustomizeControlsL10n', array(
    382382                'activate'  => __( 'Save & Activate' ),
    383383                'save'      => __( 'Save & Publish' ),
     384                'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ),
    384385                'saved'     => __( 'Saved' ),
    385386                'cancel'    => __( 'Cancel' ),
    386387                'close'     => __( 'Close' ),