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

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

1,263 lines 31.5 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\AlterCarousel\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 Elementor\Icons_Manager;
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 Alter_Carousel extends Group_Control_Query
23 {
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 {
33 return 'upk-alter-carousel';
34 }
35
36 public function get_title()
37 {
38 return BDTUPK . esc_html__('Alter Carousel', 'ultimate-post-kit');
39 }
40
41 public function get_icon()
42 {
43 return 'upk-widget-icon upk-icon-alter-carousel';
44 }
45
46 public function get_categories()
47 {
48 return ['ultimate-post-kit'];
49 }
50
51 public function get_keywords()
52 {
53 return ['post', 'carousel', 'blog', 'recent', 'news', 'alter'];
54 }
55
56 public function get_style_depends()
57 {
58 if ($this->upk_is_edit_mode()) {
59 return ['swiper', 'upk-all-styles'];
60 } else {
61 return ['swiper', 'upk-font', 'upk-alter-carousel'];
62 }
63 }
64
65 public function get_script_depends()
66 {
67 if ($this->upk_is_edit_mode()) {
68 return ['swiper', 'upk-all-scripts'];
69 } else {
70 return ['swiper', 'upk-alter-carousel'];
71 }
72 }
73
74 public function get_custom_help_url()
75 {
76 return 'https://youtu.be/KInlL05e_lk';
77 }
78
79 public function get_query()
80 {
81 return $this->_query;
82 }
83
84 public function has_widget_inner_wrapper(): bool {
85 return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
86 }
87
88
89 protected function register_controls() {
90 $this->start_controls_section(
91 'section_content_layout',
92 [
93 'label' => esc_html__('Layout', 'ultimate-post-kit'),
94 ]
95 );
96
97 $this->add_responsive_control(
98 'columns',
99 [
100 'label' => __('Columns', 'ultimate-post-kit'),
101 'type' => Controls_Manager::SELECT,
102 'default' => 3,
103 'tablet_default' => 2,
104 'mobile_default' => 1,
105 'options' => [
106 1 => '1',
107 2 => '2',
108 3 => '3',
109 4 => '4',
110 5 => '5',
111 6 => '6',
112 ],
113 ]
114 );
115
116 $this->add_responsive_control(
117 'item_gap',
118 [
119 'label' => __('Item Gap', 'ultimate-post-kit'),
120 'type' => Controls_Manager::SLIDER,
121 'default' => [
122 'size' => 20,
123 ],
124 'tablet_default' => [
125 'size' => 20,
126 ],
127 'mobile_default' => [
128 'size' => 20,
129 ],
130 'range' => [
131 'px' => [
132 'min' => 0,
133 'max' => 100,
134 ],
135 ],
136 ]
137 );
138
139 $this->add_group_control(
140 Group_Control_Image_Size::get_type(),
141 [
142 'name' => 'primary_thumbnail',
143 'exclude' => ['custom'],
144 'default' => 'medium',
145 ]
146 );
147
148 $this->add_responsive_control(
149 'default_image_height',
150 [
151 'label' => esc_html__('Image Height(px)', 'ultimate-post-kit'),
152 'type' => Controls_Manager::SLIDER,
153 'range' => [
154 'px' => [
155 'min' => 100,
156 'max' => 500,
157 ],
158 ],
159 'selectors' => [
160 '{{WRAPPER}} .upk-alter-carousel .upk-img-wrap .upk-main-img' => 'height: {{SIZE}}px;',
161 ],
162 ]
163 );
164
165 $this->end_controls_section();
166
167 // Query Settings
168 $this->start_controls_section(
169 'section_post_query_builder',
170 [
171 'label' => __('Query', 'ultimate-post-kit') . BDTUPK_NC,
172 'tab' => Controls_Manager::TAB_CONTENT,
173 ]
174 );
175
176 $this->add_control(
177 'item_limit',
178 [
179 'label' => esc_html__('Item Limit', 'ultimate-post-kit'),
180 'type' => Controls_Manager::SLIDER,
181 'range' => [
182 'px' => [
183 'min' => 1,
184 'max' => 20,
185 ],
186 ],
187 'default' => [
188 'size' => 6,
189 ],
190 ]
191 );
192
193 $this->register_query_builder_controls();
194
195 $this->end_controls_section();
196
197 $this->start_controls_section(
198 'section_content_additional',
199 [
200 'label' => esc_html__('Additional', 'ultimate-post-kit'),
201 ]
202 );
203
204 //Global Title Controls
205 $this->register_title_controls();
206 $this->register_text_controls();
207
208 $this->add_control(
209 'show_author',
210 [
211 'label' => esc_html__('Show Author', 'ultimate-post-kit'),
212 'type' => Controls_Manager::SWITCHER,
213 'default' => 'yes',
214 'separator' => 'before'
215 ]
216 );
217
218 $this->add_control(
219 'meta_separator',
220 [
221 'label' => __('Separator', 'ultimate-post-kit') . BDTUPK_NC,
222 'type' => Controls_Manager::TEXT,
223 'default' => '|',
224 'label_block' => false,
225 ]
226 );
227
228 //Global Date Controls
229 $this->register_date_controls();
230
231 //Global Reading Time Controls
232 $this->register_reading_time_controls();
233
234 $this->add_control(
235 'show_category',
236 [
237 'label' => esc_html__('Show Category', 'ultimate-post-kit'),
238 'type' => Controls_Manager::SWITCHER,
239 'default' => 'yes',
240 'separator' => 'before'
241 ]
242 );
243
244 $this->add_control(
245 'readmore_type',
246 [
247 'label' => esc_html__('Read More Type', 'ultimate-post-kit') . BDTUPK_PC,
248 'type' => Controls_Manager::SELECT,
249 'default' => 'none',
250 'options' => [
251 'none' => esc_html__('None', 'ultimate-post-kit'),
252 'classic' => esc_html__('Classic', 'ultimate-post-kit'),
253 'on_image' => esc_html__('On Image', 'ultimate-post-kit'),
254 ],
255 'separator' => 'before',
256 'classes' => BDTUPK_IS_PC
257 ]
258 );
259
260 $this->add_control(
261 'item_match_height',
262 [
263 'label' => __('Item Match Height', 'ultimate-post-kit'),
264 'type' => Controls_Manager::SWITCHER,
265 'default' => 'yes',
266 'prefix_class' => 'upk-item-match-height--',
267 'separator' => 'before',
268 'render_type' => 'template'
269 ]
270 );
271
272 $this->add_control(
273 'meta_end_position',
274 [
275 'label' => esc_html__('Meta End Position', 'ultimate-post-kit') . BDTUPK_NC,
276 'type' => Controls_Manager::SWITCHER,
277 'prefix_class' => 'upk-meta-end-position--',
278 'condition' => [
279 'item_match_height' => 'yes'
280 ]
281 ]
282 );
283
284 $this->add_control(
285 'show_post_format',
286 [
287 'label' => esc_html__('Post Format', 'ultimate-post-kit') . BDTUPK_NC,
288 'type' => Controls_Manager::SWITCHER,
289 'separator' => 'before'
290 ]
291 );
292
293 $this->add_control(
294 'global_link',
295 [
296 'label' => __('Item Wrapper Link', 'ultimate-post-kit'),
297 'type' => Controls_Manager::SWITCHER,
298 'prefix_class' => 'upk-global-link-',
299 'description' => __('Be aware! When Item Wrapper Link activated then title link and read more link will not work', 'ultimate-post-kit'),
300 'separator' => 'before',
301 ]
302 );
303
304 $this->end_controls_section();
305
306 $this->start_controls_section(
307 'section_content_readmore',
308 [
309 'label' => esc_html__('Read More', 'ultimate-post-kit') . BDTUPK_NC,
310 'condition' => [
311 'readmore_type' => 'classic',
312 ],
313 ]
314 );
315
316 $this->add_control(
317 'readmore_text',
318 [
319 'label' => esc_html__('Read More Text', 'ultimate-post-kit'),
320 'type' => Controls_Manager::TEXT,
321 'default' => esc_html__('Read More', 'ultimate-post-kit'),
322 'placeholder' => esc_html__('Read More', 'ultimate-post-kit'),
323 ]
324 );
325
326 $this->add_control(
327 'readmore_icon',
328 [
329 'label' => esc_html__('Icon', 'ultimate-post-kit'),
330 'type' => Controls_Manager::ICONS,
331 'label_block' => false,
332 'skin' => 'inline'
333 ]
334 );
335
336 $this->add_control(
337 'readmore_icon_align',
338 [
339 'label' => esc_html__('Icon Position', 'ultimate-post-kit'),
340 'type' => Controls_Manager::CHOOSE,
341 'default' => 'right',
342 'toggle' => false,
343 'options' => [
344 'left' => [
345 'title' => esc_html__('Left', 'ultimate-post-kit'),
346 'icon' => 'eicon-h-align-left',
347 ],
348 'right' => [
349 'title' => esc_html__('Right', 'ultimate-post-kit'),
350 'icon' => 'eicon-h-align-right',
351 ],
352 ],
353 'condition' => [
354 'readmore_icon[value]!' => '',
355 ],
356 ]
357 );
358
359 $this->add_responsive_control(
360 'readmore_icon_indent',
361 [
362 'label' => esc_html__('Icon Spacing', 'ultimate-post-kit'),
363 'type' => Controls_Manager::SLIDER,
364 'default' => [
365 'size' => 8,
366 ],
367 'range' => [
368 'px' => [
369 'max' => 50,
370 ],
371 ],
372 'condition' => [
373 'readmore_icon[value]!' => '',
374 ],
375 'selectors' => [
376 '{{WRAPPER}} .upk-alter-carousel .upk-button-icon-align-right' => is_rtl() ? 'margin-right: {{SIZE}}{{UNIT}};' : 'margin-left: {{SIZE}}{{UNIT}};',
377 '{{WRAPPER}} .upk-alter-carousel .upk-button-icon-align-left' => is_rtl() ? 'margin-left: {{SIZE}}{{UNIT}};' : 'margin-right: {{SIZE}}{{UNIT}};',
378 ],
379 ]
380 );
381
382 $this->end_controls_section();
383
384 //Navigaiton Global Controls
385 $this->register_navigation_controls('alter');
386
387 //Style
388 $this->start_controls_section(
389 'upk_section_style',
390 [
391 'label' => esc_html__('Items', 'ultimate-post-kit'),
392 'tab' => Controls_Manager::TAB_STYLE,
393 ]
394 );
395
396 $this->add_responsive_control(
397 'content_padding',
398 [
399 'label' => __('Content Padding', 'ultimate-post-kit'),
400 'type' => Controls_Manager::DIMENSIONS,
401 'size_units' => ['px', 'em', '%'],
402 'selectors' => [
403 '{{WRAPPER}} .upk-alter-carousel .upk-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
404 ],
405 ]
406 );
407
408 $this->start_controls_tabs('tabs_item_style');
409
410 $this->start_controls_tab(
411 'tab_item_normal',
412 [
413 'label' => esc_html__('Normal', 'ultimate-post-kit'),
414 ]
415 );
416
417 $this->add_group_control(
418 Group_Control_Background::get_type(),
419 [
420 'name' => 'itam_background',
421 'selector' => '{{WRAPPER}} .upk-alter-carousel .upk-item',
422 ]
423 );
424
425 $this->add_group_control(
426 Group_Control_Border::get_type(),
427 [
428 'name' => 'item_border',
429 'label' => __('Border', 'ultimate-post-kit'),
430 'placeholder' => '1px',
431 'default' => '1px',
432 'selector' => '{{WRAPPER}} .upk-alter-carousel .upk-item',
433 ]
434 );
435
436 $this->add_responsive_control(
437 'item_border_radius',
438 [
439 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
440 'type' => Controls_Manager::DIMENSIONS,
441 'size_units' => ['px', '%'],
442 'selectors' => [
443 '{{WRAPPER}} .upk-alter-carousel .upk-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
444 ],
445 ]
446 );
447
448 $this->add_group_control(
449 Group_Control_Box_Shadow::get_type(),
450 [
451 'name' => 'item_box_shadow',
452 'selector' => '{{WRAPPER}} .upk-alter-carousel .upk-item',
453 ]
454 );
455
456 $this->end_controls_tab();
457
458 $this->start_controls_tab(
459 'tab_item_hover',
460 [
461 'label' => esc_html__('Hover', 'ultimate-post-kit'),
462 ]
463 );
464
465 $this->add_group_control(
466 Group_Control_Background::get_type(),
467 [
468 'name' => 'itam_background_hover',
469 'selector' => '{{WRAPPER}} .upk-alter-carousel .upk-item:hover',
470 ]
471 );
472
473 $this->add_control(
474 'item_border_color_hover',
475 [
476 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
477 'type' => Controls_Manager::COLOR,
478 'selectors' => [
479 '{{WRAPPER}} .upk-alter-carousel .upk-item:hover' => 'border-color: {{VALUE}};'
480 ],
481 'condition' => [
482 'item_border_border!' => ''
483 ]
484 ]
485 );
486
487 $this->add_group_control(
488 Group_Control_Box_Shadow::get_type(),
489 [
490 'name' => 'item_box_shadow_hover',
491 'selector' => '{{WRAPPER}} .upk-alter-carousel .upk-item:hover',
492 ]
493 );
494
495 $this->add_responsive_control(
496 'item_shadow_padding',
497 [
498 'label' => __('Match Padding', 'ultimate-post-kit'),
499 'description' => __('You have to add padding for matching overlaping normal/hover box shadow when you used Box Shadow option.', 'ultimate-post-kit'),
500 'type' => Controls_Manager::SLIDER,
501 'range' => [
502 'px' => [
503 'min' => 0,
504 'step' => 1,
505 'max' => 50,
506 ]
507 ],
508 'selectors' => [
509 '{{WRAPPER}} .swiper-carousel' => 'padding: {{SIZE}}{{UNIT}}; margin: 0 -{{SIZE}}{{UNIT}};'
510 ],
511 ]
512 );
513
514 $this->end_controls_tab();
515
516 $this->end_controls_tabs();
517
518 $this->end_controls_section();
519
520 $this->start_controls_section(
521 'section_style_title',
522 [
523 'label' => esc_html__('Title', 'ultimate-post-kit'),
524 'tab' => Controls_Manager::TAB_STYLE,
525 'condition' => [
526 'show_title' => 'yes',
527 ],
528 ]
529 );
530
531 $this->add_control(
532 'title_style',
533 [
534 'label' => esc_html__('Style', 'ultimate-post-kit'),
535 'type' => Controls_Manager::SELECT,
536 'default' => 'underline',
537 'options' => [
538 'underline' => esc_html__('Underline', 'ultimate-post-kit'),
539 'middle-underline' => esc_html__('Middle Underline', 'ultimate-post-kit'),
540 'overline' => esc_html__('Overline', 'ultimate-post-kit'),
541 'middle-overline' => esc_html__('Middle Overline', 'ultimate-post-kit'),
542 ],
543 ]
544 );
545
546 $this->add_control(
547 'title_color',
548 [
549 'label' => esc_html__('Color', 'ultimate-post-kit'),
550 'type' => Controls_Manager::COLOR,
551 'selectors' => [
552 '{{WRAPPER}} .upk-alter-carousel .upk-title a' => 'color: {{VALUE}};',
553 ],
554 ]
555 );
556
557 $this->add_control(
558 'title_hover_color',
559 [
560 'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
561 'type' => Controls_Manager::COLOR,
562 'selectors' => [
563 '{{WRAPPER}} .upk-alter-carousel .upk-title a:hover' => 'color: {{VALUE}};',
564 ],
565 ]
566 );
567
568 $this->add_responsive_control(
569 'title_spacing',
570 [
571 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
572 'type' => Controls_Manager::SLIDER,
573 'range' => [
574 'px' => [
575 'min' => 0,
576 'max' => 50,
577 ],
578 ],
579 'selectors' => [
580 '{{WRAPPER}} .upk-alter-carousel .upk-title' => 'margin-bottom: {{SIZE}}{{UNIT}};',
581 ],
582 ]
583 );
584
585 $this->add_group_control(
586 Group_Control_Typography::get_type(),
587 [
588 'name' => 'title_typography',
589 'label' => esc_html__('Typography', 'ultimate-post-kit'),
590 'selector' => '{{WRAPPER}} .upk-alter-carousel .upk-title a',
591 ]
592 );
593
594 $this->add_control(
595 'title_advanced_style',
596 [
597 'label' => esc_html__('Advanced Style', 'ultimate-post-kit'),
598 'type' => Controls_Manager::SWITCHER,
599 ]
600 );
601
602 $this->add_control(
603 'title_background',
604 [
605 'label' => esc_html__('Background Color', 'ultimate-post-kit'),
606 'type' => Controls_Manager::COLOR,
607 'selectors' => [
608 '{{WRAPPER}} .upk-alter-carousel .upk-title a' => 'background-color: {{VALUE}};',
609 ],
610 'condition' => [
611 'title_advanced_style' => 'yes'
612 ]
613 ]
614 );
615
616 $this->add_group_control(
617 Group_Control_Text_Shadow::get_type(),
618 [
619 'name' => 'title_text_shadow',
620 'label' => __('Text Shadow', 'ultimate-post-kit'),
621 'selector' => '{{WRAPPER}} .upk-alter-carousel .upk-title a',
622 'condition' => [
623 'title_advanced_style' => 'yes'
624 ]
625 ]
626 );
627
628 $this->add_group_control(
629 Group_Control_Border::get_type(),
630 [
631 'name' => 'title_border',
632 'selector' => '{{WRAPPER}} .upk-alter-carousel .upk-title a',
633 'condition' => [
634 'title_advanced_style' => 'yes'
635 ]
636 ]
637 );
638
639 $this->add_responsive_control(
640 'title_border_radius',
641 [
642 'label' => __('Border Radius', 'ultimate-post-kit'),
643 'type' => Controls_Manager::DIMENSIONS,
644 'size_units' => ['px', '%'],
645 'selectors' => [
646 '{{WRAPPER}} .upk-alter-carousel .upk-title a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
647 ],
648 'condition' => [
649 'title_advanced_style' => 'yes'
650 ]
651 ]
652 );
653
654 $this->add_group_control(
655 Group_Control_Box_Shadow::get_type(),
656 [
657 'name' => 'title_box_shadow',
658 'selector' => '{{WRAPPER}} .upk-alter-carousel .upk-title a',
659 'condition' => [
660 'title_advanced_style' => 'yes'
661 ]
662 ]
663 );
664
665 $this->add_responsive_control(
666 'title_text_padding',
667 [
668 'label' => __('Padding', 'ultimate-post-kit'),
669 'type' => Controls_Manager::DIMENSIONS,
670 'size_units' => ['px', 'em', '%'],
671 'selectors' => [
672 '{{WRAPPER}} .upk-alter-carousel .upk-title a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
673 ],
674 'condition' => [
675 'title_advanced_style' => 'yes'
676 ]
677 ]
678 );
679
680 $this->end_controls_section();
681
682 $this->start_controls_section(
683 'section_style_text',
684 [
685 'label' => esc_html__('Text', 'ultimate-post-kit'),
686 'tab' => Controls_Manager::TAB_STYLE,
687 'condition' => [
688 'show_excerpt' => 'yes',
689 ],
690 ]
691 );
692
693 $this->add_control(
694 'text_color',
695 [
696 'label' => esc_html__('Color', 'ultimate-post-kit'),
697 'type' => Controls_Manager::COLOR,
698 'selectors' => [
699 '{{WRAPPER}} .upk-alter-carousel .upk-text' => 'color: {{VALUE}};',
700 ],
701 ]
702 );
703
704 $this->add_group_control(
705 Group_Control_Typography::get_type(),
706 [
707 'name' => 'text_typography',
708 'label' => esc_html__('Typography', 'ultimate-post-kit'),
709 'selector' => '{{WRAPPER}} .upk-alter-carousel .upk-text',
710 ]
711 );
712
713 $this->add_responsive_control(
714 'text_margin',
715 [
716 'label' => __('Margin', 'ultimate-post-kit'),
717 'type' => Controls_Manager::DIMENSIONS,
718 'size_units' => ['px', 'em', '%'],
719 'selectors' => [
720 '{{WRAPPER}} .upk-alter-carousel .upk-text' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
721 ]
722 ]
723 );
724
725 $this->end_controls_section();
726
727 $this->start_controls_section(
728 'section_style_author',
729 [
730 'label' => esc_html__('Meta', 'ultimate-post-kit'),
731 'tab' => Controls_Manager::TAB_STYLE,
732 'conditions' => [
733 'relation' => 'or',
734 'terms' => [
735 [
736 'name' => 'show_author',
737 'value' => 'yes'
738 ],
739 [
740 'name' => 'show_date',
741 'value' => 'yes'
742 ]
743 ]
744 ],
745 ]
746 );
747
748 $this->add_control(
749 'author_color',
750 [
751 'label' => esc_html__('Color', 'ultimate-post-kit'),
752 'type' => Controls_Manager::COLOR,
753 'selectors' => [
754 '{{WRAPPER}} .upk-alter-carousel .upk-meta .upk-blog-author a, {{WRAPPER}} .upk-alter-carousel .upk-meta' => 'color: {{VALUE}};',
755 ],
756 ]
757 );
758
759 $this->add_control(
760 'author_hover_color',
761 [
762 'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
763 'type' => Controls_Manager::COLOR,
764 'selectors' => [
765 '{{WRAPPER}} .upk-alter-carousel .upk-meta .upk-blog-author a:hover' => 'color: {{VALUE}};',
766 ],
767 ]
768 );
769
770 $this->add_responsive_control(
771 'meta_spacing',
772 [
773 'label' => esc_html__('Space Between', 'ultimate-post-kit'),
774 'type' => Controls_Manager::SLIDER,
775 'range' => [
776 'px' => [
777 'min' => 0,
778 'max' => 50,
779 ],
780 ],
781 'selectors' => [
782 '{{WRAPPER}} .upk-alter-carousel .upk-meta > div:before' => 'margin: 0 {{SIZE}}{{UNIT}};',
783 ],
784 ]
785 );
786
787 $this->add_group_control(
788 Group_Control_Typography::get_type(),
789 [
790 'name' => 'author_typography',
791 'label' => esc_html__('Typography', 'ultimate-post-kit'),
792 'selector' => '{{WRAPPER}} .upk-alter-carousel .upk-meta',
793 ]
794 );
795
796 $this->end_controls_section();
797
798 $this->start_controls_section(
799 'section_style_category',
800 [
801 'label' => esc_html__('Category', 'ultimate-post-kit'),
802 'tab' => Controls_Manager::TAB_STYLE,
803 'condition' => [
804 'show_category' => 'yes',
805 ],
806 ]
807 );
808
809 $this->add_responsive_control(
810 'category_spacing',
811 [
812 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
813 'type' => Controls_Manager::SLIDER,
814 'range' => [
815 'px' => [
816 'min' => 0,
817 'max' => 50,
818 ],
819 ],
820 'selectors' => [
821 '{{WRAPPER}} .upk-alter-carousel .upk-category' => 'margin-bottom: {{SIZE}}{{UNIT}};',
822 ],
823 ]
824 );
825
826 $this->start_controls_tabs('tabs_category_style');
827
828 $this->start_controls_tab(
829 'tab_category_normal',
830 [
831 'label' => esc_html__('Normal', 'ultimate-post-kit'),
832 ]
833 );
834
835 $this->add_control(
836 'category_color',
837 [
838 'label' => esc_html__('Color', 'ultimate-post-kit'),
839 'type' => Controls_Manager::COLOR,
840 'selectors' => [
841 '{{WRAPPER}} .upk-alter-carousel .upk-category a' => 'color: {{VALUE}};',
842 ],
843 ]
844 );
845
846 $this->add_group_control(
847 Group_Control_Background::get_type(),
848 [
849 'name' => 'category_background',
850 'selector' => '{{WRAPPER}} .upk-alter-carousel .upk-category a',
851 ]
852 );
853
854 $this->add_group_control(
855 Group_Control_Border::get_type(),
856 [
857 'name' => 'category_border',
858 'selector' => '{{WRAPPER}} .upk-alter-carousel .upk-category a',
859 ]
860 );
861
862 $this->add_responsive_control(
863 'category_border_radius',
864 [
865 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
866 'type' => Controls_Manager::DIMENSIONS,
867 'size_units' => ['px', '%'],
868 'selectors' => [
869 '{{WRAPPER}} .upk-alter-carousel .upk-category a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
870 ],
871 ]
872 );
873
874 $this->add_responsive_control(
875 'category_padding',
876 [
877 'label' => esc_html__('Padding', 'ultimate-post-kit'),
878 'type' => Controls_Manager::DIMENSIONS,
879 'size_units' => ['px', 'em', '%'],
880 'selectors' => [
881 '{{WRAPPER}} .upk-alter-carousel .upk-category a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
882 ],
883 ]
884 );
885
886 $this->add_responsive_control(
887 'category_margin',
888 [
889 'label' => esc_html__('Margin', 'ultimate-post-kit'),
890 'type' => Controls_Manager::DIMENSIONS,
891 'size_units' => ['px', 'em', '%'],
892 'selectors' => [
893 '{{WRAPPER}} .upk-alter-carousel .upk-category' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
894 ],
895 ]
896 );
897
898 $this->add_responsive_control(
899 'category_spacing_between',
900 [
901 'label' => esc_html__('Space Between', 'ultimate-post-kit'),
902 'type' => Controls_Manager::SLIDER,
903 'range' => [
904 'px' => [
905 'min' => 0,
906 'max' => 50,
907 ],
908 ],
909 'selectors' => [
910 '{{WRAPPER}} .upk-alter-carousel .upk-category a+a' => 'margin-left: {{SIZE}}{{UNIT}};',
911 ],
912 ]
913 );
914
915
916 $this->add_group_control(
917 Group_Control_Box_Shadow::get_type(),
918 [
919 'name' => 'category_shadow',
920 'selector' => '{{WRAPPER}} .upk-alter-carousel .upk-category a',
921 ]
922 );
923
924 $this->add_group_control(
925 Group_Control_Typography::get_type(),
926 [
927 'name' => 'category_typography',
928 'label' => esc_html__('Typography', 'ultimate-post-kit'),
929 'selector' => '{{WRAPPER}} .upk-alter-carousel .upk-category a',
930 ]
931 );
932
933 $this->end_controls_tab();
934
935 $this->start_controls_tab(
936 'tab_category_hover',
937 [
938 'label' => esc_html__('Hover', 'ultimate-post-kit'),
939 ]
940 );
941
942 $this->add_control(
943 'category_hover_color',
944 [
945 'label' => esc_html__('Color', 'ultimate-post-kit'),
946 'type' => Controls_Manager::COLOR,
947 'selectors' => [
948 '{{WRAPPER}} .upk-alter-carousel .upk-category a:hover' => 'color: {{VALUE}};',
949 ],
950 ]
951 );
952
953 $this->add_group_control(
954 Group_Control_Background::get_type(),
955 [
956 'name' => 'category_hover_background',
957 'selector' => '{{WRAPPER}} .upk-alter-carousel .upk-category a:hover',
958 ]
959 );
960
961 $this->add_control(
962 'category_hover_border_color',
963 [
964 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
965 'type' => Controls_Manager::COLOR,
966 'condition' => [
967 'category_border_border!' => '',
968 ],
969 'selectors' => [
970 '{{WRAPPER}} .upk-alter-carousel .upk-category a:hover' => 'border-color: {{VALUE}};',
971 ],
972 ]
973 );
974
975 $this->end_controls_tab();
976
977 $this->end_controls_tabs();
978
979 $this->end_controls_section();
980
981 $this->start_controls_section(
982 'section_style_post_format',
983 [
984 'label' => esc_html__('Post Format', 'ultimate-post-kit') . BDTUPK_NC,
985 'tab' => Controls_Manager::TAB_STYLE,
986 'condition' => [
987 'show_post_format' => 'yes',
988 ],
989 ]
990 );
991
992 $this->start_controls_tabs('tabs_post_format_style');
993
994 $this->start_controls_tab(
995 'tab_post_format_normal',
996 [
997 'label' => esc_html__('Normal', 'ultimate-post-kit'),
998 ]
999 );
1000
1001 $this->add_control(
1002 'post_format_color',
1003 [
1004 'label' => esc_html__('Color', 'ultimate-post-kit'),
1005 'type' => Controls_Manager::COLOR,
1006 'selectors' => [
1007 '{{WRAPPER}} .upk-alter-carousel .upk-post-format a' => 'color: {{VALUE}};',
1008 ],
1009 ]
1010 );
1011
1012 $this->add_group_control(
1013 Group_Control_Background::get_type(),
1014 [
1015 'name' => 'post_format_background',
1016 'selector' => '{{WRAPPER}} .upk-alter-carousel .upk-post-format a',
1017 ]
1018 );
1019
1020 $this->add_group_control(
1021 Group_Control_Border::get_type(),
1022 [
1023 'name' => 'post_format_border',
1024 'selector' => '{{WRAPPER}} .upk-alter-carousel .upk-post-format a',
1025 ]
1026 );
1027
1028 $this->add_responsive_control(
1029 'post_format_border_radius',
1030 [
1031 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
1032 'type' => Controls_Manager::DIMENSIONS,
1033 'size_units' => ['px', '%'],
1034 'selectors' => [
1035 '{{WRAPPER}} .upk-alter-carousel .upk-post-format a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1036 ],
1037 ]
1038 );
1039
1040 $this->add_responsive_control(
1041 'post_format_padding',
1042 [
1043 'label' => esc_html__('Padding', 'ultimate-post-kit'),
1044 'type' => Controls_Manager::DIMENSIONS,
1045 'size_units' => ['px', 'em', '%'],
1046 'selectors' => [
1047 '{{WRAPPER}} .upk-alter-carousel .upk-post-format a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1048 ],
1049 ]
1050 );
1051
1052 $this->add_responsive_control(
1053 'post_format_margin',
1054 [
1055 'label' => esc_html__('Margin', 'ultimate-post-kit'),
1056 'type' => Controls_Manager::DIMENSIONS,
1057 'size_units' => ['px', 'em', '%'],
1058 'selectors' => [
1059 '{{WRAPPER}} .upk-alter-carousel .upk-post-format a' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1060 ],
1061 ]
1062 );
1063
1064 $this->add_group_control(
1065 Group_Control_Box_Shadow::get_type(),
1066 [
1067 'name' => 'post_format_shadow',
1068 'selector' => '{{WRAPPER}} .upk-alter-carousel .upk-post-format a',
1069 ]
1070 );
1071
1072 $this->add_group_control(
1073 Group_Control_Typography::get_type(),
1074 [
1075 'name' => 'post_format_typography',
1076 'label' => esc_html__('Typography', 'ultimate-post-kit'),
1077 'selector' => '{{WRAPPER}} .upk-alter-carousel .upk-post-format a',
1078 ]
1079 );
1080
1081 $this->end_controls_tab();
1082
1083 $this->start_controls_tab(
1084 'tab_post_format_hover',
1085 [
1086 'label' => esc_html__('Hover', 'ultimate-post-kit'),
1087 ]
1088 );
1089
1090 $this->add_control(
1091 'post_format_hover_color',
1092 [
1093 'label' => esc_html__('Color', 'ultimate-post-kit'),
1094 'type' => Controls_Manager::COLOR,
1095 'selectors' => [
1096 '{{WRAPPER}} .upk-alter-carousel .upk-post-format a:hover' => 'color: {{VALUE}};',
1097 ],
1098 ]
1099 );
1100
1101 $this->add_group_control(
1102 Group_Control_Background::get_type(),
1103 [
1104 'name' => 'post_format_hover_background',
1105 'selector' => '{{WRAPPER}} .upk-alter-carousel .upk-post-format a:hover',
1106 ]
1107 );
1108
1109 $this->add_control(
1110 'post_format_hover_border_color',
1111 [
1112 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
1113 'type' => Controls_Manager::COLOR,
1114 'condition' => [
1115 'post_format_border_border!' => '',
1116 ],
1117 'selectors' => [
1118 '{{WRAPPER}} .upk-alter-carousel .upk-post-format a:hover' => 'border-color: {{VALUE}};',
1119 ],
1120 ]
1121 );
1122
1123 $this->end_controls_tab();
1124
1125 $this->end_controls_tabs();
1126
1127 $this->end_controls_section();
1128
1129 //Navigation Global Controls
1130 $this->register_navigation_style('swiper');
1131 }
1132
1133 /**
1134 * Main query render for this widget
1135 * @param $posts_per_page number item query limit
1136 */
1137 public function query_posts($posts_per_page)
1138 {
1139
1140 $default = $this->getGroupControlQueryArgs();
1141 if ($posts_per_page) {
1142 $args['posts_per_page'] = $posts_per_page;
1143 // $args['paged'] = max(1, get_query_var('paged'), get_query_var('page'));
1144 }
1145 $args = array_merge($default, $args);
1146 $this->_query = new WP_Query($args);
1147 }
1148
1149 public function render_header()
1150 {
1151 //Global Function
1152 $this->render_header_attribute('alter');
1153
1154 ?>
1155 <div <?php $this->print_render_attribute_string('carousel'); ?>>
1156 <div class="upk-post-grid">
1157 <div <?php echo $this->get_render_attribute_string('swiper'); ?>>
1158 <div class="swiper-wrapper">
1159 <?php
1160 }
1161
1162 public function render_post_grid_item($post_id, $image_size, $excerpt_length)
1163 {
1164 $settings = $this->get_settings_for_display();
1165
1166 if ('yes' == $settings['global_link']) {
1167
1168 $this->add_render_attribute('grid-item', 'onclick', "window.open('" . esc_url(get_permalink()) . "', '_self')", true);
1169 }
1170 $this->add_render_attribute('grid-item', 'class', 'upk-item swiper-slide', true);
1171
1172 ?>
1173 <div <?php $this->print_render_attribute_string('grid-item'); ?>>
1174 <div class="upk-item-box">
1175 <div class="upk-img-wrap">
1176 <div class="upk-main-img">
1177 <?php $this->render_image(get_post_thumbnail_id($post_id), $image_size); ?>
1178 <?php
1179 if (_is_upk_pro_activated()) {
1180 if ($settings['readmore_type'] == 'on_image') {
1181 apply_filters('alter_render_readmore_on_image', '');
1182 }
1183 }
1184 ?>
1185 <?php $this->render_post_format(); ?>
1186 </div>
1187 </div>
1188
1189 <div class="upk-content">
1190 <div>
1191 <?php $this->render_category(); ?>
1192 <?php $this->render_title(substr($this->get_name(), 4)); ?>
1193
1194 <div class="upk-text-wrap">
1195 <?php $this->render_excerpt($excerpt_length); ?>
1196 <?php
1197 if (_is_upk_pro_activated()) {
1198 if ($settings['readmore_type'] == 'classic') {
1199 apply_filters('alter_render_readmore', $this);
1200 }
1201 }
1202 ?>
1203 </div>
1204
1205 <?php if ($settings['show_author'] or $settings['show_date'] or $settings['show_reading_time']) : ?>
1206 <div class="upk-meta">
1207 <?php if ($settings['show_author']) : ?>
1208 <div class="upk-blog-author" data-separator="<?php echo esc_html($settings['meta_separator']); ?>">
1209 <a class="author-name" href="<?php echo esc_url( get_author_posts_url(get_the_author_meta('ID')) ); ?>">
1210 <?php echo esc_html( get_the_author() ) ?>
1211 </a>
1212 </div>
1213 <?php endif; ?>
1214
1215 <?php if ('yes' === $settings['show_date']) : ?>
1216 <div data-separator="<?php echo esc_html($settings['meta_separator']); ?>">
1217 <?php $this->render_date(); ?>
1218 </div>
1219 <?php endif; ?>
1220
1221 <?php if (_is_upk_pro_activated()) :
1222 if ('yes' === $settings['show_reading_time']) : ?>
1223 <div class="upk-reading-time" data-separator="<?php echo esc_html($settings['meta_separator']); ?>">
1224 <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'] ) ); ?>
1225 </div>
1226 <?php endif; ?>
1227 <?php endif; ?>
1228 </div>
1229 <?php endif; ?>
1230
1231 </div>
1232 </div>
1233 </div>
1234 </div>
1235 <?php
1236 }
1237
1238 public function render()
1239 {
1240 $settings = $this->get_settings_for_display();
1241
1242 $this->query_posts($settings['item_limit']['size']);
1243 $wp_query = $this->get_query();
1244
1245 if (!$wp_query->found_posts) {
1246 return;
1247 }
1248
1249 $this->render_header();
1250
1251 while ($wp_query->have_posts()) {
1252 $wp_query->the_post();
1253 $thumbnail_size = $settings['primary_thumbnail_size'];
1254
1255 $this->render_post_grid_item(get_the_ID(), $thumbnail_size, $settings['excerpt_length']);
1256 }
1257
1258 $this->render_footer();
1259
1260 wp_reset_postdata();
1261 }
1262 }
1263