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