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