I'm working on a plugin that constructs a top level menu and resides within its own directory in /wp-content/plugins.
For example, the plugin looks like this:
function main_menu() {
if(function_exists('add_menu_page')) {
add_menu_page('Main Menu Title', 'Main Menu', 'administrator', 'main-menu-handle', 'menu-display');
}
}
add_action('admin_menu', 'main_menu');
I would like to build out additional menu items as plugins in the future so that they may reside in their own directory within /wp-content/plugins but will add themselves to this particular custom menu.
Ideally, these new plugins would register themselves like this:
function register_submenu() {
if(function_exists('add_submenu_page')) {
add_submenu_page('main-menu-handle', 'Widget Title', 'Widget', 'administrator', 'widget-handle', 'widget_display');
}
}
add_action('admin_menu', 'register_submenu');
But I can't seem to make this work mainly because of the way WordPress uses the admin.php and the page query string parameter to navigate custom menus.
Any insight?