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

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