1

I've looked at other posts regarding mu-plugins but I don't understand yet. Here's the situation: My site is hosted by a service that automatically sets up 2 caching plugins. Cloudflare and OP Cache. They were originally installed in the mu-plugins folder. I'm not sure what happened, as there are multiple people working on this site, but they all disappeared.

I reinstalled them but can't activate them. I got the error

Fatal error: Cannot redeclare class OPcache_dashboard in oursite/www/wp-content/plugins/opcache/opcache.php on line 28

So I guess when I reinstalled them, it put them in the normal plugins folder. If I delete the mu-plugins version, I can then activate it. However, what I'd like to do is keep them in the mu-plugins folder and activate them from there, but they don't appear unless they're in the normal plugins folder.

Any thoughts?

Thanks in advance!

3
  • Must-use plugins are not in same list with normal plugins, there's a separate tab in plugin page. You cannot enable/disable must-use plugins, they are enabled by default and cannot be disabled! Are you sure you looked the right tab? Are you sure they are not working? Double check please. Also, this is very fishy setup in my opinion.. 3rd party plugins shouldn't be must-use because updates might break your site and you can't disable them.. It's not the best idea to depend on 3rd party plugins.
    – N00b
    Commented May 2, 2016 at 8:07
  • Additional note: if your host enforces must-use plugins, there's a chance that they might have enforced custom rules or code. If that's the case, this problem is out of our scope and you should contact your host.
    – N00b
    Commented May 2, 2016 at 8:17
  • Thanks so much for your response. I would definitely prefer having them in their original form as "mu-plugins" that work correctly. The reason I'm installing them as 3rd party plugins is because I'm having trouble getting a hold of the hosting company. The person who hired me is connected with them and I can't get a hold of him. I do see your point though. If they're custom, then we should be using them. But you answered my question. They're not interchangeable like I thought and can't just be swapped in and out of folders like that. Thanks!
    – Kevmon
    Commented May 2, 2016 at 8:23

2 Answers 2

1

The reason plugins in the mu-plugins folder can't be activated in the plugins page is because that's not how mu-plugins works. The mu stands for must use.

Improtant things to know:

  • mu-plugins load before plugins
  • WP loads PHP files in the mu-plugins folder
    • it does not search subfolders
    • it does not look for plugin headers
  • PHP files in the mu-plugins folder have no activation status, they are always loaded.
    • this is true for all sites in a multisite, there is no conditional loading.

So code in the mu-plugins folder will never have an activate/deactivate link. You can never put code in both mu-plugins and plugins. You also can't just put a plugin in mu-plugins, it needs a PHP file that includes the plugins main file to work.

mu-plugins is a folder of PHP files, where WP loads all the PHP files before it loads the plugins or themes.

0

Where that error comes from is hard to say. Obviously something needs that class, but it hasn't been included/autoloaded.

If the plugins you mentioned are designed to be in the mu plugins folder, then you should obviously place them there.

MU plugins behave a bit differently as Twerking N00b hinted at and must have an init file in the ROOT of the mu-folder (unlike normal plugins). The structure you should aim for is one init file per mu-plugin, and then the folder with the actual plugin code. The only thing the init file does, is one line with an "include", that includes the main plugin file.

2
  • Thanks DarkNeuron, I'm working on getting a hold of the hosting company and having them fix it because I'm realizing I can't and probably shouldn't try to fix it myself. Thanks for the info!
    – Kevmon
    Commented May 4, 2016 at 3:48
  • No problem. If you are satisfied with my answer, you can mark it as such. Thanks in return.
    – DarkNeuron
    Commented May 4, 2016 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.