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