PluginProbe
Elementor Website Builder – more than just a page builder / 3.17.1
Elementor Website Builder – more than just a page builder v3.17.1
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / includes / widgets / icon-list.php

icon-list.php in Elementor Website Builder – more than just a page builder 3.17.1, at includes/widgets/icon-list.php

838 lines 21.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
9 use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
10
11 /**
12 * Elementor icon list widget.
13 *
14 * Elementor widget that displays a bullet list with any chosen icons and texts.
15 *
16 * @since 1.0.0
17 */
18 class Widget_Icon_List extends Widget_Base {
19
20 /**
21 * Get widget name.
22 *
23 * Retrieve icon list widget name.
24 *
25 * @since 1.0.0
26 * @access public
27 *
28 * @return string Widget name.
29 */
30 public function get_name() {
31 return 'icon-list';
32 }
33
34 /**
35 * Get widget title.
36 *
37 * Retrieve icon list widget title.
38 *
39 * @since 1.0.0
40 * @access public
41 *
42 * @return string Widget title.
43 */
44 public function get_title() {
45 return esc_html__( 'Icon List', 'elementor' );
46 }
47
48 /**
49 * Get widget icon.
50 *
51 * Retrieve icon list widget icon.
52 *
53 * @since 1.0.0
54 * @access public
55 *
56 * @return string Widget icon.
57 */
58 public function get_icon() {
59 return 'eicon-bullet-list';
60 }
61
62 /**
63 * Get widget keywords.
64 *
65 * Retrieve the list of keywords the widget belongs to.
66 *
67 * @since 2.1.0
68 * @access public
69 *
70 * @return array Widget keywords.
71 */
72 public function get_keywords() {
73 return [ 'icon list', 'icon', 'list' ];
74 }
75
76 /**
77 * Register icon list widget controls.
78 *
79 * Adds different input fields to allow the user to change and customize the widget settings.
80 *
81 * @since 3.1.0
82 * @access protected
83 */
84 protected function register_controls() {
85 $this->start_controls_section(
86 'section_icon',
87 [
88 'label' => esc_html__( 'Icon List', 'elementor' ),
89 ]
90 );
91
92 $this->add_control(
93 'view',
94 [
95 'label' => esc_html__( 'Layout', 'elementor' ),
96 'type' => Controls_Manager::CHOOSE,
97 'default' => 'traditional',
98 'options' => [
99 'traditional' => [
100 'title' => esc_html__( 'Default', 'elementor' ),
101 'icon' => 'eicon-editor-list-ul',
102 ],
103 'inline' => [
104 'title' => esc_html__( 'Inline', 'elementor' ),
105 'icon' => 'eicon-ellipsis-h',
106 ],
107 ],
108 'render_type' => 'template',
109 'classes' => 'elementor-control-start-end',
110 'style_transfer' => true,
111 'prefix_class' => 'elementor-icon-list--layout-',
112 ]
113 );
114
115 $repeater = new Repeater();
116
117 $repeater->add_control(
118 'text',
119 [
120 'label' => esc_html__( 'Text', 'elementor' ),
121 'type' => Controls_Manager::TEXT,
122 'label_block' => true,
123 'placeholder' => esc_html__( 'List Item', 'elementor' ),
124 'default' => esc_html__( 'List Item', 'elementor' ),
125 'dynamic' => [
126 'active' => true,
127 ],
128 ]
129 );
130
131 $repeater->add_control(
132 'selected_icon',
133 [
134 'label' => esc_html__( 'Icon', 'elementor' ),
135 'type' => Controls_Manager::ICONS,
136 'default' => [
137 'value' => 'fas fa-check',
138 'library' => 'fa-solid',
139 ],
140 'fa4compatibility' => 'icon',
141 ]
142 );
143
144 $repeater->add_control(
145 'link',
146 [
147 'label' => esc_html__( 'Link', 'elementor' ),
148 'type' => Controls_Manager::URL,
149 'dynamic' => [
150 'active' => true,
151 ],
152 ]
153 );
154
155 $this->add_control(
156 'icon_list',
157 [
158 'label' => esc_html__( 'Items', 'elementor' ),
159 'type' => Controls_Manager::REPEATER,
160 'fields' => $repeater->get_controls(),
161 'default' => [
162 [
163 'text' => esc_html__( 'List Item #1', 'elementor' ),
164 'selected_icon' => [
165 'value' => 'fas fa-check',
166 'library' => 'fa-solid',
167 ],
168 ],
169 [
170 'text' => esc_html__( 'List Item #2', 'elementor' ),
171 'selected_icon' => [
172 'value' => 'fas fa-times',
173 'library' => 'fa-solid',
174 ],
175 ],
176 [
177 'text' => esc_html__( 'List Item #3', 'elementor' ),
178 'selected_icon' => [
179 'value' => 'fas fa-dot-circle',
180 'library' => 'fa-solid',
181 ],
182 ],
183 ],
184 'title_field' => '{{{ elementor.helpers.renderIcon( this, selected_icon, {}, "i", "panel" ) || \'<i class="{{ icon }}" aria-hidden="true"></i>\' }}} {{{ text }}}',
185 ]
186 );
187
188 $this->add_control(
189 'link_click',
190 [
191 'label' => esc_html__( 'Apply Link On', 'elementor' ),
192 'type' => Controls_Manager::SELECT,
193 'options' => [
194 'full_width' => esc_html__( 'Full Width', 'elementor' ),
195 'inline' => esc_html__( 'Inline', 'elementor' ),
196 ],
197 'default' => 'full_width',
198 'separator' => 'before',
199 'prefix_class' => 'elementor-list-item-link-',
200 ]
201 );
202
203 $this->end_controls_section();
204
205 $this->start_controls_section(
206 'section_icon_list',
207 [
208 'label' => esc_html__( 'List', 'elementor' ),
209 'tab' => Controls_Manager::TAB_STYLE,
210 ]
211 );
212
213 $this->add_responsive_control(
214 'space_between',
215 [
216 'label' => esc_html__( 'Space Between', 'elementor' ),
217 'type' => Controls_Manager::SLIDER,
218 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
219 'range' => [
220 'px' => [
221 'max' => 50,
222 ],
223 ],
224 'selectors' => [
225 '{{WRAPPER}} .elementor-icon-list-items:not(.elementor-inline-items) .elementor-icon-list-item:not(:last-child)' => 'padding-bottom: calc({{SIZE}}{{UNIT}}/2)',
226 '{{WRAPPER}} .elementor-icon-list-items:not(.elementor-inline-items) .elementor-icon-list-item:not(:first-child)' => 'margin-top: calc({{SIZE}}{{UNIT}}/2)',
227 '{{WRAPPER}} .elementor-icon-list-items.elementor-inline-items .elementor-icon-list-item' => 'margin-right: calc({{SIZE}}{{UNIT}}/2); margin-left: calc({{SIZE}}{{UNIT}}/2)',
228 '{{WRAPPER}} .elementor-icon-list-items.elementor-inline-items' => 'margin-right: calc(-{{SIZE}}{{UNIT}}/2); margin-left: calc(-{{SIZE}}{{UNIT}}/2)',
229 'body.rtl {{WRAPPER}} .elementor-icon-list-items.elementor-inline-items .elementor-icon-list-item:after' => 'left: calc(-{{SIZE}}{{UNIT}}/2)',
230 'body:not(.rtl) {{WRAPPER}} .elementor-icon-list-items.elementor-inline-items .elementor-icon-list-item:after' => 'right: calc(-{{SIZE}}{{UNIT}}/2)',
231 ],
232 ]
233 );
234
235 $this->add_responsive_control(
236 'icon_align',
237 [
238 'label' => esc_html__( 'Alignment', 'elementor' ),
239 'type' => Controls_Manager::CHOOSE,
240 'options' => [
241 'left' => [
242 'title' => esc_html__( 'Left', 'elementor' ),
243 'icon' => 'eicon-h-align-left',
244 ],
245 'center' => [
246 'title' => esc_html__( 'Center', 'elementor' ),
247 'icon' => 'eicon-h-align-center',
248 ],
249 'right' => [
250 'title' => esc_html__( 'Right', 'elementor' ),
251 'icon' => 'eicon-h-align-right',
252 ],
253 ],
254 'prefix_class' => 'elementor%s-align-',
255 ]
256 );
257
258 $this->add_control(
259 'divider',
260 [
261 'label' => esc_html__( 'Divider', 'elementor' ),
262 'type' => Controls_Manager::SWITCHER,
263 'label_off' => esc_html__( 'Off', 'elementor' ),
264 'label_on' => esc_html__( 'On', 'elementor' ),
265 'selectors' => [
266 '{{WRAPPER}} .elementor-icon-list-item:not(:last-child):after' => 'content: ""',
267 ],
268 'separator' => 'before',
269 ]
270 );
271
272 $this->add_control(
273 'divider_style',
274 [
275 'label' => esc_html__( 'Style', 'elementor' ),
276 'type' => Controls_Manager::SELECT,
277 'options' => [
278 'solid' => esc_html__( 'Solid', 'elementor' ),
279 'double' => esc_html__( 'Double', 'elementor' ),
280 'dotted' => esc_html__( 'Dotted', 'elementor' ),
281 'dashed' => esc_html__( 'Dashed', 'elementor' ),
282 ],
283 'default' => 'solid',
284 'condition' => [
285 'divider' => 'yes',
286 ],
287 'selectors' => [
288 '{{WRAPPER}} .elementor-icon-list-items:not(.elementor-inline-items) .elementor-icon-list-item:not(:last-child):after' => 'border-top-style: {{VALUE}}',
289 '{{WRAPPER}} .elementor-icon-list-items.elementor-inline-items .elementor-icon-list-item:not(:last-child):after' => 'border-left-style: {{VALUE}}',
290 ],
291 ]
292 );
293
294 $this->add_control(
295 'divider_weight',
296 [
297 'label' => esc_html__( 'Weight', 'elementor' ),
298 'type' => Controls_Manager::SLIDER,
299 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
300 'default' => [
301 'size' => 1,
302 ],
303 'range' => [
304 'px' => [
305 'min' => 1,
306 'max' => 20,
307 ],
308 ],
309 'condition' => [
310 'divider' => 'yes',
311 ],
312 'selectors' => [
313 '{{WRAPPER}} .elementor-icon-list-items:not(.elementor-inline-items) .elementor-icon-list-item:not(:last-child):after' => 'border-top-width: {{SIZE}}{{UNIT}}',
314 '{{WRAPPER}} .elementor-inline-items .elementor-icon-list-item:not(:last-child):after' => 'border-left-width: {{SIZE}}{{UNIT}}',
315 ],
316 ]
317 );
318
319 $this->add_control(
320 'divider_width',
321 [
322 'label' => esc_html__( 'Width', 'elementor' ),
323 'type' => Controls_Manager::SLIDER,
324 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
325 'default' => [
326 'unit' => '%',
327 ],
328 'condition' => [
329 'divider' => 'yes',
330 'view!' => 'inline',
331 ],
332 'selectors' => [
333 '{{WRAPPER}} .elementor-icon-list-item:not(:last-child):after' => 'width: {{SIZE}}{{UNIT}}',
334 ],
335 ]
336 );
337
338 $this->add_control(
339 'divider_height',
340 [
341 'label' => esc_html__( 'Height', 'elementor' ),
342 'type' => Controls_Manager::SLIDER,
343 'size_units' => [ 'px', '%', 'em', 'rem', 'vh', 'custom' ],
344 'default' => [
345 'unit' => '%',
346 ],
347 'range' => [
348 'px' => [
349 'min' => 1,
350 'max' => 100,
351 ],
352 '%' => [
353 'min' => 1,
354 'max' => 100,
355 ],
356 'vh' => [
357 'min' => 1,
358 'max' => 100,
359 ],
360 ],
361 'condition' => [
362 'divider' => 'yes',
363 'view' => 'inline',
364 ],
365 'selectors' => [
366 '{{WRAPPER}} .elementor-icon-list-item:not(:last-child):after' => 'height: {{SIZE}}{{UNIT}}',
367 ],
368 ]
369 );
370
371 $this->add_control(
372 'divider_color',
373 [
374 'label' => esc_html__( 'Color', 'elementor' ),
375 'type' => Controls_Manager::COLOR,
376 'default' => '#ddd',
377 'global' => [
378 'default' => Global_Colors::COLOR_TEXT,
379 ],
380 'condition' => [
381 'divider' => 'yes',
382 ],
383 'selectors' => [
384 '{{WRAPPER}} .elementor-icon-list-item:not(:last-child):after' => 'border-color: {{VALUE}}',
385 ],
386 ]
387 );
388
389 $this->end_controls_section();
390
391 $this->start_controls_section(
392 'section_icon_style',
393 [
394 'label' => esc_html__( 'Icon', 'elementor' ),
395 'tab' => Controls_Manager::TAB_STYLE,
396 ]
397 );
398
399 $this->start_controls_tabs( 'icon_colors' );
400
401 $this->start_controls_tab(
402 'icon_colors_normal',
403 [
404 'label' => esc_html__( 'Normal', 'elementor' ),
405 ]
406 );
407
408 $this->add_control(
409 'icon_color',
410 [
411 'label' => esc_html__( 'Color', 'elementor' ),
412 'type' => Controls_Manager::COLOR,
413 'default' => '',
414 'selectors' => [
415 '{{WRAPPER}} .elementor-icon-list-icon i' => 'color: {{VALUE}};',
416 '{{WRAPPER}} .elementor-icon-list-icon svg' => 'fill: {{VALUE}};',
417 ],
418 'global' => [
419 'default' => Global_Colors::COLOR_PRIMARY,
420 ],
421 ]
422 );
423
424 $this->end_controls_tab();
425
426 $this->start_controls_tab(
427 'icon_colors_hover',
428 [
429 'label' => esc_html__( 'Hover', 'elementor' ),
430 ]
431 );
432
433 $this->add_control(
434 'icon_color_hover',
435 [
436 'label' => esc_html__( 'Color', 'elementor' ),
437 'type' => Controls_Manager::COLOR,
438 'default' => '',
439 'selectors' => [
440 '{{WRAPPER}} .elementor-icon-list-item:hover .elementor-icon-list-icon i' => 'color: {{VALUE}};',
441 '{{WRAPPER}} .elementor-icon-list-item:hover .elementor-icon-list-icon svg' => 'fill: {{VALUE}};',
442 ],
443 ]
444 );
445
446 $this->add_control(
447 'icon_color_hover_transition',
448 [
449 'label' => __( 'Transition Duration', 'elementor' ),
450 'type' => Controls_Manager::SLIDER,
451 'size_units' => [ 's', 'ms', 'custom' ],
452 'default' => [
453 'unit' => 's',
454 'size' => 0.3,
455 ],
456 'selectors' => [
457 '{{WRAPPER}} .elementor-icon-list-icon i' => 'transition: color {{SIZE}}{{UNIT}}',
458 '{{WRAPPER}} .elementor-icon-list-icon svg' => 'transition: fill {{SIZE}}{{UNIT}}',
459 ],
460 ]
461 );
462
463 $this->end_controls_tab();
464
465 $this->end_controls_tabs();
466
467 $this->add_responsive_control(
468 'icon_size',
469 [
470 'label' => esc_html__( 'Size', 'elementor' ),
471 'type' => Controls_Manager::SLIDER,
472 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
473 'default' => [
474 'size' => 14,
475 ],
476 'range' => [
477 'px' => [
478 'min' => 6,
479 ],
480 '%' => [
481 'min' => 6,
482 ],
483 'vw' => [
484 'min' => 6,
485 ],
486 ],
487 'separator' => 'before',
488 'selectors' => [
489 '{{WRAPPER}}' => '--e-icon-list-icon-size: {{SIZE}}{{UNIT}};',
490 ],
491 ]
492 );
493
494 $this->add_control(
495 'text_indent',
496 [
497 'label' => esc_html__( 'Gap', 'elementor' ),
498 'type' => Controls_Manager::SLIDER,
499 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
500 'range' => [
501 'px' => [
502 'max' => 50,
503 ],
504 ],
505 'separator' => 'after',
506 'selectors' => [
507 '{{WRAPPER}} .elementor-icon-list-icon' => is_rtl() ? 'padding-left: {{SIZE}}{{UNIT}};' : 'padding-right: {{SIZE}}{{UNIT}};',
508 ],
509 ]
510 );
511
512 $e_icon_list_icon_css_var = 'var(--e-icon-list-icon-size, 1em)';
513 $e_icon_list_icon_align_left = sprintf( '0 calc(%s * 0.25) 0 0', $e_icon_list_icon_css_var );
514 $e_icon_list_icon_align_center = sprintf( '0 calc(%s * 0.125)', $e_icon_list_icon_css_var );
515 $e_icon_list_icon_align_right = sprintf( '0 0 0 calc(%s * 0.25)', $e_icon_list_icon_css_var );
516
517 $this->add_responsive_control(
518 'icon_self_align',
519 [
520 'label' => esc_html__( 'Horizontal Alignment', 'elementor' ),
521 'type' => Controls_Manager::CHOOSE,
522 'options' => [
523 'left' => [
524 'title' => esc_html__( 'Left', 'elementor' ),
525 'icon' => 'eicon-h-align-left',
526 ],
527 'center' => [
528 'title' => esc_html__( 'Center', 'elementor' ),
529 'icon' => 'eicon-h-align-center',
530 ],
531 'right' => [
532 'title' => esc_html__( 'Right', 'elementor' ),
533 'icon' => 'eicon-h-align-right',
534 ],
535 ],
536 'default' => '',
537 'selectors_dictionary' => [
538 'left' => sprintf( '--e-icon-list-icon-align: left; --e-icon-list-icon-margin: %s;', $e_icon_list_icon_align_left ),
539 'center' => sprintf( '--e-icon-list-icon-align: center; --e-icon-list-icon-margin: %s;', $e_icon_list_icon_align_center ),
540 'right' => sprintf( '--e-icon-list-icon-align: right; --e-icon-list-icon-margin: %s;', $e_icon_list_icon_align_right ),
541 ],
542 'selectors' => [
543 '{{WRAPPER}}' => '{{VALUE}}',
544 ],
545 ]
546 );
547
548 $this->add_responsive_control(
549 'icon_self_vertical_align',
550 [
551 'label' => esc_html__( 'Vertical Alignment', 'elementor' ),
552 'type' => Controls_Manager::CHOOSE,
553 'options' => [
554 'flex-start' => [
555 'title' => esc_html__( 'Start', 'elementor' ),
556 'icon' => 'eicon-v-align-top',
557 ],
558 'center' => [
559 'title' => esc_html__( 'Center', 'elementor' ),
560 'icon' => 'eicon-v-align-middle',
561 ],
562 'flex-end' => [
563 'title' => esc_html__( 'End', 'elementor' ),
564 'icon' => 'eicon-v-align-bottom',
565 ],
566 ],
567 'default' => '',
568 'selectors' => [
569 '{{WRAPPER}}' => '--icon-vertical-align: {{VALUE}};',
570 ],
571 ]
572 );
573
574 $this->add_responsive_control(
575 'icon_vertical_offset',
576 [
577 'label' => esc_html__( 'Adjust Vertical Position', 'elementor' ),
578 'type' => Controls_Manager::SLIDER,
579 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
580 'default' => [
581 'size' => 0,
582 ],
583 'range' => [
584 'px' => [
585 'min' => -15,
586 'max' => 15,
587 ],
588 'em' => [
589 'min' => -1,
590 'max' => 1,
591 'step' => 0.1,
592 ],
593 ],
594 'selectors' => [
595 '{{WRAPPER}}' => '--icon-vertical-offset: {{SIZE}}{{UNIT}};',
596 ],
597 ]
598 );
599
600 $this->end_controls_section();
601
602 $this->start_controls_section(
603 'section_text_style',
604 [
605 'label' => esc_html__( 'Text', 'elementor' ),
606 'tab' => Controls_Manager::TAB_STYLE,
607 ]
608 );
609
610 $this->add_group_control(
611 Group_Control_Typography::get_type(),
612 [
613 'name' => 'icon_typography',
614 'selector' => '{{WRAPPER}} .elementor-icon-list-item > .elementor-icon-list-text, {{WRAPPER}} .elementor-icon-list-item > a',
615 'global' => [
616 'default' => Global_Typography::TYPOGRAPHY_TEXT,
617 ],
618 ]
619 );
620
621 $this->add_group_control(
622 Group_Control_Text_Shadow::get_type(),
623 [
624 'name' => 'text_shadow',
625 'selector' => '{{WRAPPER}} .elementor-icon-list-text',
626 ]
627 );
628
629 $this->start_controls_tabs( 'text_colors' );
630
631 $this->start_controls_tab(
632 'text_colors_normal',
633 [
634 'label' => esc_html__( 'Normal', 'elementor' ),
635 ]
636 );
637
638 $this->add_control(
639 'text_color',
640 [
641 'label' => esc_html__( 'Color', 'elementor' ),
642 'type' => Controls_Manager::COLOR,
643 'default' => '',
644 'selectors' => [
645 '{{WRAPPER}} .elementor-icon-list-text' => 'color: {{VALUE}};',
646 ],
647 'global' => [
648 'default' => Global_Colors::COLOR_SECONDARY,
649 ],
650 ]
651 );
652
653 $this->end_controls_tab();
654
655 $this->start_controls_tab(
656 'text_colors_hover',
657 [
658 'label' => esc_html__( 'Hover', 'elementor' ),
659 ]
660 );
661
662 $this->add_control(
663 'text_color_hover',
664 [
665 'label' => esc_html__( 'Color', 'elementor' ),
666 'type' => Controls_Manager::COLOR,
667 'default' => '',
668 'selectors' => [
669 '{{WRAPPER}} .elementor-icon-list-item:hover .elementor-icon-list-text' => 'color: {{VALUE}};',
670 ],
671 ]
672 );
673
674 $this->add_control(
675 'text_color_hover_transition',
676 [
677 'label' => __( 'Transition Duration', 'elementor' ),
678 'type' => Controls_Manager::SLIDER,
679 'size_units' => [ 's', 'ms', 'custom' ],
680 'default' => [
681 'unit' => 's',
682 'size' => 0.3,
683 ],
684 'selectors' => [
685 '{{WRAPPER}} .elementor-icon-list-text' => 'transition: color {{SIZE}}{{UNIT}}',
686 ],
687 ]
688 );
689
690 $this->end_controls_tab();
691
692 $this->end_controls_tabs();
693
694 $this->end_controls_section();
695 }
696
697 /**
698 * Render icon list widget output on the frontend.
699 *
700 * Written in PHP and used to generate the final HTML.
701 *
702 * @since 1.0.0
703 * @access protected
704 */
705 protected function render() {
706 $settings = $this->get_settings_for_display();
707 $fallback_defaults = [
708 'fa fa-check',
709 'fa fa-times',
710 'fa fa-dot-circle-o',
711 ];
712
713 $this->add_render_attribute( 'icon_list', 'class', 'elementor-icon-list-items' );
714 $this->add_render_attribute( 'list_item', 'class', 'elementor-icon-list-item' );
715
716 if ( 'inline' === $settings['view'] ) {
717 $this->add_render_attribute( 'icon_list', 'class', 'elementor-inline-items' );
718 $this->add_render_attribute( 'list_item', 'class', 'elementor-inline-item' );
719 }
720 ?>
721 <ul <?php $this->print_render_attribute_string( 'icon_list' ); ?>>
722 <?php
723 foreach ( $settings['icon_list'] as $index => $item ) :
724 $repeater_setting_key = $this->get_repeater_setting_key( 'text', 'icon_list', $index );
725
726 $this->add_render_attribute( $repeater_setting_key, 'class', 'elementor-icon-list-text' );
727
728 $this->add_inline_editing_attributes( $repeater_setting_key );
729 $migration_allowed = Icons_Manager::is_migration_allowed();
730 ?>
731 <li <?php $this->print_render_attribute_string( 'list_item' ); ?>>
732 <?php
733 if ( ! empty( $item['link']['url'] ) ) {
734 $link_key = 'link_' . $index;
735
736 $this->add_link_attributes( $link_key, $item['link'] );
737 ?>
738 <a <?php $this->print_render_attribute_string( $link_key ); ?>>
739
740 <?php
741 }
742
743 // add old default
744 if ( ! isset( $item['icon'] ) && ! $migration_allowed ) {
745 $item['icon'] = isset( $fallback_defaults[ $index ] ) ? $fallback_defaults[ $index ] : 'fa fa-check';
746 }
747
748 $migrated = isset( $item['__fa4_migrated']['selected_icon'] );
749 $is_new = ! isset( $item['icon'] ) && $migration_allowed;
750 if ( ! empty( $item['icon'] ) || ( ! empty( $item['selected_icon']['value'] ) && $is_new ) ) :
751 ?>
752 <span class="elementor-icon-list-icon">
753 <?php
754 if ( $is_new || $migrated ) {
755 Icons_Manager::render_icon( $item['selected_icon'], [ 'aria-hidden' => 'true' ] );
756 } else { ?>
757 <i class="<?php echo esc_attr( $item['icon'] ); ?>" aria-hidden="true"></i>
758 <?php } ?>
759 </span>
760 <?php endif; ?>
761 <span <?php $this->print_render_attribute_string( $repeater_setting_key ); ?>><?php $this->print_unescaped_setting( 'text', 'icon_list', $index ); ?></span>
762 <?php if ( ! empty( $item['link']['url'] ) ) : ?>
763 </a>
764 <?php endif; ?>
765 </li>
766 <?php
767 endforeach;
768 ?>
769 </ul>
770 <?php
771 }
772
773 /**
774 * Render icon list widget output in the editor.
775 *
776 * Written as a Backbone JavaScript template and used to generate the live preview.
777 *
778 * @since 2.9.0
779 * @access protected
780 */
781 protected function content_template() {
782 ?>
783 <#
784 view.addRenderAttribute( 'icon_list', 'class', 'elementor-icon-list-items' );
785 view.addRenderAttribute( 'list_item', 'class', 'elementor-icon-list-item' );
786
787 if ( 'inline' == settings.view ) {
788 view.addRenderAttribute( 'icon_list', 'class', 'elementor-inline-items' );
789 view.addRenderAttribute( 'list_item', 'class', 'elementor-inline-item' );
790 }
791 var iconsHTML = {},
792 migrated = {};
793 #>
794 <# if ( settings.icon_list ) { #>
795 <ul {{{ view.getRenderAttributeString( 'icon_list' ) }}}>
796 <# _.each( settings.icon_list, function( item, index ) {
797
798 var iconTextKey = view.getRepeaterSettingKey( 'text', 'icon_list', index );
799
800 view.addRenderAttribute( iconTextKey, 'class', 'elementor-icon-list-text' );
801
802 view.addInlineEditingAttributes( iconTextKey ); #>
803
804 <li {{{ view.getRenderAttributeString( 'list_item' ) }}}>
805 <# if ( item.link && item.link.url ) { #>
806 <a href="{{ item.link.url }}">
807 <# } #>
808 <# if ( item.icon || item.selected_icon.value ) { #>
809 <span class="elementor-icon-list-icon">
810 <#
811 iconsHTML[ index ] = elementor.helpers.renderIcon( view, item.selected_icon, { 'aria-hidden': true }, 'i', 'object' );
812 migrated[ index ] = elementor.helpers.isIconMigrated( item, 'selected_icon' );
813 if ( iconsHTML[ index ] && iconsHTML[ index ].rendered && ( ! item.icon || migrated[ index ] ) ) { #>
814 {{{ iconsHTML[ index ].value }}}
815 <# } else { #>
816 <i class="{{ item.icon }}" aria-hidden="true"></i>
817 <# }
818 #>
819 </span>
820 <# } #>
821 <span {{{ view.getRenderAttributeString( iconTextKey ) }}}>{{{ item.text }}}</span>
822 <# if ( item.link && item.link.url ) { #>
823 </a>
824 <# } #>
825 </li>
826 <#
827 } ); #>
828 </ul>
829 <# } #>
830
831 <?php
832 }
833
834 public function on_import( $element ) {
835 return Icons_Manager::on_import_migration( $element, 'icon', 'selected_icon', true );
836 }
837 }
838