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