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