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.0 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / templates / dashboard / components / header.php
tutor / templates / dashboard / components Last commit date
header.php 1 day ago profile-completion.php 1 day ago quiz-attempt-row.php 1 day ago sidebar-nav-mobile.php 1 day ago sidebar.php 1 day ago
header.php
273 lines
1 <?php
2 /**
3 * Tutor dashboard header.
4 * Reusable component for displaying the dashboard header.
5 *
6 * @package Tutor\Templates
7 * @author Themeum <support@themeum.com>
8 * @link https://themeum.com
9 * @since 4.0.0
10 */
11
12 defined( 'ABSPATH' ) || exit;
13
14 use Tutor\Components\Avatar;
15 use Tutor\Components\Button;
16 use Tutor\Components\Constants\Size;
17 use Tutor\Components\Constants\Variant;
18 use TUTOR\Dashboard;
19 use Tutor\Components\SvgIcon;
20 use Tutor\Components\Constants\Color;
21 use TUTOR\Icon;
22 use TUTOR\Instructors_List;
23 use TUTOR\User;
24 use Tutor\Models\CourseModel;
25
26 $menu_items = Dashboard::get_account_pages();
27 $menu_items['logout'] = array(
28 'title' => esc_html__( 'Logout', 'tutor' ),
29 'icon' => Icon::LOGOUT,
30 'url' => wp_logout_url( tutor_utils()->tutor_dashboard_url() ),
31 );
32
33 $active_nav = '';
34 $user_id = get_current_user_id();
35 $display_name = tutor_utils()->display_name( $user_id );
36 $edit_profile_url = Dashboard::get_account_page_url( 'settings' ) . '?tab=account';
37 $is_become_instructor_enabled = tutor_utils()->get_option( 'enable_become_instructor_btn' );
38
39 $is_instructor_view = User::is_instructor_view();
40 ?>
41
42 <div x-data="tutorHeader()" class="tutor-dashboard-header">
43 <div class="tutor-dashboard-header-inner">
44 <div class="tutor-dashboard-header-left">
45 <div class="tutor-h5 tutor-text-primary tutor-text-medium">
46 <span class="tutor-text-subdued">
47 <?php echo esc_html_x( 'Hi,', 'greetings', 'tutor' ); ?>
48 </span>
49 <?php echo esc_html( $display_name . ' 👋' ); ?>
50 </div>
51 <?php
52 if ( $is_instructor_view ) :
53 $course_post_type = apply_filters( 'tutor_dashboard_course_list_post_type', array( tutor()->course_post_type ) );
54 $active_course_count = CourseModel::get_courses_by_instructor( $user_id, CourseModel::STATUS_PUBLISH, 0, 0, true, $course_post_type, '' );
55 $enrolled_student_count = (int) tutor_utils()->get_total_students_by_instructor( $user_id );
56 ?>
57 <div class="tutor-flex tutor-items-center tutor-gap-2 tutor-tiny">
58 <?php
59 echo wp_kses(
60 sprintf(
61 /* translators: %s is the formatted active course count. */
62 _n(
63 '<span class="tutor-font-medium">%s</span> active course',
64 '<span class="tutor-font-medium">%s</span> active courses',
65 $active_course_count,
66 'tutor'
67 ),
68 esc_html( number_format_i18n( $active_course_count ) )
69 ),
70 array(
71 'span' => array(
72 'class' => true,
73 ),
74 )
75 );
76 ?>
77 <span class="tutor-text-subdued">&bull;</span>
78 <?php
79 echo wp_kses(
80 sprintf(
81 /* translators: %s is the formatted enrolled student count. */
82 _n(
83 '<span class="tutor-font-medium">%s</span> student enrolled',
84 '<span class="tutor-font-medium">%s</span> students enrolled',
85 $enrolled_student_count,
86 'tutor'
87 ),
88 esc_html( number_format_i18n( $enrolled_student_count ) )
89 ),
90 array(
91 'span' => array(
92 'class' => true,
93 ),
94 )
95 );
96 ?>
97 </div>
98 <?php endif; ?>
99 </div>
100 <div class="tutor-dashboard-header-right">
101 <div>
102 <?php
103 // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
104 do_action( 'tutor_dashboard/before_header_button' );
105 ?>
106 </div>
107 <div
108 x-data="tutorPopover({
109 placement: 'bottom-end',
110 offset: 4,
111 })"
112 class="tutor-dashboard-header-user"
113 >
114 <button
115 class="tutor-dashboard-header-user-avatar"
116 x-ref="trigger"
117 @click="toggle()"
118 :class="{ 'active': open }"
119 x-init="$watch('open', value => { if (window.innerWidth <= 768) { document.body.style.overflow = value ? 'hidden' : ''; } })"
120 @resize.window="
121 if (window.innerWidth <= 768 && open) { document.body.style.overflow = open ? 'hidden' : ''; }
122 else if (window.innerWidth >= 768 && open) { document.body.style.overflow = '' }
123 "
124 aria-label="<?php esc_attr_e( 'Open user menu', 'tutor' ); ?>"
125 >
126 <?php Avatar::make()->user( $user_id )->size( Size::SIZE_32 )->render(); ?>
127 <?php
128 SvgIcon::make()
129 ->name( Icon::USER_CIRCLE )
130 ->size( Size::SIZE_20 )
131 ->attr( 'class', 'tutor-hidden tutor-sm-inline-block' )
132 ->render();
133 ?>
134 </button>
135
136 <div
137 x-ref="content"
138 x-show="open"
139 x-cloak
140 @click.outside="handleClickOutside()"
141 x-transition.origin.top.right
142 class="tutor-popover tutor-dashboard-header-user-popover"
143 >
144 <div class="tutor-dashboard-header-user-popover-profile">
145
146 <div class="tutor-profile-header-top tutor-hidden tutor-sm-flex tutor-items-center tutor-px-6 tutor-py-5">
147 <?php
148 Button::make()
149 ->label( __( 'Back', 'tutor' ) )
150 ->variant( Variant::GHOST )
151 ->size( Size::X_SMALL )
152 ->icon( Icon::LEFT, 'left', 20 )
153 ->icon_only()
154 ->flip_rtl()
155 ->attr( '@click', 'hide()' )
156 ->render();
157 ?>
158 <h4 class="tutor-profile-header-title tutor-text-h4 tutor-font-semibold tutor-my-none">
159 <?php esc_html_e( 'Account', 'tutor' ); ?>
160 </h4>
161 <?php
162 Button::make()
163 ->variant( Variant::GHOST )
164 ->size( Size::X_SMALL )
165 ->icon( Icon::SETTING, 'left', 20 )
166 ->tag( 'a' )
167 ->icon_only()
168 ->attr( 'href', esc_url( Dashboard::get_account_page_url( 'settings' ) ) )
169 ->render();
170 ?>
171 </div>
172
173 <div class="tutor-user-profile-info">
174 <?php Avatar::make()->user( $user_id )->size( Size::SIZE_48 )->bordered()->render(); ?>
175 <div class="tutor-user-profile-meta tutor-flex tutor-flex-column tutor-items-center tutor-gap-1">
176 <div class="tutor-text-medium tutor-text-primary tutor-font-semibold">
177 <?php echo esc_html( wp_get_current_user()->display_name ); ?>
178 </div>
179 <div class="tutor-text-tiny tutor-text-secondary">
180 <?php echo esc_html( wp_get_current_user()->user_email ); ?>
181 </div>
182 </div>
183 <a href="<?php echo esc_url( $edit_profile_url ); ?>" class="tutor-btn tutor-btn-ghost tutor-btn-x-small tutor-btn-icon tutor-ml-auto tutor-force-hidden tutor-force-sm-flex">
184 <?php SvgIcon::make()->name( Icon::EDIT_2 )->size( Size::SIZE_20 )->render(); ?>
185 </a>
186 </div>
187
188 <?php
189 if ( ! User::is_instructor( $user_id ) && ! User::is_admin( $user_id ) ) {
190 $instructor_status = tutor_utils()->instructor_status( 0, false );
191 $instructor_status = is_string( $instructor_status ) ? strtolower( $instructor_status ) : '';
192
193 if ( Instructors_List::STATUS_PENDING === $instructor_status ) {
194 $applied_on = get_user_meta( $user_id, '_is_tutor_instructor', true );
195 $applied_on = tutor_i18n_get_formated_date( $applied_on, get_option( 'date_format' ) );
196 ?>
197 <div class="tutor-w-full tutor-sm-px-6">
198 <div class="tutor-flex tutor-items-center tutor-gap-3 tutor-py-2 tutor-px-4 tutor-surface-warning-hover-2 tutor-rounded-sm">
199 <span class="tutor-flex-center">
200 <?php SvgIcon::make()->name( Icon::INFO_OCTAGON )->size( 12 )->color( Color::WARNING )->render(); ?>
201 </span>
202 <span class="tutor-p3 tutor-text-warning ">
203 <?php esc_html_e( 'Application Under Review', 'tutor' ); ?>
204 </span>
205 </div>
206 </div>
207 <?php
208 } elseif ( Instructors_List::STATUS_BLOCKED !== $instructor_status && $is_become_instructor_enabled ) {
209 ?>
210 <div class="tutor-w-full tutor-sm-px-6">
211 <a href="<?php echo esc_url( tutor_utils()->instructor_register_url() ); ?>" class="tutor-btn tutor-btn-primary-soft tutor-btn-x-small tutor-btn-block tutor-profile-switch-button">
212 <?php SvgIcon::make()->name( Icon::INSTRUCTOR )->render(); ?>
213 <?php esc_html_e( 'Become an Instructor', 'tutor' ); ?>
214 </a>
215 </div>
216 <?php
217 }
218 }
219 if ( User::can_switch_mode( $user_id ) ) {
220 $current_mode = User::get_current_view_mode();
221 $button_label = User::VIEW_AS_INSTRUCTOR === $current_mode ? esc_html__( 'Switch to Learner', 'tutor' ) : esc_html__( 'Switch to Instructor', 'tutor' );
222 ?>
223 <div class="tutor-w-full tutor-sm-px-6">
224 <?php
225 Button::make()
226 ->label( $button_label )
227 ->size( Size::X_SMALL )
228 ->variant( Variant::PRIMARY_SOFT )
229 ->icon( Icon::RELOAD_2 )
230 ->block()
231 ->attr( ':disabled', 'profileSwitchMutation?.isPending' )
232 ->attr( ':class', "{ 'tutor-btn-loading': profileSwitchMutation?.isPending }" )
233 ->attr( 'class', 'tutor-profile-switch-button' )
234 ->attr( '@click', "profileSwitchMutation.mutate('{$current_mode}')" )
235 ->render();
236 ?>
237 </div>
238 <?php } ?>
239 </div>
240 <div class="tutor-dashboard-header-user-popover-menu-wrapper">
241 <ul class="tutor-dashboard-header-user-popover-menu">
242 <?php
243 foreach ( $menu_items as $key => $item ) {
244 $icon = ( $key === $active_nav && isset( $item['icon_active'] ) ) ? $item['icon_active'] : $item['icon'];
245 ?>
246 <li>
247 <a href="<?php echo esc_url( $item['url'] ?? '#' ); ?>" class="<?php echo ( $key === $active_nav ) ? 'active' : ''; ?> tutor-small">
248 <?php SvgIcon::make()->name( $icon )->size( 20 )->flip_rtl( 'logout' === $key ? true : false )->render(); ?>
249 <span><?php echo esc_html( $item['title'] ); ?></span>
250 </a>
251 </li>
252 <?php
253 }
254 ?>
255 </ul>
256 <div class="tutor-mobile-logout-wrapper tutor-text-center tutor-px-6 tutor-pb-7 tutor-hidden tutor-sm-block">
257 <?php
258 $logout_btn = $menu_items['logout'] ?? '';
259 if ( ! empty( $logout_btn ) ) :
260 ?>
261 <a href="<?php echo esc_url( $logout_btn['url'] ?? '#' ); ?>" class="tutor-btn tutor-small">
262 <?php SvgIcon::make()->name( $icon )->size( 20 )->render(); ?>
263 <span><?php echo esc_html( $logout_btn['title'] ); ?></span>
264 </a>
265 <?php endif; ?>
266 </div>
267 </div>
268 </div>
269 </div>
270 </div>
271 </div>
272 </div>
273