PluginProbe
Easy Elements for Elementor – Addons & Website Templates / 1.3.4
Easy Elements for Elementor – Addons & Website Templates v1.3.4
1.5.3 1.5.2 1.5.1 1.5.0 1.4.9 1.4.6 1.4.7 1.4.8 1.4.5 1.4.4 1.4.3 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 All 47 releases
easy-elements / includes / Utils / SearchSelect2.php

SearchSelect2.php in Easy Elements for Elementor – Addons & Website Templates 1.3.4, at includes/Utils/SearchSelect2.php

109 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Easyel\EasyElements\Utils;
3 /**
4 * Elementor autocomplete controls
5 */
6 use Elementor\Base_Data_Control;
7 use Elementor\Plugin;
8
9 /**
10 * Elementor easyel_autocomplete control.
11 *
12 * @since 1.0.0
13 */
14 class SearchSelect2 extends Base_Data_Control {
15 /**
16 * Get easyel_autocomplete control type.
17 *
18 * Retrieve the control type, in this case `easyel_autocomplete`.
19 *
20 * @since 1.0.0
21 * @access public
22 *
23 * @return string Control type.
24 */
25 public function get_type() {
26 return 'easyel_autocomplete';
27 }
28
29 /**
30 * Get easyel_autocomplete control default settings.
31 *
32 * Retrieve the default settings of the easyel_autocomplete control. Used to return the
33 * default settings while initializing the easyel_autocomplete control.
34 *
35 * @since 1.0.0
36 * @access protected
37 *
38 * @return array Control default settings.
39 */
40 protected function get_default_settings() {
41 return [
42 'label_block' => true,
43 'multiple' => false,
44 'taxonomy' => false,
45 'post_type' => false,
46 'security' => wp_create_nonce( 'easyel_autocomplete_nonce' ),
47 'options' => [],
48 'callback' => '',
49 ];
50 }
51
52 /**
53 * Enqueue control scripts and styles.
54 *
55 * @since 1.0.0
56 * @access public
57 */
58 public function enqueue() {
59 wp_enqueue_script( 'easyel-autocomplete-control', EASYELEMENTS_ASSETS_URL . 'js/easyel-autocomplete.js', [ 'jquery' ], EASYELEMENTS_VER, false );
60
61 wp_localize_script(
62 'easyel-autocomplete-control',
63 'easyel_custom_select_obj',
64 [
65 'security' => wp_create_nonce('easyel_autocomplete_nonce'),
66 'ajax_url' => admin_url('admin-ajax.php'),
67 ]
68 );
69 }
70
71 /**
72 * Render easyel_autocomplete control output in the editor.
73 *
74 * Used to generate the control HTML in the editor using Underscore JS
75 * template. The variables for the class are available using `data` JS
76 * object.
77 *
78 * @since 1.0.0
79 * @access public
80 */
81 public function content_template() {
82 $control_uid = $this->get_control_uid();
83 ?>
84 <div class="elementor-control-field">
85 <label for="<?php echo esc_attr( $control_uid ); ?>" class="elementor-control-title">{{{ data.label
86 }}}</label>
87 <div class="elementor-control-input-wrapper">
88 <# var multiple = ( data.multiple ) ? 'multiple' : ''; #>
89 <select id="<?php echo esc_attr( $control_uid ); ?>" class="elementor-select2" type="select2" {{ multiple }} data-setting="{{ data.name }}" data-post-type="{{ data.post_type }}" data-taxonomy="{{ data.taxonomy }}" data-placeholder="<?php echo esc_attr__( 'Search', 'easy-elements' ); ?>">
90 <# _.each( data.options, function( option_title, option_value ) {
91 var value = data.controlValue;
92 if ( typeof value == 'string' ) {
93 var selected = ( option_value === value ) ? 'selected' : '';
94 } else if ( null !== value ) {
95 var value = _.values( value );
96 var selected = ( -1 !== value.indexOf( option_value ) ) ? 'selected' : '';
97 }
98 #>
99 <option {{ selected }} value="{{ option_value }}">{{{ option_title }}}</option>
100 <# } ); #>
101 </select>
102 </div>
103 </div>
104 <# if ( data.description ) { #>
105 <div class="elementor-control-field-description">{{{ data.description }}}</div>
106 <# } #>
107 <?php
108 }
109 }