class-kirki-controls-custom-control.php (2082B)
1 <?php 2 /** 3 * Customizer Control: custom. 4 * 5 * Creates a new custom control. 6 * Custom controls accept raw HTML/JS. 7 * 8 * @package Kirki 9 * @subpackage Controls 10 * @copyright Copyright (c) 2016, Aristeides Stathopoulos 11 * @license http://opensource.org/licenses/https://opensource.org/licenses/MIT 12 * @since 1.0 13 */ 14 15 // Exit if accessed directly. 16 if ( ! defined( 'ABSPATH' ) ) { 17 exit; 18 } 19 20 if ( ! class_exists( 'Kirki_Controls_Custom_Control' ) ) { 21 22 /** 23 * The "custom" control allows you to add any raw HTML. 24 */ 25 class Kirki_Controls_Custom_Control extends Kirki_Customize_Control { 26 27 /** 28 * The control type. 29 * 30 * @access public 31 * @var string 32 */ 33 public $type = 'kirki-custom'; 34 35 /** 36 * An Underscore (JS) template for this control's content (but not its container). 37 * 38 * Class variables for this control class are available in the `data` JS object; 39 * export custom variables by overriding {@see Kirki_Customize_Control::to_json()}. 40 * 41 * @see WP_Customize_Control::print_template() 42 * 43 * @access protected 44 */ 45 protected function content_template() { 46 ?> 47 <# if ( data.tooltip ) { #> 48 <a href="#" class="tooltip hint--left" data-hint="{{ data.tooltip }}"><span class='dashicons dashicons-info'></span></a> 49 <# } #> 50 <label> 51 <# if ( data.label ) { #> 52 <span class="customize-control-title">{{{ data.label }}}</span> 53 <# } #> 54 <# if ( data.description ) { #> 55 <span class="description customize-control-description">{{{ data.description }}}</span> 56 <# } #> 57 <?php 58 /** 59 * The value is defined by the developer in the field configuration as 'default'. 60 * There is no user input on this field, it's a raw HTML/JS field and we do not sanitize it. 61 * Do not be alarmed, this is not a security issue. 62 * In order for someone to be able to change this they would have to have access to your filesystem. 63 * If that happens, they can change whatever they want anyways. This field is not a concern. 64 */ 65 ?> 66 {{{ data.value }}} 67 </label> 68 <?php 69 70 } 71 } 72 }