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

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

1,413 lines 36.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\RambleCarousel\Widgets;
4
5 use Elementor\Controls_Manager;
6 use Elementor\Group_Control_Border;
7 use Elementor\Group_Control_Box_Shadow;
8 use Elementor\Group_Control_Typography;
9 use Elementor\Group_Control_Text_Shadow;
10 use Elementor\Group_Control_Image_Size;
11 use Elementor\Group_Control_Background;
12 use Elementor\Icons_Manager;
13
14 use UltimatePostKit\Traits\Global_Widget_Controls;
15 use UltimatePostKit\Traits\Global_Widget_Functions;
16 use UltimatePostKit\Traits\Global_Swiper_Functions;
17 use UltimatePostKit\Includes\Controls\GroupQuery\Group_Control_Query;
18 use WP_Query;
19
20 if (!defined('ABSPATH')) exit; // Exit if accessed directly
21
22 class Ramble_Carousel extends Group_Control_Query {
23
24 use Global_Widget_Controls;
25 use Global_Widget_Functions;
26 use Global_Swiper_Functions;
27
28 private $_query = null;
29
30 public function get_name() {
31 return 'upk-ramble-carousel';
32 }
33
34 public function get_title() {
35 return BDTUPK . esc_html__('Ramble Carousel', 'ultimate-post-kit');
36 }
37
38 public function get_icon() {
39 return 'upk-widget-icon upk-icon-ramble-carousel';
40 }
41
42 public function get_categories() {
43 return ['ultimate-post-kit'];
44 }
45
46 public function get_keywords() {
47 return ['post', 'carousel', 'blog', 'recent', 'news', 'ramble'];
48 }
49
50 public function get_style_depends() {
51 if ($this->upk_is_edit_mode()) {
52 return ['swiper', 'upk-all-styles'];
53 } else {
54 return ['swiper', 'upk-font', 'upk-ramble-carousel'];
55 }
56 }
57
58 public function get_script_depends() {
59 if ($this->upk_is_edit_mode()) {
60 return ['swiper', 'upk-all-scripts'];
61 } else {
62 return ['swiper', 'upk-ramble-carousel'];
63 }
64 }
65
66 public function get_custom_help_url() {
67 return 'https://youtu.be/vv10IM0pCHA';
68 }
69
70 public function on_import($element) {
71 if (!get_post_type_object($element['settings']['posts_post_type'])) {
72 $element['settings']['posts_post_type'] = 'post';
73 }
74
75 return $element;
76 }
77
78 public function get_query() {
79 return $this->_query;
80 }
81
82 public function has_widget_inner_wrapper(): bool {
83 return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
84 }
85
86
87 protected function register_controls() {
88 $this->start_controls_section(
89 'section_content_layout',
90 [
91 'label' => esc_html__('Layout', 'ultimate-post-kit'),
92 ]
93 );
94
95 $this->add_responsive_control(
96 'columns',
97 [
98 'label' => __('Columns', 'ultimate-post-kit'),
99 'type' => Controls_Manager::SELECT,
100 'default' => 3,
101 'tablet_default' => 2,
102 'mobile_default' => 1,
103 'options' => [
104 1 => '1',
105 2 => '2',
106 3 => '3',
107 4 => '4',
108 5 => '5',
109 6 => '6',
110 ],
111 ]
112 );
113
114 $this->add_responsive_control(
115 'item_gap',
116 [
117 'label' => __('Item Gap', 'ultimate-post-kit'),
118 'type' => Controls_Manager::SLIDER,
119 'default' => [
120 'size' => 20,
121 ],
122 'tablet_default' => [
123 'size' => 20,
124 ],
125 'mobile_default' => [
126 'size' => 20,
127 ],
128 'range' => [
129 'px' => [
130 'min' => 0,
131 'max' => 100,
132 ],
133 ],
134 ]
135 );
136
137 $this->add_responsive_control(
138 'item_height',
139 [
140 'label' => esc_html__('Item Height(px)', 'ultimate-post-kit'),
141 'type' => Controls_Manager::SLIDER,
142 'range' => [
143 'px' => [
144 'min' => 200,
145 'max' => 600,
146 ],
147 ],
148 'selectors' => [
149 '{{WRAPPER}} .upk-ramble-carousel .upk-item' => 'height: {{SIZE}}{{UNIT}};',
150 ],
151 ]
152 );
153
154 $this->add_group_control(
155 Group_Control_Image_Size::get_type(),
156 [
157 'name' => 'primary_thumbnail',
158 // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour.
159 'exclude' => ['custom'],
160 'default' => 'medium',
161 ]
162 );
163
164 $this->end_controls_section();
165
166 // Query Settings
167 $this->start_controls_section(
168 'section_post_query_builder',
169 [
170 'label' => __('Query', 'ultimate-post-kit'),
171 'tab' => Controls_Manager::TAB_CONTENT,
172 ]
173 );
174
175 $this->add_control(
176 'item_limit',
177 [
178 'label' => esc_html__('Item Limit', 'ultimate-post-kit'),
179 'type' => Controls_Manager::SLIDER,
180 'range' => [
181 'px' => [
182 'min' => 1,
183 'max' => 20,
184 ],
185 ],
186 'default' => [
187 'size' => 6,
188 ],
189 'condition' => [
190 'posts_source!' => 'current_query',
191 ]
192 ]
193 );
194
195 $this->register_query_builder_controls();
196
197 $this->end_controls_section();
198
199 $this->start_controls_section(
200 'section_content_additional',
201 [
202 'label' => esc_html__('Additional Options', 'ultimate-post-kit'),
203 ]
204 );
205
206 //Global Title Controls
207 $this->register_title_controls();
208 $this->register_text_controls();
209
210 $this->add_control(
211 'show_author_avatar',
212 [
213 'label' => esc_html__('Author Avatar', 'ultimate-post-kit'),
214 'type' => Controls_Manager::SWITCHER,
215 'default' => 'yes',
216 ]
217 );
218
219 $this->add_control(
220 'show_author_name',
221 [
222 'label' => esc_html__('Author Name', 'ultimate-post-kit'),
223 'type' => Controls_Manager::SWITCHER,
224 'default' => 'yes',
225 ]
226 );
227
228 //Global Date Controls
229 $this->register_date_controls();
230
231 //Global Reading Time Controls
232 $this->register_reading_time_controls();
233
234 $this->add_control(
235 'meta_separator',
236 [
237 'label' => __('Separator', 'ultimate-post-kit'),
238 'type' => Controls_Manager::TEXT,
239 'default' => '/',
240 'label_block' => false,
241 ]
242 );
243
244 $this->add_control(
245 'show_category',
246 [
247 'label' => esc_html__('Category', 'ultimate-post-kit'),
248 'type' => Controls_Manager::SWITCHER,
249 'default' => 'yes',
250 'separator' => 'before'
251 ]
252 );
253
254 $this->add_control(
255 'show_comments',
256 [
257 'label' => esc_html__('Show Comments', 'ultimate-post-kit'),
258 'type' => Controls_Manager::SWITCHER,
259 'default' => 'yes',
260 ]
261 );
262
263 $this->add_control(
264 'show_readmore',
265 [
266 'label' => esc_html__('Read More', 'ultimate-post-kit'),
267 'type' => Controls_Manager::SWITCHER,
268 'default' => 'yes',
269 'separator' => 'before'
270 ]
271 );
272
273 $this->add_control(
274 'readmore_text',
275 [
276 'label' => esc_html__('Read More Text', 'ultimate-post-kit'),
277 'type' => Controls_Manager::TEXT,
278 'dynamic' => [ 'active' => true ],
279 'default' => esc_html__('Read More', 'ultimate-post-kit'),
280 'placeholder' => esc_html__('Read More', 'ultimate-post-kit'),
281 'condition' => [
282 'show_readmore' => 'yes',
283 ],
284 ]
285 );
286
287 $this->add_control(
288 'readmore_icon',
289 [
290 'label' => esc_html__('Icon', 'ultimate-post-kit'),
291 'type' => Controls_Manager::ICONS,
292 'label_block' => false,
293 'skin' => 'inline',
294 'condition' => [
295 'show_readmore' => 'yes',
296 ]
297 ]
298 );
299
300 $this->add_control(
301 'icon_align',
302 [
303 'label' => esc_html__('Icon Position', 'ultimate-post-kit'),
304 'type' => Controls_Manager::SELECT,
305 'default' => 'right',
306 'options' => [
307 'left' => esc_html__('Left', 'ultimate-post-kit'),
308 'right' => esc_html__('Right', 'ultimate-post-kit'),
309 ],
310 'condition' => [
311 'readmore_icon[value]!' => '',
312 ],
313 ]
314 );
315
316 $this->add_control(
317 'icon_indent',
318 [
319 'label' => esc_html__('Icon Spacing', 'ultimate-post-kit'),
320 'type' => Controls_Manager::SLIDER,
321 'default' => [
322 'size' => 8,
323 ],
324 'range' => [
325 'px' => [
326 'max' => 50,
327 ],
328 ],
329 'condition' => [
330 'readmore_icon[value]!' => '',
331 ],
332 'selectors' => [
333 '{{WRAPPER}} .upk-ramble-carousel .upk-flex-align-right' => is_rtl() ? 'margin-right: {{SIZE}}{{UNIT}};' : 'margin-left: {{SIZE}}{{UNIT}};',
334 '{{WRAPPER}} .upk-ramble-carousel .upk-flex-align-left' => is_rtl() ? 'margin-left: {{SIZE}}{{UNIT}};' : 'margin-right: {{SIZE}}{{UNIT}};',
335 ],
336 ]
337 );
338
339 $this->add_control(
340 'global_link',
341 [
342 'label' => __('Item Wrapper Link', 'ultimate-post-kit'),
343 'type' => Controls_Manager::SWITCHER,
344 'prefix_class' => 'upk-global-link-',
345 'description' => __('Be aware! When Item Wrapper Link activated then title link and read more link will not work', 'ultimate-post-kit'),
346 'separator' => 'before'
347 ]
348 );
349
350 $this->end_controls_section();
351
352 //Navigaiton Global Controls
353 $this->register_navigation_controls('ramble');
354
355 //Style
356 $this->start_controls_section(
357 'upk_section_style',
358 [
359 'label' => esc_html__('Items', 'ultimate-post-kit'),
360 'tab' => Controls_Manager::TAB_STYLE,
361 ]
362 );
363
364 $this->add_responsive_control(
365 'content_padding',
366 [
367 'label' => __('Content Padding', 'ultimate-post-kit'),
368 'type' => Controls_Manager::DIMENSIONS,
369 'size_units' => ['px', 'em', '%'],
370 'selectors' => [
371 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-default-show, {{WRAPPER}} .upk-ramble-carousel .upk-item .upk-default-hide, {{WRAPPER}} .upk-ramble-carousel .upk-item .upk-btn-comments-wrap' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
372 ],
373 ]
374 );
375
376 $this->start_controls_tabs('tabs_item_style');
377
378 $this->start_controls_tab(
379 'tab_item_normal',
380 [
381 'label' => esc_html__('Normal', 'ultimate-post-kit'),
382 ]
383 );
384
385 $this->add_control(
386 'overlay_background',
387 [
388 'label' => esc_html__('Overlay Color', 'ultimate-post-kit'),
389 'type' => Controls_Manager::COLOR,
390 'selectors' => [
391 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-img-wrap:before' => 'background-color: {{VALUE}};'
392 ],
393 ]
394 );
395
396 $this->add_group_control(
397 Group_Control_Border::get_type(),
398 [
399 'name' => 'item_border',
400 'label' => __('Border', 'ultimate-post-kit'),
401 'placeholder' => '1px',
402 'default' => '1px',
403 'selector' => '{{WRAPPER}} .upk-ramble-carousel .upk-item',
404 ]
405 );
406
407 $this->add_responsive_control(
408 'item_border_radius',
409 [
410 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
411 'type' => Controls_Manager::DIMENSIONS,
412 'size_units' => ['px', '%'],
413 'selectors' => [
414 '{{WRAPPER}} .upk-ramble-carousel .upk-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
415 ],
416 ]
417 );
418
419 $this->add_group_control(
420 Group_Control_Box_Shadow::get_type(),
421 [
422 'name' => 'item_box_shadow',
423 'selector' => '{{WRAPPER}} .upk-ramble-carousel .upk-item',
424 ]
425 );
426
427 $this->end_controls_tab();
428
429 $this->start_controls_tab(
430 'tab_item_hover',
431 [
432 'label' => esc_html__('Hover', 'ultimate-post-kit'),
433 ]
434 );
435
436 $this->add_control(
437 'overlay_background_hover',
438 [
439 'label' => esc_html__('Overlay Color', 'ultimate-post-kit'),
440 'type' => Controls_Manager::COLOR,
441 'selectors' => [
442 '{{WRAPPER}} .upk-ramble-carousel .upk-item:hover .upk-img-wrap:before' => 'background-color: {{VALUE}};'
443 ],
444 ]
445 );
446
447 $this->add_control(
448 'item_border_color_hover',
449 [
450 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
451 'type' => Controls_Manager::COLOR,
452 'selectors' => [
453 '{{WRAPPER}} .upk-ramble-carousel .upk-item:hover' => 'border-color: {{VALUE}};'
454 ],
455 'condition' => [
456 'item_border_border!' => ''
457 ]
458 ]
459 );
460
461 $this->add_group_control(
462 Group_Control_Box_Shadow::get_type(),
463 [
464 'name' => 'item_box_shadow_hover',
465 'selector' => '{{WRAPPER}} .upk-ramble-carousel .upk-item:hover',
466 ]
467 );
468
469 $this->add_responsive_control(
470 'item_shadow_padding',
471 [
472 'label' => __('Match Padding', 'ultimate-post-kit'),
473 'description' => __('You have to add padding for matching overlaping normal/hover box shadow when you used Box Shadow option.', 'ultimate-post-kit'),
474 'type' => Controls_Manager::SLIDER,
475 'range' => [
476 'px' => [
477 'min' => 0,
478 'step' => 1,
479 'max' => 50,
480 ]
481 ],
482 'default' => [
483 'size' => 10
484 ],
485 'selectors' => [
486 '{{WRAPPER}} .swiper-carousel' => 'padding: {{SIZE}}{{UNIT}}; margin: 0 -{{SIZE}}{{UNIT}};'
487 ],
488 ]
489 );
490
491 $this->end_controls_tab();
492
493 $this->end_controls_tabs();
494
495 $this->end_controls_section();
496
497 $this->start_controls_section(
498 'section_style_title',
499 [
500 'label' => esc_html__('Title', 'ultimate-post-kit'),
501 'tab' => Controls_Manager::TAB_STYLE,
502 'condition' => [
503 'show_title' => 'yes',
504 ],
505 ]
506 );
507
508 $this->add_control(
509 'title_style',
510 [
511 'type' => Controls_Manager::HIDDEN,
512 ]
513 );
514
515 $this->add_control(
516 'title_color',
517 [
518 'label' => esc_html__('Color', 'ultimate-post-kit'),
519 'type' => Controls_Manager::COLOR,
520 'selectors' => [
521 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-title a' => 'color: {{VALUE}};',
522 ],
523 ]
524 );
525
526 $this->add_group_control(
527 Group_Control_Typography::get_type(),
528 [
529 'name' => 'title_typography',
530 'label' => esc_html__('Typography', 'ultimate-post-kit'),
531 'selector' => '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-title',
532 ]
533 );
534
535 $this->add_control(
536 'title_advanced_style',
537 [
538 'label' => esc_html__('Advanced Style', 'ultimate-post-kit'),
539 'type' => Controls_Manager::SWITCHER,
540 ]
541 );
542
543 $this->add_control(
544 'title_background',
545 [
546 'label' => esc_html__('Background', 'ultimate-post-kit'),
547 'type' => Controls_Manager::COLOR,
548 'selectors' => [
549 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-title' => 'background-color: {{VALUE}};',
550 ],
551 'condition' => [
552 'title_advanced_style' => 'yes'
553 ]
554 ]
555 );
556
557 $this->add_group_control(
558 Group_Control_Text_Shadow::get_type(),
559 [
560 'name' => 'title_text_shadow',
561 'label' => __('Text Shadow', 'ultimate-post-kit'),
562 'selector' => '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-title',
563 'condition' => [
564 'title_advanced_style' => 'yes'
565 ]
566 ]
567 );
568
569 $this->add_group_control(
570 Group_Control_Border::get_type(),
571 [
572 'name' => 'title_border',
573 'selector' => '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-title',
574 'condition' => [
575 'title_advanced_style' => 'yes'
576 ]
577 ]
578 );
579
580 $this->add_responsive_control(
581 'title_border_radius',
582 [
583 'label' => __('Border Radius', 'ultimate-post-kit'),
584 'type' => Controls_Manager::DIMENSIONS,
585 'size_units' => ['px', '%'],
586 'selectors' => [
587 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-title' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
588 ],
589 'condition' => [
590 'title_advanced_style' => 'yes'
591 ]
592 ]
593 );
594
595 $this->add_group_control(
596 Group_Control_Box_Shadow::get_type(),
597 [
598 'name' => 'title_box_shadow',
599 'selector' => '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-title',
600 'condition' => [
601 'title_advanced_style' => 'yes'
602 ]
603 ]
604 );
605
606 $this->add_responsive_control(
607 'title_text_padding',
608 [
609 'label' => __('Padding', 'ultimate-post-kit'),
610 'type' => Controls_Manager::DIMENSIONS,
611 'size_units' => ['px', 'em', '%'],
612 'selectors' => [
613 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
614 ],
615 'condition' => [
616 'title_advanced_style' => 'yes'
617 ]
618 ]
619 );
620
621 $this->add_responsive_control(
622 'title_text_margtin',
623 [
624 'label' => __('Margtin', 'ultimate-post-kit'),
625 'type' => Controls_Manager::DIMENSIONS,
626 'size_units' => ['px', 'em', '%'],
627 'selectors' => [
628 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-title' => 'margtin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
629 ],
630 'condition' => [
631 'title_advanced_style' => 'yes'
632 ]
633 ]
634 );
635
636 $this->end_controls_section();
637
638 $this->start_controls_section(
639 'section_text_style',
640 [
641 'label' => esc_html__('Text', 'ultimate-post-kit'),
642 'tab' => Controls_Manager::TAB_STYLE,
643 'condition' => [
644 'show_excerpt' => 'yes'
645 ],
646 ]
647 );
648
649 $this->add_control(
650 'text_color',
651 [
652 'label' => esc_html__('Color', 'ultimate-post-kit'),
653 'type' => Controls_Manager::COLOR,
654 'selectors' => [
655 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-text' => 'color: {{VALUE}};',
656 ],
657 ]
658 );
659
660 $this->add_group_control(
661 Group_Control_Typography::get_type(),
662 [
663 'name' => 'text_typography',
664 'label' => esc_html__('Typography', 'ultimate-post-kit'),
665 'selector' => '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-text',
666 ]
667 );
668
669 $this->end_controls_section();
670
671 $this->start_controls_section(
672 'section_style_author_date',
673 [
674 'label' => esc_html__('Author/Date', 'ultimate-post-kit'),
675 'tab' => Controls_Manager::TAB_STYLE,
676 'conditions' => [
677 'relation' => 'or',
678 'terms' => [
679 [
680 'name' => 'show_author_avatar',
681 'value' => 'yes'
682 ],
683 [
684 'name' => 'show_author_name',
685 'value' => 'yes'
686 ],
687 [
688 'name' => 'show_date',
689 'value' => 'yes'
690 ]
691 ]
692 ],
693 ]
694 );
695
696 $this->add_control(
697 'author_image_heading',
698 [
699 'label' => esc_html__('Author Avatar', 'ultimate-post-kit'),
700 'type' => Controls_Manager::HEADING,
701 'condition' => [
702 'show_author_avatar' => 'yes'
703 ]
704 ]
705 );
706
707 $this->add_group_control(
708 Group_Control_Border::get_type(),
709 [
710 'name' => 'author_iamge_border',
711 'label' => __('Border', 'ultimate-post-kit'),
712 'placeholder' => '1px',
713 'default' => '1px',
714 'selector' => '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-meta .upk-author-image img',
715 'condition' => [
716 'show_author_avatar' => 'yes'
717 ]
718 ]
719 );
720
721 $this->add_responsive_control(
722 'author_iamge_border_radius',
723 [
724 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
725 'type' => Controls_Manager::DIMENSIONS,
726 'size_units' => ['px', '%'],
727 'selectors' => [
728 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-meta .upk-author-image img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
729 ],
730 'condition' => [
731 'show_author_avatar' => 'yes'
732 ]
733 ]
734 );
735
736 $this->add_responsive_control(
737 'author_iamge_size',
738 [
739 'label' => esc_html__('Size', 'ultimate-post-kit'),
740 'type' => Controls_Manager::SLIDER,
741 'selectors' => [
742 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-meta .upk-author-image img' => 'height: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}};',
743 ],
744 'condition' => [
745 'show_author_avatar' => 'yes'
746 ]
747 ]
748 );
749
750 $this->add_responsive_control(
751 'author_iamge_spacing',
752 [
753 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
754 'type' => Controls_Manager::SLIDER,
755 'selectors' => [
756 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-meta .upk-author-image' => 'margin-right: {{SIZE}}{{UNIT}};',
757 ],
758 'condition' => [
759 'show_author_avatar' => 'yes'
760 ]
761 ]
762 );
763
764 $this->add_control(
765 'author_heading',
766 [
767 'label' => esc_html__('Author Name', 'ultimate-post-kit'),
768 'type' => Controls_Manager::HEADING,
769 'separator' => 'before',
770 'condition' => [
771 'show_author_name' => 'yes'
772 ]
773 ]
774 );
775
776 $this->add_control(
777 'author_color',
778 [
779 'label' => esc_html__('Color', 'ultimate-post-kit'),
780 'type' => Controls_Manager::COLOR,
781 'selectors' => [
782 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-author-name a' => 'color: {{VALUE}};',
783 ],
784 'condition' => [
785 'show_author_name' => 'yes'
786 ]
787 ]
788 );
789
790 $this->add_control(
791 'author_hover_color',
792 [
793 'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
794 'type' => Controls_Manager::COLOR,
795 'selectors' => [
796 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-author-name a:hover' => 'color: {{VALUE}};',
797 ],
798 'condition' => [
799 'show_author_name' => 'yes'
800 ]
801 ]
802 );
803
804 $this->add_group_control(
805 Group_Control_Typography::get_type(),
806 [
807 'name' => 'author_typography',
808 'label' => esc_html__('Typography', 'ultimate-post-kit'),
809 'selector' => '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-author-name a',
810 'condition' => [
811 'show_author_name' => 'yes'
812 ]
813 ]
814 );
815
816 $this->add_control(
817 'date_heading',
818 [
819 'label' => esc_html__('Date/Time', 'ultimate-post-kit'),
820 'type' => Controls_Manager::HEADING,
821 'separator' => 'before',
822 'conditions' => [
823 'relation' => 'or',
824 'terms' => [
825 [
826 'name' => 'show_date',
827 'value' => 'yes'
828 ],
829 [
830 'name' => 'show_reading_time',
831 'value' => 'yes'
832 ]
833 ]
834 ],
835 ]
836 );
837
838 $this->add_control(
839 'date_color',
840 [
841 'label' => esc_html__('Color', 'ultimate-post-kit'),
842 'type' => Controls_Manager::COLOR,
843 'selectors' => [
844 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-default-hide .upk-date, {{WRAPPER}} .upk-ramble-carousel .upk-item .upk-default-hide .upk-post-time, {{WRAPPER}} .upk-ramble-carousel .upk-item .upk-date-reading-time' => 'color: {{VALUE}};',
845 ],
846 'conditions' => [
847 'relation' => 'or',
848 'terms' => [
849 [
850 'name' => 'show_date',
851 'value' => 'yes'
852 ],
853 [
854 'name' => 'show_reading_time',
855 'value' => 'yes'
856 ]
857 ]
858 ],
859 ]
860 );
861
862 $this->add_group_control(
863 Group_Control_Typography::get_type(),
864 [
865 'name' => 'date_typography',
866 'label' => esc_html__('Typography', 'ultimate-post-kit'),
867 'selector' => '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-default-hide .upk-date, {{WRAPPER}} .upk-ramble-carousel .upk-item .upk-default-hide .upk-post-time, {{WRAPPER}} .upk-ramble-carousel .upk-item .upk-date-reading-time',
868 'conditions' => [
869 'relation' => 'or',
870 'terms' => [
871 [
872 'name' => 'show_date',
873 'value' => 'yes'
874 ],
875 [
876 'name' => 'show_reading_time',
877 'value' => 'yes'
878 ]
879 ]
880 ],
881 ]
882 );
883
884 $this->add_responsive_control(
885 'date_spacing',
886 [
887 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
888 'type' => Controls_Manager::SLIDER,
889 'selectors' => [
890 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-default-hide .upk-date' => 'margin-top: {{SIZE}}{{UNIT}};',
891 ],
892 'condition' => [
893 'show_date' => 'yes'
894 ]
895 ]
896 );
897
898 $this->add_responsive_control(
899 'meta_space_between',
900 [
901 'label' => esc_html__('Space Between', 'ultimate-post-kit'),
902 'type' => Controls_Manager::SLIDER,
903 'range' => [
904 'px' => [
905 'min' => 0,
906 'max' => 50,
907 ],
908 ],
909 'selectors' => [
910 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-date-reading-time > div:before' => 'margin: 0 {{SIZE}}{{UNIT}};',
911 ],
912 'conditions' => [
913 'relation' => 'or',
914 'terms' => [
915 [
916 'name' => 'show_date',
917 'value' => 'yes'
918 ],
919 [
920 'name' => 'show_reading_time',
921 'value' => 'yes'
922 ]
923 ]
924 ],
925 ]
926 );
927
928 $this->end_controls_section();
929
930 $this->start_controls_section(
931 'section_style_category',
932 [
933 'label' => esc_html__('Category/Date', 'ultimate-post-kit'),
934 'tab' => Controls_Manager::TAB_STYLE,
935 'conditions' => [
936 'relation' => 'or',
937 'terms' => [
938 [
939 'name' => 'show_category',
940 'value' => 'yes'
941 ],
942 [
943 'name' => 'show_date',
944 'value' => 'yes'
945 ]
946 ]
947 ],
948 ]
949 );
950
951 $this->add_control(
952 'category_date_color',
953 [
954 'label' => esc_html__('Color', 'ultimate-post-kit'),
955 'type' => Controls_Manager::COLOR,
956 'selectors' => [
957 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-date-cetagory-wrap .upk-date, {{WRAPPER}} .upk-ramble-carousel .upk-item .upk-date-cetagory-wrap .upk-category a, {{WRAPPER}} .upk-ramble-carousel .upk-item .upk-date-cetagory-wrap .upk-post-time' => 'color: {{VALUE}};',
958 ],
959 ]
960 );
961
962 $this->add_control(
963 'category_date_divider_color',
964 [
965 'label' => esc_html__('Divider Color', 'ultimate-post-kit'),
966 'type' => Controls_Manager::COLOR,
967 'selectors' => [
968 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-date-cetagory-wrap .upk-category:before' => 'background: {{VALUE}};',
969 ],
970 'condition' => [
971 'show_category' => 'yes'
972 ]
973 ]
974 );
975
976 $this->add_responsive_control(
977 'category_date_spacing',
978 [
979 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
980 'type' => Controls_Manager::SLIDER,
981 'selectors' => [
982 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-date-cetagory-wrap .upk-category' => 'margin-left: {{SIZE}}{{UNIT}}; padding-left: {{SIZE}}{{UNIT}};',
983 ],
984 'condition' => [
985 'show_category' => 'yes'
986 ]
987 ]
988 );
989
990 $this->add_responsive_control(
991 'category_spacing',
992 [
993 'label' => esc_html__('Category Space Beween', 'ultimate-post-kit'),
994 'type' => Controls_Manager::SLIDER,
995 'range' => [
996 'px' => [
997 'min' => 0,
998 'max' => 50,
999 'step' => 2,
1000 ],
1001 ],
1002 'selectors' => [
1003 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-date-cetagory-wrap .upk-category a+a' => 'margin-left: {{SIZE}}{{UNIT}};',
1004 ],
1005 'condition' => [
1006 'show_category' => 'yes'
1007 ]
1008 ]
1009 );
1010
1011 $this->add_group_control(
1012 Group_Control_Typography::get_type(),
1013 [
1014 'name' => 'category_date_typography',
1015 'label' => esc_html__('Typography', 'ultimate-post-kit'),
1016 'selector' => '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-date-cetagory-wrap .upk-date, {{WRAPPER}} .upk-ramble-carousel .upk-item .upk-date-cetagory-wrap .upk-category a, {{WRAPPER}} .upk-ramble-carousel .upk-item .upk-date-cetagory-wrap .upk-post-time',
1017 ]
1018 );
1019
1020 $this->end_controls_section();
1021
1022 $this->start_controls_section(
1023 'section_style_readmore',
1024 [
1025 'label' => __('Read More', 'ultimate-post-kit'),
1026 'tab' => Controls_Manager::TAB_STYLE,
1027 'condition' => [
1028 'show_readmore' => 'yes',
1029 ],
1030 ]
1031 );
1032
1033 $this->start_controls_tabs('tabs_readmore_style');
1034
1035 $this->start_controls_tab(
1036 'tab_readmore_normal',
1037 [
1038 'label' => __('Normal', 'ultimate-post-kit'),
1039 ]
1040 );
1041
1042 $this->add_control(
1043 'readmore_text_color',
1044 [
1045 'label' => __('Color', 'ultimate-post-kit'),
1046 'type' => Controls_Manager::COLOR,
1047 'selectors' => [
1048 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-btn-comments-wrap .upk-readmore' => 'color: {{VALUE}};',
1049 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-btn-comments-wrap .upk-readmore svg *' => 'fill: {{VALUE}};',
1050 ],
1051 ]
1052 );
1053
1054 $this->add_group_control(
1055 Group_Control_Background::get_type(),
1056 [
1057 'name' => 'readmore_background',
1058 'selector' => '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-btn-comments-wrap .upk-readmore',
1059 ]
1060 );
1061
1062 $this->add_group_control(
1063 Group_Control_Border::get_type(),
1064 [
1065 'name' => 'readmore_border',
1066 'placeholder' => '1px',
1067 'default' => '1px',
1068 'selector' => '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-btn-comments-wrap .upk-readmore'
1069 ]
1070 );
1071
1072 $this->add_responsive_control(
1073 'readmore_radius',
1074 [
1075 'label' => __('Border Radius', 'ultimate-post-kit'),
1076 'type' => Controls_Manager::DIMENSIONS,
1077 'size_units' => ['px', '%'],
1078 'selectors' => [
1079 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-btn-comments-wrap .upk-readmore' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1080 ],
1081 ]
1082 );
1083
1084 $this->add_responsive_control(
1085 'readmore_padding',
1086 [
1087 'label' => __('Padding', 'ultimate-post-kit'),
1088 'type' => Controls_Manager::DIMENSIONS,
1089 'size_units' => ['px', 'em', '%'],
1090 'selectors' => [
1091 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-btn-comments-wrap .upk-readmore' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1092 ],
1093 ]
1094 );
1095
1096 $this->add_responsive_control(
1097 'readmore_margin',
1098 [
1099 'label' => __('Margin', 'ultimate-post-kit'),
1100 'type' => Controls_Manager::DIMENSIONS,
1101 'size_units' => ['px', 'em', '%'],
1102 'selectors' => [
1103 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-btn-comments-wrap .upk-readmore' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1104 ],
1105 ]
1106 );
1107
1108 $this->add_group_control(
1109 Group_Control_Box_Shadow::get_type(),
1110 [
1111 'name' => 'readmore_shadow',
1112 'selector' => '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-btn-comments-wrap .upk-readmore',
1113 ]
1114 );
1115
1116 $this->add_group_control(
1117 Group_Control_Typography::get_type(),
1118 [
1119 'name' => 'readmore_typography',
1120 'selector' => '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-btn-comments-wrap .upk-readmore',
1121 ]
1122 );
1123
1124 $this->end_controls_tab();
1125
1126 $this->start_controls_tab(
1127 'tab_readmore_hover',
1128 [
1129 'label' => __('Hover', 'ultimate-post-kit'),
1130 ]
1131 );
1132
1133 $this->add_control(
1134 'readmore_hover_text_color',
1135 [
1136 'label' => __('Color', 'ultimate-post-kit'),
1137 'type' => Controls_Manager::COLOR,
1138 'selectors' => [
1139 '{{WRAPPER}} .upk-ramble-carousel .upk-item:hover .upk-btn-comments-wrap .upk-readmore' => 'color: {{VALUE}};',
1140 '{{WRAPPER}} .upk-ramble-carousel .upk-item:hover .upk-btn-comments-wrap .upk-readmore svg *' => 'fill: {{VALUE}};',
1141 ],
1142 ]
1143 );
1144
1145 $this->add_group_control(
1146 Group_Control_Background::get_type(),
1147 [
1148 'name' => 'readmore_hover_background',
1149 'selector' => '{{WRAPPER}} .upk-ramble-carousel .upk-item:hover .upk-btn-comments-wrap .upk-readmore',
1150 ]
1151 );
1152
1153 $this->add_control(
1154 'readmore_hover_border_color',
1155 [
1156 'label' => __('Border Color', 'ultimate-post-kit'),
1157 'type' => Controls_Manager::COLOR,
1158 'selectors' => [
1159 '{{WRAPPER}} .upk-ramble-carousel .upk-item:hover .upk-btn-comments-wrap .upk-readmore' => 'border-color: {{VALUE}};',
1160 ],
1161 'condition' => [
1162 'readmore_border_border!' => ''
1163 ]
1164 ]
1165 );
1166
1167 $this->add_group_control(
1168 Group_Control_Box_Shadow::get_type(),
1169 [
1170 'name' => 'readmore_hover_shadow',
1171 'selector' => '{{WRAPPER}} .upk-ramble-carousel .upk-item:hover .upk-btn-comments-wrap .upk-readmore',
1172 ]
1173 );
1174
1175 $this->add_control(
1176 'readmore_hover_animation',
1177 [
1178 'label' => __('Hover Animation', 'ultimate-post-kit'),
1179 'type' => Controls_Manager::HOVER_ANIMATION,
1180 ]
1181 );
1182
1183 $this->end_controls_tab();
1184
1185 $this->end_controls_tabs();
1186
1187 $this->end_controls_section();
1188
1189 $this->start_controls_section(
1190 'section_comments_style',
1191 [
1192 'label' => esc_html__('Comments', 'ultimate-post-kit'),
1193 'tab' => Controls_Manager::TAB_STYLE,
1194 'condition' => [
1195 'show_comments' => 'yes'
1196 ],
1197 ]
1198 );
1199
1200 $this->add_control(
1201 'comments_color',
1202 [
1203 'label' => esc_html__('Color', 'ultimate-post-kit'),
1204 'type' => Controls_Manager::COLOR,
1205 'selectors' => [
1206 '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-btn-comments-wrap .upk-comments' => 'color: {{VALUE}};',
1207 ],
1208 ]
1209 );
1210
1211 $this->add_control(
1212 'comments_hover_color',
1213 [
1214 'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
1215 'type' => Controls_Manager::COLOR,
1216 'selectors' => [
1217 '{{WRAPPER}} .upk-ramble-carousel .upk-item:hover .upk-btn-comments-wrap .upk-comments' => 'color: {{VALUE}};',
1218 ],
1219 ]
1220 );
1221
1222 $this->add_group_control(
1223 Group_Control_Typography::get_type(),
1224 [
1225 'name' => 'comments_typography',
1226 'label' => esc_html__('Typography', 'ultimate-post-kit'),
1227 'selector' => '{{WRAPPER}} .upk-ramble-carousel .upk-item .upk-btn-comments-wrap .upk-comments',
1228 ]
1229 );
1230
1231 $this->end_controls_section();
1232
1233 //Navigation Global Controls
1234 $this->register_navigation_style('swiper');
1235 }
1236
1237 /**
1238 * Main query render for this widget
1239 * @param $posts_per_page number item query limit
1240 */
1241 public function query_posts($posts_per_page) {
1242
1243 $default = $this->getGroupControlQueryArgs();
1244 $args = [];
1245 if ($posts_per_page) {
1246 $args['posts_per_page'] = $posts_per_page;
1247 }
1248 $args = array_merge($default, $args);
1249 $this->_query = new WP_Query($args);
1250 }
1251
1252 public function render_post_meta() {
1253 $settings = $this->get_settings_for_display();
1254
1255 if ($settings['show_author_avatar'] or $settings['show_author_name'] or $settings['show_date']) : ?>
1256 <div class="upk-meta">
1257
1258 <?php if ($settings['show_author_avatar']) : ?>
1259 <div class="upk-author-image">
1260 <?php echo get_avatar(get_the_author_meta('ID'), 48); ?>
1261 </div>
1262 <?php endif; ?>
1263
1264 <div class="upk-author-name-date-wrap">
1265
1266 <?php if ($settings['show_author_name']) : ?>
1267 <div class="upk-author-name">
1268 <a href="<?php echo esc_url( get_author_posts_url(get_the_author_meta('ID')) ); ?>"><?php echo esc_html( get_the_author() ); ?></a>
1269 </div>
1270 <?php endif; ?>
1271
1272 <?php if ($settings['show_date'] or $settings['show_reading_time']) : ?>
1273 <div class="upk-date-reading-time upk-flex upk-flex-middle">
1274 <?php if ($settings['show_date'] == 'yes') : ?>
1275 <div data-separator="<?php echo esc_attr($settings['meta_separator']); ?>">
1276 <?php $this->render_date(); ?>
1277 </div>
1278 <?php endif; ?>
1279
1280 <?php if (_is_upk_pro_activated()) :
1281 if ('yes' === $settings['show_reading_time']) : ?>
1282 <div class="upk-reading-time" data-separator="<?php echo esc_attr($settings['meta_separator']); ?>">
1283 <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'], $settings['hide_seconds'] ?? 'no', $settings['hide_minutes'] ?? 'no' ) ); ?>
1284 </div>
1285 <?php endif; ?>
1286 <?php endif; ?>
1287
1288 </div>
1289 <?php endif; ?>
1290
1291 </div>
1292
1293 </div>
1294 <?php endif;
1295 }
1296
1297 public function render_comments($id = 0) {
1298
1299 if (!$this->get_settings('show_comments')) {
1300 return;
1301 }
1302 ?>
1303 <div class="upk-comments">
1304 <?php echo esc_html( $this->upk_get_formatted_comments_count( $id ) ); ?>
1305 </div>
1306 <?php
1307 }
1308
1309 public function render_readmore() {
1310 $settings = $this->get_settings_for_display();
1311
1312 if (!$this->get_settings('show_readmore')) {
1313 return;
1314 }
1315
1316 $animation = ($this->get_settings('readmore_hover_animation')) ? ' elementor-animation-' . $this->get_settings('readmore_hover_animation') : '';
1317
1318 ?>
1319 <a href="<?php echo esc_url(get_permalink()); ?>" class="upk-readmore <?php echo esc_attr($animation); ?>">
1320 <span class="upk-flex upk-flex-middle">
1321 <?php echo esc_html($this->get_settings('readmore_text')); ?>
1322
1323 <?php if ($settings['readmore_icon']['value']) : ?>
1324 <span class="upk-readmore-btn-icon upk-flex-align-<?php echo esc_attr($this->get_settings('icon_align')); ?>">
1325
1326 <?php Icons_Manager::render_icon($settings['readmore_icon'], ['aria-hidden' => 'true', 'class' => 'fa-fw']); ?>
1327
1328 </span>
1329 <?php endif; ?>
1330 </span>
1331 </a>
1332 <?php
1333 }
1334
1335 public function render_header() {
1336 //Global Function
1337 $this->render_header_attribute('ramble');
1338
1339 ?>
1340 <div <?php $this->print_render_attribute_string('carousel'); ?>>
1341 <div class="upk-wrapper">
1342 <div <?php $this->print_render_attribute_string('swiper'); ?>>
1343 <div class="swiper-wrapper">
1344 <?php
1345 }
1346
1347 public function render_post_grid_item($post_id, $image_size, $excerpt_length) {
1348 $settings = $this->get_settings_for_display();
1349
1350 if ('yes' == $settings['global_link']) {
1351
1352 $this->add_render_attribute('grid-item', 'onclick', "window.open('" . esc_url(get_permalink()) . "', '_self')", true);
1353 }
1354 $this->add_render_attribute('grid-item', 'class', 'upk-item swiper-slide upk-transition-toggle', true);
1355
1356 ?>
1357 <div <?php $this->print_render_attribute_string('grid-item'); ?>>
1358 <div class="upk-img-wrap">
1359 <?php $this->render_image(get_post_thumbnail_id($post_id), $image_size); ?>
1360
1361 <div class="upk-content">
1362
1363 <div class="upk-default-show">
1364 <div class="upk-date-cetagory-wrap">
1365 <?php $this->render_date(); ?>
1366 <?php $this->render_category(); ?>
1367 </div>
1368
1369 <?php $this->render_title(substr($this->get_name(), 4)); ?>
1370 </div>
1371
1372 <div class="upk-default-hide">
1373 <?php $this->render_post_meta(); ?>
1374 <?php $this->render_excerpt($excerpt_length); ?>
1375 </div>
1376
1377 </div>
1378 <div class="upk-btn-comments-wrap">
1379 <div class="upk-btn-wrap upk-flex">
1380 <?php $this->render_readmore(); ?>
1381 </div>
1382 <?php $this->render_comments($post_id); ?>
1383 </div>
1384 </div>
1385 </div>
1386 <?php
1387 }
1388
1389 public function render() {
1390 $settings = $this->get_settings_for_display();
1391
1392 $this->query_posts($settings['item_limit']['size']);
1393 $wp_query = $this->get_query();
1394
1395 if (!$wp_query->found_posts) {
1396 return;
1397 }
1398
1399 $this->render_header();
1400
1401 while ($wp_query->have_posts()) {
1402 $wp_query->the_post();
1403 $thumbnail_size = $settings['primary_thumbnail_size'];
1404
1405 $this->render_post_grid_item(get_the_ID(), $thumbnail_size, $settings['excerpt_length']);
1406 }
1407
1408 wp_reset_postdata();
1409
1410 $this->render_footer();
1411 }
1412 }
1413