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 / featured-list / widgets / featured-list.php

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

1,341 lines 38.0 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\FeaturedList\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\Group_Control_Text_Stroke;
13 use UltimatePostKit\Traits\Global_Widget_Controls;
14 use UltimatePostKit\Traits\Global_Widget_Functions;
15 use UltimatePostKit\Includes\Controls\GroupQuery\Group_Control_Query;
16 use WP_Query;
17
18 if (!defined('ABSPATH')) {
19 exit;
20 } // Exit if accessed directly
21
22 class Featured_List extends Group_Control_Query {
23
24 use Global_Widget_Controls;
25 use Global_Widget_Functions;
26
27 private $_query = null;
28
29 public function get_name() {
30 return 'upk-featured-list';
31 }
32
33 public function get_title() {
34 return BDTUPK . esc_html__('Featured List', 'ultimate-post-kit');
35 }
36
37 public function get_icon() {
38 return 'upk-widget-icon upk-icon-featured-list';
39 }
40
41 public function get_categories() {
42 return ['ultimate-post-kit'];
43 }
44
45 public function get_keywords() {
46 return ['post', 'grid', 'blog', 'recent', 'news', 'featured', 'list'];
47 }
48
49 public function get_style_depends() {
50 if ($this->upk_is_edit_mode()) {
51 return ['upk-all-styles'];
52 } else {
53 return ['upk-font', 'upk-featured-list'];
54 }
55 }
56
57 public function get_script_depends() {
58 if ($this->upk_is_edit_mode()) {
59 return ['upk-all-scripts'];
60 } else {
61 return ['upk-ajax-loadmore'];
62 }
63 }
64
65 public function get_custom_help_url() {
66 return 'https://youtu.be/Q-Pm-6Kkmr4';
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 $this->start_controls_section(
80 'section_content_layout',
81 [
82 'label' => esc_html__('Layout', 'ultimate-post-kit'),
83 ]
84 );
85
86
87 $this->add_control(
88 'layout_style',
89 [
90 'label' => esc_html__('Layout Style', 'ultimate-post-kit'),
91 'type' => Controls_Manager::SELECT,
92 'default' => 'style-1',
93 'options' => [
94 'style-1' => esc_html__('Style 01', 'ultimate-post-kit'),
95 'style-2' => esc_html__('Style 02', 'ultimate-post-kit'),
96 'style-3' => esc_html__('Style 03', 'ultimate-post-kit'),
97 ],
98 ]
99 );
100
101
102 $this->add_responsive_control(
103 'item_image_height',
104 [
105 'label' => esc_html__('Image Height(px)', 'ultimate-post-kit'),
106 'type' => Controls_Manager::SLIDER,
107 'range' => [
108 'px' => [
109 'min' => 200,
110 'max' => 600,
111 ],
112 ],
113 'selectors' => [
114 '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-image-wrap .upk-img' => 'height: {{SIZE}}{{UNIT}};',
115 ],
116 ]
117 );
118
119 $this->add_group_control(
120 Group_Control_Image_Size::get_type(),
121 [
122 'name' => 'primary_thumbnail',
123 // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour.
124 'exclude' => ['custom'],
125 'default' => 'medium',
126 ]
127 );
128
129 $this->add_control(
130 'hr',
131 [
132 'type' => Controls_Manager::DIVIDER,
133 ]
134 );
135
136 //Global Title Controls
137 $this->register_title_controls();
138
139 $this->add_control(
140 'show_category',
141 [
142 'label' => esc_html__('Show Category', 'ultimate-post-kit'),
143 'type' => Controls_Manager::SWITCHER,
144 'default' => 'yes',
145 ]
146 );
147
148 $this->add_control(
149 'show_counter_number',
150 [
151 'label' => esc_html__('Show Counter Number', 'ultimate-post-kit'),
152 'type' => Controls_Manager::SWITCHER,
153 'default' => 'yes',
154 ]
155 );
156
157 $this->add_control(
158 'show_author',
159 [
160 'label' => esc_html__('Show Author', 'ultimate-post-kit'),
161 'type' => Controls_Manager::SWITCHER,
162 'separator' => 'before'
163 ]
164 );
165
166 $this->add_control(
167 'show_comments',
168 [
169 'label' => esc_html__('Show Comments', 'ultimate-post-kit'),
170 'type' => Controls_Manager::SWITCHER,
171 ]
172 );
173
174 $this->add_control(
175 'meta_separator',
176 [
177 'label' => __('Separator', 'ultimate-post-kit'),
178 'type' => Controls_Manager::TEXT,
179 'default' => '//',
180 'label_block' => false,
181 ]
182 );
183
184 //Global Date Controls
185 $this->register_date_controls();
186
187 //Global Reading Time Controls
188 $this->register_reading_time_controls();
189
190 $this->add_control(
191 'show_pagination',
192 [
193 'label' => esc_html__('Show Pagination', 'ultimate-post-kit'),
194 'type' => Controls_Manager::SWITCHER,
195 'separator' => 'before'
196 ]
197 );
198
199 //Global Ajax Controls
200 $this->register_ajax_loadmore_controls();
201
202 $this->add_control(
203 'global_link',
204 [
205 'label' => esc_html__('Item Wrapper Link', 'ultimate-post-kit'),
206 'type' => Controls_Manager::SWITCHER,
207 'prefix_class' => 'upk-global-link-',
208 'description' => esc_html__('Be aware! When Item Wrapper Link activated then title link and read more link will not work', 'ultimate-post-kit'),
209 ]
210 );
211
212 $this->end_controls_section();
213
214 // Query Settings
215 $this->start_controls_section(
216 'section_post_query_builder',
217 [
218 'label' => esc_html__('Query', 'ultimate-post-kit'),
219 'tab' => Controls_Manager::TAB_CONTENT,
220 ]
221 );
222
223 $this->add_control(
224 'item_limit',
225 [
226 'label' => esc_html__('Item Limit', 'ultimate-post-kit'),
227 'type' => Controls_Manager::SLIDER,
228 'range' => [
229 'px' => [
230 'min' => 1,
231 'max' => 20,
232 ],
233 ],
234 'default' => [
235 'size' => 4,
236 ],
237 'condition' => [
238 'posts_source!' => 'current_query',
239 ]
240 ]
241 );
242
243 $this->register_query_builder_controls();
244
245 $this->end_controls_section();
246
247 //Style
248 $this->start_controls_section(
249 'upk_section_style',
250 [
251 'label' => esc_html__('Item', 'ultimate-post-kit'),
252 'tab' => Controls_Manager::TAB_STYLE,
253 ]
254 );
255
256 $this->add_responsive_control(
257 'item_bottom_spacing',
258 [
259 'label' => esc_html__('Item Gap', 'ultimate-post-kit'),
260 'type' => Controls_Manager::SLIDER,
261 'range' => [
262 'px' => [
263 'min' => 0,
264 'max' => 50,
265 ],
266 ],
267 'selectors' => [
268 '{{WRAPPER}} .upk-featured-list' => 'grid-row-gap: {{SIZE}}{{UNIT}};',
269 ],
270 ]
271 );
272
273 $this->add_responsive_control(
274 'featured_item_padding',
275 [
276 'label' => esc_html__('Featured Item Padding', 'ultimate-post-kit'),
277 'type' => Controls_Manager::DIMENSIONS,
278 'size_units' => ['px', 'em', '%'],
279 'selectors' => [
280 '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
281 ],
282 ]
283 );
284
285 $this->add_responsive_control(
286 'item_padding',
287 [
288 'label' => esc_html__('Padding', 'ultimate-post-kit'),
289 'type' => Controls_Manager::DIMENSIONS,
290 'size_units' => ['px', 'em', '%'],
291 'selectors' => [
292 '{{WRAPPER}} .upk-featured-list .upk-item .upk-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
293
294 // '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-content,
295 // {{WRAPPER}} .upk-featured-list .upk-item:nth-last-child(1) .upk-content' => 'padding-bottom: calc(2 * {{TOP}}{{UNIT}});',
296 // '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(2) .upk-content' => 'padding-top: calc(2 * {{TOP}}{{UNIT}});',
297 ],
298 ]
299 );
300
301 $this->add_control(
302 'image_heading',
303 [
304 'label' => esc_html__('Image', 'ultimate-post-kit'),
305 'type' => Controls_Manager::HEADING,
306 'separator' => 'before'
307 ]
308 );
309
310 $this->add_control(
311 'item_overlay_color',
312 [
313 'label' => esc_html__('Overlay Color', 'ultimate-post-kit'),
314 'type' => Controls_Manager::COLOR,
315 'selectors' => [
316 '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-image-wrap:before' => 'background: linear-gradient(0deg, {{VALUE}} 0, rgba(141, 153, 174, 0.1) 100%);',
317 ],
318 ]
319 );
320
321 $this->add_group_control(
322 Group_Control_Border::get_type(),
323 [
324 'name' => 'item_image_border',
325 'selector' => '{{WRAPPER}} .upk-featured-list .upk-image-wrap',
326 ]
327 );
328
329 $this->add_responsive_control(
330 'item_image_border_radius',
331 [
332 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
333 'type' => Controls_Manager::DIMENSIONS,
334 'size_units' => ['px', '%'],
335 'selectors' => [
336 '{{WRAPPER}} .upk-featured-list .upk-image-wrap' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
337 ],
338 ]
339 );
340
341 $this->add_responsive_control(
342 'image_spacing',
343 [
344 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
345 'type' => Controls_Manager::SLIDER,
346 'range' => [
347 'px' => [
348 'min' => 0,
349 'max' => 50,
350 ],
351 ],
352 'selectors' => [
353 '{{WRAPPER}} .upk-featured-list.upk-featured-style-2 .upk-item-box' => 'grid-column-gap: {{SIZE}}{{UNIT}};',
354 '{{WRAPPER}} .upk-featured-list.upk-featured-style-3 .upk-item-box' => 'grid-column-gap: {{SIZE}}{{UNIT}};',
355 ],
356 ]
357 );
358
359
360 $this->end_controls_section();
361
362 $this->start_controls_section(
363 'section_style_title',
364 [
365 'label' => esc_html__('Title', 'ultimate-post-kit'),
366 'tab' => Controls_Manager::TAB_STYLE,
367 'condition' => [
368 'show_title' => 'yes',
369 ],
370 ]
371 );
372
373 $this->add_control(
374 'title_style',
375 [
376 'label' => esc_html__('Style', 'ultimate-post-kit'),
377 'type' => Controls_Manager::SELECT,
378 'default' => 'underline',
379 'options' => [
380 'underline' => esc_html__('Underline', 'ultimate-post-kit'),
381 'middle-underline' => esc_html__('Middle Underline', 'ultimate-post-kit'),
382 'overline' => esc_html__('Overline', 'ultimate-post-kit'),
383 'middle-overline' => esc_html__('Middle Overline', 'ultimate-post-kit'),
384 ],
385 ]
386 );
387
388 //title tabs control
389 $this->start_controls_tabs('tabs_title_style');
390 //title normal tab
391 $this->start_controls_tab(
392 'tab_title_normal',
393 [
394 'label' => esc_html__('Normal', 'ultimate-post-kit'),
395 ]
396 );
397
398 $this->add_control(
399 'title_color',
400 [
401 'label' => esc_html__('Color', 'ultimate-post-kit'),
402 'type' => Controls_Manager::COLOR,
403 'selectors' => [
404 '{{WRAPPER}} .upk-featured-list .upk-item .upk-title a' => 'color: {{VALUE}};',
405 ],
406 ]
407 );
408
409 $this->add_control(
410 'title_hover_color',
411 [
412 'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
413 'type' => Controls_Manager::COLOR,
414 'selectors' => [
415 '{{WRAPPER}} .upk-featured-list .upk-item .upk-title a:hover' => 'color: {{VALUE}};',
416 ],
417 ]
418 );
419
420 $this->add_group_control(
421 Group_Control_Typography::get_type(),
422 [
423 'name' => 'title_typography',
424 'label' => esc_html__('Typography', 'ultimate-post-kit'),
425 'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-title',
426 ]
427 );
428
429 $this->add_group_control(
430 Group_Control_Text_Shadow::get_type(),
431 [
432 'name' => 'title_text_shadow',
433 'label' => esc_html__('Text Shadow', 'ultimate-post-kit'),
434 'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-title a',
435 ]
436 );
437 //title text stroke control
438 $this->add_group_control(
439 Group_Control_Text_Stroke::get_type(),
440 [
441 'name' => 'title_text_stroke',
442 'label' => esc_html__('Text Stroke', 'ultimate-post-kit') . BDTUPK_PC,
443 'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-title a',
444 ]
445 );
446
447 //title normal tab end
448 $this->end_controls_tab();
449 //title featured tab
450 $this->start_controls_tab(
451 'tab_title_featured',
452 [
453 'label' => esc_html__('Featured', 'ultimate-post-kit'),
454 ]
455 );
456
457 $this->add_control(
458 'title_featured_color',
459 [
460 'label' => esc_html__('Color', 'ultimate-post-kit'),
461 'type' => Controls_Manager::COLOR,
462 'selectors' => [
463 '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-title a' => 'color: {{VALUE}};',
464 ],
465 'separator' => 'before'
466 ]
467 );
468
469 $this->add_control(
470 'title_featured_hover_color',
471 [
472 'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
473 'type' => Controls_Manager::COLOR,
474 'selectors' => [
475 '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-title a:hover' => 'color: {{VALUE}};',
476 ],
477 ]
478 );
479
480 $this->add_group_control(
481 Group_Control_Typography::get_type(),
482 [
483 'name' => 'featured_title_typography',
484 'label' => esc_html__('Typography', 'ultimate-post-kit') . BDTUPK_PC,
485 'selector' => '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-title',
486 ]
487 );
488
489 $this->add_group_control(
490 Group_Control_Text_Shadow::get_type(),
491 [
492 'name' => 'featured_title_text_shadow',
493 'label' => esc_html__('Text Shadow', 'ultimate-post-kit') . BDTUPK_PC,
494 'selector' => '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-title a',
495 ]
496 );
497
498 $this->add_group_control(
499 Group_Control_Text_Stroke::get_type(),
500 [
501 'name' => 'featured_title_text_stroke',
502 'label' => esc_html__('Text Stroke', 'ultimate-post-kit') . BDTUPK_PC,
503 'selector' => '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-title a',
504 ]
505 );
506 //title featured tab end
507 $this->end_controls_tab();
508 //title tabs control end
509 $this->end_controls_tabs();
510
511 $this->end_controls_section();
512
513 $this->start_controls_section(
514 'section_style_meta',
515 [
516 'label' => esc_html__('Meta', 'ultimate-post-kit'),
517 'tab' => Controls_Manager::TAB_STYLE,
518 'conditions' => [
519 'relation' => 'or',
520 'terms' => [
521 [
522 'name' => 'show_author',
523 'value' => 'yes'
524 ],
525 [
526 'name' => 'show_date',
527 'value' => 'yes'
528 ],
529 [
530 'name' => 'show_comments',
531 'value' => 'yes'
532 ]
533 ]
534 ],
535 ]
536 );
537
538 $this->add_control(
539 'meta_color',
540 [
541 'label' => esc_html__('Color', 'ultimate-post-kit'),
542 'type' => Controls_Manager::COLOR,
543 'selectors' => [
544 '{{WRAPPER}} .upk-featured-list .upk-item .upk-featured-meta, {{WRAPPER}} .upk-featured-list .upk-item .upk-featured-meta .upk-author-name-wrap .upk-author-name' => 'color: {{VALUE}};',
545 ],
546 ]
547 );
548
549 $this->add_control(
550 'meta_featured_color',
551 [
552 'label' => esc_html__('Featured Color', 'ultimate-post-kit'),
553 'type' => Controls_Manager::COLOR,
554 'selectors' => [
555 '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-featured-meta, {{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-featured-meta .upk-author-name-wrap .upk-author-name' => 'color: {{VALUE}};',
556 ],
557 ]
558 );
559
560 $this->add_responsive_control(
561 'meta_spacing',
562 [
563 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
564 'type' => Controls_Manager::SLIDER,
565 'range' => [
566 'px' => [
567 'min' => 0,
568 'max' => 50,
569 ],
570 ],
571 'selectors' => [
572 '{{WRAPPER}} .upk-featured-list .upk-item .upk-featured-meta' => 'padding-top: {{SIZE}}{{UNIT}};',
573 ],
574 ]
575 );
576
577 $this->add_responsive_control(
578 'meta_space_between',
579 [
580 'label' => esc_html__('Space Between', 'ultimate-post-kit'),
581 'type' => Controls_Manager::SLIDER,
582 'range' => [
583 'px' => [
584 'min' => 0,
585 'max' => 50,
586 ],
587 ],
588 'selectors' => [
589 '{{WRAPPER}} .upk-featured-list .upk-item .upk-featured-meta > div:before' => 'margin: 0 {{SIZE}}{{UNIT}};',
590 ],
591 ]
592 );
593
594 $this->add_group_control(
595 Group_Control_Typography::get_type(),
596 [
597 'name' => 'meta_typography',
598 'label' => esc_html__('Typography', 'ultimate-post-kit'),
599 'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-featured-meta',
600 ]
601 );
602
603 $this->end_controls_section();
604
605 $this->start_controls_section(
606 'section_style_category',
607 [
608 'label' => esc_html__('Category', 'ultimate-post-kit'),
609 'tab' => Controls_Manager::TAB_STYLE,
610 'condition' => [
611 'show_category' => 'yes',
612 ],
613 ]
614 );
615
616 $this->add_responsive_control(
617 'category_bottom_spacing',
618 [
619 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
620 'type' => Controls_Manager::SLIDER,
621 'range' => [
622 'px' => [
623 'min' => 0,
624 'max' => 50,
625 ],
626 ],
627 'selectors' => [
628 '{{WRAPPER}} .upk-featured-list .upk-item .upk-category' => 'padding-bottom: {{SIZE}}{{UNIT}};',
629 ],
630 ]
631 );
632
633 $this->add_control(
634 'category_style_color',
635 [
636 'label' => esc_html__('Dot Style Color', 'ultimate-post-kit'),
637 'type' => Controls_Manager::COLOR,
638 'selectors' => [
639 '{{WRAPPER}} .upk-featured-list .upk-item .upk-category a span' => 'background-color: {{VALUE}} !important;',
640 ],
641 ]
642 );
643
644 $this->start_controls_tabs('tabs_category_style');
645
646 $this->start_controls_tab(
647 'tab_category_normal',
648 [
649 'label' => esc_html__('Normal', 'ultimate-post-kit'),
650 ]
651 );
652
653 $this->add_control(
654 'category_color',
655 [
656 'label' => esc_html__('Color', 'ultimate-post-kit'),
657 'type' => Controls_Manager::COLOR,
658 'selectors' => [
659 '{{WRAPPER}} .upk-featured-list .upk-item .upk-category a' => 'color: {{VALUE}};',
660 ],
661 ]
662 );
663
664 $this->add_group_control(
665 Group_Control_Background::get_type(),
666 [
667 'name' => 'category_background',
668 'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-category a',
669 ]
670 );
671
672 $this->add_group_control(
673 Group_Control_Border::get_type(),
674 [
675 'name' => 'category_border',
676 'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-category a',
677 ]
678 );
679
680 $this->add_responsive_control(
681 'category_border_radius',
682 [
683 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
684 'type' => Controls_Manager::DIMENSIONS,
685 'size_units' => ['px', '%'],
686 'selectors' => [
687 '{{WRAPPER}} .upk-featured-list .upk-item .upk-category a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
688 ],
689 ]
690 );
691
692 $this->add_responsive_control(
693 'category_padding',
694 [
695 'label' => esc_html__('Padding', 'ultimate-post-kit'),
696 'type' => Controls_Manager::DIMENSIONS,
697 'size_units' => ['px', 'em', '%'],
698 'selectors' => [
699 '{{WRAPPER}} .upk-featured-list .upk-item .upk-category a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
700 ],
701 ]
702 );
703
704 $this->add_responsive_control(
705 'category_spacing',
706 [
707 'label' => esc_html__('Space Between', 'ultimate-post-kit'),
708 'type' => Controls_Manager::SLIDER,
709 'range' => [
710 'px' => [
711 'min' => 0,
712 'max' => 50,
713 'step' => 2,
714 ],
715 ],
716 'selectors' => [
717 '{{WRAPPER}} .upk-featured-list .upk-item .upk-category a+a' => 'margin-left: {{SIZE}}{{UNIT}};',
718 ],
719 ]
720 );
721
722 $this->add_group_control(
723 Group_Control_Box_Shadow::get_type(),
724 [
725 'name' => 'category_shadow',
726 'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-category a',
727 ]
728 );
729
730 $this->add_group_control(
731 Group_Control_Typography::get_type(),
732 [
733 'name' => 'category_typography',
734 'label' => esc_html__('Typography', 'ultimate-post-kit'),
735 'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-category a',
736 ]
737 );
738
739 $this->end_controls_tab();
740
741 $this->start_controls_tab(
742 'tab_category_hover',
743 [
744 'label' => esc_html__('Hover', 'ultimate-post-kit'),
745 ]
746 );
747
748 $this->add_control(
749 'category_hover_color',
750 [
751 'label' => esc_html__('Color', 'ultimate-post-kit'),
752 'type' => Controls_Manager::COLOR,
753 'selectors' => [
754 '{{WRAPPER}} .upk-featured-list .upk-item .upk-category a:hover' => 'color: {{VALUE}};',
755 ],
756 ]
757 );
758
759 $this->add_group_control(
760 Group_Control_Background::get_type(),
761 [
762 'name' => 'category_hover_background',
763 'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-category a:hover',
764 ]
765 );
766
767 $this->add_control(
768 'category_hover_border_color',
769 [
770 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
771 'type' => Controls_Manager::COLOR,
772 'condition' => [
773 'category_border_border!' => '',
774 ],
775 'selectors' => [
776 '{{WRAPPER}} .upk-featured-list .upk-item .upk-category a:hover' => 'border-color: {{VALUE}};',
777 ],
778 ]
779 );
780
781 $this->end_controls_tab();
782
783 $this->start_controls_tab(
784 'tab_category_featured',
785 [
786 'label' => esc_html__('Featured', 'ultimate-post-kit'),
787 ]
788 );
789
790 $this->add_control(
791 'category_featured_heading',
792 [
793 'label' => esc_html__('NORMAL', 'ultimate-post-kit'),
794 'type' => Controls_Manager::HEADING,
795 ]
796 );
797
798 $this->add_control(
799 'category_featured_color',
800 [
801 'label' => esc_html__('Color', 'ultimate-post-kit'),
802 'type' => Controls_Manager::COLOR,
803 'selectors' => [
804 '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-category a' => 'color: {{VALUE}};',
805 ],
806 ]
807 );
808
809 $this->add_group_control(
810 Group_Control_Background::get_type(),
811 [
812 'name' => 'category_featured_background',
813 'selector' => '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-category a',
814 ]
815 );
816
817 $this->add_control(
818 'category_featured_border_color',
819 [
820 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
821 'type' => Controls_Manager::COLOR,
822 'condition' => [
823 'category_border_border!' => '',
824 ],
825 'selectors' => [
826 '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-category a' => 'border-color: {{VALUE}};',
827 ],
828 ]
829 );
830
831 $this->add_control(
832 'heading_category_featured_hover_style',
833 [
834 'label' => esc_html__('HOVER', 'ultimate-post-kit'),
835 'type' => Controls_Manager::HEADING,
836 'separator' => 'before',
837 ]
838 );
839
840 $this->add_control(
841 'category_featured_color_hover',
842 [
843 'label' => esc_html__('Color', 'ultimate-post-kit'),
844 'type' => Controls_Manager::COLOR,
845 'selectors' => [
846 '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-category a:hover' => 'color: {{VALUE}};',
847 ],
848 ]
849 );
850
851 $this->add_group_control(
852 Group_Control_Background::get_type(),
853 [
854 'name' => 'category_featured_background_hover',
855 'selector' => '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-category a:hover',
856 ]
857 );
858
859 $this->add_control(
860 'category_featured_border_color_hover',
861 [
862 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
863 'type' => Controls_Manager::COLOR,
864 'condition' => [
865 'category_border_border!' => '',
866 ],
867 'selectors' => [
868 '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-category a:hover' => 'border-color: {{VALUE}};',
869 ],
870 ]
871 );
872
873 $this->end_controls_tab();
874
875
876 $this->end_controls_tabs();
877
878 $this->end_controls_section();
879
880 $this->start_controls_section(
881 'section_style_counter_number',
882 [
883 'label' => esc_html__('Counter Number', 'ultimate-post-kit'),
884 'tab' => Controls_Manager::TAB_STYLE,
885 'condition' => [
886 'show_counter_number' => 'yes',
887 'layout_style' => 'style-1',
888 ]
889 ]
890 );
891
892 $this->start_controls_tabs(
893 'counter_number_style_tabs'
894 );
895
896 $this->start_controls_tab(
897 'conter_number_style_normal_tab',
898 [
899 'label' => esc_html__( 'Normal', 'ultimate-post-kit' ),
900 ]
901 );
902
903 $this->add_control(
904 'counter_number_color',
905 [
906 'label' => esc_html__('Color', 'ultimate-post-kit'),
907 'type' => Controls_Manager::COLOR,
908 'selectors' => [
909 '{{WRAPPER}} .upk-featured-list .upk-item .upk-counter:before' => 'color: {{VALUE}};',
910 ],
911 ]
912 );
913
914 $this->add_group_control(
915 Group_Control_Background::get_type(),
916 [
917 'name' => 'counter_number_background',
918 'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-counter',
919 ]
920 );
921
922 $this->add_group_control(
923 Group_Control_Border::get_type(),
924 [
925 'name' => 'counter_number_border',
926 'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-counter',
927 ]
928 );
929
930 $this->add_responsive_control(
931 'counter_number_border_radius',
932 [
933 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
934 'type' => Controls_Manager::DIMENSIONS,
935 'size_units' => ['px', '%'],
936 'selectors' => [
937 '{{WRAPPER}} .upk-featured-list .upk-item .upk-counter' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
938 ],
939 ]
940 );
941
942 $this->add_responsive_control(
943 'counter_number_spacing',
944 [
945 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
946 'type' => Controls_Manager::SLIDER,
947 'range' => [
948 'px' => [
949 'min' => 0,
950 'max' => 50,
951 ],
952 ],
953 'selectors' => [
954 '{{WRAPPER}} .upk-featured-list .upk-item .upk-counter' => 'margin-right: {{SIZE}}{{UNIT}};',
955 ],
956 ]
957 );
958
959 $this->add_responsive_control(
960 'counter_number_size',
961 [
962 'label' => esc_html__('Counter Size', 'ultimate-post-kit'),
963 'type' => Controls_Manager::SLIDER,
964 'range' => [
965 'px' => [
966 'min' => 20,
967 'max' => 100,
968 ],
969 ],
970 'selectors' => [
971 '{{WRAPPER}} .upk-featured-list .upk-item .upk-counter' => 'height: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}}; min-width: {{SIZE}}{{UNIT}};',
972 ],
973 ]
974 );
975
976 $this->add_group_control(
977 Group_Control_Typography::get_type(),
978 [
979 'name' => 'counter_number_typography',
980 'label' => esc_html__('Typography', 'ultimate-post-kit'),
981 'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-counter:before',
982 ]
983 );
984
985
986 $this->end_controls_tab();
987
988 $this->start_controls_tab(
989 'conter_number__featured_style_normal_tab',
990 [
991 'label' => esc_html__( 'Featured', 'ultimate-post-kit' ),
992 ]
993 );
994
995 $this->add_control(
996 'featured_counter_number_color',
997 [
998 'label' => esc_html__('Color', 'ultimate-post-kit'),
999 'type' => Controls_Manager::COLOR,
1000 'selectors' => [
1001 '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-counter:before' => 'color: {{VALUE}};',
1002 ],
1003 ]
1004 );
1005
1006 $this->add_group_control(
1007 Group_Control_Background::get_type(),
1008 [
1009 'name' => 'featured_counter_number_background',
1010 'selector' => '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-counter',
1011 ]
1012 );
1013
1014 $this->add_control(
1015 'featured_counter_number_border_color',
1016 [
1017 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
1018 'type' => Controls_Manager::COLOR,
1019 'condition' => [
1020 'counter_number_border_border!' => '',
1021 ],
1022 'selectors' => [
1023 '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-counter' => 'border-color: {{VALUE}};',
1024 ],
1025 ]
1026 );
1027
1028 $this->end_controls_tab();
1029
1030 $this->end_controls_tabs();
1031
1032 $this->end_controls_section();
1033
1034 //Global Pagination Controls
1035 $this->register_pagination_controls();
1036
1037 //Global Ajax Loadmore Style Controls
1038 $this->register_ajax_loadmore_style_controls();
1039 }
1040
1041 /**
1042 * Get post query builder arguments
1043 */
1044 public function query_posts( $posts_per_page ) {
1045 $settings = $this->get_settings();
1046 $posts_per_page = isset( $posts_per_page ) ? (int) $posts_per_page : 0;
1047 $args = $this->getGroupControlQueryArgs();
1048 $is_current_query = ( ! empty( $settings['posts_source'] ) && $settings['posts_source'] === 'current_query' );
1049
1050 if ( $is_current_query ) {
1051 unset( $args['offset'] );
1052 unset( $args['no_found_rows'] );
1053 $posts_per_page = 0;
1054 }
1055
1056 if ( $posts_per_page > 0 ) {
1057 $args['posts_per_page'] = $posts_per_page;
1058 } else {
1059 $args['posts_per_page'] = (int) get_option( 'posts_per_page', 10 );
1060 }
1061
1062 if ( $settings['show_pagination'] ) {
1063 $args['paged'] = max( 1, (int) get_query_var( 'paged' ), (int) get_query_var( 'page' ) );
1064 }
1065
1066 $this->_query = new \WP_Query( $args );
1067 }
1068
1069 public function print_category_output($output) {
1070
1071
1072 $tags = [
1073 'a' => ['href' => [], 'target' => [], 'class' => []],
1074 'span' => ['style' => [], 'class' => []],
1075 ];
1076
1077 if (isset($output)) {
1078 echo wp_kses($output, $tags);
1079 }
1080 }
1081
1082 public function render_category() {
1083 if (!$this->get_settings('show_category')) {
1084 return;
1085 }
1086 ?>
1087 <div class="upk-category">
1088
1089 <?php
1090 $post_type = $this->get_settings('posts_source');
1091 switch ($post_type) {
1092 case 'campaign':
1093 $taxonomy = 'campaign_category';
1094 break;
1095 case 'lightbox_library':
1096 $taxonomy = 'ngg_tag';
1097 break;
1098 case 'give_forms':
1099 $taxonomy = 'give_forms_category';
1100 break;
1101 case 'tribe_events':
1102 $taxonomy = 'tribe_events_cat';
1103 break;
1104 case 'product':
1105 $taxonomy = 'product_cat';
1106 break;
1107 default:
1108 $taxonomy = 'category';
1109 break;
1110 }
1111
1112 $categories = get_the_terms(get_the_ID(), $taxonomy);
1113
1114 $_categories = [];
1115
1116 if ($categories) {
1117 foreach ($categories as $category) {
1118 $bg_color = strToHex($category->name);
1119 $link = '<a href="' . esc_url(get_category_link($category->term_id)) . '"><span style="background-color:' . $bg_color . '"></span>' . $category->name . '</a>';
1120 $_categories[$category->slug] = $link;
1121 }
1122 }
1123
1124 $category_link = implode(' ', $_categories);
1125
1126 $this->print_category_output($category_link);
1127
1128 ?>
1129 </div>
1130 <?php
1131 }
1132
1133 public function render_author() {
1134
1135 if (!$this->get_settings('show_author')) {
1136 return;
1137 }
1138 ?>
1139 <div class="upk-author-name-wrap">
1140 <span class="upk-by"><?php echo esc_html_x('by', 'Frontend', 'ultimate-post-kit'); ?></span>
1141 <a class="upk-author-name" href="<?php echo esc_url( get_author_posts_url(get_the_author_meta('ID')) ); ?>">
1142 <?php echo esc_html( get_the_author() ); ?>
1143 </a>
1144 </div>
1145 <?php
1146 }
1147
1148 public function render_comments($id = 0) {
1149
1150 if (!$this->get_settings('show_comments')) {
1151 return;
1152 }
1153 ?>
1154
1155 <div class="upk-featured-comments">
1156 <?php echo esc_html( $this->upk_get_formatted_comments_count( $id ) ); ?>
1157 </div>
1158
1159 <?php
1160 }
1161
1162 public function render_post_grid_item($post_id, $image_size) {
1163 $settings = $this->get_settings_for_display();
1164
1165 if ('yes' == $settings['global_link']) {
1166
1167 $this->add_render_attribute('list-item', 'onclick', "window.open('" . esc_url(get_permalink()) . "', '_self')", true);
1168 }
1169 $this->add_render_attribute('list-item', 'class', 'upk-item', true);
1170
1171 ?>
1172 <div <?php $this->print_render_attribute_string('list-item'); ?>>
1173 <div class="upk-item-box">
1174
1175 <div class="upk-image-wrap">
1176 <?php $this->render_image(get_post_thumbnail_id($post_id), $image_size); ?>
1177 </div>
1178 <div class="upk-content">
1179 <?php if ($settings['show_counter_number'] == 'yes') : ?>
1180 <div class="upk-counter"></div>
1181 <?php endif; ?>
1182
1183 <div>
1184 <?php $this->render_category(); ?>
1185 <?php $this->render_title(substr($this->get_name(), 4)); ?>
1186
1187 <?php if ($settings['show_author'] or $settings['show_comments'] or $settings['show_date'] or $settings['show_reading_time']) : ?>
1188 <div class="upk-featured-meta">
1189 <?php if ($settings['show_author']) : ?>
1190 <?php $this->render_author(); ?>
1191 <?php endif; ?>
1192 <?php if ($settings['show_date']) : ?>
1193 <div data-separator="<?php echo esc_attr($settings['meta_separator']); ?>">
1194 <?php $this->render_date(); ?>
1195 </div>
1196 <?php endif; ?>
1197 <?php if ($settings['show_comments']) : ?>
1198 <div data-separator="<?php echo esc_attr($settings['meta_separator']); ?>">
1199 <?php $this->render_comments($post_id); ?>
1200 </div>
1201 <?php endif; ?>
1202 <?php if (_is_upk_pro_activated()) :
1203 if ('yes' === $settings['show_reading_time']) : ?>
1204 <div class="upk-reading-time" data-separator="<?php echo esc_attr($settings['meta_separator']); ?>">
1205 <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'], $settings['hide_seconds'] ?? 'no', $settings['hide_minutes'] ?? 'no' ) ); ?>
1206 </div>
1207 <?php endif; ?>
1208 <?php endif; ?>
1209 </div>
1210 <?php endif; ?>
1211
1212 </div>
1213 </div>
1214
1215 </div>
1216 </div>
1217
1218 <?php
1219 }
1220
1221 protected function render() {
1222 $settings = $this->get_settings_for_display();
1223
1224 $this->query_posts($settings['item_limit']['size']);
1225 $wp_query = $this->get_query();
1226
1227 if (!$wp_query->found_posts) {
1228 return;
1229 }
1230
1231 $this->add_render_attribute(
1232 [
1233 'upk-featured-list' => [
1234 'class' => 'upk-featured-list upk-featured-' . $settings['layout_style'] . ' upk-ajax-grid',
1235 'data-loadmore' => [
1236 wp_json_encode(
1237 array_filter([
1238 'loadmore_enable' => $settings['ajax_loadmore_enable'],
1239 'loadmore_btn' => $settings['ajax_loadmore_btn'],
1240 'infinite_scroll' => $settings['ajax_loadmore_infinite_scroll'],
1241 ])
1242 ),
1243 ],
1244 ],
1245 ]
1246 );
1247
1248 if ($settings['ajax_loadmore_enable'] == 'yes') {
1249 $ajax_settings = [
1250 'posts_source' => isset($settings['posts_source']) ? $settings['posts_source'] : 'post',
1251 'posts_per_page' => isset($settings['item_limit']['size']) ? $settings['item_limit']['size'] : 4,
1252 'ajax_item_load' => isset($settings['ajax_loadmore_items']) ? $settings['ajax_loadmore_items'] : 4,
1253 'posts_selected_ids' => isset($settings['posts_selected_ids']) ? $settings['posts_selected_ids'] : '',
1254 'posts_include_by' => isset($settings['posts_include_by']) ? $settings['posts_include_by'] : [],
1255 'posts_include_author_ids' => isset($settings['posts_include_author_ids']) ? $settings['posts_include_author_ids'] : '',
1256 'posts_include_term_ids' => isset($settings['posts_include_term_ids']) ? $settings['posts_include_term_ids'] : '',
1257 'posts_exclude_by' => isset($settings['posts_exclude_by']) ? $settings['posts_exclude_by'] : [],
1258 'posts_exclude_ids' => isset($settings['posts_exclude_ids']) ? $settings['posts_exclude_ids'] : '',
1259 'posts_exclude_author_ids' => isset($settings['posts_exclude_author_ids']) ? $settings['posts_exclude_author_ids'] : '',
1260 'posts_exclude_term_ids' => isset($settings['posts_exclude_term_ids']) ? $settings['posts_exclude_term_ids'] : '',
1261 'posts_offset' => isset($settings['posts_offset']) ? $settings['posts_offset'] : 0,
1262 'posts_select_date' => isset($settings['posts_select_date']) ? $settings['posts_select_date'] : '',
1263 'posts_date_before' => isset($settings['posts_date_before']) ? $settings['posts_date_before'] : '',
1264 'posts_date_after' => isset($settings['posts_date_after']) ? $settings['posts_date_after'] : '',
1265 'posts_orderby' => isset($settings['posts_orderby']) ? $settings['posts_orderby'] : 'date',
1266 'posts_order' => isset($settings['posts_order']) ? $settings['posts_order'] : 'DESC',
1267 'posts_ignore_sticky_posts' => isset($settings['posts_ignore_sticky_posts']) ? $settings['posts_ignore_sticky_posts'] : 'no',
1268 'posts_only_with_featured_image'=> isset($settings['posts_only_with_featured_image']) ? $settings['posts_only_with_featured_image'] : 'no',
1269 // List Settings
1270 'layout_style' => isset($settings['layout_style']) ? $settings['layout_style'] : 'style-1',
1271 'show_title' => isset($settings['show_title']) ? $settings['show_title'] : 'yes',
1272 'title_tags' => isset( $settings['title_tags'] ) ? $settings['title_tags'] : 'h3',
1273 'title_style' => isset($settings['title_style']) ? $settings['title_style'] : '',
1274 'show_category' => isset($settings['show_category']) ? $settings['show_category'] : 'yes',
1275 'show_counter_number' => isset($settings['show_counter_number']) ? $settings['show_counter_number'] : 'yes',
1276 'show_author' => isset($settings['show_author']) ? $settings['show_author'] : 'no',
1277 'show_comments' => isset($settings['show_comments']) ? $settings['show_comments'] : 'no',
1278 'meta_separator' => isset($settings['meta_separator']) ? $settings['meta_separator'] : '//',
1279 'show_date' => isset($settings['show_date']) ? $settings['show_date'] : 'no',
1280 'show_time' => isset($settings['show_time']) ? $settings['show_time'] : 'no',
1281 'human_diff_time' => isset($settings['human_diff_time']) ? $settings['human_diff_time'] : 'no',
1282 'human_diff_time_short' => isset($settings['human_diff_time_short']) ? $settings['human_diff_time_short'] : 'no',
1283 'show_reading_time' => isset($settings['show_reading_time']) ? $settings['show_reading_time'] : 'no',
1284 'avg_reading_speed' => isset($settings['avg_reading_speed']) ? $settings['avg_reading_speed'] : 200,
1285 'hide_seconds' => isset($settings['hide_seconds']) ? $settings['hide_seconds'] : 'no',
1286 'hide_minutes' => isset($settings['hide_minutes']) ? $settings['hide_minutes'] : 'no',
1287 'primary_thumbnail_size' => isset($settings['primary_thumbnail_size']) ? $settings['primary_thumbnail_size'] : 'medium',
1288 'upk_link_new_tab' => isset($settings['upk_link_new_tab']) ? $settings['upk_link_new_tab'] : 'no',
1289 'global_link' => isset($settings['global_link']) ? $settings['global_link'] : 'no',
1290 ];
1291
1292 $this->add_render_attribute(
1293 [
1294 'upk-featured-list' => [
1295 'data-settings' => [
1296 wp_json_encode($ajax_settings)
1297 ],
1298 ],
1299 ]
1300 );
1301 }
1302
1303 $this->add_render_attribute('list-wrap', 'class', 'upk-featured-list upk-featured-' . $settings['layout_style'] . ' upk-ajax-grid-wrap');
1304
1305 if (isset($settings['upk_in_animation_show']) && ($settings['upk_in_animation_show'] == 'yes')) {
1306 $this->add_render_attribute('list-wrap', 'class', 'upk-in-animation');
1307 if (isset($settings['upk_in_animation_delay']['size'])) {
1308 $this->add_render_attribute('list-wrap', 'data-in-animation-delay', $settings['upk_in_animation_delay']['size']);
1309 }
1310 }
1311
1312 ?>
1313 <div <?php $this->print_render_attribute_string('upk-featured-list'); ?>>
1314 <div <?php $this->print_render_attribute_string('list-wrap'); ?>>
1315 <?php while ($wp_query->have_posts()) :
1316 $wp_query->the_post();
1317
1318 $thumbnail_size = $settings['primary_thumbnail_size'];
1319
1320 ?>
1321
1322 <?php $this->render_post_grid_item(get_the_ID(), $thumbnail_size); ?>
1323
1324 <?php endwhile; ?>
1325 </div>
1326 </div>
1327
1328 <?php $this->render_ajax_loadmore(); ?>
1329
1330 <?php
1331
1332 if ($settings['show_pagination']) { ?>
1333 <div class="ep-pagination">
1334 <?php ultimate_post_kit_post_pagination($wp_query, $this->get_id()); ?>
1335 </div>
1336 <?php
1337 }
1338 wp_reset_postdata();
1339 }
1340 }
1341