course-filter
2 months ago
dashboard
2 months ago
ecommerce
2 months ago
email
9 months ago
global
2 days ago
instructor
3 years ago
loop
2 months ago
modal
2 months ago
profile
3 years ago
shortcode
2 months ago
single
2 months ago
template-part
1 year ago
widget
3 years ago
archive-course-init.php
9 months ago
archive-course.php
3 years ago
course-embed.php
2 months ago
course-none.php
3 years ago
dashboard.php
1 year ago
feature_disabled.php
3 years ago
login-form.php
2 months ago
login.php
3 years ago
metabox-wrapper.php
2 months ago
permission-denied.php
3 years ago
public-profile.php
8 months ago
single-assignment.php
3 years ago
single-content-loader.php
2 months ago
single-course.php
9 months ago
single-lesson.php
3 years ago
single-preview-lesson.php
3 years ago
single-quiz.php
1 year ago
template.php
3 years ago
dashboard.php
290 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Template for displaying frontend dashboard |
| 4 | * |
| 5 | * @package Tutor\Templates |
| 6 | * @author Themeum <support@themeum.com> |
| 7 | * @link https://themeum.com |
| 8 | * @since 1.4.3 |
| 9 | */ |
| 10 | |
| 11 | $is_by_short_code = isset( $is_shortcode ) && true === $is_shortcode; |
| 12 | if ( ! $is_by_short_code && ! defined( 'OTLMS_VERSION' ) ) { |
| 13 | tutor_utils()->tutor_custom_header(); |
| 14 | } |
| 15 | |
| 16 | global $wp_query; |
| 17 | |
| 18 | $dashboard_page_slug = ''; |
| 19 | $dashboard_page_name = ''; |
| 20 | if ( isset( $wp_query->query_vars['tutor_dashboard_page'] ) && $wp_query->query_vars['tutor_dashboard_page'] ) { |
| 21 | $dashboard_page_slug = $wp_query->query_vars['tutor_dashboard_page']; |
| 22 | $dashboard_page_name = $wp_query->query_vars['tutor_dashboard_page']; |
| 23 | } |
| 24 | /** |
| 25 | * Getting dashboard sub pages |
| 26 | */ |
| 27 | if ( isset( $wp_query->query_vars['tutor_dashboard_sub_page'] ) && $wp_query->query_vars['tutor_dashboard_sub_page'] ) { |
| 28 | $dashboard_page_name = $wp_query->query_vars['tutor_dashboard_sub_page']; |
| 29 | if ( $dashboard_page_slug ) { |
| 30 | $dashboard_page_name = $dashboard_page_slug . '/' . $dashboard_page_name; |
| 31 | } |
| 32 | } |
| 33 | $dashboard_page_name = apply_filters( 'tutor_dashboard_sub_page_template', $dashboard_page_name ); |
| 34 | |
| 35 | $user_id = get_current_user_id(); |
| 36 | $user = get_user_by( 'ID', $user_id ); |
| 37 | $enable_profile_completion = tutor_utils()->get_option( 'enable_profile_completion' ); |
| 38 | $is_instructor = tutor_utils()->is_instructor(); |
| 39 | |
| 40 | // URLS. |
| 41 | $current_url = tutor()->current_url; |
| 42 | $footer_url_1 = trailingslashit( tutor_utils()->tutor_dashboard_url( $is_instructor ? 'my-courses' : '' ) ); |
| 43 | $footer_url_2 = trailingslashit( tutor_utils()->tutor_dashboard_url( $is_instructor ? 'question-answer' : 'my-quiz-attempts' ) ); |
| 44 | |
| 45 | // Footer links. |
| 46 | $footer_links = array( |
| 47 | array( |
| 48 | 'title' => $is_instructor ? __( 'My Courses', 'tutor' ) : __( 'Dashboard', 'tutor' ), |
| 49 | 'url' => $footer_url_1, |
| 50 | 'is_active' => $footer_url_1 == $current_url, |
| 51 | 'icon_class' => 'ttr tutor-icon-dashboard', |
| 52 | ), |
| 53 | array( |
| 54 | 'title' => $is_instructor ? __( 'Q&A', 'tutor' ) : __( 'Quiz Attempts', 'tutor' ), |
| 55 | 'url' => $footer_url_2, |
| 56 | 'is_active' => $footer_url_2 == $current_url, |
| 57 | 'icon_class' => $is_instructor ? 'ttr tutor-icon-question' : 'ttr tutor-icon-quiz-attempt', |
| 58 | ), |
| 59 | array( |
| 60 | 'title' => __( 'Menu', 'tutor' ), |
| 61 | 'url' => '#', |
| 62 | 'is_active' => false, |
| 63 | 'icon_class' => 'ttr tutor-icon-hamburger-o tutor-dashboard-menu-toggler', |
| 64 | ), |
| 65 | ); |
| 66 | |
| 67 | do_action( 'tutor_dashboard/before/wrap' ); |
| 68 | ?> |
| 69 | <div class="tutor-wrap tutor-wrap-parent tutor-dashboard tutor-frontend-dashboard tutor-dashboard-student tutor-pb-80"> |
| 70 | <div class="tutor-container"> |
| 71 | <div class="tutor-row tutor-d-flex tutor-justify-between tutor-frontend-dashboard-header"> |
| 72 | <div class="tutor-header-left-side tutor-dashboard-header tutor-col-md-6 tutor-d-flex tutor-align-center" style="border: none;"> |
| 73 | <div class="tutor-dashboard-header-avatar"> |
| 74 | <?php |
| 75 | tutor_utils()->get_tutor_avatar( $user_id, 'xl', true ) |
| 76 | ?> |
| 77 | </div> |
| 78 | |
| 79 | <div class="tutor-user-info tutor-ml-24"> |
| 80 | <?php |
| 81 | $instructor_rating = tutor_utils()->get_instructor_ratings( $user->ID ); |
| 82 | |
| 83 | if ( current_user_can( tutor()->instructor_role ) ) { |
| 84 | ?> |
| 85 | <div class="tutor-fs-4 tutor-fw-medium tutor-color-black tutor-dashboard-header-username"> |
| 86 | <?php echo esc_html( $user->display_name ); ?> |
| 87 | </div> |
| 88 | <div class="tutor-dashboard-header-stats"> |
| 89 | <div class="tutor-dashboard-header-ratings"> |
| 90 | <?php tutor_utils()->star_rating_generator_v2( $instructor_rating->rating_avg, $instructor_rating->rating_count, true ); ?> |
| 91 | </div> |
| 92 | </div> |
| 93 | <?php |
| 94 | } else { |
| 95 | ?> |
| 96 | <div class="tutor-dashboard-header-display-name tutor-color-black"> |
| 97 | <div class="tutor-fs-5 tutor-dashboard-header-greetings"> |
| 98 | <?php esc_html_e( 'Hello', 'tutor' ); ?>, |
| 99 | </div> |
| 100 | <div class="tutor-fs-4 tutor-fw-medium tutor-dashboard-header-username"> |
| 101 | <?php echo esc_html( $user->display_name ); ?> |
| 102 | </div> |
| 103 | </div> |
| 104 | <?php |
| 105 | } |
| 106 | ?> |
| 107 | </div> |
| 108 | </div> |
| 109 | <div class="tutor-header-right-side tutor-col-md-6 tutor-d-flex tutor-justify-end tutor-mt-20 tutor-mt-md-0"> |
| 110 | <div class="tutor-d-flex tutor-align-center"> |
| 111 | <?php |
| 112 | do_action( 'tutor_dashboard/before_header_button' ); |
| 113 | $instructor_status = tutor_utils()->instructor_status( 0, false ); |
| 114 | $instructor_status = is_string( $instructor_status ) ? strtolower( $instructor_status ) : ''; |
| 115 | $rejected_on = get_user_meta( $user->ID, '_is_tutor_instructor_rejected', true ); |
| 116 | $info_style = 'vertical-align: middle; margin-right: 7px;'; |
| 117 | $info_message_style = 'display:inline-block; color:#7A7A7A; font-size: 15px;'; |
| 118 | |
| 119 | ob_start(); |
| 120 | if ( tutor_utils()->get_option( 'enable_become_instructor_btn' ) ) { |
| 121 | ?> |
| 122 | <a id="tutor-become-instructor-button" class="tutor-btn tutor-btn-outline-primary" href="<?php echo esc_url( tutor_utils()->instructor_register_url() ); ?>"> |
| 123 | <i class="tutor-icon-user-bold"></i> <?php esc_html_e( 'Become an instructor', 'tutor' ); ?> |
| 124 | </a> |
| 125 | <?php |
| 126 | } |
| 127 | $become_button = ob_get_clean(); |
| 128 | |
| 129 | if ( current_user_can( tutor()->instructor_role ) ) { |
| 130 | $course_type = tutor()->course_post_type; |
| 131 | ?> |
| 132 | <?php |
| 133 | /** |
| 134 | * Render create course button based on free & pro |
| 135 | * |
| 136 | * @since v2.0.7 |
| 137 | */ |
| 138 | if ( function_exists( 'tutor_pro' ) ) : |
| 139 | ?> |
| 140 | <?php do_action( 'tutor_course_create_button' ); ?> |
| 141 | <?php else : ?> |
| 142 | <a href="#" class="tutor-btn tutor-btn-outline-primary tutor-create-new-course"> |
| 143 | <i class="tutor-icon-plus-square tutor-my-n4 tutor-mr-8"></i> |
| 144 | <?php esc_html_e( 'New Course', 'tutor' ); ?> |
| 145 | </a> |
| 146 | <?php endif; ?> |
| 147 | <?php |
| 148 | } elseif ( 'pending' === $instructor_status ) { |
| 149 | $on = get_user_meta( $user->ID, '_is_tutor_instructor', true ); |
| 150 | $on = gmdate( 'd F, Y', $on ); |
| 151 | echo '<span style="' . esc_attr( $info_message_style ) . '"> |
| 152 | <i class="dashicons dashicons-info tutor-color-warning" style=" ' . esc_attr( $info_style ) . '"></i>', |
| 153 | esc_html__( 'Your Application is pending as of', 'tutor' ), ' <b>', esc_html( $on ), '</b>', |
| 154 | '</span>'; |
| 155 | } elseif ( $rejected_on || 'blocked' !== $instructor_status ) { |
| 156 | echo $become_button; //phpcs:ignore --data escaped above |
| 157 | } |
| 158 | ?> |
| 159 | </div> |
| 160 | </div> |
| 161 | </div> |
| 162 | |
| 163 | <div class="tutor-row tutor-frontend-dashboard-maincontent"> |
| 164 | <div class="tutor-col-12 tutor-col-md-4 tutor-col-lg-3 tutor-dashboard-left-menu"> |
| 165 | <ul class="tutor-dashboard-permalinks"> |
| 166 | <?php |
| 167 | $dashboard_pages = tutor_utils()->tutor_dashboard_nav_ui_items(); |
| 168 | // get reviews settings value. |
| 169 | $disable = ! get_tutor_option( 'enable_course_review' ); |
| 170 | foreach ( $dashboard_pages as $dashboard_key => $dashboard_page ) { |
| 171 | /** |
| 172 | * If not enable from settings then quit |
| 173 | * |
| 174 | * @since v2.0.0 |
| 175 | */ |
| 176 | if ( $disable && 'reviews' === $dashboard_key ) { |
| 177 | continue; |
| 178 | } |
| 179 | |
| 180 | $menu_title = $dashboard_page; |
| 181 | $menu_link = tutor_utils()->get_tutor_dashboard_page_permalink( $dashboard_key ); |
| 182 | $separator = false; |
| 183 | $menu_icon = ''; |
| 184 | |
| 185 | if ( is_array( $dashboard_page ) ) { |
| 186 | $menu_title = tutor_utils()->array_get( 'title', $dashboard_page ); |
| 187 | $menu_icon_name = tutor_utils()->array_get( 'icon', $dashboard_page, ( isset( $dashboard_page['icon'] ) ? $dashboard_page['icon'] : '' ) ); |
| 188 | if ( $menu_icon_name ) { |
| 189 | $menu_icon = "<span class='{$menu_icon_name} tutor-dashboard-menu-item-icon'></span>"; |
| 190 | } |
| 191 | // Add new menu item property "url" for custom link. |
| 192 | if ( isset( $dashboard_page['url'] ) ) { |
| 193 | $menu_link = $dashboard_page['url']; |
| 194 | } |
| 195 | if ( isset( $dashboard_page['type'] ) && 'separator' === $dashboard_page['type'] ) { |
| 196 | $separator = true; |
| 197 | } |
| 198 | } |
| 199 | if ( $separator ) { |
| 200 | echo '<li class="tutor-dashboard-menu-divider"></li>'; |
| 201 | if ( $menu_title ) { |
| 202 | ?> |
| 203 | <li class='tutor-dashboard-menu-divider-header'> |
| 204 | <?php echo esc_html( $menu_title ); ?> |
| 205 | </li> |
| 206 | <?php |
| 207 | } |
| 208 | } else { |
| 209 | $li_class = "tutor-dashboard-menu-{$dashboard_key}"; |
| 210 | if ( 'index' === $dashboard_key ) { |
| 211 | $dashboard_key = ''; |
| 212 | } |
| 213 | $active_class = $dashboard_key == $dashboard_page_slug ? 'active' : ''; |
| 214 | $data_no_instant = 'logout' == $dashboard_key ? 'data-no-instant' : ''; |
| 215 | $menu_link = apply_filters( 'tutor_dashboard_menu_link', $menu_link, $menu_title ); |
| 216 | ?> |
| 217 | <li class='tutor-dashboard-menu-item <?php echo esc_attr( $li_class . ' ' . $active_class ); ?>'> |
| 218 | <a <?php echo esc_html( $data_no_instant ); ?> href="<?php echo esc_url( $menu_link ); ?>" class='tutor-dashboard-menu-item-link tutor-fs-6 tutor-color-black'> |
| 219 | <?php |
| 220 | echo wp_kses( |
| 221 | $menu_icon, |
| 222 | tutor_utils()->allowed_icon_tags() |
| 223 | ); |
| 224 | ?> |
| 225 | <span class='tutor-dashboard-menu-item-text tutor-ml-12'> |
| 226 | <?php echo esc_html( $menu_title ); ?> |
| 227 | </span> |
| 228 | </a> |
| 229 | </li> |
| 230 | <?php |
| 231 | } |
| 232 | } |
| 233 | ?> |
| 234 | </ul> |
| 235 | </div> |
| 236 | |
| 237 | <div class="tutor-col-12 tutor-col-md-8 tutor-col-lg-9"> |
| 238 | <div class="tutor-dashboard-content"> |
| 239 | <?php |
| 240 | |
| 241 | if ( $dashboard_page_name ) { |
| 242 | do_action( 'tutor_load_dashboard_template_before', $dashboard_page_name ); |
| 243 | |
| 244 | /** |
| 245 | * Load dashboard template part from other location |
| 246 | * |
| 247 | * This filter is basically added for adding templates from respective addons |
| 248 | * |
| 249 | * @since version 1.9.3 |
| 250 | */ |
| 251 | $other_location = ''; |
| 252 | $from_other_location = apply_filters( 'load_dashboard_template_part_from_other_location', $other_location ); |
| 253 | |
| 254 | if ( '' == $from_other_location ) { |
| 255 | tutor_load_template( 'dashboard.' . $dashboard_page_name ); |
| 256 | } else { |
| 257 | // Load template from other location full abspath. |
| 258 | include_once $from_other_location; |
| 259 | } |
| 260 | |
| 261 | do_action( 'tutor_load_dashboard_template_after', $dashboard_page_name ); |
| 262 | } else { |
| 263 | tutor_load_template( 'dashboard.dashboard' ); |
| 264 | } |
| 265 | ?> |
| 266 | </div> |
| 267 | </div> |
| 268 | </div> |
| 269 | </div> |
| 270 | <div id="tutor-dashboard-footer-mobile"> |
| 271 | <div class="tutor-container"> |
| 272 | <div class="tutor-row"> |
| 273 | <?php foreach ( $footer_links as $link_item ) : ?> |
| 274 | <a class="tutor-col-4 <?php echo $link_item['is_active'] ? 'active' : ''; ?>" href="<?php echo esc_url( $link_item['url'] ); ?>"> |
| 275 | <i class="<?php echo esc_attr( $link_item['icon_class'] ); ?>"></i> |
| 276 | <span><?php echo esc_html( $link_item['title'] ); ?></span> |
| 277 | </a> |
| 278 | <?php endforeach; ?> |
| 279 | </div> |
| 280 | </div> |
| 281 | </div> |
| 282 | </div> |
| 283 | |
| 284 | <?php do_action( 'tutor_dashboard/after/wrap' ); ?> |
| 285 | |
| 286 | <?php |
| 287 | if ( ! $is_by_short_code && ! defined( 'OTLMS_VERSION' ) ) { |
| 288 | tutor_utils()->tutor_custom_footer(); |
| 289 | } |
| 290 |