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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
427 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
189 $membership_only_mode = apply_filters( 'tutor_membership_only_mode', false );
190 echo esc_html( $membership_only_mode ? __( 'Plan', 'tutor' ) : __( 'Price', 'tutor' ) );
191 ?>
192 </th>
193 <th class="tutor-table-rows-sorting" width="15%">
194 <?php esc_html_e( 'Date', 'tutor' ); ?>
195 <span class="a-to-z-sort-icon tutor-icon-ordering-a-z"></span>
196 </th>
197 <th></th>
198 </tr>
199 </thead>
200
201 <tbody>
202 <?php if ( $the_query->have_posts() ) : ?>
203 <?php
204 $course_ids = array_column( $the_query->posts, 'ID' );
205 $course_meta_data = tutor_utils()->get_course_meta_data( $course_ids );
206 $authors = array();
207
208 //phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
209 foreach ( $the_query->posts as $key => $post ) :
210 $count_lesson = isset( $course_meta_data[ $post->ID ] ) ? $course_meta_data[ $post->ID ]['lesson'] : 0;
211
212 $count_quiz = isset( $course_meta_data[ $post->ID ] ) ? $course_meta_data[ $post->ID ]['tutor_quiz'] : 0;
213 $count_assignment = isset( $course_meta_data[ $post->ID ] ) ? $course_meta_data[ $post->ID ]['tutor_assignments'] : 0;
214 $count_topic = isset( $course_meta_data[ $post->ID ] ) ? $course_meta_data[ $post->ID ]['topics'] : 0;
215 $thumbnail_id = (int) get_post_thumbnail_id( $post->ID );
216 $thumbnail = $thumbnail_id ? wp_get_attachment_image_url( $thumbnail_id, 'thumbnail', false ) : tutor()->url . 'assets/images/placeholder.svg';
217
218 /**
219 * Prevent re-query for same author details inside loop
220 */
221 if ( ! isset( $authors[ $post->post_author ] ) ) {
222 $authors[ $post->post_author ] = tutils()->get_tutor_user( $post->post_author );
223 }
224
225 $author_details = $authors[ $post->post_author ];
226 $edit_link = $add_course_url . "&course_id=$post->ID";
227 ?>
228 <tr>
229 <td>
230 <div class="td-checkbox tutor-d-flex ">
231 <input type="checkbox" class="tutor-form-check-input tutor-bulk-checkbox" name="tutor-bulk-checkbox-all" value="<?php echo esc_attr( $post->ID ); ?>" />
232 </div>
233 </td>
234
235 <td>
236 <div class="tutor-d-flex tutor-align-center tutor-gap-2">
237 <a href="<?php echo esc_url( $edit_link ); ?>" class="tutor-d-block">
238 <div style="width: 76px;">
239 <div class="tutor-ratio tutor-ratio-16x9">
240 <img class="tutor-radius-6" src="<?php echo esc_url( $thumbnail ); ?>" alt="<?php the_title(); ?>" loading="lazy">
241 </div>
242 </div>
243 </a>
244
245 <div>
246 <a class="tutor-table-link" href="<?php echo esc_url( $edit_link ); ?>">
247 <?php echo esc_html( $post->post_title ); ?>
248 </a>
249
250 <div class="tutor-meta tutor-mt-4">
251 <span>
252 <?php esc_html_e( 'Topic:', 'tutor' ); ?>
253 <span class="tutor-meta-value">
254 <?php echo esc_html( $count_topic ); ?>
255 </span>
256 </span>
257
258 <span>
259 <?php esc_html_e( 'Lesson:', 'tutor' ); ?>
260 <span class="tutor-meta-value">
261 <?php echo esc_html( $count_lesson ); ?>
262 </span>
263 </span>
264
265 <span>
266 <?php esc_html_e( 'Quiz:', 'tutor' ); ?>
267 <span class="tutor-meta-value">
268 <?php echo esc_html( $count_quiz ); ?>
269 </span>
270 </span>
271
272 <span>
273 <?php esc_html_e( 'Assignment:', 'tutor' ); ?>
274 <span class="tutor-meta-value">
275 <?php echo esc_html( $count_assignment ); ?>
276 </span>
277 </span>
278 </div>
279 </div>
280 </div>
281 </td>
282
283 <td>
284 <span class="tutor-fw-normal tutor-fs-7">
285 <?php
286 $terms = wp_get_post_terms( $post->ID, CourseModel::COURSE_CATEGORY );
287 if ( count( $terms ) ) {
288 echo esc_html( implode( ', ', array_column( $terms, 'name' ) ) . '&nbsp;' );
289 } else {
290 echo '...';
291 }
292 ?>
293 </span>
294 </td>
295
296 <td>
297 <div class="tutor-d-flex tutor-align-center">
298 <?php
299 echo wp_kses(
300 tutor_utils()->get_tutor_avatar( $author_details, 'sm' ),
301 tutor_utils()->allowed_avatar_tags()
302 )
303 ?>
304 <div class="tutor-ml-12">
305 <a target="_blank" class="tutor-fs-7 tutor-table-link" href="<?php echo esc_url( tutor_utils()->profile_url( $author_details, true ) ); ?>">
306 <?php echo esc_html( $author_details ? $author_details->display_name : '' ); ?>
307 </a>
308 </div>
309 </div>
310 </td>
311
312 <td>
313 <div class="tutor-fs-7">
314 <?php
315 $price = tutor_utils()->get_course_price( $post->ID );
316 if ( null == $price ) {
317 esc_html_e( 'Free', 'tutor' );
318 } else {
319 echo $price; //phpcs:ignore
320 }
321 // Alert class for course status.
322 //phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
323 $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' ) ) ) );
324 ?>
325 </div>
326 </td>
327
328 <td>
329 <div class="tutor-fw-normal">
330 <div class="tutor-fs-7 tutor-mb-4">
331 <?php echo esc_html( tutor_i18n_get_formated_date( $post->post_date, get_option( 'date_format' ) ) ); ?>
332 </div>
333 <div class="tutor-fs-8 tutor-color-muted">
334 <?php echo esc_html( tutor_i18n_get_formated_date( $post->post_date, get_option( 'time_format' ) ) ); ?>
335 </div>
336 </div>
337 </td>
338
339 <td>
340 <div class="tutor-d-flex tutor-align-center tutor-justify-end tutor-gap-2">
341 <div class="tutor-form-select-with-icon <?php echo esc_attr( $status ); ?>">
342 <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">
343 <?php
344 $status_list = $available_status;
345 if ( 'future' === $post->post_status ) {
346 $status_list = $future_list;
347 }
348
349 foreach ( $status_list as $key => $value ) :
350 ?>
351 <option data-status_class="<?php echo esc_attr( $value[1] ); ?>" value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $post->post_status, 'selected' ); ?>>
352 <?php echo esc_html( $value[0] ); ?>
353 </option>
354 <?php
355 endforeach;
356 ?>
357 </select>
358 <i class="icon1 tutor-icon-eye-bold"></i>
359 <i class="icon2 tutor-icon-angle-down"></i>
360 </div>
361 <a class="tutor-btn tutor-btn-outline-primary tutor-btn-sm" href="<?php echo esc_url( get_permalink( $post->ID ) ); ?>" target="_blank">
362 <?php esc_html_e( 'View', 'tutor' ); ?>
363 </a>
364 <div class="tutor-dropdown-parent">
365 <button type="button" class="tutor-iconic-btn" action-tutor-dropdown="toggle">
366 <span class="tutor-icon-kebab-menu" area-hidden="true"></span>
367 </button>
368 <div id="table-dashboard-course-list-<?php echo esc_attr( $post->ID ); ?>" class="tutor-dropdown tutor-dropdown-dark tutor-text-left">
369 <?php do_action( 'tutor_admin_befor_course_list_action', $post->ID ); ?>
370 <a class="tutor-dropdown-item" href="<?php echo esc_url( $edit_link ); ?>">
371 <i class="tutor-icon-edit tutor-mr-8" area-hidden="true"></i>
372 <span><?php esc_html_e( 'Edit', 'tutor' ); ?></span>
373 </a>
374 <?php do_action( 'tutor_admin_middle_course_list_action', $post->ID ); ?>
375 <?php if ( $show_course_delete ) : ?>
376 <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 ); ?>">
377 <i class="tutor-icon-trash-can-bold tutor-mr-8" area-hidden="true"></i>
378 <span><?php esc_html_e( 'Delete Permanently', 'tutor' ); ?></span>
379 </a>
380 <?php endif; ?>
381 <?php do_action( 'tutor_admin_after_course_list_action', $post->ID ); ?>
382 </div>
383 </div>
384 </div>
385 </td>
386 </tr>
387 <?php endforeach; ?>
388 <?php else : ?>
389 <tr>
390 <td colspan="100%" class="column-empty-state">
391 <?php tutor_utils()->tutor_empty_state( tutor_utils()->not_found_text() ); ?>
392 </td>
393 </tr>
394 <?php endif; ?>
395 </tbody>
396 </table>
397
398 <div class="tutor-admin-page-pagination-wrapper tutor-mt-32">
399 <?php
400 /**
401 * Prepare pagination data & load template
402 */
403 if ( $the_query->found_posts > $limit ) {
404 $pagination_data = array(
405 'total_items' => $the_query->found_posts,
406 'per_page' => $limit,
407 'paged' => $paged_filter,
408 );
409 $pagination_template = tutor()->path . 'views/elements/pagination.php';
410 tutor_load_template_from_custom_path( $pagination_template, $pagination_data );
411 }
412 ?>
413 </div>
414 </div>
415 <!-- end table responsive -->
416 </div>
417 </div>
418 </div>
419
420 <?php
421 tutor_load_template_from_custom_path(
422 tutor()->path . 'views/elements/common-confirm-popup.php',
423 array(
424 'message' => __( 'Deletion of the course will erase all its topics, lessons, quizzes, events, and other information. Please confirm your choice.', 'tutor' ),
425 )
426 );
427