PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / trunk
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets vtrunk
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 / maple-grid / widgets / maple-grid.php

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

1,491 lines 44.6 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\MapleGrid\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')) {
19 exit;
20 } // Exit if accessed directly
21
22 class Maple_Grid extends Group_Control_Query {
23
24 use Global_Widget_Controls;
25 use Global_Widget_Functions;
26
27 private $_query = null;
28
29 public function get_name() {
30 return 'upk-maple-grid';
31 }
32
33 public function get_title() {
34 return BDTUPK . esc_html__('Maple Grid', 'ultimate-post-kit');
35 }
36
37 public function get_icon() {
38 return 'upk-widget-icon upk-icon-maple-grid';
39 }
40
41 public function get_categories() {
42 return ['ultimate-post-kit'];
43 }
44
45 public function get_keywords() {
46 return ['post', 'grid', 'blog', 'recent', 'news', 'maple'];
47 }
48
49 public function get_style_depends() {
50 if ($this->upk_is_edit_mode()) {
51 return ['upk-all-styles'];
52 } else {
53 return ['upk-font', 'upk-maple-grid'];
54 }
55 }
56
57 public function get_script_depends() {
58 if ($this->upk_is_edit_mode()) {
59 return ['upk-all-scripts'];
60 } else {
61 return ['upk-ajax-loadmore'];
62 }
63 }
64
65 public function get_custom_help_url() {
66 return 'https://youtu.be/teraPP36sgQ';
67 }
68
69 public function get_query() {
70 return $this->_query;
71 }
72
73 public function has_widget_inner_wrapper(): bool {
74 return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
75 }
76
77
78 protected function register_controls() {
79 $this->start_controls_section(
80 'section_content_layout',
81 [
82 'label' => esc_html__('Layout', 'ultimate-post-kit'),
83 ]
84 );
85
86 $this->add_control(
87 'grid_style',
88 [
89 'label' => esc_html__('Layout Style', 'ultimate-post-kit'),
90 'type' => Controls_Manager::SELECT,
91 'default' => '1',
92 'options' => [
93 '1' => esc_html__('Style 01', 'ultimate-post-kit'),
94 '2' => esc_html__('Style 02', 'ultimate-post-kit'),
95 '3' => esc_html__('Style 03', 'ultimate-post-kit'),
96 '4' => esc_html__('Style 04', 'ultimate-post-kit'),
97 '5' => esc_html__('Style 05', 'ultimate-post-kit'),
98 ],
99 ]
100 );
101
102 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- established hook name relied on across the plugin family; renaming would break integration.
103 $column_size = apply_filters('upk_column_size', '');
104
105 $this->add_responsive_control(
106 'columns',
107 [
108 'label' => __('Columns', 'ultimate-post-kit') . BDTUPK_PC,
109 'type' => Controls_Manager::SELECT,
110 'default' => '2',
111 'tablet_default' => '2',
112 'mobile_default' => '1',
113 'options' => [
114 '1' => '1',
115 '2' => '2',
116 '3' => '3',
117 '4' => '4',
118 '5' => '5',
119 '6' => '6',
120 ],
121 'selectors' => [
122 '{{WRAPPER}} .upk-maple-grid .upk-style-3, {{WRAPPER}} .upk-maple-grid .upk-style-4' => $column_size,
123 ],
124 'condition' => [
125 'grid_style' => ['3', '4']
126 ],
127 'classes' => BDTUPK_IS_PC
128 ]
129 );
130
131 $this->add_responsive_control(
132 'row_gap',
133 [
134 'label' => esc_html__('Row Gap', 'ultimate-post-kit'),
135 'type' => Controls_Manager::SLIDER,
136 'selectors' => [
137 '{{WRAPPER}} .upk-maple-grid .upk-post-grid' => 'grid-row-gap: {{SIZE}}{{UNIT}};',
138 ]
139 ]
140 );
141
142 $this->add_responsive_control(
143 'column_gap',
144 [
145 'label' => esc_html__('Column Gap', 'ultimate-post-kit'),
146 'type' => Controls_Manager::SLIDER,
147 'selectors' => [
148 '{{WRAPPER}} .upk-maple-grid .upk-post-grid' => 'grid-column-gap: {{SIZE}}{{UNIT}};',
149 ]
150 ]
151 );
152
153 $this->add_responsive_control(
154 'primary_item_height',
155 [
156 'label' => esc_html__('Primary Image Height', 'ultimate-post-kit'),
157 'type' => Controls_Manager::SLIDER,
158 'range' => [
159 'px' => [
160 'min' => 100,
161 'max' => 800,
162 ],
163 ],
164 'selectors' => [
165 '{{WRAPPER}} .upk-maple-grid .upk-style-1 .upk-item:nth-child(6n+1) .upk-main-image .upk-img, {{WRAPPER}} .upk-maple-grid .upk-style-1 .upk-item:nth-child(6n+2) .upk-main-image .upk-img, {{WRAPPER}} .upk-maple-grid .upk-style-2 .upk-item:nth-child(5n+1) .upk-main-image .upk-img, {{WRAPPER}} .upk-maple-grid .upk-style-4 .upk-item:nth-child(n+1) .upk-main-image .upk-img, {{WRAPPER}} .upk-maple-grid .upk-style-5 .upk-item:nth-child(5n+3) .upk-main-image .upk-img, {{WRAPPER}} .upk-maple-grid .upk-style-5 .upk-item:nth-child(5n+1) .upk-main-image .upk-img' => 'height: {{SIZE}}px;',
166 ],
167 'condition' => [
168 'grid_style' => ['1', '2', '4', '5']
169 ]
170 ]
171 );
172
173 $this->add_responsive_control(
174 'secondary_image_height',
175 [
176 'label' => esc_html__('Secondary Image Height', 'ultimate-post-kit'),
177 'type' => Controls_Manager::SLIDER,
178 'range' => [
179 'px' => [
180 'min' => 100,
181 'max' => 800,
182 ],
183 ],
184 'selectors' => [
185 '{{WRAPPER}} .upk-maple-grid .upk-style-1 .upk-item:nth-child(6n+3) .upk-main-image, {{WRAPPER}} .upk-maple-grid .upk-style-1 .upk-item:nth-child(6n+4) .upk-main-image, {{WRAPPER}} .upk-maple-grid .upk-style-1 .upk-item:nth-child(6n+5) .upk-main-image, {{WRAPPER}} .upk-maple-grid .upk-style-1 .upk-item:nth-child(6n+6) .upk-main-image, {{WRAPPER}} .upk-maple-grid .upk-style-2 .upk-item:nth-child(5n+2) .upk-main-image, {{WRAPPER}} .upk-maple-grid .upk-style-2 .upk-item:nth-child(5n+3) .upk-main-image, {{WRAPPER}} .upk-maple-grid .upk-style-2 .upk-item:nth-child(5n+4) .upk-main-image, {{WRAPPER}} .upk-maple-grid .upk-style-2 .upk-item:nth-child(5n+5) .upk-main-image, {{WRAPPER}} .upk-maple-grid .upk-style-5 .upk-item:nth-child(5n+2) .upk-main-image, {{WRAPPER}} .upk-maple-grid .upk-style-5 .upk-item:nth-child(5n+4) .upk-main-image, {{WRAPPER}} .upk-maple-grid .upk-style-5 .upk-item:nth-child(5n+5) .upk-main-image, {{WRAPPER}} .upk-maple-grid .upk-style-3 .upk-item:nth-child(n+1) .upk-main-image' => 'height: {{SIZE}}px;',
186 ],
187 'condition' => [
188 'grid_style!' => ['4']
189 ]
190 ]
191 );
192
193 $this->add_responsive_control(
194 'secondary_image_width',
195 [
196 'label' => esc_html__('Secondary Image Width', 'ultimate-post-kit'),
197 'type' => Controls_Manager::SLIDER,
198 'range' => [
199 'px' => [
200 'min' => 100,
201 'max' => 800,
202 ],
203 ],
204 'selectors' => [
205 '{{WRAPPER}} .upk-maple-grid .upk-style-1 .upk-item:nth-child(6n+3) .upk-main-image, {{WRAPPER}} .upk-maple-grid .upk-style-1 .upk-item:nth-child(6n+4) .upk-main-image, {{WRAPPER}} .upk-maple-grid .upk-style-1 .upk-item:nth-child(6n+5) .upk-main-image, {{WRAPPER}} .upk-maple-grid .upk-style-1 .upk-item:nth-child(6n+6) .upk-main-image, {{WRAPPER}} .upk-maple-grid .upk-style-2 .upk-item:nth-child(5n+2) .upk-main-image, {{WRAPPER}} .upk-maple-grid .upk-style-2 .upk-item:nth-child(5n+3) .upk-main-image, {{WRAPPER}} .upk-maple-grid .upk-style-2 .upk-item:nth-child(5n+4) .upk-main-image, {{WRAPPER}} .upk-maple-grid .upk-style-2 .upk-item:nth-child(5n+5) .upk-main-image, {{WRAPPER}} .upk-maple-grid .upk-style-5 .upk-item:nth-child(5n+2) .upk-main-image, {{WRAPPER}} .upk-maple-grid .upk-style-5 .upk-item:nth-child(5n+4) .upk-main-image, {{WRAPPER}} .upk-maple-grid .upk-style-5 .upk-item:nth-child(5n+5) .upk-main-image, {{WRAPPER}} .upk-maple-grid .upk-style-3 .upk-item:nth-child(n+1) .upk-main-image' => 'width: {{SIZE}}px;',
206 ],
207 'condition' => [
208 'grid_style!' => ['4']
209 ]
210 ]
211 );
212
213 $this->add_group_control(
214 Group_Control_Image_Size::get_type(),
215 [
216 'name' => 'primary_thumbnail',
217 // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour.
218 'exclude' => ['custom'],
219 'default' => 'medium',
220 ]
221 );
222
223 $this->add_control(
224 'content_alignment',
225 [
226 'label' => __('Alignment', 'ultimate-post-kit'),
227 'type' => Controls_Manager::CHOOSE,
228 'options' => [
229 'left' => [
230 'title' => __('Left', 'ultimate-post-kit'),
231 'icon' => 'eicon-text-align-left',
232 ],
233 'center' => [
234 'title' => __('Center', 'ultimate-post-kit'),
235 'icon' => 'eicon-text-align-center',
236 ],
237 'right' => [
238 'title' => __('Right', 'ultimate-post-kit'),
239 'icon' => 'eicon-text-align-right',
240 ],
241 ],
242 'selectors' => [
243 '{{WRAPPER}} .upk-maple-grid .upk-content-inner' => 'text-align: {{VALUE}};',
244 ],
245 'prefix_class' => 'upk-maple-content--',
246 'render_type' => 'template'
247 ]
248 );
249
250 $this->end_controls_section();
251
252 // Query Settings
253 $this->start_controls_section(
254 'section_post_query_builder',
255 [
256 'label' => __('Query', 'ultimate-post-kit'),
257 'tab' => Controls_Manager::TAB_CONTENT,
258 ]
259 );
260
261 $this->add_control(
262 'item_limit',
263 [
264 'label' => esc_html__('Item Limit', 'ultimate-post-kit'),
265 'type' => Controls_Manager::SLIDER,
266 'range' => [
267 'px' => [
268 'min' => 0,
269 'max' => 24,
270 'step' => 6
271 ],
272 ],
273 'default' => [
274 'size' => 6,
275 ],
276 'condition' => [
277 'grid_style!' => ['2', '5'],
278 'posts_source!' => 'current_query'
279 ]
280 ]
281 );
282
283 $this->add_control(
284 'item_limit_2',
285 [
286 'label' => esc_html__('Item Limit', 'ultimate-post-kit'),
287 'type' => Controls_Manager::SLIDER,
288 'range' => [
289 'px' => [
290 'min' => 0,
291 'max' => 20,
292 'step' => 5
293 ],
294 ],
295 'default' => [
296 'size' => 5,
297 ],
298 'condition' => [
299 'grid_style' => ['2', '5'],
300 'posts_source!' => 'current_query'
301 ]
302 ]
303 );
304
305 $this->register_query_builder_controls();
306
307 $this->end_controls_section();
308
309 $this->start_controls_section(
310 'section_content_additional',
311 [
312 'label' => esc_html__('Additional Options', 'ultimate-post-kit'),
313 ]
314 );
315
316 //Global Title Controls
317 $this->register_title_controls();
318
319 $this->add_control(
320 'show_excerpt',
321 [
322 'label' => esc_html__('Show Text', 'ultimate-post-kit'),
323 'type' => Controls_Manager::SWITCHER,
324 'default' => 'yes',
325 'condition' => [
326 'grid_style!' => '3'
327 ]
328 ]
329 );
330
331 $this->add_control(
332 'excerpt_length',
333 [
334 'label' => esc_html__('Text Limit', 'ultimate-post-kit'),
335 'description' => esc_html__('It\'s just work for main content, but not working with excerpt. If you set 0 so you will get full main content.', 'ultimate-post-kit'),
336 'type' => Controls_Manager::NUMBER,
337 'default' => 30,
338 'condition' => [
339 'show_excerpt' => 'yes',
340 'grid_style!' => '3'
341 ],
342 ]
343 );
344 $this->add_control(
345 'ellipsis',
346 [
347 'label' => esc_html__('Ellipsis', 'ultimate-post-kit'),
348 'type' => Controls_Manager::TEXT,
349 'condition' => [
350 'show_excerpt' => 'yes',
351 'excerpt_length!' => [0, ''],
352 'grid_style!' => '3'
353 ],
354 'ai' => [
355 'active' => false,
356 ],
357 ]
358 );
359
360 $this->add_control(
361 'strip_shortcode',
362 [
363 'label' => esc_html__('Strip Shortcode', 'ultimate-post-kit'),
364 'type' => Controls_Manager::SWITCHER,
365 'default' => 'yes',
366 'condition' => [
367 'show_excerpt' => 'yes',
368 'grid_style!' => '3'
369 ],
370 ]
371 );
372
373 $this->add_control(
374 'show_author_avatar',
375 [
376 'label' => esc_html__('Show Author Avatar', 'ultimate-post-kit'),
377 'type' => Controls_Manager::SWITCHER,
378 'default' => 'yes',
379 'condition' => [
380 'grid_style!' => '3'
381 ]
382 ]
383 );
384
385 $this->add_control(
386 'show_author_name',
387 [
388 'label' => esc_html__('Show Author Name', 'ultimate-post-kit'),
389 'type' => Controls_Manager::SWITCHER,
390 'default' => 'yes',
391 'condition' => [
392 'grid_style!' => '3'
393 ]
394 ]
395 );
396
397 $this->add_control(
398 'show_category',
399 [
400 'label' => esc_html__('Show Category', 'ultimate-post-kit'),
401 'type' => Controls_Manager::SWITCHER,
402 'default' => 'yes',
403 'condition' => [
404 'grid_style!' => '3'
405 ]
406 ]
407 );
408
409 $this->add_control(
410 'show_post_format',
411 [
412 'label' => esc_html__('Show Post Format', 'ultimate-post-kit'),
413 'type' => Controls_Manager::SWITCHER,
414 'default' => 'yes',
415 'condition' => [
416 'grid_style!' => '3'
417 ]
418 ]
419 );
420
421 //Global Date Controls
422 $this->register_date_controls();
423
424 //Global Reading Time Controls
425 $this->register_reading_time_controls();
426
427 $this->add_control(
428 'meta_separator',
429 [
430 'label' => __('Separator', 'ultimate-post-kit'),
431 'type' => Controls_Manager::TEXT,
432 'default' => '-',
433 'label_block' => false,
434 ]
435 );
436
437 $this->add_control(
438 'show_pagination',
439 [
440 'label' => esc_html__('Show Pagination', 'ultimate-post-kit'),
441 'type' => Controls_Manager::SWITCHER,
442 'separator' => 'before'
443 ]
444 );
445
446 //Global Ajax Controls
447 $this->register_ajax_loadmore_controls();
448
449 $this->add_control(
450 'global_link',
451 [
452 'label' => __('Item Wrapper Link', 'ultimate-post-kit'),
453 'type' => Controls_Manager::SWITCHER,
454 'prefix_class' => 'upk-global-link-',
455 'description' => __('Be aware! When Item Wrapper Link activated then title link and read more link will not work', 'ultimate-post-kit'),
456 'separator' => 'before'
457 ]
458 );
459
460 $this->end_controls_section();
461
462 $this->start_controls_section(
463 'upk_section_style',
464 [
465 'label' => esc_html__('Items', 'ultimate-post-kit'),
466 'tab' => Controls_Manager::TAB_STYLE,
467 ]
468 );
469
470 $this->add_group_control(
471 Group_Control_Border::get_type(),
472 [
473 'name' => 'item_border',
474 'label' => __('Border', 'ultimate-post-kit'),
475 'placeholder' => '1px',
476 'default' => '1px',
477 'selector' => '{{WRAPPER}} .upk-maple-grid .upk-item',
478 ]
479 );
480
481 $this->add_responsive_control(
482 'item_border_radius',
483 [
484 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
485 'type' => Controls_Manager::DIMENSIONS,
486 'size_units' => ['px', '%'],
487 'selectors' => [
488 '{{WRAPPER}} .upk-maple-grid .upk-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
489 ],
490 ]
491 );
492
493 $this->add_responsive_control(
494 'content_padding',
495 [
496 'label' => __('Content Padding', 'ultimate-post-kit'),
497 'type' => Controls_Manager::DIMENSIONS,
498 'size_units' => ['px', 'em', '%'],
499 'selectors' => [
500 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
501 ],
502 ]
503 );
504
505 $this->add_group_control(
506 Group_Control_Background::get_type(),
507 [
508 'name' => 'itam_background',
509 'selector' => '{{WRAPPER}} .upk-maple-grid .upk-item',
510 ]
511 );
512
513 $this->add_control(
514 'item_image_heading',
515 [
516 'label' => esc_html__('Image', 'ultimate-post-kit'),
517 'type' => Controls_Manager::HEADING,
518 'separator' => 'before'
519 ]
520 );
521
522 $this->add_responsive_control(
523 'item_image_border_radius',
524 [
525 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
526 'type' => Controls_Manager::DIMENSIONS,
527 'size_units' => ['px', '%'],
528 'selectors' => [
529 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-main-image' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
530 ],
531 ]
532 );
533
534 $this->end_controls_section();
535
536 $this->start_controls_section(
537 'section_style_title',
538 [
539 'label' => esc_html__('Title', 'ultimate-post-kit'),
540 'tab' => Controls_Manager::TAB_STYLE,
541 'condition' => [
542 'show_title' => 'yes',
543 ],
544 ]
545 );
546
547 $this->add_control(
548 'title_style',
549 [
550 'label' => esc_html__('Style', 'ultimate-post-kit'),
551 'type' => Controls_Manager::SELECT,
552 'default' => 'underline',
553 'options' => [
554 '' => esc_html__('Default', 'ultimate-post-kit'),
555 'underline' => esc_html__('Underline', 'ultimate-post-kit'),
556 'middle-underline' => esc_html__('Middle Underline', 'ultimate-post-kit'),
557 'overline' => esc_html__('Overline', 'ultimate-post-kit'),
558 'middle-overline' => esc_html__('Middle Overline', 'ultimate-post-kit'),
559 ],
560 ]
561 );
562
563 $this->add_control(
564 'title_color',
565 [
566 'label' => esc_html__('Color', 'ultimate-post-kit'),
567 'type' => Controls_Manager::COLOR,
568 'selectors' => [
569 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-title a' => 'color: {{VALUE}};',
570 ],
571 ]
572 );
573
574 $this->add_control(
575 'title_hover_color',
576 [
577 'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
578 'type' => Controls_Manager::COLOR,
579 'selectors' => [
580 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-title a:hover' => 'color: {{VALUE}};',
581 ],
582 ]
583 );
584
585 $this->add_responsive_control(
586 'title_spacing',
587 [
588 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
589 'type' => Controls_Manager::SLIDER,
590 'range' => [
591 'px' => [
592 'min' => 0,
593 'max' => 50,
594 'step' => 2,
595 ],
596 ],
597 'selectors' => [
598 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-title' => 'margin-bottom: {{SIZE}}{{UNIT}};',
599 ],
600 ]
601 );
602
603 $this->add_group_control(
604 Group_Control_Typography::get_type(),
605 [
606 'name' => 'title_typography',
607 'label' => esc_html__('Typography', 'ultimate-post-kit'),
608 'selector' => '{{WRAPPER}} .upk-maple-grid .upk-item .upk-title',
609 ]
610 );
611
612 $this->add_group_control(
613 Group_Control_Typography::get_type(),
614 [
615 'name' => 'secondary_title_typography',
616 'label' => esc_html__('Secondary Typography', 'ultimate-post-kit'),
617 'selector' => '{{WRAPPER}} .upk-maple-grid .upk-style-1 .upk-item:nth-child(6n+3) .upk-title, {{WRAPPER}} .upk-maple-grid .upk-style-1 .upk-item:nth-child(6n+4) .upk-title, {{WRAPPER}} .upk-maple-grid .upk-style-1 .upk-item:nth-child(6n+5) .upk-title, {{WRAPPER}} .upk-maple-grid .upk-style-1 .upk-item:nth-child(6n+6) .upk-title, {{WRAPPER}} .upk-maple-grid .upk-style-2 .upk-item:nth-child(5n+2) .upk-title, {{WRAPPER}} .upk-maple-grid .upk-style-2 .upk-item:nth-child(5n+3) .upk-title, {{WRAPPER}} .upk-maple-grid .upk-style-2 .upk-item:nth-child(5n+4) .upk-title, {{WRAPPER}} .upk-maple-grid .upk-style-2 .upk-item:nth-child(5n+5) .upk-title, {{WRAPPER}} .upk-maple-grid .upk-style-5 .upk-item:nth-child(5n+2) .upk-title, {{WRAPPER}} .upk-maple-grid .upk-style-5 .upk-item:nth-child(5n+4) .upk-title, {{WRAPPER}} .upk-maple-grid .upk-style-5 .upk-item:nth-child(5n+5) .upk-title',
618 ]
619 );
620
621 $this->add_control(
622 'title_advanced_style',
623 [
624 'label' => esc_html__('Advanced Style', 'ultimate-post-kit'),
625 'type' => Controls_Manager::SWITCHER,
626 ]
627 );
628
629 $this->add_control(
630 'title_background',
631 [
632 'label' => esc_html__('Background Color', 'ultimate-post-kit'),
633 'type' => Controls_Manager::COLOR,
634 'selectors' => [
635 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-title a' => 'background-color: {{VALUE}};',
636 ],
637 'condition' => [
638 'title_advanced_style' => 'yes'
639 ]
640 ]
641 );
642
643 $this->add_group_control(
644 Group_Control_Text_Shadow::get_type(),
645 [
646 'name' => 'title_text_shadow',
647 'label' => __('Text Shadow', 'ultimate-post-kit'),
648 'selector' => '{{WRAPPER}} .upk-maple-grid .upk-item .upk-title a',
649 'condition' => [
650 'title_advanced_style' => 'yes'
651 ]
652 ]
653 );
654
655 $this->add_group_control(
656 Group_Control_Border::get_type(),
657 [
658 'name' => 'title_border',
659 'selector' => '{{WRAPPER}} .upk-maple-grid .upk-item .upk-title a',
660 'condition' => [
661 'title_advanced_style' => 'yes'
662 ]
663 ]
664 );
665
666 $this->add_responsive_control(
667 'title_border_radius',
668 [
669 'label' => __('Border Radius', 'ultimate-post-kit'),
670 'type' => Controls_Manager::DIMENSIONS,
671 'size_units' => ['px', '%'],
672 'selectors' => [
673 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-title a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
674 ],
675 'condition' => [
676 'title_advanced_style' => 'yes'
677 ]
678 ]
679 );
680
681 $this->add_group_control(
682 Group_Control_Box_Shadow::get_type(),
683 [
684 'name' => 'title_box_shadow',
685 'selector' => '{{WRAPPER}} .upk-maple-grid .upk-item .upk-title a',
686 'condition' => [
687 'title_advanced_style' => 'yes'
688 ]
689 ]
690 );
691
692 $this->add_responsive_control(
693 'title_text_padding',
694 [
695 'label' => __('Padding', 'ultimate-post-kit'),
696 'type' => Controls_Manager::DIMENSIONS,
697 'size_units' => ['px', 'em', '%'],
698 'selectors' => [
699 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-title a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
700 ],
701 'condition' => [
702 'title_advanced_style' => 'yes'
703 ]
704 ]
705 );
706
707 $this->end_controls_section();
708
709 $this->start_controls_section(
710 'section_style_text',
711 [
712 'label' => esc_html__('Text', 'ultimate-post-kit'),
713 'tab' => Controls_Manager::TAB_STYLE,
714 'condition' => [
715 'show_excerpt' => 'yes',
716 'grid_style!' => '3'
717 ],
718 ]
719 );
720
721 $this->add_control(
722 'text_color',
723 [
724 'label' => esc_html__('Color', 'ultimate-post-kit'),
725 'type' => Controls_Manager::COLOR,
726 'selectors' => [
727 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-text' => 'color: {{VALUE}};',
728 ],
729 ]
730 );
731
732 $this->add_group_control(
733 Group_Control_Typography::get_type(),
734 [
735 'name' => 'text_typography',
736 'label' => esc_html__('Typography', 'ultimate-post-kit'),
737 'selector' => '{{WRAPPER}} .upk-maple-grid .upk-item .upk-text',
738 ]
739 );
740
741 $this->end_controls_section();
742
743 $this->start_controls_section(
744 'section_style_meta',
745 [
746 'label' => esc_html__('Meta', 'ultimate-post-kit'),
747 'tab' => Controls_Manager::TAB_STYLE,
748 'conditions' => [
749 'relation' => 'or',
750 'terms' => [
751 [
752 'name' => 'show_author_avatar',
753 'value' => 'yes'
754 ],
755 [
756 'name' => 'show_author_name',
757 'value' => 'yes'
758 ],
759 [
760 'name' => 'show_date',
761 'value' => 'yes'
762 ]
763 ]
764 ],
765 ]
766 );
767
768 $this->add_control(
769 'meta_color',
770 [
771 'label' => esc_html__('Text Color', 'ultimate-post-kit'),
772 'type' => Controls_Manager::COLOR,
773 'selectors' => [
774 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-meta *' => 'color: {{VALUE}};',
775 ],
776 ]
777 );
778
779 $this->add_control(
780 'meta_hover_color',
781 [
782 'label' => esc_html__('Hover Text Color', 'ultimate-post-kit'),
783 'type' => Controls_Manager::COLOR,
784 'selectors' => [
785 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-meta .author-name:hover' => 'color: {{VALUE}};',
786 ],
787 'condition' => [
788 'grid_style!' => '3'
789 ],
790 ]
791 );
792
793 // $this->add_control(
794 // 'meta_divider_color',
795 // [
796 // 'label' => esc_html__('Divider Color', 'ultimate-post-kit'),
797 // 'type' => Controls_Manager::COLOR,
798 // 'selectors' => [
799 // '{{WRAPPER}} .upk-maple-grid .upk-item .upk-meta .upk-blog-date:before' => 'background: {{VALUE}};',
800 // ],
801 // 'condition' => [
802 // 'grid_style!' => '3'
803 // ],
804 // ]
805 // );
806
807 $this->add_responsive_control(
808 'avatar_spacing',
809 [
810 'label' => esc_html__('Avatar Spacing', 'ultimate-post-kit'),
811 'type' => Controls_Manager::SLIDER,
812 'range' => [
813 'px' => [
814 'min' => 0,
815 'max' => 50,
816 ],
817 ],
818 'selectors' => [
819 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-meta .upk-author img' => 'margin-right: {{SIZE}}{{UNIT}};',
820 ],
821 'condition' => [
822 'grid_style!' => '3'
823 ],
824 ]
825 );
826
827 $this->add_responsive_control(
828 'avatar_border_radius',
829 [
830 'label' => esc_html__('Avatar Radius', 'ultimate-post-kit'),
831 'type' => Controls_Manager::DIMENSIONS,
832 'size_units' => ['px', '%'],
833 'selectors' => [
834 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-meta .upk-author img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
835 ],
836 'condition' => [
837 'grid_style!' => '3'
838 ],
839 ]
840 );
841
842 $this->add_responsive_control(
843 'meta_space_between',
844 [
845 'label' => esc_html__('Space Between', 'ultimate-post-kit'),
846 'type' => Controls_Manager::SLIDER,
847 'range' => [
848 'px' => [
849 'min' => 0,
850 'max' => 50,
851 ],
852 ],
853 'selectors' => [
854 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-meta > div:before' => 'margin: 0 {{SIZE}}{{UNIT}};',
855 ],
856 ]
857 );
858
859 $this->add_group_control(
860 Group_Control_Typography::get_type(),
861 [
862 'name' => 'meta_typography',
863 'label' => esc_html__('Typography', 'ultimate-post-kit'),
864 'selector' => '{{WRAPPER}} .upk-maple-grid .upk-item .upk-meta',
865 ]
866 );
867
868 $this->end_controls_section();
869
870 $this->start_controls_section(
871 'section_style_category',
872 [
873 'label' => esc_html__('Category', 'ultimate-post-kit'),
874 'tab' => Controls_Manager::TAB_STYLE,
875 'condition' => [
876 'show_category' => 'yes',
877 'grid_style!' => '3'
878 ],
879 ]
880 );
881
882 $this->start_controls_tabs('tabs_category_style');
883
884 $this->start_controls_tab(
885 'tab_category_normal',
886 [
887 'label' => esc_html__('Normal', 'ultimate-post-kit'),
888 ]
889 );
890
891 $this->add_control(
892 'category_color',
893 [
894 'label' => esc_html__('Color', 'ultimate-post-kit'),
895 'type' => Controls_Manager::COLOR,
896 'selectors' => [
897 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-category a' => 'color: {{VALUE}};',
898 ],
899 ]
900 );
901
902 $this->add_group_control(
903 Group_Control_Background::get_type(),
904 [
905 'name' => 'category_background',
906 'selector' => '{{WRAPPER}} .upk-maple-grid .upk-item .upk-category a',
907 ]
908 );
909
910 $this->add_group_control(
911 Group_Control_Border::get_type(),
912 [
913 'name' => 'category_border',
914 'selector' => '{{WRAPPER}} .upk-maple-grid .upk-item .upk-category a',
915 'separator' => 'before'
916 ]
917 );
918
919 $this->add_responsive_control(
920 'category_border_radius',
921 [
922 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
923 'type' => Controls_Manager::DIMENSIONS,
924 'size_units' => ['px', '%'],
925 'selectors' => [
926 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-category a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
927 ],
928 ]
929 );
930
931 $this->add_responsive_control(
932 'category_padding',
933 [
934 'label' => esc_html__('Padding', 'ultimate-post-kit'),
935 'type' => Controls_Manager::DIMENSIONS,
936 'size_units' => ['px', 'em', '%'],
937 'selectors' => [
938 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-category a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
939 ],
940 ]
941 );
942
943 $this->add_responsive_control(
944 'category_margin',
945 [
946 'label' => esc_html__('Margin', 'ultimate-post-kit'),
947 'type' => Controls_Manager::DIMENSIONS,
948 'size_units' => ['px', 'em', '%'],
949 'selectors' => [
950 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-category' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
951 ],
952 ]
953 );
954
955 $this->add_responsive_control(
956 'category_spacing',
957 [
958 'label' => esc_html__('Space Between', 'ultimate-post-kit'),
959 'type' => Controls_Manager::SLIDER,
960 'range' => [
961 'px' => [
962 'min' => 0,
963 'max' => 50,
964 'step' => 2,
965 ],
966 ],
967 'selectors' => [
968 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-category' => 'gap: {{SIZE}}{{UNIT}};',
969 ],
970 ]
971 );
972
973 $this->add_group_control(
974 Group_Control_Box_Shadow::get_type(),
975 [
976 'name' => 'category_shadow',
977 'selector' => '{{WRAPPER}} .upk-maple-grid .upk-item .upk-category a',
978 ]
979 );
980
981 $this->add_group_control(
982 Group_Control_Typography::get_type(),
983 [
984 'name' => 'category_typography',
985 'label' => esc_html__('Typography', 'ultimate-post-kit'),
986 'selector' => '{{WRAPPER}} .upk-maple-grid .upk-item .upk-category a',
987 ]
988 );
989
990 $this->end_controls_tab();
991
992 $this->start_controls_tab(
993 'tab_category_hover',
994 [
995 'label' => esc_html__('Hover', 'ultimate-post-kit'),
996 ]
997 );
998
999 $this->add_control(
1000 'category_hover_color',
1001 [
1002 'label' => esc_html__('Color', 'ultimate-post-kit'),
1003 'type' => Controls_Manager::COLOR,
1004 'selectors' => [
1005 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-category a:hover' => 'color: {{VALUE}};',
1006 ],
1007 ]
1008 );
1009
1010 $this->add_group_control(
1011 Group_Control_Background::get_type(),
1012 [
1013 'name' => 'category_hover_background',
1014 'selector' => '{{WRAPPER}} .upk-maple-grid .upk-item .upk-category a:hover',
1015 ]
1016 );
1017
1018 $this->add_control(
1019 'category_hover_border_color',
1020 [
1021 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
1022 'type' => Controls_Manager::COLOR,
1023 'condition' => [
1024 'category_border_border!' => '',
1025 ],
1026 'selectors' => [
1027 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-category a:hover' => 'border-color: {{VALUE}};',
1028 ],
1029 'separator' => 'before'
1030 ]
1031 );
1032
1033 $this->add_group_control(
1034 Group_Control_Box_Shadow::get_type(),
1035 [
1036 'name' => 'category_shadow_hover',
1037 'selector' => '{{WRAPPER}} .upk-maple-grid .upk-item .upk-category a:hover',
1038 ]
1039 );
1040
1041 $this->end_controls_tab();
1042
1043 $this->end_controls_tabs();
1044
1045 $this->end_controls_section();
1046
1047 $this->start_controls_section(
1048 'section_style_post_format',
1049 [
1050 'label' => esc_html__('Post Format', 'ultimate-post-kit'),
1051 'tab' => Controls_Manager::TAB_STYLE,
1052 'condition' => [
1053 'show_post_format' => 'yes',
1054 'grid_style!' => '3'
1055 ],
1056 ]
1057 );
1058
1059 $this->start_controls_tabs('tabs_post_format_style');
1060
1061 $this->start_controls_tab(
1062 'tab_post_format_normal',
1063 [
1064 'label' => esc_html__('Normal', 'ultimate-post-kit'),
1065 ]
1066 );
1067
1068 $this->add_control(
1069 'post_format_color',
1070 [
1071 'label' => esc_html__('Color', 'ultimate-post-kit'),
1072 'type' => Controls_Manager::COLOR,
1073 'selectors' => [
1074 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-post-format a' => 'color: {{VALUE}};',
1075 ],
1076 ]
1077 );
1078
1079 $this->add_group_control(
1080 Group_Control_Background::get_type(),
1081 [
1082 'name' => 'post_format_background',
1083 'selector' => '{{WRAPPER}} .upk-maple-grid .upk-item .upk-post-format a',
1084 ]
1085 );
1086
1087 $this->add_group_control(
1088 Group_Control_Border::get_type(),
1089 [
1090 'name' => 'post_format_border',
1091 'label' => __('Border', 'ultimate-post-kit'),
1092 'fields_options' => [
1093 'border' => [
1094 'default' => 'solid',
1095 ],
1096 'width' => [
1097 'default' => [
1098 'top' => '5',
1099 'right' => '5',
1100 'bottom' => '5',
1101 'left' => '5',
1102 'isLinked' => false,
1103 ],
1104 ],
1105 'color' => [
1106 'default' => '#fff',
1107 ],
1108 ],
1109 'selector' => '{{WRAPPER}} .upk-maple-grid .upk-item .upk-post-format a',
1110 ]
1111 );
1112
1113 $this->add_responsive_control(
1114 'post_format_border_radius',
1115 [
1116 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
1117 'type' => Controls_Manager::DIMENSIONS,
1118 'size_units' => ['px', '%'],
1119 'selectors' => [
1120 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-post-format a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1121 ],
1122 ]
1123 );
1124
1125 $this->add_responsive_control(
1126 'post_format_padding',
1127 [
1128 'label' => esc_html__('Padding', 'ultimate-post-kit'),
1129 'type' => Controls_Manager::DIMENSIONS,
1130 'size_units' => ['px', 'em', '%'],
1131 'selectors' => [
1132 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-post-format a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1133 ],
1134 ]
1135 );
1136
1137 $this->add_responsive_control(
1138 'post_format_spacing',
1139 [
1140 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
1141 'type' => Controls_Manager::SLIDER,
1142 'range' => [
1143 'px' => [
1144 'min' => 10,
1145 'max' => 100,
1146 ],
1147 ],
1148 'selectors' => [
1149 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-post-format' => 'right: {{SIZE}}{{UNIT}};',
1150 '{{WRAPPER}} .upk-maple-grid .upk-style-5 .upk-item:nth-child(5n+1) .upk-post-format' => 'bottom: {{SIZE}}{{UNIT}}; right: 0px !important;',
1151 ],
1152 ]
1153 );
1154
1155 $this->add_group_control(
1156 Group_Control_Box_Shadow::get_type(),
1157 [
1158 'name' => 'post_format_shadow',
1159 'selector' => '{{WRAPPER}} .upk-maple-grid .upk-item .upk-post-format a',
1160 ]
1161 );
1162
1163 $this->add_group_control(
1164 Group_Control_Typography::get_type(),
1165 [
1166 'name' => 'post_format_typography',
1167 'label' => esc_html__('Typography', 'ultimate-post-kit'),
1168 'selector' => '{{WRAPPER}} .upk-maple-grid .upk-item .upk-post-format a',
1169 ]
1170 );
1171
1172 $this->end_controls_tab();
1173
1174 $this->start_controls_tab(
1175 'tab_post_format_hover',
1176 [
1177 'label' => esc_html__('Hover', 'ultimate-post-kit'),
1178 ]
1179 );
1180
1181 $this->add_control(
1182 'post_format_hover_color',
1183 [
1184 'label' => esc_html__('Color', 'ultimate-post-kit'),
1185 'type' => Controls_Manager::COLOR,
1186 'selectors' => [
1187 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-post-format a:hover' => 'color: {{VALUE}};',
1188 ],
1189 ]
1190 );
1191
1192 $this->add_group_control(
1193 Group_Control_Background::get_type(),
1194 [
1195 'name' => 'post_format_hover_background',
1196 'selector' => '{{WRAPPER}} .upk-maple-grid .upk-item .upk-post-format a:hover',
1197 ]
1198 );
1199
1200 $this->add_control(
1201 'post_format_hover_border_color',
1202 [
1203 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
1204 'type' => Controls_Manager::COLOR,
1205 'condition' => [
1206 'post_format_border_border!' => '',
1207 ],
1208 'selectors' => [
1209 '{{WRAPPER}} .upk-maple-grid .upk-item .upk-post-format a:hover' => 'border-color: {{VALUE}};',
1210 ],
1211 ]
1212 );
1213
1214 $this->end_controls_tab();
1215
1216 $this->end_controls_tabs();
1217
1218 $this->end_controls_section();
1219
1220 //Global Pagination Controls
1221 $this->register_pagination_controls();
1222
1223 //Global Ajax Loadmore Controls
1224 $this->register_ajax_loadmore_style_controls();
1225 }
1226
1227 /**
1228 * Get post query builder arguments
1229 */
1230 public function query_posts( $posts_per_page ) {
1231 $settings = $this->get_settings();
1232 $posts_per_page = isset( $posts_per_page ) ? (int) $posts_per_page : 0;
1233 $args = $this->getGroupControlQueryArgs();
1234 $is_current_query = ( ! empty( $settings['posts_source'] ) && $settings['posts_source'] === 'current_query' );
1235
1236 if ( $is_current_query ) {
1237 unset( $args['offset'] );
1238 unset( $args['no_found_rows'] );
1239 $posts_per_page = 0;
1240 }
1241
1242 if ( $posts_per_page > 0 ) {
1243 $args['posts_per_page'] = $posts_per_page;
1244 } else {
1245 $args['posts_per_page'] = (int) get_option( 'posts_per_page', 10 );
1246 }
1247
1248 if ( $settings['show_pagination'] ) {
1249 $args['paged'] = max( 1, (int) get_query_var( 'paged' ), (int) get_query_var( 'page' ) );
1250 }
1251
1252 $this->_query = new \WP_Query( $args );
1253 }
1254
1255 public function render_author() {
1256 $settings = $this->get_settings_for_display();
1257
1258 ?>
1259 <?php if ($settings['show_author_avatar'] == 'yes' or $settings['show_author_name'] == 'yes') : ?>
1260 <div class="upk-author">
1261 <?php if ($settings['show_author_avatar'] == 'yes') : ?>
1262 <?php echo get_avatar(get_the_author_meta('ID'), 36); ?>
1263 <?php endif; ?>
1264
1265 <?php if ($settings['show_author_name'] == 'yes') : ?>
1266 <a class="author-name" href="<?php echo esc_url( get_author_posts_url(get_the_author_meta('ID')) ); ?>"><?php echo esc_html( get_the_author() ); ?></a>
1267 <?php endif; ?>
1268 </div>
1269 <?php endif; ?>
1270
1271 <?php
1272 }
1273
1274 public function render_date() {
1275 $settings = $this->get_settings_for_display();
1276
1277 if (!$this->get_settings('show_date')) {
1278 return;
1279 }
1280
1281 if ($settings['human_diff_time'] == 'yes') {
1282 echo esc_html( ultimate_post_kit_post_time_diff( ($settings['human_diff_time_short'] == 'yes') ? 'short' : '' ) );
1283 } else {
1284 echo get_the_date();
1285 }
1286 }
1287
1288 public function render_post_grid_item($post_id, $image_size, $excerpt_length) {
1289 $settings = $this->get_settings_for_display();
1290
1291 if ('yes' == $settings['global_link']) {
1292
1293 $this->add_render_attribute('grid-item', 'onclick', "window.open('" . esc_url(get_permalink()) . "', '_self')", true);
1294 }
1295 $this->add_render_attribute('grid-item', 'class', 'upk-item', true);
1296
1297 ?>
1298 <div <?php $this->print_render_attribute_string('grid-item'); ?>>
1299 <div class="upk-item-box">
1300 <div class="upk-image-wrap">
1301 <div class="upk-main-image">
1302 <?php $this->render_image(get_post_thumbnail_id($post_id), $image_size); ?>
1303 </div>
1304
1305 <?php if ($settings['grid_style'] != '3') : ?>
1306 <?php $this->render_post_format(); ?>
1307 <?php $this->render_category(); ?>
1308 <?php endif; ?>
1309
1310 </div>
1311
1312 <div class="upk-content">
1313 <div class="upk-content-inner">
1314
1315 <?php if ($settings['show_author_avatar'] == 'yes' or $settings['show_author_name'] == 'yes' or $settings['show_date'] or $settings['show_reading_time']) : ?>
1316 <div class="upk-meta">
1317 <?php if ($settings['grid_style'] != '3') : ?>
1318 <?php $this->render_author(); ?>
1319 <?php endif; ?>
1320
1321 <?php if ($settings['show_date'] == 'yes') : ?>
1322 <div class="upk-blog-date" data-separator="<?php echo esc_attr($settings['meta_separator']); ?>">
1323 <div class="upk-blog-date">
1324 <a class="date" href="#">
1325 <i class="upk-icon-calendar" aria-hidden="true"></i><?php $this->render_date(); ?>
1326 </a>
1327 </div>
1328
1329 <?php if ($settings['show_time']) : ?>
1330 <div class="upk-post-time">
1331 <i class="upk-icon-clock" aria-hidden="true"></i>
1332 <?php echo esc_html( get_the_time() ); ?>
1333 </div>
1334 <?php endif; ?>
1335 </div>
1336 <?php endif; ?>
1337
1338 <?php if (_is_upk_pro_activated()) :
1339 if ('yes' === $settings['show_reading_time']) : ?>
1340 <div class="upk-reading-time" data-separator="<?php echo esc_attr($settings['meta_separator']); ?>">
1341 <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'], $settings['hide_seconds'] ?? 'no', $settings['hide_minutes'] ?? 'no' ) ); ?>
1342 </div>
1343 <?php endif; ?>
1344 <?php endif; ?>
1345
1346 </div>
1347 <?php endif; ?>
1348
1349 <?php $this->render_title(substr($this->get_name(), 4)); ?>
1350
1351 <?php if ($settings['grid_style'] != '3') : ?>
1352 <?php $this->render_excerpt($excerpt_length); ?>
1353 <?php endif; ?>
1354 </div>
1355 </div>
1356
1357 </div>
1358 </div>
1359
1360
1361 <?php
1362 }
1363
1364 protected function render() {
1365 $settings = $this->get_settings_for_display();
1366
1367 if ($settings['grid_style'] == '2' or $settings['grid_style'] == '5') {
1368 $this->query_posts($settings['item_limit_2']['size']);
1369 } else {
1370 $this->query_posts($settings['item_limit']['size']);
1371 }
1372
1373 $wp_query = $this->get_query();
1374
1375 if (!$wp_query->found_posts) {
1376 return;
1377 }
1378
1379 $this->add_render_attribute('grid-wrap', 'class', 'upk-post-grid upk-ajax-grid-wrap');
1380 $this->add_render_attribute('grid-wrap', 'class', 'upk-style-' . $settings['grid_style']);
1381
1382 $this->add_render_attribute(
1383 [
1384 'upk-maple-grid' => [
1385 'class' => 'upk-maple-grid upk-ajax-grid',
1386 'data-loadmore' => [
1387 wp_json_encode(
1388 array_filter([
1389 'loadmore_enable' => $settings['ajax_loadmore_enable'],
1390 'loadmore_btn' => $settings['ajax_loadmore_btn'],
1391 'infinite_scroll' => $settings['ajax_loadmore_infinite_scroll'],
1392 ])
1393 ),
1394 ],
1395 ],
1396 ]
1397 );
1398
1399 if ($settings['ajax_loadmore_enable'] == 'yes') {
1400 $ajax_settings = [
1401 'posts_source' => isset($settings['posts_source']) ? $settings['posts_source'] : 'post',
1402 'posts_per_page' => isset($posts_load) ? $posts_load : 6,
1403 'ajax_item_load' => isset($settings['ajax_loadmore_items']) ? $settings['ajax_loadmore_items'] : 3,
1404 'posts_selected_ids' => isset($settings['posts_selected_ids']) ? $settings['posts_selected_ids'] : '',
1405 'posts_include_by' => isset($settings['posts_include_by']) ? $settings['posts_include_by'] : [],
1406 'posts_include_author_ids' => isset($settings['posts_include_author_ids']) ? $settings['posts_include_author_ids'] : '',
1407 'posts_include_term_ids' => isset($settings['posts_include_term_ids']) ? $settings['posts_include_term_ids'] : '',
1408 'posts_exclude_by' => isset($settings['posts_exclude_by']) ? $settings['posts_exclude_by'] : [],
1409 'posts_exclude_ids' => isset($settings['posts_exclude_ids']) ? $settings['posts_exclude_ids'] : '',
1410 'posts_exclude_author_ids' => isset($settings['posts_exclude_author_ids']) ? $settings['posts_exclude_author_ids'] : '',
1411 'posts_exclude_term_ids' => isset($settings['posts_exclude_term_ids']) ? $settings['posts_exclude_term_ids'] : '',
1412 'posts_offset' => isset($settings['posts_offset']) ? $settings['posts_offset'] : 0,
1413 'posts_select_date' => isset($settings['posts_select_date']) ? $settings['posts_select_date'] : '',
1414 'posts_date_before' => isset($settings['posts_date_before']) ? $settings['posts_date_before'] : '',
1415 'posts_date_after' => isset($settings['posts_date_after']) ? $settings['posts_date_after'] : '',
1416 'posts_orderby' => isset($settings['posts_orderby']) ? $settings['posts_orderby'] : 'date',
1417 'posts_order' => isset($settings['posts_order']) ? $settings['posts_order'] : 'DESC',
1418 'posts_ignore_sticky_posts' => isset($settings['posts_ignore_sticky_posts']) ? $settings['posts_ignore_sticky_posts'] : 'no',
1419 'posts_only_with_featured_image'=> isset($settings['posts_only_with_featured_image']) ? $settings['posts_only_with_featured_image'] : 'no',
1420 // Grid Settings
1421 'show_title' => isset($settings['show_title']) ? $settings['show_title'] : 'yes',
1422 'title_tags' => isset( $settings['title_tags'] ) ? $settings['title_tags'] : 'h3',
1423 'show_excerpt' => isset($settings['show_excerpt']) ? $settings['show_excerpt'] : 'yes',
1424 'show_author_avatar' => isset($settings['show_author_avatar']) ? $settings['show_author_avatar'] : 'yes',
1425 'show_author_name' => isset($settings['show_author_name']) ? $settings['show_author_name'] : 'yes',
1426 'show_date' => isset($settings['show_date']) ? $settings['show_date'] : 'yes',
1427 'show_time' => isset($settings['show_time']) ? $settings['show_time'] : 'no',
1428 'show_category' => isset($settings['show_category']) ? $settings['show_category'] : 'yes',
1429 'show_post_format' => isset($settings['show_post_format']) ? $settings['show_post_format'] : 'yes',
1430 'show_reading_time' => isset($settings['show_reading_time']) ? $settings['show_reading_time'] : 'no',
1431 'avg_reading_speed' => isset($settings['avg_reading_speed']) ? $settings['avg_reading_speed'] : 200,
1432 'hide_seconds' => isset($settings['hide_seconds']) ? $settings['hide_seconds'] : 'no',
1433 'hide_minutes' => isset($settings['hide_minutes']) ? $settings['hide_minutes'] : 'no',
1434 'meta_separator' => isset($settings['meta_separator']) ? $settings['meta_separator'] : '|',
1435 'human_diff_time' => isset($settings['human_diff_time']) ? $settings['human_diff_time'] : 'no',
1436 'human_diff_time_short' => isset($settings['human_diff_time_short']) ? $settings['human_diff_time_short'] : 'no',
1437 'excerpt_length' => isset($settings['excerpt_length']) ? $settings['excerpt_length'] : 20,
1438 'title_style' => isset($settings['title_style']) ? $settings['title_style'] : '',
1439 'upk_link_new_tab' => isset($settings['upk_link_new_tab']) ? $settings['upk_link_new_tab'] : 'no',
1440 'global_link' => isset($settings['global_link']) ? $settings['global_link'] : 'no',
1441 ];
1442
1443 $this->add_render_attribute(
1444 [
1445 'upk-maple-grid' => [
1446 'data-settings' => [
1447 wp_json_encode($ajax_settings)
1448 ],
1449 ],
1450 ]
1451 );
1452 }
1453
1454 if (isset($settings['upk_in_animation_show']) && ($settings['upk_in_animation_show'] == 'yes')) {
1455 $this->add_render_attribute('grid-wrap', 'class', 'upk-in-animation');
1456 if (isset($settings['upk_in_animation_delay']['size'])) {
1457 $this->add_render_attribute('grid-wrap', 'data-in-animation-delay', $settings['upk_in_animation_delay']['size']);
1458 }
1459 }
1460
1461 ?>
1462 <div <?php $this->print_render_attribute_string('upk-maple-grid'); ?>>
1463 <div <?php $this->print_render_attribute_string('grid-wrap'); ?>>
1464
1465 <?php while ($wp_query->have_posts()) :
1466 $wp_query->the_post();
1467
1468 $thumbnail_size = $settings['primary_thumbnail_size'];
1469
1470 ?>
1471
1472 <?php $this->render_post_grid_item(get_the_ID(), $thumbnail_size, $settings['excerpt_length']); ?>
1473
1474 <?php endwhile; ?>
1475 </div>
1476 </div>
1477
1478 <?php $this->render_ajax_loadmore(); ?>
1479
1480 <?php
1481
1482 if ($settings['show_pagination']) { ?>
1483 <div class="ep-pagination">
1484 <?php ultimate_post_kit_post_pagination($wp_query, $this->get_id()); ?>
1485 </div>
1486 <?php
1487 }
1488 wp_reset_postdata();
1489 }
1490 }
1491