Do you develop WordPress websites and constantly find yourself writing the same functions over and over again? How many times have you started a new theme, only to go straight to the functions file and copy-paste or rewrite code from previous themes?
Or maybe you have some great branding for your clients’ dashboards, and you don’t want them to turn it off?
Well…here’s the solution:
WordPress Must Use Plugins
A “must use” plugin is a plugin that must be used by WordPress. It doesn’t appear in the list of plugins, and it can’t be turned off by your users/clients. It is a way for you to add required functionality to a site.
It’s powerful stuff – but can be too powerful if you’re not careful.
A Must Use Plugin Example
We build WordPress sites for clients. Without fail, every single website we build needs at least one navigation menu. So…we used to start every website with:
'primary' => 'Primary Navigation'
…and then add additional menus as needed. But we got tired of writing it over and over again every time we started a new site.
Wouldn’t it be easier if we could just create those menus in our WordPress Dashboard? (hint: yes, it would).
So We Built a Plugin
We never hack the WordPress core to add functionality. Instead, we built a plugin that would allow us to quickly and easily register and delete navigation menus right from the Appearance -> Menus page in the dashboard.
To us, it made sense to have this functionality right in the dashboard. Why should we have to jump back and forth between the Dashboard and the functions file just to make menus? It was extra work that wasted our time.
With our New Nine Menus Manager, we could now quickly and easily register navigation menus right from the Dashboard. No more jumping back and forth to functions.php just to add another menu.
Still a Pain in the…
Our work wasn’t done. We had the plugin and everything worked perfectly, but we still had to remember to activate it on every new site we built. Surprisingly, this became a point of great frustration.
We’d create the fresh install of WordPress, head over to Appearance -> Menus, and doh! We forgot to activate the plugin. So we click over to Plugins, activate it, and then back to Appearance -> Menus to get started.
At first, that’s okay. But after a few sites, it really gets to be a pain.
Reasoning Behind a MU Plugin
This is something we use on every site. Even if the site doesn’t have navigation menus, there’s no real overhead; so, why not just include it? And, by making it a “Must Use” plugin, it will automatically be there, ready, and activated for every new site we build. No more hearing doh! around the office.
So we turned it into a MU Plugin. Then, we installed it. And voila! The New Nine Menu Manager is on every site in our network and our clients can’t accidentally turn it off and disable all of their navigation menus!
How to Install a MU Plugin
Installing a MU Plugin is a little different than a traditional plugin, but still easy as pie. Must Use plugins go in a folder called “mu-plugins” inside of “wp-content”. If that folder doesn’t exist, just go ahead and create it. (Don’t worry – that’s not hacking the core. It’s standard WordPress, but just doesn’t exist initially because most users don’t ever need it. It will remain in tact when you update WordPress.)
Your “wp-content” folder will now look something like this:
Now, put the plugin’s php file into the “mu-plugins” folder.
Seriously – the plugin is now activated and required for the site (or for your entire network of sites). It won’t appear in the Plugins section of your dashboard, but that’s because it must be used and there is no need or ability to deactivate or delete it from the Dashboard.
Why You Should Love MU Plugins
If you’re a developer, you will learn to love MU Plugins. You can add additional functionality to WordPress, add features to all of your clients’ sites, add whitebranding to your dashboards, and more.
But be careful with it. Not every plugin can be a MU Plugin. In fact, most can’t. And, not every plugin should be activated and required on every site.
In our next post, we’ll go more into detail on how you can create a MU Plugin for your clients and websites.