PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 2.17.4
Shortcodes and extra features for Phlox theme v2.17.4
2.17.21 2.17.20 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.6 1.0.9 1.1.0 1.3.0 1.3.1 1.3.10 1.3.14 1.3.2 1.3.3 1.3.6 1.4.0 1.4.1 1.4.2 1.5.0 1.5.2 1.6.0 1.6.2 1.6.4 1.7.0 1.7.2 2.10.0 2.10.1 2.10.3 2.10.5 2.10.7 2.10.8 2.10.9 2.11.0 2.11.1 2.11.2 2.12.0 2.14.0 2.15.0 2.15.2 2.15.4 2.15.5 2.15.6 2.15.7 2.15.8 2.15.9 2.16.0 2.16.1 2.16.2 2.16.3 2.16.4 2.17.0 2.17.1 2.17.12 2.17.13 2.17.14 2.17.15 2.17.16 2.17.2 2.17.3 2.17.4 2.17.5 2.17.6 2.17.8 2.17.9 2.4.12 2.4.13 2.4.14 2.4.16 2.4.18 2.4.19 2.4.9 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.14 2.5.15 2.5.16 2.5.17 2.5.19 2.5.2 2.5.20 2.5.3 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.10 2.6.12 2.6.13 2.6.14 2.6.15 2.6.16 2.6.17 2.6.19 2.6.2 2.6.20 2.6.4 2.6.5 2.6.7 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.9 2.9.0 2.9.12 2.9.14 2.9.15 2.9.16 2.9.17 2.9.18 2.9.19 2.9.2 2.9.20 2.9.21 2.9.22 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8
auxin-elements / includes / elementor / widgets / theme-elements / select.php
auxin-elements / includes / elementor / widgets / theme-elements Last commit date
breadcrumbs.php 1 year ago copyright.php 1 year ago current-time.php 1 year ago logo.php 1 year ago menu.php 1 year ago modern-search.php 1 year ago search.php 1 year ago select.php 1 year ago shopping-cart.php 1 year ago site-title.php 1 year ago
select.php
853 lines
1 <?php
2 namespace Auxin\Plugin\CoreElements\Elementor\Elements\Theme_Elements;
3 /**
4 * Elementor Select Widget
5 *
6 * @since 1.2.2
7 */
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 use Elementor\Widget_Base;
13 use Elementor\Controls_Manager;
14 use Elementor\Group_Control_Typography;
15 use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
16 use Elementor\Group_Control_Border;
17 use Elementor\Group_Control_Background;
18 use Elementor\Group_Control_Box_Shadow;
19
20 class Select extends Widget_Base {
21
22 /**
23 * Get widget name.
24 *
25 * Retrieve Icon Box Left widget name.
26 *
27 * @since 1.0.0
28 * @access public
29 *
30 * @return string Widget name.
31 */
32 public function get_name() {
33 return 'aux_select_box';
34 }
35
36 /**
37 * Get widget title.
38 *
39 * Retrieve Icon Box Left widget title.
40 *
41 * @since 1.0.0
42 * @access public
43 *
44 * @return string Widget title.
45 */
46 public function get_title() {
47 return esc_html__( 'Select Box', 'auxin-elements' );
48 }
49
50 /**
51 * Get widget icon.
52 *
53 * Retrieve Icon Box Left widget icon.
54 *
55 * @since 1.0.0
56 * @access public
57 *
58 * @return string Widget icon.
59 */
60 public function get_icon() {
61 return 'eicon-select auxin-badge';
62 }
63
64 /**
65 * Get widget categories.
66 *
67 * Retrieve the list of categories the Icon Box Left widget belongs to.
68 *
69 * @since 1.0.0
70 * @access public
71 *
72 * @return array Widget categories.
73 */
74 public function get_categories() {
75 return array( 'auxin-core', 'auxin-theme-elements' );
76 }
77
78 /**
79 * Register Icon Box Left widget controls.
80 *
81 * Adds different input fields to allow the user to change and customize the widget settings.
82 *
83 * @since 1.0.0
84 * @access protected
85 */
86 protected function register_controls() {
87 $this->start_controls_section(
88 'content_section',
89 array(
90 'label' => esc_html__( 'Select', 'auxin-elements' ),
91 'tab' => Controls_Manager::TAB_CONTENT,
92 )
93 );
94
95 $this->add_control(
96 'dropdown_icon',
97 [
98 'label' => __( 'Dropdown icon', 'auxin-elements' ),
99 'type' => Controls_Manager::ICONS,
100 'default' => [
101 'value' => 'auxicon auxicon-chevron-down',
102 'library' => 'auxicon',
103 ],
104 ]
105 );
106
107 $repeater = new \Elementor\Repeater();
108
109 $repeater->add_control(
110 'item_title',
111 array(
112 'label' => esc_html__( 'Title', 'auxin-elements' ),
113 'type' => Controls_Manager::TEXT,
114 'placeholder' => esc_html__( 'Link title', 'auxin-elements' ),
115 )
116 );
117
118 $repeater->add_control(
119 'item_link',
120 [
121 'label' => __( 'Link', 'auxin-elements' ),
122 'type' => Controls_Manager::URL,
123 'placeholder' => __( 'https://your-link.com', 'auxin-elements' ),
124 'show_external' => true,
125 'default' => [
126 'url' => '#',
127 'is_external' => false,
128 'nofollow' => true,
129 ],
130 'dynamic' => array(
131 'active' => true
132 )
133 ]
134 );
135
136 $repeater->add_control(
137 'item_icon',
138 [
139 'label' => __( 'Icon', 'auxin-elements' ),
140 'type' => Controls_Manager::ICONS,
141 'default' => [
142 'value' => 'fas fa-star',
143 'library' => 'solid',
144 ],
145 ]
146 );
147
148 $repeater->add_control(
149 'is_language_switcher',
150 array(
151 'label' => __('Is lanugage swicher ?', 'auxin-elements'),
152 'type' => Controls_Manager::SWITCHER,
153 'label_on' => __( 'Yes', 'auxin-elements' ),
154 'label_off' => __( 'No', 'auxin-elements' ),
155 'return_value' => 'yes',
156 'default' => 'yes',
157 )
158 );
159
160 $repeater->add_control(
161 'language',
162 array(
163 'label' => __('Language', 'auxin-elements'),
164 'type' => Controls_Manager::SELECT,
165 'options' => $this->get_languages_list(),
166 'condition' => [
167 'is_language_switcher' => 'yes'
168 ]
169 )
170 );
171
172 $this->add_control(
173 'select_items',
174 array(
175 'label' => esc_html__( 'Items', 'auxin-elements' ),
176 'type' => Controls_Manager::REPEATER,
177 'fields' => $repeater->get_controls(),
178 'default' => array(
179 array(
180 'item_title' => esc_html__( 'First Item', 'auxin-elements' ),
181 ),
182 array(
183 'item_title' => esc_html__( 'Second Item', 'auxin-elements' ),
184 ),
185 ),
186 'title_field' => '{{{ item_title }}}',
187 )
188 );
189
190 $this->add_control(
191 'action',
192 array(
193 'label' => esc_html__( 'Display Items On Hover', 'auxin-elements' ),
194 'type' => Controls_Manager::SWITCHER,
195 'label_on' => esc_html__( 'Hover', 'auxin-elements' ),
196 'label_off' => esc_html__( 'Click', 'auxin-elements' ),
197 'return_value' => 'hover',
198 'default' => 'hover',
199 )
200 );
201
202 $this->end_controls_section();
203
204 $this->start_controls_section(
205 'select_style_section',
206 array(
207 'label' => esc_html__( 'Select Style', 'auxin-elements' ),
208 'tab' => Controls_Manager::TAB_STYLE,
209 )
210 );
211
212 $this->add_responsive_control(
213 'select_box_margin',
214 array(
215 'label' => esc_html__( 'Select Margin', 'auxin-elements' ),
216 'type' => Controls_Manager::DIMENSIONS,
217 'size_units' => array( 'px', '%', 'em' ),
218 'selectors' => array(
219 '{{WRAPPER}}' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
220 ),
221 )
222 );
223
224 $this->add_responsive_control(
225 'select_align',
226 array(
227 'label' => esc_html__( 'Alignment', 'auxin-elements' ),
228 'type' => Controls_Manager::CHOOSE,
229 'options' => array(
230 'left' => array(
231 'title' => __( 'Left', 'auxin-elements' ),
232 'icon' => 'eicon-text-align-left',
233 ),
234 'center' => array(
235 'title' => __( 'Center', 'auxin-elements' ),
236 'icon' => 'eicon-text-align-center',
237 ),
238 'right' => array(
239 'title' => __( 'Right', 'auxin-elements' ),
240 'icon' => 'eicon-text-align-right',
241 )
242 ),
243 'default' => 'left',
244 'selectors_dictionary' => [
245 'left' => 'text-align: left;justify-content: flex-start;',
246 'center' => 'text-align: center;justify-content: center;',
247 'right' => 'text-align: right;justify-content: flex-end;'
248 ],
249 'selectors' => array(
250 '{{WRAPPER}} div.aux-select-element' => '{{VALUE}}',
251 '{{WRAPPER}} div.aux-select-element ul li' => '{{VALUE}}',
252 ),
253 )
254 );
255
256 $this->add_responsive_control(
257 'select_width',
258 array(
259 'label' => __('Select Width', 'auxin-elements' ),
260 'type' => Controls_Manager::SLIDER,
261 'size_units' => array('px', '%'),
262 'range' => array(
263 'px' => array(
264 'min' => 0,
265 'max' => 2000,
266 'step' => 5
267 ),
268 '%' => array(
269 'min' => 0,
270 'max' => 100,
271 'step' => 1
272 )
273 ),
274 'selectors' => array(
275 '{{WRAPPER}} .aux-select-element' => 'width: {{SIZE}}{{UNIT}};'
276 )
277 )
278 );
279
280 $this->add_responsive_control(
281 'select_height',
282 array(
283 'label' => __('Select Height', 'auxin-elements' ),
284 'type' => Controls_Manager::SLIDER,
285 'size_units' => array('px', '%'),
286 'range' => array(
287 'px' => array(
288 'min' => 0,
289 'max' => 2000,
290 'step' => 5
291 ),
292 '%' => array(
293 'min' => 0,
294 'max' => 100,
295 'step' => 1
296 )
297 ),
298 'selectors' => array(
299 '{{WRAPPER}} .aux-select-element' => 'height: {{SIZE}}{{UNIT}};'
300 )
301 )
302 );
303
304 $this->start_controls_tabs( 'select_state_colors' );
305
306 $this->start_controls_tab(
307 'select_normal',
308 array(
309 'label' => __( 'Normal' , 'auxin-elements' )
310 )
311 );
312
313 $this->add_control(
314 'current_color_normal',
315 array(
316 'label' => esc_html__( 'Current Item Color ', 'auxin-elements' ),
317 'type' => Controls_Manager::COLOR,
318 'default' => '',
319 'selectors' => [
320 '{{WRAPPER}} .current, {{WRAPPER}} .current a' => 'color: {{VALUE}};'
321 ]
322 )
323 );
324
325 $this->add_group_control(
326 Group_Control_Background::get_type(),
327 array(
328 'name' => 'select_background_normal',
329 'label' => __( 'Select Background', 'auxin-elements' ),
330 'types' => array( 'classic', 'gradient' ),
331 'selector' => '{{WRAPPER}} .aux-select-element',
332 )
333 );
334
335 $this->end_controls_tab();
336
337 $this->start_controls_tab(
338 'select_hover',
339 array(
340 'label' => __( 'Hover' , 'auxin-elements' )
341 )
342 );
343
344 $this->add_control(
345 'current_color_hover',
346 array(
347 'label' => esc_html__( 'Current Item Color ', 'auxin-elements' ),
348 'type' => Controls_Manager::COLOR,
349 'default' => '',
350 'selectors' => [
351 '{{WRAPPER}} .current:hover, {{WRAPPER}} .current:hover a' => 'color: {{VALUE}};'
352 ]
353 )
354 );
355
356 $this->add_group_control(
357 Group_Control_Background::get_type(),
358 array(
359 'name' => 'select_background_hover',
360 'label' => __( 'Select Background', 'auxin-elements' ),
361 'types' => array( 'classic', 'gradient' ),
362 'selector' => '{{WRAPPER}} .aux-select-element',
363 )
364 );
365
366 $this->add_responsive_control(
367 'select_transition',
368 array(
369 'label' => __('Transition (ms)', 'auxin-elements' ),
370 'type' => Controls_Manager::SLIDER,
371 'size_units' => array('px'),
372 'range' => array(
373 'px' => array(
374 'min' => 0,
375 'max' => 5000,
376 'step' => 100
377 )
378 ),
379 'selectors' => array(
380 '{{WRAPPER}} .aux-select-element, {{WRAPPER}} .current' => 'transition: all {{SIZE}}ms ease;'
381 )
382 )
383 );
384
385 $this->end_controls_tab();
386
387 $this->end_controls_tabs();
388
389 $this->add_control(
390 'select_border_options',
391 [
392 'label' => __( 'Select Border Options', 'auxin-elements' ),
393 'type' => Controls_Manager::HEADING,
394 'separator' => 'before',
395 ]
396 );
397
398 $this->add_group_control(
399 Group_Control_Border::get_type(),
400 array(
401 'name' => 'select_border',
402 'label' => esc_html__( 'Select Border', 'auxin-elements' ),
403 'selector' => '{{WRAPPER}} div.aux-select-element',
404 'separator' => 'none'
405 )
406 );
407
408 $this->add_responsive_control(
409 'select_border_radius',
410 array(
411 'label' => esc_html__( 'Select Border Radius', 'auxin-elements' ),
412 'type' => Controls_Manager::DIMENSIONS,
413 'size_units' => array( 'px', '%', 'em' ),
414 'selectors' => array(
415 '{{WRAPPER}} div.aux-select-element' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
416 ),
417 )
418 );
419
420 $this->end_controls_section();
421
422 $this->start_controls_section(
423 'dropdown_style_section',
424 array(
425 'label' => esc_html__( 'Dropdown Style', 'auxin-elements' ),
426 'tab' => Controls_Manager::TAB_STYLE,
427 )
428 );
429
430 $this->add_control(
431 'select_list_border_options',
432 [
433 'label' => __( 'Dropdown Border Options', 'auxin-elements' ),
434 'type' => Controls_Manager::HEADING,
435 'separator' => 'before',
436 ]
437 );
438
439 $this->add_group_control(
440 Group_Control_Border::get_type(),
441 array(
442 'name' => 'select_list_border',
443 'label' => esc_html__( 'Select List Border', 'auxin-elements' ),
444 'selector' => '{{WRAPPER}} div.aux-select-element ul',
445 'separator' => 'none'
446 )
447 );
448
449 $this->add_responsive_control(
450 'select_list_border_radius',
451 array(
452 'label' => esc_html__( 'Dropdown Border Radius', 'auxin-elements' ),
453 'type' => Controls_Manager::DIMENSIONS,
454 'size_units' => array( 'px', '%', 'em' ),
455 'selectors' => array(
456 '{{WRAPPER}} div.aux-select-element ul' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
457 ),
458 )
459 );
460
461 $this->add_group_control(
462 Group_Control_Box_Shadow::get_type(),
463 array(
464 'name' => 'dropdown_box_shadow',
465 'selector' => '{{WRAPPER}} div.aux-select-element ul',
466 )
467 );
468
469 $this->add_group_control(
470 Group_Control_Background::get_type(),
471 array(
472 'name' => 'dropdown_background',
473 'label' => __( 'Dropdown Background', 'auxin-elements' ),
474 'types' => array( 'classic', 'gradient' ),
475 'selector' => '{{WRAPPER}} ul',
476 )
477 );
478
479 $this->end_controls_section();
480
481 $this->start_controls_section(
482 'select_items_style_section',
483 array(
484 'label' => esc_html__( 'Items Style', 'auxin-elements' ),
485 'tab' => Controls_Manager::TAB_STYLE,
486 )
487 );
488
489 $this->add_group_control(
490 Group_Control_Typography::get_type(),
491 array(
492 'name' => 'item_typography',
493 'label' => __( 'Item Typography', 'auxin-elements' ),
494 'global' => [
495 'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
496 ],
497 'selector' => '{{WRAPPER}} .current .selected, {{WRAPPER}} ul li',
498 )
499 );
500
501 $this->add_responsive_control(
502 'item_padding',
503 array(
504 'label' => esc_html__( 'Padding', 'auxin-elements' ),
505 'type' => Controls_Manager::DIMENSIONS,
506 'size_units' => array( 'px', '%', 'em' ),
507 'selectors' => array(
508 '{{WRAPPER}} ul li' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
509 ),
510 )
511 );
512
513 $this->add_responsive_control(
514 'item_margin',
515 array(
516 'label' => esc_html__( 'Margin', 'auxin-elements' ),
517 'type' => Controls_Manager::DIMENSIONS,
518 'size_units' => array( 'px', '%', 'em' ),
519 'selectors' => array(
520 '{{WRAPPER}} ul li' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
521 ),
522 )
523 );
524
525 $this->add_group_control(
526 Group_Control_Border::get_type(),
527 array(
528 'name' => 'item_border',
529 'label' => esc_html__( 'Border', 'auxin-elements' ),
530 'selector' => '{{WRAPPER}} div.aux-select-element li:not(:last-child)',
531 'separator' => 'none'
532 )
533 );
534
535 $this->add_responsive_control(
536 'icon_padding',
537 array(
538 'label' => esc_html__( 'Icon/Image Padding', 'auxin-elements' ),
539 'type' => Controls_Manager::DIMENSIONS,
540 'size_units' => array( 'px', '%', 'em' ),
541 'selectors' => array(
542 '{{WRAPPER}} .element-icon , {{WRAPPER}} img' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
543 ),
544 )
545 );
546
547 $this->add_responsive_control(
548 'icon_size',
549 array(
550 'label' => __( 'Size', 'auxin-elements' ),
551 'type' => Controls_Manager::SLIDER,
552 'size_units' => array( 'px', 'em' ),
553 'range' => array(
554 'px' => array(
555 'max' => 100
556 ),
557 'em' => array(
558 'max' => 10
559 )
560 ),
561 'default' => [
562 'unit' => 'px',
563 'size' => 16,
564 ],
565 'selectors' => array(
566 '{{WRAPPER}} .element-icon' => 'font-size: {{SIZE}}{{UNIT}};height: {{SIZE}}{{UNIT}};',
567 )
568 )
569 );
570
571 $this->start_controls_tabs( 'item_state_colors' );
572
573 $this->start_controls_tab(
574 'item_normal',
575 array(
576 'label' => __( 'Normal' , 'auxin-elements' )
577 )
578 );
579
580 $this->add_control(
581 'icon_color_normal',
582 array(
583 'label' => esc_html__( 'Icon Color ', 'auxin-elements' ),
584 'type' => Controls_Manager::COLOR,
585 'default' => '',
586 'selectors' => [
587 '{{WRAPPER}} .element-icon' => 'color: {{VALUE}};fill: {{VALUE}};'
588 ]
589 )
590 );
591
592 $this->add_control(
593 'title_color_normal',
594 array(
595 'label' => esc_html__( 'Text Color ', 'auxin-elements' ),
596 'type' => Controls_Manager::COLOR,
597 'default' => '',
598 'selectors' => [
599 '{{WRAPPER}} ul li a' => 'color: {{VALUE}};'
600 ]
601 )
602 );
603
604 $this->add_group_control(
605 Group_Control_Background::get_type(),
606 array(
607 'name' => 'item_background_normal',
608 'label' => __( 'Item Background', 'auxin-elements' ),
609 'types' => array( 'classic', 'gradient' ),
610 'selector' => '{{WRAPPER}} ul li',
611 )
612 );
613
614 $this->end_controls_tab();
615
616 $this->start_controls_tab(
617 'item_hover',
618 array(
619 'label' => __( 'Hover' , 'auxin-elements' )
620 )
621 );
622
623 $this->add_control(
624 'icon_color_hover',
625 array(
626 'label' => esc_html__( 'Icon Color ', 'auxin-elements' ),
627 'type' => Controls_Manager::COLOR,
628 'default' => '',
629 'selectors' => [
630 '{{WRAPPER}} ul li:hover .element-icon' => 'color: {{VALUE}};fill: {{VALUE}};'
631 ]
632 )
633 );
634
635 $this->add_control(
636 'title_color_hover',
637 array(
638 'label' => esc_html__( 'Text Color ', 'auxin-elements' ),
639 'type' => Controls_Manager::COLOR,
640 'default' => '',
641 'selectors' => [
642 '{{WRAPPER}} ul li:hover a' => 'color: {{VALUE}};'
643 ]
644 )
645 );
646
647 $this->add_group_control(
648 Group_Control_Background::get_type(),
649 array(
650 'name' => 'item_background_hover',
651 'label' => __( 'Item Background', 'auxin-elements' ),
652 'types' => array( 'classic', 'gradient' ),
653 'selector' => '{{WRAPPER}} ul li:hover',
654 )
655 );
656
657 $this->add_responsive_control(
658 'dropdown_transition',
659 array(
660 'label' => __('Transition (ms)', 'auxin-elements' ),
661 'type' => Controls_Manager::SLIDER,
662 'size_units' => array('px'),
663 'range' => array(
664 'px' => array(
665 'min' => 0,
666 'max' => 5000,
667 'step' => 100
668 )
669 ),
670 'selectors' => array(
671 '{{WRAPPER}} ul li, {{WRAPPER}} ul li a, {{WRAPPER}} ul li .element-icon' => 'transition: all {{SIZE}}ms ease;'
672 )
673 )
674 );
675
676 $this->end_controls_tab();
677
678 $this->end_controls_tabs();
679
680 $this->end_controls_section();
681
682 }
683
684 /**
685 * Render Icon Box Left widget output on the frontend.
686 *
687 * Written in PHP and used to generate the final HTML.
688 *
689 * @since 1.0.0
690 * @access protected
691 */
692 protected function render() {
693 $settings = $this->get_settings_for_display();
694
695 $action = $settings['action'] == 'hover' ? 'hover' : 'click';
696
697 $current_item = $this->get_current_item( $settings );
698
699 ?>
700 <div class="aux-select-element" data-action="<?php echo esc_attr( $action );?>">
701 <span class="current">
702 <span class="selected">
703 <?php
704 if ( !empty( $settings['select_items'][ $current_item ]['item_icon']['library'] ) && $settings['select_items'][ $current_item ]['item_icon']['library'] == 'svg' ) {
705 $icon = '<img src="' . esc_url( $settings['select_items'][ $current_item ]['item_icon']['value']['url'] ) . '">';
706 } elseif ( !empty( $settings['select_items'][ $current_item ]['item_icon']['value'] ) ) {
707 $icon = \Elementor\Icons_Manager::render_font_icon( $settings['select_items'][ $current_item ]['item_icon'], [ 'aria-hidden' => 'true', 'class' => 'element-icon' ] );
708 } else {
709 $icon = '';
710 }
711 echo auxin_kses( $icon ) . esc_html( $settings['select_items'][ $current_item ]['item_title'] );
712 ?>
713 </span>
714 <?php
715 if ( !empty( $settings['dropdown_icon']['library'] ) && $settings['dropdown_icon']['library'] == 'svg' ) {
716 echo '<img class="dropdown-icon" src="' . esc_url( $settings['dropdown_icon']['value']['url'] ) . '">';
717 } elseif ( !empty( $settings['dropdown_icon']['value'] ) ) {
718 echo \Elementor\Icons_Manager::render_font_icon( $settings['dropdown_icon'], [ 'aria-hidden' => 'true', 'class' => 'dropdown-icon' ] );
719 }
720 ?>
721 </span>
722 <ul class="list">
723 <?php
724 foreach( $settings['select_items'] as $key => $item ) {
725 $is_external = $item['item_link']['is_external'] ? '_blank' : '_self';
726 if ( !empty( $item['item_icon']['library'] ) && $item['item_icon']['library'] == 'svg' ) {
727 $icon = '<img src="' . esc_url( $item['item_icon']['value']['url'] ) . '">';
728 } elseif ( !empty( $item['item_icon']['value'] ) ) {
729 $icon = '<span class="element-icon ' . esc_attr( $item['item_icon']['value'] ) . '"></span>';
730 }
731
732 $item_link = $item['is_language_switcher'] ? $this->get_item_language_link( $item ) : rtrim( $item['item_link']['url'], '/' );
733 ?>
734 <li class="option"><?php echo auxin_kses( $icon );?><a href="<?php echo esc_url( $item_link );?>" target="<?php echo esc_attr( $is_external );?>"><?php echo esc_html( $item['item_title'] );?></a></li>
735 <?php } ?>
736 </ul>
737 </div>
738 <?php
739 }
740 /**
741 * Whether the reload preview is required or not.
742 *
743 * Used to determine whether the reload preview is required.
744 *
745 * @since 1.0.0
746 * @access public
747 *
748 * @return bool Whether the reload preview is required.
749 */
750 public function is_reload_preview_required() {
751 return false;
752 }
753
754 /**
755 * Render shortcode widget as plain content.
756 *
757 * Override the default behavior by printing the shortcode instead of rendering it.
758 *
759 * @since 1.0.0
760 * @access public
761 */
762 public function render_plain_content() {
763
764 }
765
766 protected function content_template() {
767 }
768
769 /**
770 * Get current item for url visiting
771 *
772 * @param array $settings
773 * @return int
774 */
775 public function get_current_item( $settings ) {
776 global $wp;
777 $current_link = rtrim( home_url( $wp->request ), '/' );
778
779 // if permalink structure is pretty
780 foreach( $settings['select_items'] as $key => $item ) {
781 $item_link = !empty( $item['is_language_switcher'] ) ? $this->get_item_language_link($item) : rtrim( $item['item_link']['url'], '/' );
782 if ( !empty( $item_link ) && ( $item_link == $current_link || strpos( $current_link, $item_link ) != false ) ) {
783 return $key;
784 }
785 }
786
787 // if permalink structure is not pretty and hast query variables inside
788 foreach( $settings['select_items'] as $key => $item ) {
789 $item_link = !empty( $item['is_language_switcher'] ) ? $this->get_item_language_link($item) : rtrim( $item['item_link']['url'], '/' );
790 if ( !empty( $item_link ) ) {
791 $query = wp_parse_url($item_link, PHP_URL_QUERY);
792 parse_str($query, $params);
793 if ( !empty( $params ) ) {
794 $paramKeyFound = true;
795 foreach( $params as $paramKey => $paramValue ) {
796 if ( empty( $_GET[ $paramKey ] ) || $_GET[ $paramKey ] != $paramValue ) {
797 $paramKeyFound = false;
798 break;
799 }
800 }
801
802 if ( $paramKeyFound ) {
803 return $key;
804 }
805 }
806 }
807 }
808
809 return 0;
810 }
811
812 /**
813 * List available languages
814 *
815 * @return array
816 */
817 public function get_languages_list() {
818 if ( function_exists('pll_languages_list') ) {
819 $languages_list = pll_languages_list();
820 return array_combine( $languages_list, $languages_list );
821 }
822
823 if ( function_exists('wpml_get_active_languages_filter') ) {
824 $languages_list = wpml_get_active_languages_filter('');
825 return array_combine( array_keys( $languages_list ), array_keys( $languages_list ) );
826 }
827 return [];
828 }
829
830 /**
831 * Get relative language link for an item
832 *
833 * @param array $item
834 * @return string
835 */
836 public function get_item_language_link( $item ) {
837 global $post;
838 if ( is_object( $post ) && !is_archive() ) {
839 if ( function_exists('pll_get_post') ) {
840 $translated_post = pll_get_post( $post->ID, $item['language'] );
841 return !empty( $translated_post ) ? rtrim( get_permalink( $translated_post ), '/') : rtrim( $item['item_link']['url'], '/' );
842 }
843
844 if ( function_exists('wpml_object_id_filter') ) {
845 $translated_post = wpml_object_id_filter( $post->ID, $post->post_type, false, $item['language'] );
846 return !empty( $translated_post ) ? rtrim( wpml_permalink_filter( get_permalink( $translated_post ), $item['language'] ), '/') : rtrim( $item['item_link']['url'], '/' );
847 }
848 }
849
850 return rtrim( $item['item_link']['url'], '/' );
851 }
852 }
853