PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / 4.1.0
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets v4.1.0
4.5.6 4.5.5 4.5.4 4.2.1 4.2.2 4.2.3 4.5.0 4.5.2 4.5.3 4.2.0 4.1.18 4.1.17 4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.0.9 4.1.0 4.1.1 4.1.2 All 148 releases
ultimate-post-kit / modules / 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.0, at modules/harold-list/widgets/harold-list.php

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