search ]

Have you heard about WordPress MU-Plugins?

At its core, WordPress has thousands of core functions and useful tools that definitely contribute to making WordPress the number one content management system in the world. Many WordPress features are familiar to us such as custom post types, hooks, actions, and filters etc., but there are those that are not widely known.

In this guide, I will explain one of the lesser-known but nonetheless very useful features called “Must Use Plugins”, or in the short term “MU-Plugins”.

What are MU-Plugins (Must Use Plugins)?

It’s no mystery that the functionality of Must Use Plugins is not well known to many WordPress developers because it was originally created for WordPress MultiSites, and it was not integrated as an integral part of WordPress until WordPress version 3.0.

At that time, a library called mu-plugins offered the option for network administrators to activate a particular plugin for all the blogs in that Multi Site network. After the integration with WordPress 3.0, the mu-plugins library remained in place and its full name is “MU-Plugins”.

Main Features of MU-Plugins

There are advantages and disadvantages to MU-Plugins, let’s expand on them:

They are always activated: Essentially, MU-Plugins are plugins that … must be used and are automatically loaded on your WordPress site (or network of sites). Moreover, they do not appear in the plugin list in the WordPress management system.

They cannot be deactivated: Even if you are the site administrator, you do not have the option to deactivate or delete those plugins. However, your only option to delete them is by removing them from the mu-plugins directory inside wp-content. Also, you cannot install new plugins in this directory except by manually uploading those plugins to that directory.

They are loaded before the regular plugins: The plugins in the mu-plugins directory are loaded before the existing plugins in your plugins directory.

Surprisingly, right now the plugins in the mu-plugins directory are loaded alphabetically…

Cannot use activation/deactivation hooks: Since MU-Plugins are automatically activated and cannot be deactivated or removed, it is not possible to use activation and deactivation hooks with these plugins.

They do not update: The plugins in the mu-plugins directory do not update automatically and WordPress does not notify you about new updates for those plugins. You are required to keep them updated manually.

You must use PHP files: WordPress does not search for plugins in subdirectories of mu-plugins, you are required to place the PHP files in the main directory (root directory). However, you can create a proxy php loader file and perform require for those files.

Ideas for Using MU-Plugins in WordPress

There are lots of ideas on why & when it’s a good idea to use mu-plugins, let’s give some examples where you would want to use them:

Using MU-Plugins in Multisite Networks

WordPress Multisite is actually the reason the mu-plugins library exists. Although the option of Network Activation exists, you can use MU-Plugins if you need a bit more “power”. There are differences between plugins activated across a network of sites and MU-Plugins that I will not elaborate in this article.

Using MU-Plugins on Your Clients’ Sites

If you are among those who provide (or must provide) administrator access to your clients, then you surely know that these clients have a tendency to tinker with the options, with the template settings, with plugins, and with everything they have access to.

If they decide to deactivate or remove a certain plugin, there’s a strong chance you’ll have to give them support on a Friday evening claiming that you are not properly maintaining their site.

But if you transfer the plugins to the mu-plugins directory and create a php file to call those plugins, your clients will not have the option to deactivate those plugins. But remember – you will need to ensure that you perform manual updates to those plugins.

Using MU-Plugins for Specific Plugins on Your Site

If you own a site that requires specific functionality critical to its proper operation, the right thing to do is to create a dedicated plugin for that site and perform that functionality.

Since you cannot bear the thought of accidentally deactivating that plugin, it would be wise to put it in the mu-plugins directory, so even you cannot deactivate it through the management interface. And since you are the developers of the plugin, and it is not used on any other WordPress site, you will have no problem with updates for that plugin.

In Conclusion

In this short guide, I tried to explain one of the hidden (and less appreciated) features of WordPress. I was quite surprised when I discovered mu-plugins and hope you are too.

I am sure this functionality can be used in many more situations beyond those I wrote about in the guide, but these alone can make a significant difference to your WordPress site.

I would love to hear what you think about Must Use Plugins in WordPress and if you know of additional ways to use this feature. If you liked the guide, don’t forget to share it with your friends! 🙂

Roee Yossef
Roee Yossef

I develop websites & custom WordPress themes by design. I love typography, colors & everything between, and aim to provide high performance, seo optimized websites with a clean & semantic code.


Leave a Comment

Quick Navigation