course-filter
3 years ago
dashboard
2 years ago
email
2 years ago
global
3 years ago
instructor
3 years ago
loop
2 years ago
modal
3 years ago
profile
3 years ago
shortcode
2 years ago
single
2 years ago
template-part
3 years ago
widget
3 years ago
archive-course-init.php
2 years ago
archive-course.php
3 years ago
course-embed.php
3 years ago
course-none.php
3 years ago
dashboard.php
3 years ago
feature_disabled.php
3 years ago
login-form.php
3 years ago
login.php
3 years ago
metabox-wrapper.php
3 years ago
permission-denied.php
3 years ago
public-profile.php
2 years ago
single-assignment.php
3 years ago
single-content-loader.php
2 years ago
single-course.php
2 years ago
single-lesson.php
3 years ago
single-preview-lesson.php
3 years ago
single-quiz.php
3 years ago
template.php
3 years ago
public-profile.php
219 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Template for displaying student & instructor Public Profile. |
| 4 | * It is used for both of instructor and student. |
| 5 | * Separate file has not been introduced due to complicacy and backward compatibility. |
| 6 | * |
| 7 | * @package Tutor\Templates |
| 8 | * @author Themeum <support@themeum.com> |
| 9 | * @link https://themeum.com |
| 10 | * @since 1.0.0 |
| 11 | */ |
| 12 | |
| 13 | use TUTOR\Input; |
| 14 | use Tutor\Models\CourseModel; |
| 15 | |
| 16 | // Get the accessed user data. |
| 17 | $user_name = sanitize_text_field( get_query_var( 'tutor_profile_username' ) ); |
| 18 | $get_user = tutor_utils()->get_user_by_login( $user_name ); |
| 19 | |
| 20 | // Show not found page if user not exists. |
| 21 | if ( ! is_object( $get_user ) || ! property_exists( $get_user, 'ID' ) ) { |
| 22 | wp_safe_redirect( get_home_url() . '/404' ); |
| 23 | exit; |
| 24 | } |
| 25 | |
| 26 | // Prepare meta data to render the page based on user and view type. |
| 27 | $user_id = $get_user->ID; |
| 28 | $is_instructor = Input::has( 'view' ) ? 'instructor' === Input::get( 'view' ) : tutor_utils()->is_instructor( $user_id, true ); |
| 29 | $layout_key = $is_instructor ? 'public_profile_layout' : 'student_public_profile_layout'; |
| 30 | $profile_layout = tutor_utils()->get_option( $layout_key, 'private' ); |
| 31 | $user_type = $is_instructor ? 'instructor' : 'student'; |
| 32 | |
| 33 | if ( 'private' === $profile_layout ) { |
| 34 | // Disable profile access then. |
| 35 | wp_safe_redirect( get_home_url() ); |
| 36 | exit; |
| 37 | } |
| 38 | |
| 39 | // Prepare social media URLs od the user. |
| 40 | $tutor_user_social_icons = tutor_utils()->tutor_user_social_icons(); |
| 41 | foreach ( $tutor_user_social_icons as $key => $social_icon ) { |
| 42 | $url = get_user_meta( $user_id, $key, true ); |
| 43 | $tutor_user_social_icons[ $key ]['url'] = $url; |
| 44 | } |
| 45 | |
| 46 | tutor_utils()->tutor_custom_header(); |
| 47 | ?> |
| 48 | |
| 49 | <?php |
| 50 | ob_start(); |
| 51 | |
| 52 | // Rating content. |
| 53 | if ( $is_instructor ) { |
| 54 | $instructor_rating = tutor_utils()->get_instructor_ratings( $user_id ); |
| 55 | ?> |
| 56 | <div class="tutor-rating-container"> |
| 57 | <div class="ratings"> |
| 58 | <span class="rating-generated"> |
| 59 | <?php tutor_utils()->star_rating_generator( $instructor_rating->rating_avg ); ?> |
| 60 | </span> |
| 61 | <span class='rating-digits'> |
| 62 | <?php echo esc_html( number_format( $instructor_rating->rating_avg, 2 ) ); ?> |
| 63 | </span> |
| 64 | <span class='rating-total-meta tutor-fs-7 tutor-color-muted'> |
| 65 | (<?php echo esc_html( number_format( $instructor_rating->rating_count, 2 ) ); ?>) |
| 66 | </span> |
| 67 | </div> |
| 68 | </div> |
| 69 | <?php |
| 70 | } |
| 71 | |
| 72 | $rating_content = ob_get_clean(); |
| 73 | $allowed_html_for_rating = array( |
| 74 | 'div' => array( 'class' => true ), |
| 75 | 'span' => array( 'class' => true ), |
| 76 | 'i' => array( 'class' => true ), |
| 77 | ); |
| 78 | |
| 79 | // Social media content. |
| 80 | ob_start(); |
| 81 | |
| 82 | foreach ( $tutor_user_social_icons as $key => $social_icon ) { |
| 83 | $url = $social_icon['url']; |
| 84 | echo ! empty( $url ) ? '<a href="' . esc_url( $url ) . '" target="_blank" rel="noopener noreferrer nofollow" class="' . esc_attr( $social_icon['icon_classes'] ) . '" title="' . esc_attr( $social_icon['label'] ) . '"></a>' : ''; |
| 85 | } |
| 86 | |
| 87 | $social_media = ob_get_clean(); |
| 88 | $allowed_html_for_social = array( |
| 89 | 'a' => array( |
| 90 | 'href' => true, |
| 91 | 'class' => true, |
| 92 | 'target' => true, |
| 93 | 'rel' => true, |
| 94 | 'title' => true, |
| 95 | ), |
| 96 | ); |
| 97 | |
| 98 | ?> |
| 99 | |
| 100 | <?php |
| 101 | //phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
| 102 | do_action( 'tutor_profile/' . $user_type . '/before/wrap' ); |
| 103 | ?> |
| 104 | <?php $user_identifier = $is_instructor ? 'tutor-instructor' : 'tutor-student'; ?> |
| 105 | <div <?php tutor_post_class( 'tutor-wrap-parent tutor-full-width-student-profile tutor-page-wrap tutor-user-public-profile tutor-user-public-profile-' . $profile_layout . ' ' . $user_identifier ); ?> > |
| 106 | <div class="tutor-container photo-area"> |
| 107 | <div class="cover-area"> |
| 108 | <div style="background-image:url(<?php echo esc_url( tutor_utils()->get_cover_photo_url( $user_id ) ); ?>)"></div> |
| 109 | <div></div> |
| 110 | </div> |
| 111 | <div class="pp-area"> |
| 112 | <div class="profile-pic" style="background-image:url(<?php echo esc_url( get_avatar_url( $user_id, array( 'size' => 300 ) ) ); ?>)"></div> |
| 113 | |
| 114 | <div class="profile-name tutor-color-white"> |
| 115 | <div class="profile-rating-media content-for-mobile"> |
| 116 | <?php echo wp_kses( $rating_content, $allowed_html_for_rating ); ?> |
| 117 | <div class="tutor-social-container content-for-desktop"> |
| 118 | <?php echo wp_kses( $social_media, $allowed_html_for_social ); ?> |
| 119 | </div> |
| 120 | </div> |
| 121 | |
| 122 | <h3><?php echo esc_html( $get_user->display_name ); ?></h3> |
| 123 | <?php |
| 124 | if ( $is_instructor ) { |
| 125 | $course_count = CourseModel::get_course_count_by_instructor( $user_id ); |
| 126 | $student_count = tutor_utils()->get_total_students_by_instructor( $user_id ); |
| 127 | ?> |
| 128 | <span> |
| 129 | <span><?php echo esc_html( $course_count ); ?></span> |
| 130 | <?php $course_count > 1 ? esc_html_e( 'Courses', 'tutor' ) : esc_html_e( 'Course', 'tutor' ); ?> |
| 131 | </span> |
| 132 | <span> |
| 133 | <span>•</span> |
| 134 | </span> |
| 135 | <span> |
| 136 | <span><?php echo esc_html( $student_count ); ?></span> |
| 137 | <?php $student_count > 1 ? esc_html_e( 'Students', 'tutor' ) : esc_html_e( 'Student', 'tutor' ); ?> |
| 138 | </span> |
| 139 | <?php |
| 140 | } else { |
| 141 | $enrolled_course = tutor_utils()->get_enrolled_courses_by_user( $user_id ); |
| 142 | $enrol_count = is_object( $enrolled_course ) ? $enrolled_course->found_posts : 0; |
| 143 | |
| 144 | $complete_count = tutor_utils()->get_completed_courses_ids_by_user( $user_id ); |
| 145 | $complete_count = $complete_count ? count( $complete_count ) : 0; |
| 146 | ?> |
| 147 | <span> |
| 148 | <span><?php echo esc_html( $enrol_count ); ?></span> |
| 149 | <?php $enrol_count > 1 ? esc_html_e( 'Courses Enrolled', 'tutor' ) : esc_html_e( 'Course Enrolled', 'tutor' ); ?> |
| 150 | </span> |
| 151 | <span><span>•</span></span> |
| 152 | <span> |
| 153 | <span><?php echo esc_html( $complete_count ); ?></span> |
| 154 | <?php $complete_count > 1 ? esc_html_e( 'Courses Completed', 'tutor' ) : esc_html_e( 'Course Completed', 'tutor' ); ?> |
| 155 | </span> |
| 156 | <?php |
| 157 | } |
| 158 | ?> |
| 159 | </div> |
| 160 | |
| 161 | <div class="tutor-social-container content-for-mobile"> |
| 162 | <?php echo wp_kses( $social_media, $allowed_html_for_social ); ?> |
| 163 | </div> |
| 164 | |
| 165 | <div class="profile-rating-media content-for-desktop"> |
| 166 | <?php echo wp_kses( $rating_content, $allowed_html_for_rating ); ?> |
| 167 | <div class="tutor-social-container content-for-desktop"> |
| 168 | <?php echo wp_kses( $social_media, $allowed_html_for_social ); ?> |
| 169 | </div> |
| 170 | </div> |
| 171 | </div> |
| 172 | </div> |
| 173 | |
| 174 | <div class="tutor-container" style="overflow:auto"> |
| 175 | <div class="tutor-user-profile-sidebar"> |
| 176 | |
| 177 | </div> |
| 178 | <div class="tutor-user-profile-content tutor-d-block tutor-mt-72"> |
| 179 | <h3><?php esc_html_e( 'Biography', 'tutor' ); ?></h3> |
| 180 | <?php tutor_load_template( 'profile.bio' ); ?> |
| 181 | |
| 182 | <?php |
| 183 | if ( $is_instructor ) { |
| 184 | ?> |
| 185 | <h3><?php esc_html_e( 'Courses', 'tutor' ); ?></h3> |
| 186 | <?php |
| 187 | add_filter( |
| 188 | 'courses_col_per_row', |
| 189 | function() { |
| 190 | return 3; |
| 191 | } |
| 192 | ); |
| 193 | |
| 194 | tutor_load_template( 'profile.courses_taken' ); |
| 195 | ?> |
| 196 | <?php |
| 197 | } |
| 198 | ?> |
| 199 | </div> |
| 200 | </div> |
| 201 | </div> |
| 202 | <?php |
| 203 | //phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
| 204 | do_action( 'tutor_profile/' . $user_type . '/after/wrap' ); |
| 205 | tutor_utils()->tutor_custom_footer(); |
| 206 | |
| 207 | /** |
| 208 | * If user not logged in load tutor login modal. |
| 209 | * It will appear on enroll btn click. |
| 210 | * |
| 211 | * @since 2.1.3 |
| 212 | */ |
| 213 | if ( ! is_user_logged_in() ) { |
| 214 | $login_modal = tutor()->path . '/views/modal/login.php'; |
| 215 | if ( file_exists( $login_modal ) ) { |
| 216 | tutor_load_template_from_custom_path( $login_modal ); |
| 217 | } |
| 218 | } |
| 219 |