You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lot of plugins interacts with each others and they checks if plugin is installed and what is more important when different plugin is active.
For example plugins extensions or plugins which uses API of different plugins (dependencies).
By my experience they are using get_plugins function to check if specific plugin is installed and active.
In the current situation mu-plugins are loaded automatically, but WP does know nothing about them.
Implementation?
Curiously it could be very easy. get_plugins checks every sub-folder in the plugins folder. And this plugin is used heavily. This function doesn't have any filter what is sad, but happily it uses wp_get_cache, so there is a workaround.
Step 1
Copy code from get_plugins (https://developer.wordpress.org/reference/functions/get_plugins/) and change just wp_cache_get and wp_cache_set namespace to mu_plugins and $plugin_root to WPMU_PLUGIN_DIR. Name this function for example as get_mu_autoloader_plugins()
This is follow up ticket for #1
Motivation?
Lot of plugins interacts with each others and they checks if plugin is installed and what is more important when different plugin is active.
For example plugins extensions or plugins which uses API of different plugins (dependencies).
By my experience they are using
get_plugins
function to check if specific plugin is installed and active.In the current situation mu-plugins are loaded automatically, but WP does know nothing about them.
Implementation?
Curiously it could be very easy.
get_plugins
checks every sub-folder in theplugins
folder. And this plugin is used heavily. This function doesn't have any filter what is sad, but happily it useswp_get_cache
, so there is a workaround.Step 1
Copy code from get_plugins (https://developer.wordpress.org/reference/functions/get_plugins/) and change just
wp_cache_get
andwp_cache_set
namespace tomu_plugins
and$plugin_root
toWPMU_PLUGIN_DIR
. Name this function for example as get_mu_autoloader_plugins()Step 2
Merge both lists together. Eg:
This code is not optimized, so cache is rewrite on every request, which is not good.
Drawbacks?
Listed all mu-plugins as regular plugins. Which is not good.
Drawbacks fixes
Append specific array key which will say that that plugin is MU plugin.
Then in the
all_plugins
filter, just skip this plugins list.Proof of concept, workable code
The text was updated successfully, but these errors were encountered: