Make WordPress Core

Opened 3 months ago

Last modified 3 days ago

#60692 new enhancement

Plugin dependencies: Allow a mu-plugin to fulfil a dependency

Reported by: johnbillion's profile johnbillion Owned by:
Milestone: 6.6 Priority: normal
Severity: normal Version: 6.5
Component: Upgrade/Install Keywords: 2nd-opinion
Focuses: Cc:


See discussion on #60504 for background.

An inactive plugin that has a dependency that is fulfilled by a mu-plugin is prevented from being activated as its dependency is considered unfulfilled. It should be possible for a mu-plugin to fulfil a plugin dependency.

It may be that a new filter or a default mu-plugin loader needs to be introduced so facilitate this.

Change History (4)

#1 @costdev
3 months ago

  • Keywords 2nd-opinion added

The PR on #60504 enables the existing wp_plugin_dependencies_slug filter to be used to replace Must-Use plugins with their loader file.

However, before we consider changing Core to facilitate Must-Use plugins as dependencies, I think it would be beneficial to explore the concept of standardizing Must-Use plugin loading.

The benefits for Core and Must-Use plugin users by introducing an easy-to-adopt approach to this manual process appear much wider than the Plugin Dependencies feature. Additionally, if we made changes to Core to facilitate Must-Use plugins as dependencies, then later introduced a standardized Must-Use plugin loading layer, then we'd have to maintain both.

There are many implementations of Must-Use plugin loaders out there, which is part of the problem in itself. I think we could produce a better result if we hold off on coding for now, and begin by exploring the behaviours of Must-Use plugin loaders. Essentially a list of Need -> Internal configuration layer -> Expected outcome(s).

We may even find that rather than a default loader template, this instead takes the form of a Must-Use plugin API within Core that Must-Use plugin users utilize in their respective loaders.

Call for opinions: Should we focus on standardizing Must-Use plugin loading (via API or default template), and if so, start looking at the most basic needs and structure to introduce an early version that's easily iterated on?

This ticket was mentioned in Slack in #core-upgrade-install by afragen. View the logs.

6 weeks ago

This ticket was mentioned in Slack in #core by nhrrob. View the logs.

3 days ago

#4 @knutsp
3 days ago

Let a mu-plugin stay as any .php file that exists in the mu-plugins folder, as now. Some recommedations is ok, like Plugin Name, Version headers and so on. The rest is up to the developer and/or any with file system access.

Make it simple. Create a register_dependency_plugin_slug function (or any better name) to add a plugin slug to a global array, or a class static, or a singleton object, array property, like the best of existing register_something functions. Maybe make this array immutable after all mu-plugins are loaded. In this way any, plugin author can add this, in prepartion to support being a loaded as a mu-plugin. Loader files, that load many individual plugins in subfolders, who does not register, allow multiple calls, one slug string at per call.

This allows any properly coded plugin, with no hard coded assumptions on where in the file systems it is loaded from, to work as a mu-plugin and also act as a dependency for other plugins.

A new plugin file header may be added, to indicate mu-plugin support, like network, but this is not essential

A mu-plugin declaring own dependencies should continue to be ignored, as developer territory.

Note: See TracTickets for help on using tickets.