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 / exotic-list / widgets / exotic-list.php

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

912 lines 23.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\ExoticList\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 Exotic_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-exotic-list';
31 }
32
33 public function get_title() {
34 return BDTUPK . esc_html__( 'Exotic List', 'ultimate-post-kit' );
35 }
36
37 public function get_icon() {
38 return 'upk-widget-icon upk-icon-exotic-list upk-new';
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', 'exotic', '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-exotic-list' ];
54 }
55 }
56
57 public function get_custom_help_url() {
58 return 'https://youtu.be/WROTolCKOmE';
59 }
60
61 public function get_query() {
62 return $this->_query;
63 }
64
65 public function has_widget_inner_wrapper(): bool {
66 return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
67 }
68
69
70 protected function register_controls() {
71 $this->start_controls_section(
72 'section_content_layout',
73 [
74 'label' => esc_html__( 'Layout', 'ultimate-post-kit' ),
75 ]
76 );
77
78
79 $this->add_responsive_control(
80 'row_gap',
81 [
82 'label' => esc_html__( 'Row Gap', 'ultimate-post-kit' ),
83 'type' => Controls_Manager::SLIDER,
84 'selectors' => [
85 '{{WRAPPER}} .upk-exotic-list .upk-item' => 'margin-bottom: {{SIZE}}{{UNIT}};',
86 ],
87 ]
88 );
89
90 $this->add_control(
91 'image_direction_style',
92 [
93 'label' => esc_html__('Image Direction', 'ultimate-post-kit'),
94 'type' => Controls_Manager::SELECT,
95 'default' => 'right',
96 'options' => [
97 'right' => esc_html__('Right', 'ultimate-post-kit'),
98 'left' => esc_html__('Left', 'ultimate-post-kit'),
99 ],
100 ]
101 );
102
103 $this->add_responsive_control(
104 'content_alignment',
105 [
106 'label' => __('Alignment', 'ultimate-post-kit'),
107 'type' => Controls_Manager::CHOOSE,
108 'options' => [
109 'left' => [
110 'title' => __('Left', 'ultimate-post-kit'),
111 'icon' => 'eicon-h-align-left',
112 ],
113 'center' => [
114 'title' => __('Center', 'ultimate-post-kit'),
115 'icon' => 'eicon-h-align-center',
116 ],
117 'right' => [
118 'title' => __('Right', 'ultimate-post-kit'),
119 'icon' => 'eicon-h-align-right',
120 ],
121 ],
122 'selectors' => [
123 '{{WRAPPER}} .upk-exotic-list .upk-content-wrap' => 'text-align: {{VALUE}};',
124 ],
125 ]
126 );
127
128 $this->add_group_control(
129 Group_Control_Image_Size::get_type(),
130 [
131 'name' => 'primary_thumbnail',
132 // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour.
133 'exclude' => [ 'custom' ],
134 'default' => 'medium',
135 ]
136 );
137
138 $this->end_controls_section();
139
140 // Query Settings
141 $this->start_controls_section(
142 'section_post_query_builder',
143 [
144 'label' => __( 'Query', 'ultimate-post-kit' ),
145 'tab' => Controls_Manager::TAB_CONTENT,
146 ]
147 );
148
149 $this->add_control(
150 'item_limit',
151 [
152 'label' => esc_html__( 'Item Limit', 'ultimate-post-kit' ),
153 'type' => Controls_Manager::SLIDER,
154 'range' => [
155 'px' => [
156 'min' => 1,
157 'max' => 20,
158 ],
159 ],
160 'default' => [
161 'size' => 3,
162 ],
163 'condition' => [
164 'posts_source!' => 'current_query',
165 ]
166 ]
167 );
168
169 $this->register_query_builder_controls();
170
171 $this->end_controls_section();
172
173 $this->start_controls_section(
174 'section_content_additional',
175 [
176 'label' => esc_html__( 'Additional Options', 'ultimate-post-kit' ),
177 ]
178 );
179
180 $this->add_control(
181 'show_image',
182 [
183 'label' => esc_html__( 'Show Image', 'ultimate-post-kit' ),
184 'type' => Controls_Manager::SWITCHER,
185 'default' => 'yes',
186 ]
187 );
188
189 //Global Title Controls
190 $this->register_title_controls();
191
192 $this->add_control(
193 'show_category',
194 [
195 'label' => esc_html__( 'Show Category', 'ultimate-post-kit' ),
196 'type' => Controls_Manager::SWITCHER,
197 'default' => 'yes',
198 ]
199 );
200
201 $this->add_control(
202 'show_author',
203 [
204 'label' => esc_html__( 'Show Author', 'ultimate-post-kit' ),
205 'type' => Controls_Manager::SWITCHER,
206 'default' => 'yes',
207 ]
208 );
209
210 $this->add_control(
211 'meta_separator',
212 [
213 'label' => __('Separator', 'ultimate-post-kit'),
214 'type' => Controls_Manager::TEXT,
215 'default' => '//',
216 'label_block' => false,
217 'conditions' => [
218 'relation' => 'or',
219 'terms' => [
220 [
221 'name' => 'show_category',
222 'operator' => '===',
223 'value' => 'yes',
224 ],
225 [
226 'name' => 'show_author',
227 'operator' => '===',
228 'value' => 'yes',
229 ],
230 ],
231 ],
232 ]
233 );
234
235 //Global Date Controls
236 $this->register_date_controls();
237
238 //Global Reading Time Controls
239 $this->register_reading_time_controls();
240
241 $this->add_control(
242 'show_pagination',
243 [
244 'label' => esc_html__( 'Show Pagination', 'ultimate-post-kit' ),
245 'type' => Controls_Manager::SWITCHER,
246 'separator' => 'before'
247 ]
248 );
249
250 $this->add_control(
251 'global_link',
252 [
253 'label' => __( 'Item Wrapper Link', 'ultimate-post-kit' ),
254 'type' => Controls_Manager::SWITCHER,
255 'prefix_class' => 'upk-global-link-',
256 'description' => __( 'Be aware! When Item Wrapper Link activated then title link and read more link will not work', 'ultimate-post-kit' ),
257 ]
258 );
259
260 $this->end_controls_section();
261
262 $this->start_controls_section(
263 'section_style_image',
264 [
265 'label' => esc_html__( 'Image', 'ultimate-post-kit' ),
266 'tab' => Controls_Manager::TAB_STYLE,
267 'condition' => [
268 'show_image' => 'yes'
269 ]
270 ]
271 );
272
273 $this->add_responsive_control(
274 'content_gap',
275 [
276 'label' => esc_html__( 'Spacing', 'ultimate-post-kit' ),
277 'type' => Controls_Manager::SLIDER,
278 'selectors' => [
279 '{{WRAPPER}} .upk-exotic-list .upk-content-wrap' => 'grid-column-gap: {{SIZE}}{{UNIT}};',
280 ],
281 ]
282 );
283
284 $this->add_group_control(
285 Group_Control_Border::get_type(),
286 [
287 'name' => 'item_image_border',
288 'selector' => '{{WRAPPER}} .upk-exotic-list .upk-image-wrap',
289 ]
290 );
291
292 $this->add_responsive_control(
293 'item_image_border_radius',
294 [
295 'label' => esc_html__( 'Border Radius', 'ultimate-post-kit' ),
296 'type' => Controls_Manager::DIMENSIONS,
297 'size_units' => [ 'px', '%' ],
298 'selectors' => [
299 '{{WRAPPER}} .upk-exotic-list .upk-image-wrap' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
300 ],
301 ]
302 );
303
304 $this->add_responsive_control(
305 'item_image_height',
306 [
307 'label' => esc_html__( 'Height', 'ultimate-post-kit' ),
308 'type' => Controls_Manager::SLIDER,
309 'range' => [
310 'px' => [
311 'min' => 100,
312 'max' => 500,
313 ],
314 ],
315 'selectors' => [
316 '{{WRAPPER}} .upk-exotic-list' => 'height: {{SIZE}}{{UNIT}};',
317 ],
318 ]
319 );
320
321 $this->end_controls_section();
322
323 $this->start_controls_section(
324 'section_style_title',
325 [
326 'label' => esc_html__( 'Title', 'ultimate-post-kit' ),
327 'tab' => Controls_Manager::TAB_STYLE,
328 'condition' => [
329 'show_title' => 'yes',
330 ],
331 ]
332 );
333
334 $this->add_control(
335 'title_style',
336 [
337 'label' => esc_html__('Style', 'ultimate-post-kit'),
338 'type' => Controls_Manager::SELECT,
339 'default' => 'underline',
340 'options' => [
341 'underline' => esc_html__('Underline', 'ultimate-post-kit'),
342 'middle-underline' => esc_html__('Middle Underline', 'ultimate-post-kit'),
343 'overline' => esc_html__('Overline', 'ultimate-post-kit'),
344 'middle-overline' => esc_html__('Middle Overline', 'ultimate-post-kit'),
345 ],
346 ]
347 );
348
349 $this->add_control(
350 'title_color',
351 [
352 'label' => esc_html__( 'Color', 'ultimate-post-kit' ),
353 'type' => Controls_Manager::COLOR,
354 'selectors' => [
355 '{{WRAPPER}} .upk-exotic-list .upk-title a' => 'color: {{VALUE}};',
356 ],
357 ]
358 );
359
360 $this->add_control(
361 'title_hover_color',
362 [
363 'label' => esc_html__( 'Hover Color', 'ultimate-post-kit' ),
364 'type' => Controls_Manager::COLOR,
365 'selectors' => [
366 '{{WRAPPER}} .upk-exotic-list .upk-title a:hover' => 'color: {{VALUE}};',
367 ],
368 ]
369 );
370
371 $this->add_responsive_control(
372 'title_spacing',
373 [
374 'label' => esc_html__( 'Spacing', 'ultimate-post-kit' ),
375 'type' => Controls_Manager::SLIDER,
376 'range' => [
377 'px' => [
378 'min' => 0,
379 'max' => 50,
380 ],
381 ],
382 'selectors' => [
383 '{{WRAPPER}} .upk-exotic-list .upk-title' => 'padding-bottom: {{SIZE}}{{UNIT}};',
384 ],
385 ]
386 );
387
388 $this->add_group_control(
389 Group_Control_Typography::get_type(),
390 [
391 'name' => 'title_typography',
392 'label' => esc_html__( 'Typography', 'ultimate-post-kit' ),
393 'selector' => '{{WRAPPER}} .upk-exotic-list .upk-title',
394 ]
395 );
396
397 $this->add_group_control(
398 Group_Control_Text_Shadow::get_type(),
399 [
400 'name' => 'title_text_shadow',
401 'label' => __( 'Text Shadow', 'ultimate-post-kit' ),
402 'selector' => '{{WRAPPER}} .upk-exotic-list .upk-title a',
403 ]
404 );
405
406 $this->end_controls_section();
407
408 $this->start_controls_section(
409 'section_style_date',
410 [
411 'label' => esc_html__( 'Date', 'ultimate-post-kit' ),
412 'tab' => Controls_Manager::TAB_STYLE,
413 'conditions' => [
414 'relation' => 'or',
415 'terms' => [
416 [
417 'name' => 'show_date',
418 'value' => 'yes'
419 ],
420 ]
421 ],
422 ]
423 );
424
425 $this->add_control(
426 'date_color',
427 [
428 'label' => esc_html__( 'Color', 'ultimate-post-kit' ),
429 'type' => Controls_Manager::COLOR,
430 'selectors' => [
431 '{{WRAPPER}} .upk-exotic-list .upk-date-wrap' => 'color: {{VALUE}};',
432 ],
433 ]
434 );
435
436
437 $this->add_group_control(
438 Group_Control_Background::get_type(),
439 [
440 'name' => 'date_background',
441 'selector' => '{{WRAPPER}} .upk-exotic-list .upk-date-wrap',
442 ]
443 );
444
445 $this->add_group_control(
446 Group_Control_Border::get_type(),
447 [
448 'name' => 'date_border',
449 'label' => __( 'Border', 'ultimate-post-kit' ),
450 'selector' => '{{WRAPPER}} .upk-exotic-list .upk-date-wrap',
451 ]
452 );
453
454 $this->add_responsive_control(
455 'date_border_radius',
456 [
457 'label' => esc_html__( 'Border Radius', 'ultimate-post-kit' ),
458 'type' => Controls_Manager::DIMENSIONS,
459 'size_units' => [ 'px', '%' ],
460 'selectors' => [
461 '{{WRAPPER}} .upk-exotic-list .upk-date-wrap' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
462 ],
463 ]
464 );
465
466 $this->add_responsive_control(
467 'date_padding',
468 [
469 'label' => esc_html__( 'Padding', 'ultimate-post-kit' ),
470 'type' => Controls_Manager::DIMENSIONS,
471 'size_units' => [ 'px', 'em', '%' ],
472 'selectors' => [
473 '{{WRAPPER}} .upk-exotic-list .upk-date-wrap' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
474 ],
475 ]
476 );
477
478
479 $this->add_responsive_control(
480 'date_spacing',
481 [
482 'label' => esc_html__( 'Spacing', 'ultimate-post-kit' ),
483 'type' => Controls_Manager::SLIDER,
484 'range' => [
485 'px' => [
486 'min' => 0,
487 'max' => 50,
488 'step' => 2,
489 ],
490 ],
491 'selectors' => [
492 '{{WRAPPER}} .upk-exotic-list .upk-content-wrap' => 'grid-column-gap: {{SIZE}}{{UNIT}};',
493 ],
494 ]
495 );
496
497 $this->add_group_control(
498 Group_Control_Typography::get_type(),
499 [
500 'name' => 'date_typography',
501 'label' => esc_html__( 'Typography', 'ultimate-post-kit' ),
502 'selector' => '{{WRAPPER}} .upk-exotic-list .upk-date-wrap',
503 ]
504 );
505
506 $this->end_controls_section();
507
508
509 $this->start_controls_section(
510 'section_style_author',
511 [
512 'label' => esc_html__( 'Author', 'ultimate-post-kit' ),
513 'tab' => Controls_Manager::TAB_STYLE,
514 'conditions' => [
515 'relation' => 'or',
516 'terms' => [
517 [
518 'name' => 'show_author',
519 'value' => 'yes'
520 ],
521 ]
522 ],
523 ]
524 );
525
526 $this->add_control(
527 'author_color',
528 [
529 'label' => esc_html__( 'Color', 'ultimate-post-kit' ),
530 'type' => Controls_Manager::COLOR,
531 'selectors' => [
532 '{{WRAPPER}} .upk-exotic-list .upk-author a' => 'color: {{VALUE}};',
533 ],
534 ]
535 );
536
537 $this->add_control(
538 'author_hover_color',
539 [
540 'label' => esc_html__( 'Hover Color', 'ultimate-post-kit' ),
541 'type' => Controls_Manager::COLOR,
542 'selectors' => [
543 '{{WRAPPER}} .upk-exotic-list .upk-author a:hover' => 'color: {{VALUE}};',
544 ],
545 ]
546 );
547
548 // $this->add_responsive_control(
549 // 'author_spacing',
550 // [
551 // 'label' => esc_html__( 'Spacing', '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-exotic-list .upk-meta' => 'grid-column-gap: {{SIZE}}{{UNIT}};',
562 // ],
563 // ]
564 // );
565 $this->add_responsive_control(
566 'author_spacing',
567 [
568 'label' => esc_html__('Space Between', 'ultimate-post-kit'),
569 'type' => Controls_Manager::SLIDER,
570 'range' => [
571 'px' => [
572 'min' => 0,
573 'max' => 50,
574 ],
575 ],
576 'selectors' => [
577 '{{WRAPPER}} .upk-exotic-list .upk-meta > div:before' => 'margin: 0 {{SIZE}}{{UNIT}};',
578 ],
579 ]
580 );
581
582 $this->add_group_control(
583 Group_Control_Typography::get_type(),
584 [
585 'name' => 'author_typography',
586 'label' => esc_html__( 'Typography', 'ultimate-post-kit' ),
587 'selector' => '{{WRAPPER}} .upk-exotic-list .upk-author',
588 ]
589 );
590
591 $this->end_controls_section();
592
593 $this->start_controls_section(
594 'section_style_category',
595 [
596 'label' => esc_html__( 'Category', 'ultimate-post-kit' ),
597 'tab' => Controls_Manager::TAB_STYLE,
598 'condition' => [
599 'show_category' => 'yes',
600 ],
601 ]
602 );
603
604 $this->start_controls_tabs( 'tabs_category_style' );
605
606 $this->start_controls_tab(
607 'tab_category_normal',
608 [
609 'label' => esc_html__( 'Normal', 'ultimate-post-kit' ),
610 ]
611 );
612
613 $this->add_control(
614 'category_color',
615 [
616 'label' => esc_html__( 'Color', 'ultimate-post-kit' ),
617 'type' => Controls_Manager::COLOR,
618 'selectors' => [
619 '{{WRAPPER}} .upk-exotic-list .upk-category a' => 'color: {{VALUE}};',
620 ],
621 ]
622 );
623
624 $this->add_group_control(
625 Group_Control_Background::get_type(),
626 [
627 'name' => 'category_background',
628 'selector' => '{{WRAPPER}} .upk-exotic-list .upk-category a',
629 ]
630 );
631
632 $this->add_group_control(
633 Group_Control_Border::get_type(),
634 [
635 'name' => 'category_border',
636 'label' => __( 'Border', 'ultimate-post-kit' ),
637 'selector' => '{{WRAPPER}} .upk-exotic-list .upk-category a',
638 ]
639 );
640
641 $this->add_responsive_control(
642 'category_border_radius',
643 [
644 'label' => esc_html__( 'Border Radius', 'ultimate-post-kit' ),
645 'type' => Controls_Manager::DIMENSIONS,
646 'size_units' => [ 'px', '%' ],
647 'selectors' => [
648 '{{WRAPPER}} .upk-exotic-list .upk-category a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
649 ],
650 ]
651 );
652
653 $this->add_responsive_control(
654 'category_padding',
655 [
656 'label' => esc_html__( 'Padding', 'ultimate-post-kit' ),
657 'type' => Controls_Manager::DIMENSIONS,
658 'size_units' => [ 'px', 'em', '%' ],
659 'selectors' => [
660 '{{WRAPPER}} .upk-exotic-list .upk-category a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
661 ],
662 ]
663 );
664
665 $this->add_responsive_control(
666 'category_spacing',
667 [
668 'label' => esc_html__( 'Space Between', 'ultimate-post-kit' ),
669 'type' => Controls_Manager::SLIDER,
670 'range' => [
671 'px' => [
672 'min' => 0,
673 'max' => 50,
674 'step' => 2,
675 ],
676 ],
677 'selectors' => [
678 '{{WRAPPER}} .upk-exotic-list .upk-category a+a' => 'margin-left: {{SIZE}}{{UNIT}};',
679 ],
680 ]
681 );
682
683
684 $this->add_group_control(
685 Group_Control_Box_Shadow::get_type(),
686 [
687 'name' => 'category_shadow',
688 'selector' => '{{WRAPPER}} .upk-exotic-list .upk-category a',
689 ]
690 );
691
692 $this->add_group_control(
693 Group_Control_Typography::get_type(),
694 [
695 'name' => 'category_typography',
696 'label' => esc_html__( 'Typography', 'ultimate-post-kit' ),
697 'selector' => '{{WRAPPER}} .upk-exotic-list .upk-category a',
698 ]
699 );
700
701 $this->end_controls_tab();
702
703 $this->start_controls_tab(
704 'tab_category_hover',
705 [
706 'label' => esc_html__( 'Hover', 'ultimate-post-kit' ),
707 ]
708 );
709
710 $this->add_control(
711 'category_hover_color',
712 [
713 'label' => esc_html__( 'Color', 'ultimate-post-kit' ),
714 'type' => Controls_Manager::COLOR,
715 'selectors' => [
716 '{{WRAPPER}} .upk-exotic-list .upk-category a:hover' => 'color: {{VALUE}};',
717 ],
718 ]
719 );
720
721 $this->add_group_control(
722 Group_Control_Background::get_type(),
723 [
724 'name' => 'category_hover_background',
725 'selector' => '{{WRAPPER}} .upk-exotic-list .upk-category a:hover',
726 ]
727 );
728
729 $this->add_control(
730 'category_hover_border_color',
731 [
732 'label' => esc_html__( 'Border Color', 'ultimate-post-kit' ),
733 'type' => Controls_Manager::COLOR,
734 'condition' => [
735 'category_border_border!' => '',
736 ],
737 'selectors' => [
738 '{{WRAPPER}} .upk-exotic-list .upk-category a:hover' => 'border-color: {{VALUE}};',
739 ],
740 ]
741 );
742
743 $this->end_controls_tab();
744
745 $this->end_controls_tabs();
746
747 $this->end_controls_section();
748
749 //Global Pagination Controls
750 $this->register_pagination_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_author() {
782
783 if ( ! $this->get_settings( 'show_author' ) ) {
784 return;
785 }
786
787 ?>
788 <div class="upk-author">
789 <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) ?>">
790 <?php echo esc_html( get_the_author() ) ?>
791 </a>
792 </div>
793
794 <?php
795 }
796
797 public function render_date() {
798 $settings = $this->get_settings_for_display();
799
800 if ( ! $this->get_settings( 'show_date' ) ) {
801 return;
802 }
803
804 ?>
805 <div class="upk-date-wrap">
806 <span>
807 <?php if ($settings['human_diff_time'] == 'yes') {
808 echo esc_html( ultimate_post_kit_post_time_diff( ( $settings['human_diff_time_short'] == 'yes' ) ? 'short' : '' ) );
809 } else {
810 echo get_the_date();
811 } ?>
812 </span>
813 </div>
814 <?php if ($settings['show_time']) : ?>
815 <div class="upk-post-time">
816 <i class="upk-icon-clock" aria-hidden="true"></i>
817 <?php echo esc_html( get_the_time() ); ?>
818 </div>
819 <?php endif; ?>
820
821 <?php
822 }
823
824 public function render_post_grid_item( $post_id, $image_size ) {
825 $settings = $this->get_settings_for_display();
826
827 if ( 'yes' == $settings['global_link'] ) {
828
829 $this->add_render_attribute( 'list-item', 'onclick', "window.open('" . esc_url( get_permalink() ) . "', '_self')", true );
830 }
831 $this->add_render_attribute( 'list-item', 'class', 'upk-item', true );
832
833 ?>
834 <div <?php $this->print_render_attribute_string( 'list-item' ); ?>>
835
836 <div class="upk-content-wrap">
837 <?php $this->render_date(); ?>
838 <div class="upk-inner-content">
839 <?php $this->render_title(substr($this->get_name(), 4)); ?>
840 <div class="upk-meta">
841 <?php $this->render_category(); ?>
842
843 <?php if ($settings['show_author']) : ?>
844 <div data-separator="<?php echo esc_attr($settings['meta_separator']); ?>">
845 <?php $this->render_author(); ?>
846 </div>
847 <?php endif; ?>
848 <?php if (_is_upk_pro_activated()) :
849 if ('yes' === $settings['show_reading_time']) : ?>
850 <div class="upk-reading-time" data-separator="<?php echo esc_attr($settings['meta_separator']); ?>">
851 <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'], $settings['hide_seconds'] ?? 'no', $settings['hide_minutes'] ?? 'no' ) ); ?>
852 </div>
853 <?php endif; ?>
854 <?php endif; ?>
855 </div>
856 </div>
857 </div>
858 <?php if ( 'yes' == $settings['show_image'] ) : ?>
859 <div class="upk-image-wrap">
860 <?php $this->render_image( get_post_thumbnail_id( $post_id ), $image_size ); ?>
861 </div>
862 <?php endif; ?>
863 </div>
864
865 <?php
866 }
867
868 protected function render() {
869 $settings = $this->get_settings_for_display();
870
871 $this->query_posts( $settings['item_limit']['size'] );
872 $wp_query = $this->get_query();
873
874 if ( ! $wp_query->found_posts ) {
875 return;
876 }
877 $this->add_render_attribute( 'list-wrap', 'class', 'upk-exotic-list upk-image-direction-' . $settings['image_direction_style']);
878
879 if (isset($settings['upk_in_animation_show']) && ($settings['upk_in_animation_show'] == 'yes')) {
880 $this->add_render_attribute( 'list-wrap', 'class', 'upk-in-animation' );
881 if (isset($settings['upk_in_animation_delay']['size'])) {
882 $this->add_render_attribute( 'list-wrap', 'data-in-animation-delay', $settings['upk_in_animation_delay']['size'] );
883 }
884 }
885
886 ?>
887 <div <?php $this->print_render_attribute_string('list-wrap'); ?>>
888
889 <?php while ( $wp_query->have_posts() ) :
890 $wp_query->the_post();
891
892 $thumbnail_size = $settings['primary_thumbnail_size'];
893
894 ?>
895
896 <?php $this->render_post_grid_item( get_the_ID(), $thumbnail_size ); ?>
897
898 <?php endwhile; ?>
899 </div>
900
901 <?php
902
903 if ( $settings['show_pagination'] ) { ?>
904 <div class="ep-pagination">
905 <?php ultimate_post_kit_post_pagination( $wp_query, $this->get_id() ); ?>
906 </div>
907 <?php
908 }
909 wp_reset_postdata();
910 }
911 }
912