PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / 4.1.16
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets v4.1.16
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 / alice-grid / widgets / alice-grid.php

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

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