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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 / pages / course-list.php
tutor / views / pages Last commit date
ecommerce 1 year ago tools 1 year ago add_new_instructor.php 2 years ago addons.php 1 year ago announcements.php 2 years ago answer.php 3 years ago course-builder.php 1 year ago course-list.php 1 year ago enable_disable_addons.php 1 year ago feature-promotion.php 2 years ago get-pro.php 2 years ago instructors.php 1 year ago question_answer.php 2 years ago quiz_attempts.php 3 years ago students.php 3 years ago tools.php 3 years ago view_attempt.php 3 years ago welcome.php 1 year ago whats-new.php 1 year ago withdraw_requests.php 2 years ago
course-list.php
484 lines
1 <?php
2 /**
3 * Course List Template.
4 *
5 * @package Tutor\Views
6 * @author Themeum <support@themeum.com>
7 * @link https://themeum.com
8 * @since 2.0.0
9 */
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 use TUTOR\Course_List;
16 use TUTOR\Input;
17 use Tutor\Models\CourseModel;
18
19 $courses = \TUTOR\Tutor::instance()->course_list;
20
21 /**
22 * Short able params
23 */
24 $course_id = Input::get( 'course-id', '' );
25 $order_filter = Input::get( 'order', 'DESC' );
26 $date = Input::get( 'date', '' );
27 $search_filter = Input::get( 'search', '' );
28 $category_slug = Input::get( 'category', '' );
29
30 /**
31 * Determine active tab
32 */
33 $active_tab = Input::get( 'data', 'all' );
34
35 /**
36 * Pagination data
37 */
38 $paged_filter = Input::get( 'paged', 1, Input::TYPE_INT );
39 $limit = tutor_utils()->get_option( 'pagination_per_page' );
40 $offset = ( $limit * $paged_filter ) - $limit;
41
42 /**
43 * Navbar data to make nav menu
44 */
45 $add_course_url = esc_url( admin_url( 'admin.php?page=create-course' ) );
46 $navbar_data = array(
47 'page_title' => $courses->page_title,
48 'add_button' => true,
49 'button_title' => __( 'New Course', 'tutor' ),
50 'button_url' => '#',
51 'button_class' => 'tutor-create-new-course',
52 );
53
54 $status_options = $courses->tabs_key_value( $category_slug, $course_id, $date, $search_filter );
55
56 $categories = get_terms(
57 array(
58 'taxonomy' => CourseModel::COURSE_CATEGORY,
59 'orderby' => 'term_id',
60 'order' => 'DESC',
61 )
62 );
63 $category_options = array(
64 array(
65 'key' => '',
66 'title' => __( 'All Categories', 'tutor' ),
67 ),
68 );
69 if ( ! is_wp_error( $categories ) && ! empty( $categories ) ) {
70 foreach ( $categories as $category ) {
71 $category_options[] = array(
72 'key' => $category->slug,
73 'title' => $category->name,
74 );
75 }
76 }
77
78 /**
79 * Bulk action & filters
80 */
81 $filters = array(
82 'bulk_action' => $courses->bulk_action,
83 'bulk_actions' => $courses->prepare_bulk_actions(),
84 'ajax_action' => 'tutor_course_list_bulk_action',
85 'filters' => apply_filters(
86 'tutor_course_list_before_filter_items',
87 array(
88 array(
89 'label' => __( 'Status', 'tutor' ),
90 'field_type' => 'select',
91 'field_name' => 'data',
92 'options' => $status_options,
93 'value' => Input::get( 'data', '' ),
94 ),
95 array(
96 'label' => __( 'Category', 'tutor' ),
97 'field_type' => 'select',
98 'field_name' => 'category',
99 'options' => $category_options,
100 'searchable' => true,
101 'value' => Input::get( 'category', '' ),
102 ),
103 array(
104 'label' => __( 'Publish Date', 'tutor' ),
105 'field_type' => 'date',
106 'field_name' => 'date',
107 'show_label' => true,
108 'value' => Input::get( 'date', '' ),
109 ),
110 ),
111 ),
112 );
113
114 $args = array(
115 'post_type' => tutor()->course_post_type,
116 'orderby' => 'ID',
117 'order' => $order_filter,
118 'paged' => $paged_filter,
119 'offset' => $offset,
120 'posts_per_page' => tutor_utils()->get_option( 'pagination_per_page' ),
121 );
122
123 if ( 'all' === $active_tab || 'mine' === $active_tab ) {
124 $args['post_status'] = array( 'publish', 'pending', 'draft', 'private', 'future' );
125 } else {
126 //phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
127 $status = 'published' === $active_tab ? 'publish' : $active_tab;
128 $args['post_status'] = array( $status );
129 }
130
131 $date_filter = sanitize_text_field( tutor_utils()->array_get( 'date', $_GET, '' ) );
132
133 //phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
134 $year = gmdate( 'Y', strtotime( $date_filter ) );
135 $month = gmdate( 'm', strtotime( $date_filter ) );
136 $day = gmdate( 'd', strtotime( $date_filter ) );
137 // Add date query.
138 if ( '' !== $date_filter ) {
139 $args['date_query'] = array(
140 array(
141 'year' => $year,
142 'month' => $month,
143 'day' => $day,
144 ),
145 );
146 }
147
148 if ( '' !== $course_id ) {
149 $args['p'] = $course_id;
150 }
151 // Add author param.
152 if ( 'mine' === $active_tab || ! current_user_can( 'administrator' ) ) {
153 $args['author'] = get_current_user_id();
154 }
155 // Search filter.
156 if ( '' !== $search_filter ) {
157 $args['s'] = $search_filter;
158 }
159 // Category filter.
160 if ( '' !== $category_slug ) {
161 $args['tax_query'] = array(
162 array(
163 'taxonomy' => CourseModel::COURSE_CATEGORY,
164 'field' => 'slug',
165 'terms' => $category_slug,
166 ),
167 );
168 }
169
170 add_filter( 'posts_search', '_tutor_search_by_title_only', 500, 2 );
171
172 $the_query = Course_List::course_list_query( $args, get_current_user_id(), $active_tab );
173
174 remove_filter( 'posts_search', '_tutor_search_by_title_only', 500 );
175
176 $available_status = array(
177 'publish' => array( __( 'Publish', 'tutor' ), 'select-success' ),
178 'pending' => array( __( 'Pending', 'tutor' ), 'select-warning' ),
179 'trash' => array( __( 'Trash', 'tutor' ), 'select-danger' ),
180 'draft' => array( __( 'Draft', 'tutor' ), 'select-default' ),
181 'private' => array( __( 'Private', 'tutor' ), 'select-default' ),
182 );
183
184 if ( ! tutor_utils()->get_option( 'instructor_can_delete_course' ) && ! current_user_can( 'administrator' ) ) {
185 unset( $available_status['trash'] );
186 }
187
188 $future_list = array(
189 'publish' => array( __( 'Publish', 'tutor' ), 'select-success' ),
190 'future' => array( __( 'Schedule', 'tutor' ), 'select-default' ),
191 );
192
193 $show_course_delete = false;
194 if ( 'trash' === $active_tab && current_user_can( 'administrator' ) ) {
195 $show_course_delete = true;
196 }
197
198 $total_course_count = $the_query->found_posts;
199 if ( 0 === $total_course_count ) {
200 $total_list_args = array(
201 'post_type' => tutor()->course_post_type,
202 'post_status' => array( 'publish', 'pending', 'draft', 'private', 'future', 'trash' ),
203 'author' => current_user_can( 'administrator' ) ? null : get_current_user_id(),
204 );
205 $total_list_query = Course_List::course_list_query( $total_list_args, get_current_user_id(), 'any' );
206 $total_course_count = $total_list_query->found_posts;
207
208 if ( 0 === $total_course_count ) {
209 $navbar_data['hide_action_buttons'] = true;
210 }
211 }
212 ?>
213
214 <div class="tutor-admin-wrap">
215 <?php
216 $navbar_template = tutor()->path . 'views/elements/course-navbar.php';
217 tutor_load_template_from_custom_path( $navbar_template, $navbar_data );
218
219 if ( $total_course_count > 0 ) {
220 $filters_template = tutor()->path . 'views/elements/course-filters.php';
221 tutor_load_template_from_custom_path( $filters_template, $filters );
222 }
223 ?>
224 <div class="tutor-admin-container tutor-admin-container-lg">
225 <div class="tutor-dashboard-course-list tutor-mt-16">
226 <?php if ( $the_query->have_posts() ) : ?>
227 <div class="tutor-table-responsive">
228 <table class="tutor-table tutor-table-middle table-dashboard-course-list">
229 <thead class="tutor-text-sm tutor-text-400">
230 <tr>
231 <th>
232 <div class="tutor-d-flex">
233 <input type="checkbox" id="tutor-bulk-checkbox-all" class="tutor-form-check-input" />
234 </div>
235 </th>
236 <th class="tutor-table-rows-sorting" width="30%">
237 <?php esc_html_e( 'Title', 'tutor' ); ?>
238 <span class="a-to-z-sort-icon tutor-icon-ordering-a-z"></span>
239 </th>
240 <th width="13%">
241 <?php esc_html_e( 'Categories', 'tutor' ); ?>
242 </th>
243 <th width="10%">
244 <?php
245 $membership_only_mode = apply_filters( 'tutor_membership_only_mode', false );
246 echo esc_html( $membership_only_mode ? __( 'Plan', 'tutor' ) : __( 'Price', 'tutor' ) );
247 ?>
248 </th>
249 <th width="13%">
250 <?php esc_html_e( 'Author', 'tutor' ); ?>
251 </th>
252 <th class="tutor-table-rows-sorting" width="15%">
253 <?php esc_html_e( 'Date', 'tutor' ); ?>
254 <span class="a-to-z-sort-icon tutor-icon-ordering-a-z"></span>
255 </th>
256 <th></th>
257 </tr>
258 </thead>
259
260 <tbody>
261 <?php
262 $course_ids = array_column( $the_query->posts, 'ID' );
263 $course_meta_data = tutor_utils()->get_course_meta_data( $course_ids );
264 $authors = array();
265
266 //phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
267 foreach ( $the_query->posts as $key => $post ) :
268 $count_lesson = isset( $course_meta_data[ $post->ID ] ) ? $course_meta_data[ $post->ID ]['lesson'] : 0;
269
270 $count_quiz = isset( $course_meta_data[ $post->ID ] ) ? $course_meta_data[ $post->ID ]['tutor_quiz'] : 0;
271 $count_assignment = isset( $course_meta_data[ $post->ID ] ) ? $course_meta_data[ $post->ID ]['tutor_assignments'] : 0;
272 $count_topic = isset( $course_meta_data[ $post->ID ] ) ? $course_meta_data[ $post->ID ]['topics'] : 0;
273 $thumbnail = get_tutor_course_thumbnail_src( 'post-thumbnail', $post->ID );
274
275 /**
276 * Prevent re-query for same author details inside loop
277 */
278 if ( ! isset( $authors[ $post->post_author ] ) ) {
279 $authors[ $post->post_author ] = tutils()->get_tutor_user( $post->post_author );
280 }
281
282 $author_details = $authors[ $post->post_author ];
283 $edit_link = apply_filters( 'tutor_course_list_course_edit_link', $add_course_url . "&course_id=$post->ID", $post );
284 ?>
285 <tr>
286 <td>
287 <div class="td-checkbox tutor-d-flex ">
288 <input type="checkbox" class="tutor-form-check-input tutor-bulk-checkbox" name="tutor-bulk-checkbox-all" value="<?php echo esc_attr( $post->ID ); ?>" />
289 </div>
290 </td>
291
292 <td>
293 <div class="tutor-d-flex tutor-align-center tutor-gap-12px">
294 <a href="<?php echo esc_url( $edit_link ); ?>" class="tutor-d-block">
295 <div style="width: 76px;">
296 <div class="tutor-ratio tutor-ratio-3x2">
297 <img class="tutor-radius-3 <?php echo esc_attr( 'course-bundle' === $post->post_type ? 'tutor-bundle-list-thumb' : '' ); ?>" src="<?php echo esc_url( $thumbnail ); ?>" alt="<?php the_title(); ?>" loading="lazy">
298 </div>
299 </div>
300 </a>
301
302 <div>
303 <a class="tutor-table-link" href="<?php echo esc_url( $edit_link ); ?>">
304 <?php echo esc_html( $post->post_title ); ?>
305 </a>
306
307 <?php ob_start(); ?>
308 <div class="tutor-meta tutor-gap-1 tutor-mt-4">
309 <div class="tutor-d-flex tutor-align-center tutor-gap-4px">
310 <i class="tutor-icon-topic"></i>
311 <?php esc_html_e( 'Topic:', 'tutor' ); ?>
312 <span class="tutor-meta-value"><?php echo esc_html( $count_topic ); ?></span>
313 </div>
314
315 <div class="tutor-d-flex tutor-align-center tutor-gap-4px">
316 <i class="tutor-icon-note"></i>
317 <?php esc_html_e( 'Lesson:', 'tutor' ); ?>
318 <span class="tutor-meta-value"><?php echo esc_html( $count_lesson ); ?></span>
319 </div>
320
321 <div class="tutor-d-flex tutor-align-center tutor-gap-4px">
322 <i class="tutor-icon-quiz-2"></i>
323 <?php esc_html_e( 'Quiz:', 'tutor' ); ?>
324 <span class="tutor-meta-value"><?php echo esc_html( $count_quiz ); ?></span>
325 </div>
326
327 <div class="tutor-d-flex tutor-align-center tutor-gap-4px">
328 <i class="tutor-icon-report-time"></i>
329 <?php esc_html_e( 'Assignment:', 'tutor' ); ?>
330 <span class="tutor-meta-value"><?php echo esc_html( $count_assignment ); ?></span>
331 </div>
332 </div>
333 <?php echo wp_kses_post( apply_filters( 'tutor_course_list_meta', ob_get_clean(), $post ) ); ?>
334 </div>
335 </div>
336 </td>
337
338 <td>
339 <?php
340 $terms = wp_get_post_terms( $post->ID, CourseModel::COURSE_CATEGORY );
341 $category_text = '';
342 if ( count( $terms ) ) {
343 $category_text = implode( ', ', array_column( $terms, 'name' ) ) . '&nbsp;';
344 } else {
345 $category_text = '...';
346 }
347 ?>
348 <div title="<?php echo esc_attr( $category_text ); ?>" class="tutor-fw-medium tutor-fs-7 tutor-color-hints tutor-text-ellipsis-2-lines">
349 <?php echo esc_html( $category_text ); ?>
350 </div>
351 </td>
352 <td>
353 <div class="tutor-fw-medium tutor-fs-7 tutor-color-hints">
354 <?php
355 $price = tutor_utils()->get_course_price( $post->ID );
356 if ( is_null( $price ) ) {
357 esc_html_e( 'Free', 'tutor' );
358 } else {
359 echo $price; //phpcs:ignore
360 }
361 // Alert class for course status.
362 //phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
363 $status = ( 'publish' === $post->post_status ? 'select-success' : ( 'pending' === $post->post_status ? 'select-warning' : ( 'trash' === $post->post_status ? 'select-danger' : ( 'private' === $post->post_status ? 'select-default' : 'select-default' ) ) ) );
364 ?>
365 </div>
366 </td>
367 <td>
368 <div class="tutor-d-flex tutor-align-center">
369 <?php
370 echo wp_kses(
371 tutor_utils()->get_tutor_avatar( $author_details, 'sm' ),
372 tutor_utils()->allowed_avatar_tags()
373 )
374 ?>
375 <div class="tutor-ml-8">
376 <a target="_blank" class="tutor-fs-7 tutor-table-link" href="<?php echo esc_url( tutor_utils()->profile_url( $author_details, true ) ); ?>">
377 <?php echo esc_html( $author_details ? $author_details->display_name : '' ); ?>
378 </a>
379 </div>
380 </div>
381 </td>
382 <td>
383 <div class="tutor-fw-normal">
384 <div class="tutor-fs-7 tutor-mb-4 tutor-color-black tutor-text-nowrap">
385 <?php echo esc_html( tutor_i18n_get_formated_date( $post->post_date, get_option( 'date_format' ) ) ); ?>
386 </div>
387 <div class="tutor-fs-7 tutor-color-subdued">
388 <?php echo esc_html( tutor_i18n_get_formated_date( $post->post_date, get_option( 'time_format' ) ) ); ?>
389 </div>
390 </div>
391 </td>
392
393 <td>
394 <div class="tutor-d-flex tutor-align-center tutor-justify-end tutor-gap-1">
395 <div class="tutor-form-select-with-icon <?php echo esc_attr( $status ); ?>">
396 <select title="<?php esc_attr_e( 'Update course status', 'tutor' ); ?>" class="tutor-table-row-status-update" data-id="<?php echo esc_attr( $post->ID ); ?>" data-status="<?php echo esc_attr( $post->post_status ); ?>" data-status_key="status" data-action="tutor_change_course_status">
397 <?php
398 $status_list = $available_status;
399 if ( 'future' === $post->post_status ) {
400 $status_list = $future_list;
401 }
402
403 foreach ( $status_list as $key => $value ) :
404 ?>
405 <option data-status_class="<?php echo esc_attr( $value[1] ); ?>" value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $post->post_status, 'selected' ); ?>>
406 <?php echo esc_html( $value[0] ); ?>
407 </option>
408 <?php
409 endforeach;
410 ?>
411 </select>
412 <i class="icon1 tutor-icon-eye-bold"></i>
413 <i class="icon2 tutor-icon-angle-down"></i>
414 </div>
415 <a class="tutor-btn tutor-btn-tertiary tutor-btn-sm tutor-ml-4" href="<?php echo esc_url( get_permalink( $post->ID ) ); ?>" target="_blank">
416 <?php esc_html_e( 'View', 'tutor' ); ?>
417 </a>
418 <div class="tutor-dropdown-parent">
419 <button type="button" class="tutor-iconic-btn" action-tutor-dropdown="toggle">
420 <span class="tutor-icon-kebab-menu" area-hidden="true"></span>
421 </button>
422 <div id="table-dashboard-course-list-<?php echo esc_attr( $post->ID ); ?>" class="tutor-dropdown tutor-dropdown-dark tutor-text-left">
423 <?php do_action( 'tutor_admin_befor_course_list_action', $post->ID ); ?>
424 <a class="tutor-dropdown-item" href="<?php echo esc_url( $edit_link ); ?>">
425 <i class="tutor-icon-edit tutor-mr-8" area-hidden="true"></i>
426 <span><?php esc_html_e( 'Edit', 'tutor' ); ?></span>
427 </a>
428 <?php do_action( 'tutor_admin_middle_course_list_action', $post->ID ); ?>
429 <?php if ( $show_course_delete ) : ?>
430 <a href="javascript:void(0)" class="tutor-dropdown-item tutor-admin-course-delete" data-tutor-modal-target="tutor-common-confirmation-modal" data-id="<?php echo esc_attr( $post->ID ); ?>">
431 <i class="tutor-icon-trash-can-bold tutor-mr-8" area-hidden="true"></i>
432 <span><?php esc_html_e( 'Delete Permanently', 'tutor' ); ?></span>
433 </a>
434 <?php endif; ?>
435 <?php do_action( 'tutor_admin_after_course_list_action', $post->ID ); ?>
436 </div>
437 </div>
438 </div>
439 </td>
440 </tr>
441 <?php endforeach; ?>
442 </tbody>
443 </table>
444
445 <div class="tutor-admin-page-pagination-wrapper tutor-mt-32">
446 <?php
447 /**
448 * Prepare pagination data & load template
449 */
450 if ( $the_query->found_posts > $limit ) {
451 $pagination_data = array(
452 'total_items' => $the_query->found_posts,
453 'per_page' => $limit,
454 'paged' => $paged_filter,
455 );
456 $pagination_template = tutor()->path . 'views/elements/pagination.php';
457 tutor_load_template_from_custom_path( $pagination_template, $pagination_data );
458 }
459 ?>
460 </div>
461 </div>
462 <?php else : ?>
463 <?php
464 $empty_state_template = tutor()->path . 'views/elements/course-empty-state.php';
465 tutor_load_template_from_custom_path(
466 $empty_state_template,
467 array(
468 'show_empty_state_create' => 0 === $total_course_count,
469 )
470 );
471 ?>
472 <?php endif; ?>
473 </div>
474 </div>
475 </div>
476
477 <?php
478 tutor_load_template_from_custom_path(
479 tutor()->path . 'views/elements/common-confirm-popup.php',
480 array(
481 'message' => __( 'Deletion of the course will erase all its topics, lessons, quizzes, events, and other information. Please confirm your choice.', 'tutor' ),
482 )
483 );
484