WPMU Administration Plugins

As I browsed through the competition plugins here on wpmu.org, I noticed that several of them were strictly administration plugins.  Meaning all of the actions were strictly used once a user is logged in and within the administration menu.

Yet on the installations they were still being placed in the mu-plugins folder.

Here are my thoughts and please correct me if I am wrong, which wouldn’t be the first and certainly not the last.

Every person/bot/spider/rss feed/etc that requests one of the pages on one of your blogs, will loop through the entire mu-plugins folder.

If you have 50 plugins in there, that could potentially take up a lot of needed resources on your server, especially if the plugin deals strictly with administration features.  Why should an average reader have to load 5-10 files of administration plugins when they will never use them?

A different approach:

Create a separate folder in your wp-content folder.  Let’s call it admin-plugins. ie. /wp-content/admin-plugins. Then every mu plugin that strictly deals with administration side functions, meaning in the wp-admin area, drop it in that folder.

Then in your mu-plugins folder, you can add this file:

http://realestatetomato.com/wpmu-director.txt

(Copy file, paste in source code editor, change name to wpmu-director.php, upload to mu-plugins)

This small piece of code will determine whether or not the /wp-admin section of the blog is being called then and only then, load your mu administration plugins.

I would love to hear your guy’s thoughts on this…

What say you?

Tags ,

Comments (22)

  1. Would an alternative be to put the plugin in the regular plugin folder, and then deactivate it for userblogs, deactivate user conntrol over it, and allow it solely for the main blog? (using plugin commander). That way you needn’t introduce nonstandard directories.

    unrelated – the list of plugins submitted for the Competition seems to be out of date on the official contest page.

  2. The advantage of putting a plugin in the plugins directory is that it can be activated per blog. domain1.com has plugin A running on it while domain2.com does not.

    So the files for that plugin will be parsed for domain1.com/wp-admin and domain1.com/post1 but not for domain2.com/wp-admin or domain2.com/post1.

    The idea with mu-plugins is that they are parsed for domain1.com/wp-admin, domain1.com/post, domain2.com/wp-admin, domain2.com/post1.

    If you create an admin-plugins directory then the files would be parsed if domain1.com/wp-admin and domain2.com/wp-admin but not for domain1.com/post and domain2.com/post

    As long as you put the nonstandard directories in your wp-content folder, it shouldn’t cause you any problems, as when you upgrade that is the one folder you don’t delete.

  3. ok guys, let me repeat this:

    putting plugins into this new folder, instaed of mu-plugins folder helps by not loading the plugins if the user is not browsing in the backend, right?

    I sugest you take the is_admin check out, because a blog owner can add unlimited users who might not be admins but also use plugins that are active inside the backend…

    Btw. how does a plugin inside mu-plugins comapre to a plugin inside plugins folder (automatically activated by plugin commander? is it the same? will it be called as often?

    I think the idea Jason had is pretty brilliant, but I will not use the is_admin check. Thx for sharing the idea :-)

  4. Right.

    is_admin() is actually a template function which searches the uri request path and returns true if it finds wp-admin/. You can find this file in wp-includes/functions.php. I think you are thinking of is_site_admin() which will verify if the user is a site admin or not.

    function is_admin () {
    global $wp_query;

    return ( $wp_query->is_admin || strstr($_SERVER[‘REQUEST_URI’], ‘wp-admin/’) );
    }

    The mu-plugins folder gets looped through per load in the wp-settings.php file.

    Plugin Commander attaches itself to the wpmunewblog action hook and auto activates various plugins.

    Differences that I can see right off the bat. Several plugins actually install tables and what not with a wordpress activation hook. I can think of cforms, which I use on a lot of my blogs. I don’t believe you can dump this in the mu-plugins folder because it needs to be activated or installed. Plugin commander works quite nicely for this need.

    Mu-plugins folder is set up for more global changes. For instance, tomorrow morning there will be an article that I published explaining the benefits of a global robots.txt file which is a perfect example of a plugin that works better as a mu-plugin instead of a plugins plugin :)

  5. What do you mean it’s not compatible? What error are you receiving?

    I haven’t looked at ah_recent_posts_mu but right off the bat it looks like the plugin adds functionality to the external side of the blog. Meaning not admin, and should not be included in the admin-plugins folder.

  6. Админчег :) У меня к тебе небольшое предложение, хоть и не по теме блога ;) Напиши пожалуйста свой обзор передачи Гордон Кихот. Особенно прошлый выпуск, про Шансон.

    Спасибо :) Удачи дружище

  7. wpmu.org, админ. Кто писал про последнее китайское предупреждение ? Извини. Я надеюсь мы найдем компромисс ? 1. Поставь на блог-комментирование хорошую каптчу. 2. Пошли урлы своих блогов сюда [email protected] и ты избавишься от меня. Ещё раз приношу извинения. издержки производства…

  8. Hey, I’ve been using your plugin and found an issue. It breaks any plugin that tries to add buttons to TinyMCE, because when the system makes a callback to load PHP files from wp-include, it’s not technically an “admin” page. I’m not sure if there’s an easy way to address this but I thought I’d let ya know. Thanks for the clever idea, it works well for other plugins!

  9. @steve Thanks for the heads up. In my installation I actually have a wpmu-sites.php and wpmu-companies.php file in my wp-admin directory. But for the plugin competition, I tried moving everything over to the plugin files. Which brought some unexpected results/bugs. I will be spending some more time in the near future fixing it up, cleaning bugs and releasing some new features.

Participate