mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-13 05:10:18 +00:00
Customize: Introduce extensible code editor Customizer control for CodeMirror.
* Adds `WP_Customize_Code_Editor_Control` and `wp.customize.CodeEditorControl()`. * Control respects user preference for syntax highlighting, showing a textarea when user opts out. * Code editor control takes the ad hoc code for Additional CSS and makes it reusable and extensible, for Additional CSS in core and plugins to use (such as Jetpack). * Replace `settings` arg in `wp_enqueue_code_editor()` with separate args for `codemirror`, `csslint`, `jshint`, and `htmlhint`. * Prefix `codemirror` script and style handles with `wp-` to prevent collisions, as also the object is exported as `wp.CodeMirror` in JS. * Reduce indent size in Customizer code editor instances and Custom HTML widget to use tab size of 2 instead of 4 to save on space. See #12423, #38707, #35395. Fixes #41897. git-svn-id: https://develop.svn.wordpress.org/trunk@41558 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -3125,11 +3125,14 @@ function wp_enqueue_editor() {
|
||||
* @param array $args {
|
||||
* Args.
|
||||
*
|
||||
* @type string $type The MIME type of the file to be edited.
|
||||
* @type string $file Filename to be edited. Extension is used to sniff the type. Can be supplied as alternative to `$type` param.
|
||||
* @type array $settings Settings to merge on top of defaults which derive from `$type` or `$file` args.
|
||||
* @type WP_Theme $theme Theme being edited when on theme editor.
|
||||
* @type string $plugin Plugin being edited when on plugin editor.
|
||||
* @type string $type The MIME type of the file to be edited.
|
||||
* @type string $file Filename to be edited. Extension is used to sniff the type. Can be supplied as alternative to `$type` param.
|
||||
* @type WP_Theme $theme Theme being edited when on theme editor.
|
||||
* @type string $plugin Plugin being edited when on plugin editor.
|
||||
* @type array $codemirror Additional CodeMirror setting overrides.
|
||||
* @type array $csslint CSSLint rule overrides.
|
||||
* @type array $jshint JSHint rule overrides.
|
||||
* @type array $htmlhint JSHint rule overrides.
|
||||
* }
|
||||
* @returns array|false Settings for the enqueued code editor, or false if the editor was not enqueued .
|
||||
*/
|
||||
@@ -3408,13 +3411,11 @@ function wp_enqueue_code_editor( $args ) {
|
||||
}
|
||||
|
||||
// Let settings supplied via args override any defaults.
|
||||
if ( isset( $args['settings'] ) ) {
|
||||
foreach ( $args['settings'] as $key => $value ) {
|
||||
$settings[ $key ] = array_merge(
|
||||
$settings[ $key ],
|
||||
$value
|
||||
);
|
||||
}
|
||||
foreach ( wp_array_slice_assoc( $args, array( 'codemirror', 'csslint', 'jshint', 'htmlhint' ) ) as $key => $value ) {
|
||||
$settings[ $key ] = array_merge(
|
||||
$settings[ $key ],
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3428,11 +3429,14 @@ function wp_enqueue_code_editor( $args ) {
|
||||
* @param array $args {
|
||||
* Args passed when calling `wp_enqueue_code_editor()`.
|
||||
*
|
||||
* @type string $type The MIME type of the file to be edited.
|
||||
* @type string $file Filename being edited.
|
||||
* @type array $settings Settings to merge on top of defaults which derive from `$type` or `$file` args.
|
||||
* @type WP_Theme $theme Theme being edited when on theme editor.
|
||||
* @type string $plugin Plugin being edited when on plugin editor.
|
||||
* @type string $type The MIME type of the file to be edited.
|
||||
* @type string $file Filename being edited.
|
||||
* @type WP_Theme $theme Theme being edited when on theme editor.
|
||||
* @type string $plugin Plugin being edited when on plugin editor.
|
||||
* @type array $codemirror Additional CodeMirror setting overrides.
|
||||
* @type array $csslint CSSLint rule overrides.
|
||||
* @type array $jshint JSHint rule overrides.
|
||||
* @type array $htmlhint JSHint rule overrides.
|
||||
* }
|
||||
*/
|
||||
$settings = apply_filters( 'wp_code_editor_settings', $settings, $args );
|
||||
@@ -3444,9 +3448,6 @@ function wp_enqueue_code_editor( $args ) {
|
||||
wp_enqueue_script( 'code-editor' );
|
||||
wp_enqueue_style( 'code-editor' );
|
||||
|
||||
wp_enqueue_script( 'codemirror' );
|
||||
wp_enqueue_style( 'codemirror' );
|
||||
|
||||
if ( isset( $settings['codemirror']['mode'] ) ) {
|
||||
$mode = $settings['codemirror']['mode'];
|
||||
if ( is_string( $mode ) ) {
|
||||
|
||||
Reference in New Issue
Block a user