class-kirki-controls-generic-control.php (2485B)
1 <?php 2 /** 3 * Customizer Control: kirki-generic. 4 * 5 * @package Kirki 6 * @subpackage Controls 7 * @copyright Copyright (c) 2016, Aristeides Stathopoulos 8 * @license http://opensource.org/licenses/https://opensource.org/licenses/MIT 9 * @since 2.0 10 */ 11 12 // Exit if accessed directly. 13 if ( ! defined( 'ABSPATH' ) ) { 14 exit; 15 } 16 17 if ( ! class_exists( 'Kirki_Controls_Generic_Control' ) ) { 18 19 /** 20 * A generic and pretty abstract control. 21 * Allows for great manipulation using the field's "choices" argumnent. 22 */ 23 class Kirki_Controls_Generic_Control extends Kirki_Customize_Control { 24 25 /** 26 * The control type. 27 * 28 * @access public 29 * @var string 30 */ 31 public $type = 'kirki-generic'; 32 33 /** 34 * Enqueue control related scripts/styles. 35 * 36 * @access public 37 */ 38 public function enqueue() { 39 wp_enqueue_script( 'kirki-generic' ); 40 } 41 42 /** 43 * An Underscore (JS) template for this control's content (but not its container). 44 * 45 * Class variables for this control class are available in the `data` JS object; 46 * export custom variables by overriding {@see Kirki_Customize_Control::to_json()}. 47 * 48 * @see WP_Customize_Control::print_template() 49 * 50 * @access protected 51 */ 52 protected function content_template() { 53 ?> 54 <# if ( data.tooltip ) { #> 55 <a href="#" class="tooltip hint--left" data-hint="{{ data.tooltip }}"><span class='dashicons dashicons-info'></span></a> 56 <# } #> 57 <label> 58 <# if ( data.label ) { #> 59 <span class="customize-control-title">{{{ data.label }}}</span> 60 <# } #> 61 <# if ( data.description ) { #> 62 <span class="description customize-control-description">{{{ data.description }}}</span> 63 <# } #> 64 <div class="customize-control-content"> 65 <# if ( 'textarea' == data.choices['element'] ) { #> 66 <textarea {{{ data.inputAttrs }}} {{{ data.link }}} <# for ( key in data.choices ) { #> {{ key }}="{{ data.choices[ key ] }}"<# } #>>{{ data.value }}</textarea> 67 <# } else { #> 68 <# var element = ( data.choices.element ) ? data.choices.element : 'input'; #> 69 <{{ element }} 70 {{{ data.inputAttrs }}} 71 value="{{ data.value }}" 72 {{{ data.link }}} 73 <# for ( key in data.choices ) { #> 74 {{ key }}="{{ data.choices[ key ] }}" 75 <# } #> 76 <# if ( data.choices.content ) { #> 77 >{{{ data.choices.content }}}</{{ element }}> 78 <# } else { #> 79 /> 80 <# } #> 81 <# } #> 82 </div> 83 </label> 84 <?php 85 } 86 } 87 }