Friday, October 19, 2018
Plugins

What are MU plugins and what are they useful for

We explain you in detail what are these “hidden” plugins and their differences with any other conventional plugin.

mu plugins

¿Have you ever wondered what are mu plugins and what are they used for? Here we will explain you in detail what are these “hidden” plugins and their differences with any other conventional plugin.

Maybe you’ve never heard about mu plugins. If your WordPress installation have one or more mu plugins you can see them in the plugins page in your WP dashboard.

So if you want to know what are mu plugins and what are they used for, just go on reading and learn all what you need to know about them.

Mu plugins: A bit of history

Since the release of WordPress 3.0 “Baker” back in 2011, WordPress integrates multi site to its default source code. Before that, it was mandatory to use a multi user directory to upload plugins that were applied to all sites in multi site network.

This directory -named “mu plugins” for Multi User plugins- become useless after integration with multi sites in WordPress download file.

But wisely, they kept the folder because of some other features that were not well known at that moment.

So because mu plugins was no more used for multi sites, and relative to its new functions, it was renamed as Must Use plugins. keeping the same initials and folder name.

The mu plugins folder is just like any other folder in a WP installation. In fact, it’s practically identical to the plugins folder located in wp-content.

But there are some significant differences between them.

Difference between mu plugins and normal plugins

The concept that lies behind mu plugins is that they can be used for adding functionality not included in WordPress and that website must have for default in your installation.

Of course, you can say that’s what all plugins do. But mu plugins have some special features that you will love, and much more if you are a WP developer.

Mu plugins doesn’t need to be activated on plugins page, they will activate automatically when installed. You just need to upload the .zip file to the mu-plugins folder and that’s all. For uninstall, you can simple delete it. All from files system on Cpanel or by FTP.

Also mu plugins are loaded before any other “normal” plugin. And in alphabetical order. This is great for many tasks. For example when you need to load a library that other plugin or theme should use.

In contrast with conventional plugins, a mu plugin doesn’t need a header like all plugins have. You can have a header in a mu plugin but it is not necessary, the only difference is what you are going to see in your plugins page in WP dashboard.

If there is no header, you will see just the name of file. And if name and description is set in header, then you’ll see it in dashboard.

This is the main file of a plugin:

If uploaded in mu-plugins, header can be missing and the plugin will work as well.

Without header will also works

Something you must know is that mu plugins cannot contain subdirectories. Only files in root directory. But there is a trick to avoid this disability.

You can create a file in mu plugins folder to load the sub directory you need.

This is the code in loader file:

As mu plugins cannot be activated in backend, they can’t use any activation hook like normal plugins. So if the plugin you need must use one of these hooks, it will not work from mu-plugins folder.

Finally, you must know that mu plugins can’t be updated, deleted or edited from the WordPress dashboard. These means you must not upload normal plugins in mu plugins folder. If you do it, the plugin will not be updated even if you have automatic updates enabled.

This can be dangerous with normal plugins since they will never update. But also can be an advantage if you have a customized plugin that you don’t want to update.

Any update or modification you want to make to your mu plugin must be made manually from Cpanel file manager or through FTP client.

Features of mu plugins

  1. Doesn’t need to be activated, they activate automatically when uploaded to mu plugins folder
  2. There is no need of a header in main file of mu plugin, although it may have one
  3. They load before any other plugin in alphabetical order
  4. Cannot have sub directories. If it must have one, you can use a loader file
  5. Activation hooks are not allowed in mu plugins
  6. Can’t be uploaded, updated, deleted or edited from WP dashboard

Why and when should you use a mu plugin

There can be many situations where a mu plugin can bring a solution, here are some:

  • Load automatically a library that other plugins or theme needs, before they load.
  • Custom posts types or custom taxonomies that can’t be modified
  • Custom functions that you want to activate by default and don’t want to let anybody to deactivate
  • Essential plugins that can’t be deactivated, deleted or modified. This is very useful when working with clients that likes to hang around there touching every single thing they found.
Seba Rossi
the authorSeba Rossi
Experienced Web Editor with more than 1500 published articles. Passionate about Web development and with advanced knowledge of SEO, amateur guitarist and lover of tasty beer with the company of good and old friends.

Leave a Reply