Opened 14 years ago
Closed 11 years ago
#23836 closed defect (bug) (wontfix)
add_submenu_page() duplicate menus
| Reported by: | king_of_the_ring | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Administration | Version: | |
| Severity: | minor | Keywords: | needs-patch |
| Cc: | Focuses: |
Description
Creating two sub-menus with the same "menu slug" using add_submenu_page() should create only the last sub-menu.
But it creates two sub-menus with the same "menu slug".
Based on documentation "menu slug" should be unique for each sub-menu.
Change History (4)
#3
@
13 years ago
- Severity major → minor
While it really doesn't seem to cause any issues having duplicate pages, it does seem a bit odd to me that duplicate sub menu items are allowed.
function test_add_duplicate_menu_page() {
add_submenu_page( 'plugins.php', 'Test', 'Test', 'manage_options', 'my-test-page', '__return_null' );
add_submenu_page( 'plugins.php', 'Test', 'Test', 'manage_options', 'my-test-page', '__return_null' );
}
add_action( 'admin_menu', 'test_add_duplicate_menu_page' );
That, for example, will register two "Test" submenu items that both point to the same page.
Is it an issue? I don't really think so but it is a bit odd. What if we prevented the second one from being added (or replaced the first) if all arguments are the same?
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
While it should be unique, I don't think the behavior you're seeing is necessarily a bug. The function is "add", not "update". If you want to replace a menu, remove it then add it.