The MU forums have moved to WordPress.org

differences for plugins between WP and WPMU? (15 posts)

  1. pixline
    Member
    Posted 15 years ago #

    exactly: what are the differences in writing regular wordpress plugins, regular plugins that works with wpmu, and mu-plugins? I have a big confusion about them, and references online aren't explicit enough for me....

  2. zappoman
    Member
    Posted 15 years ago #

    In general they are the same, they use the same APIs, but when you place a plugin in the mu-plugins directory the code will be executed for all blogs all the time. When you place the code in plugins directory, each blog can individually turn them on or off.

    Also the DB schemas are obviously a little bit different between WP and WPmu, particularly if you want to do tricky stuff... so theoretically a plugin designed exclusively for MU might not work in standard WP.

  3. plcom
    Member
    Posted 15 years ago #

    This MAY be a stupid question, dont shoot me if it is.

    Can I place ANY plugin in the MU-Plugin directory if I want it operational for all?

    Some directions say to install in plugin directory, but I am wondering if I can still put them in MU to automatically install for all.

  4. zappoman
    Member
    Posted 15 years ago #

    It all depends on the plugin. There could be nuances to the plugin that make it not function properly when run in this manner.

    If I want the behavior to always be on for all blogs, and I am confident in the code (you gotta test it) then I'd put it in mu-plugins... but you also don't want to pollute mu-plugins with a lot of cruft, so make sure to only put the plugins you really want/need in there.

  5. andrewbillits
    Member
    Posted 15 years ago #

    Also, keep in mind that whatever goes into mu-plugins gets loaded every time any page is loaded. If you put a very bloated plugin in mu-plugins, it WILL make page loads a bit slower.

  6. suleiman
    Member
    Posted 15 years ago #

    so here's my question:

    Widgets. What if i put widgets in my mu-plugins folder?

    I thought they would only activate if the user put them in their sidebar. But does one user putting a widget in their sidebar make it "active" for all? Hence loading on each and every blog even those without that widget enabled? Me think no, but me sometimes no think.

  7. Ovidiu
    Member
    Posted 15 years ago #

    I asked a similar question once and I udnerstood the answer like this: yes anything inside mu-plugins gets loaded every time, whether its needed or now, so placing anrchy media player there loads it for every single blog/page in the whole wpmu installation.

    That made me rethink my strategy of putting all widgets inside mu-plugins folder :-)

  8. zappoman
    Member
    Posted 15 years ago #

    I guess the other thing to consider though is how savvy you believe your users to be. For example, I don't think I want to assume that my users are smart enough to first go to their plugins page in their dashboard to turn on a plugin before they can use those widgets.

    I haven't gotten to the point yet in my deployment where this question matters, but when I get there, my plan is to make all of my widgets enabled sitewide, and try to make only very few plugins left for the user to turn on.

    In order to make this scalable I plan to research exactly how each plugin and widget works before I deploy it. For example, I could imagine that a widget does something really stupid on every page load... and therefore I wouldn't want to deploy that particular widget in my deployment.

    There is a consistent theme I see mentioned in this forum, and I think it is particularly important when you consider how to manage plugins. That theme is this: remember that MU is server software... and so you have to have an appropriate level of sophistication and experience to operate it.

    So on the point of plugins: I think you should look at the code. This is a good thing about open source. Determine for yourself whether you want that code running on EVERY page load.

    If a widget is installed but not enabled on the page, as I understand the WP code base, it's php file still gets loaded and parsed and it's main code section is still executed. Maybe it's rendering functions aren't executed, but something is... Do you want that code running on every page?

  9. pixline
    Member
    Posted 15 years ago #

    Ok, now I've learned enough about the semantic differences... But what about the code ones? In which case a regular wordpress plugin won't work with WPMU? What should I take care of?

  10. Ovidiu
    Member
    Posted 15 years ago #

    have a closer look at the wp prefix stuff the specific plugin is using.

    wpmu uses your prefix for general tables, i.e. wp_users and another prefix for specific blogs settings/tables, like your_prefix_$blog_id_table name, i.e. wp_6_forum so check out the plugin details to see if it creates the tables right.

  11. zappoman
    Member
    Posted 15 years ago #

    I wish there was a good answer to the question that pixline is asking, but the challenge (and one of the benefits) of open source code is that developers can see inside the details of the platform code and make assumptions (some might say hacks) about how the platform code will be maintained into the future. When those assumptions are good ones, no problems, when those assumptions are mistaken... incompatibility can happen.

    So for example, to Ovidiu's point, a WordPress plugin developer could easily have looked into the internals of wordpress and said "oh, hey they always create a 'posts' table with a prefix of $table_prefix... so I can just call the SQL calls directly with those table names". And of course in Wordpress that plugin will run fine, but in WordpressMU it will get a SQL error of unknown table name. Theoretically the code could have been originally written to use $wpdb->posts and that code would work correctly in both WP and WPmu, because WPmu does the magic to change that variable to point to the correct blog's table names when the blogs are navigated to.

    To enumerate all the nuanced differences would be impossible (or at least really hard)... but in general, well written plugins for WP will work fine out of the box in WPmu, but there are always corner cases, of course, and that's why you should test them before you deploy them.

    Good luck! I think you'll discover as you work with MU more that it really is a very elegant solution, and most things work very well right out of the box.

  12. pixline
    Member
    Posted 15 years ago #

    Just to reopen this thread, I've finally found a real demo of my doubts.

    Installing as a regular plugin would install, but the software isn't ready for WPMU and it can't work. Anyway I'm trying to install Open Web Analytics on a WPMU site as mu-plugin, and it don't even show in the dashboard.

    This mean that something in a plugin won't work as a mu-plugin and needs to be manually set up by users, and I can't understand what it is. Any ideas?

    (btw: I'll report wpmu bugs to owa soon)

  13. jaredbangs
    Member
    Posted 15 years ago #

    Do you have a link for that plugin?

    There's nothing particular that needs to always be done differently on MU, but there are some things that may not work the way you expect if you're coming from standard WP.

    Usually, the problem comes down to assumptions that the plugin author makes about operating in a single-blog environment.

    I've written several plugins that work without modification on both MU and standard WP; it just depends on what you're trying to do.

  14. pixline
    Member
    Posted 14 years ago #

    I've finally understand what I was looking for: WPMU plugins *NEEDS* a single file in mu-plugin folder, even if the whole plugin is in a subdirectory. That's why many plugins can't load.

    Simply include the plugin file in another php, placed straight in mu-plugin, will load quite anything. I wonder if it's just me or is a common misunderstanding :)

  15. lunabyte
    Member
    Posted 14 years ago #

    99% of plugins can be dropped in the /plugins/ directory as usual.

    MU plugins is reserved for things that must be loaded on every single page, for every single blog.

About this Topic

  • Started 15 years ago by pixline
  • Latest reply from lunabyte