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 / amox-grid / widgets / amox-grid.php

amox-grid.php in Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets 4.0.9, at modules/amox-grid/widgets/amox-grid.php

1,183 lines 39.8 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\AmoxGrid\Widgets;
4
5 use Elementor\Controls_Manager;
6 use Elementor\Group_Control_Background;
7 use Elementor\Group_Control_Border;
8 use Elementor\Group_Control_Box_Shadow;
9 use Elementor\Group_Control_Image_Size;
10 use Elementor\Group_Control_Text_Shadow;
11 use Elementor\Group_Control_Typography;
12 use UltimatePostKit\Includes\Controls\GroupQuery\Group_Control_Query;
13 use UltimatePostKit\Traits\Global_Widget_Controls;
14 use UltimatePostKit\Traits\Global_Widget_Functions;
15 use WP_Query;
16
17 if (!defined('ABSPATH')) {
18 exit;
19 }
20 // Exit if accessed directly
21
22 class Amox_Grid extends Group_Control_Query
23 {
24
25 use Global_Widget_Controls;
26 use Global_Widget_Functions;
27
28 private $_query = null;
29
30 public function get_name()
31 {
32 return 'upk-amox-grid';
33 }
34
35 public function get_title()
36 {
37 return BDTUPK . esc_html__('Amox Grid', 'ultimate-post-kit');
38 }
39
40 public function get_icon()
41 {
42 return 'upk-widget-icon upk-icon-amox-grid';
43 }
44
45 public function get_categories()
46 {
47 return ['ultimate-post-kit'];
48 }
49
50 public function get_keywords()
51 {
52 return ['post', 'grid', 'blog', 'recent', 'news', 'amox'];
53 }
54
55 public function get_style_depends()
56 {
57 if ($this->upk_is_edit_mode()) {
58 return ['upk-all-styles'];
59 } else {
60 return ['upk-font', 'upk-amox-grid'];
61 }
62 }
63
64 public function get_script_depends()
65 {
66 if ($this->upk_is_edit_mode()) {
67 return ['upk-all-scripts'];
68 } else {
69 return ['upk-ajax-loadmore'];
70 }
71 }
72
73 public function get_custom_help_url()
74 {
75 return 'https://youtu.be/BeJ77OLErAk';
76 }
77
78 public function get_query()
79 {
80 return $this->_query;
81 }
82
83 public function has_widget_inner_wrapper(): bool {
84 return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
85 }
86
87 protected function register_controls() {
88 $this->start_controls_section(
89 'section_content_layout',
90 [
91 'label' => esc_html__('Layout', 'ultimate-post-kit'),
92 ]
93 );
94
95 $this->add_responsive_control(
96 'columns',
97 [
98 'label' => __('Columns', 'ultimate-post-kit'),
99 'type' => Controls_Manager::SELECT,
100 'default' => '3',
101 'tablet_default' => '2',
102 'mobile_default' => '1',
103 'options' => [
104 '1' => '1',
105 '2' => '2',
106 '3' => '3',
107 '4' => '4',
108 '5' => '5',
109 '6' => '6',
110 ],
111 'selectors' => [
112 '{{WRAPPER}} .upk-amox-grid' => 'grid-template-columns: repeat({{SIZE}}, 1fr);',
113 ],
114 ]
115 );
116
117 $this->add_responsive_control(
118 'row_gap',
119 [
120 'label' => esc_html__('Row Gap', 'ultimate-post-kit'),
121 'type' => Controls_Manager::SLIDER,
122 'selectors' => [
123 '{{WRAPPER}} .upk-amox-grid' => 'grid-row-gap: {{SIZE}}{{UNIT}};',
124 ],
125 ]
126 );
127
128 $this->add_responsive_control(
129 'column_gap',
130 [
131 'label' => esc_html__('Column Gap', 'ultimate-post-kit'),
132 'type' => Controls_Manager::SLIDER,
133 'selectors' => [
134 '{{WRAPPER}} .upk-amox-grid' => 'grid-column-gap: {{SIZE}}{{UNIT}};',
135 ],
136 ]
137 );
138
139 $this->add_responsive_control(
140 'image_height',
141 [
142 'label' => esc_html__('Image Height', 'ultimate-post-kit'),
143 'type' => Controls_Manager::SLIDER,
144 'range' => [
145 'px' => [
146 'min' => 100,
147 'max' => 800,
148 ],
149 ],
150 'selectors' => [
151 '{{WRAPPER}} .upk-amox-grid .upk-img-wrap' => 'height: {{SIZE}}px;',
152 ],
153 ]
154 );
155
156 $this->add_group_control(
157 Group_Control_Image_Size::get_type(),
158 [
159 'name' => 'primary_thumbnail',
160 'exclude' => ['custom'],
161 'default' => 'medium',
162 ]
163 );
164
165 $this->add_responsive_control(
166 'content_alignment',
167 [
168 'label' => __('Alignment', 'ultimate-post-kit'),
169 'type' => Controls_Manager::CHOOSE,
170 'options' => [
171 'left' => [
172 'title' => __('Left', 'ultimate-post-kit'),
173 'icon' => 'eicon-text-align-left',
174 ],
175 'center' => [
176 'title' => __('Center', 'ultimate-post-kit'),
177 'icon' => 'eicon-text-align-center',
178 ],
179 'right' => [
180 'title' => __('Right', 'ultimate-post-kit'),
181 'icon' => 'eicon-text-align-right',
182 ],
183 ],
184 'selectors' => [
185 '{{WRAPPER}} .upk-amox-grid .upk-item .upk-content' => 'text-align: {{VALUE}};',
186 ],
187 ]
188 );
189
190 $this->add_control(
191 'active_item',
192 [
193 'label' => __('Active Item', 'ultimate-post-kit') . BDTUPK_PC,
194 'type' => Controls_Manager::NUMBER,
195 'default' => 2,
196 'description' => __('Be more creative with your design by typing in your item number.', 'ultimate-post-kit'),
197 'separator' => 'before',
198 'classes' => BDTUPK_IS_PC,
199 ]
200 );
201
202 $this->end_controls_section();
203
204 //New Query Builder Settings
205 $this->start_controls_section(
206 'section_post_query_builder',
207 [
208 'label' => __('Query', 'ultimate-post-kit'),
209 'tab' => Controls_Manager::TAB_CONTENT,
210 ]
211 );
212
213 $this->add_control(
214 'item_limit',
215 [
216 'label' => esc_html__('Item Limit', 'ultimate-post-kit'),
217 'type' => Controls_Manager::SLIDER,
218 'range' => [
219 'px' => [
220 'min' => 0,
221 'max' => 21,
222 ],
223 ],
224 'default' => [
225 'size' => 6,
226 ],
227 ]
228 );
229
230 $this->register_query_builder_controls();
231
232 $this->end_controls_section();
233
234 $this->start_controls_section(
235 'section_content_additional',
236 [
237 'label' => esc_html__('Additional Options', 'ultimate-post-kit'),
238 ]
239 );
240
241 //Global Title Controls
242 $this->register_title_controls();
243
244 $this->add_control(
245 'show_category',
246 [
247 'label' => esc_html__('Category', 'ultimate-post-kit'),
248 'type' => Controls_Manager::SWITCHER,
249 'default' => 'yes',
250 'separator' => 'before',
251 ]
252 );
253
254 //Global Date Controls
255 $this->register_date_controls();
256
257 //Global Reading Time Controls
258 $this->register_reading_time_controls();
259
260 $this->add_control(
261 'meta_separator',
262 [
263 'label' => esc_html__('Separator', 'ultimate-post-kit'),
264 'type' => Controls_Manager::TEXT,
265 'default' => '.',
266 'label_block' => false,
267 ]
268 );
269
270 $this->add_control(
271 'show_comments',
272 [
273 'label' => esc_html__('Show Comments', 'ultimate-post-kit'),
274 'type' => Controls_Manager::SWITCHER,
275 'default' => 'yes',
276 'separator' => 'before',
277 ]
278 );
279
280 $this->add_control(
281 'show_pagination',
282 [
283 'label' => esc_html__('Pagination', 'ultimate-post-kit'),
284 'type' => Controls_Manager::SWITCHER,
285 'separator' => 'before',
286 ]
287 );
288
289 //Global Ajax Controls
290 $this->register_ajax_loadmore_controls();
291
292 $this->add_control(
293 'global_link',
294 [
295 'label' => esc_html__('Item Wrapper Link', 'ultimate-post-kit'),
296 'type' => Controls_Manager::SWITCHER,
297 'prefix_class' => 'upk-global-link-',
298 'description' => esc_html__('Be aware! When Item Wrapper Link activated then title link and read more link will not work', 'ultimate-post-kit'),
299 ]
300 );
301
302 $this->end_controls_section();
303
304 //Style
305 $this->start_controls_section(
306 'upk_section_style',
307 [
308 'label' => esc_html__('Items', 'ultimate-post-kit'),
309 'tab' => Controls_Manager::TAB_STYLE,
310 ]
311 );
312
313 $this->add_responsive_control(
314 'content_padding',
315 [
316 'label' => esc_html__('Content Padding', 'ultimate-post-kit'),
317 'type' => Controls_Manager::DIMENSIONS,
318 'size_units' => ['px', 'em', '%'],
319 'selectors' => [
320 '{{WRAPPER}} .upk-amox-grid .upk-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
321 ],
322 ]
323 );
324
325 $this->start_controls_tabs('tabs_item_style');
326
327 $this->start_controls_tab(
328 'tab_item_normal',
329 [
330 'label' => esc_html__('Normal', 'ultimate-post-kit'),
331 ]
332 );
333
334 $this->add_group_control(
335 Group_Control_Background::get_type(),
336 [
337 'name' => 'content_background',
338 'selector' => '{{WRAPPER}} .upk-amox-grid .upk-item',
339 ]
340 );
341
342 $this->add_group_control(
343 Group_Control_Border::get_type(),
344 [
345 'name' => 'item_border',
346 'selector' => '{{WRAPPER}} .upk-amox-grid .upk-item',
347 ]
348 );
349
350 $this->add_responsive_control(
351 'item_border_radius',
352 [
353 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
354 'type' => Controls_Manager::DIMENSIONS,
355 'size_units' => ['px', '%'],
356 'selectors' => [
357 '{{WRAPPER}} .upk-amox-grid .upk-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
358 ],
359 ]
360 );
361
362 $this->add_responsive_control(
363 'item_padding',
364 [
365 'label' => esc_html__('Padding', 'ultimate-post-kit'),
366 'type' => Controls_Manager::DIMENSIONS,
367 'size_units' => ['px', 'em', '%'],
368 'selectors' => [
369 '{{WRAPPER}} .upk-amox-grid .upk-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
370 ],
371 ]
372 );
373
374 $this->add_group_control(
375 Group_Control_Box_Shadow::get_type(),
376 [
377 'name' => 'item_box_shadow',
378 'selector' => '{{WRAPPER}} .upk-amox-grid .upk-item',
379 ]
380 );
381
382 $this->end_controls_tab();
383
384 $this->start_controls_tab(
385 'tab_item_hover',
386 [
387 'label' => esc_html__('Hover', 'ultimate-post-kit'),
388 ]
389 );
390
391 $this->add_group_control(
392 Group_Control_Background::get_type(),
393 [
394 'name' => 'content_hover_background',
395 'selector' => '{{WRAPPER}} .upk-amox-grid .upk-item:hover',
396 ]
397 );
398
399 $this->add_control(
400 'item_hover_border_color',
401 [
402 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
403 'type' => Controls_Manager::COLOR,
404 'condition' => [
405 'item_border_border!' => '',
406 ],
407 'selectors' => [
408 '{{WRAPPER}} .upk-amox-grid .upk-item:hover' => 'border-color: {{VALUE}};',
409 ],
410 ]
411 );
412
413 $this->add_group_control(
414 Group_Control_Box_Shadow::get_type(),
415 [
416 'name' => 'item_hover_box_shadow',
417 'selector' => '{{WRAPPER}} .upk-amox-grid .upk-item:hover',
418 ]
419 );
420
421 $this->end_controls_tab();
422
423 $this->end_controls_tabs();
424
425 $this->end_controls_section();
426
427 $this->start_controls_section(
428 'section_style_title',
429 [
430 'label' => esc_html__('Title', 'ultimate-post-kit'),
431 'tab' => Controls_Manager::TAB_STYLE,
432 'condition' => [
433 'show_title' => 'yes',
434 ],
435 ]
436 );
437
438 $this->add_control(
439 'title_style',
440 [
441 'label' => esc_html__('Style', 'ultimate-post-kit'),
442 'type' => Controls_Manager::SELECT,
443 'default' => 'underline',
444 'options' => [
445 '' => esc_html__('Default', 'ultimate-post-kit'),
446 'underline' => esc_html__('Underline', 'ultimate-post-kit'),
447 'middle-underline' => esc_html__('Middle Underline', 'ultimate-post-kit'),
448 'overline' => esc_html__('Overline', 'ultimate-post-kit'),
449 'middle-overline' => esc_html__('Middle Overline', 'ultimate-post-kit'),
450 ],
451 ]
452 );
453
454 $this->add_responsive_control(
455 'title_spacing',
456 [
457 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
458 'type' => Controls_Manager::SLIDER,
459 'range' => [
460 'px' => [
461 'min' => 0,
462 'max' => 50,
463 ],
464 ],
465 'selectors' => [
466 '{{WRAPPER}} .upk-amox-grid .upk-title' => 'padding-bottom: {{SIZE}}{{UNIT}};',
467 ],
468 ]
469 );
470
471 $this->add_group_control(
472 Group_Control_Typography::get_type(),
473 [
474 'name' => 'title_typography',
475 'label' => esc_html__('Typography', 'ultimate-post-kit'),
476 'selector' => '{{WRAPPER}} .upk-amox-grid .upk-title',
477 ]
478 );
479
480 $this->add_group_control(
481 Group_Control_Text_Shadow::get_type(),
482 [
483 'name' => 'title_text_shadow',
484 'label' => __('Text Shadow', 'ultimate-post-kit'),
485 'selector' => '{{WRAPPER}} .upk-amox-grid .upk-title',
486 ]
487 );
488
489 $this->start_controls_tabs('tabs_title_style');
490
491 $this->start_controls_tab(
492 'tab_title_normal',
493 [
494 'label' => esc_html__('Normal', 'ultimate-post-kit'),
495 ]
496 );
497
498 $this->add_control(
499 'title_color',
500 [
501 'label' => esc_html__('Color', 'ultimate-post-kit'),
502 'type' => Controls_Manager::COLOR,
503 'selectors' => [
504 '{{WRAPPER}} .upk-amox-grid .upk-title a' => 'color: {{VALUE}};',
505 ],
506 ]
507 );
508
509 $this->end_controls_tab();
510
511 $this->start_controls_tab(
512 'tab_title_hover',
513 [
514 'label' => esc_html__('Hover', 'ultimate-post-kit'),
515 ]
516 );
517
518 $this->add_control(
519 'title_color_hover',
520 [
521 'label' => esc_html__('Color', 'ultimate-post-kit'),
522 'type' => Controls_Manager::COLOR,
523 'selectors' => [
524 '{{WRAPPER}} .upk-amox-grid .upk-title a:hover' => 'color: {{VALUE}};',
525 ],
526 ]
527 );
528
529 $this->end_controls_tab();
530
531 $this->end_controls_tabs();
532
533 $this->end_controls_section();
534
535 $this->start_controls_section(
536 'section_style_meta',
537 [
538 'label' => esc_html__('Meta', 'ultimate-post-kit'),
539 'tab' => Controls_Manager::TAB_STYLE,
540 'conditions' => [
541 'relation' => 'or',
542 'terms' => [
543 [
544 'name' => 'show_date',
545 'value' => 'yes',
546 ],
547 [
548 'name' => 'show_comments',
549 'value' => 'yes',
550 ],
551 ],
552 ],
553 ]
554 );
555
556 $this->add_control(
557 'meta_color',
558 [
559 'label' => esc_html__('Color', 'ultimate-post-kit'),
560 'type' => Controls_Manager::COLOR,
561 'selectors' => [
562 '{{WRAPPER}} .upk-amox-grid .upk-meta' => 'color: {{VALUE}};',
563 ],
564 ]
565 );
566
567 $this->add_responsive_control(
568 'meta_space_between',
569 [
570 'label' => esc_html__('Space Between', 'ultimate-post-kit'),
571 'type' => Controls_Manager::SLIDER,
572 'range' => [
573 'px' => [
574 'min' => 0,
575 'max' => 50,
576 ],
577 ],
578 'selectors' => [
579 '{{WRAPPER}} .upk-amox-grid .upk-meta > div:before' => 'margin: 0 {{SIZE}}{{UNIT}};',
580 ],
581 ]
582 );
583
584 $this->add_group_control(
585 Group_Control_Typography::get_type(),
586 [
587 'name' => 'meta_typography',
588 'label' => esc_html__('Typography', 'ultimate-post-kit'),
589 'selector' => '{{WRAPPER}} .upk-amox-grid .upk-meta',
590 ]
591 );
592
593 $this->end_controls_section();
594
595 $this->start_controls_section(
596 'section_style_category',
597 [
598 'label' => esc_html__('Category', 'ultimate-post-kit'),
599 'tab' => Controls_Manager::TAB_STYLE,
600 'condition' => [
601 'show_category' => 'yes',
602 ],
603 ]
604 );
605
606 $this->add_responsive_control(
607 'category_bottom_spacing',
608 [
609 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
610 'type' => Controls_Manager::SLIDER,
611 'range' => [
612 'px' => [
613 'min' => 0,
614 'max' => 50,
615 ],
616 ],
617 'selectors' => [
618 '{{WRAPPER}} .upk-amox-grid .upk-category' => 'margin-bottom: {{SIZE}}{{UNIT}};',
619 ],
620 ]
621 );
622
623 $this->start_controls_tabs('tabs_category_style');
624
625 $this->start_controls_tab(
626 'tab_category_normal',
627 [
628 'label' => esc_html__('Normal', 'ultimate-post-kit'),
629 ]
630 );
631
632 $this->add_control(
633 'category_color',
634 [
635 'label' => esc_html__('Color', 'ultimate-post-kit'),
636 'type' => Controls_Manager::COLOR,
637 'selectors' => [
638 '{{WRAPPER}} .upk-amox-grid .upk-category a' => 'color: {{VALUE}};',
639 ],
640 ]
641 );
642
643 $this->add_group_control(
644 Group_Control_Background::get_type(),
645 [
646 'name' => 'category_background',
647 'selector' => '{{WRAPPER}} .upk-amox-grid .upk-category a',
648 ]
649 );
650
651 $this->add_group_control(
652 Group_Control_Border::get_type(),
653 [
654 'name' => 'category_border',
655 'selector' => '{{WRAPPER}} .upk-amox-grid .upk-category a',
656 ]
657 );
658
659 $this->add_responsive_control(
660 'category_border_radius',
661 [
662 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
663 'type' => Controls_Manager::DIMENSIONS,
664 'size_units' => ['px', '%'],
665 'selectors' => [
666 '{{WRAPPER}} .upk-amox-grid .upk-category a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
667 ],
668 ]
669 );
670
671 $this->add_responsive_control(
672 'category_padding',
673 [
674 'label' => esc_html__('Padding', 'ultimate-post-kit'),
675 'type' => Controls_Manager::DIMENSIONS,
676 'size_units' => ['px', 'em', '%'],
677 'selectors' => [
678 '{{WRAPPER}} .upk-amox-grid .upk-category a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
679 ],
680 ]
681 );
682
683 $this->add_responsive_control(
684 'category_spacing',
685 [
686 'label' => esc_html__('Space Between', 'ultimate-post-kit'),
687 'type' => Controls_Manager::SLIDER,
688 'range' => [
689 'px' => [
690 'min' => 0,
691 'max' => 50,
692 'step' => 2,
693 ],
694 ],
695 'selectors' => [
696 '{{WRAPPER}} .upk-amox-grid .upk-category' => 'gap: {{SIZE}}{{UNIT}};',
697 ],
698 ]
699 );
700
701 $this->add_group_control(
702 Group_Control_Box_Shadow::get_type(),
703 [
704 'name' => 'category_shadow',
705 'selector' => '{{WRAPPER}} .upk-amox-grid .upk-category a',
706 ]
707 );
708
709 $this->add_group_control(
710 Group_Control_Typography::get_type(),
711 [
712 'name' => 'category_typography',
713 'label' => esc_html__('Typography', 'ultimate-post-kit'),
714 'selector' => '{{WRAPPER}} .upk-amox-grid .upk-category a',
715 ]
716 );
717
718 $this->end_controls_tab();
719
720 $this->start_controls_tab(
721 'tab_category_hover',
722 [
723 'label' => esc_html__('Hover', 'ultimate-post-kit'),
724 ]
725 );
726
727 $this->add_control(
728 'category_hover_color',
729 [
730 'label' => esc_html__('Color', 'ultimate-post-kit'),
731 'type' => Controls_Manager::COLOR,
732 'selectors' => [
733 '{{WRAPPER}} .upk-amox-grid .upk-category a:hover' => 'color: {{VALUE}};',
734 ],
735 ]
736 );
737
738 $this->add_group_control(
739 Group_Control_Background::get_type(),
740 [
741 'name' => 'category_hover_background',
742 'selector' => '{{WRAPPER}} .upk-amox-grid .upk-category a:hover',
743 ]
744 );
745
746 $this->add_control(
747 'category_hover_border_color',
748 [
749 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
750 'type' => Controls_Manager::COLOR,
751 'condition' => [
752 'category_border_border!' => '',
753 ],
754 'selectors' => [
755 '{{WRAPPER}} .upk-amox-grid .upk-category a:hover' => 'border-color: {{VALUE}};',
756 ],
757 ]
758 );
759
760 $this->end_controls_tab();
761
762 if (_is_upk_pro_activated()) {
763 $this->start_controls_tab(
764 'tab_category_active',
765 [
766 'label' => esc_html__('Active', 'ultimate-post-kit'),
767 ]
768 );
769
770 $this->add_control(
771 'category_active_normal_heading',
772 [
773 'label' => esc_html__('NORMAL', 'ultimate-post-kit'),
774 'type' => Controls_Manager::HEADING,
775 ]
776 );
777
778 $this->end_controls_tab();
779 }
780
781 $this->end_controls_tabs();
782
783 $this->end_controls_section();
784
785 //Pagination
786 $this->start_controls_section(
787 'section_style_pagination',
788 [
789 'label' => esc_html__('Pagination', 'ultimate-post-kit'),
790 'tab' => Controls_Manager::TAB_STYLE,
791 'condition' => [
792 'show_pagination' => 'yes',
793 ],
794 ]
795 );
796
797 $this->start_controls_tabs('tabs_pagination_style');
798
799 $this->start_controls_tab(
800 'tab_pagination_normal',
801 [
802 'label' => esc_html__('Normal', 'ultimate-post-kit'),
803 ]
804 );
805
806 $this->add_control(
807 'pagination_color',
808 [
809 'label' => esc_html__('Color', 'ultimate-post-kit'),
810 'type' => Controls_Manager::COLOR,
811 'selectors' => [
812 '{{WRAPPER}} ul.upk-pagination li a, {{WRAPPER}} ul.upk-pagination li span' => 'color: {{VALUE}};',
813 ],
814 ]
815 );
816
817 $this->add_group_control(
818 Group_Control_Background::get_type(),
819 [
820 'name' => 'pagination_background',
821 'types' => ['classic', 'gradient'],
822 'selector' => '{{WRAPPER}} ul.upk-pagination li a',
823 'separator' => 'after',
824 ]
825 );
826
827 $this->add_group_control(
828 Group_Control_Border::get_type(),
829 [
830 'name' => 'pagination_border',
831 'label' => esc_html__('Border', 'ultimate-post-kit'),
832 'selector' => '{{WRAPPER}} ul.upk-pagination li a',
833 ]
834 );
835
836 $this->add_responsive_control(
837 'pagination_offset',
838 [
839 'label' => esc_html__('Offset', 'ultimate-post-kit'),
840 'type' => Controls_Manager::SLIDER,
841 'selectors' => [
842 '{{WRAPPER}} .upk-pagination' => 'margin-top: {{SIZE}}px;',
843 ],
844 ]
845 );
846
847 $this->add_responsive_control(
848 'pagination_space',
849 [
850 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
851 'type' => Controls_Manager::SLIDER,
852 'selectors' => [
853 '{{WRAPPER}} .upk-pagination' => 'margin-left: {{SIZE}}px;',
854 '{{WRAPPER}} .upk-pagination > *' => 'padding-left: {{SIZE}}px;',
855 ],
856 ]
857 );
858
859 $this->add_responsive_control(
860 'pagination_padding',
861 [
862 'label' => esc_html__('Padding', 'ultimate-post-kit'),
863 'type' => Controls_Manager::DIMENSIONS,
864 'selectors' => [
865 '{{WRAPPER}} ul.upk-pagination li a' => 'padding: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
866 ],
867 ]
868 );
869
870 $this->add_responsive_control(
871 'pagination_radius',
872 [
873 'label' => esc_html__('Radius', 'ultimate-post-kit'),
874 'type' => Controls_Manager::DIMENSIONS,
875 'selectors' => [
876 '{{WRAPPER}} ul.upk-pagination li a' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
877 ],
878 ]
879 );
880
881 $this->add_responsive_control(
882 'pagination_arrow_size',
883 [
884 'label' => esc_html__('Arrow Size', 'ultimate-post-kit'),
885 'type' => Controls_Manager::SLIDER,
886 'selectors' => [
887 '{{WRAPPER}} ul.upk-pagination li a svg' => 'height: {{SIZE}}px; width: auto;',
888 ],
889 ]
890 );
891
892 $this->add_group_control(
893 Group_Control_Typography::get_type(),
894 [
895 'name' => 'pagination_typography',
896 'label' => esc_html__('Typography', 'ultimate-post-kit'),
897 //'scheme' => Schemes\Typography::TYPOGRAPHY_4,
898 'selector' => '{{WRAPPER}} ul.upk-pagination li a, {{WRAPPER}} ul.upk-pagination li span',
899 ]
900 );
901
902 $this->end_controls_tab();
903
904 $this->start_controls_tab(
905 'tab_pagination_hover',
906 [
907 'label' => esc_html__('Hover', 'ultimate-post-kit'),
908 ]
909 );
910
911 $this->add_control(
912 'pagination_hover_color',
913 [
914 'label' => esc_html__('Color', 'ultimate-post-kit'),
915 'type' => Controls_Manager::COLOR,
916 'selectors' => [
917 '{{WRAPPER}} ul.upk-pagination li a:hover' => 'color: {{VALUE}};',
918 ],
919 ]
920 );
921
922 $this->add_control(
923 'pagination_hover_border_color',
924 [
925 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
926 'type' => Controls_Manager::COLOR,
927 'selectors' => [
928 '{{WRAPPER}} ul.upk-pagination li a:hover' => 'border-color: {{VALUE}};',
929 ],
930 ]
931 );
932
933 $this->add_group_control(
934 Group_Control_Background::get_type(),
935 [
936 'name' => 'pagination_hover_background',
937 'types' => ['classic', 'gradient'],
938 'selector' => '{{WRAPPER}} ul.upk-pagination li a:hover',
939 ]
940 );
941
942 $this->end_controls_tab();
943
944 $this->start_controls_tab(
945 'tab_pagination_active',
946 [
947 'label' => esc_html__('Active', 'ultimate-post-kit'),
948 ]
949 );
950
951 $this->add_control(
952 'pagination_active_color',
953 [
954 'label' => esc_html__('Color', 'ultimate-post-kit'),
955 'type' => Controls_Manager::COLOR,
956 'selectors' => [
957 '{{WRAPPER}} ul.upk-pagination li.upk-active a' => 'color: {{VALUE}};',
958 ],
959 ]
960 );
961
962 $this->add_control(
963 'pagination_active_border_color',
964 [
965 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
966 'type' => Controls_Manager::COLOR,
967 'selectors' => [
968 '{{WRAPPER}} ul.upk-pagination li.upk-active a' => 'border-color: {{VALUE}};',
969 ],
970 ]
971 );
972
973 $this->add_group_control(
974 Group_Control_Background::get_type(),
975 [
976 'name' => 'pagination_active_background',
977 'selector' => '{{WRAPPER}} ul.upk-pagination li.upk-active a',
978 ]
979 );
980
981 $this->end_controls_tab();
982
983 $this->end_controls_tabs();
984
985 $this->end_controls_section();
986
987 //Global Ajax Loadmore Style Controls
988 $this->register_ajax_loadmore_style_controls();
989 }
990
991 /**
992 * Main query render for this widget
993 * @param $posts_per_page number item query limit
994 */
995 public function query_posts($posts_per_page)
996 {
997 $default = $this->getGroupControlQueryArgs();
998 if ($posts_per_page) {
999 $args['posts_per_page'] = $posts_per_page;
1000 $args['paged'] = max(1, get_query_var('paged'), get_query_var('page'));
1001 }
1002 $args = array_merge($default, $args);
1003 $this->_query = new WP_Query($args);
1004 }
1005
1006 public function render_comments($id = 0)
1007 {
1008
1009 if (!$this->get_settings('show_comments')) {
1010 return;
1011 }
1012 ?>
1013
1014 <div class="upk-comments upk-flex upk-flex-middle">
1015 <i class="upk-icon-post-comments"></i>
1016 <span><?php echo get_comments_number($id) ?></span>
1017 </div>
1018
1019 <?php
1020 }
1021
1022 public function render_post_grid_item($post_id, $image_size, $active_item)
1023 {
1024 $settings = $this->get_settings_for_display();
1025
1026 if ('yes' == $settings['global_link']) {
1027
1028 $this->add_render_attribute('grid-item', 'onclick', "window.open('" . esc_url(get_permalink()) . "', '_self')", true);
1029 }
1030
1031 $this->add_render_attribute('grid-item', 'class', 'upk-item ' . $active_item, true);
1032
1033 ?>
1034 <div <?php $this->print_render_attribute_string('grid-item');?>>
1035 <div class="upk-img-wrap">
1036 <?php $this->render_image(get_post_thumbnail_id($post_id), $image_size);?>
1037 </div>
1038 <div class="upk-content">
1039 <?php $this->render_category();?>
1040 <?php $this->render_title(substr($this->get_name(), 4));?>
1041
1042 <?php if ($settings['show_comments'] or $settings['show_date'] or $settings['show_reading_time']): ?>
1043 <div class="upk-meta upk-flex-inline upk-flex-middle">
1044 <?php $this->render_date();?>
1045 <?php if (_is_upk_pro_activated()):
1046 if ('yes' === $settings['show_reading_time']): ?>
1047 <div class="upk-reading-time" data-separator="<?php echo esc_html($settings['meta_separator']); ?>">
1048 <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'] ) );?>
1049 </div>
1050 <?php endif;?>
1051 <?php endif;?>
1052 <div data-separator="<?php echo esc_html($settings['meta_separator']); ?>">
1053 <?php $this->render_comments($post_id);?>
1054 </div>
1055 </div>
1056 <?php endif;?>
1057 </div>
1058 </div>
1059
1060
1061 <?php
1062 }
1063
1064 protected function render()
1065 {
1066 $settings = $this->get_settings_for_display();
1067
1068 $this->query_posts($settings['item_limit']['size']);
1069 $wp_query = $this->get_query();
1070
1071 if (!$wp_query->found_posts) {
1072 return;
1073 }
1074
1075 $this->add_render_attribute('grid-wrap', 'class', 'upk-amox-grid upk-ajax-grid-wrap');
1076 $this->add_render_attribute(
1077 [
1078 'upk-amox-grid-container' => [
1079 'class' => 'upk-amox-grid-container upk-ajax-grid',
1080 'data-loadmore' => [
1081 wp_json_encode(
1082 array_filter([
1083 'loadmore_enable' => $settings['ajax_loadmore_enable'],
1084 'loadmore_btn' => $settings['ajax_loadmore_btn'],
1085 'infinite_scroll' => $settings['ajax_loadmore_infinite_scroll'],
1086 ])
1087 ),
1088 ],
1089 ],
1090 ]
1091 );
1092
1093 if ( $settings['ajax_loadmore_enable'] == 'yes' ) {
1094 $ajax_settings = [
1095 'posts_source' => isset( $settings['posts_source'] ) ? $settings['posts_source'] : 'post',
1096 'posts_per_page' => isset( $posts_load ) ? $posts_load : 6,
1097 'ajax_item_load' => isset( $settings['ajax_loadmore_items'] ) ? $settings['ajax_loadmore_items'] : 3,
1098 'posts_selected_ids' => isset( $settings['posts_selected_ids'] ) ? $settings['posts_selected_ids'] : '',
1099 'posts_include_by' => isset( $settings['posts_include_by'] ) ? $settings['posts_include_by'] : [],
1100 'posts_include_author_ids' => isset( $settings['posts_include_author_ids'] ) ? $settings['posts_include_author_ids'] : '',
1101 'posts_include_term_ids' => isset( $settings['posts_include_term_ids'] ) ? $settings['posts_include_term_ids'] : '',
1102 'posts_exclude_by' => isset( $settings['posts_exclude_by'] ) ? $settings['posts_exclude_by'] : [],
1103 'posts_exclude_ids' => isset( $settings['posts_exclude_ids'] ) ? $settings['posts_exclude_ids'] : '',
1104 'posts_exclude_author_ids' => isset( $settings['posts_exclude_author_ids'] ) ? $settings['posts_exclude_author_ids'] : '',
1105 'posts_exclude_term_ids' => isset( $settings['posts_exclude_term_ids'] ) ? $settings['posts_exclude_term_ids'] : '',
1106 'posts_offset' => isset( $settings['posts_offset'] ) ? $settings['posts_offset'] : 0,
1107 'posts_select_date' => isset( $settings['posts_select_date'] ) ? $settings['posts_select_date'] : '',
1108 'posts_date_before' => isset( $settings['posts_date_before'] ) ? $settings['posts_date_before'] : '',
1109 'posts_date_after' => isset( $settings['posts_date_after'] ) ? $settings['posts_date_after'] : '',
1110 'posts_orderby' => isset( $settings['posts_orderby'] ) ? $settings['posts_orderby'] : 'date',
1111 'posts_order' => isset( $settings['posts_order'] ) ? $settings['posts_order'] : 'DESC',
1112 'posts_ignore_sticky_posts' => isset( $settings['posts_ignore_sticky_posts'] ) ? $settings['posts_ignore_sticky_posts'] : 'no',
1113 'posts_only_with_featured_image' => isset( $settings['posts_only_with_featured_image'] ) ? $settings['posts_only_with_featured_image'] : 'no',
1114 // Grid Settings
1115 'show_title' => isset( $settings['show_title'] ) ? $settings['show_title'] : 'yes',
1116 'title_tags' => isset( $settings['title_tags'] ) ? $settings['title_tags'] : 'h3',
1117 'show_date' => isset( $settings['show_date'] ) ? $settings['show_date'] : 'yes',
1118 'show_time' => isset( $settings['show_time'] ) ? $settings['show_time'] : 'no',
1119 'show_category' => isset( $settings['show_category'] ) ? $settings['show_category'] : 'yes',
1120 'show_comments' => isset( $settings['show_comments'] ) ? $settings['show_comments'] : 'yes',
1121 'show_reading_time' => isset( $settings['show_reading_time'] ) ? $settings['show_reading_time'] : 'no',
1122 'avg_reading_speed' => isset( $settings['avg_reading_speed'] ) ? $settings['avg_reading_speed'] : 200,
1123 'upk_link_new_tab' => isset( $settings['upk_link_new_tab'] ) ? $settings['upk_link_new_tab'] : 'no',
1124 'meta_separator' => isset( $settings['meta_separator'] ) ? $settings['meta_separator'] : '.',
1125 'human_diff_time' => isset( $settings['human_diff_time'] ) ? $settings['human_diff_time'] : 'no',
1126 'human_diff_time_short' => isset( $settings['human_diff_time_short'] ) ? $settings['human_diff_time_short'] : 'no',
1127 'title_style' => isset( $settings['title_style'] ) ? $settings['title_style'] : 'underline',
1128 'global_link' => isset( $settings['global_link'] ) ? $settings['global_link'] : 'no',
1129 ];
1130
1131 $this->add_render_attribute(
1132 [
1133 'upk-amox-grid-container' => [
1134 'data-settings' => [
1135 wp_json_encode( $ajax_settings ),
1136 ],
1137 ],
1138 ]
1139 );
1140 }
1141
1142 if (isset($settings['upk_in_animation_show']) && ($settings['upk_in_animation_show'] == 'yes')) {
1143 $this->add_render_attribute('grid-wrap', 'class', 'upk-in-animation');
1144 if (isset($settings['upk_in_animation_delay']['size'])) {
1145 $this->add_render_attribute('grid-wrap', 'data-in-animation-delay', $settings['upk_in_animation_delay']['size']);
1146 }
1147 }
1148
1149 ?>
1150 <div <?php $this->print_render_attribute_string('upk-amox-grid-container');?>>
1151 <div <?php $this->print_render_attribute_string('grid-wrap');?>>
1152 <?php
1153 $i = 0;
1154 while ($wp_query->have_posts()):
1155 $wp_query->the_post();
1156 $thumbnail_size = $settings['primary_thumbnail_size'];
1157
1158 $i++;
1159 $active_item = '';
1160 if (_is_upk_pro_activated()) {
1161 $active_item = apply_filters('amox_grid_active_item', $this, $i);
1162 }
1163
1164 ?>
1165 <?php $this->render_post_grid_item(get_the_ID(), $thumbnail_size, $active_item);?>
1166 <?php endwhile;?>
1167 </div>
1168 </div>
1169
1170 <?php $this->render_ajax_loadmore(); ?>
1171
1172 <?php
1173
1174 if ($settings['show_pagination']) {?>
1175 <div class="ep-pagination">
1176 <?php ultimate_post_kit_post_pagination($wp_query, $this->get_id());?>
1177 </div>
1178 <?php
1179 }
1180 wp_reset_postdata();
1181 }
1182 }
1183