Skip to content

Instantly share code, notes, and snippets.

@mavinothkumar
Last active September 3, 2021 11:45
Show Gist options
  • Save mavinothkumar/e24b231b052dc37ef2925007729e9fdc to your computer and use it in GitHub Desktop.
Save mavinothkumar/e24b231b052dc37ef2925007729e9fdc to your computer and use it in GitHub Desktop.
Multiple Custom Menu
/**
* From Frontend Dashboard version 1.2
*/
add_filter( 'fed_add_custom_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'] = array(
'id' => 999, //Some Random number
'menu_slug' => 'custom', //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
);
$custom['custom_2'] = array(
'id' => 99, //Some Random number
'menu_slug' => 'custom_2', //Menu Slug
'menu' => 'Custom Menu 2', //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' ) {
?>
<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
}
if ( isset($menu_items['menu_request']['menu_slug']) && $menu_items['menu_request']['menu_slug'] === 'custom_2' ) {
?>
<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 2
</h3>
</div>
<div class="panel-body">
<!-- You custom code here-->
Custom Menu 2 Code Here
</div>
</div>
<?php
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment