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

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

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