PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / 4.5.6
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets v4.5.6
4.5.6 4.5.5 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 All 148 releases
ultimate-post-kit / modules / scott-list / widgets / scott-list.php

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

994 lines 28.6 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\ScottList\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 UltimatePostKit\Utils;
13
14 use UltimatePostKit\Traits\Global_Widget_Controls;
15 use UltimatePostKit\Traits\Global_Widget_Functions;
16 use UltimatePostKit\Includes\Controls\GroupQuery\Group_Control_Query;
17 use WP_Query;
18
19 if (!defined('ABSPATH')) {
20 exit; // Exit if accessed directly
21 }
22
23 class Scott_List extends Group_Control_Query {
24
25 use Global_Widget_Controls;
26 use Global_Widget_Functions;
27
28 private $_query = null;
29
30 public function get_name() {
31 return 'upk-scott-list';
32 }
33
34 public function get_title() {
35 return BDTUPK . esc_html__('Scott List', 'ultimate-post-kit');
36 }
37
38 public function get_icon() {
39 return 'upk-widget-icon upk-icon-scott-list';
40 }
41
42 public function get_categories() {
43 return ['ultimate-post-kit'];
44 }
45
46 public function get_keywords() {
47 return ['post', 'grid', 'blog', 'recent', 'news', 'scott', 'list'];
48 }
49
50 public function get_style_depends() {
51 if ($this->upk_is_edit_mode()) {
52 return ['upk-all-styles'];
53 } else {
54 return ['upk-font', 'upk-scott-list'];
55 }
56 }
57
58 public function get_script_depends() {
59 if ($this->upk_is_edit_mode()) {
60 return ['upk-all-scripts'];
61 } else {
62 return ['upk-ajax-loadmore'];
63 }
64 }
65
66 public function get_custom_help_url() {
67 return 'https://youtu.be/twaysnvoWkM';
68 }
69
70 public function get_query() {
71 return $this->_query;
72 }
73
74 public function has_widget_inner_wrapper(): bool {
75 return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
76 }
77
78
79 protected function register_controls() {
80 $this->start_controls_section(
81 'section_content_layout',
82 [
83 'label' => esc_html__('Layout', 'ultimate-post-kit'),
84 ]
85 );
86
87 //Global Title Controls
88 $this->register_title_controls();
89
90 $this->add_control(
91 'show_category',
92 [
93 'label' => esc_html__('Show Category', 'ultimate-post-kit'),
94 'type' => Controls_Manager::SWITCHER,
95 'default' => 'yes',
96 ]
97 );
98
99 $this->add_control(
100 'show_author',
101 [
102 'label' => esc_html__('Show Author', 'ultimate-post-kit'),
103 'type' => Controls_Manager::SWITCHER,
104 'default' => 'yes',
105 'separator' => 'before'
106 ]
107 );
108
109 $this->add_control(
110 'show_comments',
111 [
112 'label' => esc_html__('Show Comments', 'ultimate-post-kit'),
113 'type' => Controls_Manager::SWITCHER,
114 ]
115 );
116
117 $this->add_control(
118 'meta_separator',
119 [
120 'label' => __('Separator', 'ultimate-post-kit'),
121 'type' => Controls_Manager::TEXT,
122 'default' => '//',
123 'label_block' => false,
124 ]
125 );
126
127 //Global Date Controls
128 $this->register_date_controls();
129
130 //Global Reading Time Controls
131 $this->register_reading_time_controls();
132
133 $this->add_control(
134 'hr',
135 [
136 'type' => Controls_Manager::DIVIDER,
137 ]
138 );
139
140 $this->add_group_control(
141 Group_Control_Image_Size::get_type(),
142 [
143 'name' => 'primary_thumbnail',
144 // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour.
145 'exclude' => ['custom'],
146 'default' => 'medium',
147 ]
148 );
149
150 $this->add_control(
151 'show_pagination',
152 [
153 'label' => esc_html__('Show Pagination', 'ultimate-post-kit'),
154 'type' => Controls_Manager::SWITCHER,
155 'separator' => 'before'
156 ]
157 );
158
159 //Global Ajax Controls
160 $this->register_ajax_loadmore_controls();
161
162 $this->add_control(
163 'global_link',
164 [
165 'label' => __('Item Wrapper Link', 'ultimate-post-kit'),
166 'type' => Controls_Manager::SWITCHER,
167 'prefix_class' => 'upk-global-link-',
168 'description' => __('Be aware! When Item Wrapper Link activated then title link and read more link will not work', 'ultimate-post-kit'),
169 ]
170 );
171
172 $this->end_controls_section();
173
174 // Query Settings
175 $this->start_controls_section(
176 'section_post_query_builder',
177 [
178 'label' => esc_html__('Query', 'ultimate-post-kit'),
179 'tab' => Controls_Manager::TAB_CONTENT,
180 ]
181 );
182
183 $this->add_control(
184 'item_limit',
185 [
186 'label' => esc_html__('Item Limit', 'ultimate-post-kit'),
187 'type' => Controls_Manager::SLIDER,
188 'range' => [
189 'px' => [
190 'min' => 1,
191 'max' => 20,
192 ],
193 ],
194 'default' => [
195 'size' => 3,
196 ],
197 'condition' => [
198 'posts_source!' => 'current_query',
199 ]
200 ]
201 );
202
203 $this->register_query_builder_controls();
204
205 $this->end_controls_section();
206
207 //Style
208 $this->start_controls_section(
209 'upk_section_style',
210 [
211 'label' => esc_html__('Item', 'ultimate-post-kit'),
212 'tab' => Controls_Manager::TAB_STYLE,
213 ]
214 );
215
216 $this->add_control(
217 'item_border_style',
218 [
219 'label' => esc_html__('Border Style', 'ultimate-post-kit'),
220 'type' => Controls_Manager::SELECT,
221 'default' => 'solid',
222 'options' => [
223 'none' => esc_html__('None', 'ultimate-post-kit'),
224 'solid' => esc_html__('Solid', 'ultimate-post-kit'),
225 'dashed' => esc_html__('Dashed', 'ultimate-post-kit'),
226 'dotted' => esc_html__('Dotted', 'ultimate-post-kit'),
227 'double' => esc_html__('Double', 'ultimate-post-kit'),
228 ],
229 'selectors' => [
230 '{{WRAPPER}} .upk-scott-list .upk-item' => 'border-top-style: {{VALUE}};',
231 ],
232 ]
233 );
234
235 $this->add_control(
236 'item_border_color',
237 [
238 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
239 'type' => Controls_Manager::COLOR,
240 'selectors' => [
241 '{{WRAPPER}} .upk-scott-list .upk-item' => 'border-top-color: {{VALUE}};',
242 ],
243 'condition' => [
244 'item_border_style!' => 'none'
245 ]
246 ]
247 );
248
249 $this->add_responsive_control(
250 'item_border_width',
251 [
252 'label' => esc_html__('Border Width', 'ultimate-post-kit'),
253 'type' => Controls_Manager::SLIDER,
254 'range' => [
255 'px' => [
256 'min' => 0,
257 'max' => 50,
258 ],
259 ],
260 'selectors' => [
261 '{{WRAPPER}} .upk-scott-list .upk-item' => 'border-top-width: {{SIZE}}{{UNIT}};',
262 ],
263 'condition' => [
264 'item_border_style!' => 'none'
265 ]
266 ]
267 );
268
269 $this->add_responsive_control(
270 'item_border_spacing',
271 [
272 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
273 'type' => Controls_Manager::SLIDER,
274 'range' => [
275 'px' => [
276 'min' => 0,
277 'max' => 50,
278 ],
279 ],
280 'selectors' => [
281 '{{WRAPPER}} .upk-scott-list .upk-item' => 'padding-top: {{SIZE}}{{UNIT}}; margin-top: {{SIZE}}{{UNIT}};',
282 ],
283 ]
284 );
285
286 $this->add_responsive_control(
287 'content_padding',
288 [
289 'label' => esc_html__('Content Padding', 'ultimate-post-kit'),
290 'type' => Controls_Manager::DIMENSIONS,
291 'size_units' => ['px', 'em', '%'],
292 'selectors' => [
293 '{{WRAPPER}} .upk-scott-list .upk-item .upk-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
294 ],
295 'separator' => 'before'
296 ]
297 );
298
299 $this->end_controls_section();
300
301 $this->start_controls_section(
302 'section_style_title',
303 [
304 'label' => esc_html__('Title', 'ultimate-post-kit'),
305 'tab' => Controls_Manager::TAB_STYLE,
306 'condition' => [
307 'show_title' => 'yes',
308 ],
309 ]
310 );
311
312 $this->add_control(
313 'title_style',
314 [
315 'label' => esc_html__('Style', 'ultimate-post-kit'),
316 'type' => Controls_Manager::SELECT,
317 'default' => 'underline',
318 'options' => [
319 'underline' => esc_html__('Style 01', 'ultimate-post-kit'),
320 'middle-underline' => esc_html__('Style 02', 'ultimate-post-kit'),
321 'overline' => esc_html__('Style 03', 'ultimate-post-kit'),
322 'middle-overline' => esc_html__('Style 04', 'ultimate-post-kit'),
323 'style-5' => esc_html__('Style 05', 'ultimate-post-kit'),
324 'style-6' => esc_html__('Style 06', 'ultimate-post-kit'),
325 ],
326 ]
327 );
328
329 $this->add_control(
330 'title_color',
331 [
332 'label' => esc_html__('Color', 'ultimate-post-kit'),
333 'type' => Controls_Manager::COLOR,
334 'selectors' => [
335 '{{WRAPPER}} .upk-scott-list .upk-item .upk-title a' => 'color: {{VALUE}};',
336 ],
337 'separator' => 'before'
338 ]
339 );
340
341 $this->add_control(
342 'title_hover_color',
343 [
344 'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
345 'type' => Controls_Manager::COLOR,
346 'selectors' => [
347 '{{WRAPPER}} .upk-scott-list .upk-item .upk-title a:hover' => 'color: {{VALUE}};',
348 ],
349 ]
350 );
351
352 $this->add_group_control(
353 Group_Control_Typography::get_type(),
354 [
355 'name' => 'title_typography',
356 'label' => esc_html__('Typography', 'ultimate-post-kit'),
357 'selector' => '{{WRAPPER}} .upk-scott-list .upk-item .upk-title',
358 ]
359 );
360
361 $this->add_group_control(
362 Group_Control_Text_Shadow::get_type(),
363 [
364 'name' => 'title_text_shadow',
365 'label' => __('Text Shadow', 'ultimate-post-kit'),
366 'selector' => '{{WRAPPER}} .upk-scott-list .upk-item .upk-title a',
367 ]
368 );
369
370 $this->end_controls_section();
371
372 $this->start_controls_section(
373 'section_style_meta',
374 [
375 'label' => esc_html__('Meta', 'ultimate-post-kit'),
376 'tab' => Controls_Manager::TAB_STYLE,
377 'conditions' => [
378 'relation' => 'or',
379 'terms' => [
380 [
381 'name' => 'show_author',
382 'value' => 'yes'
383 ],
384 [
385 'name' => 'show_date',
386 'value' => 'yes'
387 ],
388 [
389 'name' => 'show_comments',
390 'value' => 'yes'
391 ]
392 ]
393 ],
394 ]
395 );
396
397 $this->add_control(
398 'meta_color',
399 [
400 'label' => esc_html__('Color', 'ultimate-post-kit'),
401 'type' => Controls_Manager::COLOR,
402 'selectors' => [
403 '{{WRAPPER}} .upk-scott-list .upk-item .upk-meta, {{WRAPPER}} .upk-scott-list .upk-item .upk-meta .upk-author-name-wrap .upk-author-name' => 'color: {{VALUE}};',
404 ],
405 ]
406 );
407
408 $this->add_control(
409 'meta_hover_color',
410 [
411 'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
412 'type' => Controls_Manager::COLOR,
413 'selectors' => [
414 '{{WRAPPER}} .upk-scott-list .upk-item .upk-meta .upk-author-name-wrap .upk-author-name:hover' => 'color: {{VALUE}};',
415 ],
416 ]
417 );
418
419 $this->add_responsive_control(
420 'meta_spacing',
421 [
422 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
423 'type' => Controls_Manager::SLIDER,
424 'range' => [
425 'px' => [
426 'min' => 0,
427 'max' => 50,
428 ],
429 ],
430 'selectors' => [
431 '{{WRAPPER}} .upk-scott-list .upk-item .upk-meta' => 'padding-top: {{SIZE}}{{UNIT}};',
432 ],
433 ]
434 );
435
436 $this->add_responsive_control(
437 'meta_space_between',
438 [
439 'label' => esc_html__('Space Between', 'ultimate-post-kit'),
440 'type' => Controls_Manager::SLIDER,
441 'range' => [
442 'px' => [
443 'min' => 0,
444 'max' => 50,
445 ],
446 ],
447 'selectors' => [
448 '{{WRAPPER}} .upk-scott-list .upk-item .upk-meta > div:before' => 'margin: 0 {{SIZE}}{{UNIT}};',
449 ],
450 ]
451 );
452
453 $this->add_group_control(
454 Group_Control_Typography::get_type(),
455 [
456 'name' => 'meta_typography',
457 'label' => esc_html__('Typography', 'ultimate-post-kit'),
458 'selector' => '{{WRAPPER}} .upk-scott-list .upk-item .upk-meta',
459 ]
460 );
461
462 $this->end_controls_section();
463
464 $this->start_controls_section(
465 'section_style_category',
466 [
467 'label' => esc_html__('Category', 'ultimate-post-kit'),
468 'tab' => Controls_Manager::TAB_STYLE,
469 'condition' => [
470 'show_category' => 'yes',
471 ],
472 ]
473 );
474
475 $this->add_responsive_control(
476 'category_bottom_spacing',
477 [
478 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
479 'type' => Controls_Manager::SLIDER,
480 'range' => [
481 'px' => [
482 'min' => 0,
483 'max' => 50,
484 ],
485 ],
486 'selectors' => [
487 '{{WRAPPER}} .upk-scott-list .upk-item .upk-category' => 'margin-bottom: {{SIZE}}{{UNIT}};',
488 ],
489 ]
490 );
491
492 $this->start_controls_tabs('tabs_category_style');
493
494 $this->start_controls_tab(
495 'tab_category_normal',
496 [
497 'label' => esc_html__('Normal', 'ultimate-post-kit'),
498 ]
499 );
500
501 $this->add_control(
502 'category_color',
503 [
504 'label' => esc_html__('Color', 'ultimate-post-kit'),
505 'type' => Controls_Manager::COLOR,
506 'selectors' => [
507 '{{WRAPPER}} .upk-scott-list .upk-item .upk-category a' => 'color: {{VALUE}};',
508 ],
509 ]
510 );
511
512 $this->add_group_control(
513 Group_Control_Background::get_type(),
514 [
515 'name' => 'category_background',
516 'selector' => '{{WRAPPER}} .upk-scott-list .upk-item .upk-category a',
517 ]
518 );
519
520 $this->add_group_control(
521 Group_Control_Border::get_type(),
522 [
523 'name' => 'category_border',
524 'selector' => '{{WRAPPER}} .upk-scott-list .upk-item .upk-category a',
525 ]
526 );
527
528 $this->add_responsive_control(
529 'category_border_radius',
530 [
531 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
532 'type' => Controls_Manager::DIMENSIONS,
533 'size_units' => ['px', '%'],
534 'selectors' => [
535 '{{WRAPPER}} .upk-scott-list .upk-item .upk-category a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
536 ],
537 ]
538 );
539
540 $this->add_responsive_control(
541 'category_padding',
542 [
543 'label' => esc_html__('Padding', 'ultimate-post-kit'),
544 'type' => Controls_Manager::DIMENSIONS,
545 'size_units' => ['px', 'em', '%'],
546 'selectors' => [
547 '{{WRAPPER}} .upk-scott-list .upk-item .upk-category a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
548 ],
549 ]
550 );
551
552 $this->add_responsive_control(
553 'category_spacing',
554 [
555 'label' => esc_html__('Space Between', 'ultimate-post-kit'),
556 'type' => Controls_Manager::SLIDER,
557 'range' => [
558 'px' => [
559 'min' => 0,
560 'max' => 50,
561 'step' => 2,
562 ],
563 ],
564 'selectors' => [
565 '{{WRAPPER}} .upk-scott-list .upk-item .upk-category a+a' => 'margin-left: {{SIZE}}{{UNIT}};',
566 ],
567 ]
568 );
569
570 $this->add_group_control(
571 Group_Control_Box_Shadow::get_type(),
572 [
573 'name' => 'category_shadow',
574 'selector' => '{{WRAPPER}} .upk-scott-list .upk-item .upk-category a',
575 ]
576 );
577
578 $this->add_group_control(
579 Group_Control_Typography::get_type(),
580 [
581 'name' => 'category_typography',
582 'label' => esc_html__('Typography', 'ultimate-post-kit'),
583 'selector' => '{{WRAPPER}} .upk-scott-list .upk-item .upk-category a',
584 ]
585 );
586
587 $this->end_controls_tab();
588
589 $this->start_controls_tab(
590 'tab_category_hover',
591 [
592 'label' => esc_html__('Hover', 'ultimate-post-kit'),
593 ]
594 );
595
596 $this->add_control(
597 'category_hover_color',
598 [
599 'label' => esc_html__('Color', 'ultimate-post-kit'),
600 'type' => Controls_Manager::COLOR,
601 'selectors' => [
602 '{{WRAPPER}} .upk-scott-list .upk-item .upk-category a:hover' => 'color: {{VALUE}};',
603 ],
604 ]
605 );
606
607 $this->add_group_control(
608 Group_Control_Background::get_type(),
609 [
610 'name' => 'category_hover_background',
611 'selector' => '{{WRAPPER}} .upk-scott-list .upk-item .upk-category a:hover',
612 ]
613 );
614
615 $this->add_control(
616 'category_hover_border_color',
617 [
618 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
619 'type' => Controls_Manager::COLOR,
620 'condition' => [
621 'category_border_border!' => '',
622 ],
623 'selectors' => [
624 '{{WRAPPER}} .upk-scott-list .upk-item .upk-category a:hover' => 'border-color: {{VALUE}};',
625 ],
626 ]
627 );
628
629 $this->end_controls_tab();
630
631 $this->end_controls_tabs();
632
633 $this->end_controls_section();
634
635 $this->start_controls_section(
636 'section_style_counter_number',
637 [
638 'label' => esc_html__('Image', 'ultimate-post-kit'),
639 'tab' => Controls_Manager::TAB_STYLE,
640 ]
641 );
642
643 $this->add_control(
644 'image_overlay_color',
645 [
646 'label' => esc_html__('Overlay Color', 'ultimate-post-kit'),
647 'type' => Controls_Manager::COLOR,
648 'selectors' => [
649 '{{WRAPPER}} .upk-scott-list .upk-item .upk-image-wrap .upk-img-overlay:before' => 'background: {{VALUE}};',
650 ],
651 ]
652 );
653
654 $this->add_group_control(
655 Group_Control_Border::get_type(),
656 [
657 'name' => 'image_border',
658 'selector' => '{{WRAPPER}} .upk-scott-list .upk-item .upk-image-wrap',
659 ]
660 );
661
662 $this->add_responsive_control(
663 'image_border_radius',
664 [
665 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
666 'type' => Controls_Manager::DIMENSIONS,
667 'size_units' => ['px', '%'],
668 'selectors' => [
669 '{{WRAPPER}} .upk-scott-list .upk-item .upk-image-wrap, {{WRAPPER}} .upk-scott-list .upk-item .upk-image-wrap img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
670 ],
671 ]
672 );
673
674 $this->add_responsive_control(
675 'image_padding',
676 [
677 'label' => esc_html__('Padding', 'ultimate-post-kit'),
678 'type' => Controls_Manager::DIMENSIONS,
679 'size_units' => ['px', 'em', '%'],
680 'selectors' => [
681 '{{WRAPPER}} .upk-scott-list .upk-item .upk-image-wrap' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
682 ],
683 ]
684 );
685
686 $this->add_control(
687 'counter_number_heading',
688 [
689 'label' => esc_html__('Counter Number', 'ultimate-post-kit'),
690 'type' => Controls_Manager::HEADING,
691 'separator' => 'before'
692 ]
693 );
694
695 $this->add_control(
696 'counter_number_color',
697 [
698 'label' => esc_html__('Color', 'ultimate-post-kit'),
699 'type' => Controls_Manager::COLOR,
700 'selectors' => [
701 '{{WRAPPER}} .upk-scott-list .upk-item .upk-image-wrap:before' => 'color: {{VALUE}};',
702 ],
703 ]
704 );
705
706 $this->add_group_control(
707 Group_Control_Typography::get_type(),
708 [
709 'name' => 'counter_number_typography',
710 'label' => esc_html__('Typography', 'ultimate-post-kit'),
711 'selector' => '{{WRAPPER}} .upk-scott-list .upk-item .upk-image-wrap:before',
712 ]
713 );
714
715
716 $this->add_control(
717 'icon_heading',
718 [
719 'label' => esc_html__('Icon', 'ultimate-post-kit'),
720 'type' => Controls_Manager::HEADING,
721 'separator' => 'before'
722 ]
723 );
724
725 $this->add_control(
726 'icon_color',
727 [
728 'label' => esc_html__('Color', 'ultimate-post-kit'),
729 'type' => Controls_Manager::COLOR,
730 'selectors' => [
731 '{{WRAPPER}} .upk-scott-list .upk-item .upk-image-wrap:after' => 'color: {{VALUE}};',
732 ],
733 ]
734 );
735
736 $this->add_group_control(
737 Group_Control_Typography::get_type(),
738 [
739 'name' => 'icon_typography',
740 'label' => esc_html__('Typography', 'ultimate-post-kit'),
741 'selector' => '{{WRAPPER}} .upk-scott-list .upk-item .upk-image-wrap:after',
742 ]
743 );
744
745 $this->end_controls_section();
746
747 //Global Pagination Controls
748 $this->register_pagination_controls();
749
750 //Global Ajax Loadmore Style Controls
751 $this->register_ajax_loadmore_style_controls();
752 }
753
754 /**
755 * Get post query builder arguments
756 */
757 public function query_posts( $posts_per_page ) {
758 $settings = $this->get_settings();
759 $posts_per_page = isset( $posts_per_page ) ? (int) $posts_per_page : 0;
760 $args = $this->getGroupControlQueryArgs();
761 $is_current_query = ( ! empty( $settings['posts_source'] ) && $settings['posts_source'] === 'current_query' );
762
763 if ( $is_current_query ) {
764 unset( $args['offset'] );
765 unset( $args['no_found_rows'] );
766 $posts_per_page = 0;
767 }
768
769 if ( $posts_per_page > 0 ) {
770 $args['posts_per_page'] = $posts_per_page;
771 } else {
772 $args['posts_per_page'] = (int) get_option( 'posts_per_page', 10 );
773 }
774
775 if ( $settings['show_pagination'] ) {
776 $args['paged'] = max( 1, (int) get_query_var( 'paged' ), (int) get_query_var( 'page' ) );
777 }
778
779 $this->_query = new \WP_Query( $args );
780 }
781
782 public function render_image($image_id, $size) {
783 $placeholder_image_src = Utils::get_placeholder_image_src();
784
785 $image_src = wp_get_attachment_image_src($image_id, $size);
786
787 if (!$image_src) {
788 $image_src = $placeholder_image_src;
789 } else {
790 $image_src = $image_src[0];
791 }
792
793 ?>
794 <a class="upk-image-wrap" href="<?php echo esc_url(get_permalink()) ?>">
795 <img src="<?php echo esc_url($image_src); ?>" alt="<?php echo esc_attr(get_the_title()); ?>">
796 <span class="upk-img-overlay"></span>
797 </a>
798 <?php
799 }
800
801 public function render_author() {
802
803 if (!$this->get_settings('show_author')) {
804 return;
805 }
806 ?>
807 <div class="upk-author-name-wrap">
808 <span class="upk-by"><?php echo esc_html_x('by', 'Frontend', 'ultimate-post-kit') ?></span>
809 <a class="upk-author-name" href="<?php echo esc_url( get_author_posts_url(get_the_author_meta('ID')) ); ?>">
810 <?php echo esc_html( get_the_author() ) ?>
811 </a>
812 </div>
813 <?php
814 }
815
816 public function render_comments($id = 0) {
817
818 if (!$this->get_settings('show_comments')) {
819 return;
820 }
821 ?>
822
823 <div class="upk-scott-comments">
824 <?php echo esc_html( $this->upk_get_formatted_comments_count( $id ) ); ?>
825 </div>
826
827 <?php
828 }
829
830 public function render_post_grid_item($post_id, $image_size) {
831 $settings = $this->get_settings_for_display();
832
833 if ('yes' == $settings['global_link']) {
834
835 $this->add_render_attribute('list-item', 'onclick', "window.open('" . esc_url(get_permalink()) . "', '_self')", true);
836 }
837 $this->add_render_attribute('list-item', 'class', 'upk-item', true);
838
839 ?>
840 <div <?php $this->print_render_attribute_string('list-item'); ?>>
841 <?php $this->render_image(get_post_thumbnail_id($post_id), $image_size); ?>
842 <div class="upk-content">
843 <?php $this->render_category(); ?>
844 <?php $this->render_title(substr($this->get_name(), 4)); ?>
845 <?php if ($settings['show_author'] or $settings['show_comments'] or $settings['show_date'] or $settings['show_reading_time']) : ?>
846 <div class="upk-meta upk-flex upk-flex-middle">
847 <?php $this->render_author(); ?>
848
849 <?php if ($settings['show_date'] == 'yes') : ?>
850 <div data-separator="<?php echo esc_attr($settings['meta_separator']); ?>">
851 <?php $this->render_date(); ?>
852 </div>
853 <?php endif; ?>
854
855 <?php if ($settings['show_comments']) : ?>
856 <div data-separator="<?php echo esc_attr($settings['meta_separator']); ?>">
857 <?php $this->render_comments($post_id); ?>
858 </div>
859 <?php endif; ?>
860
861 <?php if (_is_upk_pro_activated()) :
862 if ('yes' === $settings['show_reading_time']) : ?>
863 <div class="upk-reading-time" data-separator="<?php echo esc_attr($settings['meta_separator']); ?>">
864 <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'], $settings['hide_seconds'] ?? 'no', $settings['hide_minutes'] ?? 'no' ) ); ?>
865 </div>
866 <?php endif; ?>
867 <?php endif; ?>
868
869 </div>
870 <?php endif; ?>
871 </div>
872 </div>
873 <?php
874 }
875
876 protected function render() {
877 $settings = $this->get_settings_for_display();
878
879 $this->query_posts($settings['item_limit']['size']);
880 $wp_query = $this->get_query();
881
882 if (!$wp_query->found_posts) {
883 return;
884 }
885
886 $this->add_render_attribute(
887 [
888 'upk-scott-list' => [
889 'class' => 'upk-scott-list upk-ajax-grid',
890 'data-loadmore' => [
891 wp_json_encode(
892 array_filter([
893 'loadmore_enable' => $settings['ajax_loadmore_enable'],
894 'loadmore_btn' => $settings['ajax_loadmore_btn'],
895 'infinite_scroll' => $settings['ajax_loadmore_infinite_scroll'],
896 ])
897 ),
898 ],
899 ],
900 ]
901 );
902
903 if ($settings['ajax_loadmore_enable'] == 'yes') {
904 $ajax_settings = [
905 'posts_source' => isset($settings['posts_source']) ? $settings['posts_source'] : 'post',
906 'posts_per_page' => isset($settings['item_limit']['size']) ? $settings['item_limit']['size'] : 3,
907 'ajax_item_load' => isset($settings['ajax_loadmore_items']) ? $settings['ajax_loadmore_items'] : 3,
908 'posts_selected_ids' => isset($settings['posts_selected_ids']) ? $settings['posts_selected_ids'] : '',
909 'posts_include_by' => isset($settings['posts_include_by']) ? $settings['posts_include_by'] : [],
910 'posts_include_author_ids' => isset($settings['posts_include_author_ids']) ? $settings['posts_include_author_ids'] : '',
911 'posts_include_term_ids' => isset($settings['posts_include_term_ids']) ? $settings['posts_include_term_ids'] : '',
912 'posts_exclude_by' => isset($settings['posts_exclude_by']) ? $settings['posts_exclude_by'] : [],
913 'posts_exclude_ids' => isset($settings['posts_exclude_ids']) ? $settings['posts_exclude_ids'] : '',
914 'posts_exclude_author_ids' => isset($settings['posts_exclude_author_ids']) ? $settings['posts_exclude_author_ids'] : '',
915 'posts_exclude_term_ids' => isset($settings['posts_exclude_term_ids']) ? $settings['posts_exclude_term_ids'] : '',
916 'posts_offset' => isset($settings['posts_offset']) ? $settings['posts_offset'] : 0,
917 'posts_select_date' => isset($settings['posts_select_date']) ? $settings['posts_select_date'] : '',
918 'posts_date_before' => isset($settings['posts_date_before']) ? $settings['posts_date_before'] : '',
919 'posts_date_after' => isset($settings['posts_date_after']) ? $settings['posts_date_after'] : '',
920 'posts_orderby' => isset($settings['posts_orderby']) ? $settings['posts_orderby'] : 'date',
921 'posts_order' => isset($settings['posts_order']) ? $settings['posts_order'] : 'DESC',
922 'posts_ignore_sticky_posts' => isset($settings['posts_ignore_sticky_posts']) ? $settings['posts_ignore_sticky_posts'] : 'no',
923 'posts_only_with_featured_image'=> isset($settings['posts_only_with_featured_image']) ? $settings['posts_only_with_featured_image'] : 'no',
924 // List Settings
925 'show_title' => isset($settings['show_title']) ? $settings['show_title'] : 'yes',
926 'title_tags' => isset( $settings['title_tags'] ) ? $settings['title_tags'] : 'h3',
927 'title_style' => isset($settings['title_style']) ? $settings['title_style'] : '',
928 'show_category' => isset($settings['show_category']) ? $settings['show_category'] : 'yes',
929 'show_author' => isset($settings['show_author']) ? $settings['show_author'] : 'yes',
930 'show_comments' => isset($settings['show_comments']) ? $settings['show_comments'] : 'no',
931 'meta_separator' => isset($settings['meta_separator']) ? $settings['meta_separator'] : '//',
932 'show_date' => isset($settings['show_date']) ? $settings['show_date'] : 'no',
933 'show_time' => isset($settings['show_time']) ? $settings['show_time'] : 'no',
934 'human_diff_time' => isset($settings['human_diff_time']) ? $settings['human_diff_time'] : 'no',
935 'human_diff_time_short' => isset($settings['human_diff_time_short']) ? $settings['human_diff_time_short'] : 'no',
936 'show_reading_time' => isset($settings['show_reading_time']) ? $settings['show_reading_time'] : 'no',
937 'avg_reading_speed' => isset($settings['avg_reading_speed']) ? $settings['avg_reading_speed'] : 200,
938 'hide_seconds' => isset($settings['hide_seconds']) ? $settings['hide_seconds'] : 'no',
939 'hide_minutes' => isset($settings['hide_minutes']) ? $settings['hide_minutes'] : 'no',
940 'primary_thumbnail_size' => isset($settings['primary_thumbnail_size']) ? $settings['primary_thumbnail_size'] : 'medium',
941 'upk_link_new_tab' => isset($settings['upk_link_new_tab']) ? $settings['upk_link_new_tab'] : 'no',
942 'global_link' => isset($settings['global_link']) ? $settings['global_link'] : 'no',
943 ];
944
945 $this->add_render_attribute(
946 [
947 'upk-scott-list' => [
948 'data-settings' => [
949 wp_json_encode($ajax_settings)
950 ],
951 ],
952 ]
953 );
954 }
955
956 $this->add_render_attribute('list-wrap', 'class', 'upk-scott-list upk-ajax-grid-wrap');
957
958 if (isset($settings['upk_in_animation_show']) && ($settings['upk_in_animation_show'] == 'yes')) {
959 $this->add_render_attribute('list-wrap', 'class', 'upk-in-animation');
960 if (isset($settings['upk_in_animation_delay']['size'])) {
961 $this->add_render_attribute('list-wrap', 'data-in-animation-delay', $settings['upk_in_animation_delay']['size']);
962 }
963 }
964
965 ?>
966 <div <?php $this->print_render_attribute_string('upk-scott-list'); ?>>
967 <div <?php $this->print_render_attribute_string('list-wrap'); ?>>
968 <?php while ($wp_query->have_posts()) :
969 $wp_query->the_post();
970
971 $thumbnail_size = $settings['primary_thumbnail_size'];
972
973 ?>
974
975 <?php $this->render_post_grid_item(get_the_ID(), $thumbnail_size); ?>
976
977 <?php endwhile; ?>
978 </div>
979 </div>
980
981 <?php $this->render_ajax_loadmore(); ?>
982
983 <?php
984
985 if ($settings['show_pagination']) { ?>
986 <div class="ep-pagination">
987 <?php ultimate_post_kit_post_pagination($wp_query, $this->get_id()); ?>
988 </div>
989 <?php
990 }
991 wp_reset_postdata();
992 }
993 }
994