enrolled
1 year ago
add-to-cart-edd.php
1 year ago
add-to-cart-tutor.php
11 months ago
add-to-cart-woocommerce.php
1 year ago
continue-lesson.php
3 years ago
course-benefits.php
3 years ago
course-content.php
3 years ago
course-entry-box.php
1 year ago
course-requirements.php
3 years ago
course-target-audience.php
3 years ago
course-topics.php
1 year ago
instructors.php
3 years ago
lead-info.php
9 months ago
material-includes.php
3 years ago
q_and_a_turned_off.php
3 years ago
reviews-loop.php
1 year ago
reviews.php
2 years ago
social_share.php
3 years ago
tags.php
3 years ago
wc-price-html.php
3 years ago
course-entry-box.php
307 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Template for course entry box |
| 4 | * |
| 5 | * @package Tutor\Templates |
| 6 | * @subpackage Single\Course |
| 7 | * @author Themeum <support@themeum.com> |
| 8 | * @link https://themeum.com |
| 9 | * @since 1.0.0 |
| 10 | */ |
| 11 | |
| 12 | use Tutor\Models\CourseModel; |
| 13 | |
| 14 | // Utility data. |
| 15 | global $is_enrolled; |
| 16 | |
| 17 | $is_enrolled = apply_filters( 'tutor_alter_enroll_status', $is_enrolled ); |
| 18 | $lesson_url = tutor_utils()->get_course_first_lesson(); |
| 19 | $is_privileged_user = tutor_utils()->has_user_course_content_access(); |
| 20 | $tutor_course_sell_by = apply_filters( 'tutor_course_sell_by', null ); |
| 21 | $is_public = get_post_meta( get_the_ID(), '_tutor_is_public_course', true ) == 'yes'; |
| 22 | |
| 23 | // Monetization info. |
| 24 | $monetize_by = tutor_utils()->get_option( 'monetize_by' ); |
| 25 | $is_purchasable = tutor_utils()->is_course_purchasable(); |
| 26 | |
| 27 | // Get login url if. |
| 28 | $is_tutor_login_disabled = ! tutor_utils()->get_option( 'enable_tutor_native_login', null, true, true ); |
| 29 | $auth_url = $is_tutor_login_disabled ? ( isset( $_SERVER['REQUEST_SCHEME'] ) ? wp_login_url( tutor_utils()->get_current_url() ) : '' ) : ''; |
| 30 | $default_meta = array( |
| 31 | array( |
| 32 | 'icon_class' => 'tutor-icon-mortarboard', |
| 33 | 'label' => __( 'Total Enrolled', 'tutor' ), |
| 34 | 'value' => tutor_utils()->get_option( 'enable_course_total_enrolled' ) ? tutor_utils()->count_enrolled_users_by_course() . ' ' . __( 'Total Enrolled', 'tutor' ) : null, |
| 35 | ), |
| 36 | array( |
| 37 | 'icon_class' => 'tutor-icon-clock-line', |
| 38 | 'label' => __( 'Duration', 'tutor' ), |
| 39 | 'value' => get_tutor_option( 'enable_course_duration' ) ? ( get_tutor_course_duration_context() ? get_tutor_course_duration_context() . ' ' . __( 'Duration', 'tutor' ) : false ) : null, |
| 40 | ), |
| 41 | array( |
| 42 | 'icon_class' => 'tutor-icon-refresh-o', |
| 43 | 'label' => __( 'Last Updated', 'tutor' ), |
| 44 | 'value' => get_tutor_option( 'enable_course_update_date' ) ? get_the_modified_date( get_option( 'date_format' ) ) . ' ' . __( 'Last Updated', 'tutor' ) : null, |
| 45 | ), |
| 46 | ); |
| 47 | |
| 48 | // Add level if enabled. |
| 49 | if ( tutor_utils()->get_option( 'enable_course_level', true, true ) ) { |
| 50 | array_unshift( |
| 51 | $default_meta, |
| 52 | array( |
| 53 | 'icon_class' => 'tutor-icon-level', |
| 54 | 'label' => __( 'Level', 'tutor' ), |
| 55 | 'value' => get_tutor_course_level( get_the_ID() ), |
| 56 | ) |
| 57 | ); |
| 58 | } |
| 59 | |
| 60 | // Right sidebar meta data. |
| 61 | $sidebar_meta = apply_filters( 'tutor/course/single/sidebar/metadata', $default_meta, get_the_ID() ); |
| 62 | $login_url = tutor_utils()->get_option( 'enable_tutor_native_login', null, true, true ) ? '' : wp_login_url( tutor()->current_url ); |
| 63 | |
| 64 | ?> |
| 65 | |
| 66 | <div class="tutor-card tutor-card-md tutor-sidebar-card"> |
| 67 | <?php |
| 68 | $tutor_load_sidebar_actions = apply_filters( 'tutor_load_single_sidebar_actions', true, get_the_ID() ); |
| 69 | if ( $tutor_load_sidebar_actions ) : |
| 70 | ?> |
| 71 | <div class="tutor-card-body"> |
| 72 | <?php |
| 73 | if ( $is_enrolled || $is_privileged_user ) { |
| 74 | ob_start(); |
| 75 | |
| 76 | // Course Info. |
| 77 | $user_id = get_current_user_id(); |
| 78 | $course_id = get_the_ID(); |
| 79 | $completion_mode = tutor_utils()->get_option( 'course_completion_process' ); |
| 80 | $is_completed_course = tutor_utils()->is_completed_course(); |
| 81 | $retake_course = tutor_utils()->can_user_retake_course(); |
| 82 | $course_progress = tutor_utils()->get_course_completed_percent( $course_id, 0, true ); |
| 83 | $completed_percent = $course_progress['completed_percent']; |
| 84 | ?> |
| 85 | <!-- course progress --> |
| 86 | <?php if ( tutor_utils()->get_option( 'enable_course_progress_bar', true, true ) && is_array( $course_progress ) && count( $course_progress ) ) : ?> |
| 87 | <div class="tutor-course-progress-wrapper tutor-mb-32"> |
| 88 | <h3 class="tutor-color-black tutor-fs-5 tutor-fw-bold tutor-mb-16"> |
| 89 | <?php esc_html_e( 'Course Progress', 'tutor' ); ?> |
| 90 | </h3> |
| 91 | <div class="list-item-progress"> |
| 92 | <div class="tutor-fs-6 tutor-color-secondary tutor-d-flex tutor-align-center tutor-justify-between"> |
| 93 | <span class="progress-steps"> |
| 94 | <?php echo esc_html( $course_progress['completed_count'] . '/' . $course_progress['total_count'] ); ?> |
| 95 | </span> |
| 96 | <span class="progress-percentage"> |
| 97 | <?php echo esc_html( $completed_percent . '%' ); ?> |
| 98 | <?php esc_html_e( 'Complete', 'tutor' ); ?> |
| 99 | </span> |
| 100 | </div> |
| 101 | <div class="tutor-progress-bar tutor-mt-12" style="--tutor-progress-value:<?php echo esc_attr( $completed_percent ); ?>%;"> |
| 102 | <span class="tutor-progress-value" area-hidden="true"></span> |
| 103 | </div> |
| 104 | </div> |
| 105 | </div> |
| 106 | <?php endif; ?> |
| 107 | <?php |
| 108 | $start_content = ''; |
| 109 | |
| 110 | // The user is enrolled anyway. No matter manual, free, purchased, woocommerce, edd, membership. |
| 111 | do_action( 'tutor_course/single/actions_btn_group/before' ); |
| 112 | |
| 113 | // Show Start/Continue/Retake Button. |
| 114 | if ( $lesson_url ) { |
| 115 | ob_start(); |
| 116 | /** |
| 117 | * Course retake button. |
| 118 | * |
| 119 | * Todo: `href` attribute is exist for backward compatibility. |
| 120 | * we need to make it `data-link` attribute and update the js code at course-landing.js |
| 121 | * |
| 122 | * @since 1.0.0 |
| 123 | * @since 2.4.0 refactored and hide it when strict mode enabled and course not completed. |
| 124 | */ |
| 125 | if ( $retake_course && ( CourseModel::MODE_FLEXIBLE === $completion_mode || $is_completed_course ) ) { |
| 126 | ?> |
| 127 | <button type="button" |
| 128 | class="tutor-btn tutor-btn-block tutor-btn-outline-primary start-continue-retake-button tutor-course-retake-button" |
| 129 | href="<?php echo esc_url( $lesson_url ); ?>" |
| 130 | data-course_id="<?php echo esc_attr( get_the_ID() ); ?>"> |
| 131 | <?php esc_html_e( 'Retake This Course', 'tutor' ); ?> |
| 132 | </button> |
| 133 | <?php |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * Start/Continue learning button |
| 138 | * |
| 139 | * @since 1.0.0 |
| 140 | * @since 2.4.0 refactored for enhance readibility. |
| 141 | */ |
| 142 | $link_text = ''; |
| 143 | if ( ! $is_completed_course ) { |
| 144 | if ( 0 === (int) $completed_percent ) { |
| 145 | $link_text = __( 'Start Learning', 'tutor' ); |
| 146 | } |
| 147 | if ( $completed_percent > 0 && $completed_percent < 100 ) { |
| 148 | $link_text = __( 'Continue Learning', 'tutor' ); |
| 149 | } |
| 150 | |
| 151 | /** |
| 152 | * `Review Progress` link text shown when |
| 153 | * - strict mode enabled |
| 154 | * - course progress 100% |
| 155 | * - in course progress any quiz or assignemnt result is not passed. |
| 156 | * |
| 157 | * @since 2.4.0 |
| 158 | */ |
| 159 | if ( 100 === (int) $completed_percent && false === CourseModel::can_complete_course( $course_id, $user_id ) ) { |
| 160 | $lesson_url = CourseModel::get_review_progress_link( $course_id, $user_id ); |
| 161 | $link_text = __( 'Review Progress', 'tutor' ); |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | if ( strlen( $link_text ) > 0 ) { |
| 166 | ?> |
| 167 | <a href="<?php echo esc_url( $lesson_url ); ?>" |
| 168 | class="tutor-btn tutor-btn-block tutor-btn-primary tutor-mt-20"> |
| 169 | <?php echo esc_html( $link_text ); ?> |
| 170 | </a> |
| 171 | <?php |
| 172 | } |
| 173 | |
| 174 | $start_content = ob_get_clean(); |
| 175 | } |
| 176 | echo apply_filters( 'tutor_course/single/start/button', $start_content, get_the_ID() );//phpcs:ignore |
| 177 | |
| 178 | // Show Course Completion Button. |
| 179 | if ( ! $is_completed_course ) { |
| 180 | ob_start(); |
| 181 | ?> |
| 182 | <form method="post" class="tutor-mt-20"> |
| 183 | <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce, false ); ?> |
| 184 | |
| 185 | <input type="hidden" value="<?php echo esc_attr( get_the_ID() ); ?>" name="course_id"/> |
| 186 | <input type="hidden" value="tutor_complete_course" name="tutor_action"/> |
| 187 | |
| 188 | <button type="submit" class="tutor-btn tutor-btn-outline-primary tutor-btn-block" name="complete_course_btn" value="complete_course"> |
| 189 | <?php esc_html_e( 'Complete Course', 'tutor' ); ?> |
| 190 | </button> |
| 191 | </form> |
| 192 | <?php |
| 193 | echo apply_filters( 'tutor_course/single/complete_form', ob_get_clean() );//phpcs:ignore |
| 194 | } |
| 195 | |
| 196 | ?> |
| 197 | <?php |
| 198 | // check if has enrolled date. |
| 199 | $post_date = is_object( $is_enrolled ) && isset( $is_enrolled->post_date ) ? $is_enrolled->post_date : ''; |
| 200 | if ( '' !== $post_date ) : |
| 201 | ?> |
| 202 | <div class="tutor-fs-7 tutor-color-muted tutor-mt-20 tutor-d-flex"> |
| 203 | <span class="tutor-fs-6 tutor-color-success tutor-icon-purchase-mark tutor-mr-8"></span> |
| 204 | <span class="tutor-enrolled-info-text"> |
| 205 | <?php esc_html_e( 'You enrolled in this course on', 'tutor' ); ?> |
| 206 | <span class="tutor-fs-7 tutor-fw-bold tutor-color-success tutor-ml-4 tutor-enrolled-info-date"> |
| 207 | <?php |
| 208 | echo esc_html( tutor_i18n_get_formated_date( $post_date, get_option( 'date_format' ) ) ); |
| 209 | ?> |
| 210 | </span> |
| 211 | </span> |
| 212 | </div> |
| 213 | <?php endif; ?> |
| 214 | <?php |
| 215 | do_action( 'tutor_course/single/actions_btn_group/after' ); |
| 216 | echo apply_filters( 'tutor/course/single/entry-box/is_enrolled', ob_get_clean(), get_the_ID() );//phpcs:ignore |
| 217 | } elseif ( $is_public ) { |
| 218 | // Get the first content url. |
| 219 | $first_lesson_url = tutor_utils()->get_course_first_lesson( get_the_ID(), tutor()->lesson_post_type ); |
| 220 | ! $first_lesson_url ? $first_lesson_url = tutor_utils()->get_course_first_lesson( get_the_ID() ) : 0; |
| 221 | ob_start(); |
| 222 | ?> |
| 223 | <a href="<?php echo esc_url( $first_lesson_url ); ?>" class="tutor-btn tutor-btn-primary tutor-btn-lg tutor-btn-block"> |
| 224 | <?php esc_html_e( 'Start Learning', 'tutor' ); ?> |
| 225 | </a> |
| 226 | <?php |
| 227 | echo apply_filters( 'tutor/course/single/entry-box/is_public', ob_get_clean(), get_the_ID() );//phpcs:ignore |
| 228 | } else { |
| 229 | // The course enroll options like purchase or free enrollment. |
| 230 | $price = apply_filters( 'get_tutor_course_price', null, get_the_ID() ); |
| 231 | |
| 232 | if ( tutor_utils()->is_course_fully_booked( null ) ) { |
| 233 | ob_start(); |
| 234 | ?> |
| 235 | <div class="tutor-alert tutor-warning tutor-mt-28"> |
| 236 | <div class="tutor-alert-text"> |
| 237 | <span class="tutor-icon-circle-info tutor-alert-icon tutor-mr-12" area-hidden="true"></span> |
| 238 | <span> |
| 239 | <?php esc_html_e( 'This course is full right now. We limit the number of students to create an optimized and productive group dynamic.', 'tutor' ); ?> |
| 240 | </span> |
| 241 | </div> |
| 242 | </div> |
| 243 | <?php |
| 244 | echo apply_filters( 'tutor/course/single/entry-box/fully_booked', ob_get_clean(), get_the_ID() );//phpcs:ignore |
| 245 | } elseif ( $is_purchasable && $price && $tutor_course_sell_by ) { |
| 246 | // Load template based on monetization option. |
| 247 | ob_start(); |
| 248 | tutor_load_template( 'single.course.add-to-cart-' . $tutor_course_sell_by ); |
| 249 | echo apply_filters( 'tutor/course/single/entry-box/purchasable', ob_get_clean(), get_the_ID() );//phpcs:ignore |
| 250 | } else { |
| 251 | ob_start(); |
| 252 | ?> |
| 253 | <div class="tutor-course-single-pricing"> |
| 254 | <span class="tutor-fs-4 tutor-fw-bold tutor-color-black"> |
| 255 | <?php esc_html_e( 'Free', 'tutor' ); ?> |
| 256 | </span> |
| 257 | </div> |
| 258 | |
| 259 | <div class="tutor-course-single-btn-group <?php echo is_user_logged_in() ? '' : 'tutor-course-entry-box-login'; ?>" data-login_url="<?php echo esc_url( $login_url ); ?>"> |
| 260 | <form class="tutor-enrol-course-form" method="post"> |
| 261 | <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?> |
| 262 | <input type="hidden" name="tutor_course_id" value="<?php echo esc_attr( get_the_ID() ); ?>"> |
| 263 | <input type="hidden" name="tutor_course_action" value="_tutor_course_enroll_now"> |
| 264 | <button type="submit" class="tutor-btn tutor-btn-primary tutor-btn-lg tutor-btn-block tutor-mt-24 tutor-enroll-course-button <?php echo is_user_logged_in() ? 'tutor-static-loader' : ''; ?>"> |
| 265 | <?php esc_html_e( 'Enroll Now', 'tutor' ); ?> |
| 266 | </button> |
| 267 | </form> |
| 268 | </div> |
| 269 | |
| 270 | <div class="tutor-fs-7 tutor-color-muted tutor-mt-20 tutor-text-center"> |
| 271 | <?php esc_html_e( 'Free access this course', 'tutor' ); ?> |
| 272 | </div> |
| 273 | <?php |
| 274 | echo apply_filters( 'tutor/course/single/entry-box/free', ob_get_clean(), get_the_ID() );//phpcs:ignore |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | do_action( 'tutor_course/single/entry/after', get_the_ID() ); |
| 279 | ?> |
| 280 | </div> |
| 281 | <?php endif; ?> |
| 282 | <!-- Course Info --> |
| 283 | <div class="tutor-card-footer <?php echo esc_attr( $tutor_load_sidebar_actions ? '' : 'tutor-no-border' ); ?>"> |
| 284 | <ul class="tutor-ul"> |
| 285 | <?php foreach ( $sidebar_meta as $key => $meta ) : ?> |
| 286 | <?php |
| 287 | if ( ! $meta['value'] ) { |
| 288 | continue; |
| 289 | } |
| 290 | ?> |
| 291 | <li class="tutor-d-flex<?php echo $key > 0 ? ' tutor-mt-12' : ''; ?> <?php echo esc_attr( isset( $meta['list_class'] ) ? $meta['list_class'] : '' ); ?>"> |
| 292 | <span class="<?php echo esc_attr( $meta['icon_class'] ); ?> tutor-color-black tutor-mt-4 tutor-mr-12" aria-labelledby="<?php echo esc_html( $meta['label'] ); ?>"></span> |
| 293 | <span class="tutor-fs-6 tutor-color-secondary"> |
| 294 | <?php echo wp_kses_post( $meta['value'] ); ?> |
| 295 | </span> |
| 296 | </li> |
| 297 | <?php endforeach; ?> |
| 298 | </ul> |
| 299 | </div> |
| 300 | </div> |
| 301 | |
| 302 | <?php |
| 303 | if ( ! is_user_logged_in() ) { |
| 304 | tutor_load_template_from_custom_path( tutor()->path . '/views/modal/login.php' ); |
| 305 | } |
| 306 | ?> |
| 307 |