#4048 closed enhancement (wontfix)
some hooks for the plugin management system
Reported by: | m0n5t3r | Owned by: | westi |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Administration | Keywords: | has-patch new-hook plugin-management |
Focuses: | Cc: |
Description
failed to get any feedback on this from wp-hackers, posting anyway:
- filter
get_plugin_data
: allows plugging functions that handle additional plugin metadata - action
before_activate_$plugin
: allows the plugin to do some stuff before being activated, and refuse activation if it doesn't like something
2nd opinion needed on the first point: perhaps a more efficient/extensible rewrite of get_plugin_data would also be appropriate (preg_match is not really needed, neither is reading beyond the end of the first comment block; see, some people have a nasty habit: they put everything about their plugin in one huge file)
Attachments (4)
Change History (19)
#4
@
17 years ago
- Keywords new-hook added; 2nd-opinion removed
Added a new patch which implements the above hooks.
#7
@
17 years ago
As for the plugin data info. I have no idea what it would be used for, other than some malicious purpose. It is part of the ticket, so I don't know. It might be useful, in the event a plugin wanted to do something with the urls to check to see if there was an update available based on the author's web site. However, it might just be better to make it an action in that case.
I'm not sure how I feel about allowing a plugin to overwrite the information in the plugin. It isn't like the plugin itself can change that, because it can't, until it is enabled and ran. However, that sort of defeats the purpose. Why would a plugin want to do that? They can just change the info in the file.
For the second, I had a really good reason to need this. I could check whether dependencies have been enabled and if not then I return false and fail the activation.
In the current situation, I would have to wait until the plugin is already activated and the test that information and then deactivate the plugin manually. A painful hack and I would rather keep that logic separate and in a location create purposefully for that situation.
#8
@
17 years ago
It might be nice to filter the plugin data to provide l10n of the name and description.
#9
@
17 years ago
Oh yeah. Well, I don't do very much l10n coding, so you know, I wouldn't have guessed that! Thanks.
#11
@
17 years ago
Filtering for l10n purposes means the plugin has to get the source strings in the catalog somehow. It could do this with some dummy () calls within the plugin that duplicate the header information. But then we would have to load catalogs for inactive plugins to get at these translations, which we don't currently do. If we did do this, it would be an integrated feature and not a filter.
#12
@
17 years ago
Okay, I'll work some more on it. Can the before_activate_ hook still go in?
What I was thinking going off your idea, is if there was a file that could be loaded that uses the __()
and loads the plugin locale domain. This file could be set by another optional comment field and would be loaded to get the translatable plugin details. It would also remove the problem found in the current patch when the plugin isn't activated, the translations won't load.
I suppose the work above would have to go into the other ticket. If you add the hook, I think you should close this out as fixed and allow the other feature to be done in the other ticket.
before_activate_$plugin.action.diff, have you tested this to make sure it works?
It appears as if you are depending on register globals or globals for the $can_activate.
My guess is that it should be a filter
This would be most useful for checking dependencies before the fact. Would have been quite useful in some previous projects.