dozent_render_dashboard_menu( bool $echo = true )
Render Dashboard Menu
Parameters
- $echo
-
(bool) (Optional)
Default value: true
Return
(mixed|string|void)
Source
File: includes/core-functions.php
function dozent_render_dashboard_menu( $echo = true ) { $is_instructor_approved = dozent_is_instructor_approved(); $sidebar_pages = dozent_dashboard_permalinks(); //Is menu closed by user $is_menu_closed = dozent_user_data()->get( 'dashboard_sidebar_status' ); $hide_group_name = ( $is_menu_closed === 'closed' ); global $wp_query; $dashboard_page_slug = ''; if ( isset( $wp_query->query_vars['dozent_dashboard_page'] ) && $wp_query->query_vars['dozent_dashboard_page'] ) { $dashboard_page_slug = $wp_query->query_vars['dozent_dashboard_page']; } $output = '<div class="dashboard-side-menu-container">'; foreach ( $sidebar_pages as $group_index => $item_group ) { $group_name = dozent_array_get( 'group_name', $item_group ); $cap = dozent_array_get( 'cap', $item_group ); if ( $cap && ! current_user_can( $cap ) ) { continue; } //Group Naming in the menu $group_header_name = ''; if ( $group_name ){ $group_display = 'block'; if ( $hide_group_name ){ $group_display = 'none'; } $group_header_name = "<li class='menu-group-header dashboard-menu-item' style='display: {$group_display};' > <a href='javascript:;'> {$group_name} </a> </li>"; } $output .= "<ul class='dozent-dashboard-sidebar-menu dashboard-menu-group dashboard-menu-group-{$group_index}'>"; $output .= $group_header_name; foreach ( $item_group as $item ) { if ( ! is_array( $item ) ) { continue; } $cap_not = dozent_array_get( 'cap_not', $item ); if ( ! empty( $cap_not ) && current_user_can( $cap ) ){ continue; } $should_show = ! dozent_array_get( 'guest_item', $item ); $instructor_item = dozent_array_get( 'instructor_item', $item ); if ( $should_show ) { $should_show = ! dozent_array_get( 'hide_ui', $item ); } if ( $should_show && $instructor_item ) { if ( ! $is_instructor_approved ) { $should_show = false; } } $should_show = apply_filters( 'dozent_dashboard_item_should_show', $should_show, $item ); if ( ! $should_show ) { continue; } $id = dozent_array_get( 'id', $item ); $title = dozent_array_get( 'title', $item ); $url = dozent_array_get( 'url', $item ); $icon_class = dozent_array_get( 'icon_class', $item ); if ( ! $icon_class ) { $icon_class = 'dicon-cog'; } $menu_icon = "<i class='{$icon_class}'></i>"; if ( ! $url ) { $url = dozent_get_dashboard_permalink( $id ); } //Menu Item Class in Array $menu_item_classes = [ "dashboard-menu-item", "dashboard-menu-item-{$id}", ]; if ( $id == $dashboard_page_slug ) { $menu_item_classes[] = 'active'; } $menu_item_class_arr = apply_filters( 'dozent_dashboard_menu_item_classes', $menu_item_classes, $item ); $menu_class = implode( ' ', $menu_item_class_arr ); $tooltip = dozent_tooltips( $title, 'right', false ); $output .= "<li class='{$menu_class}'>"; $output .= "<a href='{$url}' class='menu-item-{$id}' {$tooltip} > {$menu_icon} <span class='dashboard-menu-title'>{$title}</span> </a>"; $output .= "</li>"; } $output .= "</ul>"; } $output .= "</div>"; $output = apply_filters( 'dozent_render_dashboard_menu', $output, $sidebar_pages ); if ( $echo ) { echo $output; } return $output; }
Changelog
Version | Description |
---|---|
DozentLMS 1.0.0 | Introduced. |