WordPress Must-Use plugin is a plugin that will always be enabled by default without you needing to do it yourself. To activate a mu-plugin, you just have to upload in the right directory of WordPress. Must-Use(MU) plugins are located in the “mu-plugins” folder. You can not deactivate mu-plugin form your WordPress dashboard. The only way to do it is either deleting or moving its file so that no one can accidentally remove the necessary feature.
WordPress MU plugins load first before normal plugins. MU plugins cannot use activation hook as classic plugins use it. WordPress MU Plugins don’t update automatically, we have to keep them up to date manually.
Steps to create Must-Use (MU) plugin
1. Create the ‘mu-plugins’ folder in wp-content.
2. Create a new PHP file with name ‘first-mu-plugin’ in the mu-plugins folder
3. Open the file and copy the following code.
<?php /* plugin name: First mu-plugin Description: This is just a first mu-plugin test Author: your-name */ Function Test(){ echo ‘<p>My First Test mu-plugin</p>’; } ?>
After this process, your mu-plugin will be activated automatically
How MU-plugin differ from a normal plugin?
- Automatically Activates: Must Use plug-in gets activate automatically in all WordPress sites.
- You can’t disable: You cannot disable or delete the Must-Use(MU) plugin. However, you can delete it from the /wp-content/mu-plugins.
- High Priority: The plugin inside the mu-plugins directory loads first, before the normal plugin.
- Can’t Activate/Deactivate hooks: Must-use plugins are auto-activate so we cannot deactivate or uninstalled, you can’t use activation and deactivation hooks.
- No Update: The plugin inside the “mu-plugins” directory will not activate automatically, we have to manually update by yourself.
Conclusion
You don’t need to activate/deactivate the MU plugins as it activates itself by default. The advantage is that even though there is an update in WordPress, it won’t harm MU-Plugin, so you can be sure that you will always retrieve your features.