-
Notifications
You must be signed in to change notification settings - Fork 585
Description
Hello, I noticed strange behaviour with parent_page and 'menu_type' => 'submenu'.
Redux-Framework Version: 3.3.6
Using Redux as: Plugin
Wordpress Version: 3.9
'dev_mode' => true,
Browser console errors: None
Builder TGM Settings: Embed only
In detail I was trying to add the settings as submenu to my plugin.
add_plugin_menu() {
add_menu_page(
__('Plugin Title', 'plugin'),
__('Plugin Title', 'plugin'),
'administrator',
'my_plugin_dashboard',
array($this, 'Dashboard'),
$pluginIcon
);
}
add_action('admin_menu', array( $this, 'add_plugin_menu' ) );
My args look like this:
'page_slug' => 'my_plugin_settings',
'page_title' => 'Settings'
'menu_type' => 'submenu',
'page_parent' => 'my_plugin_dashboard',
I think this is the most simple setup to add the settings as submenu. But this is not working for me because the menu doesn't appear!
To get it working I need to add at least one submenu manually:
So lets add it -
add_submenu_page(
'my_plugin_dashboard',
null,
'Im a silly dummy entry',
'administrator',
'dummy',
'__return_null'
);
After adding at least one submenu item that's the content of $submenu at the entry of add_submenu():
...
[my_plugin_dashboard] => Array
(
[0] => Array
(
[0] => Plugin Title
[1] => administrator
[2] => my_plugin_dashboard
[3] => Plugin Title
[4] => menu-top toplevel_page_my_plugin_dashboard
[5] => toplevel_page_my_plugin_dashboard
[6] => dashicons-email-alt
)
[1] => Array
(
[0] => Im a silly dummy entry
[1] => administrator
[2] => dummy
[3] =>
)
)
As you can see now there is the key 'my_plugin_dashboard' <=> $this->args['page_parent'] and so obviously the custom menu case (see below) is true.
If there is no submenu at all global $submenu doesn't contain information ( no key $this->args['page_parent'] although there is a menu but with no submenus ) about the submenu and
// framework.php -> add_submenu()
// custom menu
} elseif ( isset( $submenu[ $this->args['page_parent'] ] ) ) {
$addMenu = true;
}
is never true.
I'm doing it wrong?
Please tell me if you need further details.
PS: global $menu contains the actually menu at any time but in fancy format (guess with priority as key):
...
[100] => Array
(
[0] => Plugin Title
[1] => administrator
[2] => my_plugin_dashboard
[3] => Plugin Title
[4] => menu-top toplevel_page_my_plugin_dashboard
[5] => toplevel_page_my_plugin_dashboard
[6] => dashicons-email-alt
)