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.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 / views / qna / qna-single.php
tutor / views / qna Last commit date
contexts.php 3 years ago qna-new.php 3 years ago qna-single.php 2 months ago qna-table.php 2 months ago
qna-single.php
205 lines
1 <?php
2 /**
3 * Tutor Q&A single page
4 *
5 * @package Tutor\Views
6 * @subpackage Tutor\Q&A
7 * @author Themeum <support@themeum.com>
8 * @link https://themeum.com
9 * @since 2.0.0
10 */
11
12 use TUTOR\Input;
13
14 extract( $data ); // $question_id
15
16 // QNA data.
17 $question = tutor_utils()->get_qa_question( (int) $question_id );
18 if ( ! $question ) {
19 tutor_utils()->tutor_empty_state();
20 return;
21 }
22
23 if ( property_exists( $question, 'meta' ) ) {
24 $meta = $question->meta;
25 }
26
27 $answers = tutor_utils()->get_qa_answer_by_question( $question_id );
28 $back_url = isset( $back_url ) ? $back_url : remove_query_arg( 'question_id', is_admin() ? admin_url( 'admin.php?page=question_answer' ) : tutor()->current_url );
29
30 // Badges data.
31 $_user_id = get_current_user_id();
32 if ( property_exists( $question, 'user_id' ) ) {
33 $is_user_asker = $question->user_id == $_user_id;
34 }
35 $id_slug = $is_user_asker ? '_' . $_user_id : '';
36 $is_solved = (int) tutor_utils()->array_get( 'tutor_qna_solved' . $id_slug, $meta, 0 );
37 $is_important = (int) tutor_utils()->array_get( 'tutor_qna_important' . $id_slug, $meta, 0 );
38 $is_archived = (int) tutor_utils()->array_get( 'tutor_qna_archived' . $id_slug, $meta, 0 );
39 $is_read = (int) tutor_utils()->array_get( 'tutor_qna_read' . $id_slug, $meta, 0 );
40
41 $modal_id = 'tutor_qna_delete_single_' . $question_id;
42 $reply_hidden = ! wp_doing_ajax() ? 'display:none;' : 0;
43
44 // At first set this as read.
45 update_comment_meta( $question_id, 'tutor_qna_read' . $id_slug, 1 );
46 ?>
47
48 <div class="tutor-qna-single-question<?php echo is_admin() ? ' tutor-admin-wrap' : ''; ?>" data-course_id="<?php echo esc_attr( $question->course_id ); ?>" data-question_id="<?php echo esc_attr( $question_id ); ?>" data-context="<?php echo esc_attr( $context ); ?>">
49 <?php if ( in_array( $context, array( 'backend-dashboard-qna-single', 'frontend-dashboard-qna-single' ) ) ) : ?>
50 <div class="<?php echo is_admin() ? 'tutor-wp-dashboard-header tutor-px-24 tutor-mb-24' : 'tutor-qa-sticky-bar'; ?>">
51 <div class="tutor-row tutor-align-lg-center">
52 <div class="tutor-col-lg">
53 <div class="tutor-d-lg-flex tutor-align-lg-center tutor-px-12 tutor-py-16">
54 <a class="tutor-btn tutor-btn-ghost" href="<?php echo esc_url( $back_url ); ?>">
55 <span class="tutor-icon-previous tutor-mr-8" aria-hidden="true"></span>
56 <?php esc_html_e( 'Back', 'tutor' ); ?>
57 </a>
58 </div>
59 </div>
60
61 <div class="tutor-col-lg-auto">
62 <div class="tutor-qna-badges tutor-qna-badges-wrapper">
63 <?php if ( ! $is_user_asker ) : ?>
64 <span class="tutor-btn tutor-btn-ghost tutor-mr-16" data-action="solved" data-state-class-selector="i" data-state-class-0="tutor-icon-circle-mark-line" data-state-class-1="tutor-icon-circle-mark tutor-color-success" role="button">
65 <i class="<?php echo $is_solved ? 'tutor-icon-circle-mark tutor-color-success active' : 'tutor-icon-circle-mark-line'; ?> tutor-mr-8"></i>
66 <span><?php esc_html_e( 'Solved', 'tutor' ); ?></span>
67 </span>
68
69 <span class="tutor-btn tutor-btn-ghost tutor-mr-16" data-action="important" data-state-class-selector="i" data-state-class-0="tutor-icon-important-line" data-state-class-1="tutor-icon-important-bold">
70 <i class="<?php echo $is_important ? 'tutor-icon-important-bold active' : 'tutor-icon-important-line'; ?> tutor-mr-8"></i>
71 <span><?php esc_html_e( 'Important', 'tutor' ); ?></span>
72 </span>
73
74 <span class="tutor-btn tutor-btn-ghost tutor-mr-16" data-action="archived" data-state-text-selector="span" data-state-text-0="<?php esc_html_e( 'Archive', 'tutor' ); ?>" data-state-text-1="<?php esc_html_e( 'Un-Archive', 'tutor' ); ?>" data-state-class-selector="i" data-state-class-0="tutor-icon-archive" data-state-class-1="tutor-icon-archive">
75 <i class="<?php echo $is_archived ? 'tutor-icon-archive active' : 'tutor-icon-archive'; ?> tutor-mr-8"></i>
76 <span><?php $is_archived ? esc_html_e( 'Un-Archive', 'tutor' ) : esc_html_e( 'Archive', 'tutor' ); ?></span>
77 </span>
78 <?php endif; ?>
79 <span class="tutor-btn tutor-btn-ghost" data-tutor-modal-target="<?php echo esc_attr( $modal_id ); ?>">
80 <i class="tutor-icon-trash-can-bold tutor-mr-8" aria-hidden="true"></i>
81 <?php esc_html_e( 'Delete', 'tutor' ); ?>
82 </span>
83 </div>
84 </div>
85 </div>
86 </div>
87 <?php endif; ?>
88
89 <div class="<?php echo is_admin() ? 'tutor-admin-container' : ''; ?>">
90 <div class="tutor-qna-course-title tutor-color-black tutor-fs-6 tutor-fw-bold tutor-mb-32<?php echo is_single_course( true ) || ( Input::has( 'action' ) ) ? ' tutor-d-none' : ''; ?>">
91 <?php echo esc_html( $question->post_title ); ?>
92 <div class="tutor-hr tutor-mt-20" aria-hidden="true"></div>
93 </div>
94 <div class="tutor-qna-single-wrapper">
95 <div class="tutor-qa-reply-wrapper tutor-mt-20">
96 <div class="tutor-qa-chatlist">
97 <?php
98 $current_user_id = get_current_user_id();
99 $avatar_url = array();
100 $is_single = in_array( $context, array( 'course-single-qna-sidebar', 'course-single-qna-single' ) );
101
102 if ( is_array( $answers ) && count( $answers ) ) {
103 $reply_count = count( $answers ) - 1;
104 foreach ( $answers as $answer ) {
105 if ( ! isset( $avatar_url[ $answer->user_id ] ) ) {
106 // Get avatar url if not already got.
107 $avatar_url[ $answer->user_id ] = get_avatar_url( $answer->user_id );
108 }
109
110 $css_class = ( $current_user_id != $answer->user_id || 0 == $answer->comment_parent ) ? 'tutor-qna-left' : 'tutor-qna-right';
111 $css_style = ( $is_single && $answer->comment_parent != 0 ) ? 'margin-left:14%;' . $reply_hidden : '';
112 $reply_class = ( $is_single && $answer->comment_parent != 0 ) ? 'tutor-reply-msg' : '';
113 ?>
114 <div class="tutor-qna-chat <?php echo esc_attr( $css_class . ' ' . $reply_class ); ?>" style="<?php echo esc_attr( $css_style ); ?>">
115 <div class="tutor-qna-user">
116 <div>
117 <img src="<?php echo wp_kses( get_avatar_url( $answer->user_id ), tutor_utils()->allowed_avatar_tags() ); ?>" />
118 </div>
119
120 <div>
121 <div class="tutor-fs-6 tutor-fw-medium tutor-color-secondary">
122 <?php echo esc_html( $answer->display_name ); ?>
123 </div>
124 <div class="tutor-fs-7 tutor-color-muted">
125 <?php
126 $date = human_time_diff( strtotime( $answer->comment_date_gmt ) );
127 $time_ago = __( 'ago', 'tutor' );
128 echo esc_html( $date . ' ' . $time_ago );
129 ?>
130 </div>
131 </div>
132 </div>
133
134 <div class="tutor-qna-text tutor-fs-7">
135 <?php
136 $content = stripslashes( $answer->comment_content );
137 echo tutor()->has_pro ? wp_kses_post( $content ) : esc_textarea( $content );
138 ?>
139 </div>
140
141 <?php if ( $is_single && 0 == $answer->comment_parent ) : ?>
142 <div class="tutor-toggle-reply">
143 <span>
144 <?php esc_html_e( 'Reply', 'tutor' ); ?>
145 <?php echo esc_html( $reply_count ? '(' . $reply_count . ')' : '' ); ?>
146 </span>
147 </div>
148 <?php endif; ?>
149 </div>
150 <?php
151 }
152 }
153 ?>
154 </div>
155 <div class="tutor-qa-reply tutor-mt-12 tutor-mb-24 tutor-qna-reply-editor" data-context="<?php echo esc_attr( $context ); ?>" style="<?php echo esc_attr( $is_single ? $reply_hidden : '' ); ?>">
156 <?php if ( function_exists( 'tutor_pro' ) ) : ?>
157 <?php
158 wp_editor(
159 '',
160 'tutor_qna_reply_editor_' . $question_id,
161 tutor_utils()->text_editor_config(
162 array(
163 'plugins' => 'codesample',
164 'tinymce' => array(
165 'toolbar1' => 'bold,italic,underline,link,unlink,removeformat,image,bullist,codesample',
166 'toolbar2' => '',
167 'toolbar3' => '',
168 ),
169 )
170 )
171 );
172 ?>
173 <?php else : ?>
174 <textarea class="tutor-form-control" placeholder="<?php esc_html_e( 'Write here...', 'tutor' ); ?>"></textarea>
175 <?php endif; ?>
176
177 <div class="tutor-d-flex tutor-align-center tutor-mt-12">
178 <button data-back_url="<?php echo esc_url( $back_url ); ?>" type="submit" class="tutor-btn tutor-btn-primary tutor-btn-sm">
179 <?php esc_html_e( 'Reply', 'tutor' ); ?>
180 </button>
181 </div>
182 </div>
183 </div>
184 </div>
185 </div>
186 </div>
187
188 <?php
189 // Delete modal.
190 tutor_load_template(
191 'modal.confirm',
192 array(
193 'id' => $modal_id,
194 'image' => 'icon-trash.svg',
195 'title' => __( 'Do You Want to Delete This Question?', 'tutor' ),
196 'content' => __( 'All the replies also will be deleted.', 'tutor' ),
197 'yes' => array(
198 'text' => __( 'Yes, Delete This', 'tutor' ),
199 'class' => 'tutor-list-ajax-action',
200 'attr' => array( 'data-request_data=\'{"action":"tutor_delete_dashboard_question", "question_id":"' . $question_id . '"}\'', 'data-redirect_to="' . $back_url . '"' ),
201 ),
202 )
203 );
204 ?>
205