PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / 4.5.3
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets v4.5.3
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 / harold-list / widgets / harold-list.php

harold-list.php in Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets 4.5.3, at modules/harold-list/widgets/harold-list.php

1,039 lines 29.7 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\HaroldList\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 Harold_List 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-harold-list';
31 }
32
33 public function get_title() {
34 return BDTUPK . esc_html__('Harold List', 'ultimate-post-kit');
35 }
36
37 public function get_icon() {
38 return 'upk-widget-icon upk-icon-harold-list';
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', 'harold', 'list'];
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-harold-list'];
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/gmMpNuw4LD8';
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_responsive_control(
87 'columns',
88 [
89 'label' => __('Columns', 'ultimate-post-kit'),
90 'type' => Controls_Manager::SELECT,
91 'default' => '2',
92 'tablet_default' => '1',
93 'mobile_default' => '1',
94 'options' => [
95 '1' => '1',
96 '2' => '2',
97 ],
98 'selectors' => [
99 '{{WRAPPER}} .upk-harold-list .upk-list-wrap' => 'grid-template-columns: repeat({{SIZE}}, 1fr);',
100 ],
101 ]
102 );
103
104 $this->add_responsive_control(
105 'row_gap',
106 [
107 'label' => esc_html__('Row Gap', 'ultimate-post-kit'),
108 'type' => Controls_Manager::SLIDER,
109 'default' => [
110 'size' => 20,
111 ],
112 'selectors' => [
113 '{{WRAPPER}} .upk-harold-list .upk-list-wrap' => 'grid-row-gap: {{SIZE}}{{UNIT}};',
114 ],
115 ]
116 );
117
118 $this->add_responsive_control(
119 'column_gap',
120 [
121 'label' => esc_html__('Column Gap', 'ultimate-post-kit'),
122 'type' => Controls_Manager::SLIDER,
123 'default' => [
124 'size' => 20,
125 ],
126 'selectors' => [
127 '{{WRAPPER}} .upk-harold-list .upk-list-wrap' => 'grid-column-gap: {{SIZE}}{{UNIT}};',
128 ],
129 ]
130 );
131
132 $this->add_group_control(
133 Group_Control_Image_Size::get_type(),
134 [
135 'name' => 'primary_thumbnail',
136 // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour.
137 'exclude' => ['custom'],
138 'default' => 'medium',
139 ]
140 );
141
142 $this->end_controls_section();
143
144 // Query Settings
145 $this->start_controls_section(
146 'section_post_query_builder',
147 [
148 'label' => __('Query', 'ultimate-post-kit'),
149 'tab' => Controls_Manager::TAB_CONTENT,
150 ]
151 );
152
153 $this->add_control(
154 'item_limit',
155 [
156 'label' => esc_html__('Item Limit', 'ultimate-post-kit'),
157 'type' => Controls_Manager::SLIDER,
158 'range' => [
159 'px' => [
160 'min' => 1,
161 'max' => 20,
162 ],
163 ],
164 'default' => [
165 'size' => 6,
166 ],
167 'condition' => [
168 'posts_source!' => 'current_query',
169 ]
170 ]
171 );
172
173 $this->register_query_builder_controls();
174
175 $this->end_controls_section();
176
177 $this->start_controls_section(
178 'section_content_additional',
179 [
180 'label' => esc_html__('Additional Options', 'ultimate-post-kit'),
181 ]
182 );
183
184 $this->add_control(
185 'show_image',
186 [
187 'label' => esc_html__('Show Image', 'ultimate-post-kit'),
188 'type' => Controls_Manager::SWITCHER,
189 'default' => 'yes',
190 ]
191 );
192
193 //Global Title Controls
194 $this->register_title_controls();
195
196 $this->add_control(
197 'show_category',
198 [
199 'label' => esc_html__('Show Category', 'ultimate-post-kit'),
200 'type' => Controls_Manager::SWITCHER,
201 'default' => 'yes',
202 ]
203 );
204
205 $this->add_control(
206 'show_author',
207 [
208 'label' => esc_html__('Show Author', 'ultimate-post-kit'),
209 'type' => Controls_Manager::SWITCHER,
210 'default' => 'yes',
211 ]
212 );
213
214 //Global Date Controls
215 $this->register_date_controls();
216
217 //Global Reading Time Controls
218 $this->register_reading_time_controls();
219
220 $this->add_control(
221 'meta_separator',
222 [
223 'label' => __('Separator', 'ultimate-post-kit'),
224 'type' => Controls_Manager::TEXT,
225 'default' => '.',
226 'label_block' => false,
227 ]
228 );
229
230 $this->add_control(
231 'show_pagination',
232 [
233 'label' => esc_html__('Show Pagination', 'ultimate-post-kit'),
234 'type' => Controls_Manager::SWITCHER,
235 'separator' => 'before'
236 ]
237 );
238
239 //Global Ajax Controls
240 $this->register_ajax_loadmore_controls();
241
242 $this->add_control(
243 'global_link',
244 [
245 'label' => __('Item Wrapper Link', 'ultimate-post-kit'),
246 'type' => Controls_Manager::SWITCHER,
247 'prefix_class' => 'upk-global-link-',
248 'description' => __('Be aware! When Item Wrapper Link activated then title link and read more link will not work', 'ultimate-post-kit'),
249 ]
250 );
251
252 $this->end_controls_section();
253
254 $this->start_controls_section(
255 'upk_section_style',
256 [
257 'label' => esc_html__('Items', 'ultimate-post-kit'),
258 'tab' => Controls_Manager::TAB_STYLE,
259 ]
260 );
261
262 $this->add_responsive_control(
263 'content_padding',
264 [
265 'label' => __('Content Padding', 'ultimate-post-kit'),
266 'type' => Controls_Manager::DIMENSIONS,
267 'size_units' => ['px', 'em', '%'],
268 'selectors' => [
269 '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
270 ],
271 ]
272 );
273
274 $this->start_controls_tabs('tabs_item_style');
275
276 $this->start_controls_tab(
277 'tab_item_normal',
278 [
279 'label' => esc_html__('Normal', 'ultimate-post-kit'),
280 ]
281 );
282
283 $this->add_group_control(
284 Group_Control_Background::get_type(),
285 [
286 'name' => 'item_background',
287 'selector' => '{{WRAPPER}} .upk-harold-list .upk-item',
288 ]
289 );
290
291 $this->add_group_control(
292 Group_Control_Border::get_type(),
293 [
294 'name' => 'item_border',
295 'selector' => '{{WRAPPER}} .upk-harold-list .upk-item',
296 ]
297 );
298
299 $this->add_responsive_control(
300 'item_border_radius',
301 [
302 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
303 'type' => Controls_Manager::DIMENSIONS,
304 'size_units' => ['px', '%'],
305 'selectors' => [
306 '{{WRAPPER}} .upk-harold-list .upk-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
307 ],
308 ]
309 );
310
311 $this->add_responsive_control(
312 'item_padding',
313 [
314 'label' => __('Padding', 'ultimate-post-kit'),
315 'type' => Controls_Manager::DIMENSIONS,
316 'size_units' => ['px', 'em', '%'],
317 'selectors' => [
318 '{{WRAPPER}} .upk-harold-list .upk-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
319 ],
320 ]
321 );
322
323 $this->add_group_control(
324 Group_Control_Box_Shadow::get_type(),
325 [
326 'name' => 'item_box_shadow',
327 'selector' => '{{WRAPPER}} .upk-harold-list .upk-item',
328 ]
329 );
330
331 $this->end_controls_tab();
332
333 $this->start_controls_tab(
334 'tab_item_hover',
335 [
336 'label' => esc_html__('Hover', 'ultimate-post-kit'),
337 ]
338 );
339
340 $this->add_group_control(
341 Group_Control_Background::get_type(),
342 [
343 'name' => 'item_hover_background',
344 'selector' => '{{WRAPPER}} .upk-harold-list .upk-item:hover',
345 ]
346 );
347
348 $this->add_control(
349 'item_hover_border_color',
350 [
351 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
352 'type' => Controls_Manager::COLOR,
353 'condition' => [
354 'item_border_border!' => '',
355 ],
356 'selectors' => [
357 '{{WRAPPER}} .upk-harold-list .upk-item:hover' => 'border-color: {{VALUE}};',
358 ],
359 ]
360 );
361
362 $this->add_group_control(
363 Group_Control_Box_Shadow::get_type(),
364 [
365 'name' => 'item_hover_box_shadow',
366 'selector' => '{{WRAPPER}} .upk-harold-list .upk-item:hover',
367 ]
368 );
369
370 $this->end_controls_tab();
371
372 $this->end_controls_tabs();
373
374 $this->end_controls_section();
375
376 $this->start_controls_section(
377 'section_style_image',
378 [
379 'label' => esc_html__('Image', 'ultimate-post-kit'),
380 'tab' => Controls_Manager::TAB_STYLE,
381 'condition' => [
382 'show_image' => 'yes'
383 ]
384 ]
385 );
386
387 $this->add_group_control(
388 Group_Control_Border::get_type(),
389 [
390 'name' => 'item_image_border',
391 'selector' => '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-image-wrap .upk-img',
392 ]
393 );
394
395 $this->add_responsive_control(
396 'item_image_border_radius',
397 [
398 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
399 'type' => Controls_Manager::DIMENSIONS,
400 'size_units' => ['px', '%'],
401 'selectors' => [
402 '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-image-wrap .upk-img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
403 ],
404 ]
405 );
406
407 $this->add_responsive_control(
408 'item_image_size',
409 [
410 'label' => esc_html__('Size(px)', 'ultimate-post-kit'),
411 'type' => Controls_Manager::SLIDER,
412 'range' => [
413 'px' => [
414 'min' => 100,
415 'max' => 500,
416 ],
417 ],
418 'selectors' => [
419 '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-image-wrap' => 'max-width: {{SIZE}}{{UNIT}}; min-width: {{SIZE}}{{UNIT}};',
420 ],
421 ]
422 );
423
424 $this->end_controls_section();
425
426 $this->start_controls_section(
427 'section_style_title',
428 [
429 'label' => esc_html__('Title', 'ultimate-post-kit'),
430 'tab' => Controls_Manager::TAB_STYLE,
431 'condition' => [
432 'show_title' => 'yes',
433 ],
434 ]
435 );
436
437 $this->add_control(
438 'title_style',
439 [
440 'label' => esc_html__('Style', 'ultimate-post-kit'),
441 'type' => Controls_Manager::SELECT,
442 'default' => 'underline',
443 'options' => [
444 '' => esc_html__('Default', 'ultimate-post-kit'),
445 'underline' => esc_html__('Underline', 'ultimate-post-kit'),
446 'middle-underline' => esc_html__('Middle Underline', 'ultimate-post-kit'),
447 'overline' => esc_html__('Overline', 'ultimate-post-kit'),
448 'middle-overline' => esc_html__('Middle Overline', 'ultimate-post-kit'),
449 ],
450 ]
451 );
452
453 $this->add_control(
454 'title_color',
455 [
456 'label' => esc_html__('Color', 'ultimate-post-kit'),
457 'type' => Controls_Manager::COLOR,
458 'selectors' => [
459 '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content .upk-title a' => 'color: {{VALUE}};',
460 ],
461 ]
462 );
463
464 $this->add_control(
465 'title_hover_color',
466 [
467 'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
468 'type' => Controls_Manager::COLOR,
469 'selectors' => [
470 '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content .upk-title a:hover' => 'color: {{VALUE}};',
471 ],
472 ]
473 );
474
475 $this->add_responsive_control(
476 'title_spacing',
477 [
478 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
479 'type' => Controls_Manager::SLIDER,
480 'range' => [
481 'px' => [
482 'min' => 0,
483 'max' => 50,
484 ],
485 ],
486 'selectors' => [
487 '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content .upk-title' => 'padding-bottom: {{SIZE}}{{UNIT}};',
488 ],
489 ]
490 );
491
492 $this->add_group_control(
493 Group_Control_Typography::get_type(),
494 [
495 'name' => 'title_typography',
496 'label' => esc_html__('Typography', 'ultimate-post-kit'),
497 'selector' => '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content .upk-title',
498 ]
499 );
500
501 $this->add_group_control(
502 Group_Control_Text_Shadow::get_type(),
503 [
504 'name' => 'title_text_shadow',
505 'label' => __('Text Shadow', 'ultimate-post-kit'),
506 'selector' => '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content .upk-title a',
507 ]
508 );
509
510 $this->end_controls_section();
511
512 $this->start_controls_section(
513 'section_style_meta',
514 [
515 'label' => esc_html__('Meta', 'ultimate-post-kit'),
516 'tab' => Controls_Manager::TAB_STYLE,
517 'conditions' => [
518 'relation' => 'or',
519 'terms' => [
520 [
521 'name' => 'show_author',
522 'value' => 'yes'
523 ],
524 [
525 'name' => 'show_date',
526 'value' => 'yes'
527 ]
528 ]
529 ],
530 ]
531 );
532
533 $this->add_control(
534 'meta_color',
535 [
536 'label' => esc_html__('Color', 'ultimate-post-kit'),
537 'type' => Controls_Manager::COLOR,
538 'selectors' => [
539 '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content .upk-meta *' => 'color: {{VALUE}};',
540 ],
541 ]
542 );
543
544 $this->add_control(
545 'meta_hover_color',
546 [
547 'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
548 'type' => Controls_Manager::COLOR,
549 'selectors' => [
550 '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content .upk-meta .upk-author a:hover *' => 'color: {{VALUE}};',
551 ],
552 ]
553 );
554
555 // $this->add_responsive_control(
556 // 'meta_spacing',
557 // [
558 // 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
559 // 'type' => Controls_Manager::SLIDER,
560 // 'range' => [
561 // 'px' => [
562 // 'min' => 0,
563 // 'max' => 50,
564 // 'step' => 2,
565 // ],
566 // ],
567 // 'selectors' => [
568 // '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content .upk-meta .upk-date' => 'margin-left: {{SIZE}}{{UNIT}};',
569 // ],
570 // ]
571 // );
572 $this->add_responsive_control(
573 'meta_spacing',
574 [
575 'label' => esc_html__('Space Between', 'ultimate-post-kit'),
576 'type' => Controls_Manager::SLIDER,
577 'range' => [
578 'px' => [
579 'min' => 0,
580 'max' => 50,
581 ],
582 ],
583 'selectors' => [
584 '{{WRAPPER}} .upk-harold-list .upk-meta > div:before' => 'margin: 0 {{SIZE}}{{UNIT}};',
585 ],
586 ]
587 );
588
589 $this->add_group_control(
590 Group_Control_Typography::get_type(),
591 [
592 'name' => 'meta_typography',
593 'label' => esc_html__('Typography', 'ultimate-post-kit'),
594 'selector' => '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content .upk-meta, {{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content .upk-meta *',
595 ]
596 );
597
598 $this->end_controls_section();
599
600 $this->start_controls_section(
601 'section_style_category',
602 [
603 'label' => esc_html__('Category', 'ultimate-post-kit'),
604 'tab' => Controls_Manager::TAB_STYLE,
605 'condition' => [
606 'show_category' => 'yes',
607 ],
608 ]
609 );
610
611 $this->add_responsive_control(
612 'category_bottom_spacing',
613 [
614 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
615 'type' => Controls_Manager::SLIDER,
616 'range' => [
617 'px' => [
618 'min' => 0,
619 'max' => 50,
620 'step' => 2,
621 ],
622 ],
623 'selectors' => [
624 '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content .upk-category' => 'margin-bottom: {{SIZE}}{{UNIT}};',
625 ],
626 ]
627 );
628
629 $this->start_controls_tabs('tabs_category_style');
630
631 $this->start_controls_tab(
632 'tab_category_normal',
633 [
634 'label' => esc_html__('Normal', 'ultimate-post-kit'),
635 ]
636 );
637
638 $this->add_control(
639 'category_color',
640 [
641 'label' => esc_html__('Color', 'ultimate-post-kit'),
642 'type' => Controls_Manager::COLOR,
643 'selectors' => [
644 '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content .upk-category a' => 'color: {{VALUE}};',
645 ],
646 ]
647 );
648
649 $this->add_group_control(
650 Group_Control_Background::get_type(),
651 [
652 'name' => 'category_background',
653 'selector' => '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content .upk-category a',
654 ]
655 );
656
657 $this->add_group_control(
658 Group_Control_Border::get_type(),
659 [
660 'name' => 'category_border',
661 'label' => __('Border', 'ultimate-post-kit'),
662 'fields_options' => [
663 'border' => [
664 'default' => 'solid',
665 ],
666 'width' => [
667 'default' => [
668 'top' => '1',
669 'right' => '1',
670 'bottom' => '1',
671 'left' => '1',
672 'isLinked' => false,
673 ],
674 ],
675 'color' => [
676 'default' => '#8D99AE',
677 ],
678 ],
679 'selector' => '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content .upk-category a',
680 ]
681 );
682
683 $this->add_responsive_control(
684 'category_border_radius',
685 [
686 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
687 'type' => Controls_Manager::DIMENSIONS,
688 'size_units' => ['px', '%'],
689 'selectors' => [
690 '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content .upk-category a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
691 ],
692 ]
693 );
694
695 $this->add_responsive_control(
696 'category_padding',
697 [
698 'label' => esc_html__('Padding', 'ultimate-post-kit'),
699 'type' => Controls_Manager::DIMENSIONS,
700 'size_units' => ['px', 'em', '%'],
701 'selectors' => [
702 '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content .upk-category a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
703 ],
704 ]
705 );
706
707 $this->add_responsive_control(
708 'category_spacing',
709 [
710 'label' => esc_html__('Space Between', 'ultimate-post-kit'),
711 'type' => Controls_Manager::SLIDER,
712 'range' => [
713 'px' => [
714 'min' => 0,
715 'max' => 50,
716 'step' => 2,
717 ],
718 ],
719 'selectors' => [
720 '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content .upk-category a+a' => 'margin-left: {{SIZE}}{{UNIT}};',
721 ],
722 ]
723 );
724
725
726 $this->add_group_control(
727 Group_Control_Box_Shadow::get_type(),
728 [
729 'name' => 'category_shadow',
730 'selector' => '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content .upk-category a',
731 ]
732 );
733
734 $this->add_group_control(
735 Group_Control_Typography::get_type(),
736 [
737 'name' => 'category_typography',
738 'label' => esc_html__('Typography', 'ultimate-post-kit'),
739 'selector' => '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content .upk-category a',
740 ]
741 );
742
743 $this->end_controls_tab();
744
745 $this->start_controls_tab(
746 'tab_category_hover',
747 [
748 'label' => esc_html__('Hover', 'ultimate-post-kit'),
749 ]
750 );
751
752 $this->add_control(
753 'category_hover_color',
754 [
755 'label' => esc_html__('Color', 'ultimate-post-kit'),
756 'type' => Controls_Manager::COLOR,
757 'selectors' => [
758 '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content .upk-category a:hover' => 'color: {{VALUE}};',
759 ],
760 ]
761 );
762
763 $this->add_group_control(
764 Group_Control_Background::get_type(),
765 [
766 'name' => 'category_hover_background',
767 'selector' => '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content .upk-category a:hover',
768 ]
769 );
770
771 $this->add_control(
772 'category_hover_border_color',
773 [
774 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
775 'type' => Controls_Manager::COLOR,
776 'condition' => [
777 'category_border_border!' => '',
778 ],
779 'selectors' => [
780 '{{WRAPPER}} .upk-harold-list .upk-item .upk-item-box .upk-content .upk-category a:hover' => 'border-color: {{VALUE}};',
781 ],
782 ]
783 );
784
785 $this->end_controls_tab();
786
787 $this->end_controls_tabs();
788
789 $this->end_controls_section();
790
791 //Global Pagination Controls
792 $this->register_pagination_controls();
793
794 //Global Ajax Loadmore Style Controls
795 $this->register_ajax_loadmore_style_controls();
796 }
797
798 /**
799 * Get post query builder arguments
800 */
801 public function query_posts( $posts_per_page ) {
802 $settings = $this->get_settings();
803 $posts_per_page = isset( $posts_per_page ) ? (int) $posts_per_page : 0;
804 $args = $this->getGroupControlQueryArgs();
805 $is_current_query = ( ! empty( $settings['posts_source'] ) && $settings['posts_source'] === 'current_query' );
806
807 if ( $is_current_query ) {
808 unset( $args['offset'] );
809 unset( $args['no_found_rows'] );
810 $posts_per_page = 0;
811 }
812
813 if ( $posts_per_page > 0 ) {
814 $args['posts_per_page'] = $posts_per_page;
815 } else {
816 $args['posts_per_page'] = (int) get_option( 'posts_per_page', 10 );
817 }
818
819 if ( $settings['show_pagination'] ) {
820 $args['paged'] = max( 1, (int) get_query_var( 'paged' ), (int) get_query_var( 'page' ) );
821 }
822
823 $this->_query = new \WP_Query( $args );
824 }
825
826 public function render_author() {
827
828 if (!$this->get_settings('show_author')) {
829 return;
830 }
831
832 ?>
833
834 <div class="upk-author">
835 <a href="<?php echo esc_url( get_author_posts_url(get_the_author_meta('ID')) ); ?>">
836 <i class="upk-icon-user"></i>
837 <span class="upk-author-name"><?php echo esc_html( get_the_author() ); ?></span>
838 </a>
839 </div>
840
841 <?php
842 }
843
844 public function render_date() {
845 $settings = $this->get_settings_for_display();
846
847 if (!$this->get_settings('show_date')) {
848 return;
849 }
850
851 ?>
852 <div class="upk-flex">
853 <div class="upk-date">
854 <i class="upk-icon-calendar"></i>
855 <span class="upk-harold-date">
856 <?php if ($settings['human_diff_time'] == 'yes') {
857 echo esc_html( ultimate_post_kit_post_time_diff(($settings['human_diff_time_short'] == 'yes') ? 'short' : '') );
858 } else {
859 echo get_the_date();
860 } ?>
861 </span>
862 </div>
863 <?php if ($settings['show_time']) : ?>
864 <div class="upk-post-time">
865 <i class="upk-icon-clock" aria-hidden="true"></i>
866 <?php echo esc_html( get_the_time() ); ?>
867 </div>
868 <?php endif; ?>
869 </div>
870
871 <?php
872 }
873
874 public function render_post_grid_item($post_id, $image_size) {
875 $settings = $this->get_settings_for_display();
876
877 if ('yes' == $settings['global_link']) {
878
879 $this->add_render_attribute('list-item', 'onclick', "window.open('" . esc_url(get_permalink()) . "', '_self')", true);
880 }
881 $this->add_render_attribute('list-item', 'class', 'upk-item', true);
882
883 ?>
884 <div <?php $this->print_render_attribute_string('list-item'); ?>>
885 <div class="upk-item-box">
886 <?php if ('yes' == $settings['show_image']) : ?>
887 <div class="upk-image-wrap">
888 <?php $this->render_image(get_post_thumbnail_id($post_id), $image_size); ?>
889 </div>
890 <?php endif; ?>
891 <div class="upk-content">
892 <div>
893 <?php $this->render_category(); ?>
894 <?php $this->render_title(substr($this->get_name(), 4)); ?>
895 <?php if ($settings['show_author'] or $settings['show_date'] or $settings['show_reading_time']) : ?>
896 <div class="upk-meta">
897 <?php $this->render_author(); ?>
898 <?php if ($settings['show_date']) : ?>
899 <div data-separator="<?php echo esc_attr($settings['meta_separator']); ?>">
900 <?php $this->render_date(); ?>
901 </div>
902 <?php endif; ?>
903 <?php if (_is_upk_pro_activated()) :
904 if ('yes' === $settings['show_reading_time']) : ?>
905 <div class="upk-reading-time" data-separator="<?php echo esc_attr($settings['meta_separator']); ?>">
906 <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'], $settings['hide_seconds'] ?? 'no', $settings['hide_minutes'] ?? 'no' ) ); ?>
907 </div>
908 <?php endif; ?>
909 <?php endif; ?>
910 </div>
911 <?php endif; ?>
912 </div>
913 </div>
914 </div>
915 </div>
916
917 <?php
918 }
919
920 protected function render() {
921 $settings = $this->get_settings_for_display();
922
923 $this->query_posts($settings['item_limit']['size']);
924 $wp_query = $this->get_query();
925
926 if (!$wp_query->found_posts) {
927 return;
928 }
929
930 $this->add_render_attribute(
931 [
932 'upk-harold-list' => [
933 'class' => 'upk-harold-list upk-ajax-grid',
934 'data-loadmore' => [
935 wp_json_encode(
936 array_filter([
937 'loadmore_enable' => $settings['ajax_loadmore_enable'],
938 'loadmore_btn' => $settings['ajax_loadmore_btn'],
939 'infinite_scroll' => $settings['ajax_loadmore_infinite_scroll'],
940 ])
941 ),
942 ],
943 ],
944 ]
945 );
946
947 if ($settings['ajax_loadmore_enable'] == 'yes') {
948 $ajax_settings = [
949 'posts_source' => isset($settings['posts_source']) ? $settings['posts_source'] : 'post',
950 'posts_per_page' => isset($settings['item_limit']['size']) ? $settings['item_limit']['size'] : 6,
951 'ajax_item_load' => isset($settings['ajax_loadmore_items']) ? $settings['ajax_loadmore_items'] : 3,
952 'posts_selected_ids' => isset($settings['posts_selected_ids']) ? $settings['posts_selected_ids'] : '',
953 'posts_include_by' => isset($settings['posts_include_by']) ? $settings['posts_include_by'] : [],
954 'posts_include_author_ids' => isset($settings['posts_include_author_ids']) ? $settings['posts_include_author_ids'] : '',
955 'posts_include_term_ids' => isset($settings['posts_include_term_ids']) ? $settings['posts_include_term_ids'] : '',
956 'posts_exclude_by' => isset($settings['posts_exclude_by']) ? $settings['posts_exclude_by'] : [],
957 'posts_exclude_ids' => isset($settings['posts_exclude_ids']) ? $settings['posts_exclude_ids'] : '',
958 'posts_exclude_author_ids' => isset($settings['posts_exclude_author_ids']) ? $settings['posts_exclude_author_ids'] : '',
959 'posts_exclude_term_ids' => isset($settings['posts_exclude_term_ids']) ? $settings['posts_exclude_term_ids'] : '',
960 'posts_offset' => isset($settings['posts_offset']) ? $settings['posts_offset'] : 0,
961 'posts_select_date' => isset($settings['posts_select_date']) ? $settings['posts_select_date'] : '',
962 'posts_date_before' => isset($settings['posts_date_before']) ? $settings['posts_date_before'] : '',
963 'posts_date_after' => isset($settings['posts_date_after']) ? $settings['posts_date_after'] : '',
964 'posts_orderby' => isset($settings['posts_orderby']) ? $settings['posts_orderby'] : 'date',
965 'posts_order' => isset($settings['posts_order']) ? $settings['posts_order'] : 'DESC',
966 'posts_ignore_sticky_posts' => isset($settings['posts_ignore_sticky_posts']) ? $settings['posts_ignore_sticky_posts'] : 'no',
967 'posts_only_with_featured_image'=> isset($settings['posts_only_with_featured_image']) ? $settings['posts_only_with_featured_image'] : 'no',
968 // List Settings
969 'show_image' => isset($settings['show_image']) ? $settings['show_image'] : 'yes',
970 'show_title' => isset($settings['show_title']) ? $settings['show_title'] : 'yes',
971 'title_tags' => isset( $settings['title_tags'] ) ? $settings['title_tags'] : 'h3',
972 'title_style' => isset($settings['title_style']) ? $settings['title_style'] : 'underline',
973 'show_category' => isset($settings['show_category']) ? $settings['show_category'] : 'yes',
974 'show_author' => isset($settings['show_author']) ? $settings['show_author'] : 'yes',
975 'meta_separator' => isset($settings['meta_separator']) ? $settings['meta_separator'] : '.',
976 'show_date' => isset($settings['show_date']) ? $settings['show_date'] : 'yes',
977 'show_time' => isset($settings['show_time']) ? $settings['show_time'] : 'no',
978 'human_diff_time' => isset($settings['human_diff_time']) ? $settings['human_diff_time'] : 'no',
979 'human_diff_time_short' => isset($settings['human_diff_time_short']) ? $settings['human_diff_time_short'] : 'no',
980 'show_reading_time' => isset($settings['show_reading_time']) ? $settings['show_reading_time'] : 'no',
981 'avg_reading_speed' => isset($settings['avg_reading_speed']) ? $settings['avg_reading_speed'] : 200,
982 'hide_seconds' => isset($settings['hide_seconds']) ? $settings['hide_seconds'] : 'no',
983 'hide_minutes' => isset($settings['hide_minutes']) ? $settings['hide_minutes'] : 'no',
984 'primary_thumbnail_size' => isset($settings['primary_thumbnail_size']) ? $settings['primary_thumbnail_size'] : 'medium',
985 'upk_link_new_tab' => isset($settings['upk_link_new_tab']) ? $settings['upk_link_new_tab'] : 'no',
986 'global_link' => isset($settings['global_link']) ? $settings['global_link'] : 'no',
987 ];
988
989 $this->add_render_attribute(
990 [
991 'upk-harold-list' => [
992 'data-settings' => [
993 wp_json_encode($ajax_settings)
994 ],
995 ],
996 ]
997 );
998 }
999
1000 $this->add_render_attribute('list-wrap', 'class', 'upk-list-wrap upk-ajax-grid-wrap');
1001
1002 if (isset($settings['upk_in_animation_show']) && ($settings['upk_in_animation_show'] == 'yes')) {
1003 $this->add_render_attribute('list-wrap', 'class', 'upk-in-animation');
1004 if (isset($settings['upk_in_animation_delay']['size'])) {
1005 $this->add_render_attribute('list-wrap', 'data-in-animation-delay', $settings['upk_in_animation_delay']['size']);
1006 }
1007 }
1008
1009 ?>
1010 <div <?php $this->print_render_attribute_string('upk-harold-list'); ?>>
1011 <div <?php $this->print_render_attribute_string('list-wrap'); ?>>
1012
1013 <?php while ($wp_query->have_posts()) :
1014 $wp_query->the_post();
1015
1016 $thumbnail_size = $settings['primary_thumbnail_size'];
1017
1018 ?>
1019
1020 <?php $this->render_post_grid_item(get_the_ID(), $thumbnail_size); ?>
1021
1022 <?php endwhile; ?>
1023 </div>
1024 </div>
1025
1026 <?php $this->render_ajax_loadmore(); ?>
1027
1028 <?php
1029
1030 if ($settings['show_pagination']) { ?>
1031 <div class="ep-pagination">
1032 <?php ultimate_post_kit_post_pagination($wp_query, $this->get_id()); ?>
1033 </div>
1034 <?php
1035 }
1036 wp_reset_postdata();
1037 }
1038 }
1039