course-filter
1 year ago
dashboard
8 months ago
ecommerce
7 months ago
email
9 months ago
global
3 years ago
instructor
3 years ago
loop
9 months ago
modal
3 years ago
profile
3 years ago
shortcode
1 year ago
single
5 months ago
template-part
1 year ago
widget
3 years ago
archive-course-init.php
9 months ago
archive-course.php
3 years ago
course-embed.php
1 year ago
course-none.php
3 years ago
dashboard.php
1 year ago
feature_disabled.php
3 years ago
login-form.php
1 year ago
login.php
3 years ago
metabox-wrapper.php
3 years ago
permission-denied.php
3 years ago
public-profile.php
8 months ago
single-assignment.php
3 years ago
single-content-loader.php
2 years ago
single-course.php
9 months ago
single-lesson.php
3 years ago
single-preview-lesson.php
3 years ago
single-quiz.php
1 year ago
template.php
3 years ago
archive-course-init.php
183 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Template for course archive init |
| 4 | * |
| 5 | * @package Tutor\Templates |
| 6 | * @subpackage CourseArchive |
| 7 | * @author Themeum <support@themeum.com> |
| 8 | * @link https://themeum.com |
| 9 | * @since 1.0.0 |
| 10 | */ |
| 11 | |
| 12 | use TUTOR\Input; |
| 13 | |
| 14 | ! isset( $course_filter ) ? $course_filter = false : 0; |
| 15 | ! isset( $supported_filters ) ? $supported_filters = tutor_utils()->get_option( 'supported_course_filters', array() ) : 0; |
| 16 | ! isset( $loop_content_only ) ? $loop_content_only = false : 0; |
| 17 | ! isset( $column_per_row ) ? $column_per_row = tutor_utils()->get_option( 'courses_col_per_row', 3 ) : 0; |
| 18 | ! isset( $course_per_page ) ? $course_per_page = tutor_utils()->get_option( 'courses_per_page', 12 ) : 0; |
| 19 | ! isset( $show_pagination ) ? $show_pagination = true : 0; |
| 20 | ! isset( $current_page ) ? $current_page = 1 : 0; |
| 21 | |
| 22 | // Hide pagination is there is no page after first one. |
| 23 | $pages_count = 0; |
| 24 | if ( isset( $the_query ) ) { |
| 25 | $pages_count = $the_query->max_num_pages; |
| 26 | } else { |
| 27 | global $wp_query; |
| 28 | $pages_count = $wp_query->max_num_pages; |
| 29 | } |
| 30 | $pages_count < 2 ? $show_pagination = false : 0; |
| 31 | |
| 32 | // Set in global variable to avoid too many stack to pass to other templates. |
| 33 | $GLOBALS['tutor_course_archive_arg'] = compact( |
| 34 | 'course_filter', |
| 35 | 'supported_filters', |
| 36 | 'loop_content_only', |
| 37 | 'column_per_row', |
| 38 | 'course_per_page', |
| 39 | 'show_pagination' |
| 40 | ); |
| 41 | |
| 42 | // Render the loop. |
| 43 | ob_start(); |
| 44 | do_action( 'tutor_course/archive/before_loop' ); |
| 45 | |
| 46 | if ( ( isset( $the_query ) && $the_query->have_posts() ) || have_posts() ) { |
| 47 | /* Start the Loop */ |
| 48 | |
| 49 | tutor_course_loop_start(); |
| 50 | |
| 51 | while ( isset( $the_query ) ? $the_query->have_posts() : have_posts() ) { |
| 52 | isset( $the_query ) ? $the_query->the_post() : the_post(); |
| 53 | |
| 54 | /** |
| 55 | * Usage Idea, you may keep a loop within a wrap, such as bootstrap col |
| 56 | * |
| 57 | * @hook tutor_course/archive/before_loop_course |
| 58 | * @type action |
| 59 | */ |
| 60 | do_action( 'tutor_course/archive/before_loop_course' ); |
| 61 | |
| 62 | tutor_load_template( 'loop.course' ); |
| 63 | |
| 64 | /** |
| 65 | * Usage Idea, If you start any div before course loop, you can end it here, such as </div> |
| 66 | * |
| 67 | * @hook tutor_course/archive/after_loop_course |
| 68 | * @type action |
| 69 | */ |
| 70 | do_action( 'tutor_course/archive/after_loop_course' ); |
| 71 | } |
| 72 | |
| 73 | tutor_course_loop_end(); |
| 74 | } else { |
| 75 | |
| 76 | /** |
| 77 | * No course found |
| 78 | */ |
| 79 | tutor_utils()->tutor_empty_state( tutor_utils()->not_found_text() ); |
| 80 | } |
| 81 | |
| 82 | do_action( 'tutor_course/archive/after_loop' ); |
| 83 | |
| 84 | if ( $show_pagination ) { |
| 85 | global $wp_query; |
| 86 | |
| 87 | $current_url = wp_doing_ajax() ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_REFERER'] ?? '' ) ) : tutor()->current_url; |
| 88 | //phpcs:disable WordPress.Security.NonceVerification.Missing |
| 89 | $push_link = add_query_arg( array_merge( $_POST, $GLOBALS['tutor_course_archive_arg'] ), $current_url ); |
| 90 | |
| 91 | $data = wp_doing_ajax() ? Input::sanitize_array( $_POST ) : Input::sanitize_array( $_GET ); |
| 92 | $pagination_data = array( |
| 93 | 'total_page' => isset( $the_query ) ? $the_query->max_num_pages : $wp_query->max_num_pages, |
| 94 | 'per_page' => $course_per_page, |
| 95 | 'paged' => $current_page, |
| 96 | 'data_set' => array( 'push_state_link' => $push_link ), |
| 97 | 'ajax' => array_merge( |
| 98 | $data, |
| 99 | array( |
| 100 | 'loading_container' => '.tutor-course-filter-loop-container', |
| 101 | 'action' => 'tutor_course_filter_ajax', |
| 102 | 'course_per_page' => $course_per_page, |
| 103 | 'column_per_row' => $column_per_row, |
| 104 | ) |
| 105 | ), |
| 106 | ); |
| 107 | |
| 108 | tutor_load_template_from_custom_path( |
| 109 | tutor()->path . 'templates/dashboard/elements/pagination.php', |
| 110 | $pagination_data |
| 111 | ); |
| 112 | } |
| 113 | |
| 114 | $course_loop = ob_get_clean(); |
| 115 | |
| 116 | if ( isset( $loop_content_only ) && true == $loop_content_only ) { |
| 117 | echo $course_loop; //phpcs:ignore --$course_loop contain sanitized data |
| 118 | return; |
| 119 | } |
| 120 | |
| 121 | $course_archive_arg = isset( $GLOBALS['tutor_course_archive_arg'] ) ? $GLOBALS['tutor_course_archive_arg']['column_per_row'] : null; |
| 122 | $columns = null === $course_archive_arg ? tutor_utils()->get_option( 'courses_col_per_row', 3 ) : $course_archive_arg; |
| 123 | $has_course_filters = $course_filter && count( $supported_filters ); |
| 124 | |
| 125 | $supported_filters_keys = array_keys( $supported_filters ); |
| 126 | ?> |
| 127 | |
| 128 | <div class="tutor-wrap tutor-wrap-parent tutor-courses-wrap tutor-container course-archive-page" data-tutor_courses_meta="<?php echo esc_attr( json_encode( $GLOBALS['tutor_course_archive_arg'] ) ); ?>"> |
| 129 | <?php if ( $has_course_filters ) : ?> |
| 130 | <div class="tutor-d-block tutor-d-xl-none tutor-mb-32"> |
| 131 | <div class="tutor-d-flex tutor-align-center tutor-justify-between"> |
| 132 | <span class="tutor-fs-3 tutor-fw-medium tutor-color-black"><?php esc_html_e( 'Courses', 'tutor' ); ?></span> |
| 133 | <a href="#" class="tutor-iconic-btn tutor-iconic-btn-secondary tutor-iconic-btn-md" tutor-toggle-course-filter><span class="tutor-icon-slider-vertical"></span></a> |
| 134 | </div> |
| 135 | </div> |
| 136 | <?php endif; ?> |
| 137 | |
| 138 | <div class="tutor-row tutor-gx-xl-5"> |
| 139 | <?php if ( $has_course_filters ) : ?> |
| 140 | <div class="tutor-col-3 tutor-course-filter-container"> |
| 141 | <div class="tutor-course-filter" tutor-course-filter> |
| 142 | <?php tutor_load_template( 'course-filter.filters', array( 'supported_filters' => $supported_filters ) ); ?> |
| 143 | </div> |
| 144 | </div> |
| 145 | |
| 146 | <div class="tutor-col-xl-<?php echo $columns < 3 ? 8 : 9; ?> "> |
| 147 | <div> |
| 148 | <?php tutor_load_template( 'course-filter.course-archive-filter-bar' ); ?> |
| 149 | </div> |
| 150 | <div class="tutor-pagination-wrapper-replaceable" tutor-course-list-container> |
| 151 | <?php echo $course_loop; //phpcs:ignore --$course_loop contain sanitized data ?> |
| 152 | </div> |
| 153 | </div> |
| 154 | <?php else : ?> |
| 155 | <div class="tutor-col-12"> |
| 156 | <div class=""> |
| 157 | <?php tutor_load_template( 'course-filter.course-archive-filter-bar' ); ?> |
| 158 | </div> |
| 159 | <div class="tutor-pagination-wrapper-replaceable" tutor-course-list-container> |
| 160 | <?php echo $course_loop; //phpcs:ignore --$course_loop contain sanitized data ?> |
| 161 | </div> |
| 162 | </div> |
| 163 | <?php endif; ?> |
| 164 | </div> |
| 165 | </div> |
| 166 | <?php if ( isset( $course_filter_category ) ) : ?> |
| 167 | <input type="hidden" id="course_filter_categories" value="<?php echo esc_html( $course_filter_category ); ?>"></input> |
| 168 | <?php endif; ?> |
| 169 | |
| 170 | <?php if ( isset( $course_filter_exclude_ids ) ) : ?> |
| 171 | <input type="hidden" id="course_filter_exclude_ids" value="<?php echo esc_html( $course_filter_exclude_ids ); ?>"></input> |
| 172 | <?php endif; ?> |
| 173 | |
| 174 | <?php if ( isset( $course_filter_post_ids ) ) : ?> |
| 175 | <input type="hidden" id="course_filter_post_ids" value="<?php echo esc_html( $course_filter_post_ids ); ?>"></input> |
| 176 | <?php endif; ?> |
| 177 | |
| 178 | <?php |
| 179 | if ( ! is_user_logged_in() ) { |
| 180 | tutor_load_template_from_custom_path( tutor()->path . '/views/modal/login.php' ); |
| 181 | } |
| 182 | ?> |
| 183 |