Must-Use plugins are standard wordpress plugins, just that they reside in the mu-plugins directory (wp-content/mu-plugins). Plugins residing in this directory are automatically activated. The only way to deactivate them is to delete the plugin files from the mu-plugins directory.
The plugin files do not need to contain plugin headers, so you just need to create a PHP file and that’s it. These MU plugins are listed as ‘Must-Use’ in the plugins page in the WordPress admin.
What’s so great about this when we can easily place our code in the theme’s functions.php? Well, I can find use for this when creating post types, taxonomies, or shortcodes. By separating such codes from functions.php, I’m saving myself the trouble of transferring the code, or breaking my WordPress site when I need to switch themes.
Also, this has advantage over regular plugins found in the plugins directory (wp-content/plugins). For developers, must-use plugins prevent clients from disabling codes that are crucial to their site.
However, take note that WordPress looks in the mu-plugins directory for php files and not in its subdirectories. So if you want to move regular plugins which reside in their own subdirectories into wp-content/mu-plugins, you’ll probably need to create a proxy php file that contains require_once()
or include_once()
to include the plugin’s main php file from its subdirectory. An easy way is to create a single php file to include all the plugins found in mu-plugins sub-directories.