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

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

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