The MU forums have moved to WordPress.org

WP Plugin developer looking for WPMU documentation (9 posts)

  1. mark8barnes
    Member
    Posted 16 years ago #

    I'm the author of a WP plugin, and some of my users have asked for WPMU compatibility. I'd like to oblige, but the lack of documentation is killing me.

    Somewhere I'm sure there's a nice little page explaining what will work, and what won't, and listing WPMU-specific functions, ideally with some work-arounds for common coding problems.

    The difficulty is, I can't find that page. Can anyone help?

  2. demonicume
    Member
    Posted 16 years ago #

    Somewhere I'm sure there's a nice little page explaining what will work, and what won't, and listing WPMU-specific functions, ideally with some work-arounds for common coding problems.

    lol. you better talk to Andrea.

  3. lunabyte
    Member
    Posted 16 years ago #

    What is this "documentation" you speak of?

    Never heard of it. ;)

    Although [unknown] once told me that if it's a b***h to write, is should be a b***h to understand. :D

  4. cafespain
    Member
    Posted 16 years ago #

    Have a look at the following:
    http://mu.wordpress.org/forums/topic.php?id=3792

    http://mu.wordpress.org/forums/topic.php?id=3043

    and

    http://mu.wordpress.org/forums/topic.php?id=8314

    Though in essence plugins for the two platforms are basically the same AS LONG AS you don't assume things and use the built in WordPress functions to get values.

    A few examples:
    1. Don't assume that the plugin will be placed in a wp-content/plugins directory it might be placed in mu-plugins.
    2. Don't assume that it will be in it's own directory - as far as I recall plugins placed in mu-plugins can't be in a sub-dir (though their images, etc can).
    3. The upload directory works differently in mu - the value stored in the options is the directory to write to but shouldn't (in my opinion) be the one to use in URLs.
    4. I've found that Activiation code isn't fired when a plugin is placed in the mu-plugins directory, though that's probably something I've done (please correct me if wrong).

    If you want an example of a plugin that works in both the standard plugins directory and the mu-plugins directory have a look at the Vent plugin code. I'm not saying it's a textbook example (or even very good), but there is code in there for the plugin to determine it's own location (even down to the renaming of the plugins directory or main php file) and handle things appropriately.

    http://blog.clearskys.net/plugins/vent-events-system/

  5. cafespain
    Member
    Posted 16 years ago #

    Oh yeah, don't assume that table names are wp_myname.
    WordPress MU adds a blog identifier to the name, eg. wp_23_myname

  6. andrea_r
    Moderator
    Posted 16 years ago #

    "lol. you better talk to Andrea. "

    Oh, very funny. :D I'm typing as fast as I can. cafespain is right on with his examples.

    this documentation you're looking for doesn't exist yet. :)

  7. mark8barnes
    Member
    Posted 16 years ago #

    OK, that's helpful, thank you - particularly cafespain.

    (1) In WP2.6 the plug-in folder can be moved, so I've had to update my code to cope with this. That is: WP_CONTENT_DIR.'/plugins/'.plugin_basename(dirname(__FILE__))
    Presumably this will have the additional effect of coping with WPMU's plugin-folder. (Possibly renaming "plugins" to "wpmu-plugins" if WPMU is detected.)

    (2) OK, that's easy enough.

    (3) My plugin does a LOT of uploading. Are you saying WPMU has rewrite rules for hiding the true upload path? Can you point me in the direction of more help here?

    (4) I don't use activation code, so that's OK.

    I'm already using $wpdb->prefix and $wpdb->posts, so database calls should be OK, I think.

    There also needs to be the issue of global/local admin. Can I presume that add_menu_page adds a menu in the local admin. Can you point me to documentation for creating a site-wide administrative menu?

    I guess the best thing I can do is to install a copy of WPMU and get testing ;-)

  8. cafespain
    Member
    Posted 16 years ago #

    Hi
    Yes the easiest is to get a copy up and running and then play.
    Once you are more familiar you'll find that you can do most of your development and testing on standard WordPress and then just do the last bits on MU (for non-MU only plugins of course).

    The htaccess for MU rewrites http://sub.domain.com/files/thefile.jpg to the correct location held in the uploads directory (something along the lines of http://sub.domain.com/wp-content/blogs.dir/23/files/thefile.jpg ).

    The site admin page (Site Admin) is wpmu_admin.php, so adding a sub menu to that file will put it under the the Site Admin menu only. You can also use is_site_admin() to check if the current user is a site administrator rather than just a blog administrator.

  9. mark8barnes
    Member
    Posted 16 years ago #

    Thanks very much for the help, guys. I was pleasantly surprised how straightforward this was. Actually, there were benefits too, as WPMU brought to my attention a few bugs which I might not have spotted otherwise.

    Although I managed without documentation, it's lack is very off-putting. I'm sure many, many more plug-in authors would provide WPMU compatibility if there was even one page on the wiki which gave some of the advice you gave me, plus some other pointers.

    If there are other WP plugin writers reading this, can I encourage you to go for compatibility. My plug-in is pretty complex (approaching 4,000 lines of code) I'm not a WP expert (this is my first plugin, and half the code was written by someone else), and I'd never used WPMU 24 hours ago. But now (I think!) I'm compatible.

    Here's a link to the diff which shows just what changes were necessary.

    I don't pretend it's a perfect solution, and there's one or two extra features I probably ought to add for site admin, but I hope it demonstrates that WPMU compatibility isn't as hard as it appears. If I can do it...

About this Topic

  • Started 16 years ago by mark8barnes
  • Latest reply from mark8barnes