PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / 4.1.15
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets v4.1.15
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 4.1.3 4.1.4 All 146 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.1.15, at modules/social-share/widgets/social-share.php

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