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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
tools 3 years ago add_new_instructor.php 2 years ago addons.php 3 years ago announcements.php 3 years ago answer.php 3 years ago course-bundle.php 2 years ago course-list.php 2 years ago enable_disable_addons.php 3 years ago get-pro.php 2 years ago instructors.php 2 years ago question_answer.php 3 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 uninstall.php 3 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
406 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 $future_list = array(
137 'publish' => array( __( 'Publish', 'tutor' ), 'select-success' ),
138 'future' => array( __( 'Schedule', 'tutor' ), 'select-default' ),
139 );
140 ?>
141
142 <div class="tutor-admin-wrap">
143 <?php
144 /**
145 * Load Templates with data.
146 */
147 $navbar_template = tutor()->path . 'views/elements/navbar.php';
148 $filters_template = tutor()->path . 'views/elements/filters.php';
149 tutor_load_template_from_custom_path( $navbar_template, $navbar_data );
150 tutor_load_template_from_custom_path( $filters_template, $filters );
151 ?>
152 <div class="tutor-admin-body">
153 <div class="tutor-mt-24">
154 <div class="tutor-table-responsive">
155
156 <table class="tutor-table tutor-table-middle table-dashboard-course-list">
157 <thead class="tutor-text-sm tutor-text-400">
158 <tr>
159 <th>
160 <div class="tutor-d-flex">
161 <input type="checkbox" id="tutor-bulk-checkbox-all" class="tutor-form-check-input" />
162 </div>
163 </th>
164 <th class="tutor-table-rows-sorting" width="30%">
165 <?php esc_html_e( 'Title', 'tutor' ); ?>
166 <span class="a-to-z-sort-icon tutor-icon-ordering-a-z"></span>
167 </th>
168 <th width="13%">
169 <?php esc_html_e( 'Categories', 'tutor' ); ?>
170 </th>
171 <th width="13%">
172 <?php esc_html_e( 'Author', 'tutor' ); ?>
173 </th>
174 <th width="6%">
175 <?php esc_html_e( 'Price', 'tutor' ); ?>
176 </th>
177 <th class="tutor-table-rows-sorting" width="10%">
178 <?php esc_html_e( 'Date', 'tutor' ); ?>
179 <span class="a-to-z-sort-icon tutor-icon-ordering-a-z"></span>
180 </th>
181 <th></th>
182 </tr>
183 </thead>
184
185 <tbody>
186 <?php if ( $the_query->have_posts() ) : ?>
187 <?php
188 $course_ids = array_column( $the_query->posts, 'ID' );
189 $course_meta_data = tutor_utils()->get_course_meta_data( $course_ids );
190 $authors = array();
191
192 foreach ( $the_query->posts as $key => $post ) :
193 $count_lesson = isset( $course_meta_data[ $post->ID ] ) ? $course_meta_data[ $post->ID ]['lesson'] : 0;
194
195 $count_quiz = isset( $course_meta_data[ $post->ID ] ) ? $course_meta_data[ $post->ID ]['tutor_quiz'] : 0;
196 $count_assignment = isset( $course_meta_data[ $post->ID ] ) ? $course_meta_data[ $post->ID ]['tutor_assignments'] : 0;
197 $count_topic = isset( $course_meta_data[ $post->ID ] ) ? $course_meta_data[ $post->ID ]['topics'] : 0;
198 $thumbnail_id = (int) get_post_thumbnail_id( $post->ID );
199 $thumbnail = $thumbnail_id ? wp_get_attachment_image_url( $thumbnail_id, 'thumbnail', false ) : tutor()->url . 'assets/images/placeholder.svg';
200
201 /**
202 * Prevent re-query for same author details inside loop
203 */
204 if ( ! isset( $authors[ $post->post_author ] ) ) {
205 $authors[ $post->post_author ] = tutils()->get_tutor_user( $post->post_author );
206 }
207
208 $author_details = $authors[ $post->post_author ];
209 ?>
210 <tr>
211 <td>
212 <div class="td-checkbox tutor-d-flex ">
213 <input type="checkbox" class="tutor-form-check-input tutor-bulk-checkbox" name="tutor-bulk-checkbox-all" value="<?php echo esc_attr( $post->ID ); ?>" />
214 </div>
215 </td>
216
217 <td>
218 <div class="tutor-d-flex tutor-align-center tutor-gap-2">
219 <a href="<?php echo esc_url( admin_url( 'post.php?post=' . $post->ID . '&action=edit' ) ); ?>" class="tutor-d-block">
220 <div style="width: 76px;">
221 <div class="tutor-ratio tutor-ratio-16x9">
222 <img class="tutor-radius-6" src="<?php echo esc_url( $thumbnail ); ?>" alt="<?php the_title(); ?>" loading="lazy">
223 </div>
224 </div>
225 </a>
226
227 <div>
228 <a class="tutor-table-link" href="<?php echo esc_url( admin_url( 'post.php?post=' . $post->ID . '&action=edit' ) ); ?>">
229 <?php echo esc_html( $post->post_title ); ?>
230 </a>
231
232 <div class="tutor-meta tutor-mt-4">
233 <span>
234 <?php esc_html_e( 'Topic:', 'tutor' ); ?>
235 <span class="tutor-meta-value">
236 <?php echo esc_html( $count_topic ); ?>
237 </span>
238 </span>
239
240 <span>
241 <?php esc_html_e( 'Lesson:', 'tutor' ); ?>
242 <span class="tutor-meta-value">
243 <?php echo esc_html( $count_lesson ); ?>
244 </span>
245 </span>
246
247 <span>
248 <?php esc_html_e( 'Quiz:', 'tutor' ); ?>
249 <span class="tutor-meta-value">
250 <?php echo esc_html( $count_quiz ); ?>
251 </span>
252 </span>
253
254 <span>
255 <?php esc_html_e( 'Assignment:', 'tutor' ); ?>
256 <span class="tutor-meta-value">
257 <?php echo esc_html( $count_assignment ); ?>
258 </span>
259 </span>
260 </div>
261 </div>
262 </div>
263 </td>
264
265 <td>
266 <span class="tutor-fw-normal tutor-fs-7">
267 <?php
268 $terms = wp_get_post_terms( $post->ID, 'course-category' );
269 if ( count( $terms ) ) {
270 echo esc_html( implode( ', ', array_column( $terms, 'name' ) ) . '&nbsp;' );
271 } else {
272 echo '...';
273 }
274 ?>
275 </span>
276 </td>
277
278 <td>
279 <div class="tutor-d-flex tutor-align-center">
280 <?php
281 echo wp_kses(
282 tutor_utils()->get_tutor_avatar( $author_details, 'sm' ),
283 tutor_utils()->allowed_avatar_tags()
284 )
285 ?>
286 <div class="tutor-ml-12">
287 <a target="_blank" class="tutor-fs-7 tutor-table-link" href="<?php echo esc_url( tutor_utils()->profile_url( $author_details, true ) ); ?>">
288 <?php echo esc_html( $author_details ? $author_details->display_name : '' ); ?>
289 </a>
290 </div>
291 </div>
292 </td>
293
294 <td>
295 <div class="tutor-fs-7">
296 <?php
297 $price = tutor_utils()->get_course_price( $post->ID );
298 if ( null == $price ) {
299 esc_html_e( 'Free', 'tutor' );
300 } else {
301 echo $price; //phpcs:ignore
302 }
303 // Alert class for course status.
304 $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' ) ) ) );
305 ?>
306 </div>
307 </td>
308
309 <td>
310 <div class="tutor-fw-normal">
311 <div class="tutor-fs-7 tutor-mb-4">
312 <?php echo esc_html( tutor_get_formated_date( get_option( 'date_format' ), $post->post_date ) ); ?>
313 </div>
314 <div class="tutor-fs-8 tutor-color-muted">
315 <?php echo esc_html( tutor_get_formated_date( get_option( 'time_format' ), $post->post_date ) ); ?>
316 </div>
317 </div>
318 </td>
319
320 <td>
321 <div class="tutor-d-flex tutor-align-center tutor-justify-end tutor-gap-2">
322 <div class="tutor-form-select-with-icon <?php echo esc_attr( $status ); ?>">
323 <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">
324 <?php
325 $status_list = $available_status;
326 if ( 'future' === $post->post_status ) {
327 $status_list = $future_list;
328 }
329
330 foreach ( $status_list as $key => $value ) :
331 ?>
332 <option data-status_class="<?php echo esc_attr( $value[1] ); ?>" value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $post->post_status, 'selected' ); ?>>
333 <?php echo esc_html( $value[0] ); ?>
334 </option>
335 <?php
336 endforeach;
337 ?>
338 </select>
339 <i class="icon1 tutor-icon-eye-bold"></i>
340 <i class="icon2 tutor-icon-angle-down"></i>
341 </div>
342 <a class="tutor-btn tutor-btn-outline-primary tutor-btn-sm" href="<?php echo esc_url( get_permalink( $post->ID ) ); ?>" target="_blank">
343 <?php esc_html_e( 'View Course', 'tutor' ); ?>
344 </a>
345 <div class="tutor-dropdown-parent">
346 <button type="button" class="tutor-iconic-btn" action-tutor-dropdown="toggle">
347 <span class="tutor-icon-kebab-menu" area-hidden="true"></span>
348 </button>
349 <div id="table-dashboard-course-list-<?php echo esc_attr( $post->ID ); ?>" class="tutor-dropdown tutor-dropdown-dark tutor-text-left">
350 <?php do_action( 'tutor_admin_befor_course_list_action', $post->ID ); ?>
351 <a class="tutor-dropdown-item" href="<?php echo esc_url( admin_url( 'post.php?post=' . $post->ID . '&action=edit' ) ); ?>">
352 <i class="tutor-icon-edit tutor-mr-8" area-hidden="true"></i>
353 <span><?php esc_html_e( 'Edit', 'tutor' ); ?></span>
354 </a>
355 <?php do_action( 'tutor_admin_middle_course_list_action', $post->ID ); ?>
356 <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 ); ?>">
357 <i class="tutor-icon-trash-can-bold tutor-mr-8" area-hidden="true"></i>
358 <span><?php esc_html_e( 'Delete Permanently', 'tutor' ); ?></span>
359 </a>
360 <?php do_action( 'tutor_admin_after_course_list_action', $post->ID ); ?>
361 </div>
362 </div>
363 </div>
364 </td>
365 </tr>
366 <?php endforeach; ?>
367 <?php else : ?>
368 <tr>
369 <td colspan="100%" class="column-empty-state">
370 <?php tutor_utils()->tutor_empty_state( tutor_utils()->not_found_text() ); ?>
371 </td>
372 </tr>
373 <?php endif; ?>
374 </tbody>
375 </table>
376
377 <div class="tutor-admin-page-pagination-wrapper tutor-mt-32">
378 <?php
379 /**
380 * Prepare pagination data & load template
381 */
382 if ( $the_query->found_posts > $limit ) {
383 $pagination_data = array(
384 'total_items' => $the_query->found_posts,
385 'per_page' => $limit,
386 'paged' => $paged_filter,
387 );
388 $pagination_template = tutor()->path . 'views/elements/pagination.php';
389 tutor_load_template_from_custom_path( $pagination_template, $pagination_data );
390 }
391 ?>
392 </div>
393 </div>
394 <!-- end table responsive -->
395 </div>
396 </div>
397 </div>
398
399 <?php
400 tutor_load_template_from_custom_path(
401 tutor()->path . 'views/elements/common-confirm-popup.php',
402 array(
403 'message' => __( 'Deletion of the course will erase all its topics, lessons, quizzes, events, and other information. Please confirm your choice.', 'tutor' ),
404 )
405 );
406