[wp-trac] [WordPress Trac] #54026: One admin menu item from different plugins

WordPress Trac noreply at wordpress.org
Fri Aug 27 14:43:43 UTC 2021


#54026: One admin menu item from different plugins
----------------------------+-----------------------------
 Reporter:  kimjo           |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Administration  |    Version:
 Severity:  normal          |   Keywords:
  Focuses:  administration  |
----------------------------+-----------------------------
 Hello.

 In this example i have two plugins (which cannot be merged) which should
 use one admin menu item.

 plugin 1:
 {{{
 function test1_admin_menu() {

     add_menu_page("Test Plugin", "Test Item", "manage_options", "test-
 plugin-admin");

     add_submenu_page("test-plugin-admin", "", "Subitem for plugin 1",
 "manage_options", "test1-admin-subitem");

     // remove the automatically created submenu
     remove_submenu_page("test-plugin-admin", "test-plugin-admin");

 }

 add_action("admin_menu", "test1_admin_menu");
 }}}

 plugin 2:

 {{{
 function test2_admin_menu() {

     add_menu_page("Test Plugin", "Test Item", "manage_options", "test-
 plugin-admin");

     add_submenu_page("test-plugin-admin", "", "Subitem for plugin 2",
 "manage_options", "test2-admin-subitem");

     // remove the automatically created submenu
     remove_submenu_page("test-plugin-admin", "test-plugin-admin");

 }

 add_action("admin_menu", "test2_admin_menu");
 }}}

 This works - and the menu is also shown, if only one plugin is
 active/enabled.

 BUT:
 The menu "Test Item" in the admin backend is shown twice. Same ID in HTML,
 same subitems, same links, same names ... completly copied.

 Is there a way to avoid that behaviour ?

 I will use a clean admin menu and all my plugins should use one (own)
 admin menu item as parent.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54026>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list