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

887 lines 23.2 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 // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour.
655 'exclude' => [ 'line_height' ],
656 ]
657 );
658
659 $this->add_control(
660 'color_source',
661 [
662 'label' => esc_html__( 'Color', 'ultimate-post-kit' ),
663 'type' => Controls_Manager::SELECT,
664 'label_block' => false,
665 'options' => [
666 'original' => 'Original Color',
667 'custom' => 'Custom Color',
668 ],
669 'default' => 'original',
670 'prefix_class' => 'upk-ss-btns-color-',
671 'separator' => 'before',
672 ]
673 );
674
675 $this->start_controls_tabs( 'tabs_button_style' );
676
677 $this->start_controls_tab(
678 'tab_button_normal',
679 [
680 'label' => esc_html__( 'Normal', 'ultimate-post-kit' ),
681 'condition' => [
682 'color_source' => 'custom',
683 ],
684 ]
685 );
686
687 $this->add_control(
688 'primary_color',
689 [
690 'label' => esc_html__( 'Primary Color', 'ultimate-post-kit' ),
691 'type' => Controls_Manager::COLOR,
692 'selectors' => [
693 '{{WRAPPER}}.upk-ss-btns-style-flat .upk-ss-btn,
694 {{WRAPPER}}.upk-ss-btns-style-gradient .upk-ss-btn,
695 {{WRAPPER}}.upk-ss-btns-style-boxed .upk-ss-btn .upk-ss-icon,
696 {{WRAPPER}}.upk-ss-btns-style-minimal .upk-ss-btn .upk-ss-icon' => 'background-color: {{VALUE}}',
697 '{{WRAPPER}}.upk-ss-btns-style-framed .upk-ss-btn,
698 {{WRAPPER}}.upk-ss-btns-style-minimal .upk-ss-btn,
699 {{WRAPPER}}.upk-ss-btns-style-boxed .upk-ss-btn' => 'color: {{VALUE}}; border-color: {{VALUE}}',
700 ],
701 'condition' => [
702 'color_source' => 'custom',
703 ],
704 ]
705 );
706
707 $this->add_control(
708 'secondary_color',
709 [
710 'label' => esc_html__( 'Secondary Color', 'ultimate-post-kit' ),
711 'type' => Controls_Manager::COLOR,
712 'selectors' => [
713 '{{WRAPPER}}.upk-ss-btns-style-flat .upk-ss-icon,
714 {{WRAPPER}}.upk-ss-btns-style-flat .upk-social-share-text,
715 {{WRAPPER}}.upk-ss-btns-style-gradient .upk-ss-icon,
716 {{WRAPPER}}.upk-ss-btns-style-gradient .upk-social-share-text,
717 {{WRAPPER}}.upk-ss-btns-style-boxed .upk-ss-icon,
718 {{WRAPPER}}.upk-ss-btns-style-minimal .upk-ss-icon' => 'color: {{VALUE}}',
719 '{{WRAPPER}}.upk-ss-btns-style-framed .upk-ss-btn' => 'background-color: {{VALUE}}',
720 ],
721 'condition' => [
722 'color_source' => 'custom',
723 ],
724 ]
725 );
726
727 $this->add_control(
728 'border_color',
729 [
730 'label' => esc_html__( 'Border Color', 'ultimate-post-kit' ),
731 'type' => Controls_Manager::COLOR,
732 'selectors' => [
733 '{{WRAPPER}}.upk-ss-btns-style-boxed .upk-ss-btn, {{WRAPPER}}.upk-ss-btns-style-framed .upk-ss-btn' => 'border-color: {{VALUE}}',
734 ],
735 'condition' => [
736 'color_source' => 'custom',
737 'style' => ['framed', 'boxed']
738 ],
739 ]
740 );
741
742 $this->end_controls_tab();
743
744 $this->start_controls_tab(
745 'tab_button_hover',
746 [
747 'label' => esc_html__( 'Hover', 'ultimate-post-kit' ),
748 'condition' => [
749 'color_source' => 'custom',
750 ],
751 ]
752 );
753
754 $this->add_control(
755 'primary_color_hover',
756 [
757 'label' => esc_html__( 'Primary Color', 'ultimate-post-kit' ),
758 'type' => Controls_Manager::COLOR,
759 'selectors' => [
760 '{{WRAPPER}}.upk-ss-btns-style-flat .upk-ss-btn:hover,
761 {{WRAPPER}}.upk-ss-btns-style-gradient .upk-ss-btn:hover' => 'background-color: {{VALUE}}',
762 '{{WRAPPER}}.upk-ss-btns-style-framed .upk-ss-btn:hover,
763 {{WRAPPER}}.upk-ss-btns-style-minimal .upk-ss-btn:hover,
764 {{WRAPPER}}.upk-ss-btns-style-boxed .upk-ss-btn:hover' => 'color: {{VALUE}}; border-color: {{VALUE}}',
765 '{{WRAPPER}}.upk-ss-btns-style-boxed .upk-ss-btn:hover .upk-ss-icon,
766 {{WRAPPER}}.upk-ss-btns-style-minimal .upk-ss-btn:hover .upk-ss-icon' => 'background-color: {{VALUE}}',
767 ],
768 'condition' => [
769 'color_source' => 'custom',
770 ],
771 ]
772 );
773
774 $this->add_control(
775 'secondary_color_hover',
776 [
777 'label' => esc_html__( 'Secondary Color', 'ultimate-post-kit' ),
778 'type' => Controls_Manager::COLOR,
779 'selectors' => [
780 '{{WRAPPER}}.upk-ss-btns-style-flat .upk-ss-btn:hover .upk-ss-icon,
781 {{WRAPPER}}.upk-ss-btns-style-flat .upk-ss-btn:hover .upk-social-share-text,
782 {{WRAPPER}}.upk-ss-btns-style-gradient .upk-ss-btn:hover .upk-ss-icon,
783 {{WRAPPER}}.upk-ss-btns-style-gradient .upk-ss-btn:hover .upk-social-share-text,
784 {{WRAPPER}}.upk-ss-btns-style-boxed .upk-ss-btn:hover .upk-ss-icon,
785 {{WRAPPER}}.upk-ss-btns-style-minimal .upk-ss-btn:hover .upk-ss-icon' => 'color: {{VALUE}}',
786 '{{WRAPPER}}.upk-ss-btns-style-framed .upk-ss-btn:hover' => 'background-color: {{VALUE}}',
787 ],
788 'condition' => [
789 'color_source' => 'custom',
790 ],
791 ]
792 );
793
794 $this->add_control(
795 'border_hover_color',
796 [
797 'label' => esc_html__( 'Border Color', 'ultimate-post-kit' ),
798 'type' => Controls_Manager::COLOR,
799 'selectors' => [
800 '{{WRAPPER}}.upk-ss-btns-style-boxed .upk-ss-btn:hover, {{WRAPPER}}.upk-ss-btns-style-framed .upk-ss-btn:hover' => 'border-color: {{VALUE}}',
801 ],
802 'condition' => [
803 'color_source' => 'custom',
804 'style' => ['framed', 'boxed']
805 ],
806 ]
807 );
808
809 $this->end_controls_tab();
810
811 $this->end_controls_tabs();
812
813 $this->end_controls_section();
814 }
815
816 private function has_counter( $media_name ) {
817 $settings = $this->get_active_settings();
818
819 return 'icon' !== $settings['view'] && 'yes' === $settings['show_counter'] && ! empty( Module::get_social_media( $media_name )['has_counter'] );
820 }
821
822 public function render() {
823
824 $settings = $this->get_active_settings();
825
826 if ( empty( $settings['share_buttons'] ) ) {
827 return;
828 }
829
830 $show_text = 'text' === $settings['view'] || 'icon-text' === $settings['view'];
831 ?>
832 <div class="upk-social-share upk-ep-grid">
833 <?php
834 foreach ( $settings['share_buttons'] as $button ) {
835 $social_name = $button['button'];
836 $has_counter = $this->has_counter( $social_name );
837
838 if ( 'custom' === $settings['share_url_type'] ) {
839 $this->add_render_attribute( 'social-attrs', 'data-url', esc_url( $settings['share_url']['url'] ), true );
840 }
841
842 $this->add_render_attribute(
843 [
844 'social-attrs' => [
845 'class' => [
846 'upk-ss-btn',
847 'upk-ss-' . sanitize_html_class( $social_name ),
848 ],
849 'data-social' => esc_attr( $social_name ),
850 ]
851 ], '', '', true
852 );
853
854 ?>
855 <div class="upk-social-share-item upk-ep-grid-item">
856 <div <?php $this->print_render_attribute_string( 'social-attrs' ); ?>>
857 <?php if ( 'icon' === $settings['view'] || 'icon-text' === $settings['view'] ) : ?>
858 <span class="upk-ss-icon">
859 <i class="<?php echo esc_attr( self::get_social_media_class( $social_name ) ); ?>"></i>
860 </span>
861 <?php endif; ?>
862 <?php if ( $show_text || $has_counter ) : ?>
863 <div class="upk-social-share-text upk-inline">
864 <?php if ( 'icon-text' === $settings['view'] || 'text' === $settings['view'] ) : ?>
865 <span class="upk-social-share-title">
866 <?php echo $button['text'] ? esc_html($button['text']) : esc_html( Module::get_social_media( $social_name )['title'] ); ?>
867 </span>
868 <?php endif; ?>
869 <?php if ( $has_counter ) : ?>
870 <span class="upk-social-share-counter" data-counter="<?php echo esc_attr($social_name); ?>"></span>
871 <?php endif; ?>
872 </div>
873 <?php endif; ?>
874 </div>
875 </div>
876 <?php
877 }
878 ?>
879 </div>
880
881
882 <?php
883 }
884
885
886 }
887