You can manipulate the global variable $submenu
and change that there (we also have the variable $menu
, but it has no use here):
add_action( 'admin_menu', function()
{
add_menu_page(
'Gallery',
__('Gallery', 'Galleries'),
'manage_options',
'gallery',
function(){ echo '<h1>Principal</h1>'; }
);
add_submenu_page(
'gallery',
'My Custom Page',
'My Custom Page',
'manage_options',
'slug-1',
function(){ echo '<h2>Segundo</h2>'; }
);
add_submenu_page(
'gallery',
'My Custom Submenu Page',
'My Custom Submenu Page',
'manage_options',
'slug-2',
function(){ echo '<h2>Terceiro</h2>'; }
);
// Trocar o nome de um submenu
global $submenu;
$submenu['gallery'][0][0] = 'Galerias';
});
And here, a var_dump
of the variable (summarised):
Array (
[index.php] => Array (
[0] => Array (
[0] => Home
[1] => read
[2] => index.php
)
[10] => Array (
[0] => Updates <span class='update-plugins count-5' title='4 Plugin Updates, 1 Theme Update'><span class='update-count'>5</span></span>
[1] => update_core
[2] => update-core.php
)
)
[edit.php] => Array ( [...etc...] )
[upload.php] => Array ( [...etc...] )
[edit.php?post_type=page] => Array ( [...etc...] )
[edit-comments.php] => Array ( [...etc...] )
[themes.php] => Array ( [...etc...] )
[plugins.php] => Array ( [...etc...] )
[users.php] => Array ( [...etc...] )
[tools.php] => Array ( [...etc...] )
[options-general.php] => Array ( [...etc...] )
[gallery] => Array (
[0] => Array (
[0] => Gallery
[1] => manage_options
[2] => gallery
[3] => Gallery
[4] => menu-top menu-icon-generic toplevel_page_gallery
[5] => toplevel_page_gallery
[6] => none
)
[1] => Array (
[0] => My Custom Page
[1] => manage_options
[2] => slug-1
[3] => My Custom Page
)
[2] => Array (
[0] => My Custom Submenu Page
[1] => manage_options
[2] => slug-2
[3] => My Custom Submenu Page
)
)
)