PluginProbe
Tutor LMS – eLearning and online course solution / 2.1.8
Tutor LMS – eLearning and online course solution v2.1.8
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 3.9.15 3.9.14 3.9.13 3.9.12 3.9.11 trunk 1.0.0 1.0.0-alpha 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 All 191 releases
tutor / templates / dashboard / my-courses.php
my-courses.php
331 lines 13.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * My Courses Page
4 *
5 * @package Tutor\Templates
6 * @subpackage Dashboard
7 * @author Themeum <support@themeum.com>
8 * @link https://themeum.com
9 * @since 1.4.3
10 */
11
12 use TUTOR\Input;
13 use Tutor\Models\CourseModel;
14
15 // Get the user ID and active tab.
16 $current_user_id = get_current_user_id();
17 ! isset( $active_tab ) ? $active_tab = 'my-courses' : 0;
18
19 // Map required course status according to page.
20 $status_map = array(
21 'my-courses' => CourseModel::STATUS_PUBLISH,
22 'my-courses/draft-courses' => CourseModel::STATUS_DRAFT,
23 'my-courses/pending-courses' => CourseModel::STATUS_PENDING,
24 );
25
26 // Set currently required course status fo rcurrent tab.
27 $status = isset( $status_map[ $active_tab ] ) ? $status_map[ $active_tab ] : CourseModel::STATUS_PUBLISH;
28
29 // Get counts for course tabs.
30 $count_map = array(
31 'publish' => CourseModel::get_courses_by_instructor( $current_user_id, CourseModel::STATUS_PUBLISH, 0, 0, true ),
32 'pending' => CourseModel::get_courses_by_instructor( $current_user_id, CourseModel::STATUS_PENDING, 0, 0, true ),
33 'draft' => CourseModel::get_courses_by_instructor( $current_user_id, CourseModel::STATUS_DRAFT, 0, 0, true ),
34 );
35
36 $course_archive_arg = isset( $GLOBALS['tutor_course_archive_arg'] ) ? $GLOBALS['tutor_course_archive_arg']['column_per_row'] : null;
37 $courseCols = null === $course_archive_arg ? tutor_utils()->get_option( 'courses_col_per_row', 4 ) : $course_archive_arg;
38 $per_page = tutor_utils()->get_option( 'courses_per_page', 10 );
39 $paged = Input::get( 'current_page', 1, Input::TYPE_INT );
40 $offset = $per_page * ( $paged - 1 );
41
42 $results = CourseModel::get_courses_by_instructor( $current_user_id, $status, $offset, $per_page );
43 ?>
44
45 <div class="tutor-dashboard-my-courses">
46 <div class="tutor-fs-5 tutor-fw-medium tutor-color-black tutor-mb-16">
47 <?php esc_html_e( 'My Courses', 'tutor' ); ?>
48 </div>
49
50 <div class="tutor-dashboard-content-inner">
51 <div class="tutor-mb-32">
52 <ul class="tutor-nav">
53 <li class="tutor-nav-item">
54 <a class="tutor-nav-link<?php echo esc_attr( 'my-courses' === $active_tab ? ' is-active' : '' ); ?>" href="<?php echo esc_url( tutor_utils()->get_tutor_dashboard_page_permalink( 'my-courses' ) ); ?>">
55 <?php esc_html_e( 'Publish', 'tutor' ); ?> <?php echo esc_html( '(' . $count_map['publish'] . ')' ); ?>
56 </a>
57 </li>
58 <li class="tutor-nav-item">
59 <a class="tutor-nav-link<?php echo esc_attr( 'my-courses/pending-courses' === $active_tab ? ' is-active' : '' ); ?>" href="<?php echo esc_url( tutor_utils()->get_tutor_dashboard_page_permalink( 'my-courses/pending-courses' ) ); ?>">
60 <?php esc_html_e( 'Pending', 'tutor' ); ?> <?php echo esc_html( '(' . $count_map['pending'] . ')' ); ?>
61 </a>
62 </li>
63 <li class="tutor-nav-item">
64 <a class="tutor-nav-link<?php echo esc_attr( 'my-courses/draft-courses' === $active_tab ? ' is-active' : '' ); ?>" href="<?php echo esc_url( tutor_utils()->get_tutor_dashboard_page_permalink( 'my-courses/draft-courses' ) ); ?>">
65 <?php esc_html_e( 'Draft', 'tutor' ); ?> <?php echo esc_html( '(' . $count_map['draft'] . ')' ); ?>
66 </a>
67 </li>
68 </ul>
69 </div>
70
71 <!-- Course list -->
72 <?php
73 $placeholder_img = tutor()->url . 'assets/images/placeholder.svg';
74
75 if ( ! is_array( $results ) || ( ! count( $results ) && 1 == $paged ) ) {
76 tutor_utils()->tutor_empty_state( tutor_utils()->not_found_text() );
77 } else {
78 ?>
79 <div class="tutor-grid tutor-grid-3">
80 <?php
81 global $post;
82 $tutor_nonce_value = wp_create_nonce( tutor()->nonce_action );
83 foreach ( $results as $post ) :
84 setup_postdata( $post );
85
86 $avg_rating = tutor_utils()->get_course_rating()->rating_avg;
87 $tutor_course_img = get_tutor_course_thumbnail_src();
88 $id_string_delete = 'tutor_my_courses_delete_' . $post->ID;
89 $row_id = 'tutor-dashboard-my-course-' . $post->ID;
90 $course_duration = get_tutor_course_duration_context( $post->ID, true );
91 $course_students = tutor_utils()->count_enrolled_users_by_course();
92 ?>
93
94 <div id="<?php echo esc_attr( $row_id ); ?>" class="tutor-card tutor-course-card tutor-mycourse-<?php the_ID(); ?>">
95 <a href="<?php echo esc_url( get_the_permalink() ); ?>" class="tutor-d-block">
96 <div class="tutor-ratio tutor-ratio-16x9">
97 <img class="tutor-card-image-top" src="<?php echo empty( $tutor_course_img ) ? esc_url( $placeholder_img ) : esc_url( $tutor_course_img ); ?>" alt="<?php the_title(); ?>" loading="lazy">
98 </div>
99 </a>
100
101 <div class="tutor-card-body">
102 <div class="tutor-meta tutor-mb-8">
103 <span>
104 <?php echo esc_html( get_the_date() ); ?> <?php echo esc_html( get_the_time() ); ?>
105 </span>
106 </div>
107
108 <div class="tutor-course-name tutor-fs-6 tutor-fw-bold tutor-mb-16">
109 <a href="<?php echo esc_url( get_the_permalink() ); ?>"><?php the_title(); ?></a>
110 </div>
111
112 <?php if ( ! empty( $course_duration ) || ! empty( $course_students ) ) : ?>
113 <div class="tutor-meta tutor-mt-16">
114 <?php if ( ! empty( $course_duration ) ) : ?>
115 <div>
116 <span class="tutor-icon-clock-line tutor-meta-icon" area-hidden="true"></span>
117 <span class="tutor-meta-value">
118 <?php
119 echo wp_kses(
120 stripslashes( $course_duration ),
121 array(
122 'span' => array( 'class' => true ),
123 )
124 );
125 ?>
126 </span>
127 </div>
128 <?php endif; ?>
129
130 <?php if ( ! empty( $course_students ) ) : ?>
131 <div>
132 <span class="tutor-icon-user-line tutor-meta-icon" area-hidden="true"></span>
133 <span class="tutor-meta-value">
134 <?php
135 echo wp_kses(
136 stripslashes( $course_students ),
137 array(
138 'span' => array( 'class' => true ),
139 )
140 );
141 ?>
142 </span>
143 </div>
144 <?php endif; ?>
145 </div>
146 <?php endif; ?>
147 </div>
148
149 <div class="tutor-card-footer">
150 <div class="tutor-d-flex tutor-align-center tutor-justify-between">
151 <div class="tutor-d-flex tutor-align-center">
152 <span class="tutor-fs-7 tutor-fw-medium tutor-color-muted tutor-mr-4">
153 <?php esc_html_e( 'Price:', 'tutor' ); ?>
154 </span>
155 <span class="tutor-fs-7 tutor-fw-medium tutor-color-black">
156 <?php
157 $price = tutor_utils()->get_course_price();
158 if ( null === $price ) {
159 esc_html_e( 'Free', 'tutor' );
160 } else {
161 echo wp_kses_post( tutor_utils()->get_course_price() );
162 }
163 ?>
164 </span>
165 </div>
166 <div class="tutor-iconic-btn-group tutor-mr-n8">
167 <a href="<?php echo esc_url( tutor_utils()->course_edit_link( $post->ID ) ); ?>" class="tutor-iconic-btn tutor-my-course-edit">
168 <i class="tutor-icon-edit" area-hidden="true"></i>
169 </a>
170 <div class="tutor-dropdown-parent">
171 <button type="button" class="tutor-iconic-btn" action-tutor-dropdown="toggle">
172 <span class="tutor-icon-kebab-menu" area-hidden="true"></span>
173 </button>
174 <div id="table-dashboard-course-list-<?php echo esc_attr( $post->ID ); ?>" class="tutor-dropdown tutor-dropdown-dark tutor-text-left">
175
176 <!-- Submit Action -->
177 <?php if ( tutor()->has_pro && in_array( $post->post_status, array( CourseModel::STATUS_DRAFT ) ) ) : ?>
178 <?php
179 $params = http_build_query(
180 array(
181 'tutor_action' => 'update_course_status',
182 'status' => CourseModel::STATUS_PENDING,
183 'course_id' => $post->ID,
184 tutor()->nonce => $tutor_nonce_value,
185 )
186 );
187 ?>
188 <a class="tutor-dropdown-item" href="?<?php echo esc_attr( $params ); ?>">
189 <i class="tutor-icon-share tutor-mr-8" area-hidden="true"></i>
190 <span>
191 <?php
192 $can_publish_course = current_user_can( 'administrator' ) || (bool) tutor_utils()->get_option( 'instructor_can_publish_course' );
193 if ( $can_publish_course ) {
194 esc_html_e( 'Publish', 'tutor' );
195 } else {
196 esc_html_e( 'Submit', 'tutor' );
197 }
198 ?>
199 </span>
200 </a>
201 <?php endif; ?>
202 <!-- # Submit Action -->
203
204 <!-- Duplicate Action -->
205 <?php if ( tutor()->has_pro && in_array( $post->post_status, array( CourseModel::STATUS_PUBLISH, CourseModel::STATUS_PENDING, CourseModel::STATUS_DRAFT ) ) ) : ?>
206 <?php
207 $params = http_build_query(
208 array(
209 'tutor_action' => 'duplicate_course',
210 'course_id' => $post->ID,
211 )
212 );
213 ?>
214 <a class="tutor-dropdown-item" href="?<?php echo esc_attr( $params ); ?>">
215 <i class="tutor-icon-copy-text tutor-mr-8" area-hidden="true"></i>
216 <span><?php esc_html_e( 'Duplicate', 'tutor' ); ?></span>
217 </a>
218 <?php endif; ?>
219 <!-- # Duplicate Action -->
220
221 <!-- Move to Draf Action -->
222 <?php if ( tutor()->has_pro && in_array( $post->post_status, array( CourseModel::STATUS_PUBLISH ) ) ) : ?>
223 <?php
224 $params = http_build_query(
225 array(
226 'tutor_action' => 'update_course_status',
227 'status' => CourseModel::STATUS_DRAFT,
228 'course_id' => $post->ID,
229 tutor()->nonce => $tutor_nonce_value,
230 )
231 );
232 ?>
233 <a class="tutor-dropdown-item" href="?<?php echo esc_attr( $params ); ?>">
234 <i class="tutor-icon-archive tutor-mr-8" area-hidden="true"></i>
235 <span><?php esc_html_e( 'Move to Draft', 'tutor' ); ?></span>
236 </a>
237 <?php endif; ?>
238 <!-- # Move to Draft Action -->
239
240 <!-- Cancel Submission -->
241 <?php if ( tutor()->has_pro && in_array( $post->post_status, array( CourseModel::STATUS_PENDING ) ) ) : ?>
242 <?php
243 $params = http_build_query(
244 array(
245 'tutor_action' => 'update_course_status',
246 'status' => CourseModel::STATUS_DRAFT,
247 'course_id' => $post->ID,
248 tutor()->nonce => $tutor_nonce_value,
249 )
250 );
251 ?>
252 <a href="?<?php echo esc_attr( $params ); ?>" class="tutor-dropdown-item">
253 <i class="tutor-icon-times tutor-mr-8" area-hidden="true"></i>
254 <span><?php esc_html_e( 'Cancel Submission', 'tutor' ); ?></span>
255 </a>
256 <?php endif; ?>
257 <!-- # Cancel Submission -->
258
259 <!-- Delete Action -->
260 <?php if ( in_array( $post->post_status, array( CourseModel::STATUS_PUBLISH, CourseModel::STATUS_DRAFT ) ) ) : ?>
261 <a href="#" data-tutor-modal-target="<?php echo esc_attr( $id_string_delete ); ?>" class="tutor-dropdown-item tutor-admin-course-delete">
262 <i class="tutor-icon-trash-can-bold tutor-mr-8" area-hidden="true"></i>
263 <span><?php esc_html_e( 'Delete', 'tutor' ); ?></span>
264 </a>
265 <?php endif; ?>
266 <!-- # Delete Action -->
267
268 </div>
269 </div>
270 </div>
271 </div>
272 </div>
273
274 <!-- Delete prompt modal -->
275 <div id="<?php echo esc_attr( $id_string_delete ); ?>" class="tutor-modal">
276 <div class="tutor-modal-overlay"></div>
277 <div class="tutor-modal-window">
278 <div class="tutor-modal-content tutor-modal-content-white">
279 <button class="tutor-iconic-btn tutor-modal-close-o" data-tutor-modal-close>
280 <span class="tutor-icon-times" area-hidden="true"></span>
281 </button>
282
283 <div class="tutor-modal-body tutor-text-center">
284 <div class="tutor-mt-48">
285 <img class="tutor-d-inline-block" src="<?php echo esc_attr( tutor()->url ); ?>assets/images/icon-trash.svg" />
286 </div>
287
288 <div class="tutor-fs-3 tutor-fw-medium tutor-color-black tutor-mb-12"><?php esc_html_e( 'Delete This Course?', 'tutor' ); ?></div>
289 <div class="tutor-fs-6 tutor-color-muted"><?php esc_html_e( 'Are you sure you want to delete this course permanently from the site? Please confirm your choice.', 'tutor' ); ?></div>
290
291 <div class="tutor-d-flex tutor-justify-center tutor-my-48">
292 <button data-tutor-modal-close class="tutor-btn tutor-btn-outline-primary">
293 <?php esc_html_e( 'Cancel', 'tutor' ); ?>
294 </button>
295 <button class="tutor-btn tutor-btn-primary tutor-list-ajax-action tutor-ml-20" data-request_data='{"course_id":<?php echo esc_attr( $post->ID ); ?>,"action":"tutor_delete_dashboard_course","redirect_to":"<?php echo esc_url( tutor_utils()->get_current_url() ); ?>"}' data-delete_element_id="<?php echo esc_attr( $row_id ); ?>">
296 <?php esc_html_e( 'Yes, Delete This', 'tutor' ); ?>
297 </button>
298 </div>
299 </div>
300 </div>
301 </div>
302 </div>
303 </div>
304 <?php
305 endforeach;
306 wp_reset_postdata();
307 ?>
308 </div>
309 <div class="tutor-mt-20">
310 <?php
311 if ( $count_map[ $status ] > $per_page ) {
312 $pagination_data = array(
313 'total_items' => $count_map[ $status ],
314 'per_page' => $per_page,
315 'paged' => $paged,
316 );
317
318 tutor_load_template_from_custom_path(
319 tutor()->path . 'templates/dashboard/elements/pagination.php',
320 $pagination_data
321 );
322 }
323 ?>
324
325 </div>
326 <?php
327 }
328 ?>
329 </div>
330 </div>
331