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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 / learning-area / lesson / comment-card.php
tutor / templates / learning-area / lesson Last commit date
comment-card.php 5 days ago comment-form.php 5 days ago comment-list.php 5 days ago comment-replies.php 5 days ago comments.php 5 days ago content.php 5 days ago exercise-files.php 5 days ago footer.php 5 days ago nav-item.php 5 days ago overview.php 5 days ago
comment-card.php
142 lines
1 <?php
2 /**
3 * Comment Card Template
4 *
5 * @package Tutor\Templates
6 * @subpackage LearningArea\Lesson
7 * @author Themeum <support@themeum.com>
8 * @link https://themeum.com
9 * @since 4.0.0
10 */
11
12 defined( 'ABSPATH' ) || exit;
13
14 use Tutor\Components\Avatar;
15 use Tutor\Components\Constants\Size;
16 use Tutor\Components\Constants\Color;
17 use TUTOR\Icon;
18 use Tutor\Components\SvgIcon;
19
20 /**
21 * Variables available:
22 *
23 * @var $comment_item Object The comment object
24 * @var $lesson_id Int The lesson ID
25 * @var $user_id Int The current user ID
26 * @var $is_reply Bool Whether this is a reply (default false)
27 */
28
29 $is_reply = $is_reply ?? false;
30 $id_prefix = $is_reply ? 'tutor-comment-reply-' : 'tutor-comment-';
31 $class = $is_reply ? 'tutor-comment-reply-item' : 'tutor-comment-item';
32 ?>
33
34 <div class="<?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $id_prefix . $comment_item->comment_ID ); ?>">
35 <div
36 class="tutor-comment"
37 x-data="{ repliesExpanded: false }"
38 x-show="editingId !== <?php echo (int) $comment_item->comment_ID; ?>"
39 x-cloak
40 <?php if ( ! $is_reply ) : ?>
41 @tutor:comment:replied.window="if ($event.detail.parentId === <?php echo (int) $comment_item->comment_ID; ?>) { repliesExpanded = true; replyingId = null; }"
42 <?php endif; ?>
43 >
44 <?php Avatar::make()->user( $comment_item->user_id )->size( Size::SIZE_40 )->render(); ?>
45
46 <div class="tutor-comment-content tutor-flex-1">
47 <div class="tutor-flex tutor-justify-between">
48 <div>
49 <div class="tutor-flex tutor-items-center tutor-gap-5 tutor-mb-2 tutor-small">
50 <span class="tutor-discussion-card-author">
51 <?php echo esc_html( $comment_item->comment_author ); ?>
52 </span>
53 <span class="tutor-text-subdued">
54 <?php
55 /* translators: %s human-readable time difference. */
56 echo esc_html( sprintf( __( '%s ago', 'tutor' ), human_time_diff( strtotime( $comment_item->comment_date_gmt ) ) ) );
57 ?>
58 </span>
59 </div>
60 <div class="tutor-p2 tutor-text-secondary">
61 <?php echo wp_kses_post( $comment_item->comment_content ); ?>
62 </div>
63 </div>
64
65 <?php if ( $user_id === (int) $comment_item->user_id ) : ?>
66 <div x-data="tutorPopover({ placement: 'bottom-end' })">
67 <button x-ref="trigger" @click="toggle()" class="tutor-btn tutor-btn-ghost tutor-btn-x-small tutor-btn-icon">
68 <?php SvgIcon::make()->name( Icon::ELLIPSES )->size( 16 )->color( Color::SECONDARY )->render(); ?>
69 </button>
70 <div x-ref="content" x-show="open" x-cloak @click.outside="handleClickOutside()" class="tutor-popover">
71 <div class="tutor-popover-menu" style="min-width: 104px;">
72 <button class="tutor-popover-menu-item" @click="editingId = <?php echo (int) $comment_item->comment_ID; ?>; $nextTick(() => $dispatch('tutor-focus-form-<?php echo esc_attr( $id_prefix . 'edit-form-' . (int) $comment_item->comment_ID ); ?>')); hide()">
73 <?php SvgIcon::make()->name( Icon::EDIT_2 )->render(); ?>
74 <?php esc_html_e( 'Edit', 'tutor' ); ?>
75 </button>
76 <button class="tutor-popover-menu-item" @click="handleDeleteComment({commentId: <?php echo esc_html( $comment_item->comment_ID ); ?>}); hide()">
77 <?php SvgIcon::make()->name( Icon::DELETE_2 )->render(); ?>
78 <?php esc_html_e( 'Delete', 'tutor' ); ?>
79 </button>
80 </div>
81 </div>
82 </div>
83 <?php endif; ?>
84 </div>
85
86 <?php if ( ! $is_reply ) : ?>
87 <div class="tutor-mt-6">
88 <button class="tutor-comment-action-btn tutor-comment-action-btn-reply" @click="replyingId = replyingId === <?php echo (int) $comment_item->comment_ID; ?> ? null : <?php echo (int) $comment_item->comment_ID; ?>; if (replyingId) $nextTick(() => $dispatch('tutor-focus-form-lesson-comment-reply-form-<?php echo (int) $comment_item->comment_ID; ?>'))">
89 <?php SvgIcon::make()->name( Icon::COMMENTS )->render(); ?>
90 <?php esc_html_e( 'Reply', 'tutor' ); ?>
91 </button>
92 </div>
93
94 <?php
95 tutor_load_template(
96 'learning-area.lesson.comment-form',
97 array(
98 'form_id' => 'lesson-comment-reply-form-' . (int) $comment_item->comment_ID,
99 'placeholder' => __( 'Write your reply', 'tutor' ),
100 'submit_handler' => 'handleReplyComment(data, ' . (int) $comment_item->comment_ID . ')',
101 'cancel_handler' => 'reset(); replyingId = null',
102 'is_pending' => 'replyCommentMutation?.isPending',
103 'class' => 'tutor-comment-reply-form tutor-mt-6',
104 'x_show' => 'replyingId === ' . (int) $comment_item->comment_ID,
105 )
106 );
107 ?>
108
109 <!-- Display Comment Replies -->
110 <?php
111 tutor_load_template(
112 'learning-area.lesson.comment-replies',
113 array(
114 'lesson_id' => $lesson_id,
115 'comment_item' => $comment_item,
116 'user_id' => $user_id,
117 )
118 );
119 ?>
120 <?php endif; ?>
121 </div>
122 </div>
123
124 <?php if ( $user_id === (int) $comment_item->user_id ) : ?>
125 <?php
126 tutor_load_template(
127 'learning-area.lesson.comment-form',
128 array(
129 'form_id' => $id_prefix . 'edit-form-' . (int) $comment_item->comment_ID,
130 'placeholder' => $is_reply ? __( 'Write your reply', 'tutor' ) : __( 'Write your comment', 'tutor' ),
131 'submit_handler' => 'handleEditComment(data,' . (int) $comment_item->comment_ID . ')',
132 'cancel_handler' => 'reset(); editingId = null',
133 'is_pending' => 'editCommentMutation?.isPending',
134 'class' => 'tutor-comment-edit-form',
135 'x_show' => 'editingId === ' . (int) $comment_item->comment_ID,
136 'default_value' => $comment_item->comment_content,
137 )
138 );
139 ?>
140 <?php endif; ?>
141 </div>
142