[wp-hackers] Change in plugin Options page handling

Morgan Doocy morgan at doocy.net
Thu Feb 3 16:38:30 GMT 2005


On Feb 3, 2005, at 6:42 AM, Owen Winkler wrote:
> How does one now add menus to the interface if not using 
> add_options_page()?  Or do you still use add_options_page() to add 
> menus, but use the hook to fill the page?

Yes, the latter is correct. You still use add_options_page() to add the 
Options page to the Options submenu. The $file attribute from that is 
used to generate the URL one visits when the plugin's Options page is 
clicked in the submenu.

When that URL is visited, WordPress looks for the '?page=' variable in 
the query string, strips the '.php' suffix from it, and uses the 
resulting string to compose an action hook tag. It checks to see if 
that tag has been hooked into by a plugin, and if so, executes that 
action; if not, it simply loads the file specified to create the 
options page just like it used to.

> The name of the hook is a misnomer, since this hook would presumably 
> be valid for any page that was tossed at the admin.php in 
> $_GET['page']. Should it be 'admin_page_*' instead?

This is a good point, although I'd suggest splitting it up into two, as 
is done with add_options_menu() and add_management_menu(), so that one 
could hook into either a Management page, an Options page, or both. 
I'll add this to the patch.

> Has anyone else noticed that in today's CVS plugin hooks can now have 
> more than one value passed to them?

Actually, that was my idea too. Doesn't affect plugin filters which 
don't know about the extra parameters being passed, so it's completely 
backward compatible. Bug 768 [1].

[1] http://mosquito.wordpress.org/view.php?id=768

> Of course, this is my initial reaction to having to revise several 
> months worth of plugin work and all of the related API docs, which I 
> remember writing a decent portion of.

I won't address the first part, since you've already tested it in your 
followup email.

Firas has already committed to changing the plugin docs to reflect the 
change; if anything there should simply be much less to explain since 
it's much more intuitive.

Morgan



More information about the hackers mailing list