PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / 4.1.4
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets v4.1.4
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 / buzz-list / widgets / buzz-list.php

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

1,020 lines 28.5 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\BuzzList\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
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 Buzz_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-buzz-list';
31 }
32
33 public function get_title() {
34 return BDTUPK . esc_html__('Buzz List', 'ultimate-post-kit');
35 }
36
37 public function get_icon() {
38 return 'upk-widget-icon upk-icon-buzz-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', 'buzz', '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-buzz-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/fxjL-ugL_Ls';
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 $this->add_responsive_control(
87 'columns',
88 [
89 'label' => __('Columns', 'ultimate-post-kit'),
90 'type' => Controls_Manager::SELECT,
91 'default' => '3',
92 'tablet_default' => '2',
93 'mobile_default' => '1',
94 'options' => [
95 '1' => '1',
96 '2' => '2',
97 '3' => '3',
98 '4' => '4',
99 ],
100 'selectors' => [
101 '{{WRAPPER}} .upk-buzz-list' => 'grid-template-columns: repeat({{SIZE}}, 1fr);',
102 ],
103 ]
104 );
105
106 $this->add_responsive_control(
107 'column_gap',
108 [
109 'label' => esc_html__('Column Gap', 'ultimate-post-kit'),
110 'type' => Controls_Manager::SLIDER,
111 'selectors' => [
112 '{{WRAPPER}} .upk-buzz-list' => 'grid-column-gap: {{SIZE}}{{UNIT}};',
113 ],
114 ]
115 );
116
117 $this->add_responsive_control(
118 'row_gap',
119 [
120 'label' => esc_html__('Row Gap', 'ultimate-post-kit'),
121 'type' => Controls_Manager::SLIDER,
122 'selectors' => [
123 '{{WRAPPER}} .upk-buzz-list' => 'grid-row-gap: {{SIZE}}{{UNIT}};',
124 ],
125 ]
126 );
127
128 $this->add_group_control(
129 Group_Control_Image_Size::get_type(),
130 [
131 'name' => 'primary_thumbnail',
132 'exclude' => ['custom'],
133 'default' => 'medium',
134 ]
135 );
136
137 $this->add_control(
138 'hr',
139 [
140 'type' => Controls_Manager::DIVIDER,
141 ]
142 );
143
144 //Global Title Controls
145 $this->register_title_controls();
146
147 $this->add_control(
148 'show_category',
149 [
150 'label' => esc_html__('Show Category', '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 'default' => 'yes',
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' => esc_html__('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' => 6,
236 ],
237 ]
238 );
239
240 $this->register_query_builder_controls();
241
242 $this->end_controls_section();
243
244 //Style
245 $this->start_controls_section(
246 'upk_section_style',
247 [
248 'label' => esc_html__('Item', 'ultimate-post-kit'),
249 'tab' => Controls_Manager::TAB_STYLE,
250 ]
251 );
252
253 $this->start_controls_tabs('tabs_item_style');
254
255 $this->start_controls_tab(
256 'tab_item_normal',
257 [
258 'label' => esc_html__('Normal', 'ultimate-post-kit'),
259 ]
260 );
261
262 $this->add_control(
263 'overlay_background',
264 [
265 'label' => esc_html__('Overlay Color', 'ultimate-post-kit'),
266 'type' => Controls_Manager::COLOR,
267 'selectors' => [
268 '{{WRAPPER}} .upk-buzz-list .upk-img-wrap::before' => 'background: {{VALUE}};'
269 ],
270 ]
271 );
272
273 $this->add_group_control(
274 Group_Control_Border::get_type(),
275 [
276 'name' => 'item_border',
277 'label' => esc_html__('Border', 'ultimate-post-kit'),
278 'placeholder' => '1px',
279 'default' => '1px',
280 'selector' => '{{WRAPPER}} .upk-buzz-list .upk-item',
281 ]
282 );
283
284 $this->add_responsive_control(
285 'item_border_radius',
286 [
287 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
288 'type' => Controls_Manager::DIMENSIONS,
289 'size_units' => ['px', '%'],
290 'selectors' => [
291 '{{WRAPPER}} .upk-buzz-list .upk-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
292 ],
293 ]
294 );
295
296 $this->add_responsive_control(
297 'item_padding',
298 [
299 'label' => esc_html__('Padding', 'ultimate-post-kit'),
300 'type' => Controls_Manager::DIMENSIONS,
301 'size_units' => ['px', 'em', '%'],
302 'selectors' => [
303 '{{WRAPPER}} .upk-buzz-list .upk-item .upk-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
304 ],
305 ]
306 );
307
308 $this->add_group_control(
309 Group_Control_Box_Shadow::get_type(),
310 [
311 'name' => 'item_box_shadow',
312 'selector' => '{{WRAPPER}} .upk-buzz-list .upk-item',
313 ]
314 );
315
316 $this->end_controls_tab();
317
318 $this->start_controls_tab(
319 'tab_item_hover',
320 [
321 'label' => esc_html__('Hover', 'ultimate-post-kit'),
322 ]
323 );
324
325 $this->add_control(
326 'overlay_background_hover',
327 [
328 'label' => esc_html__('Overlay Color', 'ultimate-post-kit'),
329 'type' => Controls_Manager::COLOR,
330 'selectors' => [
331 '{{WRAPPER}} .upk-buzz-list .upk-item:hover .upk-img-wrap::before' => 'background: {{VALUE}};'
332 ],
333 ]
334 );
335
336 $this->add_control(
337 'item_border_color_hover',
338 [
339 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
340 'type' => Controls_Manager::COLOR,
341 'selectors' => [
342 '{{WRAPPER}} .upk-buzz-list .upk-item:hover' => 'border-color: {{VALUE}};'
343 ],
344 'condition' => [
345 'item_border_border!' => ''
346 ]
347 ]
348 );
349
350 $this->add_group_control(
351 Group_Control_Box_Shadow::get_type(),
352 [
353 'name' => 'item_box_shadow_hover',
354 'selector' => '{{WRAPPER}} .upk-buzz-list .upk-item:hover',
355 ]
356 );
357
358 $this->end_controls_tab();
359
360 $this->end_controls_tabs();
361
362 $this->end_controls_section();
363
364 $this->start_controls_section(
365 'section_style_title',
366 [
367 'label' => esc_html__('Title', 'ultimate-post-kit'),
368 'tab' => Controls_Manager::TAB_STYLE,
369 'condition' => [
370 'show_title' => 'yes',
371 ],
372 ]
373 );
374
375 $this->add_control(
376 'title_style',
377 [
378 'label' => esc_html__('Style', 'ultimate-post-kit'),
379 'type' => Controls_Manager::SELECT,
380 'default' => 'underline',
381 'options' => [
382 'underline' => esc_html__('Underline', 'ultimate-post-kit'),
383 'middle-underline' => esc_html__('Middle Underline', 'ultimate-post-kit'),
384 'overline' => esc_html__('Overline', 'ultimate-post-kit'),
385 'middle-overline' => esc_html__('Middle Overline', 'ultimate-post-kit'),
386 ],
387 ]
388 );
389
390 $this->add_control(
391 'title_color',
392 [
393 'label' => esc_html__('Color', 'ultimate-post-kit'),
394 'type' => Controls_Manager::COLOR,
395 'selectors' => [
396 '{{WRAPPER}} .upk-buzz-list .upk-title a' => 'color: {{VALUE}};',
397 ],
398 'separator' => 'before'
399 ]
400 );
401
402 $this->add_control(
403 'title_hover_color',
404 [
405 'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
406 'type' => Controls_Manager::COLOR,
407 'selectors' => [
408 '{{WRAPPER}} .upk-buzz-list .upk-item:hover .upk-title a' => 'color: {{VALUE}};',
409 ],
410 ]
411 );
412
413 $this->add_group_control(
414 Group_Control_Typography::get_type(),
415 [
416 'name' => 'title_typography',
417 'label' => esc_html__('Typography', 'ultimate-post-kit'),
418 'selector' => '{{WRAPPER}} .upk-buzz-list .upk-title',
419 ]
420 );
421
422 $this->add_group_control(
423 Group_Control_Text_Shadow::get_type(),
424 [
425 'name' => 'title_text_shadow',
426 'label' => esc_html__('Text Shadow', 'ultimate-post-kit'),
427 'selector' => '{{WRAPPER}} .upk-buzz-list .upk-title a',
428 ]
429 );
430
431 $this->end_controls_section();
432
433 $this->start_controls_section(
434 'section_style_meta',
435 [
436 'label' => esc_html__('Meta', 'ultimate-post-kit'),
437 'tab' => Controls_Manager::TAB_STYLE,
438 'conditions' => [
439 'relation' => 'or',
440 'terms' => [
441 [
442 'name' => 'show_author',
443 'value' => 'yes'
444 ],
445 [
446 'name' => 'show_date',
447 'value' => 'yes'
448 ],
449 [
450 'name' => 'show_comments',
451 'value' => 'yes'
452 ]
453 ]
454 ],
455 ]
456 );
457
458 $this->add_control(
459 'meta_color',
460 [
461 'label' => esc_html__('Color', 'ultimate-post-kit'),
462 'type' => Controls_Manager::COLOR,
463 'selectors' => [
464 '{{WRAPPER}} .upk-buzz-list .upk-meta, {{WRAPPER}} .upk-buzz-list .upk-meta .upk-author-wrap .upk-author-name' => 'color: {{VALUE}};',
465 ],
466 ]
467 );
468
469 $this->add_control(
470 'meta_hover_color',
471 [
472 'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
473 'type' => Controls_Manager::COLOR,
474 'selectors' => [
475 '{{WRAPPER}} .upk-buzz-list .upk-item:hover .upk-meta, {{WRAPPER}} .upk-buzz-list .upk-item:hover .upk-meta .upk-author-wrap .upk-author-name' => 'color: {{VALUE}};',
476 ],
477 ]
478 );
479
480 $this->add_responsive_control(
481 'meta_spacing',
482 [
483 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
484 'type' => Controls_Manager::SLIDER,
485 'range' => [
486 'px' => [
487 'min' => 0,
488 'max' => 50,
489 ],
490 ],
491 'selectors' => [
492 '{{WRAPPER}} .upk-buzz-list .upk-meta' => 'padding-top: {{SIZE}}{{UNIT}};',
493 ],
494 ]
495 );
496
497 // $this->add_responsive_control(
498 // 'meta_space_between',
499 // [
500 // 'label' => esc_html__('Space Between', 'ultimate-post-kit'),
501 // 'type' => Controls_Manager::SLIDER,
502 // 'range' => [
503 // 'px' => [
504 // 'min' => 0,
505 // 'max' => 50,
506 // ],
507 // ],
508 // 'selectors' => [
509 // '{{WRAPPER}} .upk-buzz-list .upk-meta .upk-separator' => 'margin: 0 {{SIZE}}{{UNIT}};',
510 // ],
511 // ]
512 // );
513 $this->add_responsive_control(
514 'meta_space_between',
515 [
516 'label' => esc_html__('Space Between', 'ultimate-post-kit'),
517 'type' => Controls_Manager::SLIDER,
518 'range' => [
519 'px' => [
520 'min' => 0,
521 'max' => 50,
522 ],
523 ],
524 'selectors' => [
525 '{{WRAPPER}} .upk-buzz-list .upk-meta > div:before' => 'margin: 0 {{SIZE}}{{UNIT}};',
526 ],
527 ]
528 );
529
530 $this->add_group_control(
531 Group_Control_Typography::get_type(),
532 [
533 'name' => 'meta_typography',
534 'label' => esc_html__('Typography', 'ultimate-post-kit'),
535 'selector' => '{{WRAPPER}} .upk-buzz-list .upk-meta',
536 ]
537 );
538
539 $this->end_controls_section();
540
541 $this->start_controls_section(
542 'section_style_category',
543 [
544 'label' => esc_html__('Category', 'ultimate-post-kit'),
545 'tab' => Controls_Manager::TAB_STYLE,
546 'condition' => [
547 'show_category' => 'yes',
548 ],
549 ]
550 );
551
552 $this->add_responsive_control(
553 'category_bottom_spacing',
554 [
555 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
556 'type' => Controls_Manager::SLIDER,
557 'range' => [
558 'px' => [
559 'min' => 0,
560 'max' => 50,
561 ],
562 ],
563 'selectors' => [
564 '{{WRAPPER}} .upk-buzz-list .upk-category' => 'margin-bottom: {{SIZE}}{{UNIT}};',
565 ],
566 ]
567 );
568
569 $this->start_controls_tabs('tabs_category_style');
570
571 $this->start_controls_tab(
572 'tab_category_normal',
573 [
574 'label' => esc_html__('Normal', 'ultimate-post-kit'),
575 ]
576 );
577
578 $this->add_control(
579 'category_color',
580 [
581 'label' => esc_html__('Color', 'ultimate-post-kit'),
582 'type' => Controls_Manager::COLOR,
583 'selectors' => [
584 '{{WRAPPER}} .upk-buzz-list .upk-category a' => 'color: {{VALUE}};',
585 ],
586 ]
587 );
588
589 $this->add_group_control(
590 Group_Control_Background::get_type(),
591 [
592 'name' => 'category_background',
593 'selector' => '{{WRAPPER}} .upk-buzz-list .upk-category a',
594 ]
595 );
596
597 $this->add_group_control(
598 Group_Control_Border::get_type(),
599 [
600 'name' => 'category_border',
601 'selector' => '{{WRAPPER}} .upk-buzz-list .upk-category a',
602 ]
603 );
604
605 $this->add_responsive_control(
606 'category_border_radius',
607 [
608 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
609 'type' => Controls_Manager::DIMENSIONS,
610 'size_units' => ['px', '%'],
611 'selectors' => [
612 '{{WRAPPER}} .upk-buzz-list .upk-category a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
613 ],
614 ]
615 );
616
617 $this->add_responsive_control(
618 'category_padding',
619 [
620 'label' => esc_html__('Padding', 'ultimate-post-kit'),
621 'type' => Controls_Manager::DIMENSIONS,
622 'size_units' => ['px', 'em', '%'],
623 'selectors' => [
624 '{{WRAPPER}} .upk-buzz-list .upk-category a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
625 ],
626 ]
627 );
628
629 $this->add_responsive_control(
630 'category_spacing',
631 [
632 'label' => esc_html__('Space Between', 'ultimate-post-kit'),
633 'type' => Controls_Manager::SLIDER,
634 'range' => [
635 'px' => [
636 'min' => 0,
637 'max' => 50,
638 'step' => 2,
639 ],
640 ],
641 'selectors' => [
642 '{{WRAPPER}} .upk-buzz-list .upk-category a+a' => 'margin-left: {{SIZE}}{{UNIT}};',
643 ],
644 ]
645 );
646
647 $this->add_group_control(
648 Group_Control_Box_Shadow::get_type(),
649 [
650 'name' => 'category_shadow',
651 'selector' => '{{WRAPPER}} .upk-buzz-list .upk-category a',
652 ]
653 );
654
655 $this->add_group_control(
656 Group_Control_Typography::get_type(),
657 [
658 'name' => 'category_typography',
659 'label' => esc_html__('Typography', 'ultimate-post-kit'),
660 'selector' => '{{WRAPPER}} .upk-buzz-list .upk-category a',
661 ]
662 );
663
664 $this->end_controls_tab();
665
666 $this->start_controls_tab(
667 'tab_category_hover',
668 [
669 'label' => esc_html__('Hover', 'ultimate-post-kit'),
670 ]
671 );
672
673 $this->add_control(
674 'category_hover_color',
675 [
676 'label' => esc_html__('Color', 'ultimate-post-kit'),
677 'type' => Controls_Manager::COLOR,
678 'selectors' => [
679 '{{WRAPPER}} .upk-buzz-list .upk-item:hover .upk-category a' => 'color: {{VALUE}};',
680 ],
681 ]
682 );
683
684 $this->add_group_control(
685 Group_Control_Background::get_type(),
686 [
687 'name' => 'category_hover_background',
688 'selector' => '{{WRAPPER}} .upk-buzz-list .upk-item:hover .upk-category a',
689 ]
690 );
691
692 $this->add_control(
693 'category_hover_border_color',
694 [
695 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
696 'type' => Controls_Manager::COLOR,
697 'condition' => [
698 'category_border_border!' => '',
699 ],
700 'selectors' => [
701 '{{WRAPPER}} .upk-buzz-list .upk-item:hover .upk-category a' => 'border-color: {{VALUE}};',
702 ],
703 ]
704 );
705
706 $this->end_controls_tab();
707
708 $this->end_controls_tabs();
709
710 $this->end_controls_section();
711
712 $this->start_controls_section(
713 'section_style_counter_number',
714 [
715 'label' => esc_html__('Counter Number', 'ultimate-post-kit'),
716 'tab' => Controls_Manager::TAB_STYLE,
717 ]
718 );
719
720 $this->add_control(
721 'counter_number_color',
722 [
723 'label' => esc_html__('Color', 'ultimate-post-kit'),
724 'type' => Controls_Manager::COLOR,
725 'selectors' => [
726 '{{WRAPPER}} .upk-buzz-list .upk-count:before' => 'color: {{VALUE}};',
727 ],
728 ]
729 );
730
731 $this->add_control(
732 'counter_number_hover_color',
733 [
734 'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
735 'type' => Controls_Manager::COLOR,
736 'selectors' => [
737 '{{WRAPPER}} .upk-buzz-list .upk-item:hover .upk-count:before' => 'color: {{VALUE}};',
738 ],
739 ]
740 );
741
742 $this->add_control(
743 'counter_line_color',
744 [
745 'label' => esc_html__('Line Color', 'ultimate-post-kit'),
746 'type' => Controls_Manager::COLOR,
747 'selectors' => [
748 '{{WRAPPER}} .upk-buzz-list .upk-inner' => 'border-left-color: {{VALUE}};',
749 ],
750 'separator' => 'before'
751 ]
752 );
753
754 $this->add_control(
755 'counter_line_hover_color',
756 [
757 'label' => esc_html__('Hover Line Color', 'ultimate-post-kit'),
758 'type' => Controls_Manager::COLOR,
759 'selectors' => [
760 '{{WRAPPER}} .upk-buzz-list .upk-item:hover .upk-inner' => 'border-left-color: {{VALUE}};',
761 ],
762 ]
763 );
764
765 $this->add_responsive_control(
766 'counter_number_spacing',
767 [
768 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
769 'type' => Controls_Manager::SLIDER,
770 'range' => [
771 'px' => [
772 'min' => 0,
773 'max' => 50,
774 ],
775 ],
776 'selectors' => [
777 '{{WRAPPER}} .upk-buzz-list .upk-count' => 'padding-right: {{SIZE}}{{UNIT}};',
778 '{{WRAPPER}} .upk-buzz-list .upk-inner' => 'padding-left: {{SIZE}}{{UNIT}};',
779 ],
780 'separator' => 'before'
781 ]
782 );
783
784 $this->add_group_control(
785 Group_Control_Typography::get_type(),
786 [
787 'name' => 'counter_number_typography',
788 'label' => esc_html__('Typography', 'ultimate-post-kit'),
789 'selector' => '{{WRAPPER}} .upk-buzz-list .upk-count:before',
790 ]
791 );
792
793 $this->end_controls_section();
794
795 //Global Pagination Controls
796 $this->register_pagination_controls();
797
798 //Global Ajax Loadmore Style Controls
799 $this->register_ajax_loadmore_style_controls();
800 }
801
802 /**
803 * Main query render for this widget
804 * @param $posts_per_page number item query limit
805 */
806 public function query_posts($posts_per_page) {
807
808 $default = $this->getGroupControlQueryArgs();
809 $args = [];
810 if ($posts_per_page) {
811 $args['posts_per_page'] = $posts_per_page;
812 $args['paged'] = max(1, get_query_var('paged'), get_query_var('page'));
813 }
814 $args = array_merge($default, $args);
815 $this->_query = new WP_Query($args);
816 }
817
818 public function render_author() {
819
820 if (!$this->get_settings('show_author')) {
821 return;
822 }
823 ?>
824 <div class="upk-author-wrap">
825 <span class="upk-by"><?php echo esc_html_x('by', 'Frontend', 'ultimate-post-kit') ?></span>
826 <a class="upk-author-name" href="<?php echo esc_url( get_author_posts_url(get_the_author_meta('ID')) ); ?>">
827 <?php echo esc_html( get_the_author() ) ?>
828 </a>
829 </div>
830 <?php
831 }
832
833 public function render_comments($id = 0) {
834
835 if (!$this->get_settings('show_comments')) {
836 return;
837 }
838 ?>
839
840 <div class="upk-comments">
841 <?php echo get_comments_number($id) ?>
842 <?php echo esc_html_x('Comments', 'Frontend', 'ultimate-post-kit') ?>
843 </div>
844
845 <?php
846 }
847
848 public function render_post_grid_item($post_id, $image_size) {
849 $settings = $this->get_settings_for_display();
850
851 if ('yes' == $settings['global_link']) {
852
853 $this->add_render_attribute('list-item', 'onclick', "window.open('" . esc_url(get_permalink()) . "', '_self')", true);
854 }
855 $this->add_render_attribute('list-item', 'class', 'upk-item upk-flex upk-flex-middle', true);
856
857 ?>
858 <div <?php $this->print_render_attribute_string('list-item'); ?>>
859 <div class="upk-img-wrap">
860 <?php $this->render_image(get_post_thumbnail_id($post_id), $image_size); ?>
861 </div>
862 <div class="upk-content">
863 <div class="upk-count"></div>
864 <div class="upk-inner">
865 <?php $this->render_category(); ?>
866 <?php $this->render_title(substr($this->get_name(), 4)); ?>
867 <?php if ($settings['show_author'] or $settings['show_comments'] or $settings['show_date'] or $settings['show_reading_time']) : ?>
868 <div class="upk-meta upk-flex upk-flex-middle">
869 <?php if ($settings['show_author']) : ?>
870 <?php $this->render_author(); ?>
871 <?php endif; ?>
872
873 <?php if ($settings['show_date']) : ?>
874 <div data-separator="<?php echo esc_html($settings['meta_separator']); ?>">
875 <?php $this->render_date(); ?>
876 </div>
877 <?php endif; ?>
878
879 <?php if (_is_upk_pro_activated()) :
880 if ('yes' === $settings['show_reading_time']) : ?>
881 <div class="upk-reading-time" data-separator="<?php echo esc_html($settings['meta_separator']); ?>">
882 <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'], $settings['hide_seconds'] ?? 'no', $settings['hide_minutes'] ?? 'no' ) ); ?>
883 </div>
884 <?php endif; ?>
885 <?php endif; ?>
886
887 <?php if ($settings['show_comments']) : ?>
888 <div data-separator="<?php echo esc_html($settings['meta_separator']); ?>">
889 <?php $this->render_comments($post_id); ?>
890 </div>
891 <?php endif; ?>
892
893 </div>
894 <?php endif; ?>
895 </div>
896 </div>
897 </div>
898 <?php
899 }
900
901 protected function render() {
902 $settings = $this->get_settings_for_display();
903
904 $this->query_posts($settings['item_limit']['size']);
905 $wp_query = $this->get_query();
906
907 if (!$wp_query->found_posts) {
908 return;
909 }
910
911 $this->add_render_attribute(
912 [
913 'upk-buzz-list' => [
914 'class' => 'upk-buzz-list-container upk-ajax-grid',
915 'data-loadmore' => [
916 wp_json_encode(
917 array_filter([
918 'loadmore_enable' => $settings['ajax_loadmore_enable'],
919 'loadmore_btn' => $settings['ajax_loadmore_btn'],
920 'infinite_scroll' => $settings['ajax_loadmore_infinite_scroll'],
921 ])
922 ),
923 ],
924 ],
925 ]
926 );
927
928 if ($settings['ajax_loadmore_enable'] == 'yes') {
929 $ajax_settings = [
930 'posts_source' => isset($settings['posts_source']) ? $settings['posts_source'] : 'post',
931 'posts_per_page' => isset($settings['item_limit']['size']) ? $settings['item_limit']['size'] : 6,
932 'ajax_item_load' => isset($settings['ajax_loadmore_items']) ? $settings['ajax_loadmore_items'] : 3,
933 'posts_selected_ids' => isset($settings['posts_selected_ids']) ? $settings['posts_selected_ids'] : '',
934 'posts_include_by' => isset($settings['posts_include_by']) ? $settings['posts_include_by'] : [],
935 'posts_include_author_ids' => isset($settings['posts_include_author_ids']) ? $settings['posts_include_author_ids'] : '',
936 'posts_include_term_ids' => isset($settings['posts_include_term_ids']) ? $settings['posts_include_term_ids'] : '',
937 'posts_exclude_by' => isset($settings['posts_exclude_by']) ? $settings['posts_exclude_by'] : [],
938 'posts_exclude_ids' => isset($settings['posts_exclude_ids']) ? $settings['posts_exclude_ids'] : '',
939 'posts_exclude_author_ids' => isset($settings['posts_exclude_author_ids']) ? $settings['posts_exclude_author_ids'] : '',
940 'posts_exclude_term_ids' => isset($settings['posts_exclude_term_ids']) ? $settings['posts_exclude_term_ids'] : '',
941 'posts_offset' => isset($settings['posts_offset']) ? $settings['posts_offset'] : 0,
942 'posts_select_date' => isset($settings['posts_select_date']) ? $settings['posts_select_date'] : '',
943 'posts_date_before' => isset($settings['posts_date_before']) ? $settings['posts_date_before'] : '',
944 'posts_date_after' => isset($settings['posts_date_after']) ? $settings['posts_date_after'] : '',
945 'posts_orderby' => isset($settings['posts_orderby']) ? $settings['posts_orderby'] : 'date',
946 'posts_order' => isset($settings['posts_order']) ? $settings['posts_order'] : 'DESC',
947 'posts_ignore_sticky_posts' => isset($settings['posts_ignore_sticky_posts']) ? $settings['posts_ignore_sticky_posts'] : 'no',
948 'posts_only_with_featured_image'=> isset($settings['posts_only_with_featured_image']) ? $settings['posts_only_with_featured_image'] : 'no',
949 // List Settings
950 'columns' => isset($settings['columns']) ? $settings['columns'] : '3',
951 'show_title' => isset($settings['show_title']) ? $settings['show_title'] : 'yes',
952 'title_tags' => isset( $settings['title_tags'] ) ? $settings['title_tags'] : 'h3',
953 'title_style' => isset($settings['title_style']) ? $settings['title_style'] : '',
954 'show_category' => isset($settings['show_category']) ? $settings['show_category'] : 'yes',
955 'show_author' => isset($settings['show_author']) ? $settings['show_author'] : 'yes',
956 'show_comments' => isset($settings['show_comments']) ? $settings['show_comments'] : 'no',
957 'meta_separator' => isset($settings['meta_separator']) ? $settings['meta_separator'] : '//',
958 'show_date' => isset($settings['show_date']) ? $settings['show_date'] : 'no',
959 'show_time' => isset($settings['show_time']) ? $settings['show_time'] : 'no',
960 'human_diff_time' => isset($settings['human_diff_time']) ? $settings['human_diff_time'] : 'no',
961 'human_diff_time_short' => isset($settings['human_diff_time_short']) ? $settings['human_diff_time_short'] : 'no',
962 'show_reading_time' => isset($settings['show_reading_time']) ? $settings['show_reading_time'] : 'no',
963 'avg_reading_speed' => isset($settings['avg_reading_speed']) ? $settings['avg_reading_speed'] : 200,
964 'hide_seconds' => isset($settings['hide_seconds']) ? $settings['hide_seconds'] : 'no',
965 'hide_minutes' => isset($settings['hide_minutes']) ? $settings['hide_minutes'] : 'no',
966 'primary_thumbnail_size' => isset($settings['primary_thumbnail_size']) ? $settings['primary_thumbnail_size'] : 'medium',
967 'upk_link_new_tab' => isset($settings['upk_link_new_tab']) ? $settings['upk_link_new_tab'] : 'no',
968 'global_link' => isset($settings['global_link']) ? $settings['global_link'] : 'no',
969 ];
970
971 $this->add_render_attribute(
972 [
973 'upk-buzz-list' => [
974 'data-settings' => [
975 wp_json_encode($ajax_settings)
976 ],
977 ],
978 ]
979 );
980 }
981
982 $this->add_render_attribute('list-wrap', 'class', 'upk-buzz-list upk-ajax-grid-wrap');
983
984 if (isset($settings['upk_in_animation_show']) && ($settings['upk_in_animation_show'] == 'yes')) {
985 $this->add_render_attribute('list-wrap', 'class', 'upk-in-animation');
986 if (isset($settings['upk_in_animation_delay']['size'])) {
987 $this->add_render_attribute('list-wrap', 'data-in-animation-delay', $settings['upk_in_animation_delay']['size']);
988 }
989 }
990
991 ?>
992 <div <?php $this->print_render_attribute_string('upk-buzz-list'); ?>>
993 <div <?php $this->print_render_attribute_string('list-wrap'); ?>>
994 <?php while ($wp_query->have_posts()) :
995 $wp_query->the_post();
996
997 $thumbnail_size = $settings['primary_thumbnail_size'];
998
999 ?>
1000
1001 <?php $this->render_post_grid_item(get_the_ID(), $thumbnail_size); ?>
1002
1003 <?php endwhile; ?>
1004 </div>
1005 </div>
1006
1007 <?php $this->render_ajax_loadmore(); ?>
1008
1009 <?php
1010
1011 if ($settings['show_pagination']) { ?>
1012 <div class="ep-pagination">
1013 <?php ultimate_post_kit_post_pagination($wp_query, $this->get_id()); ?>
1014 </div>
1015 <?php
1016 }
1017 wp_reset_postdata();
1018 }
1019 }
1020