PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / 4.1.8
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets v4.1.8
4.5.4 4.2.1 4.2.2 4.2.3 4.5.0 4.5.2 4.5.3 4.2.0 4.1.18 4.1.17 4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.0.9 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 All 146 releases
ultimate-post-kit / modules / 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.8, at modules/elite-carousel/widgets/elite-carousel.php

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