Checkbox.php
83 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Customizer Control: checkbox. |
| 4 | * |
| 5 | * Creates a new custom control. |
| 6 | * Custom controls contains all background-related options. |
| 7 | * |
| 8 | * @package kirki-framework/control-checkbox |
| 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 | use Kirki\URL; |
| 18 | |
| 19 | /** |
| 20 | * Adds a checkbox control. |
| 21 | * |
| 22 | * @since 1.0 |
| 23 | */ |
| 24 | class Checkbox extends Base { |
| 25 | |
| 26 | /** |
| 27 | * The control type. |
| 28 | * |
| 29 | * @access public |
| 30 | * @since 1.0 |
| 31 | * @var string |
| 32 | */ |
| 33 | public $type = 'kirki-checkbox'; |
| 34 | |
| 35 | /** |
| 36 | * The control version. |
| 37 | * |
| 38 | * @static |
| 39 | * @access public |
| 40 | * @since 1.0 |
| 41 | * @var string |
| 42 | */ |
| 43 | public static $control_ver = '1.0.3'; |
| 44 | |
| 45 | /** |
| 46 | * Enqueue control related scripts/styles. |
| 47 | * |
| 48 | * @access public |
| 49 | * @since 1.0 |
| 50 | * @return void |
| 51 | */ |
| 52 | |
| 53 | |
| 54 | /** |
| 55 | * An Underscore (JS) template for this control's content (but not its container). |
| 56 | * |
| 57 | * Class variables for this control class are available in the `data` JS object; |
| 58 | * export custom variables by overriding {@see WP_Customize_Control::to_json()}. |
| 59 | * |
| 60 | * @see WP_Customize_Control::print_template() |
| 61 | * |
| 62 | * @access protected |
| 63 | * @since 1.0 |
| 64 | * @return void |
| 65 | */ |
| 66 | protected function content_template() { |
| 67 | ?> |
| 68 | <input |
| 69 | id="_customize-input-{{ data.id }}" |
| 70 | type="checkbox" |
| 71 | value="{{ data.value }}" |
| 72 | {{{ data.link }}} |
| 73 | <# if ( data.description ) { #>aria-describedby="_customize-description-{{ data.id }}"<# } #> |
| 74 | <# if ( data.value ) { #>checked="checked"<# } #> |
| 75 | /> |
| 76 | <label for="_customize-input-{{ data.id }}">{{{ data.label }}}</label> |
| 77 | <# if ( data.description ) { #> |
| 78 | <span id="_customize-description-{{ data.id }}" class="description customize-control-description">{{{ data.description }}}</span> |
| 79 | <# } #> |
| 80 | <?php |
| 81 | } |
| 82 | } |
| 83 |