Last active
January 6, 2019 08:11
-
-
Save mavinothkumar/0ac80b71a93298c1c18275c369092d69 to your computer and use it in GitHub Desktop.
Frontend Dashboard Custom Menu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* From Frontend Dashboard version 1.2 | |
*/ | |
add_filter( 'fed_frontend_main_menu', 'fed_frontend_main_menu_fn' ); | |
add_action( 'fed_frontend_dashboard_menu_container', 'fed_frontend_dashboard_menu_container_fn', 10, 2 ); | |
/** | |
* Create custom main menu | |
* | |
* @param array $custom | |
* | |
* @return array | |
*/ | |
function fed_frontend_main_menu_fn( $custom ) { | |
$custom['custom_menu'] = array( | |
'id' => 99, //Some Random number | |
'menu_slug' => 'custom_menu', //Menu Slug | |
'menu' => 'Custom Menu', //Menu Name | |
'menu_type' => 'custom',//Menu type, please don't change it until you are aware of it | |
'menu_order' => 10, //Menu Order | |
'menu_image_id' => 'fa fa-address-book', //Font Awesome Icon | |
'show_user_profile' => 'Enable', //Show User Profile | |
'extra' => 'yes', // Please don't change this too | |
'user_role' => serialize( array( 'administrator', 'subscriber' ) ), // Allow this user role to access that menu | |
'extended' => '', // Don't change until you are aware of this | |
'menu_key' => '', // Don't change until you are aware of this | |
'menu_value' => '' // Don't change until you are aware of this | |
); | |
return $custom; | |
} | |
/** | |
* Menu Container | |
* | |
* @param $request | |
* @param $menu_items | |
*/ | |
function fed_frontend_dashboard_menu_container_fn( $request, $menu_items) { | |
if ( isset($menu_items['menu_request']['menu_slug']) && $menu_items['menu_request']['menu_slug'] === 'custom_menu' ) { | |
?> | |
<div class="panel panel-primary fed_dashboard_item"> | |
<div class="panel-heading"> | |
<h3 class="panel-title"> | |
<!-- Menu Icon Font ID--> | |
<span class=""></span> | |
<!-- Menu title--> | |
Custom | |
</h3> | |
</div> | |
<div class="panel-body"> | |
<!-- You custom code here--> | |
Custom Code Here | |
</div> | |
</div> | |
<?php | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment