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

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

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