I’m working on a plugin that I have to release in parts.
The problem is, if there is a menu in the page then add the new plugin to the 2nd or next submenu else add a new menu and then add the plugin to 1st submenu.
My questions:
- How to check that there exists a menu?
- If I’m coding a reusable function , that will go with every plugin then that causes conflict option.
- I don’t know the order of the plugin release.
add_menu_page(
'Page Title',
'Top Menu Title',
'manage_options',
'my_unique_slug',
'my_magic_function'
);
add_submenu_page(
'my_unique_slug',
'page title',
'submenu title',
'manage_options',
'my_submenu_slug',
'my_magic_function_of_submenu'
);
You can use the fourth parameter of
add_menu_page()
, themy_unique_slug
, to check if the page exists:$GLOBALS['admin_page_hooks']
is the list of registered pages.