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

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