Created
November 3, 2014 20:24
-
-
Save tonykwon/405251858843e9cfefb2 to your computer and use it in GitHub Desktop.
Customizing admin menus which are created by Wordpress MVC plugin
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
bootstrap.php | |
MvcConfiguration::append(array( | |
'AdminPages' => array( | |
'flakes' => array( | |
'add', | |
'other1', | |
), | |
) | |
)); | |
function my_modify_menu_pages() { | |
//remove original automatically created top menu item | |
remove_menu_page('mvc_things'); | |
$controller = 'things'; //other controllers name | |
$action = 'manage'; //action name | |
$class = 'admin_' . $controller; | |
$method = $controller . '_' . $action; | |
//get MVC dispatcher | |
$dispatcher = new MvcDispatcher(); | |
if (!method_exists($dispatcher, $method)) { | |
$dispatcher->{$method} = create_function( | |
'', | |
'MvcDispatcher::dispatch(array("controller" => "' . | |
$class . '", "action" => "' . $action .'"));' | |
); | |
} | |
add_submenu_page( | |
'mvc_flakes', | |
'Things', | |
'Things', | |
'administrator', | |
'mvc_' . $controller . '-' . $method, | |
array($dispatcher, $method) | |
); | |
} | |
add_action( 'admin_menu', 'my_modify_menu_pages' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment