Make WordPress Core

Opened 12 years ago

Last modified 23 months ago

#20241 assigned enhancement

make it possible for plugins to activate other plugins

Reported by: magnus78's profile magnus78 Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Plugins Keywords: has-patch needs-unit-tests needs-refresh
Focuses: Cc:

Description

When creating a plugin that depends on other plugins, i would like to enable those plugins during activation of the main plugin.

This is currently not possible, as updates to active_plugins done by the other plugins get overwritten.

Please apply the attached patch to fix this.

Attachments (4)

allow_plugin_to_register_other_plugins.patch (1.9 KB) - added by magnus78 12 years ago.
proposed fix
allow_plugin_to_register_other_plugins_v2.patch (2.1 KB) - added by magnus78 12 years ago.
proposed fix
wptrac20241_allow_plugin_to_register_other_plugins_v3.patch (2.5 KB) - added by magnus78 12 years ago.
proposed fix, v3
20241.diff (7.3 KB) - added by nacin 11 years ago.

Download all attachments as: .zip

Change History (22)

#1 @magnus78
12 years ago

Proposed fix 2 to take care of the sitewide version too...

#2 @magnus78
12 years ago

Anything i need to do to move this patch forward?

#3 @kurtpayne
12 years ago

  • Cc kpayne@… added
  • Type changed from defect (bug) to feature request

scribu has done a nice write up on dependency management in plugins

http://scribu.net/wordpress/plugin-dependencies

And he's written a plugin to handle dependency management, too

http://wordpress.org/extend/plugins/plugin-dependencies/

#4 @nacin
12 years ago

These changes could potentially break backwards compatibility.

Dependencies aside, this is doable without any patch. You can use the activated_plugin hook, which fires after the option is updated. For deactivation, you could simply choose a later hook (even something like 'shutdown' would work, as would option_active_plugins).

#5 @magnus78
12 years ago

Child plugins would indeed be nice, but it doesn't need to be either or. I'd see this patch more as a code fix than an actual feature...

How would it break backwards compatibility?
It's not doable without a patch afaikt. activated_plugin is run for every plugin not just *this* plugin like i want, i tried that first but ran into problems with plugins getting included multiple times (causing errors) and other strange problems.

Re option_active_plugins - did you mean updating the active_plugins option manually? That won't let the registration hook for each plugin run.

#6 @magnus78
12 years ago

  • Type changed from feature request to defect (bug)

V3 fixes a problem with the patch wrt multisite.

Anything more i need to do?

#7 @coffee2code
12 years ago

  • Type changed from defect (bug) to feature request

#8 @magnus78
12 years ago

I do see it as a bug fix, as it's not said anywhere that it shouldn't work, and i see no reason it shouldn't. If for some reason the fix isn't wanted, it should at least be documented that you're not allowed to activate other plugins from the registration hook.

#9 @stephenh1988
12 years ago

  • Cc contact@… added

#10 @nacin
11 years ago

  • Component changed from General to Plugins
  • Milestone changed from Awaiting Review to 3.7
  • Owner set to nacin
  • Status changed from new to accepted
  • Type changed from feature request to enhancement

@nacin
11 years ago

#11 @nacin
11 years ago

  • Keywords commit added

20241.diff:

  • Re-queries the active_sitewide_plugins or active_plugins options before modifying them in activate_plugin(), once hooks are fired.
  • Waits until saving options in deactivate_plugins() to query and manipulate them.
  • Cleans up some hook documentation.

#12 @nacin
11 years ago

  • Keywords needs-unit-tests added
  • Milestone changed from 3.7 to Future Release

This could benefit from unit tests.

#13 @kucrut
10 years ago

  • Cc kucrut.dz@… added

#14 @chriscct7
9 years ago

  • Keywords needs-refresh added; commit removed

#16 @desrosj
23 months ago

  • Milestone set to Future Release
  • Owner nacin deleted
  • Status changed from accepted to assigned

Since this one has not received any attention in 9+ years, I'm resetting the owner field. Sometimes contributors shy away from tickets with an owner assigned because it's a sign someone else has "claimed" it.

Pinging @afragen who is currently championing the efforts in #22316. This is out of scope of the latest efforts there, but should be considered in that context as that progresses.

#17 @afragen
23 months ago

Please give feedback to the Plugin Dependencies Feature Project.

There is an associated feature plugin, Plugin Dependencies.

There are testing instructions in the readme.

#18 @afragen
23 months ago

Please be aware that plugin's activating other plugins is outside the scope of the Plugin Dependencies feature project. There are libraries that have these capabilities, among them is one of my own, https://github.com/afragen/wp-dependency-installer.

Note: See TracTickets for help on using tickets.