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 / elite-carousel / widgets / elite-carousel.php

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

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