From a415c29efee45520ae252d2aa28f1083a521cd7b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 09:56:49 +0200 Subject: Adding upstream version 6.4.3+dfsg1. Signed-off-by: Daniel Baumann --- .../class-wp-customize-code-editor-control.php | 111 +++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 wp-includes/customize/class-wp-customize-code-editor-control.php (limited to 'wp-includes/customize/class-wp-customize-code-editor-control.php') diff --git a/wp-includes/customize/class-wp-customize-code-editor-control.php b/wp-includes/customize/class-wp-customize-code-editor-control.php new file mode 100644 index 0000000..c22d6ea --- /dev/null +++ b/wp-includes/customize/class-wp-customize-code-editor-control.php @@ -0,0 +1,111 @@ +editor_settings = wp_enqueue_code_editor( + array_merge( + array( + 'type' => $this->code_type, + 'codemirror' => array( + 'indentUnit' => 2, + 'tabSize' => 2, + ), + ), + $this->editor_settings + ) + ); + } + + /** + * Refresh the parameters passed to the JavaScript via JSON. + * + * @since 4.9.0 + * + * @see WP_Customize_Control::json() + * + * @return array Array of parameters passed to the JavaScript. + */ + public function json() { + $json = parent::json(); + $json['editor_settings'] = $this->editor_settings; + $json['input_attrs'] = $this->input_attrs; + return $json; + } + + /** + * Don't render the control content from PHP, as it's rendered via JS on load. + * + * @since 4.9.0 + */ + public function render_content() {} + + /** + * Render a JS template for control display. + * + * @since 4.9.0 + */ + public function content_template() { + ?> + <# var elementIdPrefix = 'el' + String( Math.random() ); #> + <# if ( data.label ) { #> + + <# } #> + <# if ( data.description ) { #> + {{{ data.description }}} + <# } #> +
+ +