PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / 4.1.16
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets v4.1.16
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 / buzz-list-carousel / widgets / buzz-list-carousel.php

buzz-list-carousel.php in Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets 4.1.16, at modules/buzz-list-carousel/widgets/buzz-list-carousel.php

1,016 lines 25.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace UltimatePostKit\Modules\BuzzListCarousel\Widgets;
4
5 use Elementor\Controls_Manager;
6 use Elementor\Group_Control_Border;
7 use Elementor\Group_Control_Box_Shadow;
8 use Elementor\Group_Control_Typography;
9 use Elementor\Group_Control_Text_Shadow;
10 use Elementor\Group_Control_Image_Size;
11 use Elementor\Group_Control_Background;
12
13 use UltimatePostKit\Traits\Global_Widget_Controls;
14 use UltimatePostKit\Traits\Global_Widget_Functions;
15 use UltimatePostKit\Traits\Global_Swiper_Functions;
16 use UltimatePostKit\Includes\Controls\GroupQuery\Group_Control_Query;
17 use WP_Query;
18
19 if (!defined('ABSPATH')) {
20 exit;
21 } // Exit if accessed directly
22
23 class Buzz_List_Carousel extends Group_Control_Query {
24
25 use Global_Widget_Controls;
26 use Global_Widget_Functions;
27 use Global_Swiper_Functions;
28
29 private $_query = null;
30
31 public function get_name() {
32 return 'upk-buzz-list-carousel';
33 }
34
35 public function get_title() {
36 return BDTUPK . esc_html__('Buzz List Carousel', 'ultimate-post-kit');
37 }
38
39 public function get_icon() {
40 return 'upk-widget-icon upk-icon-buzz-list-carousel';
41 }
42
43 public function get_categories() {
44 return ['ultimate-post-kit'];
45 }
46
47 public function get_keywords() {
48 return ['post', 'carousel', 'blog', 'recent', 'news', 'buzz', 'list'];
49 }
50
51 public function get_style_depends() {
52 if ($this->upk_is_edit_mode()) {
53 return ['swiper', 'upk-all-styles'];
54 } else {
55 return ['swiper', 'upk-font', 'upk-buzz-list-carousel'];
56 }
57 }
58
59 public function get_script_depends() {
60 if ($this->upk_is_edit_mode()) {
61 return ['swiper', 'upk-all-scripts'];
62 } else {
63 return ['swiper', 'upk-buzz-list-carousel'];
64 }
65 }
66
67 public function get_custom_help_url() {
68 return 'https://youtu.be/fxjL-ugL_Ls';
69 }
70
71 public function get_query() {
72 return $this->_query;
73 }
74
75 public function has_widget_inner_wrapper(): bool {
76 return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
77 }
78
79
80 protected function register_controls() {
81 $this->start_controls_section(
82 'section_content_layout',
83 [
84 'label' => esc_html__('Layout', 'ultimate-post-kit'),
85 ]
86 );
87
88 $this->add_responsive_control(
89 'columns',
90 [
91 'label' => __('Columns', 'ultimate-post-kit'),
92 'type' => Controls_Manager::SELECT,
93 'default' => 3,
94 'tablet_default' => 2,
95 'mobile_default' => 1,
96 'options' => [
97 1 => '1',
98 2 => '2',
99 3 => '3',
100 4 => '4',
101 ],
102 ]
103 );
104
105 $this->add_responsive_control(
106 'item_gap',
107 [
108 'label' => __('Column Gap', 'ultimate-post-kit'),
109 'type' => Controls_Manager::SLIDER,
110 ]
111 );
112
113 $this->add_group_control(
114 Group_Control_Image_Size::get_type(),
115 [
116 'name' => 'primary_thumbnail',
117 'exclude' => ['custom'],
118 'default' => 'medium',
119 ]
120 );
121
122 $this->add_control(
123 'hr',
124 [
125 'type' => Controls_Manager::DIVIDER,
126 ]
127 );
128
129 //Global Title Controls
130 $this->register_title_controls();
131
132 $this->add_control(
133 'show_category',
134 [
135 'label' => esc_html__('Show Category', 'ultimate-post-kit'),
136 'type' => Controls_Manager::SWITCHER,
137 'default' => 'yes',
138 ]
139 );
140
141 $this->add_control(
142 'show_author',
143 [
144 'label' => esc_html__('Show Author', 'ultimate-post-kit'),
145 'type' => Controls_Manager::SWITCHER,
146 'default' => 'yes',
147 'separator' => 'before'
148 ]
149 );
150
151 $this->add_control(
152 'show_comments',
153 [
154 'label' => esc_html__('Show Comments', 'ultimate-post-kit'),
155 'type' => Controls_Manager::SWITCHER,
156 ]
157 );
158
159 $this->add_control(
160 'meta_separator',
161 [
162 'label' => __('Separator', 'ultimate-post-kit'),
163 'type' => Controls_Manager::TEXT,
164 'default' => '//',
165 'label_block' => false,
166 ]
167 );
168
169 //Global Date Controls
170 $this->register_date_controls();
171
172 //Global Reading Time Controls
173 $this->register_reading_time_controls();
174
175 $this->add_control(
176 'item_match_height',
177 [
178 'label' => __('Item Match Height', 'ultimate-post-kit'),
179 'type' => Controls_Manager::SWITCHER,
180 'default' => 'yes',
181 'prefix_class' => 'upk-item-match-height--',
182 'separator' => 'before'
183 ]
184 );
185
186 $this->add_control(
187 'global_link',
188 [
189 'label' => __('Item Wrapper Link', 'ultimate-post-kit'),
190 'type' => Controls_Manager::SWITCHER,
191 'prefix_class' => 'upk-global-link-',
192 'description' => __('Be aware! When Item Wrapper Link activated then title link and read more link will not work', 'ultimate-post-kit'),
193 ]
194 );
195
196 $this->add_responsive_control(
197 'content_vertical_align',
198 [
199 'label' => esc_html__('Vertical Align', 'ultimate-post-kit'),
200 'type' => Controls_Manager::CHOOSE,
201 'options' => [
202 'flex-start' => [
203 'title' => esc_html__('Top', 'ultimate-post-kit'),
204 'icon' => 'eicon-v-align-top',
205 ],
206 'center' => [
207 'title' => esc_html__('Center', 'ultimate-post-kit'),
208 'icon' => 'eicon-v-align-middle',
209 ],
210 'flex-end' => [
211 'title' => esc_html__('Bottom', 'ultimate-post-kit'),
212 'icon' => 'eicon-v-align-bottom',
213 ],
214 ],
215 'selectors' => [
216 '{{WRAPPER}} .upk-buzz-list-carousel .upk-content' => 'align-items: {{VALUE}};',
217 ],
218 'separator' => 'before'
219 ]
220 );
221
222 $this->end_controls_section();
223
224 // Query Settings
225 $this->start_controls_section(
226 'section_post_query_builder',
227 [
228 'label' => __('Query', 'ultimate-post-kit'),
229 'tab' => Controls_Manager::TAB_CONTENT,
230 ]
231 );
232
233 $this->add_control(
234 'item_limit',
235 [
236 'label' => esc_html__('Item Limit', 'ultimate-post-kit'),
237 'type' => Controls_Manager::SLIDER,
238 'range' => [
239 'px' => [
240 'min' => 1,
241 'max' => 20,
242 ],
243 ],
244 'default' => [
245 'size' => 6,
246 ],
247 'condition' => [
248 'posts_source!' => 'current_query',
249 ]
250 ]
251 );
252
253 $this->register_query_builder_controls();
254
255 $this->end_controls_section();
256
257 //Navigaiton Global Controls
258 $this->register_navigation_controls('buzz-list');
259
260 //Style
261 $this->start_controls_section(
262 'upk_section_style',
263 [
264 'label' => esc_html__('Item', 'ultimate-post-kit'),
265 'tab' => Controls_Manager::TAB_STYLE,
266 ]
267 );
268
269 $this->start_controls_tabs('tabs_item_style');
270
271 $this->start_controls_tab(
272 'tab_item_normal',
273 [
274 'label' => esc_html__('Normal', 'ultimate-post-kit'),
275 ]
276 );
277
278 $this->add_control(
279 'overlay_background',
280 [
281 'label' => esc_html__('Overlay Color', 'ultimate-post-kit'),
282 'type' => Controls_Manager::COLOR,
283 'selectors' => [
284 '{{WRAPPER}} .upk-buzz-list-carousel .upk-img-wrap::before' => 'background: {{VALUE}};'
285 ],
286 ]
287 );
288
289 $this->add_group_control(
290 Group_Control_Border::get_type(),
291 [
292 'name' => 'item_border',
293 'label' => __('Border', 'ultimate-post-kit'),
294 'placeholder' => '1px',
295 'default' => '1px',
296 'selector' => '{{WRAPPER}} .upk-buzz-list-carousel .upk-item',
297 ]
298 );
299
300 $this->add_responsive_control(
301 'item_border_radius',
302 [
303 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
304 'type' => Controls_Manager::DIMENSIONS,
305 'size_units' => ['px', '%'],
306 'selectors' => [
307 '{{WRAPPER}} .upk-buzz-list-carousel .upk-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
308 ],
309 ]
310 );
311
312 $this->add_responsive_control(
313 'item_padding',
314 [
315 'label' => esc_html__('Padding', 'ultimate-post-kit'),
316 'type' => Controls_Manager::DIMENSIONS,
317 'size_units' => ['px', 'em', '%'],
318 'selectors' => [
319 '{{WRAPPER}} .upk-buzz-list-carousel .upk-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
320 ],
321 ]
322 );
323
324 $this->end_controls_tab();
325
326 $this->start_controls_tab(
327 'tab_item_hover',
328 [
329 'label' => esc_html__('Hover', 'ultimate-post-kit'),
330 ]
331 );
332
333 $this->add_control(
334 'overlay_background_hover',
335 [
336 'label' => esc_html__('Overlay Color', 'ultimate-post-kit'),
337 'type' => Controls_Manager::COLOR,
338 'selectors' => [
339 '{{WRAPPER}} .upk-buzz-list-carousel .upk-item:hover .upk-img-wrap::before' => 'background: {{VALUE}};'
340 ],
341 ]
342 );
343
344 $this->add_control(
345 'item_border_color_hover',
346 [
347 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
348 'type' => Controls_Manager::COLOR,
349 'selectors' => [
350 '{{WRAPPER}} .upk-buzz-list-carousel .upk-item:hover' => 'border-color: {{VALUE}};'
351 ],
352 'condition' => [
353 'item_border_border!' => ''
354 ]
355 ]
356 );
357
358 $this->end_controls_tab();
359
360 $this->end_controls_tabs();
361
362 $this->end_controls_section();
363
364 $this->start_controls_section(
365 'section_style_title',
366 [
367 'label' => esc_html__('Title', 'ultimate-post-kit'),
368 'tab' => Controls_Manager::TAB_STYLE,
369 'condition' => [
370 'show_title' => 'yes',
371 ],
372 ]
373 );
374
375 $this->add_control(
376 'title_style',
377 [
378 'label' => esc_html__('Style', 'ultimate-post-kit'),
379 'type' => Controls_Manager::SELECT,
380 'default' => 'underline',
381 'options' => [
382 'underline' => esc_html__('Underline', 'ultimate-post-kit'),
383 'middle-underline' => esc_html__('Middle Underline', 'ultimate-post-kit'),
384 'overline' => esc_html__('Overline', 'ultimate-post-kit'),
385 'middle-overline' => esc_html__('Middle Overline', 'ultimate-post-kit'),
386 ],
387 ]
388 );
389
390 $this->add_control(
391 'title_color',
392 [
393 'label' => esc_html__('Color', 'ultimate-post-kit'),
394 'type' => Controls_Manager::COLOR,
395 'selectors' => [
396 '{{WRAPPER}} .upk-buzz-list-carousel .upk-title a' => 'color: {{VALUE}};',
397 ],
398 'separator' => 'before'
399 ]
400 );
401
402 $this->add_control(
403 'title_hover_color',
404 [
405 'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
406 'type' => Controls_Manager::COLOR,
407 'selectors' => [
408 '{{WRAPPER}} .upk-buzz-list-carousel .upk-item:hover .upk-title a' => 'color: {{VALUE}};',
409 ],
410 ]
411 );
412
413 $this->add_group_control(
414 Group_Control_Typography::get_type(),
415 [
416 'name' => 'title_typography',
417 'label' => esc_html__('Typography', 'ultimate-post-kit'),
418 'selector' => '{{WRAPPER}} .upk-buzz-list-carousel .upk-title',
419 ]
420 );
421
422 $this->add_group_control(
423 Group_Control_Text_Shadow::get_type(),
424 [
425 'name' => 'title_text_shadow',
426 'label' => __('Text Shadow', 'ultimate-post-kit'),
427 'selector' => '{{WRAPPER}} .upk-buzz-list-carousel .upk-title a',
428 ]
429 );
430
431 $this->end_controls_section();
432
433 $this->start_controls_section(
434 'section_style_meta',
435 [
436 'label' => esc_html__('Meta', 'ultimate-post-kit'),
437 'tab' => Controls_Manager::TAB_STYLE,
438 'conditions' => [
439 'relation' => 'or',
440 'terms' => [
441 [
442 'name' => 'show_author',
443 'value' => 'yes'
444 ],
445 [
446 'name' => 'show_date',
447 'value' => 'yes'
448 ],
449 [
450 'name' => 'show_comments',
451 'value' => 'yes'
452 ]
453 ]
454 ],
455 ]
456 );
457
458 $this->add_control(
459 'meta_color',
460 [
461 'label' => esc_html__('Color', 'ultimate-post-kit'),
462 'type' => Controls_Manager::COLOR,
463 'selectors' => [
464 '{{WRAPPER}} .upk-buzz-list-carousel .upk-meta, {{WRAPPER}} .upk-buzz-list-carousel .upk-meta .upk-author-wrap .upk-author-name' => 'color: {{VALUE}};',
465 ],
466 ]
467 );
468
469 $this->add_control(
470 'meta_hover_color',
471 [
472 'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
473 'type' => Controls_Manager::COLOR,
474 'selectors' => [
475 '{{WRAPPER}} .upk-buzz-list-carousel .upk-item:hover .upk-meta, {{WRAPPER}} .upk-buzz-list-carousel .upk-item:hover .upk-meta .upk-author-wrap .upk-author-name' => 'color: {{VALUE}};',
476 ],
477 ]
478 );
479
480 $this->add_responsive_control(
481 'meta_spacing',
482 [
483 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
484 'type' => Controls_Manager::SLIDER,
485 'range' => [
486 'px' => [
487 'min' => 0,
488 'max' => 50,
489 ],
490 ],
491 'selectors' => [
492 '{{WRAPPER}} .upk-buzz-list-carousel .upk-meta' => 'padding-top: {{SIZE}}{{UNIT}};',
493 ],
494 ]
495 );
496
497 $this->add_responsive_control(
498 'meta_space_between',
499 [
500 'label' => esc_html__('Space Between', 'ultimate-post-kit'),
501 'type' => Controls_Manager::SLIDER,
502 'range' => [
503 'px' => [
504 'min' => 0,
505 'max' => 50,
506 ],
507 ],
508 'selectors' => [
509 '{{WRAPPER}} .upk-buzz-list-carousel .upk-meta > div:before' => 'margin: 0 {{SIZE}}{{UNIT}};',
510 ],
511 ]
512 );
513
514 $this->add_group_control(
515 Group_Control_Typography::get_type(),
516 [
517 'name' => 'meta_typography',
518 'label' => esc_html__('Typography', 'ultimate-post-kit'),
519 'selector' => '{{WRAPPER}} .upk-buzz-list-carousel .upk-meta',
520 ]
521 );
522
523 $this->end_controls_section();
524
525 $this->start_controls_section(
526 'section_style_category',
527 [
528 'label' => esc_html__('Category', 'ultimate-post-kit'),
529 'tab' => Controls_Manager::TAB_STYLE,
530 'condition' => [
531 'show_category' => 'yes',
532 ],
533 ]
534 );
535
536 $this->add_responsive_control(
537 'category_bottom_spacing',
538 [
539 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
540 'type' => Controls_Manager::SLIDER,
541 'range' => [
542 'px' => [
543 'min' => 0,
544 'max' => 50,
545 ],
546 ],
547 'selectors' => [
548 '{{WRAPPER}} .upk-buzz-list-carousel .upk-category' => 'margin-bottom: {{SIZE}}{{UNIT}};',
549 ],
550 ]
551 );
552
553 $this->start_controls_tabs('tabs_category_style');
554
555 $this->start_controls_tab(
556 'tab_category_normal',
557 [
558 'label' => esc_html__('Normal', 'ultimate-post-kit'),
559 ]
560 );
561
562 $this->add_control(
563 'category_color',
564 [
565 'label' => esc_html__('Color', 'ultimate-post-kit'),
566 'type' => Controls_Manager::COLOR,
567 'selectors' => [
568 '{{WRAPPER}} .upk-buzz-list-carousel .upk-category a' => 'color: {{VALUE}};',
569 ],
570 ]
571 );
572
573 $this->add_group_control(
574 Group_Control_Background::get_type(),
575 [
576 'name' => 'category_background',
577 'selector' => '{{WRAPPER}} .upk-buzz-list-carousel .upk-category a',
578 ]
579 );
580
581 $this->add_group_control(
582 Group_Control_Border::get_type(),
583 [
584 'name' => 'category_border',
585 'selector' => '{{WRAPPER}} .upk-buzz-list-carousel .upk-category a',
586 ]
587 );
588
589 $this->add_responsive_control(
590 'category_border_radius',
591 [
592 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
593 'type' => Controls_Manager::DIMENSIONS,
594 'size_units' => ['px', '%'],
595 'selectors' => [
596 '{{WRAPPER}} .upk-buzz-list-carousel .upk-category a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
597 ],
598 ]
599 );
600
601 $this->add_responsive_control(
602 'category_padding',
603 [
604 'label' => esc_html__('Padding', 'ultimate-post-kit'),
605 'type' => Controls_Manager::DIMENSIONS,
606 'size_units' => ['px', 'em', '%'],
607 'selectors' => [
608 '{{WRAPPER}} .upk-buzz-list-carousel .upk-category a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
609 ],
610 ]
611 );
612
613 $this->add_responsive_control(
614 'category_spacing',
615 [
616 'label' => esc_html__('Space Between', 'ultimate-post-kit'),
617 'type' => Controls_Manager::SLIDER,
618 'range' => [
619 'px' => [
620 'min' => 0,
621 'max' => 50,
622 'step' => 2,
623 ],
624 ],
625 'selectors' => [
626 '{{WRAPPER}} .upk-buzz-list-carousel .upk-category a+a' => 'margin-left: {{SIZE}}{{UNIT}};',
627 ],
628 ]
629 );
630
631 $this->add_group_control(
632 Group_Control_Box_Shadow::get_type(),
633 [
634 'name' => 'category_shadow',
635 'selector' => '{{WRAPPER}} .upk-buzz-list-carousel .upk-category a',
636 ]
637 );
638
639 $this->add_group_control(
640 Group_Control_Typography::get_type(),
641 [
642 'name' => 'category_typography',
643 'label' => esc_html__('Typography', 'ultimate-post-kit'),
644 'selector' => '{{WRAPPER}} .upk-buzz-list-carousel .upk-category a',
645 ]
646 );
647
648 $this->end_controls_tab();
649
650 $this->start_controls_tab(
651 'tab_category_hover',
652 [
653 'label' => esc_html__('Hover', 'ultimate-post-kit'),
654 ]
655 );
656
657 $this->add_control(
658 'category_hover_color',
659 [
660 'label' => esc_html__('Color', 'ultimate-post-kit'),
661 'type' => Controls_Manager::COLOR,
662 'selectors' => [
663 '{{WRAPPER}} .upk-buzz-list-carousel .upk-item:hover .upk-category a' => 'color: {{VALUE}};',
664 ],
665 ]
666 );
667
668 $this->add_group_control(
669 Group_Control_Background::get_type(),
670 [
671 'name' => 'category_hover_background',
672 'selector' => '{{WRAPPER}} .upk-buzz-list-carousel .upk-item:hover .upk-category a',
673 ]
674 );
675
676 $this->add_control(
677 'category_hover_border_color',
678 [
679 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
680 'type' => Controls_Manager::COLOR,
681 'condition' => [
682 'category_border_border!' => '',
683 ],
684 'selectors' => [
685 '{{WRAPPER}} .upk-buzz-list-carousel .upk-item:hover .upk-category a' => 'border-color: {{VALUE}};',
686 ],
687 ]
688 );
689
690 $this->end_controls_tab();
691
692 $this->end_controls_tabs();
693
694 $this->end_controls_section();
695
696 $this->start_controls_section(
697 'section_style_counter_number',
698 [
699 'label' => esc_html__('Counter Number', 'ultimate-post-kit'),
700 'tab' => Controls_Manager::TAB_STYLE,
701 ]
702 );
703
704 $this->start_controls_tabs('tabs_counter_number_style');
705
706 $this->start_controls_tab(
707 'tab_counter_number_normal',
708 [
709 'label' => esc_html__('Normal', 'ultimate-post-kit'),
710 ]
711 );
712
713 $this->add_control(
714 'counter_number_color',
715 [
716 'label' => esc_html__('Color', 'ultimate-post-kit'),
717 'type' => Controls_Manager::COLOR,
718 'selectors' => [
719 '{{WRAPPER}} .upk-buzz-list-carousel .upk-count' => 'color: {{VALUE}};',
720 ],
721 ]
722 );
723
724 $this->add_group_control(
725 Group_Control_Background::get_type(),
726 [
727 'name' => 'counter_number_background',
728 'selector' => '{{WRAPPER}} .upk-buzz-list-carousel .upk-count',
729 ]
730 );
731
732 $this->add_group_control(
733 Group_Control_Border::get_type(),
734 [
735 'name' => 'counter_number_border',
736 'label' => esc_html__('Border', 'ultimate-post-kit'),
737 'selector' => '{{WRAPPER}} .upk-buzz-list-carousel .upk-count',
738 ]
739 );
740
741 $this->add_responsive_control(
742 'counter_number_border_radius',
743 [
744 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
745 'type' => Controls_Manager::DIMENSIONS,
746 'size_units' => ['px', '%'],
747 'selectors' => [
748 '{{WRAPPER}} .upk-buzz-list-carousel .upk-count' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
749 ],
750 ]
751 );
752
753 $this->add_responsive_control(
754 'counter_number_padding',
755 [
756 'label' => esc_html__('Padding', 'ultimate-post-kit'),
757 'type' => Controls_Manager::DIMENSIONS,
758 'size_units' => ['px', 'em', '%'],
759 'selectors' => [
760 '{{WRAPPER}} .upk-buzz-list-carousel .upk-count' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
761 ],
762 ]
763 );
764
765 $this->add_group_control(
766 Group_Control_Box_Shadow::get_type(),
767 [
768 'name' => 'counter_number_shadow',
769 'selector' => '{{WRAPPER}} .upk-buzz-list-carousel .upk-count',
770 ]
771 );
772
773 $this->add_group_control(
774 Group_Control_Typography::get_type(),
775 [
776 'name' => 'counter_number_typography',
777 'label' => esc_html__('Typography', 'ultimate-post-kit'),
778 'selector' => '{{WRAPPER}} .upk-buzz-list-carousel .upk-count',
779 ]
780 );
781
782 $this->add_control(
783 'counter_line_color',
784 [
785 'label' => esc_html__('Line Color', 'ultimate-post-kit'),
786 'type' => Controls_Manager::COLOR,
787 'selectors' => [
788 '{{WRAPPER}} .upk-buzz-list-carousel .upk-inner' => 'border-left-color: {{VALUE}};',
789 ],
790 'separator' => 'before'
791 ]
792 );
793
794 $this->add_responsive_control(
795 'counter_number_spacing',
796 [
797 'label' => esc_html__('Line Space Between', 'ultimate-post-kit'),
798 'type' => Controls_Manager::SLIDER,
799 'range' => [
800 'px' => [
801 'min' => 0,
802 'max' => 50,
803 ],
804 ],
805 'selectors' => [
806 '{{WRAPPER}} .upk-buzz-list-carousel .upk-count' => 'margin-right: {{SIZE}}{{UNIT}};',
807 '{{WRAPPER}} .upk-buzz-list-carousel .upk-inner' => 'padding-left: {{SIZE}}{{UNIT}};',
808 ],
809 ]
810 );
811
812 $this->end_controls_tab();
813
814 $this->start_controls_tab(
815 'tab_counter_number_hover',
816 [
817 'label' => esc_html__('Hover', 'ultimate-post-kit'),
818 ]
819 );
820
821 $this->add_control(
822 'counter_number_hover_color',
823 [
824 'label' => esc_html__('Text Color', 'ultimate-post-kit'),
825 'type' => Controls_Manager::COLOR,
826 'selectors' => [
827 '{{WRAPPER}} .upk-buzz-list-carousel .upk-item:hover .upk-count' => 'color: {{VALUE}};',
828 ],
829 ]
830 );
831
832 $this->add_group_control(
833 Group_Control_Background::get_type(),
834 [
835 'name' => 'counter_number_background_hover',
836 'selector' => '{{WRAPPER}} .upk-buzz-list-carousel .upk-item:hover .upk-count',
837 ]
838 );
839
840 $this->add_control(
841 'counter_number_border_hover_color',
842 [
843 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
844 'type' => Controls_Manager::COLOR,
845 'condition' => [
846 'counter_number_border_border!' => '',
847 ],
848 'selectors' => [
849 '{{WRAPPER}} .upk-buzz-list-carousel .upk-item:hover .upk-count' => 'border-color: {{VALUE}};',
850 ],
851 ]
852 );
853
854 $this->add_group_control(
855 Group_Control_Box_Shadow::get_type(),
856 [
857 'name' => 'counter_number_shadow_hover',
858 'selector' => '{{WRAPPER}} .upk-buzz-list-carousel .upk-item:hover .upk-count',
859 ]
860 );
861
862 $this->add_control(
863 'counter_line_hover_color',
864 [
865 'label' => esc_html__('Line Color', 'ultimate-post-kit'),
866 'type' => Controls_Manager::COLOR,
867 'selectors' => [
868 '{{WRAPPER}} .upk-buzz-list-carousel .upk-item:hover .upk-inner' => 'border-left-color: {{VALUE}};',
869 ],
870 'separator' => 'before'
871 ]
872 );
873
874 $this->end_controls_tab();
875 $this->end_controls_tabs();
876 $this->end_controls_section();
877
878 //Navigation Global Controls
879 $this->register_navigation_style('swiper');
880 }
881
882 /**
883 * Main query render for this widget
884 * @param $posts_per_page number item query limit
885 */
886 public function query_posts($posts_per_page) {
887
888 $default = $this->getGroupControlQueryArgs();
889 $args = [];
890 if ($posts_per_page) {
891 $args['posts_per_page'] = $posts_per_page;
892 }
893 $args = array_merge($default, $args);
894 $this->_query = new WP_Query($args);
895 }
896
897 public function render_author() {
898
899 if (!$this->get_settings('show_author')) {
900 return;
901 }
902 ?>
903 <div class="upk-author-wrap">
904 <span class="upk-by"><?php echo esc_html_x('by', 'Frontend', 'ultimate-post-kit'); ?></span>
905 <a class="upk-author-name" href="<?php echo esc_url( get_author_posts_url(get_the_author_meta('ID')) ); ?>">
906 <?php echo esc_html( get_the_author() ); ?>
907 </a>
908 </div>
909 <?php
910 }
911
912 public function render_comments($id = 0) {
913
914 if (!$this->get_settings('show_comments')) {
915 return;
916 }
917 ?>
918
919 <div class="upk-comments">
920 <?php echo esc_html( $this->upk_get_formatted_comments_count( $id ) ); ?>
921 </div>
922
923 <?php
924 }
925
926 public function render_header() {
927 //Global Function
928 $this->render_header_attribute('buzz-list');
929
930 ?>
931 <div <?php $this->print_render_attribute_string('carousel'); ?>>
932 <div class="upk-buzz-wrapper">
933 <div <?php $this->print_render_attribute_string('swiper'); ?>>
934 <div class="swiper-wrapper">
935 <?php
936 }
937
938 public function render_post_grid_item($post_id, $image_size, $slide_index) {
939 $settings = $this->get_settings_for_display();
940
941 if ('yes' == $settings['global_link']) {
942
943 $this->add_render_attribute('list-item', 'onclick', "window.open('" . esc_url(get_permalink()) . "', '_self')", true);
944 }
945 $this->add_render_attribute('list-item', 'class', 'upk-item swiper-slide upk-flex upk-flex-middle', true);
946
947 ?>
948 <div <?php $this->print_render_attribute_string('list-item'); ?>>
949 <div class="upk-img-wrap">
950 <?php $this->render_image(get_post_thumbnail_id($post_id), $image_size); ?>
951 </div>
952 <div class="upk-content">
953 <div class="upk-count"><?php printf("%2d", $slide_index); ?></div>
954 <div class="upk-inner">
955 <?php $this->render_category(); ?>
956 <?php $this->render_title(substr($this->get_name(), 4)); ?>
957 <?php if ($settings['show_author'] or $settings['show_comments'] or $settings['show_date'] or $settings['show_reading_time']) : ?>
958 <div class="upk-meta upk-flex upk-flex-middle">
959 <?php if ($settings['show_author']) : ?>
960 <?php $this->render_author(); ?>
961 <?php endif; ?>
962
963 <?php if ($settings['show_date']) : ?>
964 <div data-separator="<?php echo esc_html($settings['meta_separator']); ?>">
965 <?php $this->render_date(); ?>
966 </div>
967 <?php endif; ?>
968
969 <?php if (_is_upk_pro_activated()) :
970 if ('yes' === $settings['show_reading_time']) : ?>
971 <div class="upk-reading-time" data-separator="<?php echo esc_html($settings['meta_separator']); ?>">
972 <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'], $settings['hide_seconds'] ?? 'no', $settings['hide_minutes'] ?? 'no' ) ); ?>
973 </div>
974 <?php endif; ?>
975 <?php endif; ?>
976
977 <?php if ($settings['show_comments']) : ?>
978 <div data-separator="<?php echo esc_html($settings['meta_separator']); ?>">
979 <?php $this->render_comments($post_id); ?>
980 </div>
981 <?php endif; ?>
982
983 </div>
984 <?php endif; ?>
985 </div>
986 </div>
987 </div>
988 <?php
989 }
990
991 public function render() {
992 $settings = $this->get_settings_for_display();
993
994 $this->query_posts($settings['item_limit']['size']);
995 $wp_query = $this->get_query();
996
997 if (!$wp_query->found_posts) {
998 return;
999 }
1000
1001 $this->render_header();
1002
1003 $slide_index = 1;
1004 while ($wp_query->have_posts()) {
1005 $wp_query->the_post();
1006 $thumbnail_size = $settings['primary_thumbnail_size'];
1007 $this->render_post_grid_item(get_the_ID(), $thumbnail_size, $slide_index);
1008 $slide_index++;
1009 }
1010
1011 wp_reset_postdata();
1012
1013 $this->render_footer();
1014 }
1015 }
1016