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

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