#23767 closed enhancement (wontfix)
remove_menu_page: Check for existing menu items
Reported by: | sergej.mueller | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.5 |
Component: | Warnings/Notices | Keywords: | has-patch |
Focuses: | Cc: |
Description
This error appears in my error log:
PHP Warning: Invalid argument supplied for foreach() in /www/htdocs/wp-admin/includes/plugin.php on line 1290
The if-empty patch is attached.
Attachments (1)
Change History (9)
Note: See
TracTickets for help on using
tickets.
Looks like there are only three ways to get this warning:
remove_menu_page()
after the admin is fully loaded, but before$menu
global is set up, e.g. by hooking intoauth_redirect
action instead ofadmin_menu
, which goes against the Codex example: http://codex.wordpress.org/Function_Reference/remove_menu_page.remove_menu_page()
on theadmin_init
hook instead ofadmin_menu
. As noted in #19937,admin_init
fires in some situations where there is no UI for which a menu will be built.$menu
global at some point.These are all developer errors, so the developer should see the warning.