wppaste
WordPress

WP_Customize_Code_Editor_Control

Since
4.9.0
Source
wp-includes/customize/class-wp-customize-code-editor-control.php:17
Customize Code Editor Control class.

Compatibility

WordPress
since 4.9.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Properties · 3

$typestringpublic
Customize control type.
$code_typestringpublic
Type of code that is being edited.
$editor_settingsarray|falsepublic
Code editor settings.

Methods · 4

  • enqueue()Enqueue control related scripts/styles.
  • json()Refresh the parameters passed to the JavaScript via JSON.
  • render_content()Don't render the control content from PHP, as it's rendered via JS on load.
  • content_template()Render a JS template for control display.

Source code

class WP_Customize_Code_Editor_Control extends WP_Customize_Control { 	/**	 * Customize control type.	 *	 * @since 4.9.0	 * @var string	 */	public $type = 'code_editor'; 	/**	 * Type of code that is being edited.	 *	 * @since 4.9.0	 * @var string	 */	public $code_type = ''; 	/**	 * Code editor settings.	 *	 * @see wp_enqueue_code_editor()	 * @since 4.9.0	 * @var array|false	 */	public $editor_settings = array(); 	/**	 * Enqueue control related scripts/styles.	 *	 * @since 4.9.0	 */	public function enqueue() {		$this->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 ) { #>			<label for="{{ elementIdPrefix }}_editor" class="customize-control-title">

Changelog

Introduced in 4.9.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 tag, from src/wp-includes/customize/class-wp-customize-code-editor-control.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.