everest-forms
/
addons
/
StyleCustomizer
/
includes
/
customize
/
class-evf-customize-image-radio-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 week 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-image-radio-control.php
85 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Customize API: EVF_Customize_Image_Radio_Control class |
| 4 | * |
| 5 | * @package EverestForms_Style_Customizer\Customize |
| 6 | * @since 1.0.0 |
| 7 | */ |
| 8 | |
| 9 | defined( 'ABSPATH' ) || exit; |
| 10 | |
| 11 | /** |
| 12 | * Customize Image Radio Control class. |
| 13 | * |
| 14 | * @see WP_Customize_Control |
| 15 | */ |
| 16 | class EVF_Customize_Image_Radio_Control extends WP_Customize_Control { |
| 17 | |
| 18 | /** |
| 19 | * Type. |
| 20 | * |
| 21 | * @var string |
| 22 | */ |
| 23 | public $type = 'evf-image_radio'; |
| 24 | |
| 25 | /** |
| 26 | * Display Label param. |
| 27 | * |
| 28 | * @var bool |
| 29 | */ |
| 30 | public $display_label = false; |
| 31 | |
| 32 | /** |
| 33 | * Refresh the parameters passed to the JavaScript via JSON. |
| 34 | * |
| 35 | * @uses WP_Customize_Control::to_json() |
| 36 | */ |
| 37 | public function to_json() { |
| 38 | parent::to_json(); |
| 39 | $this->json['default'] = $this->setting->default; |
| 40 | $this->json['id'] = $this->id; |
| 41 | $this->json['value'] = $this->value(); |
| 42 | $this->json['link'] = $this->get_link(); |
| 43 | $this->json['choices'] = $this->choices; |
| 44 | $this->json['display_label'] = $this->display_label; |
| 45 | |
| 46 | $this->json['inputAttrs'] = ''; |
| 47 | foreach ( $this->input_attrs as $attr => $value ) { |
| 48 | $this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" '; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Don't render the control content from PHP, as it's rendered via JS on load. |
| 54 | */ |
| 55 | public function render_content() {} |
| 56 | |
| 57 | /** |
| 58 | * Render a JS template for control display. |
| 59 | * |
| 60 | * @see WP_Customize_Control::print_template() |
| 61 | */ |
| 62 | protected function content_template() { |
| 63 | ?> |
| 64 | <label> |
| 65 | <# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #> |
| 66 | <# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# |
| 67 | } #> |
| 68 | </label> |
| 69 | <ul class="image-radio-wrapper"> |
| 70 | <# Object.keys( data.choices ).forEach( function( key ) { #> |
| 71 | <li> |
| 72 | <input id="image-radio-{{{data.id}}}-{{{key}}}" type="radio" name="image-radio-{{{data.id}}}" value = "{{{key}}}" {{{data.link}}} {{{ (data.value === key)? 'checked="checked"' : '' }}} /> |
| 73 | <label class="image-radio-item" title="{{{data.choices[key].name}}}" for="image-radio-{{{data.id}}}-{{{key}}}"> |
| 74 | <img src="{{{data.choices[key].image}}}" alt="{{{data.choices[key].name}}}" /> |
| 75 | <# if ( data.display_label == true ) { #> |
| 76 | <span class="image-radio-label">{{{data.choices[key].name}}}</span> |
| 77 | <# } #> |
| 78 | </label> |
| 79 | </li> |
| 80 | <# } ); #> |
| 81 | </ul> |
| 82 | <?php |
| 83 | } |
| 84 | } |
| 85 |