Hefta-Gaub Development Blog

April 6, 2007

Supporting Subdirectory Plugins in WordPressMU

Filed under: development, Wordpress plugins, WordpressMU — zappoman @ 12:27 am

WordPressMU treats plugins a little differently than standalone wordpress does. Namely it supports two types of plugins. Those loaded and controlled on a per-blog basis (like normal WordPress) which are stored in the wp-content/plugins directory; and those that are loaded for all blogs on all pages, which are stored in the wp-content/mu-plugins directory.

I won’t attempt to explain all the good reasons for why these plugins are segregated, instead this is a quick description of a small feature enhancement to the mu-plugins behavior. Namely, one of the differences between how plugins are loaded from mu-plugins vs. how they are loaded in standalone wordpress or the plugins directory; is that mu-plugins only loads php files in the root directory. (It also happens to include all php files, which is another important difference.)

What if you wanted to cleanup your mu-plugins directory a little and store some plugins in subdirectories. Well, here is a simple mu-only plugin that adds this feature.

Download: here.

Install: Rename this file as .php and place it in your “wp-content/mu-plugins” directory.

Usage:  You can now place mu-plugins into subdirectories of you “wp-content/mu-plugins” directory and they will load like any other mu-plugin.

15 Comments »

  1. Well nice.. now I can see the plugin. But when I acivate it I got this error:

    Warning: Cannot modify header information – headers already sent by (output started at /home/web/xxxxx/blogs/wp-content/mu-plugins/subdir-mu-plugins.php:167) in /home/web/xxxxx/blogs/wp-includes/pluggable.php on line 334

    Comment by Peach — April 26, 2007 @ 9:55 pm

  2. hmmm? When you say you “activate it” what do you mean? This plugin (the subdirectory plugin) is only designed to run in WordPressMu in the mu-plugins directory in which case you don’t actually activate plugins.

    Now the error you mention clearly indicates that you’re running in mu so not sure what you’re actually trying to do.

    What plugin in particular are you trying to use this with? It sounds to me like the plugin in question is sending some php headers after the headers have already been sent.

    One thing to keep in mind is that these plugin will still load all php files in the subdirectories, so it won’t work with all normal wordpress plugins which may have other helper files which wouldn’t normally run.

    Let me know what plugin you’re trying to use and I’ll look into the problem if I get a chance.

    Comment by zappoman — April 26, 2007 @ 10:19 pm

  3. Ok, I don’t know exactly what problem Peach is having, but I ran into a plugin that I wanted to use that needed a small change.

    Namely, since WordPress single instance will only load files that have the “Plugin Name:” directive, but WordPressMU will load all PHP files, if a plugin has extra support PHP files that aren’t safe to load all the time (but can be loaded at the right time by the plugin for example) these types of plugins don’t work well in WordPressMU.

    I’ve now changed the behavior of this subdirectory loading plugin to behave a little more like WordPress. Namely it will only load files from subdirectories that have a “Plugin Name” directive.

    Read more about this change here

    Comment by zappoman — April 26, 2007 @ 10:33 pm

  4. Thanks for your great plugin.
    It’s working like a charm.

    I had been headake everytime when I try to install plugin which in sub-directory in mu-plugins directory, as you know, it didn’t work, but your plugin make it work.

    It’s so useful. Thank you.

    Comment by Dog training — July 15, 2007 @ 4:38 pm

  5. Thanks. I had a problem, and you solved it 🙂

    Comment by dan — August 22, 2007 @ 2:58 am

  6. Errorrrrrrrrrs

    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /mounted-storage/home30a/sub003/sc26878-GIJV/www/wpmub/wp-content/mu-plugins/mu-plugins-sub.php:219) in /mounted-storage/home30a/sub003/sc26878-GIJV/www/wpmub/wp-content/mu-plugins/wpmu-signup-captcha.php on line 30

    Warning: Cannot modify header information – headers already sent by (output started at /mounted-storage/home30a/sub003/sc26878-GIJV/www/wpmub/wp-content/mu-plugins/mu-plugins-sub.php:219) in /mounted-storage/home30a/sub003/sc26878-GIJV/www/wpmub/wp-login.php on line 12

    Warning: Cannot modify header information – headers already sent by (output started at /mounted-storage/home30a/sub003/sc26878-GIJV/www/wpmub/wp-content/mu-plugins/mu-plugins-sub.php:219) in /mounted-storage/home30a/sub003/sc26878-GIJV/www/wpmub/wp-login.php on line 24

    Warning: Cannot modify header information – headers already sent by (output started at /mounted-storage/home30a/sub003/sc26878-GIJV/www/wpmub/wp-content/mu-plugins/mu-plugins-sub.php:219) in /mounted-storage/home30a/sub003/sc26878-GIJV/www/wpmub/wp-includes/pluggable.php on line 549

    Warning: Cannot modify header information – headers already sent by (output started at /mounted-storage/home30a/sub003/sc26878-GIJV/www/wpmub/wp-content/mu-plugins/mu-plugins-sub.php:219) in /mounted-storage/home30a/sub003/sc26878-GIJV/www/wpmub/wp-includes/pluggable.php on line 550

    Warning: Cannot modify header information – headers already sent by (output started at /mounted-storage/home30a/sub003/sc26878-GIJV/www/wpmub/wp-content/mu-plugins/mu-plugins-sub.php:219) in /mounted-storage/home30a/sub003/sc26878-GIJV/www/wpmub/wp-includes/pluggable.php on line 551

    Warning: Cannot modify header information – headers already sent by (output started at /mounted-storage/home30a/sub003/sc26878-GIJV/www/wpmub/wp-content/mu-plugins/mu-plugins-sub.php:219) in /mounted-storage/home30a/sub003/sc26878-GIJV/www/wpmub/wp-includes/pluggable.php on line 552

    Warning: Cannot modify header information – headers already sent by (output started at /mounted-storage/home30a/sub003/sc26878-GIJV/www/wpmub/wp-content/mu-plugins/mu-plugins-sub.php:219) in /mounted-storage/home30a/sub003/sc26878-GIJV/www/wpmub/wp-includes/pluggable.php on line 448

    Comment by fasadstan — October 26, 2007 @ 1:44 pm

  7. Alright, clue in all the WPmu newbies. I’m solid on single install plugins, but the documentation for WPmu how to install, what to look for before considering an install, and how to make them show up… type documentation is a mess on the WP site and elsewhere. The article you’ve posted above has me somewhat understanding. Here’s what I’m missing:

    1) From what I’ve read, only some single WP site plugins work on WPmu, true? How may we distinguish?
    2) When you want a plugin to work on a global level, you a) ftp the plugin file to the wp-content/mu-plugins/ directory, and b) check mark the Site Admin > Options: Plugins Menu (enabled)
    3) To display the plugins available you go to Plugins > Plugins

    Ok, now, here’s what’s happening…
    On step #3 above, I get error: Couldn’t open plugins directory or there are no plugins available.
    Yet, I can see recent comments(plugin results) on my home page, I can see Akismet options working, and yet neither appear on a Plugins >Plugins list (instead the error message above).

    Help please! ~thanks
    j

    Comment by JDuran — October 26, 2007 @ 3:56 pm

  8. I found that works in my WPMU, good job!

    Comment by lukmanf — May 22, 2008 @ 12:15 pm

  9. Sounds intersting.. Tell me about my better submission I have a nice joke for you) What did the sailor say when he saw a boat loaded with ewes? Sheep ahoy!

    Comment by Altentscall — October 28, 2008 @ 7:19 pm

  10. Hello webmaster
    I would like to share with you a link to your site
    write me here preonrelt@mail.ru

    Comment by Alexwebmaster — March 3, 2009 @ 10:33 am

  11. Greetings the Web-master.
    I would like to take advantage of your plugin, but the reference for downloading is not good. You could not send this plugin on email AntonSurkont@gmail.com

    Comment by Antoha — July 14, 2009 @ 3:42 pm

  12. how you get to this fold in wordpress wp-content/mu-plugins/

    Comment by inesunsecuritycameras — August 20, 2009 @ 1:15 pm

  13. my cousing is very good in giving dog trainings, my favorite puppy was trained by him,’`

    Comment by Eyelid Surgery : — October 27, 2010 @ 7:45 pm

  14. professional dog trainings are expensive specially if you hire those dog trainers that can teach your dogs lots of tricks -:’

    Comment by Ways to earn money forum · — November 14, 2010 @ 1:52 pm

  15. *.. that seems to be a great topic, i really love it “;,

    Comment by Anxiety Symptoms Information — February 6, 2011 @ 5:01 pm


RSS feed for comments on this post. TrackBack URI

Leave a reply to zappoman Cancel reply

Create a free website or blog at WordPress.com.