Customize: Allow notifications for linting errors in code editor control (for Additional CSS) to be overridden to allow saving.

Implements the same override that was implemented in [41721] for the theme/plugin editors.

See #41897, #41887.
Fixes #42528.


git-svn-id: https://develop.svn.wordpress.org/trunk@42171 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Weston Ruter 2017-11-13 21:18:49 +00:00
parent 33f7cfd2b9
commit e260210294
2 changed files with 33 additions and 0 deletions

View File

@ -5280,6 +5280,27 @@
codemirror: $.Deferred()
} );
api.Control.prototype.initialize.call( control, id, options );
// Note that rendering is debounced so the props will be used when rendering happens after add event.
control.notifications.bind( 'add', function( notification ) {
// Skip if control notification is not from setting csslint_error notification.
if ( notification.code !== control.setting.id + ':csslint_error' ) {
return;
}
// Customize the template and behavior of csslint_error notifications.
notification.templateId = 'customize-code-editor-lint-error-notification';
notification.render = (function( render ) {
return function() {
var li = render.call( this );
li.find( 'input[type=checkbox]' ).on( 'click', function() {
control.setting.notifications.remove( 'csslint_error' );
} );
return li;
};
})( notification.render );
} );
},
/**

View File

@ -4125,6 +4125,18 @@ final class WP_Customize_Manager {
</li>
</script>
<script type="text/html" id="tmpl-customize-code-editor-lint-error-notification">
<li class="notice notice-{{ data.type || 'info' }} {{ data.alt ? 'notice-alt' : '' }} {{ data.dismissible ? 'is-dismissible' : '' }} {{ data.containerClasses || '' }}" data-code="{{ data.code }}" data-type="{{ data.type }}">
<div class="notification-message">{{{ data.message || data.code }}}</div>
<p>
<# var elementId = 'el-' + String( Math.random() ); #>
<input id="{{ elementId }}" type="checkbox">
<label for="{{ elementId }}"><?php _e( 'Update anyway, even though it might break your site?' ); ?></label>
</p>
</li>
</script>
<?php
/* The following template is obsolete in core but retained for plugins. */
?>