enrolled
3 years ago
add-to-cart-edd.php
4 years ago
add-to-cart-woocommerce.php
3 years ago
continue-lesson.php
4 years ago
course-benefits.php
4 years ago
course-content.php
4 years ago
course-entry-box.php
3 years ago
course-requirements.php
4 years ago
course-target-audience.php
4 years ago
course-topics.php
3 years ago
instructors.php
3 years ago
lead-info.php
3 years ago
material-includes.php
4 years ago
q_and_a_turned_off.php
4 years ago
reviews-loop.php
3 years ago
reviews.php
3 years ago
social_share.php
4 years ago
tags.php
3 years ago
wc-price-html.php
4 years ago
course-entry-box.php
247 lines
| 1 | <?php |
| 2 | // Utility data |
| 3 | $is_enrolled = apply_filters( 'tutor_alter_enroll_status', tutor_utils()->is_enrolled() ); |
| 4 | $lesson_url = tutor_utils()->get_course_first_lesson(); |
| 5 | $is_privileged_user = tutor_utils()->has_user_course_content_access(); |
| 6 | $tutor_course_sell_by = apply_filters( 'tutor_course_sell_by', null ); |
| 7 | $is_public = get_post_meta( get_the_ID(), '_tutor_is_public_course', true ) == 'yes'; |
| 8 | |
| 9 | // Monetization info |
| 10 | $monetize_by = tutor_utils()->get_option( 'monetize_by' ); |
| 11 | $is_purchasable = tutor_utils()->is_course_purchasable(); |
| 12 | |
| 13 | // Get login url if |
| 14 | $is_tutor_login_disabled = ! tutor_utils()->get_option( 'enable_tutor_native_login', null, true, true ); |
| 15 | $auth_url = $is_tutor_login_disabled ? ( isset( $_SERVER['REQUEST_SCHEME'] ) ? wp_login_url( $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) : '' ) : ''; |
| 16 | $default_meta = array( |
| 17 | array( |
| 18 | 'icon_class' => 'tutor-icon-mortarboard', |
| 19 | 'label' => __( 'Total Enrolled', 'tutor' ), |
| 20 | 'value' => tutor_utils()->get_option( 'enable_course_total_enrolled' ) ? tutor_utils()->count_enrolled_users_by_course() . ' ' . __("Total Enrolled", "tutor") : null, |
| 21 | ), |
| 22 | array( |
| 23 | 'icon_class' => 'tutor-icon-clock-line', |
| 24 | 'label' => __( 'Duration', 'tutor' ), |
| 25 | 'value' => get_tutor_option( 'enable_course_duration' ) ? ( get_tutor_course_duration_context() ? get_tutor_course_duration_context() . ' ' . __("Duration", "tutor") : false ) : null, |
| 26 | ), |
| 27 | array( |
| 28 | 'icon_class' => 'tutor-icon-refresh-o', |
| 29 | 'label' => __( 'Last Updated', 'tutor' ), |
| 30 | 'value' => get_tutor_option( 'enable_course_update_date' ) ? get_the_modified_date( get_option( 'date_format' ) ) . ' ' . __("Last Updated", "tutor") : null, |
| 31 | ), |
| 32 | ); |
| 33 | |
| 34 | // Add level if enabled |
| 35 | if(tutor_utils()->get_option('enable_course_level', true, true)) { |
| 36 | array_unshift($default_meta, array( |
| 37 | 'icon_class' => 'tutor-icon-level', |
| 38 | 'label' => __( 'Level', 'tutor' ), |
| 39 | 'value' => get_tutor_course_level( get_the_ID() ), |
| 40 | )); |
| 41 | } |
| 42 | |
| 43 | // Right sidebar meta data |
| 44 | $sidebar_meta = apply_filters('tutor/course/single/sidebar/metadata', $default_meta, get_the_ID() ); |
| 45 | $login_url = tutor_utils()->get_option( 'enable_tutor_native_login', null, true, true ) ? '' : wp_login_url( tutor()->current_url ); |
| 46 | ?> |
| 47 | |
| 48 | <div class="tutor-card tutor-card-md tutor-sidebar-card"> |
| 49 | <div class="tutor-card-body"> |
| 50 | <?php |
| 51 | if ( $is_enrolled || $is_privileged_user) { |
| 52 | ob_start(); |
| 53 | |
| 54 | // Course Info |
| 55 | $completed_percent = tutor_utils()->get_course_completed_percent(); |
| 56 | $is_completed_course = tutor_utils()->is_completed_course(); |
| 57 | $retake_course = tutor_utils()->can_user_retake_course(); |
| 58 | $course_id = get_the_ID(); |
| 59 | $course_progress = tutor_utils()->get_course_completed_percent( $course_id, 0, true ); |
| 60 | ?> |
| 61 | <!-- course progress --> |
| 62 | <?php if ( tutor_utils()->get_option('enable_course_progress_bar', true, true) && is_array( $course_progress ) && count( $course_progress ) ) : ?> |
| 63 | <div class="tutor-course-progress-wrapper tutor-mb-32"> |
| 64 | <h3 class="tutor-color-black tutor-fs-5 tutor-fw-bold tutor-mb-16"> |
| 65 | <?php esc_html_e( 'Course Progress', 'tutor' ); ?> |
| 66 | </h3> |
| 67 | <div class="list-item-progress"> |
| 68 | <div class="tutor-fs-6 tutor-color-secondary tutor-d-flex tutor-align-center tutor-justify-between"> |
| 69 | <span class="progress-steps"> |
| 70 | <?php echo esc_html( $course_progress['completed_count'] ); ?>/ |
| 71 | <?php echo esc_html( $course_progress['total_count'] ); ?> |
| 72 | </span> |
| 73 | <span class="progress-percentage"> |
| 74 | <?php echo esc_html( $course_progress['completed_percent'] . '%' ); ?> |
| 75 | <?php esc_html_e( 'Complete', 'tutor' ); ?> |
| 76 | </span> |
| 77 | </div> |
| 78 | <div class="tutor-progress-bar tutor-mt-12" style="--tutor-progress-value:<?php echo esc_attr( $course_progress['completed_percent'] ); ?>%;"> |
| 79 | <span class="tutor-progress-value" area-hidden="true"></span> |
| 80 | </div> |
| 81 | </div> |
| 82 | </div> |
| 83 | <?php endif; ?> |
| 84 | <?php |
| 85 | $start_content = ''; |
| 86 | |
| 87 | // The user is enrolled anyway. No matter manual, free, purchased, woocommerce, edd, membership |
| 88 | do_action( 'tutor_course/single/actions_btn_group/before' ); |
| 89 | |
| 90 | // Show Start/Continue/Retake Button |
| 91 | if ( $lesson_url ) { |
| 92 | $button_class = 'tutor-btn ' . |
| 93 | ( $retake_course ? 'tutor-btn-outline-primary' : 'tutor-btn-primary' ) . |
| 94 | ' tutor-btn-block' . |
| 95 | ( $retake_course ? ' tutor-course-retake-button' : '' ); |
| 96 | |
| 97 | // Button identifier class |
| 98 | $button_identifier = 'start-continue-retake-button'; |
| 99 | $tag = $retake_course ? 'button' : 'a'; |
| 100 | ob_start(); |
| 101 | ?> |
| 102 | <<?php echo $tag; ?> <?php echo $retake_course ? 'disabled="disabled"' : ''; ?> href="<?php echo esc_url( $lesson_url ); ?>" class="<?php echo esc_attr( $button_class . ' ' . $button_identifier ); ?>" data-course_id="<?php echo esc_attr( get_the_ID() ); ?>"> |
| 103 | <?php |
| 104 | if ( $retake_course ) { |
| 105 | esc_html_e( 'Retake This Course', 'tutor' ); |
| 106 | } elseif ( $completed_percent <= 0 ) { |
| 107 | esc_html_e( 'Start Learning', 'tutor' ); |
| 108 | } else { |
| 109 | esc_html_e( 'Continue Learning', 'tutor' ); |
| 110 | } |
| 111 | ?> |
| 112 | </<?php echo $tag; ?>> |
| 113 | <?php |
| 114 | $start_content = ob_get_clean(); |
| 115 | } |
| 116 | echo apply_filters( 'tutor_course/single/start/button', $start_content, get_the_ID() ); |
| 117 | |
| 118 | // Show Course Completion Button. |
| 119 | if ( ! $is_completed_course ) { |
| 120 | ob_start(); |
| 121 | ?> |
| 122 | <form method="post" class="tutor-mt-20"> |
| 123 | <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?> |
| 124 | |
| 125 | <input type="hidden" value="<?php echo esc_attr( get_the_ID() ); ?>" name="course_id"/> |
| 126 | <input type="hidden" value="tutor_complete_course" name="tutor_action"/> |
| 127 | |
| 128 | <button type="submit" class="tutor-btn tutor-btn-outline-primary tutor-btn-block" name="complete_course_btn" value="complete_course"> |
| 129 | <?php esc_html_e( 'Complete Course', 'tutor' ); ?> |
| 130 | </button> |
| 131 | </form> |
| 132 | <?php |
| 133 | echo apply_filters( 'tutor_course/single/complete_form', ob_get_clean() ); |
| 134 | } |
| 135 | |
| 136 | ?> |
| 137 | <?php |
| 138 | // check if has enrolled date. |
| 139 | $post_date = is_object( $is_enrolled ) && isset( $is_enrolled->post_date ) ? $is_enrolled->post_date : ''; |
| 140 | if ( '' !== $post_date ) : |
| 141 | ?> |
| 142 | <div class="tutor-fs-7 tutor-color-muted tutor-mt-20 tutor-d-flex"> |
| 143 | <span class="tutor-fs-6 tutor-color-success tutor-icon-purchase-mark tutor-mr-8"></span> |
| 144 | <span class="tutor-enrolled-info-text"> |
| 145 | <?php esc_html_e( 'You enrolled in this course on', 'tutor' ); ?> |
| 146 | <span class="tutor-fs-7 tutor-fw-bold tutor-color-success tutor-ml-4 tutor-enrolled-info-date"> |
| 147 | <?php |
| 148 | echo esc_html( tutor_i18n_get_formated_date( $post_date, get_option( 'date_format' ) ) ); |
| 149 | ?> |
| 150 | </span> |
| 151 | </span> |
| 152 | </div> |
| 153 | <?php endif; ?> |
| 154 | <?php |
| 155 | do_action( 'tutor_course/single/actions_btn_group/after' ); |
| 156 | echo apply_filters( 'tutor/course/single/entry-box/is_enrolled', ob_get_clean(), get_the_ID() ); |
| 157 | } else if ( $is_public ) { |
| 158 | // Get the first content url |
| 159 | $first_lesson_url = tutor_utils()->get_course_first_lesson( get_the_ID(), tutor()->lesson_post_type ); |
| 160 | !$first_lesson_url ? $first_lesson_url = tutor_utils()->get_course_first_lesson( get_the_ID() ) : 0; |
| 161 | ob_start(); |
| 162 | ?> |
| 163 | <a href="<?php echo esc_url( $first_lesson_url ); ?>" class="tutor-btn tutor-btn-primary tutor-btn-lg tutor-btn-block"> |
| 164 | <?php esc_html_e( 'Start Learning', 'tutor' ); ?> |
| 165 | </a> |
| 166 | <?php |
| 167 | echo apply_filters( 'tutor/course/single/entry-box/is_public', ob_get_clean(), get_the_ID() ); |
| 168 | } else { |
| 169 | // The course enroll options like purchase or free enrollment |
| 170 | $price = apply_filters( 'get_tutor_course_price', null, get_the_ID() ); |
| 171 | |
| 172 | if ( tutor_utils()->is_course_fully_booked( null ) ) { |
| 173 | ob_start(); |
| 174 | ?> |
| 175 | <div class="tutor-alert tutor-warning tutor-mt-28"> |
| 176 | <div class="tutor-alert-text"> |
| 177 | <span class="tutor-icon-circle-info tutor-alert-icon tutor-mr-12" area-hidden="true"></span> |
| 178 | <span> |
| 179 | <?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' ); ?> |
| 180 | </span> |
| 181 | </div> |
| 182 | </div> |
| 183 | <?php |
| 184 | echo apply_filters( 'tutor/course/single/entry-box/fully_booked', ob_get_clean(), get_the_ID() ); |
| 185 | } elseif ( $is_purchasable && $price && $tutor_course_sell_by ) { |
| 186 | // Load template based on monetization option |
| 187 | ob_start(); |
| 188 | tutor_load_template( 'single.course.add-to-cart-' . $tutor_course_sell_by ); |
| 189 | echo apply_filters( 'tutor/course/single/entry-box/purchasable', ob_get_clean(), get_the_ID() ); |
| 190 | } else { |
| 191 | ob_start(); |
| 192 | ?> |
| 193 | <div class="tutor-course-single-pricing"> |
| 194 | <span class="tutor-fs-4 tutor-fw-bold tutor-color-black"> |
| 195 | <?php esc_html_e( 'Free', 'tutor' ); ?> |
| 196 | </span> |
| 197 | </div> |
| 198 | |
| 199 | <div class="tutor-course-single-btn-group <?php echo is_user_logged_in() ? '' : 'tutor-course-entry-box-login'; ?>" data-login_url="<?php echo $login_url; ?>"> |
| 200 | <form class="tutor-enrol-course-form" method="post"> |
| 201 | <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?> |
| 202 | <input type="hidden" name="tutor_course_id" value="<?php echo esc_attr( get_the_ID() ); ?>"> |
| 203 | <input type="hidden" name="tutor_course_action" value="_tutor_course_enroll_now"> |
| 204 | <button type="submit" class="tutor-btn tutor-btn-primary tutor-btn-lg tutor-btn-block tutor-mt-24 tutor-enroll-course-button tutor-static-loader"> |
| 205 | <?php esc_html_e( 'Enroll now', 'tutor' ); ?> |
| 206 | </button> |
| 207 | </form> |
| 208 | </div> |
| 209 | |
| 210 | <div class="tutor-fs-7 tutor-color-muted tutor-mt-20 tutor-text-center"> |
| 211 | <?php esc_html_e( 'Free access this course', 'tutor' ); ?> |
| 212 | </div> |
| 213 | <?php |
| 214 | echo apply_filters( 'tutor/course/single/entry-box/free', ob_get_clean(), get_the_ID() ); |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | do_action('tutor_course/single/entry/after', get_the_ID()); |
| 219 | ?> |
| 220 | </div> |
| 221 | |
| 222 | <!-- Course Info --> |
| 223 | <div class="tutor-card-footer"> |
| 224 | <ul class="tutor-ul"> |
| 225 | <?php foreach ( $sidebar_meta as $key => $meta ) : ?> |
| 226 | <?php |
| 227 | if ( ! $meta['value'] ) { |
| 228 | continue; |
| 229 | } |
| 230 | ?> |
| 231 | <li class="tutor-d-flex<?php echo $key > 0 ? ' tutor-mt-12' : ''; ?>"> |
| 232 | <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> |
| 233 | <span class="tutor-fs-6 tutor-color-secondary"> |
| 234 | <?php echo wp_kses_post( $meta['value'] ); ?> |
| 235 | </span> |
| 236 | </li> |
| 237 | <?php endforeach; ?> |
| 238 | </ul> |
| 239 | </div> |
| 240 | </div> |
| 241 | |
| 242 | <?php |
| 243 | if ( ! is_user_logged_in() ) { |
| 244 | tutor_load_template_from_custom_path( tutor()->path . '/views/modal/login.php' ); |
| 245 | } |
| 246 | ?> |
| 247 |