diff --git a/src/wp-admin/js/widgets/custom-html-widgets.js b/src/wp-admin/js/widgets/custom-html-widgets.js
index 6fd6421..61dabe7 100644
a
|
b
|
wp.customHtmlWidgets = ( function( $ ) { |
116 | 116 | * Show linting error notice. |
117 | 117 | * |
118 | 118 | * @param {Array} errorAnnotations - Error annotations. |
| 119 | * @param {Object} onChangeLintingErrors - codeEditorSettings.onChangeLintingErrors |
119 | 120 | * @returns {void} |
120 | 121 | */ |
121 | | updateErrorNotice: function( errorAnnotations ) { |
| 122 | updateErrorNotice: function( errorAnnotations, onChangeLintingErrors ) { |
122 | 123 | var control = this, errorNotice, message = '', customizeSetting; |
123 | 124 | |
124 | 125 | if ( 1 === errorAnnotations.length ) { |
… |
… |
wp.customHtmlWidgets = ( function( $ ) { |
142 | 143 | } |
143 | 144 | } else if ( 0 !== errorAnnotations.length ) { |
144 | 145 | errorNotice = $( '<div class="inline notice notice-error notice-alt"></div>' ); |
145 | | errorNotice.append( $( '<p></p>', { |
146 | | text: message |
147 | | } ) ); |
| 146 | errorNotice.append( |
| 147 | $( '<p>', { text: message } ), |
| 148 | $( '<p><input type="checkbox"></p>' ).append( |
| 149 | $( '<label>', { text: component.l10n.dismissError } ) |
| 150 | ) |
| 151 | ); |
148 | 152 | control.errorNoticeContainer.empty(); |
149 | 153 | control.errorNoticeContainer.append( errorNotice ); |
150 | 154 | control.errorNoticeContainer.slideDown( 'fast' ); |
151 | 155 | wp.a11y.speak( message ); |
| 156 | |
| 157 | control.errorNoticeContainer.find( 'input[type=checkbox]' ).on( 'click', function() { |
| 158 | control.errorNoticeContainer.slideUp( 'fast' ); |
| 159 | control.errorNoticeContainer.empty(); |
| 160 | onChangeLintingErrors( [] ); |
| 161 | if ( control.fields.content[0].setCustomValidity ) { |
| 162 | control.fields.content[0].setCustomValidity( '' ); |
| 163 | } |
| 164 | } ); |
152 | 165 | } else { |
153 | 166 | control.errorNoticeContainer.slideUp( 'fast' ); |
154 | 167 | } |
… |
… |
wp.customHtmlWidgets = ( function( $ ) { |
195 | 208 | */ |
196 | 209 | onChangeLintingErrors: function onChangeLintingErrors( errorAnnotations ) { |
197 | 210 | control.currentErrorAnnotations = errorAnnotations; |
| 211 | |
| 212 | if ( 0 === errorAnnotations.length ) { |
| 213 | control.saveButton.toggleClass( 'validation-blocked disabled', false ); |
| 214 | } |
198 | 215 | }, |
199 | 216 | |
200 | 217 | /** |
… |
… |
wp.customHtmlWidgets = ( function( $ ) { |
204 | 221 | * @returns {void} |
205 | 222 | */ |
206 | 223 | onUpdateErrorNotice: function onUpdateErrorNotice( errorAnnotations ) { |
207 | | control.saveButton.toggleClass( 'validation-blocked disabled', errorAnnotations.length ); |
208 | | control.updateErrorNotice( errorAnnotations ); |
| 224 | control.saveButton.toggleClass( 'validation-blocked disabled', errorAnnotations.length > 0 ); |
| 225 | |
| 226 | // TODO: find a way to not pass down settings.onChangeLintingErrors |
| 227 | control.updateErrorNotice( errorAnnotations, settings.onChangeLintingErrors ); |
209 | 228 | } |
210 | 229 | }); |
211 | 230 | |
diff --git a/src/wp-includes/widgets/class-wp-widget-custom-html.php b/src/wp-includes/widgets/class-wp-widget-custom-html.php
index 068d6f7..6a42eec 100644
a
|
b
|
class WP_Widget_Custom_HTML extends WP_Widget { |
222 | 222 | /* translators: %d: error count */ |
223 | 223 | 'plural' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 2 ), // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491. |
224 | 224 | ), |
| 225 | 'dismissError' => _( 'Update anyway, even though it might break your site?' ), |
225 | 226 | ); |
226 | 227 | wp_add_inline_script( 'custom-html-widgets', sprintf( 'jQuery.extend( wp.customHtmlWidgets.l10n, %s );', wp_json_encode( $l10n ) ), 'after' ); |
227 | 228 | } |