Opened 11 years ago
Closed 11 years ago
#24670 closed feature request (wontfix)
Standardized plugin activation file
Reported by: | JD55 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Plugins | Keywords: | |
Focuses: | Cc: |
Description
For plugins uninstall, the standardized uninstall.php file has been introduced (see #5625), that is included only when a plugin is being deleted. There should be a similar file (maybe activate.php) included each time the plugin is activated. (We can't really do an install.php file, because there's no reliable way test whether a plugin is installed, it's plugin dependent.) This would allow plugin developers to separate and centralize their activation/installation code, rather than having to use register_activation_hook().
Change History (4)
#2
in reply to:
↑ 1
@
11 years ago
Replying to nacin:
I think register_activation_hook() is fine. The real benefit to uninstall.php is that it makes it very clear that since the plugin is deactivated, it is not included and you can't rely on it. You can only rely on what is done inside uninstall.php.
That's true, and I hadn't thought of it that way.
I suppose the same thing could be accomplished by including a plugin file inside of the activation hook function.
#3
@
11 years ago
I've been thinking some more about this, and I've realized that when the plugin is activated it isn't a "normal" WP run either. Although - unlike the uninstall routine - the entire plugin is available, the page is redirected immediately after the activation hook is called, so it's not possible to hook into anything during the activate routine.
That being said, it is slightly different than the logic behind uninstall.php.
#4
@
11 years ago
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
This is a good idea, but I think it's pretty safe to close this out. We want activation to be as close as possible to a "real" plugin inclusion. Having a separate file could mean we would avoid catching fatal errors, syntax issues, or just plain incompatibility.
I think register_activation_hook() is fine. The real benefit to uninstall.php is that it makes it very clear that since the plugin is deactivated, it is not included and you can't rely on it. You can only rely on what is done inside uninstall.php.