Composer mu-plugins

This will be complicated.

Unfortunately, mu-plugins and plugins are not always interchangeable.

  • Must-use plugins are initiated from the mu-plugins root. Every file in the root is included, but folders are not traversed.

  • Standard plugins are different and can be initiated from their own folder plugins/my-plugin-name/ or the root plugins/my-other-plugin-name.php.

This means that re-declaring the package type from plugin to mu-plugin will only work for one-file, no folder plugins (CPTs, taxonomies etc - the stuff you probably wouldn’t be getting from wpackagist).

To get around this limitation you would have to create your own must-use loader plugin that initiates the plugins you want to be treated as mu-plugins or hope that all the plugins you need use PSR-4 autoloading (hint: they won’t).

You would also need to re-order the installer-paths in Bedrock and add the package to the mu-plugin installer-path array:

"extra": {
    "installer-paths": {
      "web/app/mu-plugins/{$name}/": ["type:wordpress-muplugin", "wpackagist-plugin/my-plugin-name"],
      "web/app/plugins/{$name}/": ["type:wordpress-plugin"],
      "web/app/themes/{$name}/": ["type:wordpress-theme"]
    },
1 Like