tools
4 years ago
add_new_instructor.php
4 years ago
addons.php
4 years ago
announcements.php
4 years ago
answer.php
4 years ago
course-list.php
4 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
4 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
4 years ago
welcome.php
4 years ago
withdraw_requests.php
4 years ago
course-list.php
374 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=courses' ) ); |
| 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-wrapper"> |
| 149 | <table class="tutor-table tutor-table-responsive table-dashboard-course-list td-align-middle"> |
| 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"> |
| 158 | <div class="tutor-fs-7 tutor-color-secondary"> |
| 159 | <span class="tutor-fs-7"> |
| 160 | <?php esc_html_e( 'Date', 'tutor' ); ?> |
| 161 | </span> |
| 162 | <span class="a-to-z-sort-icon tutor-icon-ordering-a-z "></span> |
| 163 | </div> |
| 164 | </th> |
| 165 | <th class="tutor-table-rows-sorting"> |
| 166 | <div class="tutor-fs-7 tutor-color-secondary"> |
| 167 | <span class="tutor-fs-7"> |
| 168 | <?php esc_html_e( 'Title', 'tutor' ); ?> |
| 169 | </span> |
| 170 | <span class="a-to-z-sort-icon tutor-icon-ordering-a-z "></span> |
| 171 | </div> |
| 172 | </th> |
| 173 | <th class="tutor-table-rows-sorting"> |
| 174 | <div class="tutor-color-secondary"> |
| 175 | <span class="tutor-fs-7"> |
| 176 | <?php esc_html_e( 'Author', 'tutor' ); ?> |
| 177 | </span> |
| 178 | <span class="a-to-z-sort-icon tutor-icon-ordering-a-z "></span> |
| 179 | </div> |
| 180 | </th> |
| 181 | <th> |
| 182 | <div class="tutor-fs-7 tutor-color-secondary"> |
| 183 | <?php esc_html_e( 'Course Categories', 'tutor' ); ?> |
| 184 | </div> |
| 185 | </th> |
| 186 | <th> |
| 187 | <div class="tutor-fs-7 tutor-color-secondary"> |
| 188 | <?php esc_html_e( 'Students', 'tutor' ); ?> |
| 189 | </div> |
| 190 | </th> |
| 191 | <th> |
| 192 | <div class="tutor-fs-7 tutor-color-secondary"> |
| 193 | <?php esc_html_e( 'Price', 'tutor' ); ?> |
| 194 | </div> |
| 195 | </th> |
| 196 | <th class="tutor-shrink"></th> |
| 197 | </tr> |
| 198 | </thead> |
| 199 | <tbody class="tutor-text-500"> |
| 200 | <?php if ( $the_query->have_posts() ) : ?> |
| 201 | <?php |
| 202 | $course_ids = array_column($the_query->posts, 'ID'); |
| 203 | $course_meta_data = tutor_utils()->get_course_meta_data($course_ids); |
| 204 | $authors = array(); |
| 205 | |
| 206 | foreach ( $the_query->posts as $key => $post ) : |
| 207 | $count_lesson = isset($course_meta_data[$post->ID]) ? $course_meta_data[$post->ID]['lesson'] : 0;; |
| 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 | $total_student = isset($course_meta_data[$post->ID]) ? $course_meta_data[$post->ID]['tutor_enrolled'] : 0; |
| 212 | |
| 213 | !isset($authors[$post->post_author]) ? $authors[$post->post_author]=get_userdata( $post->post_author ) : 0; |
| 214 | $author_details = $authors[$post->post_author]; |
| 215 | ?> |
| 216 | <tr> |
| 217 | <td data-th="<?php esc_html_e( 'Checkbox', 'tutor' ); ?>"> |
| 218 | <div class="td-checkbox tutor-d-flex "> |
| 219 | <input type="checkbox" class="tutor-form-check-input tutor-bulk-checkbox" name="tutor-bulk-checkbox-all" value="<?php echo esc_attr( $post->ID ); ?>" /> |
| 220 | </div> |
| 221 | </td> |
| 222 | <td data-th="<?php esc_html_e( 'Date', 'tutor' ); ?>"> |
| 223 | <div class="td-datetime"> |
| 224 | <div class="tutor-fs-7 tutor-color-black tutor-fw-medium tutor-d-block tutor-mb-8"> |
| 225 | <?php echo esc_html( tutor_get_formated_date( get_option( 'date_format' ), $post->post_date ) ); ?> |
| 226 | </div> |
| 227 | <div class="tutor-fs-8 tutor-color-muted tutor-fw-medium tutor-d-block"> |
| 228 | <?php echo esc_html( tutor_get_formated_date( get_option( 'time_format' ), $post->post_date ) ); ?> |
| 229 | </div> |
| 230 | </div> |
| 231 | </td> |
| 232 | |
| 233 | <td data-th="<?php esc_html_e( 'Course Name', 'tutor' ); ?>" class="column-fullwidth"> |
| 234 | <div class="td-course tutor-color-black tutor-fs-6 tutor-fw-medium tutor-line-clamp-2"> |
| 235 | <a href="<?php echo esc_url( admin_url( 'post.php?post=' . $post->ID . '&action=edit' ) ); ?>"> |
| 236 | <?php echo esc_html( $post->post_title ); ?> |
| 237 | </a> |
| 238 | <div class="course-meta"> |
| 239 | <span class="tutor-color-muted tutor-fs-7 tutor-fw-medium"> |
| 240 | <?php esc_html_e( 'Topic:', 'tutor' ); ?> |
| 241 | <strong class="tutor-color-black"> |
| 242 | <?php echo esc_html( $count_topic ); ?> |
| 243 | </strong> |
| 244 | </span> |
| 245 | <span class="tutor-color-muted tutor-fs-7 tutor-fw-medium"> |
| 246 | <?php esc_html_e( 'Lesson:', 'tutor' ); ?> |
| 247 | <strong class="tutor-color-black"> |
| 248 | <?php echo esc_html( $count_lesson ); ?> |
| 249 | </strong> |
| 250 | </span> |
| 251 | <span class="tutor-color-muted tutor-fs-7 tutor-fw-medium"> |
| 252 | <?php esc_html_e( 'Quiz:', 'tutor' ); ?> |
| 253 | <strong class="tutor-color-black"> |
| 254 | <?php echo esc_html( $count_quiz ); ?> |
| 255 | </strong> |
| 256 | </span> |
| 257 | <span class="tutor-color-muted tutor-fs-7 tutor-fw-medium"> |
| 258 | <?php esc_html_e( 'Assignment:', 'tutor' ); ?> |
| 259 | <strong class="tutor-color-black"> |
| 260 | <?php echo esc_html( $count_assignment ); ?> |
| 261 | </strong> |
| 262 | </span> |
| 263 | </div> |
| 264 | </div> |
| 265 | </td> |
| 266 | <td data-th="<?php esc_html_e( 'Author', 'tutor' ); ?>"> |
| 267 | <div class="td-avatar"> |
| 268 | <?php echo tutor_utils()->get_tutor_avatar( $author_details->ID ); ?> |
| 269 | |
| 270 | <div class="tutor-fs-6 tutor-fw-medium tutor-color-black"> |
| 271 | <?php echo esc_html( $author_details ? $author_details->display_name : '' ); ?> |
| 272 | </div> |
| 273 | <a |
| 274 | href="<?php echo esc_url( tutor_utils()->profile_url( $post->post_author, true ) ); ?>" |
| 275 | class="tutor-iconic-btn" target="_blank" |
| 276 | > |
| 277 | <span class="tutor-icon-external-link"></span> |
| 278 | </a> |
| 279 | </div> |
| 280 | </td> |
| 281 | <td data-th="<?php esc_html_e( 'Course Category', 'tutor' ); ?>"> |
| 282 | <?php |
| 283 | $terms = wp_get_post_terms( $post->ID, 'course-category' ); |
| 284 | echo implode(', ', array_column($terms, 'name')) . ' '; |
| 285 | ?> |
| 286 | </td> |
| 287 | <td data-th="<?php esc_html_e( 'Student', 'tutor' ); ?>"> |
| 288 | <div class="tutor-fs-7 tutor-color-black"> |
| 289 | <?php echo esc_html( $total_student ); ?> |
| 290 | </div> |
| 291 | </td> |
| 292 | <td data-th="<?php esc_html_e( 'Price', 'tutor' ); ?>"> |
| 293 | <div class="tutor-fs-7 tutor-color-black"> |
| 294 | <?php |
| 295 | $price = tutor_utils()->get_course_price( $post->ID ); |
| 296 | if ( null == $price ) { |
| 297 | esc_html_e( 'Free', 'tutor' ); |
| 298 | } else { |
| 299 | echo $price; |
| 300 | } |
| 301 | // Alert class for course status. |
| 302 | $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' ) ) ) ); |
| 303 | ?> |
| 304 | </div> |
| 305 | </td> |
| 306 | <td data-th="<?php esc_html_e( 'Action', 'tutor' ); ?>"> |
| 307 | <div class="tutor-d-inline-flex tutor-align-center td-action-btns"> |
| 308 | <div class="tutor-form-select-with-icon <?php echo esc_attr( $status ); ?>"> |
| 309 | <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"> |
| 310 | <?php foreach ( $available_status as $key => $value ) : ?> |
| 311 | <option data-status_class="<?php echo esc_attr( $value[1] ); ?>" value="<?php echo $key; ?>" <?php selected( $key, $post->post_status, 'selected' ); ?>> |
| 312 | <?php echo esc_html( $value[0] ); ?> |
| 313 | </option> |
| 314 | <?php endforeach; ?> |
| 315 | </select> |
| 316 | <i class="icon1 tutor-icon-eye-bold"></i> |
| 317 | <i class="icon2 tutor-icon-angle-down"></i> |
| 318 | </div> |
| 319 | <a href="<?php echo esc_url( admin_url( 'post.php?post=' . $post->ID . '&action=edit' ) ); ?>" class="tutor-btn tutor-btn-outline-primary tutor-btn-sm"> |
| 320 | <?php esc_html_e( 'Edit', 'tutor' ); ?> |
| 321 | </a> |
| 322 | <div class="tutor-dropdown-parent"> |
| 323 | <button type="button" class="tutor-iconic-btn" action-tutor-dropdown="toggle"> |
| 324 | <span class="tutor-icon-kebab-menu" area-hidden="true"></span> |
| 325 | </button> |
| 326 | <div id="table-dashboard-course-list-<?php echo esc_attr( $post->ID ); ?>" class="tutor-dropdown tutor-dropdown-dark tutor-text-left"> |
| 327 | <?php do_action( 'tutor_admin_befor_course_list_action', $post->ID ); ?> |
| 328 | <a class="tutor-dropdown-item" href="<?php echo esc_url( get_permalink( $post->ID ) ); ?>" target="_blank"> |
| 329 | <i class="tutor-icon-eye-bold tutor-mr-8" area-hidden="true"></i> |
| 330 | <span><?php esc_html_e( 'View Course', 'tutor' ); ?></span> |
| 331 | </a> |
| 332 | <?php do_action( 'tutor_admin_middle_course_list_action', $post->ID ); ?> |
| 333 | <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 ); ?>"> |
| 334 | <i class="tutor-icon-trash-can-bold tutor-mr-8" area-hidden="true"></i> |
| 335 | <span><?php esc_html_e( 'Delete Permanently', 'tutor' ); ?></span> |
| 336 | </a> |
| 337 | <?php do_action( 'tutor_admin_after_course_list_action', $post->ID ); ?> |
| 338 | </div> |
| 339 | </div> |
| 340 | </div> |
| 341 | </td> |
| 342 | </tr> |
| 343 | <?php endforeach; ?> |
| 344 | <?php else : ?> |
| 345 | <tr> |
| 346 | <td colspan="100%" class="column-empty-state"> |
| 347 | <?php tutor_utils()->tutor_empty_state( tutor_utils()->not_found_text() ); ?> |
| 348 | </td> |
| 349 | </tr> |
| 350 | <?php endif; ?> |
| 351 | </tbody> |
| 352 | </table> |
| 353 | </div> |
| 354 | </div> |
| 355 | <div class="tutor-admin-page-pagination-wrapper tutor-mt-32"> |
| 356 | <?php |
| 357 | /** |
| 358 | * Prepare pagination data & load template |
| 359 | */ |
| 360 | if($the_query->found_posts > $limit) { |
| 361 | $pagination_data = array( |
| 362 | 'total_items' => $the_query->found_posts, |
| 363 | 'per_page' => $limit, |
| 364 | 'paged' => $paged_filter, |
| 365 | ); |
| 366 | $pagination_template = tutor()->path . 'views/elements/pagination.php'; |
| 367 | tutor_load_template_from_custom_path( $pagination_template, $pagination_data ); |
| 368 | } |
| 369 | ?> |
| 370 | </div> |
| 371 | </div> |
| 372 | </div> |
| 373 | |
| 374 | <?php tutor_load_template_from_custom_path( tutor()->path . 'views/elements/common-confirm-popup.php' ); |