PluginProbe
Elementor Website Builder – more than just a page builder / 3.22.3
Elementor Website Builder – more than just a page builder v3.22.3
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.22.3, at includes/widgets/icon-list.php

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