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