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 / harold-list / widgets / harold-list.php

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

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