[wp-trac] [WordPress Trac] #47690: remove_submenu_page() doesn't remove corresponding entry from $_wp_submenu_nopriv

WordPress Trac noreply at wordpress.org
Sun Jul 28 10:11:46 UTC 2019


#47690: remove_submenu_page() doesn't remove corresponding entry from
$_wp_submenu_nopriv
----------------------------+-----------------------------
 Reporter:  johnbillion     |       Owner:  (none)
     Type:  defect (bug)    |      Status:  new
 Priority:  normal          |   Milestone:  5.3
Component:  Administration  |     Version:
 Severity:  normal          |  Resolution:
 Keywords:  has-patch       |     Focuses:  administration
----------------------------+-----------------------------
Changes (by donmhico):

 * keywords:  needs-patch => has-patch


Comment:

 On my attachment
 [https://core.trac.wordpress.org/attachment/ticket/47690/47690.diff
 47690.diff], you'll notice on line 1715

 {{{#!php
 remove_all_actions( $hookname );
 }}}

 This is to reciprocate the code from line 1360 of the function
 `add_submenu_page()`.

 I'm not sure if `remove_all_actions( $hookname )` is the best solution. If
 the `$hookname` from the code

 {{{#!php
 $hookname = get_plugin_page_hookname( $menu_slug, $parent_slug );
 }}}

 is unique for the `add_submenu_page()` then I suppose there's no harm
 using `remove_all_actions( $hookname )`. If it's not then we do need to
 somehow hold the `$function` passed on `add_submenu_page()` and use
 `remove_action( $hookname, $function )` instead.

 Another thing is, I changed the variable names passed on
 `remove_submenu_page()` from `$menu_slug` and `$submenu_slug` to
 `$parent_slug` and `$menu_slug` to make it consistent with the variable
 names used on `add_submenu_page()`.

 References:
 https://developer.wordpress.org/reference/functions/add_submenu_page/
 https://codex.wordpress.org/Function_Reference/remove_all_actions
 https://codex.wordpress.org/Function_Reference/remove_action.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/47690#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list