WordPress MUPlugins: What They Are + Useful MustUse Plugins For WP Web Developers

WordPress MU-Plugins: What They Are + Useful Must-Use Plugins For WP Web Developers

Do you need features to activate automatically and remain enabled on your website? Then consider adding these to WordPress as an mu-plugin…even create your own!

So, a must-use plugin (‘mu-plugin’) is just like any other WordPress plugin, except for the fact that when uploaded into the mu-plugins directory of the wp-content folder (i.e. /wp-content/mu-plugins it is automatically activated and remains enabled on your WordPress installation.

Back in the early days (around version 3.0), WordPress introduced a feature called Multisite (originally called WordPress MU) to allow multiple sites to share and be managed by one WordPress installation, WordPress Multisite (or WPMU as it became known) also introduced the ‘mu-plugins’ directory, offering site admins an easy way to activate plugins by default on all blogs in a multisite network.

Although MU-plugins originally referred to ‘multi-user plugins’, they were renamed to ‘must-use’ plugins.  Installed in the ‘mu-plugins’ directory of a WPMU installation, mu-plugins can now be used wherever you want one or more plugins to automatically activate and remain enabled, whether on one or multiple WordPress installations.

A must-use plugin (‘mu-plugin’) is a plugin that, by default, is automatically activated and remains enabled when uploaded into the mu-plugins directory of the wp-content folder (i.e. /wp-content/mu-plugins. Once uploaded into this directory, WordPress will automatically know that this plugin must be used on the installation.

Must-use plugins are loaded before normal plugins and do not show in the default list of plugins on the Plugins page of wp-admin. They do, however, appear in a special Must-Use section in the Plugin screen’s list menu.

To change the default directory manually, you will need to define two constants (WPMU_PLUGIN_DIR and WPMU_PLUGIN_URL) in wp-config.php:

define('WPMU_PLUGIN_DIR', '/full/path/to/new/directory');
define('WPMU_PLUGIN_URL', 'https://URL/to/new/directory');

Must-use plugins let you add features to the WordPress core that are not installed by default but that users may need.

The documentation then goes on to list a number of important caveats to keep in mind:

Note: WordPress only looks for PHP files right inside the mu-plugins directory, and (unlike for normal plugins) not for files in subdirectories. You may want to create a proxy PHP loader file inside the mu-plugins directory:

Mu-plugins should only be used to do “one” simple action. Calling complex code all the time might lead to conflict with other code or plugins and involving mu-plugins as suspected sources when troubleshooting conflicts can really complicate things.

Additionally, keep in mind that, unlike regular plugins, you can’t store an mu-plugin in a subdirectory of the mu-plugins directory. This means that you

[…]

 



This article was written by Martin Aranovitch and originally published on WPMU DEV Blog.

Disclosure: Some of the links in this post are "affiliate links." This means if you click on the link and purchase the product, We may receive an affiliate commission.

Leave a Comment

Your email address will not be published. Required fields are marked *

Show Your ❤️ Love! Like Us
Scroll to Top