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

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

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