[wp-hackers] add_submenu_page() with no parent

Jonathan Brinley jonathanbrinley at gmail.com
Tue Aug 13 12:53:51 UTC 2013


According to the codex (
http://codex.wordpress.org/Function_Reference/add_submenu_page#Parameters)
you can call add_submenu_page() with NULL or options.php as the parent to
create an admin page that doesn't appear in the admin menu. options.php
does, indeed, work for this, and NULL seems to work on multisite, but not
single site installs.

On a single site install, the permissions check
in user_can_access_admin_page() gets the incorrect page hook name when it
calls get_plugin_page_hookname(). A page registered with a NULL parent gets
the hook "dashboard_page_*", but get_plugin_page_hookname() returns
"admin_page_*". On multisite, it correctly returns "dashboard_page_*".

So, finally, to my question: is this a bug in the documentation, or a bug
in the code? It looks like NULL is unpredictable, and options.php is the
only safe way to register an orphan admin page.

Have a nice day,
Jonathan


-- 
Jonathan M. Brinley

jonathanbrinley at gmail.com
http://xplus3.net/


More information about the wp-hackers mailing list