1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
|
<?php namespace Elementor;
if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. }
/** * Elementor social icons widget. * * Elementor widget that displays icons to social pages like Facebook and Twitter. * * @since 1.0.0 */ class Widget_Social_Icons extends Widget_Base {
/** * Get widget name. * * Retrieve social icons widget name. * * @since 1.0.0 * @access public * * @return string Widget name. */ public function get_name() { return 'social-icons'; }
/** * Get widget title. * * Retrieve social icons widget title. * * @since 1.0.0 * @access public * * @return string Widget title. */ public function get_title() { return esc_html__( 'Social Icons', 'elementor' ); }
/** * Get widget icon. * * Retrieve social icons widget icon. * * @since 1.0.0 * @access public * * @return string Widget icon. */ public function get_icon() { return 'eicon-social-icons'; }
/** * Get widget keywords. * * Retrieve the list of keywords the widget belongs to. * * @since 2.1.0 * @access public * * @return array Widget keywords. */ public function get_keywords() { return [ 'social', 'icon', 'link' ]; }
protected function is_dynamic_content(): bool { return false; }
/** * Get style dependencies. * * Retrieve the list of style dependencies the widget requires. * * @since 3.24.0 * @access public * * @return array Widget style dependencies. */ public function get_style_depends(): array { return [ 'widget-social-icons', 'e-apple-webkit' ]; }
public function has_widget_inner_wrapper(): bool { return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); }
/** * Register social icons widget controls. * * Adds different input fields to allow the user to change and customize the widget settings. * * @since 3.1.0 * @access protected */ protected function register_controls() { $this->start_controls_section( 'section_social_icon', [ 'label' => esc_html__( 'Social Icons', 'elementor' ), ] );
$repeater = new Repeater();
$repeater->add_control( 'social_icon', [ 'label' => esc_html__( 'Icon', 'elementor' ), 'type' => Controls_Manager::ICONS, 'fa4compatibility' => 'social', 'default' => [ 'value' => 'fab fa-wordpress', 'library' => 'fa-brands', ], 'recommended' => [ 'fa-brands' => [ 'android', 'apple', 'behance', 'bitbucket', 'codepen', 'delicious', 'deviantart', 'digg', 'dribbble', 'elementor', 'facebook', 'flickr', 'foursquare', 'free-code-camp', 'github', 'gitlab', 'globe', 'houzz', 'instagram', 'jsfiddle', 'linkedin', 'medium', 'meetup', 'mix', 'mixcloud', 'odnoklassniki', 'pinterest', 'product-hunt', 'reddit', 'shopping-cart', 'skype', 'slideshare', 'snapchat', 'soundcloud', 'spotify', 'stack-overflow', 'steam', 'telegram', 'thumb-tack', 'threads', 'tripadvisor', 'tumblr', 'twitch', 'twitter', 'viber', 'vimeo', 'vk', 'weibo', 'weixin', 'whatsapp', 'wordpress', 'xing', 'x-twitter', 'yelp', 'youtube', '500px', ], 'fa-solid' => [ 'envelope', 'link', 'rss', ], ], ] );
$repeater->add_control( 'link', [ 'label' => esc_html__( 'Link', 'elementor' ), 'type' => Controls_Manager::URL, 'default' => [ 'is_external' => 'true', ], 'dynamic' => [ 'active' => true, ], ] );
$repeater->add_control( 'item_icon_color', [ 'label' => esc_html__( 'Color', 'elementor' ), 'type' => Controls_Manager::SELECT, 'default' => 'default', 'options' => [ 'default' => esc_html__( 'Official Color', 'elementor' ), 'custom' => esc_html__( 'Custom', 'elementor' ), ], ] );
$repeater->add_control( 'item_icon_primary_color', [ 'label' => esc_html__( 'Primary Color', 'elementor' ), 'type' => Controls_Manager::COLOR, 'condition' => [ 'item_icon_color' => 'custom', ], 'selectors' => [ '{{WRAPPER}} {{CURRENT_ITEM}}.elementor-social-icon' => 'background-color: {{VALUE}};', ], ] );
$repeater->add_control( 'item_icon_secondary_color', [ 'label' => esc_html__( 'Secondary Color', 'elementor' ), 'type' => Controls_Manager::COLOR, 'condition' => [ 'item_icon_color' => 'custom', ], 'selectors' => [ '{{WRAPPER}} {{CURRENT_ITEM}}.elementor-social-icon i' => 'color: {{VALUE}};', '{{WRAPPER}} {{CURRENT_ITEM}}.elementor-social-icon svg' => 'fill: {{VALUE}};', ], ] );
$this->add_control( 'social_icon_list', [ 'label' => esc_html__( 'Social Icons', 'elementor' ), 'type' => Controls_Manager::REPEATER, 'fields' => $repeater->get_controls(), 'default' => [ [ 'social_icon' => [ 'value' => 'fab fa-facebook', 'library' => 'fa-brands', ], ], [ 'social_icon' => [ 'value' => 'fab fa-twitter', 'library' => 'fa-brands', ], ], [ 'social_icon' => [ 'value' => 'fab fa-youtube', 'library' => 'fa-brands', ], ], ], 'title_field' => '<# var migrated = "undefined" !== typeof __fa4_migrated, social = ( "undefined" === typeof social ) ? false : social; #>{{{ elementor.helpers.getSocialNetworkNameFromIcon( social_icon, social, true, migrated, true ) }}}', ] );
$this->add_control( 'shape', [ 'label' => esc_html__( 'Shape', 'elementor' ), 'type' => Controls_Manager::SELECT, 'default' => 'rounded', 'options' => [ 'square' => esc_html__( 'Square', 'elementor' ), 'rounded' => esc_html__( 'Rounded', 'elementor' ), 'circle' => esc_html__( 'Circle', 'elementor' ), ], 'prefix_class' => 'elementor-shape-', ] );
$this->add_responsive_control( 'columns', [ 'label' => esc_html__( 'Columns', 'elementor' ), 'type' => Controls_Manager::SELECT, 'default' => '0', 'options' => [ '0' => esc_html__( 'Auto', 'elementor' ), '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', ], 'prefix_class' => 'elementor-grid%s-', 'selectors' => [ '{{WRAPPER}}' => '--grid-template-columns: repeat({{VALUE}}, auto);', ], ] );
$start = is_rtl() ? 'end' : 'start'; $end = is_rtl() ? 'start' : 'end';
$align_selector = Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ) && ! $this->has_widget_inner_wrapper() ? '{{WRAPPER}}' : '{{WRAPPER}} .elementor-widget-container';
$this->add_responsive_control( 'align', [ 'label' => esc_html__( 'Alignment', 'elementor' ), 'type' => Controls_Manager::CHOOSE, 'options' => [ 'left' => [ 'title' => esc_html__( 'Left', 'elementor' ), 'icon' => 'eicon-text-align-left', ], 'center' => [ 'title' => esc_html__( 'Center', 'elementor' ), 'icon' => 'eicon-text-align-center', ], 'right' => [ 'title' => esc_html__( 'Right', 'elementor' ), 'icon' => 'eicon-text-align-right', ], ], 'prefix_class' => 'e-grid-align%s-', 'default' => 'center', 'selectors' => [ $align_selector => 'text-align: {{VALUE}}', ], ] );
$this->end_controls_section();
$this->start_controls_section( 'section_social_style', [ 'label' => esc_html__( 'Icon', 'elementor' ), 'tab' => Controls_Manager::TAB_STYLE, ] );
$this->add_control( 'icon_color', [ 'label' => esc_html__( 'Color', 'elementor' ), 'type' => Controls_Manager::SELECT, 'default' => 'default', 'options' => [ 'default' => esc_html__( 'Official Color', 'elementor' ), 'custom' => esc_html__( 'Custom', 'elementor' ), ], ] );
$this->add_control( 'icon_primary_color', [ 'label' => esc_html__( 'Primary Color', 'elementor' ), 'type' => Controls_Manager::COLOR, 'condition' => [ 'icon_color' => 'custom', ], 'selectors' => [ '{{WRAPPER}} .elementor-social-icon' => 'background-color: {{VALUE}};', ], ] );
$this->add_control( 'icon_secondary_color', [ 'label' => esc_html__( 'Secondary Color', 'elementor' ), 'type' => Controls_Manager::COLOR, 'condition' => [ 'icon_color' => 'custom', ], 'selectors' => [ '{{WRAPPER}} .elementor-social-icon i' => 'color: {{VALUE}};', '{{WRAPPER}} .elementor-social-icon svg' => 'fill: {{VALUE}};', ], ] );
$this->add_responsive_control( 'icon_size', [ 'label' => esc_html__( 'Size', 'elementor' ), 'type' => Controls_Manager::SLIDER, // The `%' and `em` units are not supported as the widget implements icons differently then other icons. 'size_units' => [ 'px', 'rem', 'vw', 'custom' ], 'range' => [ 'px' => [ 'min' => 6, 'max' => 300, ], ], 'selectors' => [ '{{WRAPPER}}' => '--icon-size: {{SIZE}}{{UNIT}}', ], ] );
$this->add_responsive_control( 'icon_padding', [ 'label' => esc_html__( 'Padding', 'elementor' ), 'type' => Controls_Manager::SLIDER, // The `%' unit is not supported. 'size_units' => [ 'px', 'em', 'rem', 'custom' ], 'selectors' => [ '{{WRAPPER}} .elementor-social-icon' => '--icon-padding: {{SIZE}}{{UNIT}}', ], 'default' => [ 'unit' => 'em', ], 'tablet_default' => [ 'unit' => 'em', ], 'mobile_default' => [ 'unit' => 'em', ], 'range' => [ 'px' => [ 'max' => 50, ], 'em' => [ 'min' => 0, 'max' => 5, ], 'rem' => [ 'min' => 0, 'max' => 5, ], ], ] );
$this->add_responsive_control( 'icon_spacing', [ 'label' => esc_html__( 'Spacing', 'elementor' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', 'em', 'rem', 'custom' ], 'range' => [ 'px' => [ 'max' => 100, ], 'em' => [ 'min' => 0, 'max' => 10, ], 'rem' => [ 'min' => 0, 'max' => 10, ], ], 'default' => [ 'size' => 5, ], 'selectors' => [ '{{WRAPPER}}' => '--grid-column-gap: {{SIZE}}{{UNIT}}', ], ] );
$this->add_responsive_control( 'row_gap', [ 'label' => esc_html__( 'Rows Gap', 'elementor' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', 'em', 'rem', 'custom' ], 'default' => [ 'size' => 0, ], 'selectors' => [ '{{WRAPPER}}' => '--grid-row-gap: {{SIZE}}{{UNIT}}', ], ] );
$this->add_group_control( Group_Control_Border::get_type(), [ 'name' => 'image_border', // We know this mistake - TODO: 'icon_border' (for hover control condition also) 'selector' => '{{WRAPPER}} .elementor-social-icon', 'separator' => 'before', ] );
$this->add_responsive_control( 'border_radius', [ 'label' => esc_html__( 'Border Radius', 'elementor' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ], 'selectors' => [ '{{WRAPPER}} .elementor-icon' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] );
$this->end_controls_section();
$this->start_controls_section( 'section_social_hover', [ 'label' => esc_html__( 'Icon Hover', 'elementor' ), 'tab' => Controls_Manager::TAB_STYLE, ] );
$this->add_control( 'hover_primary_color', [ 'label' => esc_html__( 'Primary Color', 'elementor' ), 'type' => Controls_Manager::COLOR, 'default' => '', 'condition' => [ 'icon_color' => 'custom', ], 'selectors' => [ '{{WRAPPER}} .elementor-social-icon:hover' => 'background-color: {{VALUE}};', ], ] );
$this->add_control( 'hover_secondary_color', [ 'label' => esc_html__( 'Secondary Color', 'elementor' ), 'type' => Controls_Manager::COLOR, 'default' => '', 'condition' => [ 'icon_color' => 'custom', ], 'selectors' => [ '{{WRAPPER}} .elementor-social-icon:hover i' => 'color: {{VALUE}};', '{{WRAPPER}} .elementor-social-icon:hover svg' => 'fill: {{VALUE}};', ], ] );
$this->add_control( 'hover_border_color', [ 'label' => esc_html__( 'Border Color', 'elementor' ), 'type' => Controls_Manager::COLOR, 'default' => '', 'condition' => [ 'image_border_border!' => '', ], 'selectors' => [ '{{WRAPPER}} .elementor-social-icon:hover' => 'border-color: {{VALUE}};', ], ] );
$this->add_control( 'hover_animation', [ 'label' => esc_html__( 'Hover Animation', 'elementor' ), 'type' => Controls_Manager::HOVER_ANIMATION, ] );
$this->end_controls_section();
}
/** * Render social icons widget output on the frontend. * * Written in PHP and used to generate the final HTML. * * @since 1.0.0 * @access protected */ protected function render() { $settings = $this->get_settings_for_display(); $fallback_defaults = [ 'fa fa-facebook', 'fa fa-twitter', 'fa fa-google-plus', ];
$class_animation = '';
if ( ! empty( $settings['hover_animation'] ) ) { $class_animation = ' elementor-animation-' . $settings['hover_animation']; }
$migration_allowed = Icons_Manager::is_migration_allowed();
?> <div class="elementor-social-icons-wrapper elementor-grid"> <?php foreach ( $settings['social_icon_list'] as $index => $item ) { $migrated = isset( $item['__fa4_migrated']['social_icon'] ); $is_new = empty( $item['social'] ) && $migration_allowed; $social = '';
// add old default if ( empty( $item['social'] ) && ! $migration_allowed ) { $item['social'] = isset( $fallback_defaults[ $index ] ) ? $fallback_defaults[ $index ] : 'fa fa-wordpress'; }
if ( ! empty( $item['social'] ) ) { $social = str_replace( 'fa fa-', '', $item['social'] ); }
if ( ( $is_new || $migrated ) && 'svg' !== $item['social_icon']['library'] ) { $social = explode( ' ', $item['social_icon']['value'], 2 ); if ( empty( $social[1] ) ) { $social = ''; } else { $social = str_replace( 'fa-', '', $social[1] ); } } if ( 'svg' === $item['social_icon']['library'] ) { $social = get_post_meta( $item['social_icon']['value']['id'], '_wp_attachment_image_alt', true ); }
$link_key = 'link_' . $index;
$this->add_render_attribute( $link_key, 'class', [ 'elementor-icon', 'elementor-social-icon', 'elementor-social-icon-' . $social . $class_animation, 'elementor-repeater-item-' . $item['_id'], ] );
$this->add_link_attributes( $link_key, $item['link'] );
?> <span class="elementor-grid-item"> <a <?php $this->print_render_attribute_string( $link_key ); ?>> <span class="elementor-screen-only"><?php echo esc_html( ucwords( $social ) ); ?></span> <?php if ( $is_new || $migrated ) { Icons_Manager::render_icon( $item['social_icon'] ); } else { ?> <i class="<?php echo esc_attr( $item['social'] ); ?>"></i> <?php } ?> </a> </span> <?php } ?> </div> <?php }
/** * Render social icons widget output in the editor. * * Written as a Backbone JavaScript template and used to generate the live preview. * * @since 2.9.0 * @access protected */ protected function content_template() { ?> <# var iconsHTML = {}; #> <div class="elementor-social-icons-wrapper elementor-grid"> <# _.each( settings.social_icon_list, function( item, index ) { var link = item.link ? item.link.url : '', migrated = elementor.helpers.isIconMigrated( item, 'social_icon' ); social = elementor.helpers.getSocialNetworkNameFromIcon( item.social_icon, item.social, false, migrated ); #> <span class="elementor-grid-item"> <a class="elementor-icon elementor-social-icon elementor-social-icon-{{ social }} elementor-animation-{{ settings.hover_animation }} elementor-repeater-item-{{item._id}}" href="{{ elementor.helpers.sanitizeUrl( link ) }}"> <span class="elementor-screen-only">{{{ social }}}</span> <# iconsHTML[ index ] = elementor.helpers.renderIcon( view, item.social_icon, {}, 'i', 'object' ); if ( ( ! item.social || migrated ) && iconsHTML[ index ] && iconsHTML[ index ].rendered ) { #> {{{ iconsHTML[ index ].value }}} <# } else { #> <i class="{{ item.social }}"></i> <# } #> </a> </span> <# } ); #> </div> <?php } }
|