Skip to content

Instantly share code, notes, and snippets.

@Blair2004
Created August 24, 2018 22:48
Show Gist options
  • Select an option

  • Save Blair2004/31f9c983676ea57a07e0cee491646c9f to your computer and use it in GitHub Desktop.

Select an option

Save Blair2004/31f9c983676ea57a07e0cee491646c9f to your computer and use it in GitHub Desktop.

Revisions

  1. Blair2004 created this gist Aug 24, 2018.
    38 changes: 38 additions & 0 deletions HelloWorldModuleMenu3.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    <?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 )
    {
    $menus = array_insert_before( 'dashboard', $menus, 'mymenu', [
    [ // fisrt menu definition
    'title' => __( 'Custom Menu' ),
    'disable' => true, // this will won't be displayed as a child 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
    ], [ // second menu definition
    'title' => __( 'Sub Menu' ),
    'href' => '#',
    'icon' => 'fa fa-home', // icon aren't supported for sub menu
    ], [ // second menu definition
    'title' => __( 'Sub Menu 2' ),
    'href' => '#',
    'icon' => 'fa fa-home', // icon aren't supported for sub menu
    ],
    ]);

    return $menus;
    }
    }