Opened 13 years ago
Closed 8 years ago
#14769 closed feature request (maybelater)
API for "Settings" action link on plugins.php
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.0 |
Component: | Plugins | Keywords: | needs-patch |
Focuses: | administration | Cc: |
Description
Plugins should be able to register a "Settings" actions link that will then take them to their plugin settings page.
We should try to hook into add_options_page() as well, just by taking the first one that the plugin registers. Probably not really doable to ascertain which plugin calls that function however, without running a backtrace. Maybe try matching the slug with the plugin basename.
Someone is encouraged to run with this before I get to it.
Change History (14)
#3
@
13 years ago
We have a few days before freeze to get a patch for this into consideration, if anyone wants to take a stab.
#4
follow-up:
↓ 5
@
13 years ago
- Cc edward@… added
When would this settings link be clicked? And where?
Are you referring to them there quicklinks on the plugin page? Activate / Deactivate / Settings?
#5
in reply to:
↑ 4
@
13 years ago
Replying to edward mindreantre:
Are you referring to them there quicklinks on the plugin page? Activate / Deactivate / Settings?
Yeah.
#6
@
13 years ago
Doesn't the action "plugin_action_links" already do that?
See wp-admin/includes/class-wp-plugins-list-table.php, lines 388 and 389.
#8
@
13 years ago
- Milestone changed from 3.1 to Future Release
We already have the ability to do this. Or did you want to abstract it even further?
A very simple way to implement this would just be to create a function analogous to register_activation_hook and register_deactivation_hook, that takes the plugin's filepath (i.e.
__FILE__
) and callback as args. i.e. the plugin author would do:And then
register_plugins_link_filter()
would just register theplugin_action_links_
filter.Or, if you want to plug into
add_(options|media|posts|etc)_page
, we could add an optional argument toadd_submenu_page
, i.e. a(bool) $settings_link
that if set, would add the link.Would be easy and efficient to implement because add_submenu_page is already doing the capability check to see if the link should appear, and already calling get_plugin_page_hookname() to generate the link URL, so would not have to do that twice. Would also need to add this optional argument to add_menu_page. And, to all of the one-line wrapper functions like add_options_page as well -- unless you want these to just always do it by default.
I think this second approach is more along the lines of what you're suggesting. If the plugin calls add_(sub)menu_page more than once to add multiple options pages, and sets the bool $settings_link more than once, it would be easy to check whether a filter for
'plugin_action_links_'.plugin_basename()
has already been set before setting another one.Or, we could not add this optional argument at all and just always register a settings link for whatever is the first page the plugin registers. I guess I don't necessarily love this degree of automagic (what if the plugin author doesn't want any settings link, or doesn't want to register their pages in a particular order?) but then I don't necessarily love adding an (eighth!) argument to these functions either, and making the API more complicated for people. Speaking as a plugin author I can't see why I wouldn't want to have the Settings link, so I guess I would lean toward the automagic and not complicating the API with an additional argument.
Alternately, could do only 50% automagic: Add the argument to add_menu_page and add_submenu_page, but just have add_(options|media|post|etc)_page call add_submenu_page with the flag always set to TRUE, so the API is magic for people who are using these simpler wrapper funcs, but anyone who needs the additional control can call add_submenu_page directly.