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

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