PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / 4.5.6
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets v4.5.6
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.5.6, at modules/elite-carousel/widgets/elite-carousel.php

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