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.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 / recent-comments / widgets / recent-comments.php

recent-comments.php in Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets 4.1.0, at modules/recent-comments/widgets/recent-comments.php

900 lines 21.8 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\RecentComments\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_Background;
10 use UltimatePostKit\Includes\Controls\SelectInput\Dynamic_Select;
11
12 use UltimatePostKit\Traits\Global_Widget_Controls;
13 use UltimatePostKit\Includes\Controls\GroupQuery\Group_Control_Query;
14 use WP_Comment_Query;
15
16 if (!defined('ABSPATH')) {
17 exit;
18 } // Exit if accessed directly
19
20 class Recent_Comments extends Group_Control_Query {
21
22 use Global_Widget_Controls;
23
24 private $_query = null;
25
26 public function get_name() {
27 return 'upk-recent-comments';
28 }
29
30 public function get_title() {
31 return BDTUPK . esc_html__('Recent Comments', 'ultimate-post-kit');
32 }
33
34 public function get_icon() {
35 return 'upk-widget-icon upk-icon-recent-comments';
36 }
37
38 public function get_categories() {
39 return ['ultimate-post-kit'];
40 }
41
42 public function get_keywords() {
43 return ['post', 'featured', 'blog', 'recent', 'news', 'classic', 'list'];
44 }
45
46 public function get_style_depends() {
47 if ($this->upk_is_edit_mode()) {
48 return ['upk-all-styles'];
49 } else {
50 return ['upk-recent-comments'];
51 }
52 }
53
54 public function get_custom_help_url() {
55 return 'https://youtu.be/_RFwr9Lx7Gs';
56 }
57
58
59 public function has_widget_inner_wrapper(): bool {
60 return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
61 }
62
63
64 protected function register_controls() {
65 $this->start_controls_section(
66 'section_content_layout',
67 [
68 'label' => esc_html__('Layout', 'ultimate-post-kit'),
69 ]
70 );
71
72 $this->add_responsive_control(
73 'columns',
74 [
75 'label' => __('Columns', 'ultimate-post-kit'),
76 'type' => Controls_Manager::SELECT,
77 'default' => '1',
78 'tablet_default' => '1',
79 'mobile_default' => '1',
80 'options' => [
81 '1' => '1',
82 '2' => '2',
83 '3' => '3',
84 '4' => '4',
85 ],
86 'selectors' => [
87 '{{WRAPPER}} .upk-recent-comments' => 'grid-template-columns: repeat({{SIZE}}, 1fr);',
88 ],
89 ]
90 );
91
92 $this->add_responsive_control(
93 'row_gap',
94 [
95 'label' => esc_html__('Row Gap', 'ultimate-post-kit'),
96 'type' => Controls_Manager::SLIDER,
97 'default' => [
98 'size' => 30,
99 ],
100 'selectors' => [
101 '{{WRAPPER}} .upk-recent-comments' => 'grid-row-gap: {{SIZE}}{{UNIT}};',
102 ],
103 ]
104 );
105
106 $this->add_responsive_control(
107 'column_gap',
108 [
109 'label' => esc_html__('Column Gap', 'ultimate-post-kit'),
110 'type' => Controls_Manager::SLIDER,
111 'default' => [
112 'size' => 30,
113 ],
114 'selectors' => [
115 '{{WRAPPER}} .upk-recent-comments' => 'grid-column-gap: {{SIZE}}{{UNIT}};',
116 ],
117 'condition' => [
118 'columns!' => '1'
119 ]
120 ]
121 );
122
123 $this->add_responsive_control(
124 'content_alignment',
125 [
126 'label' => __('Alignment', 'ultimate-post-kit'),
127 'type' => Controls_Manager::CHOOSE,
128 'options' => [
129 'left' => [
130 'title' => __('Left', 'ultimate-post-kit'),
131 'icon' => 'eicon-text-align-left',
132 ],
133 'center' => [
134 'title' => __('Center', 'ultimate-post-kit'),
135 'icon' => 'eicon-text-align-center',
136 ],
137 'right' => [
138 'title' => __('Right', 'ultimate-post-kit'),
139 'icon' => 'eicon-text-align-right',
140 ],
141 ],
142 'selectors' => [
143 '{{WRAPPER}} .upk-recent-comments .upk-item' => 'text-align: {{VALUE}};',
144 ],
145 ]
146 );
147
148 $this->end_controls_section();
149
150 // Query Settings
151 $this->start_controls_section(
152 'section_post_query_builder',
153 [
154 'label' => __('Query', 'ultimate-post-kit'),
155 'tab' => Controls_Manager::TAB_CONTENT,
156 ]
157 );
158
159 $this->add_control(
160 'post_type',
161 [
162 'label' => __('Post Type', 'ultimate-post-kit'),
163 'type' => Controls_Manager::SELECT,
164 'default' => 'post',
165 'options' => $this->ultimate_post_kit_get_post_types(),
166 ]
167 );
168
169 $this->start_controls_tabs(
170 'tabs_posts_include_exclude'
171 );
172
173 $this->start_controls_tab(
174 'tab_posts_include',
175 [
176 'label' => __('Include', 'ultimate-post-kit'),
177 ]
178 );
179
180 $this->add_control(
181 'posts_include_by',
182 [
183 'label' => __('Include By', 'ultimate-post-kit'),
184 'type' => Controls_Manager::SELECT2,
185 'multiple' => true,
186 'label_block' => true,
187 'options' => [
188 'authors' => __('Authors', 'ultimate-post-kit'),
189 ]
190 ]
191 );
192
193 $this->add_control(
194 'posts_include_author_ids',
195 [
196 'label' => __('Authors', 'ultimate-post-kit'),
197 'type' => Dynamic_Select::TYPE,
198 'multiple' => true,
199 'label_block' => true,
200 'query_args' => [
201 'query' => 'authors',
202 ],
203 'condition' => [
204 'posts_include_by' => 'authors',
205 ]
206 ]
207 );
208
209
210 $this->end_controls_tab();
211
212 $this->start_controls_tab(
213 'tab_posts_exclude',
214 [
215 'label' => __('Exclude', 'ultimate-post-kit'),
216 ]
217 );
218
219 $this->add_control(
220 'posts_exclude_by',
221 [
222 'label' => __('Exclude By', 'ultimate-post-kit'),
223 'type' => Controls_Manager::SELECT2,
224 'multiple' => true,
225 'label_block' => true,
226 'options' => [
227 'authors' => __('Authors', 'ultimate-post-kit'),
228
229 ]
230 ]
231 );
232
233
234 $this->add_control(
235 'posts_exclude_author_ids',
236 [
237 'label' => __('Authors', 'ultimate-post-kit'),
238 'type' => Dynamic_Select::TYPE,
239 'multiple' => true,
240 'label_block' => true,
241 'query_args' => [
242 'query' => 'authors',
243 ],
244 'condition' => [
245 'posts_exclude_by' => 'authors',
246 ]
247 ]
248 );
249
250 $this->end_controls_tab();
251 $this->end_controls_tabs();
252
253 $this->add_control(
254 'number',
255 [
256 'label' => __('Limit', 'ultimate-post-kit'),
257 'description' => __('The maximum number of comments to return.', 'ultimate-post-kit'),
258 'type' => Controls_Manager::TEXT,
259 'default' => '4',
260 'separator' => 'before'
261 ]
262 );
263
264 $this->add_control(
265 'offset',
266 [
267 'label' => __('Offset', 'ultimate-post-kit'),
268 'description' => __(' The number of comments to pass over in the query.', 'ultimate-post-kit'),
269 'type' => Controls_Manager::TEXT,
270 ]
271 );
272
273 $this->add_control(
274 'parent',
275 [
276 'label' => __('Only Parent', 'ultimate-post-kit'),
277 'type' => Controls_Manager::SWITCHER,
278 ]
279 );
280
281 $this->add_control(
282 'status',
283 [
284 'label' => __('Status', 'ultimate-post-kit'),
285 'type' => Controls_Manager::SELECT,
286 'default' => 'approve',
287 'options' => [
288 'approve' => __('Approve', 'ultimate-post-kit'),
289 'hold' => __('Hold', 'ultimate-post-kit'),
290 'all' => __('All', 'ultimate-post-kit'),
291 ],
292 ]
293 );
294
295 $this->add_control(
296 'orderby',
297 [
298 'label' => __('Order By', 'ultimate-post-kit'),
299 'type' => Controls_Manager::SELECT,
300 'default' => 'comment_date',
301 'options' => [
302 'comment_author' => __('Author', 'ultimate-post-kit'),
303 'comment_approved' => __('Approved', 'ultimate-post-kit'),
304 'comment_date' => __('Date', 'ultimate-post-kit'),
305 'comment_content' => __('Content', 'ultimate-post-kit'),
306 'none' => __('Random', 'ultimate-post-kit'),
307 ],
308 ]
309 );
310
311 $this->add_control(
312 'order',
313 [
314 'label' => __('Order', 'ultimate-post-kit'),
315 'type' => Controls_Manager::SELECT,
316 'default' => 'desc',
317 'options' => [
318 'asc' => __('ASC', 'ultimate-post-kit'),
319 'desc' => __('DESC', 'ultimate-post-kit'),
320 ],
321 ]
322 );
323
324 $this->end_controls_section();
325
326 $this->start_controls_section(
327 'section_additional_settings',
328 [
329 'label' => esc_html__('Additional Settings', 'ultimate-post-kit'),
330 ]
331 );
332
333 $this->add_control(
334 'show_title',
335 [
336 'label' => esc_html__('Show Title', 'ultimate-post-kit'),
337 'type' => Controls_Manager::SWITCHER,
338 'default' => 'yes',
339 ]
340 );
341
342 $this->add_control(
343 'show_excerpt',
344 [
345 'label' => esc_html__('Show Text', 'ultimate-post-kit'),
346 'type' => Controls_Manager::SWITCHER,
347 'default' => 'yes',
348 'separator' => 'before'
349 ]
350 );
351
352 $this->add_control(
353 'excerpt_limit',
354 [
355 'label' => esc_html__('Text Limit', 'ultimate-post-kit'),
356 'type' => Controls_Manager::NUMBER,
357 'default' => 30,
358 'condition' => [
359 'show_excerpt' => 'yes'
360 ],
361 ]
362 );
363
364 $this->add_control(
365 'show_author',
366 [
367 'label' => esc_html__('Show Author', 'ultimate-post-kit'),
368 'type' => Controls_Manager::SWITCHER,
369 'default' => 'yes',
370 'separator' => 'before'
371 ]
372 );
373
374 $this->add_control(
375 'author_middle_text',
376 [
377 'label' => __( 'Author Middle Text', 'ultimate-post-kit' ),
378 'type' => Controls_Manager::TEXT,
379 'dynamic' => [
380 'active' => true,
381 ],
382 'default' => ' @ ',
383 'placeholder' => __( 'Enter your text', 'ultimate-post-kit' ),
384 'label_block' => false,
385 'condition' => [
386 'show_author' => 'yes'
387 ]
388 ]
389 );
390
391 $this->add_control(
392 'show_date',
393 [
394 'label' => esc_html__('Show Date', 'ultimate-post-kit'),
395 'type' => Controls_Manager::SWITCHER,
396 'default' => 'yes',
397 'separator' => 'before'
398 ]
399 );
400
401 $this->end_controls_section();
402
403 //Style
404 $this->start_controls_section(
405 'upk_section_style',
406 [
407 'label' => esc_html__('Items', 'ultimate-post-kit'),
408 'tab' => Controls_Manager::TAB_STYLE,
409 ]
410 );
411
412 $this->add_group_control(
413 Group_Control_Background::get_type(),
414 [
415 'name' => 'item_background',
416 'selector' => '{{WRAPPER}} .upk-recent-comments .upk-item',
417 ]
418 );
419
420 $this->add_group_control(
421 Group_Control_Border::get_type(),
422 [
423 'name' => 'item_border',
424 'selector' => '{{WRAPPER}} .upk-recent-comments .upk-item',
425 ]
426 );
427
428 $this->add_responsive_control(
429 'item_border_radius',
430 [
431 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
432 'type' => Controls_Manager::DIMENSIONS,
433 'size_units' => ['px', '%'],
434 'selectors' => [
435 '{{WRAPPER}} .upk-recent-comments .upk-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
436 ],
437 ]
438 );
439
440 $this->add_responsive_control(
441 'item_padding',
442 [
443 'label' => __('Padding', 'ultimate-post-kit'),
444 'type' => Controls_Manager::DIMENSIONS,
445 'size_units' => ['px', 'em', '%'],
446 'selectors' => [
447 '{{WRAPPER}} .upk-recent-comments .upk-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
448 ],
449 ]
450 );
451
452 $this->add_group_control(
453 Group_Control_Box_Shadow::get_type(),
454 [
455 'name' => 'item_box_shadow',
456 'selector' => '{{WRAPPER}} .upk-recent-comments .upk-item',
457 ]
458 );
459
460 $this->end_controls_section();
461
462 $this->start_controls_section(
463 'section_style_text',
464 [
465 'label' => esc_html__('Text', 'ultimate-post-kit'),
466 'tab' => Controls_Manager::TAB_STYLE,
467 'condition' => [
468 'show_excerpt' => 'yes'
469 ]
470 ]
471 );
472
473 $this->add_control(
474 'text_color',
475 [
476 'label' => esc_html__('Color', 'ultimate-post-kit'),
477 'type' => Controls_Manager::COLOR,
478 'selectors' => [
479 '{{WRAPPER}} .upk-recent-comments .upk-text' => 'color: {{VALUE}};',
480 ],
481 ]
482 );
483
484 $this->add_group_control(
485 Group_Control_Typography::get_type(),
486 [
487 'name' => 'text_typography',
488 'label' => esc_html__('Typography', 'ultimate-post-kit'),
489 'selector' => '{{WRAPPER}} .upk-recent-comments .upk-text',
490 ]
491 );
492
493 $this->end_controls_section();
494
495 $this->start_controls_section(
496 'section_style_meta',
497 [
498 'label' => esc_html__('Meta', 'ultimate-post-kit'),
499 'tab' => Controls_Manager::TAB_STYLE,
500 'conditions' => [
501 'relation' => 'or',
502 'terms' => [
503 [
504 'name' => 'show_author',
505 'value' => 'yes'
506 ],
507 [
508 'name' => 'show_date',
509 'value' => 'yes'
510 ]
511 ]
512 ],
513 ]
514 );
515
516 $this->add_responsive_control(
517 'meta_spacing',
518 [
519 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
520 'type' => Controls_Manager::SLIDER,
521 'range' => [
522 'px' => [
523 'min' => 0,
524 'max' => 50,
525 ],
526 ],
527 'selectors' => [
528 '{{WRAPPER}} .upk-recent-comments .upk-meta' => 'margin-bottom: {{SIZE}}{{UNIT}};',
529 ],
530 ]
531 );
532
533 $this->start_controls_tabs('tabs_comments_meta_style');
534
535 $this->start_controls_tab(
536 'tab_comments_avatar',
537 [
538 'label' => esc_html__('Avatar', 'ultimate-post-kit'),
539 'condition' => [
540 'show_author' => 'yes'
541 ]
542 ]
543 );
544
545 $this->add_control(
546 'avatar_size',
547 [
548 'label' => __('Size', 'ultimate-post-kit'),
549 'type' => Controls_Manager::SELECT,
550 'default' => '48',
551 'options' => [
552 '16' => '16 X 16',
553 '24' => '24 X 24',
554 '48' => '48 X 48',
555 '64' => '64 X 64',
556 '80' => '80 X 80',
557 '90' => '90 X 90',
558 '100' => '100 X 100',
559 '120' => '120 X 120',
560 ],
561 'selectors' => [
562 '{{WRAPPER}} .upk-recent-comments .upk-meta .upk-avatar img' => 'min-width: {{VALUE}}px;',
563 ],
564 'condition' => [
565 'show_author' => 'yes'
566 ],
567 'render_type' => 'template'
568 ]
569 );
570
571 $this->add_group_control(
572 Group_Control_Border::get_type(),
573 [
574 'name' => 'avatar_border',
575 'selector' => '{{WRAPPER}} .upk-recent-comments .upk-meta .upk-avatar img',
576 'condition' => [
577 'show_author' => 'yes'
578 ]
579 ]
580 );
581
582 $this->add_responsive_control(
583 'avatar_border_radius',
584 [
585 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
586 'type' => Controls_Manager::DIMENSIONS,
587 'size_units' => ['px', '%'],
588 'selectors' => [
589 '{{WRAPPER}} .upk-recent-comments .upk-meta .upk-avatar img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
590 ],
591 'condition' => [
592 'show_author' => 'yes'
593 ]
594 ]
595 );
596
597 $this->add_responsive_control(
598 'avatar_padding',
599 [
600 'label' => __('Padding', 'ultimate-post-kit'),
601 'type' => Controls_Manager::DIMENSIONS,
602 'size_units' => ['px', 'em', '%'],
603 'selectors' => [
604 '{{WRAPPER}} .upk-recent-comments .upk-meta .upk-avatar img' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
605 ],
606 'condition' => [
607 'show_author' => 'yes'
608 ]
609 ]
610 );
611
612 $this->add_responsive_control(
613 'avatar_margin',
614 [
615 'label' => __('Margin', 'ultimate-post-kit'),
616 'type' => Controls_Manager::DIMENSIONS,
617 'size_units' => ['px', 'em', '%'],
618 'selectors' => [
619 '{{WRAPPER}} .upk-recent-comments .upk-meta .upk-avatar' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
620 ],
621 'condition' => [
622 'show_author' => 'yes'
623 ]
624 ]
625 );
626
627 $this->add_group_control(
628 Group_Control_Box_Shadow::get_type(),
629 [
630 'name' => 'avatar_box_shadow',
631 'selector' => '{{WRAPPER}} .upk-recent-comments .upk-meta .upk-avatar img',
632 'condition' => [
633 'show_author' => 'yes'
634 ]
635 ]
636 );
637
638 $this->end_controls_tab();
639
640 $this->start_controls_tab(
641 'tab_comments_name',
642 [
643 'label' => esc_html__('Author Text', 'ultimate-post-kit'),
644 'condition' => [
645 'show_author' => 'yes'
646 ]
647 ]
648 );
649
650 $this->add_control(
651 'author_name_color',
652 [
653 'label' => esc_html__('Color', 'ultimate-post-kit'),
654 'type' => Controls_Manager::COLOR,
655 'selectors' => [
656 '{{WRAPPER}} .upk-recent-comments .upk-meta .upk-author-name' => 'color: {{VALUE}};',
657 ],
658 'condition' => [
659 'show_author' => 'yes'
660 ]
661 ]
662 );
663
664 $this->add_control(
665 'author_name_hover_color',
666 [
667 'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
668 'type' => Controls_Manager::COLOR,
669 'selectors' => [
670 '{{WRAPPER}} .upk-recent-comments .upk-meta .upk-author-name:hover' => 'color: {{VALUE}};',
671 ],
672 'condition' => [
673 'show_author' => 'yes'
674 ]
675 ]
676 );
677
678 $this->add_group_control(
679 Group_Control_Typography::get_type(),
680 [
681 'name' => 'author_name_typography',
682 'label' => esc_html__('Typography', 'ultimate-post-kit'),
683 'selector' => '{{WRAPPER}} .upk-recent-comments .upk-meta .upk-author-name',
684 'condition' => [
685 'show_author' => 'yes'
686 ]
687 ]
688 );
689
690 $this->end_controls_tab();
691
692 $this->start_controls_tab(
693 'tab_comments_date',
694 [
695 'label' => esc_html__('Date', 'ultimate-post-kit'),
696 'condition' => [
697 'show_date' => 'yes'
698 ]
699 ]
700 );
701
702 $this->add_control(
703 'date_color',
704 [
705 'label' => esc_html__('Color', 'ultimate-post-kit'),
706 'type' => Controls_Manager::COLOR,
707 'selectors' => [
708 '{{WRAPPER}} .upk-recent-comments .upk-meta .upk-date' => 'color: {{VALUE}};',
709 ],
710 'condition' => [
711 'show_date' => 'yes'
712 ]
713 ]
714 );
715
716 $this->add_responsive_control(
717 'date_margin',
718 [
719 'label' => __('Margin', 'ultimate-post-kit'),
720 'type' => Controls_Manager::DIMENSIONS,
721 'size_units' => ['px', 'em', '%'],
722 'selectors' => [
723 '{{WRAPPER}} .upk-recent-comments .upk-meta .upk-date' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
724 ],
725 'condition' => [
726 'show_date' => 'yes'
727 ]
728 ]
729 );
730
731 $this->add_group_control(
732 Group_Control_Typography::get_type(),
733 [
734 'name' => 'date_typography',
735 'label' => esc_html__('Typography', 'ultimate-post-kit'),
736 'selector' => '{{WRAPPER}} .upk-recent-comments .upk-meta .upk-date',
737 'condition' => [
738 'show_date' => 'yes'
739 ]
740 ]
741 );
742
743 $this->end_controls_tab();
744
745 $this->end_controls_tabs();
746
747 $this->end_controls_section();
748 }
749
750 public function ultimate_post_kit_get_post_types($args = []) {
751
752 $post_type_args = [
753 'show_in_nav_menus' => true,
754 ];
755
756 if (!empty($args['post_type'])) {
757 $post_type_args['name'] = $args['post_type'];
758 }
759
760 $_post_types = get_post_types($post_type_args, 'objects');
761
762 $post_types = ['0' => esc_html__('All', 'ultimate-post-kit')];
763
764 foreach ($_post_types as $post_type => $object) {
765 $post_types[$post_type] = $object->label;
766 }
767
768 return $post_types;
769 }
770
771 public function get_html_output($output) {
772 $tags = [
773 'a' => ['href' => [], 'target' => [], 'class' => []],
774 'img' => ['src' => [], 'alt' => [], 'srcset' => [], 'height' => [], 'width' => [], 'loading' => []],
775 ];
776
777 if (isset($output)) {
778 echo wp_kses($output, $tags);
779 }
780 }
781
782 public function render() {
783 $settings = $this->get_settings_for_display();
784 global $post_id;
785 $query_args = [
786 'status' => $settings['status'],
787 'order' => $settings['order'],
788 'orderby' => $settings['orderby'],
789 'post_id' => $post_id,
790 'number' => $settings['number'],
791 'offset' => $settings['offset'],
792 'post_type' => $settings['post_type'],
793 ];
794
795 if ($settings['parent'] == 'yes') {
796 $query_args['parent'] = 0;
797 }
798 /**
799 * Set Authors
800 */
801 $include_users = [];
802 $exclude_users = [];
803 if (!empty($settings['posts_include_author_ids'])) {
804 if (in_array('authors', $settings['posts_include_by'])) {
805 $include_users = wp_parse_id_list($settings['posts_include_author_ids']);
806 }
807 }
808 if (!empty($settings['posts_exclude_author_ids'])) {
809 if (in_array('authors', $settings['posts_exclude_by'])) {
810 $exclude_users = wp_parse_id_list($settings['posts_exclude_author_ids']);
811 $include_users = array_diff($include_users, $exclude_users);
812 }
813 }
814 if (!empty($include_users)) {
815 $query_args['author__in'] = $include_users;
816 }
817
818 if (!empty($exclude_users)) {
819 $query_args['author__not_in'] = $exclude_users;;
820 }
821
822 $this->add_render_attribute('grid-wrap', 'class', 'upk-recent-comments');
823
824 if (isset($settings['upk_in_animation_show']) && ($settings['upk_in_animation_show'] == 'yes')) {
825 $this->add_render_attribute('grid-wrap', 'class', 'upk-in-animation');
826 if (isset($settings['upk_in_animation_delay']['size'])) {
827 $this->add_render_attribute('grid-wrap', 'data-in-animation-delay', $settings['upk_in_animation_delay']['size']);
828 }
829 }
830
831 $comments_query = new WP_Comment_Query;
832 $comments = $comments_query->query($query_args);
833 if ($comments) { ?>
834 <div <?php $this->print_render_attribute_string('grid-wrap'); ?>>
835 <?php
836 foreach ($comments as $comment) {
837 $title = get_the_title($comment->comment_post_ID);
838 $comment_id = $comment->comment_ID;
839 $content = wp_trim_words($comment->comment_content, $settings['excerpt_limit']);
840 $avatar = get_avatar($comment->comment_author_email, $size = $settings['avatar_size']);
841 $author = $comment->comment_author;
842 $date = get_comment_date('F j, Y \a\t g:i a', $comment_id);
843
844 $this->add_render_attribute(
845 'upk-author',
846 [
847 'class' => 'upk-author-name',
848 'href' => esc_url(get_permalink($comment->comment_post_ID)) . '#comment-' . $comment_id,
849 'target' => '_blank'
850 ],
851 null,
852 true
853 );
854
855 ?>
856 <div class="upk-item">
857
858 <?php if ($settings['show_author'] or $settings['show_date']) : ?>
859 <div class="upk-meta upk-flex-inline upk-flex-middle">
860
861 <?php if ($settings['show_author']) : ?>
862 <div class="upk-avatar">
863 <?php $this->get_html_output($avatar); ?>
864 </div>
865 <?php endif; ?>
866
867 <div class="upk-author-info">
868 <?php if ($settings['show_author']) : ?>
869 <a <?php $this->print_render_attribute_string('upk-author'); ?>>
870 <?php echo esc_html($author); ?>
871 <?php if ($settings['show_title']) : ?>
872 <?php echo esc_html($settings['author_middle_text']); ?>
873 <?php echo esc_html($title) ?>
874 <?php endif; ?>
875 </a>
876 <?php endif; ?>
877
878 <?php if ($settings['show_date']) : ?>
879 <div class="upk-date"><?php echo esc_html($date); ?></div>
880 <?php endif; ?>
881 </div>
882
883 </div>
884 <?php endif; ?>
885
886 <?php if ($settings['show_excerpt']) : ?>
887 <div class="upk-text"><?php echo wp_kses_post($content); ?></div>
888 <?php endif; ?>
889
890 </div>
891 <?php
892 }
893 echo '</div>';
894 wp_reset_postdata();
895 } else {
896 echo esc_html__('No Comments Found.', 'ultimate-post-kit');
897 }
898 }
899 }
900