Skip to content

Instantly share code, notes, and snippets.

@tonykwon
Created November 3, 2014 20:24
Show Gist options
  • Save tonykwon/405251858843e9cfefb2 to your computer and use it in GitHub Desktop.
Save tonykwon/405251858843e9cfefb2 to your computer and use it in GitHub Desktop.
Customizing admin menus which are created by Wordpress MVC plugin
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