Created
August 24, 2018 22:33
-
-
Save Blair2004/4bd212f3b61a1af12580b897f765a30c to your computer and use it in GitHub Desktop.
How to create a menu for a module
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 | |
class MyModule extends Tendoo_Module // should alway extends Tendoo module | |
{ | |
public function __construct() | |
{ | |
parent::__construct(); | |
$this->events->add_filter( 'admin_menus', [ $this, 'menus' ]); | |
} | |
/** | |
* register Menu | |
* @param array menu | |
* @return array | |
**/ | |
public function menus( $menus ) | |
{ | |
// menu should have a namespace | |
$menus[ 'mymenu' ] = [ | |
[ | |
'title' => __( 'Custom Menu' ), | |
'href' => '#', // it can be something else using site_url(), | |
// 'permission' => [ 'custom.permision' ], // optional to hide the menu if the use doesn't have the required permission. | |
//You should comment this section if the permission has not yet been created | |
'icon' => 'fa fa-home', // font awesome icon are supported | |
] | |
]; | |
return $menus | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment