PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / 4.1.10
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets v4.1.10
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.1.10, at modules/featured-list/widgets/featured-list.php

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