-
-
Notifications
You must be signed in to change notification settings - Fork 0
About MU Plugins
WPMU Plugins as in 'WordPress Must Use Plugins' is a very interesting concept that is not used as much as it should be, and in general, I have found that most WordPress users are not aware of it. A long time ago, before WordPress 3.0, there was a special edition of WordPress called MU or Mult-user or Multisite - allowing you to run multiple blogs with the single installation of WordPress, and all that was merged into WordPress core in version 3.0. But, that MU is somehow still associated with WordPress Multisite.
But, MU nowadays (should) refer to 'must use'. WordPress has three main directories inside wp-content: plugins, themes and uploads. But, there is a forth directory used by WordPress, that is not created by default (and it should - with at least a readme file placed there with some basic explanations what it does), and that directory is mu-plugins.
It is simple. Whatever PHP file you place in the mu-plugins directory, that file is loaded by WordPress before any of the normal plugins are loaded! You can add one or more files there, there is no limit. There is no real limit what these plugins can do, but the main idea was to create small code snippets and place them there for small tweaks and changes, without creating full plugins.
Basically, MU Plugins is the proper way to tweak the WordPress, instead what is typically done: cram all sorts of things into the active theme functions.php file. Use of functions.php is one of the worst things done when it comes to adding custom code to WordPress, and the only code that should go there is the code that directly modifies the theme. If you have a child theme, put in functions.php only custom PHP code that modifies some aspects of the main theme, nothing else. Whatever else custom code you need, a few lines tweaks or whatever, it should go into the mu-plugins directory.