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

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