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

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