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

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

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