Code Editor: Improve ability to create Customizer CodeEditorControl instances in JS, lessening PHP dependencies.
Allow `CodeEditorControl` to be instantiated with a `editor_settings` param which is merged with `wp.codeEditor.defaultSettings`. Also: * Turn redundant "CSS Code" control label into screen reader text for Additional CSS. * Remove `code-editor` as script dependency for `custom-html-widgets` since enqueueing is determined by `wp_enqueue_code_editor()`. * Remove useless exporting of `code_type` param to JS in `WP_Customize_Code_Editor_Control`. * Add `disabled` class to Custom HTML widget's Save button when linting errors are present. * Remove redundant `span` inside CodeEditorControl's `label`. See #41897, #12423, #41872. Built from https://develop.svn.wordpress.org/trunk@41957 git-svn-id: http://core.svn.wordpress.org/trunk@41791 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -5152,15 +5152,43 @@
|
||||
* @returns {void}
|
||||
*/
|
||||
initEditor: function() {
|
||||
var control = this, element;
|
||||
var control = this, element, editorSettings = false;
|
||||
|
||||
// Obtain editorSettings for instantiation.
|
||||
if ( wp.codeEditor && ( _.isUndefined( control.params.editor_settings ) || false !== control.params.editor_settings ) ) {
|
||||
|
||||
// Obtain default editor settings.
|
||||
editorSettings = wp.codeEditor.defaultSettings ? _.clone( wp.codeEditor.defaultSettings ) : {};
|
||||
editorSettings.codemirror = _.extend(
|
||||
{},
|
||||
editorSettings.codemirror,
|
||||
{
|
||||
indentUnit: 2,
|
||||
tabSize: 2
|
||||
}
|
||||
);
|
||||
|
||||
// Merge editor_settings param on top of defaults.
|
||||
if ( _.isObject( control.params.editor_settings ) ) {
|
||||
_.each( control.params.editor_settings, function( value, key ) {
|
||||
if ( _.isObject( value ) ) {
|
||||
editorSettings[ key ] = _.extend(
|
||||
{},
|
||||
editorSettings[ key ],
|
||||
value
|
||||
);
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
element = new api.Element( control.container.find( 'textarea' ) );
|
||||
control.elements.push( element );
|
||||
element.sync( control.setting );
|
||||
element.set( control.setting() );
|
||||
|
||||
if ( control.params.editor_settings ) {
|
||||
control.initSyntaxHighlightingEditor( control.params.editor_settings );
|
||||
if ( editorSettings ) {
|
||||
control.initSyntaxHighlightingEditor( editorSettings );
|
||||
} else {
|
||||
control.initPlainTextareaEditor();
|
||||
}
|
||||
@@ -8839,6 +8867,9 @@
|
||||
sectionReady.done( function setupSectionDescription( section ) {
|
||||
var control = api.control( 'custom_css' );
|
||||
|
||||
// Hide redundant label for visual users.
|
||||
control.container.find( '.customize-control-title:first' ).addClass( 'screen-reader-text' );
|
||||
|
||||
// Close the section description when clicking the close button.
|
||||
section.container.find( '.section-description-buttons .section-description-close' ).on( 'click', function() {
|
||||
section.container.find( '.section-meta .customize-section-description:first' )
|
||||
|
||||
6
wp-admin/js/customize-controls.min.js
vendored
6
wp-admin/js/customize-controls.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -204,7 +204,7 @@ wp.customHtmlWidgets = ( function( $ ) {
|
||||
* @returns {void}
|
||||
*/
|
||||
onUpdateErrorNotice: function onUpdateErrorNotice( errorAnnotations ) {
|
||||
control.saveButton.toggleClass( 'validation-blocked', errorAnnotations.length );
|
||||
control.saveButton.toggleClass( 'validation-blocked disabled', errorAnnotations.length );
|
||||
control.updateErrorNotice( errorAnnotations );
|
||||
}
|
||||
});
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user