class-kirki-controls-editor-control.php (2111B)
1 <?php 2 /** 3 * Customizer Control: editor. 4 * 5 * Creates a TinyMCE textarea. 6 * 7 * @package Kirki 8 * @subpackage Controls 9 * @copyright Copyright (c) 2016, Aristeides Stathopoulos 10 * @license http://opensource.org/licenses/https://opensource.org/licenses/MIT 11 * @since 1.0 12 */ 13 14 // Exit if accessed directly. 15 if ( ! defined( 'ABSPATH' ) ) { 16 exit; 17 } 18 19 if ( ! class_exists( 'Kirki_Controls_Editor_Control' ) ) { 20 21 /** 22 * A TinyMCE control. 23 */ 24 class Kirki_Controls_Editor_Control extends Kirki_Customize_Control { 25 26 /** 27 * The control type. 28 * 29 * @access public 30 * @var string 31 */ 32 public $type = 'kirki-editor'; 33 34 /** 35 * Enqueue control related scripts/styles. 36 * 37 * @access public 38 */ 39 public function enqueue() { 40 wp_enqueue_script( 'kirki-editor' ); 41 } 42 43 /** 44 * An Underscore (JS) template for this control's content (but not its container). 45 * 46 * Class variables for this control class are available in the `data` JS object; 47 * export custom variables by overriding {@see Kirki_Customize_Control::to_json()}. 48 * 49 * The actual editor is added from the Kirki_Field_Editor class. 50 * All this template contains is a button that triggers the global editor on/off 51 * and a hidden textarea element that is used to mirror save the options. 52 * 53 * @see WP_Customize_Control::print_template() 54 * 55 * @access protected 56 */ 57 protected function content_template() { 58 ?> 59 <# if ( data.tooltip ) { #> 60 <a href="#" class="tooltip hint--left" data-hint="{{ data.tooltip }}"><span class='dashicons dashicons-info'></span></a> 61 <# } #> 62 <label> 63 <# if ( data.label ) { #> 64 <span class="customize-control-title">{{{ data.label }}}</span> 65 <# } #> 66 <# if ( data.description ) { #> 67 <span class="description customize-control-description">{{{ data.description }}}</span> 68 <# } #> 69 <div class="customize-control-content"> 70 <a href="#" class="button button-primary toggle-editor"></a> 71 <textarea {{{ data.inputAttrs }}} class="hidden" {{{ data.link }}}>{{ data.value }}</textarea> 72 </div> 73 </label> 74 <?php 75 } 76 } 77 }