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