PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / 4.5.3
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets v4.5.3
4.5.4 4.2.1 4.2.2 4.2.3 4.5.0 4.5.2 4.5.3 4.2.0 4.1.18 4.1.17 4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.0.9 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 All 146 releases
ultimate-post-kit / modules / buzz-list / widgets / buzz-list.php

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

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