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