Make WordPress Core

Opened 7 weeks ago

#43882 new enhancement

Introduce slug-specific hooks to manage plugin loading order

Reported by: schlessera Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Plugins Keywords:
Focuses: Cc:


As already discussed in #41346, I'd like to propose a simple mechanism that can solve the loading order problems that inter-dependent plugins can have.

The main mechanism just adds an action that is named after the plugin that was just loaded. In this way, other plugins are able to initiate actions based on when another plugin was loaded.

A similar mechanism has been used in WP-CLI to solve the problems in the loading order of commands that rely on each other. You can read more about how commands can control their loading order here: https://make.wordpress.org/cli/2017/05/03/managing-command-dependencies/

Furthermore, this also allows for a small extension that can automatically resolve loading order, provided it knows about the dependency to look for. This is used in WP-CLI as well, where it is easy to deduce the parent command to look for, as described here: https://make.wordpress.org/cli/2017/05/31/command-dependencies-revisited/. For plugins, this could be solved by adding a simple plugin slug to the plugin header. I'll introduce a separate ticket to that regard.

I will upload a patch that adds the above-mentioned action, together with pre_plugin_loaded and post_plugin_loaded actions that give further control to plugins.

In case anyone wonders whether that might open the door to abuse and have plugins block loading of other plugins: that is already easily possible right now. A plugin can just remove whatever plugins it dislikes from the list of active plugins on activation hook.

Attachments (1)

43882.diff (1.1 KB) - added by schlessera 7 weeks ago.
Initial implementation (with simple & naïve plugin name detection)

Download all attachments as: .zip

Change History (1)

7 weeks ago

Initial implementation (with simple & naïve plugin name detection)

Note: See TracTickets for help on using tickets.