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

918 lines 25.3 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 ]
263 );
264
265 $this->register_query_builder_controls();
266
267 $this->end_controls_section();
268
269 //Style
270 $this->start_controls_section(
271 'upk_section_style',
272 [
273 'label' => esc_html__('Item', 'ultimate-post-kit'),
274 'tab' => Controls_Manager::TAB_STYLE,
275 ]
276 );
277
278 $this->start_controls_tabs('tabs_item_style');
279
280 $this->start_controls_tab(
281 'tab_item_normal',
282 [
283 'label' => esc_html__('Normal', 'ultimate-post-kit'),
284 ]
285 );
286
287 $this->add_group_control(
288 Group_Control_Background::get_type(),
289 [
290 'name' => 'item_background',
291 'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item',
292 ]
293 );
294
295 $this->add_group_control(
296 Group_Control_Border::get_type(),
297 [
298 'name' => 'item_border',
299 'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item',
300 ]
301 );
302
303 $this->add_responsive_control(
304 'item_border_radius',
305 [
306 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
307 'type' => Controls_Manager::DIMENSIONS,
308 'size_units' => ['px', '%'],
309 'selectors' => [
310 '{{WRAPPER}} .upk-tiny-list .upk-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
311 ],
312 ]
313 );
314
315 $this->add_responsive_control(
316 'item_padding',
317 [
318 'label' => esc_html__('Padding', 'ultimate-post-kit'),
319 'type' => Controls_Manager::DIMENSIONS,
320 'size_units' => ['px', 'em', '%'],
321 'selectors' => [
322 '{{WRAPPER}} .upk-tiny-list .upk-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
323 ],
324 ]
325 );
326
327 $this->add_group_control(
328 Group_Control_Box_Shadow::get_type(),
329 [
330 'name' => 'item_shadow',
331 'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item',
332 ]
333 );
334
335 $this->end_controls_tab();
336
337 $this->start_controls_tab(
338 'tab_item_hover',
339 [
340 'label' => esc_html__('Hover', 'ultimate-post-kit'),
341 ]
342 );
343
344 $this->add_group_control(
345 Group_Control_Background::get_type(),
346 [
347 'name' => 'item_hover_background',
348 'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item:hover',
349 ]
350 );
351
352 $this->add_control(
353 'item_hover_border_color',
354 [
355 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
356 'type' => Controls_Manager::COLOR,
357 'condition' => [
358 'item_border_border!' => '',
359 ],
360 'selectors' => [
361 '{{WRAPPER}} .upk-tiny-list .upk-item:hover' => 'border-color: {{VALUE}};',
362 ],
363 ]
364 );
365
366 $this->add_group_control(
367 Group_Control_Box_Shadow::get_type(),
368 [
369 'name' => 'item_hover_shadow',
370 'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item:hover',
371 ]
372 );
373
374 $this->end_controls_tab();
375
376 $this->end_controls_tabs();
377
378 $this->end_controls_section();
379
380 $this->start_controls_section(
381 'section_style_image',
382 [
383 'label' => esc_html__('Image', 'ultimate-post-kit'),
384 'tab' => Controls_Manager::TAB_STYLE,
385 'condition' => [
386 'show_image' => 'yes',
387 ],
388 ]
389 );
390
391 $this->add_responsive_control(
392 'item_image_size',
393 [
394 'label' => esc_html__('Size', 'ultimate-post-kit'),
395 'type' => Controls_Manager::SLIDER,
396 'range' => [
397 'px' => [
398 'min' => 10,
399 'max' => 100,
400 ],
401 ],
402 'selectors' => [
403 '{{WRAPPER}} .upk-tiny-list .upk-item .upk-img' => 'height: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}};',
404 ],
405 ]
406 );
407
408 $this->add_group_control(
409 Group_Control_Border::get_type(),
410 [
411 'name' => 'item_image_border',
412 'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item .upk-img',
413 ]
414 );
415
416 $this->add_responsive_control(
417 'item_image_border_radius',
418 [
419 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
420 'type' => Controls_Manager::DIMENSIONS,
421 'size_units' => ['px', '%'],
422 'selectors' => [
423 '{{WRAPPER}} .upk-tiny-list .upk-item .upk-img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
424 ],
425 ]
426 );
427
428 $this->add_responsive_control(
429 'item_image_padding',
430 [
431 'label' => esc_html__('Padding', 'ultimate-post-kit'),
432 'type' => Controls_Manager::DIMENSIONS,
433 'size_units' => ['px', 'em', '%'],
434 'selectors' => [
435 '{{WRAPPER}} .upk-tiny-list .upk-item .upk-img' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
436 ],
437 ]
438 );
439
440 $this->add_responsive_control(
441 'item_image_margin',
442 [
443 'label' => esc_html__('Margin', 'ultimate-post-kit'),
444 'type' => Controls_Manager::DIMENSIONS,
445 'size_units' => ['px', 'em', '%'],
446 'selectors' => [
447 '{{WRAPPER}} .upk-tiny-list .upk-item .upk-img' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
448 ],
449 ]
450 );
451
452 $this->add_group_control(
453 Group_Control_Box_Shadow::get_type(),
454 [
455 'name' => 'item_image_shadow',
456 'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item .upk-img',
457 ]
458 );
459
460 $this->end_controls_section();
461
462 $this->start_controls_section(
463 'section_style_icon',
464 [
465 'label' => esc_html__('Icon', 'ultimate-post-kit'),
466 'tab' => Controls_Manager::TAB_STYLE,
467 'condition' => [
468 'show_item_icon[value]!' => '',
469 ],
470 ]
471 );
472
473 $this->add_control(
474 'item_icon_color',
475 [
476 'label' => esc_html__('Color', 'ultimate-post-kit'),
477 'type' => Controls_Manager::COLOR,
478 'selectors' => [
479 '{{WRAPPER}} .upk-tiny-list .upk-item .upk-title-icon i' => 'color: {{VALUE}};',
480 '{{WRAPPER}} .upk-tiny-list .upk-item .upk-title-icon svg *' => 'fill: {{VALUE}};',
481 ],
482 ]
483 );
484
485 $this->add_group_control(
486 Group_Control_Background::get_type(),
487 [
488 'name' => 'item_icon_background',
489 'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item .upk-title-icon',
490 ]
491 );
492
493 $this->add_group_control(
494 Group_Control_Border::get_type(),
495 [
496 'name' => 'item_icon_border',
497 'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item .upk-title-icon',
498 ]
499 );
500
501 $this->add_responsive_control(
502 'item_icon_border_radius',
503 [
504 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
505 'type' => Controls_Manager::DIMENSIONS,
506 'size_units' => ['px', '%'],
507 'selectors' => [
508 '{{WRAPPER}} .upk-tiny-list .upk-item .upk-title-icon' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
509 ],
510 ]
511 );
512
513 $this->add_responsive_control(
514 'item_icon_padding',
515 [
516 'label' => esc_html__('Padding', 'ultimate-post-kit'),
517 'type' => Controls_Manager::DIMENSIONS,
518 'size_units' => ['px', 'em', '%'],
519 'selectors' => [
520 '{{WRAPPER}} .upk-tiny-list .upk-item .upk-title-icon' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
521 ],
522 ]
523 );
524
525 $this->add_responsive_control(
526 'item_icon_margin',
527 [
528 'label' => esc_html__('Margin', 'ultimate-post-kit'),
529 'type' => Controls_Manager::DIMENSIONS,
530 'size_units' => ['px', 'em', '%'],
531 'selectors' => [
532 '{{WRAPPER}} .upk-tiny-list .upk-item .upk-title-icon' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
533 ],
534 ]
535 );
536
537 $this->add_group_control(
538 Group_Control_Box_Shadow::get_type(),
539 [
540 'name' => 'item_icon_shadow',
541 'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item .upk-title-icon',
542 ]
543 );
544
545 $this->add_responsive_control(
546 'icon_size',
547 [
548 'label' => esc_html__('Size', 'ultimate-post-kit'),
549 'type' => Controls_Manager::SLIDER,
550 'range' => [
551 'px' => [
552 'min' => 10,
553 'max' => 100,
554 ],
555 ],
556 'selectors' => [
557 '{{WRAPPER}} .upk-tiny-list .upk-item .upk-title-icon' => 'font-size: {{SIZE}}{{UNIT}};',
558 ],
559 ]
560 );
561
562 $this->end_controls_section();
563
564 $this->start_controls_section(
565 'section_style_title',
566 [
567 'label' => esc_html__('Title', 'ultimate-post-kit'),
568 'tab' => Controls_Manager::TAB_STYLE,
569 'condition' => [
570 'show_title' => 'yes'
571 ]
572 ]
573 );
574
575 $this->add_control(
576 'title_style',
577 [
578 'label' => esc_html__('Style', 'ultimate-post-kit'),
579 'type' => Controls_Manager::SELECT,
580 'default' => 'underline',
581 'options' => [
582 '' => esc_html__('Default', 'ultimate-post-kit'),
583 'underline' => esc_html__('Underline', 'ultimate-post-kit'),
584 'middle-underline' => esc_html__('Middle Underline', 'ultimate-post-kit'),
585 'overline' => esc_html__('Overline', 'ultimate-post-kit'),
586 'middle-overline' => esc_html__('Middle Overline', 'ultimate-post-kit'),
587 ],
588 ]
589 );
590
591 $this->add_control(
592 'title_color',
593 [
594 'label' => esc_html__('Color', 'ultimate-post-kit'),
595 'type' => Controls_Manager::COLOR,
596 'selectors' => [
597 '{{WRAPPER}} .upk-tiny-list .upk-item .upk-title a' => 'color: {{VALUE}};',
598 ],
599 'separator' => 'before'
600 ]
601 );
602
603 $this->add_control(
604 'title_hover_color',
605 [
606 'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
607 'type' => Controls_Manager::COLOR,
608 'selectors' => [
609 '{{WRAPPER}} .upk-tiny-list .upk-item .upk-title a:hover' => 'color: {{VALUE}};',
610 ],
611 ]
612 );
613
614 $this->add_group_control(
615 Group_Control_Typography::get_type(),
616 [
617 'name' => 'title_typography',
618 'label' => esc_html__('Typography', 'ultimate-post-kit'),
619 'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item .upk-title',
620 ]
621 );
622
623 $this->add_group_control(
624 Group_Control_Text_Shadow::get_type(),
625 [
626 'name' => 'title_text_shadow',
627 'label' => __('Text Shadow', 'ultimate-post-kit'),
628 'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item .upk-title',
629 ]
630 );
631
632 $this->add_group_control(
633 Group_Control_Text_Stroke::get_type(),
634 [
635 'name' => 'title_text_stroke',
636 'label' => esc_html__('Text Stroke', 'ultimate-post-kit'),
637 'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item .upk-title a',
638 ]
639 );
640
641 $this->add_control(
642 'title_hover_transition_duration',
643 [
644 'label' => esc_html__( 'Transition Duration', 'ultimate-post-kit' ),
645 'type' => Controls_Manager::SLIDER,
646 'size_units' => [ 's', 'ms', 'custom' ],
647 'default' => [
648 'unit' => 's',
649 ],
650 'selectors' => [
651 '{{WRAPPER}} .upk-tiny-list .upk-item .upk-title a' => 'transition-duration: {{SIZE}}{{UNIT}};',
652 ],
653 ]
654 );
655
656 $this->end_controls_section();
657
658 $this->start_controls_section(
659 'section_style_counter_number',
660 [
661 'label' => esc_html__('Counter Number', 'ultimate-post-kit'),
662 'tab' => Controls_Manager::TAB_STYLE,
663 'condition' => [
664 'show_counter_number' => 'yes',
665 ]
666 ]
667 );
668
669 $this->add_control(
670 'counter_number_color',
671 [
672 'label' => esc_html__('Color', 'ultimate-post-kit'),
673 'type' => Controls_Manager::COLOR,
674 'selectors' => [
675 '{{WRAPPER}} .upk-tiny-list .upk-item .upk-counter:before' => 'color: {{VALUE}};',
676 ],
677 ]
678 );
679
680 $this->add_group_control(
681 Group_Control_Background::get_type(),
682 [
683 'name' => 'counter_number_background',
684 'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item .upk-counter',
685 ]
686 );
687
688 $this->add_group_control(
689 Group_Control_Border::get_type(),
690 [
691 'name' => 'counter_number_border',
692 'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item .upk-counter',
693 ]
694 );
695
696 $this->add_responsive_control(
697 'counter_number_border_radius',
698 [
699 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
700 'type' => Controls_Manager::DIMENSIONS,
701 'size_units' => ['px', '%'],
702 'selectors' => [
703 '{{WRAPPER}} .upk-tiny-list .upk-item .upk-counter' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
704 ],
705 ]
706 );
707
708 $this->add_responsive_control(
709 'counter_number_spacing',
710 [
711 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
712 'type' => Controls_Manager::SLIDER,
713 'range' => [
714 'px' => [
715 'min' => 0,
716 'max' => 50,
717 ],
718 ],
719 'selectors' => [
720 '{{WRAPPER}} .upk-tiny-list .upk-item .upk-counter' => 'margin-right: {{SIZE}}{{UNIT}};',
721 ],
722 ]
723 );
724
725 $this->add_responsive_control(
726 'counter_number_size',
727 [
728 'label' => esc_html__('Counter Size', 'ultimate-post-kit'),
729 'type' => Controls_Manager::SLIDER,
730 'range' => [
731 'px' => [
732 'min' => 20,
733 'max' => 100,
734 ],
735 ],
736 'selectors' => [
737 '{{WRAPPER}} .upk-tiny-list .upk-item .upk-counter' => 'height: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}}; min-width: {{SIZE}}{{UNIT}};',
738 ],
739 ]
740 );
741
742 $this->add_group_control(
743 Group_Control_Typography::get_type(),
744 [
745 'name' => 'counter_number_typography',
746 'label' => esc_html__('Typography', 'ultimate-post-kit'),
747 'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item .upk-counter:before',
748 ]
749 );
750
751 $this->end_controls_section();
752
753 //Global Pagination Controls
754 $this->register_pagination_controls();
755
756 //Global Ajax Loadmore Style Controls
757 $this->register_ajax_loadmore_style_controls();
758 }
759
760 /**
761 * Main query render for this widget
762 * @param $posts_per_page number item query limit
763 */
764 public function query_posts($posts_per_page) {
765
766 $default = $this->getGroupControlQueryArgs();
767 $args = [];
768 if ($posts_per_page) {
769 $args['posts_per_page'] = $posts_per_page;
770 $args['paged'] = max(1, get_query_var('paged'), get_query_var('page'));
771 }
772 $args = array_merge($default, $args);
773 $this->_query = new WP_Query($args);
774 }
775
776 public function render_post_grid_item($post_id, $image_size) {
777 $settings = $this->get_settings_for_display();
778
779 if ('yes' == $settings['global_link']) {
780
781 $this->add_render_attribute('list-item', 'onclick', "window.open('" . esc_url(get_permalink()) . "', '_self')", true);
782 }
783 $this->add_render_attribute('list-item', 'class', 'upk-item', true);
784
785 ?>
786 <div <?php $this->print_render_attribute_string('list-item'); ?>>
787 <div class="upk-content upk-flex upk-flex-middle">
788
789 <?php if ($settings['show_counter_number'] == 'yes') : ?>
790 <div class="upk-counter"></div>
791 <?php endif; ?>
792
793 <?php if ($settings['show_image'] == 'yes') : ?>
794 <?php $this->render_image(get_post_thumbnail_id($post_id), $image_size); ?>
795 <?php endif; ?>
796
797 <?php if ($settings['show_item_icon']['value']) : ?>
798 <div class="upk-title-icon">
799 <?php Icons_Manager::render_icon($settings['show_item_icon'], ['aria-hidden' => 'true', 'class' => 'fa-fw']); ?>
800 </div>
801 <?php endif; ?>
802
803 <?php $this->render_title(substr($this->get_name(), 4)); ?>
804 </div>
805 </div>
806
807 <?php
808 }
809
810 protected function render() {
811 $settings = $this->get_settings_for_display();
812
813 $this->query_posts($settings['item_limit']['size']);
814 $wp_query = $this->get_query();
815
816 if (!$wp_query->found_posts) {
817 return;
818 }
819
820 $this->add_render_attribute('list-wrap', 'class', 'upk-tiny-list upk-ajax-grid-wrap');
821
822 $this->add_render_attribute(
823 [
824 'upk-tiny-list' => [
825 'class' => 'upk-tiny-list-container upk-ajax-grid',
826 'data-loadmore' => [
827 wp_json_encode(
828 array_filter([
829 'loadmore_enable' => $settings['ajax_loadmore_enable'],
830 'loadmore_btn' => $settings['ajax_loadmore_btn'],
831 'infinite_scroll' => $settings['ajax_loadmore_infinite_scroll'],
832 ])
833 ),
834 ],
835 ],
836 ]
837 );
838
839 if ($settings['ajax_loadmore_enable'] == 'yes') {
840 $ajax_settings = [
841 'posts_source' => isset($settings['posts_source']) ? $settings['posts_source'] : 'post',
842 'posts_per_page' => isset($settings['item_limit']['size']) ? $settings['item_limit']['size'] : 4,
843 'ajax_item_load' => isset($settings['ajax_loadmore_items']) ? $settings['ajax_loadmore_items'] : 3,
844 'posts_selected_ids' => isset($settings['posts_selected_ids']) ? $settings['posts_selected_ids'] : '',
845 'posts_include_by' => isset($settings['posts_include_by']) ? $settings['posts_include_by'] : [],
846 'posts_include_author_ids' => isset($settings['posts_include_author_ids']) ? $settings['posts_include_author_ids'] : '',
847 'posts_include_term_ids' => isset($settings['posts_include_term_ids']) ? $settings['posts_include_term_ids'] : '',
848 'posts_exclude_by' => isset($settings['posts_exclude_by']) ? $settings['posts_exclude_by'] : [],
849 'posts_exclude_ids' => isset($settings['posts_exclude_ids']) ? $settings['posts_exclude_ids'] : '',
850 'posts_exclude_author_ids' => isset($settings['posts_exclude_author_ids']) ? $settings['posts_exclude_author_ids'] : '',
851 'posts_exclude_term_ids' => isset($settings['posts_exclude_term_ids']) ? $settings['posts_exclude_term_ids'] : '',
852 'posts_offset' => isset($settings['posts_offset']) ? $settings['posts_offset'] : 0,
853 'posts_select_date' => isset($settings['posts_select_date']) ? $settings['posts_select_date'] : '',
854 'posts_date_before' => isset($settings['posts_date_before']) ? $settings['posts_date_before'] : '',
855 'posts_date_after' => isset($settings['posts_date_after']) ? $settings['posts_date_after'] : '',
856 'posts_orderby' => isset($settings['posts_orderby']) ? $settings['posts_orderby'] : 'date',
857 'posts_order' => isset($settings['posts_order']) ? $settings['posts_order'] : 'DESC',
858 'posts_ignore_sticky_posts' => isset($settings['posts_ignore_sticky_posts']) ? $settings['posts_ignore_sticky_posts'] : 'no',
859 'posts_only_with_featured_image'=> isset($settings['posts_only_with_featured_image']) ? $settings['posts_only_with_featured_image'] : 'no',
860 // List Settings
861 'show_title' => isset($settings['show_title']) ? $settings['show_title'] : 'yes',
862 'title_tags' => isset( $settings['title_tags'] ) ? $settings['title_tags'] : 'h3',
863 'title_style' => isset($settings['title_style']) ? $settings['title_style'] : '',
864 'show_image' => isset($settings['show_image']) ? $settings['show_image'] : 'no',
865 'primary_thumbnail_size' => isset($settings['primary_thumbnail_size']) ? $settings['primary_thumbnail_size'] : 'thumbnail',
866 'show_counter_number' => isset($settings['show_counter_number']) ? $settings['show_counter_number'] : 'no',
867 'show_item_icon' => isset($settings['show_item_icon']) ? $settings['show_item_icon'] : [],
868 'global_link' => isset($settings['global_link']) ? $settings['global_link'] : 'no',
869 ];
870
871 $this->add_render_attribute(
872 [
873 'upk-tiny-list' => [
874 'data-settings' => [
875 wp_json_encode($ajax_settings)
876 ],
877 ],
878 ]
879 );
880 }
881
882 if (isset($settings['upk_in_animation_show']) && ($settings['upk_in_animation_show'] == 'yes')) {
883 $this->add_render_attribute('list-wrap', 'class', 'upk-in-animation');
884 if (isset($settings['upk_in_animation_delay']['size'])) {
885 $this->add_render_attribute('list-wrap', 'data-in-animation-delay', $settings['upk_in_animation_delay']['size']);
886 }
887 }
888
889 ?>
890 <div <?php $this->print_render_attribute_string('upk-tiny-list'); ?>>
891 <div <?php $this->print_render_attribute_string('list-wrap'); ?>>
892 <?php while ($wp_query->have_posts()) :
893 $wp_query->the_post();
894
895 $thumbnail_size = $settings['primary_thumbnail_size'];
896
897 ?>
898
899 <?php $this->render_post_grid_item(get_the_ID(), $thumbnail_size); ?>
900
901 <?php endwhile; ?>
902 </div>
903 </div>
904
905 <?php $this->render_ajax_loadmore(); ?>
906
907 <?php
908
909 if ($settings['show_pagination']) { ?>
910 <div class="ep-pagination">
911 <?php ultimate_post_kit_post_pagination($wp_query, $this->get_id()); ?>
912 </div>
913 <?php
914 }
915 wp_reset_postdata();
916 }
917 }
918