最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Plugins in mu-plugins folder are not loaded

programmeradmin2浏览0评论

I'm trying to load plugins automatically by putting the plugins into mu-plugins folder. But if the plugin is put in a folder, it isn't loaded. I tried some popular plugins such as W3 Total Cache, WordPress SEO By Yoast, but all of them are not loaded.

Does WordPress only loads plugins which are just single files in mu-plugins?

I'm trying to load plugins automatically by putting the plugins into mu-plugins folder. But if the plugin is put in a folder, it isn't loaded. I tried some popular plugins such as W3 Total Cache, WordPress SEO By Yoast, but all of them are not loaded.

Does WordPress only loads plugins which are just single files in mu-plugins?

Share Improve this question asked Aug 19, 2011 at 13:41 Anh TranAnh Tran 4,1521 gold badge28 silver badges36 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 18

Does WordPress only loads plugins which are just single files in mu-plugins?

No, they do not need to be single files but you cannot use plugins in their own subfolders as in the standard plugins/ folder.

The main plugin file (one with the specified plugin header info) has to be right there in mu-plugins/. Other files can be put in a subfolder and referenced from there.

I used it with my own plugins. I've never tried moving any robust plugin in there.

Also note that not all plugins are must-use-compatible
see http://codex.wordpress/Must_Use_Plugins#Caveats

I've recently faced this very issue and in order to avoid mixing all plugins or patching files to keep organization, I've found that you can actually keep all plugins within separate sub-folders and create a symbolic link in the the mu-plugins folder pointing to the plugin's main file within the respective sub-folder.

I hope that this information can become helpful to others in the future!

I have been working on running WordPress inside Docker containers, and am using mu-plugins to run scripts on the server. I found out there is a global constant in WordPress called WPMU_PLUGIN_DIR that will help solve this problem.

Create your custom plugins in mu-plugin sub-directories as needed, and then load them from a single file. Example:

wp-content/mu-plugins/foo/bar.php
wp-content/mu-plugins/another/index.php

Then create a single file in the mu-plugins and name it anything.

For example, create wp-content/mu-plugins/load.php with the following code

<?php
require(WPMU_PLUGIN_DIR . '/foo/bar.php');
require(WPMU_PLUGIN_DIR . '/another/index.php');

You will only see the load.php under mu-plugins in the backend, but all of your functions will load from this single script.

发布评论

评论列表(0)

  1. 暂无评论