From 6b6a643b0b7a3597e2464c32c74cc2773eaabb70 Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Tue, 17 Nov 2020 04:43:33 +0000 Subject: [PATCH] Customize: Temporary fix for autosave restore notice not being removed Fixes the "There is a more recent autosave of your changes" notice from not being removed when the dismiss button is clicked. The problem is caused by the notice being initialized twice: once by the `common` script and then again by the `customize-controls` script. This temporary fix prevents `customize-controls` from initializing a notice if it has already been initialized. A better fix would be to not initialize notices twice. This can be done by removing `common` as a dependency of `updates` when `deprecateL10nObject` is removed. When this happens (est: 5.7), this temporary fix should be reverted. Fixes #51425. See #51317. Props karthikbhatb, dlh, SergeyBiryukov. git-svn-id: https://develop.svn.wordpress.org/trunk@49625 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/admin/common.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/js/_enqueues/admin/common.js b/src/js/_enqueues/admin/common.js index 3832bcac2c..eea96d3778 100644 --- a/src/js/_enqueues/admin/common.js +++ b/src/js/_enqueues/admin/common.js @@ -1094,6 +1094,10 @@ $document.ready( function() { var $el = $( this ), $button = $( '' ); + if ( $el.find( '.notice-dismiss' ).length ) { + return; + } + // Ensure plain text. $button.find( '.screen-reader-text' ).text( __( 'Dismiss this notice.' ) ); $button.on( 'click.wp-dismiss-notice', function( event ) {