Radio_Buttonset.php
68 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Customizer Control: radio-buttonset. |
| 4 | * |
| 5 | * @package kirki-framework/control-radio |
| 6 | * @copyright Copyright (c) 2023, Themeum |
| 7 | * @license https://opensource.org/licenses/MIT |
| 8 | * @since 1.0 |
| 9 | */ |
| 10 | |
| 11 | namespace Kirki\Control; |
| 12 | |
| 13 | use Kirki\Control\Base; |
| 14 | use Kirki\Control\Radio; |
| 15 | use Kirki\URL; |
| 16 | |
| 17 | /** |
| 18 | * Radio Buttonset control (modified radio) |
| 19 | * |
| 20 | * @since 1.0 |
| 21 | */ |
| 22 | class Radio_Buttonset extends Base { |
| 23 | |
| 24 | /** |
| 25 | * The control type. |
| 26 | * |
| 27 | * @access public |
| 28 | * @since 1.0 |
| 29 | * @var string |
| 30 | */ |
| 31 | public $type = 'kirki-radio-buttonset'; |
| 32 | |
| 33 | /** |
| 34 | * Enqueue control related scripts/styles. |
| 35 | * |
| 36 | * @access public |
| 37 | * @since 1.0 |
| 38 | * @return void |
| 39 | */ |
| 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 WP_Customize_Control::to_json()}. |
| 47 | * |
| 48 | * @see WP_Customize_Control::print_template() |
| 49 | * |
| 50 | * @access protected |
| 51 | * @since 1.0 |
| 52 | * @return void |
| 53 | */ |
| 54 | protected function content_template() { |
| 55 | ?> |
| 56 | <# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #> |
| 57 | <# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #> |
| 58 | <div id="input_{{ data.id }}" class="buttonset"> |
| 59 | <# for ( key in data.choices ) { #> |
| 60 | <input {{{ data.inputAttrs }}} class="switch-input screen-reader-text" type="radio" value="{{ key }}" name="_customize-radio-{{{ data.id }}}" id="{{ data.id }}{{ key }}" {{{ data.link }}}<# if ( key === data.value ) { #> checked="checked" <# } #>> |
| 61 | <label class="switch-label switch-label-<# if ( key === data.value ) { #>on <# } else { #>off<# } #>" for="{{ data.id }}{{ key }}">{{{ data.choices[ key ] }}}</label> |
| 62 | </input> |
| 63 | <# } #> |
| 64 | </div> |
| 65 | <?php |
| 66 | } |
| 67 | } |
| 68 |