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

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

964 lines 27.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace UltimatePostKit\Modules\CategoryCarousel\Widgets;
4
5 use UltimatePostKit\Base\Module_Base;
6 use Elementor\Controls_Manager;
7 use Elementor\Group_Control_Border;
8 use Elementor\Group_Control_Typography;
9 use Elementor\Group_Control_Box_Shadow;
10 use Elementor\Group_Control_Image_Size;
11 use Elementor\Group_Control_Background;
12 use Elementor\Utils;
13 use Elementor\Plugin;
14 use UltimatePostKit\Traits\Global_Widget_Controls;
15 use UltimatePostKit\Traits\Global_Widget_Functions;
16 use UltimatePostKit\Traits\Global_Swiper_Functions;
17
18 if (!defined('ABSPATH')) {
19 exit;
20 } // Exit if accessed directly
21
22 class Category_Carousel extends Module_Base {
23 use Global_Widget_Controls;
24 use Global_Widget_Functions;
25 use Global_Swiper_Functions;
26 private $_query = null;
27
28 public function get_name() {
29 return 'upk-category-carousel';
30 }
31
32 public function get_title() {
33 return BDTUPK . esc_html__('Category Carousel', 'ultimate-post-kit');
34 }
35
36 public function get_icon() {
37 return 'upk-widget-icon upk-icon-category-carousel';
38 }
39
40 public function get_categories() {
41 return ['ultimate-post-kit'];
42 }
43
44 public function get_keywords() {
45 return ['post', 'carousel', 'blog', 'recent', 'news', 'elite'];
46 }
47
48 public function get_style_depends() {
49 if ($this->upk_is_edit_mode()) {
50 return ['swiper', 'upk-all-styles'];
51 } else {
52 return ['swiper', 'upk-font', 'upk-category-carousel'];
53 }
54 }
55
56 public function get_script_depends() {
57 if ($this->upk_is_edit_mode()) {
58 return ['swiper', 'upk-all-scripts'];
59 } else {
60 return ['swiper', 'upk-category-carousel'];
61 }
62 }
63
64 public function get_custom_help_url() {
65 return 'https://youtu.be/kNA3mYIMkLM';
66 }
67
68
69 public function get_query() {
70 return $this->_query;
71 }
72
73 public function has_widget_inner_wrapper(): bool {
74 return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
75 }
76
77
78 protected function register_controls() {
79 $image_settings = ultimate_post_kit_option('category_image', 'ultimate_post_kit_other_settings', 'off');
80 $this->start_controls_section(
81 'section_content_layout',
82 [
83 'label' => esc_html__('Layout', 'ultimate-post-kit'),
84 ]
85 );
86
87 $this->add_control(
88 'skin_layout',
89 [
90 'label' => __('Skin', 'ultimate-post-kit'),
91 'type' => Controls_Manager::SELECT,
92 'default' => 'style-1',
93 'options' => [
94 'style-1' => __('Style 1', 'ultimate-post-kit'),
95 'style-2' => __('Style 2', 'ultimate-post-kit'),
96 'style-3' => __('Style 3', 'ultimate-post-kit'),
97 'style-4' => __('Style 4', 'ultimate-post-kit'),
98 'style-5' => __('Style 5', 'ultimate-post-kit'),
99 // 'style-6' => __('Style 6', 'ultimate-post-kit'),
100 ],
101 ]
102 );
103 $this->add_responsive_control(
104 'columns',
105 [
106 'label' => __('Columns', 'ultimate-post-kit'),
107 'type' => Controls_Manager::SELECT,
108 'default' => 3,
109 'tablet_default' => 2,
110 'mobile_default' => 1,
111 'options' => [
112 1 => '1',
113 2 => '2',
114 3 => '3',
115 4 => '4',
116 5 => '5',
117 6 => '6',
118 ],
119 ]
120 );
121
122 $this->add_responsive_control(
123 'item_gap',
124 [
125 'label' => __('Item Gap', 'ultimate-post-kit'),
126 'type' => Controls_Manager::SLIDER,
127 'default' => [
128 'size' => 20,
129 ],
130 'tablet_default' => [
131 'size' => 20,
132 ],
133 'mobile_default' => [
134 'size' => 20,
135 ],
136 'range' => [
137 'px' => [
138 'min' => 0,
139 'max' => 100,
140 ],
141 ],
142 ]
143 );
144 $this->add_responsive_control(
145 'item_height',
146 [
147 'label' => esc_html__('Item Height(px)', 'ultimate-post-kit'),
148 'type' => Controls_Manager::SLIDER,
149 'range' => [
150 'px' => [
151 'min' => 0,
152 'max' => 1000,
153 ],
154 ],
155 'selectors' => [
156 '{{WRAPPER}} .upk-category-carousel .upk-item' => 'height: {{SIZE}}{{UNIT}};',
157 '{{WRAPPER}} .upk-category-carousel .upk-category-carousel-image' => 'height: {{SIZE}}{{UNIT}};'
158 ],
159 'condition' => [
160 'skin_layout!' => 'style-3'
161 ]
162 ]
163 );
164 $this->add_responsive_control(
165 'item_height_skin_3',
166 [
167 'label' => esc_html__('Item Height(px)', 'ultimate-post-kit'),
168 'type' => Controls_Manager::SLIDER,
169 'range' => [
170 'px' => [
171 'min' => 0,
172 'max' => 1000,
173 ],
174 ],
175 'selectors' => [
176 '{{WRAPPER}} .upk-category-carousel .upk-category-carousel-image' => 'height: {{SIZE}}{{UNIT}};'
177 ],
178 'condition' => [
179 'skin_layout' => 'style-3'
180 ]
181 ]
182 );
183
184 $this->add_group_control(
185 Group_Control_Image_Size::get_type(),
186 [
187 'name' => 'primary_thumbnail',
188 'exclude' => ['custom'],
189 'default' => 'medium',
190 ]
191 );
192
193 $this->end_controls_section();
194 $this->start_controls_section(
195 'section_post_grid_query',
196 [
197 'label' => esc_html__('Query', 'ultimate-post-kit'),
198 ]
199 );
200
201 $this->add_control(
202 'taxonomy',
203 [
204 'label' => esc_html__('Taxonomy', 'ultimate-post-kit'),
205 'type' => Controls_Manager::SELECT,
206 'default' => 'category',
207 'options' => ultimate_post_kit_get_taxonomies(),
208 ]
209 );
210
211 $this->add_control(
212 'orderby',
213 [
214 'label' => esc_html__('Order By', 'ultimate-post-kit'),
215 'type' => Controls_Manager::SELECT,
216 'default' => 'name',
217 'options' => [
218 'name' => esc_html__('Name', 'ultimate-post-kit'),
219 'post_date' => esc_html__('Date', 'ultimate-post-kit'),
220 'post_title' => esc_html__('Title', 'ultimate-post-kit'),
221 'menu_order' => esc_html__('Menu Order', 'ultimate-post-kit'),
222 'rand' => esc_html__('Random', 'ultimate-post-kit'),
223 ],
224 ]
225 );
226
227 $this->add_control(
228 'order',
229 [
230 'label' => esc_html__('Order', 'ultimate-post-kit'),
231 'type' => Controls_Manager::SELECT,
232 'default' => 'asc',
233 'options' => [
234 'asc' => esc_html__('ASC', 'ultimate-post-kit'),
235 'desc' => esc_html__('DESC', 'ultimate-post-kit'),
236 ],
237 ]
238 );
239 // $this->add_control(
240 // 'include',
241 // [
242 // 'label' => esc_html__('Include', 'ultimate-post-kit'),
243 // 'type' => Controls_Manager::TEXT,
244 // 'placeholder' => __('Category ID: 12,3,1', 'ultimate-post-kit'),
245 // ]
246 // );
247 $this->add_control(
248 'exclude',
249 [
250 'label' => esc_html__('Exclude', 'ultimate-post-kit'),
251 'type' => Controls_Manager::TEXT,
252 'placeholder' => __('Category ID: 12,3,1', 'ultimate-post-kit'),
253 ]
254 );
255 $this->add_control(
256 'parent',
257 [
258 'label' => esc_html__('Parent', 'ultimate-post-kit'),
259 'type' => Controls_Manager::TEXT,
260 'placeholder' => __('Category ID: 12', 'ultimate-post-kit'),
261 ]
262 );
263 // $this->add_control(
264 // 'hide_empty',
265 // [
266 // 'label' => esc_html__('Hide Empty', 'ultimate-post-kit'),
267 // 'type' => Controls_Manager::SWITCHER,
268 // ]
269 // );
270
271
272 $this->end_controls_section();
273 $this->start_controls_section(
274 'section_content_additional',
275 [
276 'label' => esc_html__('Additional Options', 'ultimate-post-kit'),
277 ]
278 );
279
280 $this->add_control(
281 'show_image',
282 [
283 'label' => esc_html__('Show Image', 'ultimate-post-kit'),
284 'type' => Controls_Manager::SWITCHER,
285 'default' => 'yes',
286 ]
287 );
288
289 $this->add_control(
290 'show_count',
291 [
292 'label' => esc_html__('Show Count', 'ultimate-post-kit'),
293 'type' => Controls_Manager::SWITCHER,
294 'default' => 'yes',
295 ]
296 );
297 $this->add_control(
298 'show_text',
299 [
300 'label' => esc_html__('Show Text', 'ultimate-post-kit'),
301 'type' => Controls_Manager::SWITCHER,
302 'default' => 'yes',
303 ]
304 );
305 $this->add_control(
306 'count_text_label',
307 [
308 'label' => esc_html__('Count Label', 'ultimate-post-kit'),
309 'type' => Controls_Manager::TEXT,
310 'placeholder' => esc_html__('Posts', 'ultimate-post-kit'),
311 'default' => esc_html__('Posts', 'ultimate-post-kit'),
312 'condition' => [
313 'show_text' => 'yes'
314 ]
315 ]
316 );
317 $this->add_control(
318 'item_match_height',
319 [
320 'label' => __('Item Match Height', 'ultimate-post-kit'),
321 'type' => Controls_Manager::SWITCHER,
322 'default' => 'yes',
323 'prefix_class' => 'upk-item-match-height--',
324 'separator' => 'before'
325 ]
326 );
327
328 $this->end_controls_section();
329
330 //Navigaation Global Controls
331 $this->register_navigation_controls('category');
332
333 //Style
334 $this->start_controls_section(
335 'section_style_item',
336 [
337 'label' => esc_html__('Item', 'ultimate-post-kit'),
338 'tab' => Controls_Manager::TAB_STYLE,
339 ]
340 );
341 $this->start_controls_tabs(
342 'item_tabs'
343 );
344 $this->start_controls_tab(
345 'item_tab_normal',
346 [
347 'label' => esc_html__('Normal', 'ultimate-post-kit'),
348 ]
349 );
350 $this->add_group_control(
351 Group_Control_Background::get_type(),
352 [
353 'name' => 'items_background',
354 'label' => esc_html__('Backgrund', 'ultimate-post-kit'),
355 'types' => ['classic', 'gradient'],
356 'selector' => '{{WRAPPER}} .upk-category-carousel .upk-category-carousel-image',
357 ]
358 );
359 $this->add_control(
360 'item_overlay',
361 [
362 'label' => esc_html__('Overlay Color', 'ultimate-post-kit'),
363 'type' => Controls_Manager::COLOR,
364 'selectors' => [
365 '{{WRAPPER}} .upk-category-carousel .upk-item-overlay' => 'background: {{VALUE}}',
366 ],
367 'condition' => [
368 'skin_layout!' => ['style-3']
369 ]
370 ]
371 );
372 $this->add_control(
373 'item_overlay_blur_effect',
374 [
375 'label' => esc_html__('Glassmorphism', 'ultimate-post-kit'),
376 'type' => Controls_Manager::SWITCHER,
377 // translators: %1s: Opening anchor tag with link to MDN backdrop-filter documentation, %2s: Closing anchor tag
378 'description' => sprintf(__('This feature will not work in the Firefox browser untill you enable browser compatibility so please %1s look here %2s', 'ultimate-post-kit'), '<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility" target="_blank">', '</a>'),
379 'default' => 'yes',
380 'condition' => [
381 'skin_layout' => [
382 'style-5',
383 ]
384 ]
385 ]
386 );
387
388 $this->add_control(
389 'item_overlay_blur_level',
390 [
391 'label' => __('Blur Level', 'ultimate-post-kit'),
392 'type' => Controls_Manager::SLIDER,
393 'range' => [
394 'px' => [
395 'min' => 0,
396 'step' => 1,
397 'max' => 50,
398 ]
399 ],
400 'default' => [
401 'size' => 10
402 ],
403 'selectors' => [
404 '{{WRAPPER}} .upk-category-carousel.style-5 .upk-category-carousel-image:before' => 'backdrop-filter: blur({{SIZE}}px); -webkit-backdrop-filter: blur({{SIZE}}px);'
405 ],
406 'condition' => [
407 'item_overlay_blur_effect' => 'yes',
408 'skin_layout' => [
409 'style-5'
410 ]
411 ]
412 ]
413 );
414
415 $this->add_group_control(
416 Group_Control_Background::get_type(),
417 [
418 'name' => 'item_background',
419 'selector' => '{{WRAPPER}} .upk-category-carousel.style-5 .upk-category-carousel-image:before',
420 'condition' => [
421 'skin_layout' => [
422 'style-5'
423 ]
424 ]
425 ]
426 );
427 $this->add_responsive_control(
428 'item_padding',
429 [
430 'label' => esc_html__('Padding', 'ultimate-post-kit'),
431 'type' => Controls_Manager::DIMENSIONS,
432 'size_units' => ['px', '%', 'em'],
433 'selectors' => [
434 '{{WRAPPER}} .upk-category-carousel .upk-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
435 ],
436 ]
437 );
438 $this->add_responsive_control(
439 'item_margin',
440 [
441 'label' => esc_html__('Margin', 'ultimate-post-kit'),
442 'type' => Controls_Manager::DIMENSIONS,
443 'size_units' => ['px', '%', 'em'],
444 'selectors' => [
445 '{{WRAPPER}} .upk-category-carousel .upk-item' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
446 ],
447 ]
448 );
449 $this->add_group_control(
450 Group_Control_Border::get_type(),
451 [
452 'name' => 'item_border',
453 'label' => esc_html__('Border', 'ultimate-post-kit'),
454 'selector' => '{{WRAPPER}} .upk-category-carousel .upk-item',
455 ]
456 );
457 $this->add_responsive_control(
458 'item_radius',
459 [
460 'label' => esc_html__('Radius', 'ultimate-post-kit'),
461 'type' => Controls_Manager::DIMENSIONS,
462 'size_units' => ['px', '%', 'em'],
463 'selectors' => [
464 '{{WRAPPER}} .upk-category-carousel .upk-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
465 ],
466 ]
467 );
468
469 // $this->add_group_control(
470 // Group_Control_Box_Shadow::get_type(),
471 // [
472 // 'name' => 'item_shadow',
473 // 'selector' => '{{WRAPPER}} .upk-category-carousel .upk-item',
474 // ]
475 // );
476 $this->end_controls_tab();
477 $this->start_controls_tab(
478 'item_tab_hover',
479 [
480 'label' => esc_html__('Hover', 'ultimate-post-kit'),
481 ]
482 );
483 $this->add_group_control(
484 Group_Control_Background::get_type(),
485 [
486 'name' => 'items_hover_background',
487 'label' => esc_html__('Backgrund', 'ultimate-post-kit'),
488 'types' => ['classic', 'gradient'],
489 'selector' => '{{WRAPPER}} .upk-category-carousel .upk-item:hover .upk-category-carousel-image',
490 'condition' => [
491 'skin_layout!' => 'style-5'
492 ]
493 ]
494 );
495 $this->add_control(
496 'item_overlay_hover',
497 [
498 'label' => esc_html__('Overlay Color', 'ultimate-post-kit'),
499 'type' => Controls_Manager::COLOR,
500 'selectors' => [
501 '{{WRAPPER}} .upk-category-carousel .upk-item:hover .upk-item-overlay' => 'background: {{VALUE}}',
502 ],
503 'condition' => [
504 'skin_layout!' => ['style-3']
505 ]
506 ]
507 );
508 $this->add_control(
509 'item_hover_border_color',
510 [
511 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
512 'type' => Controls_Manager::COLOR,
513 'selectors' => [
514 '{{WRAPPER}} .upk-category-carousel .upk-item:hover' => 'border-color: {{VALUE}}',
515 ],
516 ]
517 );
518 $this->end_controls_tab();
519 $this->end_controls_tabs();
520 $this->end_controls_section();
521
522 $this->start_controls_section(
523 'section_style_content',
524 [
525 'label' => esc_html__('Content', 'ultimate-post-kit'),
526 'tab' => Controls_Manager::TAB_STYLE,
527 'condition' => [
528 'skin_layout' => [
529 'style-1'
530 ]
531 ]
532 ]
533 );
534 $this->start_controls_tabs(
535 'content_tabs'
536 );
537 $this->start_controls_tab(
538 'content_tab_normal',
539 [
540 'label' => esc_html__('Normal', 'ultimate-post-kit'),
541 ]
542 );
543
544 $this->add_group_control(
545 Group_Control_Background::get_type(),
546 [
547 'name' => 'content_background',
548 'selector' => '{{WRAPPER}} .upk-category-carousel .upk-item .upk-content',
549 'condition' => [
550 'skin_layout' => 'style-1'
551 ]
552 ]
553 );
554
555 $this->add_responsive_control(
556 'content_padding',
557 [
558 'label' => esc_html__('Padding', 'ultimate-post-kit'),
559 'type' => Controls_Manager::DIMENSIONS,
560 'size_units' => ['px', '%', 'em'],
561 'selectors' => [
562 '{{WRAPPER}} .upk-category-carousel .upk-item .upk-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
563 ],
564 ]
565 );
566 $this->add_responsive_control(
567 'content_margin',
568 [
569 'label' => esc_html__('Margin', 'ultimate-post-kit'),
570 'type' => Controls_Manager::DIMENSIONS,
571 'size_units' => ['px', '%', 'em'],
572 'selectors' => [
573 '{{WRAPPER}} .upk-category-carousel .upk-item .upk-content' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
574 ],
575 ]
576 );
577 $this->add_group_control(
578 Group_Control_Border::get_type(),
579 [
580 'name' => 'content_border',
581 'label' => esc_html__('Border', 'ultimate-post-kit'),
582 'selector' => '{{WRAPPER}} .upk-category-carousel .upk-item .upk-content',
583 ]
584 );
585 $this->add_responsive_control(
586 'content_radius',
587 [
588 'label' => esc_html__('Radius', 'ultimate-post-kit'),
589 'type' => Controls_Manager::DIMENSIONS,
590 'size_units' => ['px', '%', 'em'],
591 'selectors' => [
592 '{{WRAPPER}} .upk-category-carousel .upk-item .upk-content' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
593 ],
594 ]
595 );
596
597 $this->add_group_control(
598 Group_Control_Box_Shadow::get_type(),
599 [
600 'name' => 'content_shadow',
601 'selector' => '{{WRAPPER}} .upk-category-carousel .upk-item .upk-content',
602 ]
603 );
604 $this->end_controls_tab();
605 $this->start_controls_tab(
606 'content_tab_hover',
607 [
608 'label' => esc_html__('Hover', 'ultimate-post-kit'),
609 ]
610 );
611 $this->add_control(
612 'content_hover_border_color',
613 [
614 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
615 'type' => Controls_Manager::COLOR,
616 'selectors' => [
617 '{{WRAPPER}} .upk-category-carousel .upk-item:hover .upk-content' => 'border-color: {{VALUE}}',
618 ],
619 ]
620 );
621 $this->add_group_control(
622 Group_Control_Box_Shadow::get_type(),
623 [
624 'name' => 'content_hover_shadow',
625 'selector' => '{{WRAPPER}} .upk-category-carousel .upk-item:hover .upk-content',
626 ]
627 );
628 $this->end_controls_tab();
629 $this->end_controls_tabs();
630 $this->end_controls_section();
631 $this->start_controls_section(
632 'section_style_category',
633 [
634 'label' => esc_html__('Category', 'ultimate-post-kit'),
635 'tab' => Controls_Manager::TAB_STYLE,
636 ]
637 );
638 // $this->add_responsive_control(
639 // 'category_title_spacing',
640 // [
641 // 'label' => esc_html__('Bottom Spacing', 'ultimate-post-kit'),
642 // 'type' => Controls_Manager::SLIDER,
643 // 'size_units' => ['px'],
644 // 'selectors' => [
645 // '{{WRAPPER}} .upk-cateogry-carousel .title' => 'margin-bottom: {{SIZE}}{{UNIT}};',
646 // ],
647 // ]
648 // );
649 $this->start_controls_tabs(
650 'category_tabs'
651 );
652 $this->start_controls_tab(
653 'category_tab_normal',
654 [
655 'label' => esc_html__('Normal', 'ultimate-post-kit'),
656 ]
657 );
658 $this->add_control(
659 'category_color',
660 [
661 'label' => esc_html__('Color', 'ultimate-post-kit'),
662 'type' => Controls_Manager::COLOR,
663 'selectors' => [
664 '{{WRAPPER}} .upk-category-carousel .upk-item .upk-content .title' => 'color: {{VALUE}}',
665 ],
666 ]
667 );
668 $this->add_group_control(
669 Group_Control_Background::get_type(),
670 [
671 'name' => 'style_5_category_bg',
672 'label' => esc_html__('Backgorund', 'ultimate-post-kit'),
673 'types' => ['classic', 'gradient'],
674 'selector' => '{{WRAPPER}} .upk-category-carousel .upk-item .upk-content .title',
675 'condition' => [
676 'skin_layout' => [
677 'style-5'
678 ]
679 ]
680 ]
681 );
682 $this->add_group_control(
683 Group_Control_Background::get_type(),
684 [
685 'name' => 'style_6_category_bg',
686 'label' => esc_html__('Background', 'ultimate-post-kit'),
687 'types' => ['classic', 'gradient'],
688 'selector' => '{{WRAPPER}} .upk-category-carousel.style-5 .upk-category-carousel-image:before',
689 'condition' => [
690 'skin_layout' => [
691 'style-6'
692 ]
693 ]
694 ]
695 );
696 $this->add_responsive_control(
697 'category_margin',
698 [
699 'label' => esc_html__('Margin', 'ultimate-post-kit'),
700 'type' => Controls_Manager::DIMENSIONS,
701 'size_units' => ['px', '%'],
702 'selectors' => [
703 '{{WRAPPER}} .upk-category-carousel .upk-item .upk-content .title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
704 ],
705 ]
706 );
707 $this->add_responsive_control(
708 'category_padding',
709 [
710 'label' => esc_html__('Padding', 'ultimate-post-kit'),
711 'type' => Controls_Manager::DIMENSIONS,
712 'size_units' => ['px', '%'],
713 'selectors' => [
714 '{{WRAPPER}} .upk-category-carousel .upk-item .upk-content .title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
715 ],
716 'condition' => [
717 'skin_layout' => [
718 'style-4'
719 ]
720 ]
721 ]
722 );
723
724 $this->add_group_control(
725 Group_Control_Typography::get_type(),
726 [
727 'name' => 'category_typography',
728 'label' => esc_html__('Typography', 'ultimate-post-kit'),
729 'exclude' => ['line_height'],
730 'selector' => '{{WRAPPER}} .upk-category-carousel .upk-item .upk-content .title',
731 ]
732 );
733 $this->end_controls_tab();
734 $this->start_controls_tab(
735 'category_tab_hover',
736 [
737 'label' => esc_html__('Hover', 'ultimate-post-kit'),
738 'condition' => [
739 'skin_layout!' => 'style-5'
740 ]
741 ]
742 );
743 $this->add_control(
744 'hover_category_color',
745 [
746 'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
747 'type' => Controls_Manager::COLOR,
748 'selectors' => [
749 '{{WRAPPER}} .upk-category-carousel .upk-item:hover .upk-content .title' => 'color: {{VALUE}};',
750 ],
751 ]
752 );
753 $this->end_controls_tab();
754 $this->end_controls_tabs();
755 $this->end_controls_section();
756 $this->start_controls_section(
757 'section_style_count',
758 [
759 'label' => esc_html__('Count', 'ultimate-post-kit'),
760 'tab' => Controls_Manager::TAB_STYLE,
761 ]
762 );
763 $this->start_controls_tabs(
764 'count_tabs'
765 );
766 $this->start_controls_tab(
767 'count_tab_normal',
768 [
769 'label' => esc_html__('Normal', 'ultimate-post-kit'),
770 'condition' => [
771 'skin_layout!' => [
772 'style-5'
773 ]
774 ]
775 ]
776 );
777 $this->add_control(
778 'count_color',
779 [
780 'label' => esc_html__('Color', 'ultimate-post-kit'),
781 'type' => Controls_Manager::COLOR,
782 'selectors' => [
783 '{{WRAPPER}} .upk-category-carousel .upk-item .upk-content .upk-category-count > *' => 'color: {{VALUE}};',
784 ],
785 ]
786 );
787 $this->add_group_control(
788 Group_Control_Background::get_type(),
789 [
790 'name' => 'count_background',
791 'label' => esc_html__('Background', 'ultimate-post-kit'),
792 'types' => ['classic', 'gradient'],
793 'selector' => '{{WRAPPER}} .upk-category-carousel .upk-item .upk-content .upk-category-count > *',
794 'condition' => [
795 'skin_layout' => [
796 'style-2'
797 ]
798 ]
799 ]
800 );
801 $this->add_responsive_control(
802 'count_number_size',
803 [
804 'label' => esc_html__('Size', 'ultimate-post-kit'),
805 'type' => Controls_Manager::SLIDER,
806 'size_units' => ['px'],
807 'default' => [
808 'unit' => 'px',
809 'size' => 30,
810 ],
811 'selectors' => [
812 '{{WRAPPER}} .upk-category-carousel .upk-item .upk-content .upk-category-count > *' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}}; line-height: {{SIZE}}{{UNIT}};',
813 ],
814 'condition' => [
815 'skin_layout' => [
816 'style-2'
817 ]
818 ]
819 ]
820 );
821 // $this->add_responsive_control(
822 // 'count_padding',
823 // [
824 // 'label' => __('Padding', 'ultimate-post-kit'),
825 // 'type' => Controls_Manager::DIMENSIONS,
826 // 'size_units' => ['px', 'em', '%'],
827 // 'selectors' => [
828 // '{{WRAPPER}} .upk-category-carousel .upk-item .upk-content .upk-category-count > *' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
829 // ],
830 // ]
831 // );
832 $this->add_group_control(
833 Group_Control_Typography::get_type(),
834 [
835 'name' => 'count_typography',
836 'label' => esc_html__('Typography', 'ultimate-post-kit'),
837 'selector' => '{{WRAPPER}} .upk-category-carousel .upk-item .upk-content .upk-category-count > *',
838 ]
839 );
840 $this->end_controls_tab();
841 $this->start_controls_tab(
842 'count_tab_hover',
843 [
844 'label' => esc_html__('Hover', 'ultimate-post-kit'),
845 ]
846 );
847 $this->add_control(
848 'count_color_hover',
849 [
850 'label' => esc_html__('Color', 'ultimate-post-kit'),
851 'type' => Controls_Manager::COLOR,
852 'selectors' => [
853 '{{WRAPPER}} .upk-category-carousel .upk-item:hover .upk-content .upk-category-count > *' => 'color: {{VALUE}};',
854 ],
855 ]
856 );
857 $this->add_group_control(
858 Group_Control_Background::get_type(),
859 [
860 'name' => 'count_hover_background',
861 'label' => esc_html__('Background', 'ultimate-post-kit'),
862 'types' => ['classic', 'gradient'],
863 'selector' => '{{WRAPPER}} .upk-category-carousel .upk-item:hover .upk-content .upk-category-count > *',
864 'condition' => [
865 'skin_layout' => [
866 'style-2'
867 ]
868 ]
869 ]
870 );
871 $this->end_controls_tab();
872 $this->end_controls_tabs();
873 $this->end_controls_section();
874 $this->register_navigation_style('swiper');
875 }
876
877 public function get_taxonomies() {
878 $taxonomies = get_taxonomies(['show_in_nav_menus' => true], 'objects');
879
880 $options = ['' => ''];
881
882 foreach ($taxonomies as $taxonomy) {
883 $options[$taxonomy->name] = $taxonomy->label;
884 }
885
886 return $options;
887 }
888
889 public function render_image($image_id, $size) {
890 $placeholder_image_src = Utils::get_placeholder_image_src();
891 $image_src = wp_get_attachment_image_src($image_id, $size);
892 if (!$image_src) {
893 return;
894 } else {
895 $image_src = $image_src[0];
896 }
897
898 ?>
899 <img class="upk-category-carousel-img" src="<?php echo esc_url($image_src); ?>" alt="<?php echo esc_html(get_the_title()); ?>">
900 <?php
901 }
902
903 public function render_header() {
904 $id = 'upk-category-carousel-' . $this->get_id();
905 $settings = $this->get_settings_for_display();
906 $this->add_render_attribute('carousel', 'class', ['upk-category-carousel', $settings['skin_layout']]);
907 $this->render_header_attribute('category');
908
909 $skin_layout = $settings['skin_layout'];
910 $this->add_render_attribute('swiper', 'class', 'swiper-carousel swiper upk-category-carousel-wrap upk-category-carousel-' . $skin_layout );
911 ?>
912 <div <?php $this->print_render_attribute_string('carousel'); ?>>
913 <div class="upk-category-carousel-wrapper">
914 <div <?php $this->print_render_attribute_string('swiper'); ?>>
915 <div class="swiper-wrapper">
916 <?php
917 }
918
919 public function render_carousel_category_item() {
920 $settings = $this->get_settings_for_display();
921 $categories = get_categories(
922 [
923 'taxonomy' => $settings["taxonomy"],
924 'orderby' => $settings["orderby"],
925 'order' => $settings["order"],
926 // 'include' => explode(',', esc_attr($settings["include"])),
927 'exclude' => explode(',', esc_attr($settings["exclude"])),
928 'parent' => $settings["parent"],
929 'hide_empty' => 0,
930 ]
931 );
932 if (!empty($categories)) :
933 foreach ($categories as $item_index => $cat) :
934 $this->add_render_attribute('category-item', 'class', ['swiper-slide', 'upk-item', 'category-link'], true);
935 $this->add_render_attribute('category-item', 'href', get_category_link($cat->cat_ID), true);
936 $category_image_id = get_term_meta($cat->cat_ID, 'upk-category-image-id', true); ?>
937 <a <?php $this->print_render_attribute_string('category-item'); ?>>
938 <div class="upk-category-carousel-image">
939 <?php $this->render_image($category_image_id, $settings['primary_thumbnail_size']); ?>
940 </div>
941 <div class="upk-content">
942 <h3 class="title"><?php echo esc_html($cat->cat_name); ?></h3>
943 <?php if ($settings['show_count'] === 'yes') : ?>
944 <p class="upk-category-count">
945 <?php printf('<span class="upk-count-number">%s</span>', esc_html($cat->category_count));
946 if ($settings['show_text'] === 'yes') :
947 printf('<span class="upk-count-text">%s</span>', esc_html($settings['count_text_label']));
948 endif;
949 endif; ?>
950 </p>
951 </div>
952 <div class="upk-item-overlay"></div>
953 </a>
954 <?php
955 endforeach;
956 endif;
957 }
958 public function render() {
959 $this->render_header();
960 $this->render_carousel_category_item();
961 $this->render_footer();
962 }
963 }
964