EAEL_Background.php
2 years ago
EAEL_Choose.php
1 year ago
Select2.php
1 year ago
index.php
3 years ago
EAEL_Choose.php
77 lines
| 1 | <?php |
| 2 | namespace Essential_Addons_Elementor\Controls; |
| 3 | use Elementor\Base_Data_Control; |
| 4 | use Elementor\Control_Choose; |
| 5 | |
| 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | exit; // Exit if accessed directly. |
| 8 | } |
| 9 | |
| 10 | /** |
| 11 | * Elementor choose control. |
| 12 | * |
| 13 | * A base control for creating choose control. Displays radio buttons styled as |
| 14 | * groups of buttons with icons for each option. |
| 15 | * |
| 16 | * @since 5.6.0 |
| 17 | */ |
| 18 | class EAEL_Choose extends Control_Choose { |
| 19 | |
| 20 | /** |
| 21 | * Render choose control output in the editor. |
| 22 | * |
| 23 | * Used to generate the control HTML in the editor using Underscore JS |
| 24 | * template. The variables for the class are available using `data` JS |
| 25 | * object. |
| 26 | * |
| 27 | * @since 5.6.0 |
| 28 | * @access public |
| 29 | */ |
| 30 | public function content_template() { |
| 31 | $control_uid_input_type = '{{value}}'; |
| 32 | ?> |
| 33 | <div class="elementor-control-field"> |
| 34 | <label class="elementor-control-title">{{{ data.label }}}</label> |
| 35 | <div class="elementor-control-input-wrapper"> |
| 36 | <div class="elementor-choices {{ data.image_choose ? 'eael-image-choices' : 'eael-choices' }}"> |
| 37 | <# _.each( data.options, function( options, value ) { #> |
| 38 | <input id="<?php $this->print_control_uid( $control_uid_input_type ); ?>" type="radio" name="elementor-choose-{{ data.name }}-{{ data._cid }}" value="{{ value }}"> |
| 39 | <label class="elementor-choices-label elementor-control-unit-1 tooltip-target" for="<?php $this->print_control_uid( $control_uid_input_type ); ?>" data-tooltip="{{ options.title }}" title="{{ options.title }}"> |
| 40 | <# if( options.image ){ #> |
| 41 | <img class="eael-image-option" src="{{ options.image }}" alt="{{ options.title }}" /> |
| 42 | <# } else if( options.text ){ #> |
| 43 | <span class="eael-text-option" alt="{{ options.title }}">{{{ options.text }}}</span> |
| 44 | <# } else{ #> |
| 45 | <i class="{{ options.icon }}" aria-hidden="true"></i> |
| 46 | <# } #> |
| 47 | <span class="elementor-screen-only">{{{ options.title }}}</span> |
| 48 | </label> |
| 49 | <# } ); #> |
| 50 | </div> |
| 51 | </div> |
| 52 | </div> |
| 53 | |
| 54 | <# if ( data.description ) { #> |
| 55 | <div class="elementor-control-field-description">{{{ data.description }}}</div> |
| 56 | <# } #> |
| 57 | <?php |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Get choose control default settings. |
| 62 | * |
| 63 | * Retrieve the default settings of the choose control. Used to return the |
| 64 | * default settings while initializing the choose control. |
| 65 | * |
| 66 | * @since 5.6.0 |
| 67 | * @access protected |
| 68 | * |
| 69 | * @return array Control default settings. |
| 70 | */ |
| 71 | protected function get_default_settings() { |
| 72 | return [ |
| 73 | 'options' => [], |
| 74 | 'toggle' => true, |
| 75 | ]; |
| 76 | } |
| 77 | } |