/The Latest /Tutorials & Code Repository

How to Create a WordPress MU Plugin

In my last tutorial, I discussed why you should consider using WordPress MU (must-use) plugins – especially if you develop sites for clients or manage a network of sites. Let’s take a look at how you can create your own MU plugins.

First, a brief refresher of MU Plugins, from the WordPress codex:

Must-use plugins (a.k.a. mu-plugins) are plugins installed in a special directory inside the content folder and which are automatically enabled on all sites in the installation. Must-use plugins do not show in the default list of plugins on the Plugins page of wp-admin – although they do appear in a special Must-Use section – and cannot be disabled except by removing the plugin file from the must-use directory, which is found in wp-content/mu-plugins by default.

WordPress codex

We’re going to create a simple MU Plugin that changes the footer text in the admin dashboard to add a little branding to our clients’ sites. Instead of seeing “Thank you for creating with WordPress” in the dashboard footer, it will say, “Powered by New Nine Media & Advertising.” It’s a small change, but it’s also another opportunity to brand yourself – unobtrusively – to your clients and their logged-in users.

Creating the Plugin

Creating the plugin is a snap, but you must keep a few things in mind that are likely different than other plugins you may have developed. (More on each later in this article.)

  1. The file structure is different. Your plugin’s main PHP file must reside directly in the mu-plugins folder. More on this in a bit.
  2. No installation, activation, deactivation, or uninstall hooks will ever be called.
  3. It will never show update notifications – you’re on your own to update the plugin.

When you’re writing your own plugin, no problem. But you shouldn’t consider using commercial or free plugins as MU Plugins unless you know what you are doing and they were specifically created and tested as mu-plugin compatible.

So here’s our code, which we’ll put into a file called n9m-dashboard-branding.php (or whatever you want).

Plugin Name: Brand the Dashboard Footer
Description: Adds my awesome text to the dashboard footer.
Version: 1.0
Author: New Nine Media & Advertising
Author URI: https://www.newnine.com
License: GPLv2
class NewNineDashboardFooter {
   function dashboard_footer(){
      print 'Powered by <a href="https://www.newnine.com" target="_blank">New Nine Media & Advertising</a>';
   function __construct(){
      add_filter( 'admin_footer_text', array( $this, 'dashboard_footer' ) );
new NewNineDashboardFooter();

Now, just drag n9m-dashboard-branding.php into your mu-plugins folder. It’s automatically activated, and can’t be deactivated by users / site owners / you unless you delete the file from the mu-plugins folder. And like that, your site or network is instantly branded.

The Considerations

Unlike regular plugins where a plugin’s files all sit in its respective folder in wp-content/plugins (except for single-file plugins), an MU Plugin must have its main PHP file in the mu-plugins directory. Any additional files can be in a subfolder. There is this workaround, but it’s an extra step you don’t need. It’s better to readjust your thinking when developing MU Plugins so you carefully consider what you’re doing.

Also, realize that you’re requiring this plugin no matter what, and on every site in your network if you run a network. That’s fine if you want to rebrand the dashboard. You probably don’t want to use it to load a heavy image gallery plugin that most sites might never use.

Now go make a mu-plugin. Then, report back and let us know what you built!

Did you enjoy this? Share it so others can too!

Got a question or comment?