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