header.php
5 days ago
profile-completion.php
5 days ago
quiz-attempt-row.php
5 days ago
sidebar-nav-mobile.php
5 days ago
sidebar.php
5 days ago
sidebar-nav-mobile.php
162 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Tutor dashboard nav mobile. |
| 4 | * |
| 5 | * @package Tutor\Templates |
| 6 | * @author Themeum <support@themeum.com> |
| 7 | * @link https://www.themeum.com/ |
| 8 | * @since 4.0.0 |
| 9 | */ |
| 10 | |
| 11 | defined( 'ABSPATH' ) || exit; |
| 12 | |
| 13 | use Tutor\Components\Avatar; |
| 14 | use Tutor\Components\Constants\Size; |
| 15 | use TUTOR\Icon; |
| 16 | use Tutor\Components\SvgIcon; |
| 17 | use TUTOR\Dashboard; |
| 18 | |
| 19 | if ( ! tutor_utils()->count( $dashboard_pages ) ) { |
| 20 | return; |
| 21 | } |
| 22 | |
| 23 | $active_nav = ''; |
| 24 | $visible_nav_items = array_slice( $dashboard_pages, 0, 2, true ); |
| 25 | $more_nav_items = array_slice( $dashboard_pages, 2, null, true ); |
| 26 | |
| 27 | // Insert the Explore link after the first visible navigation item. |
| 28 | $explore_nav_item = array( |
| 29 | 'title' => __( 'Explore', 'tutor' ), |
| 30 | 'icon' => Icon::EXPLORE, |
| 31 | 'url' => tutor_utils()->course_archive_page_url(), |
| 32 | ); |
| 33 | |
| 34 | $visible_nav_items = array_slice( $visible_nav_items, 0, 1, true ) + |
| 35 | array( 'explore' => $explore_nav_item ) + |
| 36 | array_slice( $visible_nav_items, 1, null, true ); |
| 37 | |
| 38 | ?> |
| 39 | <div class="tutor-dashboard-nav-mobile" role="navigation"> |
| 40 | <ul class="tutor-dashboard-nav-mobile-list"> |
| 41 | <?php |
| 42 | foreach ( $visible_nav_items as $key => $item ) { |
| 43 | if ( 'index' === $key ) { |
| 44 | $key = ''; |
| 45 | } |
| 46 | |
| 47 | $menu_title = $item; |
| 48 | $menu_link = tutor_utils()->get_tutor_dashboard_page_permalink( $key ); |
| 49 | |
| 50 | if ( is_array( $item ) ) { |
| 51 | $menu_title = tutor_utils()->array_get( 'title', $item ); |
| 52 | $menu_icon_name = tutor_utils()->array_get( 'icon', $item, ( isset( $item['icon'] ) ? $item['icon'] : '' ) ); |
| 53 | $active_icon_name = tutor_utils()->array_get( 'active_icon', $item, ( isset( $item['active_icon'] ) ? $item['active_icon'] : $menu_icon_name ) ); |
| 54 | |
| 55 | // Add new menu item property "url" for custom link. |
| 56 | if ( isset( $item['url'] ) ) { |
| 57 | $menu_link = $item['url']; |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | $is_active_menu = $key === $dashboard_page_slug; |
| 62 | $active_class = $is_active_menu ? 'active' : ''; |
| 63 | $menu_link = apply_filters( 'tutor_dashboard_menu_link', $menu_link, $menu_title ); |
| 64 | ?> |
| 65 | <li> |
| 66 | <a class="<?php echo esc_attr( $active_class ); ?>" href="<?php echo esc_url( $menu_link ?? '#' ); ?>"> |
| 67 | <span class="tutor-dashboard-nav-mobile-icon"> |
| 68 | <?php |
| 69 | SvgIcon::make() |
| 70 | ->name( ( $is_active_menu && ! tutor_utils()->is_kids_mode() ) ? $active_icon_name : $menu_icon_name ) |
| 71 | ->size( Size::SIZE_20 ) |
| 72 | ->render(); |
| 73 | ?> |
| 74 | </span> |
| 75 | <span class="tutor-tiny tutor-dashboard-nav-mobile-text"><?php echo esc_html( $menu_title ); ?></span> |
| 76 | </a> |
| 77 | </li> |
| 78 | <?php |
| 79 | } |
| 80 | ?> |
| 81 | <li> |
| 82 | <a href="<?php echo esc_url( Dashboard::get_account_page_url( 'profile' ) ); ?>"> |
| 83 | <div class="tutor-dashboard-nav-mobile-icon"> |
| 84 | <?php |
| 85 | Avatar::make() |
| 86 | ->user( get_current_user_id() ) |
| 87 | ->size( Size::SIZE_20 ) |
| 88 | ->render(); |
| 89 | ?> |
| 90 | </div> |
| 91 | <span class="tutor-tiny tutor-dashboard-nav-mobile-text"><?php esc_html_e( 'Profile', 'tutor' ); ?></span> |
| 92 | </a> |
| 93 | </li> |
| 94 | <?php |
| 95 | if ( tutor_utils()->count( $more_nav_items ) ) : |
| 96 | ?> |
| 97 | <li x-data="tutorPopover({ placement: 'top-end', offset: 16 })"> |
| 98 | <button |
| 99 | type="button" |
| 100 | x-ref="trigger" |
| 101 | @click="toggle()" |
| 102 | :aria-expanded="open ? 'true' : 'false'" |
| 103 | aria-haspopup="true" |
| 104 | > |
| 105 | <span class="tutor-dashboard-nav-mobile-icon"> |
| 106 | <?php SvgIcon::make()->name( Icon::ELLIPSES )->size( 20 )->render(); ?> |
| 107 | </span> |
| 108 | <span class="tutor-tiny tutor-dashboard-nav-mobile-text"><?php esc_html_e( 'More', 'tutor' ); ?></span> |
| 109 | </button> |
| 110 | <!-- Popover panel --> |
| 111 | <div |
| 112 | x-ref="content" |
| 113 | x-show="open" |
| 114 | x-cloak |
| 115 | @click.outside="handleClickOutside()" |
| 116 | class="tutor-popover tutor-dashboard-nav-mobile-more-popover" |
| 117 | role="menu" |
| 118 | aria-label="<?php echo esc_attr( $item['title'] ); ?>" |
| 119 | x-transition.origin.bottom.right |
| 120 | > |
| 121 | <ul> |
| 122 | <?php |
| 123 | foreach ( $more_nav_items as $key => $item ) { |
| 124 | $menu_title = $item; |
| 125 | $menu_link = tutor_utils()->get_tutor_dashboard_page_permalink( $key ); |
| 126 | |
| 127 | if ( is_array( $item ) ) { |
| 128 | $menu_title = tutor_utils()->array_get( 'title', $item ); |
| 129 | $menu_icon_name = tutor_utils()->array_get( 'icon', $item, ( isset( $item['icon'] ) ? $item['icon'] : '' ) ); |
| 130 | $active_icon_name = tutor_utils()->array_get( 'active_icon', $item, ( isset( $item['active_icon'] ) ? $item['active_icon'] : $menu_icon_name ) ); |
| 131 | |
| 132 | // Add new menu item property "url" for custom link. |
| 133 | if ( isset( $item['url'] ) ) { |
| 134 | $menu_link = $item['url']; |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | $is_active_menu = $key === $dashboard_page_slug; |
| 139 | $active_class = $is_active_menu ? 'active' : ''; |
| 140 | $menu_link = apply_filters( 'tutor_dashboard_menu_link', $menu_link, $menu_title ); |
| 141 | ?> |
| 142 | <li role="none"> |
| 143 | <a role="menuitem" class="<?php echo esc_attr( $active_class ); ?>" href="<?php echo esc_url( $menu_link ?? '#' ); ?>" @click="open = false"> |
| 144 | <?php |
| 145 | SvgIcon::make() |
| 146 | ->name( ( $is_active_menu && ! tutor_utils()->is_kids_mode() ) ? $active_icon_name : $menu_icon_name ) |
| 147 | ->size( tutor_utils()->is_kids_mode() ? Size::SIZE_24 : Size::SIZE_20 ) |
| 148 | ->render(); |
| 149 | ?> |
| 150 | <span class="tutor-tiny"><?php echo esc_html( $menu_title ); ?></span> |
| 151 | </a> |
| 152 | </li> |
| 153 | <?php |
| 154 | } |
| 155 | ?> |
| 156 | </nav> |
| 157 | </div> |
| 158 | </li> |
| 159 | <?php endif ?> |
| 160 | </ul> |
| 161 | </div> |
| 162 |