WordPress.org

Make WordPress Core

Opened 10 months ago

Closed 3 months 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)

comment:1 follow-up: nacin10 months ago

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.

comment:2 in reply to: ↑ 1 JD5510 months 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.

comment:3 jdgrimes8 months 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.

comment:4 nacin3 months 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.

Note: See TracTickets for help on using tickets.