header.php
105 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Common header template. |
| 4 | * |
| 5 | * @package Tutor\Templates |
| 6 | * @subpackage Single\Common |
| 7 | * @author Themeum <support@themeum.com> |
| 8 | * @link https://themeum.com |
| 9 | * @since 1.0.0 |
| 10 | */ |
| 11 | |
| 12 | use TUTOR\Course; |
| 13 | use Tutor\Models\CourseModel; |
| 14 | |
| 15 | $user_id = get_current_user_id(); |
| 16 | $course_id = isset( $course_id ) ? (int) $course_id : 0; |
| 17 | $is_enrolled = tutor_utils()->is_enrolled( $course_id ); |
| 18 | $course_stats = tutor_utils()->get_course_completed_percent( $course_id, 0, true ); |
| 19 | $show_mark_complete = isset( $mark_as_complete ) ? $mark_as_complete : false; |
| 20 | |
| 21 | |
| 22 | $is_course_completed = tutor_utils()->is_completed_course( $course_id, $user_id ); |
| 23 | |
| 24 | /** |
| 25 | * Auto course complete on all lesson, quiz, assignment complete |
| 26 | * |
| 27 | * @since 2.0.7 |
| 28 | * @since 2.4.0 update and refactor. |
| 29 | */ |
| 30 | if ( CourseModel::can_autocomplete_course( $course_id, $user_id ) ) { |
| 31 | CourseModel::mark_course_as_completed( $course_id, $user_id ); |
| 32 | |
| 33 | /** |
| 34 | * After auto complete the course. |
| 35 | * Set review popup data and redirect to course details page. |
| 36 | * Review popup will be shown on course details page. |
| 37 | * |
| 38 | * @since 2.4.0 |
| 39 | */ |
| 40 | Course::set_review_popup_data( $user_id, $course_id ); |
| 41 | $course_link = get_permalink( $course_id ); |
| 42 | if ( $course_link ) { |
| 43 | tutils()->redirect_to( $course_link ); |
| 44 | exit; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | ?> |
| 49 | <div class="tutor-course-topic-single-header tutor-single-page-top-bar"> |
| 50 | <a href="#" class="tutor-course-topics-sidebar-toggler tutor-iconic-btn tutor-iconic-btn-secondary tutor-d-none tutor-d-xl-inline-flex tutor-flex-shrink-0" tutor-course-topics-sidebar-toggler> |
| 51 | <span class="tutor-icon-left" area-hidden="true"></span> |
| 52 | </a> |
| 53 | |
| 54 | <a href="<?php echo esc_url( get_the_permalink( $course_id ) ); ?>" class="tutor-iconic-btn tutor-d-flex tutor-d-xl-none"> |
| 55 | <span class="tutor-icon-previous" area-hidden="true"></span> |
| 56 | </a> |
| 57 | |
| 58 | <div class="tutor-course-topic-single-header-title tutor-fs-6 tutor-ml-12 tutor-ml-xl-24"> |
| 59 | <?php echo esc_html( get_the_title( $course_id ) ); ?> |
| 60 | </div> |
| 61 | |
| 62 | <div class="tutor-ml-auto tutor-align-center tutor-d-none tutor-d-xl-flex"> |
| 63 | <?php if ( $is_enrolled ) : ?> |
| 64 | <?php do_action( 'tutor_course/single/enrolled/before/lead_info/progress_bar' ); ?> |
| 65 | <div class="tutor-fs-7 tutor-mr-20"> |
| 66 | <?php if ( true == get_tutor_option( 'enable_course_progress_bar' ) ) : ?> |
| 67 | <span class="tutor-progress-content tutor-color-primary-60"> |
| 68 | <?php esc_html_e( 'Your Progress:', 'tutor' ); ?> |
| 69 | </span> |
| 70 | <span class="tutor-fs-7 tutor-fw-bold"> |
| 71 | <?php echo esc_html( $course_stats['completed_count'] ); ?> |
| 72 | </span> |
| 73 | <?php esc_html_e( 'of ', 'tutor' ); ?> |
| 74 | <span class="tutor-fs-7 tutor-fw-bold"> |
| 75 | <?php echo esc_html( $course_stats['total_count'] ); ?> |
| 76 | </span> |
| 77 | (<?php echo esc_html( $course_stats['completed_percent'] . '%' ); ?>) |
| 78 | <?php endif; ?> |
| 79 | </div> |
| 80 | <?php do_action( 'tutor_course/single/enrolled/after/lead_info/progress_bar' ); ?> |
| 81 | <?php |
| 82 | if ( $show_mark_complete ) { |
| 83 | tutor_lesson_mark_complete_html(); |
| 84 | } |
| 85 | do_action( 'tutor_after_lesson_completion_button', $course_id, $user_id, $is_course_completed, $course_stats ); |
| 86 | ?> |
| 87 | <?php endif; ?> |
| 88 | <?php |
| 89 | if ( 0 === $course_id && 'tutor_zoom_meeting' === get_post_type( get_the_ID() ) ) { |
| 90 | // Zoom General Meeting. |
| 91 | $course_id = wp_get_post_parent_id( get_the_ID() ); |
| 92 | } |
| 93 | ?> |
| 94 | <a class="tutor-iconic-btn tutor-flex-shrink-0" href="<?php echo esc_url( get_the_permalink( $course_id ) ); ?>"> |
| 95 | <span class="tutor-icon-times" area-hidden="true"></span> |
| 96 | </a> |
| 97 | </div> |
| 98 | |
| 99 | <div class="tutor-ml-auto tutor-align-center tutor-d-block tutor-d-xl-none"> |
| 100 | <a class="tutor-iconic-btn" href="#" tutor-course-topics-sidebar-offcanvas-toggler> |
| 101 | <span class="tutor-icon-hamburger-menu" area-hidden="true"></span> |
| 102 | </a> |
| 103 | </div> |
| 104 | </div> |
| 105 |