Make WordPress Core

Opened 11 years ago

Closed 8 years ago

#23836 closed defect (bug) (wontfix)

add_submenu_page() duplicate menus

Reported by: king_of_the_ring's profile king_of_the_ring Owned by:
Milestone: Priority: normal
Severity: minor Version:
Component: Administration Keywords: needs-patch
Focuses: Cc:

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)

#1 @SergeyBiryukov
11 years ago

  • Component changed from Menus to Administration

#2 @nacin
11 years ago

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.

#3 @mordauk
10 years ago

  • Severity changed from major to 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?

#4 @chriscct7
8 years ago

  • Keywords needs-patch added
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Closing as wontfix. Complete lack of interest on the ticket over the last 2 years. Feel free to reopen when more interest re-emerges (particularly if there's a patch)

Note: See TracTickets for help on using tickets.