Custom.php
65 lines
| 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-framework/control-custom |
| 9 | * @copyright Copyright (c) 2023, Themeum |
| 10 | * @license https://opensource.org/licenses/MIT |
| 11 | * @since 1.0 |
| 12 | */ |
| 13 | |
| 14 | namespace Kirki\Control; |
| 15 | |
| 16 | use Kirki\Control\Base; |
| 17 | |
| 18 | /** |
| 19 | * The "custom" control allows you to add any raw HTML. |
| 20 | * |
| 21 | * @since 1.0 |
| 22 | */ |
| 23 | class Custom extends Base { |
| 24 | |
| 25 | /** |
| 26 | * The control type. |
| 27 | * |
| 28 | * @access public |
| 29 | * @since 1.0 |
| 30 | * @var string |
| 31 | */ |
| 32 | public $type = 'kirki-custom'; |
| 33 | |
| 34 | /** |
| 35 | * An Underscore (JS) template for this control's content (but not its container). |
| 36 | * |
| 37 | * Class variables for this control class are available in the `data` JS object; |
| 38 | * export custom variables by overriding {@see WP_Customize_Control::to_json()}. |
| 39 | * |
| 40 | * @see WP_Customize_Control::print_template() |
| 41 | * |
| 42 | * @access protected |
| 43 | * @since 1.0 |
| 44 | * @return void |
| 45 | */ |
| 46 | protected function content_template() { |
| 47 | ?> |
| 48 | <label> |
| 49 | <# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #> |
| 50 | <# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #> |
| 51 | <?php |
| 52 | /** |
| 53 | * The value is defined by the developer in the field configuration as 'default'. |
| 54 | * There is no user input on this field, it's a raw HTML/JS field and we do not sanitize it. |
| 55 | * Do not be alarmed, this is not a security issue. |
| 56 | * In order for someone to be able to change this they would have to have access to your filesystem. |
| 57 | * If that happens, they can change whatever they want anyways. This field is not a concern. |
| 58 | */ |
| 59 | ?> |
| 60 | {{{ data.value }}} |
| 61 | </label> |
| 62 | <?php |
| 63 | } |
| 64 | } |
| 65 |