This post is part of the ClassicPress Plugin Development series in which I am going to look at both best practice for developing plugins and how I approach some requirements as well as some of the functions I commonly use.
In the last post I showed how to create a custom top level menu and mentioned it creted both the top level menu and a sublevel menu of the same name.
As the below example, extracted from my To Twitter plugin which adds a submenu to the existing azrcrv-tt menu with a name of Settings. As the first, $parent_slug
, and fifth, $menu_slug
parameters match the top level menu the add_submenu_page
function renames the default first submenu entry:
add_action('admin_menu', 'azrcrv_tt_create_admin_menu');
/**
* Add to menu.
*
* @since 1.0.0
*
*/
function azrcrv_tt_create_admin_menu(){
add_submenu_page(
'azrcrv-tt'
,__('Settings', 'to-twitter')
,__('Settings', 'to-twitter')
,'manage_options'
,'azrcrv-tt'
,'azrcrv_t_display_options');
}
To rename a custom top level menu on a network admin dashboard, change the admin_menu
tag in the add_action
function call to network_admin_menu
.