PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / 4.0.9
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets v4.0.9
4.5.6 4.5.5 4.5.4 4.2.1 4.2.2 4.2.3 4.5.0 4.5.2 4.5.3 4.2.0 4.1.18 4.1.17 4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.0.9 4.1.0 4.1.1 4.1.2 All 148 releases
ultimate-post-kit / modules / social-share / widgets / social-share.php

social-share.php in Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets 4.0.9, at modules/social-share/widgets/social-share.php

884 lines 22.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace UltimatePostKit\Modules\SocialShare\Widgets;
3
4 use UltimatePostKit\Base\Module_Base;
5 use Elementor\Controls_Manager;
6 use Elementor\Group_Control_Typography;
7 use Elementor\Repeater;
8 use UltimatePostKit\Modules\SocialShare\Module;
9
10 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
11
12 class Social_Share extends Module_Base {
13
14 protected $_has_template_content = false;
15
16 private static $medias_class = [
17 'email' => 'upk-icon-envelope',
18 'vkontakte' => 'upk-icon-vk',
19 ];
20
21 private static function get_social_media_class( $media_name ) {
22 if ( isset( self::$medias_class[ $media_name ] ) ) {
23 return self::$medias_class[ $media_name ];
24 }
25 return 'upk-icon-' . $media_name;
26 }
27
28
29 public function get_name() {
30 return 'upk-social-share';
31 }
32
33 public function get_title() {
34 return BDTUPK . esc_html__( 'Social Share', 'ultimate-post-kit' );
35 }
36
37 public function get_icon() {
38 return 'upk-widget-icon upk-icon-social-share';
39 }
40
41 public function get_categories() {
42 return [ 'ultimate-post-kit' ];
43 }
44
45 public function get_keywords() {
46 return [ 'social', 'link', 'share' ];
47 }
48
49 public function get_style_depends() {
50 if ($this->upk_is_edit_mode()) {
51 return ['upk-all-styles'];
52 } else {
53 return [ 'upk-font', 'upk-social-share' ];
54 }
55 }
56
57 public function get_script_depends() {
58 if ( $this->upk_is_edit_mode() ) {
59 return [ 'upk-all-scripts' ];
60 } else {
61 return [ 'goodshare' ];
62 }
63 }
64
65 public function get_custom_help_url() {
66 return 'https://youtu.be/77S087dzK3Q';
67 }
68
69 public function has_widget_inner_wrapper(): bool {
70 return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
71 }
72
73
74 protected function register_controls() {
75 $this->start_controls_section(
76 'section_buttons_content',
77 [
78 'label' => esc_html__( 'Share Buttons', 'ultimate-post-kit' ),
79 ]
80 );
81
82 $repeater = new Repeater();
83
84 $medias = Module::get_social_media();
85
86 $medias_names = array_keys( $medias );
87
88 $repeater->add_control(
89 'button',
90 [
91 'label' => esc_html__( 'Social Media', 'ultimate-post-kit' ),
92 'type' => Controls_Manager::SELECT,
93 'options' => array_reduce( $medias_names, function( $options, $media_name ) use ( $medias ) {
94 $options[ $media_name ] = $medias[ $media_name ]['title'];
95
96 return $options;
97 }, [] ),
98 'default' => 'facebook',
99 ]
100 );
101
102 $repeater->add_control(
103 'text',
104 [
105 'label' => esc_html__( 'Custom Label', 'ultimate-post-kit' ),
106 'type' => Controls_Manager::TEXT,
107 ]
108 );
109
110 $this->add_control(
111 'share_buttons',
112 [
113 'type' => Controls_Manager::REPEATER,
114 'fields' => $repeater->get_controls(),
115 'default' => [
116 [ 'button' => 'facebook' ],
117 [ 'button' => 'linkedin' ],
118 [ 'button' => 'twitter' ],
119 [ 'button' => 'pinterest' ],
120 ],
121 'title_field' => '{{{ button }}}',
122 ]
123 );
124
125 $this->add_control(
126 'view',
127 [
128 'label' => esc_html__( 'View', 'ultimate-post-kit' ),
129 'type' => Controls_Manager::SELECT,
130 'label_block' => false,
131 'options' => [
132 'icon-text' => 'Icon & Text',
133 'icon' => 'Icon',
134 'text' => 'Text',
135 ],
136 'default' => 'icon-text',
137 'separator' => 'before',
138 'prefix_class' => 'upk-ss-btns-view-',
139 'render_type' => 'template',
140 ]
141 );
142
143 $this->add_control(
144 'show_counter',
145 [
146 'label' => esc_html__( 'Count', 'ultimate-post-kit' ),
147 'type' => Controls_Manager::SWITCHER,
148 'condition' => [
149 'view!' => 'icon',
150 ],
151 ]
152 );
153
154
155 $this->add_control(
156 'show_counter_note',
157 [
158 'type' => Controls_Manager::RAW_HTML,
159 'raw' => esc_html__( 'Note: Social share count only works with those platform: vkontakte, facebook, odnoklassniki, moimir, linkedin, tumblr, pinterest, buffer.', 'ultimate-post-kit' ),
160 'content_classes' => 'elementor-panel-alert elementor-panel-alert-danger',
161 'condition' => [
162 'show_counter' => 'yes',
163 'view!' => 'icon',
164 ],
165 ]
166 );
167
168 $this->add_control(
169 'hr',
170 [
171 'type' => Controls_Manager::DIVIDER,
172 ]
173 );
174
175 $this->add_control(
176 'layout_style',
177 [
178 'label' => esc_html__( 'Display', 'ultimate-post-kit' ),
179 'type' => Controls_Manager::SELECT,
180 'default' => 'inline',
181 'options' => [
182 'inline' => esc_html__( 'Inline', 'ultimate-post-kit' ),
183 'grid' => esc_html__( 'Grid', 'ultimate-post-kit' ),
184 ],
185 'prefix_class' => 'upk-layout-style--',
186 ]
187 );
188
189 $this->add_responsive_control(
190 'columns',
191 [
192 'label' => __( 'Columns', 'ultimate-post-kit' ),
193 'type' => Controls_Manager::SELECT,
194 'default' => '4',
195 'tablet_default' => '2',
196 'mobile_default' => '1',
197 'options' => [
198 '1' => '1',
199 '2' => '2',
200 '3' => '3',
201 '4' => '4',
202 '5' => '5',
203 '6' => '6',
204 ],
205 'selectors' => [
206 '{{WRAPPER}} .upk-social-share' => 'grid-template-columns: repeat({{SIZE}}, 1fr);',
207 ],
208 'condition' => [
209 'layout_style' => 'grid'
210 ]
211 ]
212 );
213
214 $this->add_responsive_control(
215 'column_gap',
216 [
217 'label' => esc_html__( 'Gap', 'ultimate-post-kit' ),
218 'type' => Controls_Manager::SLIDER,
219 'default' => [
220 'size' => 10,
221 ],
222 'selectors' => [
223 '{{WRAPPER}} .upk-social-share' => 'grid-gap: {{SIZE}}{{UNIT}};',
224 ],
225 'condition' => [
226 'layout_style' => 'grid'
227 ]
228 ]
229 );
230
231 $this->add_responsive_control(
232 'inline_column_gap',
233 [
234 'label' => esc_html__( 'Columns Gap', 'ultimate-post-kit' ),
235 'type' => Controls_Manager::SLIDER,
236 'default' => [
237 'size' => 10,
238 ],
239 'selectors' => [
240 '{{WRAPPER}} .upk-ss-btn' => 'margin-right: calc({{SIZE}}{{UNIT}} / 2); margin-left: calc({{SIZE}}{{UNIT}} / 2);',
241 '{{WRAPPER}} .upk-ep-grid' => 'margin-right: calc(-{{SIZE}}{{UNIT}} / 2); margin-left: calc(-{{SIZE}}{{UNIT}} / 2);',
242 ],
243 'condition' => [
244 'layout_style' => 'inline'
245 ]
246 ]
247 );
248
249 $this->add_responsive_control(
250 'row_gap',
251 [
252 'label' => esc_html__( 'Rows Gap', 'ultimate-post-kit' ),
253 'type' => Controls_Manager::SLIDER,
254 'default' => [
255 'size' => 10,
256 ],
257 'selectors' => [
258 '{{WRAPPER}} .upk-ss-btn' => 'margin-bottom: {{SIZE}}{{UNIT}};',
259 ],
260 'condition' => [
261 'layout_style' => 'inline'
262 ]
263 ]
264 );
265
266 $this->add_responsive_control(
267 'alignment',
268 [
269 'label' => esc_html__( 'Alignment', 'ultimate-post-kit' ),
270 'type' => Controls_Manager::CHOOSE,
271 'options' => [
272 'flex-start' => [
273 'title' => esc_html__( 'Left', 'ultimate-post-kit' ),
274 'icon' => 'eicon-text-align-left',
275 ],
276 'center' => [
277 'title' => esc_html__( 'Center', 'ultimate-post-kit' ),
278 'icon' => 'eicon-text-align-center',
279 ],
280 'flex-end' => [
281 'title' => esc_html__( 'Right', 'ultimate-post-kit' ),
282 'icon' => 'eicon-text-align-right',
283 ],
284 'space-between' => [
285 'title' => esc_html__( 'Justify', 'ultimate-post-kit' ),
286 'icon' => 'eicon-text-align-justify',
287 ],
288 ],
289 'selectors' => [
290 '{{WRAPPER}} .upk-social-share' => 'justify-content: {{VALUE}};',
291 ],
292 'condition' => [
293 'layout_style' => 'inline'
294 ]
295 ]
296 );
297
298 $this->add_control(
299 'hr_1',
300 [
301 'type' => Controls_Manager::DIVIDER,
302 'condition' => [
303 'layout_style' => 'inline'
304 ]
305 ]
306 );
307
308 $this->add_control(
309 'layout_position',
310 [
311 'label' => esc_html__( 'Position', 'ultimate-post-kit' ),
312 'type' => Controls_Manager::SELECT,
313 'default' => 'default',
314 'options' => [
315 'default' => esc_html__( 'Default', 'ultimate-post-kit' ),
316 'top-left' => esc_html__( 'Top Left', 'ultimate-post-kit' ),
317 'top-right' => esc_html__( 'Top Right', 'ultimate-post-kit' ),
318 'center-left' => esc_html__( 'Center Left', 'ultimate-post-kit' ),
319 'center-right' => esc_html__( 'Center Right', 'ultimate-post-kit' ),
320 'bottom-left' => esc_html__( 'Bottom Left', 'ultimate-post-kit' ),
321 'bottom-right' => esc_html__( 'Bottom Right', 'ultimate-post-kit' ),
322 ],
323 'prefix_class' => 'upk-ss-position--',
324 'condition' => [
325 'layout_style' => 'inline'
326 ]
327 ]
328 );
329
330 $this->add_control(
331 'social_share_offset',
332 [
333 'label' => __( 'Offset', 'ultimate-post-kit' ),
334 'type' => Controls_Manager::POPOVER_TOGGLE,
335 'condition' => [
336 'layout_position!' => 'default',
337 'layout_style' => 'inline'
338 ],
339 'render_type' => 'ui',
340 ]
341 );
342
343 $this->start_popover();
344
345 $this->add_responsive_control(
346 'ss_horizontal_offset',
347 [
348 'label' => esc_html__( 'Horizontal', 'ultimate-post-kit' ),
349 'type' => Controls_Manager::SLIDER,
350 'range' => [
351 'px' => [
352 'min' => -200,
353 'max' => 200,
354 'step' => 10,
355 ],
356 ],
357 'default' => [
358 'unit' => 'px',
359 'size' => 0,
360 ],
361 'condition' => [
362 'social_share_offset' => 'yes',
363 ],
364 'selectors' => [
365 '{{WRAPPER}}.upk-layout-style--inline .upk-social-share' => 'margin-left: {{SIZE}}{{UNIT}}; margin-right: {{SIZE}}{{UNIT}};',
366 ],
367 ]
368 );
369
370 $this->add_responsive_control(
371 'ss_vertical_offset',
372 [
373 'label' => esc_html__( 'Vertical', 'ultimate-post-kit' ),
374 'type' => Controls_Manager::SLIDER,
375 'range' => [
376 'px' => [
377 'min' => -200,
378 'max' => 200,
379 'step' => 10,
380 ],
381 ],
382 'default' => [
383 'unit' => 'px',
384 'size' => 0,
385 ],
386 'condition' => [
387 'social_share_offset' => 'yes',
388 ],
389 'selectors' => [
390 '{{WRAPPER}}.upk-layout-style--inline .upk-social-share' => 'margin-top: {{SIZE}}{{UNIT}}; margin-bottom: {{SIZE}}{{UNIT}};',
391 ],
392 ]
393 );
394
395 $this->end_popover();
396
397 $this->add_control(
398 'share_url_type',
399 [
400 'label' => esc_html__( 'Target URL', 'ultimate-post-kit' ),
401 'type' => Controls_Manager::SELECT,
402 'options' => [
403 'current_page' => esc_html__( 'Current Page', 'ultimate-post-kit' ),
404 'custom' => esc_html__( 'Custom', 'ultimate-post-kit' ),
405 ],
406 'default' => 'current_page',
407 'separator' => 'before',
408 ]
409 );
410
411 $this->add_control(
412 'share_url',
413 [
414 'label' => esc_html__( 'URL', 'ultimate-post-kit' ),
415 'type' => Controls_Manager::URL,
416 'show_external' => false,
417 'placeholder' => 'http://your-link.com',
418 'condition' => [
419 'share_url_type' => 'custom',
420 ],
421 ]
422 );
423
424 $this->end_controls_section();
425
426 //Style
427 $this->start_controls_section(
428 'section_buttons_style',
429 [
430 'label' => esc_html__( 'Share Buttons', 'ultimate-post-kit' ),
431 'tab' => Controls_Manager::TAB_STYLE,
432 ]
433 );
434
435 $this->add_control(
436 'style',
437 [
438 'label' => esc_html__( 'Style', 'ultimate-post-kit' ),
439 'type' => Controls_Manager::SELECT,
440 'options' => [
441 'flat' => esc_html__( 'Flat', 'ultimate-post-kit' ),
442 'framed' => esc_html__( 'Framed', 'ultimate-post-kit' ),
443 'gradient' => esc_html__( 'Gradient', 'ultimate-post-kit' ),
444 'minimal' => esc_html__( 'Minimal', 'ultimate-post-kit' ),
445 'boxed' => esc_html__( 'Boxed Icon', 'ultimate-post-kit' ),
446 ],
447 'default' => 'flat',
448 'prefix_class' => 'upk-ss-btns-style-',
449 ]
450 );
451
452 $prefix_class = add_filter('social_share_prefix_class', '');
453
454 $this->add_control(
455 'icon_top',
456 [
457 'label' => __( 'Icon Position Top', 'ultimate-post-kit' ) . BDTUPK_PC,
458 'type' => Controls_Manager::SWITCHER,
459 'prefix_class' => $prefix_class,
460 'condition' => [
461 'layout_position!' => ['center-left', 'center-right'],
462 'view' => 'icon-text'
463 ],
464 'classes' => BDTUPK_IS_PC
465 ]
466 );
467
468 $this->add_responsive_control(
469 'ss_icon_padding',
470 [
471 'label' => __('Icon Padding', 'ultimate-post-kit') . BDTUPK_PC,
472 'type' => Controls_Manager::DIMENSIONS,
473 'size_units' => ['px', '%', 'em'],
474 'selectors' => [
475 '{{WRAPPER}}.upk-ss-icon-top--yes .upk-ss-btn .upk-ss-icon' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
476 ],
477 'condition' => [
478 'icon_top' => 'yes'
479 ],
480 ]
481 );
482
483 $this->add_responsive_control(
484 'ss_text_padding',
485 [
486 'label' => __('Text Padding', 'ultimate-post-kit') . BDTUPK_PC,
487 'type' => Controls_Manager::DIMENSIONS,
488 'size_units' => ['px', '%', 'em'],
489 'selectors' => [
490 '{{WRAPPER}}.upk-ss-icon-top--yes .upk-ss-btn .upk-social-share-text' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
491 ],
492 'condition' => [
493 'icon_top' => 'yes'
494 ],
495 ]
496 );
497
498 $this->add_control(
499 'divider_one',
500 [
501 'type' => Controls_Manager::DIVIDER,
502 ]
503 );
504
505 $this->add_responsive_control(
506 'button_size',
507 [
508 'label' => esc_html__( 'Button Size', 'ultimate-post-kit' ),
509 'type' => Controls_Manager::SLIDER,
510 'range' => [
511 'px' => [
512 'min' => 0.5,
513 'max' => 2,
514 'step' => 0.1,
515 ],
516 ],
517 'selectors' => [
518 '{{WRAPPER}} .upk-ss-btn' => 'font-size: calc({{SIZE}}{{UNIT}} * 10);',
519 ],
520 ]
521 );
522
523 $this->add_responsive_control(
524 'icon_size',
525 [
526 'label' => esc_html__( 'Icon Size', 'ultimate-post-kit' ),
527 'type' => Controls_Manager::SLIDER,
528 'range' => [
529 'em' => [
530 'min' => 0.5,
531 'max' => 4,
532 'step' => 0.1,
533 ],
534 'px' => [
535 'min' => 0,
536 'max' => 100,
537 ],
538 ],
539 'default' => [
540 'unit' => 'em',
541 ],
542 'tablet_default' => [
543 'unit' => 'em',
544 ],
545 'mobile_default' => [
546 'unit' => 'em',
547 ],
548 'size_units' => [ 'em', 'px' ],
549 'selectors' => [
550 '{{WRAPPER}} .upk-ss-icon i' => 'font-size: {{SIZE}}{{UNIT}};',
551 ],
552 'condition' => [
553 'view!' => 'text',
554 ],
555 ]
556 );
557
558 $this->add_responsive_control(
559 'button_height',
560 [
561 'label' => esc_html__( 'Button Height', 'ultimate-post-kit' ),
562 'type' => Controls_Manager::SLIDER,
563 'range' => [
564 'em' => [
565 'min' => 1,
566 'max' => 7,
567 'step' => 0.1,
568 ],
569 'px' => [
570 'min' => 0,
571 'max' => 100,
572 ],
573 ],
574 'default' => [
575 'unit' => 'em',
576 ],
577 'tablet_default' => [
578 'unit' => 'em',
579 ],
580 'mobile_default' => [
581 'unit' => 'em',
582 ],
583 'size_units' => [ 'em', 'px' ],
584 'selectors' => [
585 '{{WRAPPER}} .upk-ss-btn' => 'height: {{SIZE}}{{UNIT}};',
586 ],
587 ]
588 );
589
590 $this->add_responsive_control(
591 'border_size',
592 [
593 'label' => esc_html__( 'Border Size', 'ultimate-post-kit' ),
594 'type' => Controls_Manager::SLIDER,
595 'size_units' => [ 'px', 'em' ],
596 'default' => [
597 'size' => 2,
598 ],
599 'range' => [
600 'px' => [
601 'min' => 1,
602 'max' => 20,
603 ],
604 'em' => [
605 'max' => 2,
606 'step' => 0.1,
607 ],
608 ],
609 'selectors' => [
610 '{{WRAPPER}} .upk-ss-btn' => 'border-width: {{SIZE}}{{UNIT}};',
611 ],
612 'condition' => [
613 'style' => [ 'framed', 'boxed' ],
614 ],
615 ]
616 );
617
618 $this->add_responsive_control(
619 'border_radius',
620 [
621 'label' => esc_html__( 'Border Radius', 'ultimate-post-kit' ),
622 'type' => Controls_Manager::DIMENSIONS,
623 'size_units' => [ 'px', '%' ],
624 'selectors' => [
625 '{{WRAPPER}} .upk-ss-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
626 ],
627 ]
628 );
629
630 $this->add_control(
631 'text_padding',
632 [
633 'label' => esc_html__( 'Text Padding', 'ultimate-post-kit' ),
634 'type' => Controls_Manager::DIMENSIONS,
635 'size_units' => [ 'px', 'em', '%' ],
636 'selectors' => [
637 '{{WRAPPER}}.upk-ss-btns-view-text .upk-social-share-text' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
638 ],
639 'separator' => 'before',
640 'condition' => [
641 'view' => 'text',
642 ],
643 ]
644 );
645
646 $this->add_group_control(
647 Group_Control_Typography::get_type(),
648 [
649 'name' => 'typography',
650 'label' => esc_html__( 'Typography', 'ultimate-post-kit' ),
651 'selector' => '{{WRAPPER}} .upk-social-share-title, {{WRAPPER}} .upk-ss-counter',
652 'exclude' => [ 'line_height' ],
653 ]
654 );
655
656 $this->add_control(
657 'color_source',
658 [
659 'label' => esc_html__( 'Color', 'ultimate-post-kit' ),
660 'type' => Controls_Manager::SELECT,
661 'label_block' => false,
662 'options' => [
663 'original' => 'Original Color',
664 'custom' => 'Custom Color',
665 ],
666 'default' => 'original',
667 'prefix_class' => 'upk-ss-btns-color-',
668 'separator' => 'before',
669 ]
670 );
671
672 $this->start_controls_tabs( 'tabs_button_style' );
673
674 $this->start_controls_tab(
675 'tab_button_normal',
676 [
677 'label' => esc_html__( 'Normal', 'ultimate-post-kit' ),
678 'condition' => [
679 'color_source' => 'custom',
680 ],
681 ]
682 );
683
684 $this->add_control(
685 'primary_color',
686 [
687 'label' => esc_html__( 'Primary Color', 'ultimate-post-kit' ),
688 'type' => Controls_Manager::COLOR,
689 'selectors' => [
690 '{{WRAPPER}}.upk-ss-btns-style-flat .upk-ss-btn,
691 {{WRAPPER}}.upk-ss-btns-style-gradient .upk-ss-btn,
692 {{WRAPPER}}.upk-ss-btns-style-boxed .upk-ss-btn .upk-ss-icon,
693 {{WRAPPER}}.upk-ss-btns-style-minimal .upk-ss-btn .upk-ss-icon' => 'background-color: {{VALUE}}',
694 '{{WRAPPER}}.upk-ss-btns-style-framed .upk-ss-btn,
695 {{WRAPPER}}.upk-ss-btns-style-minimal .upk-ss-btn,
696 {{WRAPPER}}.upk-ss-btns-style-boxed .upk-ss-btn' => 'color: {{VALUE}}; border-color: {{VALUE}}',
697 ],
698 'condition' => [
699 'color_source' => 'custom',
700 ],
701 ]
702 );
703
704 $this->add_control(
705 'secondary_color',
706 [
707 'label' => esc_html__( 'Secondary Color', 'ultimate-post-kit' ),
708 'type' => Controls_Manager::COLOR,
709 'selectors' => [
710 '{{WRAPPER}}.upk-ss-btns-style-flat .upk-ss-icon,
711 {{WRAPPER}}.upk-ss-btns-style-flat .upk-social-share-text,
712 {{WRAPPER}}.upk-ss-btns-style-gradient .upk-ss-icon,
713 {{WRAPPER}}.upk-ss-btns-style-gradient .upk-social-share-text,
714 {{WRAPPER}}.upk-ss-btns-style-boxed .upk-ss-icon,
715 {{WRAPPER}}.upk-ss-btns-style-minimal .upk-ss-icon' => 'color: {{VALUE}}',
716 '{{WRAPPER}}.upk-ss-btns-style-framed .upk-ss-btn' => 'background-color: {{VALUE}}',
717 ],
718 'condition' => [
719 'color_source' => 'custom',
720 ],
721 ]
722 );
723
724 $this->add_control(
725 'border_color',
726 [
727 'label' => esc_html__( 'Border Color', 'ultimate-post-kit' ),
728 'type' => Controls_Manager::COLOR,
729 'selectors' => [
730 '{{WRAPPER}}.upk-ss-btns-style-boxed .upk-ss-btn, {{WRAPPER}}.upk-ss-btns-style-framed .upk-ss-btn' => 'border-color: {{VALUE}}',
731 ],
732 'condition' => [
733 'color_source' => 'custom',
734 'style' => ['framed', 'boxed']
735 ],
736 ]
737 );
738
739 $this->end_controls_tab();
740
741 $this->start_controls_tab(
742 'tab_button_hover',
743 [
744 'label' => esc_html__( 'Hover', 'ultimate-post-kit' ),
745 'condition' => [
746 'color_source' => 'custom',
747 ],
748 ]
749 );
750
751 $this->add_control(
752 'primary_color_hover',
753 [
754 'label' => esc_html__( 'Primary Color', 'ultimate-post-kit' ),
755 'type' => Controls_Manager::COLOR,
756 'selectors' => [
757 '{{WRAPPER}}.upk-ss-btns-style-flat .upk-ss-btn:hover,
758 {{WRAPPER}}.upk-ss-btns-style-gradient .upk-ss-btn:hover' => 'background-color: {{VALUE}}',
759 '{{WRAPPER}}.upk-ss-btns-style-framed .upk-ss-btn:hover,
760 {{WRAPPER}}.upk-ss-btns-style-minimal .upk-ss-btn:hover,
761 {{WRAPPER}}.upk-ss-btns-style-boxed .upk-ss-btn:hover' => 'color: {{VALUE}}; border-color: {{VALUE}}',
762 '{{WRAPPER}}.upk-ss-btns-style-boxed .upk-ss-btn:hover .upk-ss-icon,
763 {{WRAPPER}}.upk-ss-btns-style-minimal .upk-ss-btn:hover .upk-ss-icon' => 'background-color: {{VALUE}}',
764 ],
765 'condition' => [
766 'color_source' => 'custom',
767 ],
768 ]
769 );
770
771 $this->add_control(
772 'secondary_color_hover',
773 [
774 'label' => esc_html__( 'Secondary Color', 'ultimate-post-kit' ),
775 'type' => Controls_Manager::COLOR,
776 'selectors' => [
777 '{{WRAPPER}}.upk-ss-btns-style-flat .upk-ss-btn:hover .upk-ss-icon,
778 {{WRAPPER}}.upk-ss-btns-style-flat .upk-ss-btn:hover .upk-social-share-text,
779 {{WRAPPER}}.upk-ss-btns-style-gradient .upk-ss-btn:hover .upk-ss-icon,
780 {{WRAPPER}}.upk-ss-btns-style-gradient .upk-ss-btn:hover .upk-social-share-text,
781 {{WRAPPER}}.upk-ss-btns-style-boxed .upk-ss-btn:hover .upk-ss-icon,
782 {{WRAPPER}}.upk-ss-btns-style-minimal .upk-ss-btn:hover .upk-ss-icon' => 'color: {{VALUE}}',
783 '{{WRAPPER}}.upk-ss-btns-style-framed .upk-ss-btn:hover' => 'background-color: {{VALUE}}',
784 ],
785 'condition' => [
786 'color_source' => 'custom',
787 ],
788 ]
789 );
790
791 $this->add_control(
792 'border_hover_color',
793 [
794 'label' => esc_html__( 'Border Color', 'ultimate-post-kit' ),
795 'type' => Controls_Manager::COLOR,
796 'selectors' => [
797 '{{WRAPPER}}.upk-ss-btns-style-boxed .upk-ss-btn:hover, {{WRAPPER}}.upk-ss-btns-style-framed .upk-ss-btn:hover' => 'border-color: {{VALUE}}',
798 ],
799 'condition' => [
800 'color_source' => 'custom',
801 'style' => ['framed', 'boxed']
802 ],
803 ]
804 );
805
806 $this->end_controls_tab();
807
808 $this->end_controls_tabs();
809
810 $this->end_controls_section();
811 }
812
813 private function has_counter( $media_name ) {
814 $settings = $this->get_active_settings();
815
816 return 'icon' !== $settings['view'] && 'yes' === $settings['show_counter'] && ! empty( Module::get_social_media( $media_name )['has_counter'] );
817 }
818
819 public function render() {
820
821 $settings = $this->get_active_settings();
822
823 if ( empty( $settings['share_buttons'] ) ) {
824 return;
825 }
826
827 $show_text = 'text' === $settings['view'] || 'icon-text' === $settings['view'];
828 ?>
829 <div class="upk-social-share upk-ep-grid">
830 <?php
831 foreach ( $settings['share_buttons'] as $button ) {
832 $social_name = $button['button'];
833 $has_counter = $this->has_counter( $social_name );
834
835 if ( 'custom' === $settings['share_url_type'] ) {
836 $this->add_render_attribute( 'social-attrs', 'data-url', esc_url( $settings['share_url']['url'] ), true );
837 }
838
839 $this->add_render_attribute(
840 [
841 'social-attrs' => [
842 'class' => [
843 'upk-ss-btn',
844 'upk-ss-' . $social_name
845 ],
846 'data-social' => $social_name,
847 ]
848 ], '', '', true
849 );
850
851 ?>
852 <div class="upk-social-share-item upk-ep-grid-item">
853 <div <?php $this->print_render_attribute_string( 'social-attrs' ); ?>>
854 <?php if ( 'icon' === $settings['view'] || 'icon-text' === $settings['view'] ) : ?>
855 <span class="upk-ss-icon">
856 <i class="<?php echo self::get_social_media_class( $social_name ); ?>"></i>
857 </span>
858 <?php endif; ?>
859 <?php if ( $show_text || $has_counter ) : ?>
860 <div class="upk-social-share-text upk-inline">
861 <?php if ( 'icon-text' === $settings['view'] || 'text' === $settings['view'] ) : ?>
862 <span class="upk-social-share-title">
863 <?php echo $button['text'] ? esc_html($button['text']) : Module::get_social_media( $social_name )['title']; ?>
864 </span>
865 <?php endif; ?>
866 <?php if ( $has_counter ) : ?>
867 <span class="upk-social-share-counter" data-counter="<?php echo esc_attr($social_name); ?>"></span>
868 <?php endif; ?>
869 </div>
870 <?php endif; ?>
871 </div>
872 </div>
873 <?php
874 }
875 ?>
876 </div>
877
878
879 <?php
880 }
881
882
883 }
884