In WordPress, there is a special folder in wp-content
: mu-plugins
which stands for Must Use Plugins. WordPress automatically loads all PHP files in this folder. This is a very cool features if you want to always turn on some plugins such as debugging plugins, SEO plugins or functionality plugin for your blog. The problem is WordPress doesn't load files in sub folders, that means when you put a plugin as a folder into mu-plugins
, it won't be loaded.
To solve this problem, I use a simple trick: create a simple PHP file in mu-plugins
and include all plugins' main files.
For more details, let's look at my mu-plugins
:
As you see, there's a PHP file load.php
, and this file contains only these lines:
<?php
include 'inspector/inspector.php';
include 'monkeyman-rewrite-analyzer/rewrite-analyzer.php';
include 'wordpress-reset/wordpress-reset.php';
include 'wordpress-importer/wordpress-importer.php';
Now, when I go to Plugins menu, I see the PHP file is loaded as well as needed plugins:
Now I have a bunch of debugging plugins always activated. This saves me a lot of time when developing themes, plugins and fixing bugs. Putting those plugins in mu-plugins
folder also is a good way to organize plugins files. For more information about Must Use Plugins, please read more at the Codex.
Leave a Reply