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.2 3.5.0 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / templates / dashboard / discussions / comment-card.php
tutor / templates / dashboard / discussions Last commit date
comment-card.php 4 days ago comment-form.php 4 days ago comment-list.php 4 days ago comment-replies.php 4 days ago comment-single.php 4 days ago qna-card.php 4 days ago qna-form.php 4 days ago qna-list.php 4 days ago qna-replies.php 4 days ago qna-single.php 4 days ago
comment-card.php
168 lines
1 <?php
2 /**
3 * Tutor dashboard lesson comment card.
4 *
5 * @package Tutor\Templates
6 * @author Themeum <support@themeum.com>
7 * @link https://themeum.com
8 * @since 4.0.0
9 */
10
11 defined( 'ABSPATH' ) || exit;
12
13 use Tutor\Components\Constants\Size;
14 use TUTOR\Icon;
15 use Tutor\Components\SvgIcon;
16 use Tutor\Components\Constants\Color;
17 use Tutor\Components\Avatar;
18 use Tutor\Components\Button;
19 use Tutor\Components\Constants\Variant;
20 use Tutor\Components\PreviewTrigger;
21 use Tutor\Helpers\UrlHelper;
22 use TUTOR\Lesson;
23
24 $course = get_post( tutor_utils()->get_course_id_by( 'lesson', $lesson_comment->comment_post_ID ) );
25 $last_reply = null;
26 $replies = Lesson::get_comments(
27 array(
28 'parent' => $lesson_comment->comment_ID,
29 'order' => 'DESC',
30 )
31 );
32
33 if ( ! empty( $replies ) ) {
34 $last_reply = $replies[0];
35 }
36
37 $single_url = UrlHelper::add_query_params(
38 $discussion_url,
39 array(
40 'tab' => 'lesson-comments',
41 'id' => $lesson_comment->comment_ID,
42 )
43 );
44 ?>
45 <div class="tutor-discussion-card" data-comment-id="<?php echo esc_attr( (int) $lesson_comment->comment_ID ); ?>" x-data="tutorPopover({ placement: 'bottom-end' })" :class="{ 'active': open }">
46 <div class="tutor-flex tutor-gap-4 tutor-w-full" x-show="editingId !== <?php echo (int) $lesson_comment->comment_ID; ?>">
47 <?php Avatar::make()->user( $lesson_comment->user_id )->size( Size::SIZE_32 )->render(); ?>
48 <div class="tutor-discussion-card-content">
49 <div class="tutor-discussion-card-top">
50 <div class="tutor-discussion-card-author tutor-flex-shrink-0"><?php echo esc_html( $lesson_comment->comment_author ); ?></div>
51 <div class="tutor-flex tutor-items-center tutor-gap-2 tutor-overflow-hidden">
52 <div class="tutor-flex tutor-items-center tutor-gap-2 tutor-min-w-0">
53 <span class="tutor-text-subdued tutor-flex-shrink-0"><?php esc_html_e( 'comment on', 'tutor' ); ?></span>
54 <div class="tutor-min-w-0 tutor-flex-1">
55 <?php PreviewTrigger::make()->id( $lesson_comment->comment_post_ID )->render(); ?>
56 </div>
57 </div>
58 <div class="tutor-flex tutor-items-center tutor-gap-2 tutor-min-w-0">
59 <span class="tutor-text-subdued tutor-flex-shrink-0"><?php esc_html_e( 'in', 'tutor' ); ?></span>
60 <div class="tutor-min-w-0 tutor-flex-1">
61 <?php PreviewTrigger::make()->id( $course->ID )->render(); ?>
62 </div>
63 </div>
64 </div>
65 </div>
66 <a href="<?php echo esc_url( $single_url ); ?>" class="tutor-discussion-card-title tutor-break-words" id="<?php echo esc_attr( 'tutor-lesson-comment-text-' . (int) $lesson_comment->comment_ID ); ?>"><?php echo wp_kses_post( $lesson_comment->comment_content ); ?></a>
67 <div class="tutor-discussion-card-meta tutor-sm-mt-4">
68 <button
69 @click="toggleCommentReply(<?php echo (int) $lesson_comment->comment_ID; ?>)"
70 class="tutor-discussion-card-meta-reply-button"
71 type="button"
72 >
73 <?php esc_html_e( 'Reply', 'tutor' ); ?>
74 </button>
75
76 <a href="<?php echo esc_url( $single_url ); ?>" class="tutor-flex tutor-items-center tutor-gap-2">
77 <?php SvgIcon::make()->name( Icon::COMMENTS )->size( 20 )->render(); ?>
78 <span class="tutor-discussion-card-reply-count tutor-text-subdued"><?php echo esc_html( count( $replies ) ); ?></span>
79 </a>
80
81 <?php if ( $last_reply ) { ?>
82 <div class="tutor-flex tutor-items-center tutor-gap-3 tutor-sm-ml-2">
83 <?php Avatar::make()->user( $last_reply->user_id )->size( Size::SIZE_20 )->render(); ?>
84 <div class="tutor-text-small"><?php echo esc_html( sprintf( __( '%s ago', 'tutor' ), human_time_diff( strtotime( $last_reply->comment_date_gmt ) ) ) ); //phpcs:ignore ?></div>
85 </div>
86 <?php } else { ?>
87 <div class="tutor-text-small"><?php echo esc_html( sprintf( __( '%s ago', 'tutor' ), human_time_diff( strtotime( $lesson_comment->comment_date_gmt ) ) ) ); //phpcs:ignore ?></div>
88 <?php } ?>
89 </div>
90 </div>
91 <div class="tutor-discussion-card-actions" x-show="replyingCommentId !== <?php echo (int) $lesson_comment->comment_ID; ?>">
92 <?php
93 Button::make()
94 ->variant( Variant::PRIMARY )
95 ->size( Size::X_SMALL )
96 ->label( __( 'Reply', 'tutor' ) )
97 ->attr( '@click', 'toggleCommentReply(' . (int) $lesson_comment->comment_ID . ')' )
98 ->attr( 'class', 'tutor-force-sm-hidden' )
99 ->attr( 'type', 'button' )
100 ->size( Size::X_SMALL )
101 ->render();
102 ?>
103 <?php if ( get_current_user_id() === (int) $lesson_comment->user_id ) : ?>
104 <div class="tutor-flex">
105 <?php
106 Button::make()
107 ->label( __( 'More options', 'tutor' ) )
108 ->variant( Variant::SECONDARY )
109 ->size( Size::X_SMALL )
110 ->icon( Icon::ELLIPSES, 'left', Size::SIZE_16, Color::SECONDARY )
111 ->icon_only()
112 ->attr( 'x-ref', 'trigger' )
113 ->attr( '@click', 'toggle()' )
114 ->render();
115 ?>
116 <div x-ref="content" x-show="open" x-cloak @click.outside="handleClickOutside()" class="tutor-popover">
117 <div class="tutor-popover-menu" style="min-width: 104px;">
118 <button class="tutor-popover-menu-item tutor-gap-5" @click="setEditing(<?php echo (int) $lesson_comment->comment_ID; ?>); hide()">
119 <?php SvgIcon::make()->name( Icon::EDIT_2 )->size( 20 )->render(); ?>
120 <?php esc_html_e( 'Edit', 'tutor' ); ?>
121 </button>
122 <button class="tutor-popover-menu-item tutor-gap-5" @click="TutorCore.modal.showModal('tutor-comment-delete-modal', { commentId: <?php echo esc_html( $lesson_comment->comment_ID ); ?> }); hide()">
123 <?php SvgIcon::make()->name( Icon::DELETE_2 )->size( 20 )->render(); ?>
124 <?php esc_html_e( 'Delete', 'tutor' ); ?>
125 </button>
126 </div>
127 </div>
128 </div>
129 <?php endif; ?>
130 </div>
131 </div>
132
133 <?php if ( get_current_user_id() === (int) $lesson_comment->user_id ) : ?>
134 <div x-show="editingId === <?php echo (int) $lesson_comment->comment_ID; ?>" x-cloak class="tutor-w-full">
135 <?php
136 tutor_load_template(
137 'dashboard.discussions.comment-form',
138 array(
139 'form_id' => 'lesson-comment-edit-' . (int) $lesson_comment->comment_ID,
140 'default_value' => $lesson_comment->comment_content,
141 'submit_handler' => '(data) => handleEditComment(data, ' . (int) $lesson_comment->comment_ID . ')',
142 'cancel_handler' => 'reset(); editingId = null; focused = false',
143 'is_pending' => 'editCommentMutation?.isPending',
144 'placeholder' => __( 'Write your comment', 'tutor' ),
145 )
146 );
147 ?>
148 </div>
149 <?php endif; ?>
150
151 <div x-show="replyingCommentId === <?php echo (int) $lesson_comment->comment_ID; ?>" x-cloak class="tutor-card tutor-surface-l1-hover tutor-mt-4 tutor-w-full">
152 <?php
153 tutor_load_template(
154 'dashboard.discussions.comment-form',
155 array(
156 'form_id' => 'lesson-comment-reply-form-' . (int) $lesson_comment->comment_ID,
157 'submit_handler' => '(data) => handleReplyComment(data, ' . (int) $lesson_comment->comment_ID . ', ' . (int) $lesson_comment->comment_post_ID . ', "list")',
158 'cancel_handler' => 'setReplyingComment(null)',
159 'is_pending' => 'replyCommentMutation?.isPending',
160 'placeholder' => __( 'Write your reply', 'tutor' ),
161 'label' => __( 'Reply', 'tutor' ),
162 'submit_label' => __( 'Save', 'tutor' ),
163 )
164 );
165 ?>
166 </div>
167 </div>
168