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

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