everest-forms
/
addons
/
StyleCustomizer
/
includes
/
customize
/
class-evf-customize-toggle-control.php
class-evf-customize-background-image-control.php
1 year ago
class-evf-customize-color-control.php
1 year ago
class-evf-customize-color-palette-control.php
1 year ago
class-evf-customize-dimension-control.php
1 year ago
class-evf-customize-image-checkbox-control.php
1 year ago
class-evf-customize-image-radio-control.php
1 year ago
class-evf-customize-select2-control.php
1 year ago
class-evf-customize-slider-control.php
1 year ago
class-evf-customize-templates-section.php
1 year ago
class-evf-customize-toggle-control.php
1 year ago
class-evf-customize-toggle-control.php
63 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Customize API: EVF_Customize_Toggle_Control class |
| 4 | * |
| 5 | * @package EverestForms_Style_Customizer\Customize |
| 6 | * @since 1.0.0 |
| 7 | */ |
| 8 | |
| 9 | defined( 'ABSPATH' ) || exit; |
| 10 | |
| 11 | /** |
| 12 | * Customize Toggle Control class. |
| 13 | * |
| 14 | * @see WP_Customize_Control |
| 15 | */ |
| 16 | class EVF_Customize_Toggle_Control extends WP_Customize_Control { |
| 17 | |
| 18 | /** |
| 19 | * Type. |
| 20 | * |
| 21 | * @var string |
| 22 | */ |
| 23 | public $type = 'evf-toggle'; |
| 24 | |
| 25 | /** |
| 26 | * Refresh the parameters passed to the JavaScript via JSON. |
| 27 | * |
| 28 | * @uses WP_Customize_Control::to_json() |
| 29 | */ |
| 30 | public function to_json() { |
| 31 | parent::to_json(); |
| 32 | $this->json['id'] = $this->id; |
| 33 | $this->json['value'] = $this->value(); |
| 34 | $this->json['link'] = $this->get_link(); |
| 35 | $this->json['defaultValue'] = $this->setting->default; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Don't render the control content from PHP, as it's rendered via JS on load. |
| 40 | */ |
| 41 | public function render_content() {} |
| 42 | |
| 43 | /** |
| 44 | * Render a JS template for control display. |
| 45 | * |
| 46 | * @see WP_Customize_Control::print_template() |
| 47 | */ |
| 48 | public function content_template() { |
| 49 | ?> |
| 50 | <label for="toggle_{{ data.id }}"> |
| 51 | <span class="customize-control-title">{{{ data.label }}}</span> |
| 52 | <# if ( data.description ) { #> |
| 53 | <span class="description customize-control-description">{{{ data.description }}}</span> |
| 54 | <# } #> |
| 55 | <input id="toggle_{{ data.id }}" type="checkbox" class="screen-reader-text" value="{{ data.value }}" {{{ data.link }}} <# if ( true === data.value ) { #> checked="checked"<# } #> /> |
| 56 | <span class="switch"> |
| 57 | <span class="switch-content"></span> |
| 58 | </span> |
| 59 | </label> |
| 60 | <?php |
| 61 | } |
| 62 | } |
| 63 |