Tags

, ,

I use Michael Simpson’s excellent template for writing WordPress plugins. At present it does not explicitly support multisite plugins. This is a cross-post of my investigation that I posted on his site.

Cross-post

Thank you Michael,

I have done a little reading

These are my early thoughts and will contain errors and omissions,

Multisite (hereafter “Network”) changes some things relevant to your template

  • Plugins may be activated once for all present and _future_ blogs (Network activation) or activated for individual blogs
  • Plugin data can be stored in tables at the Network level or in tables as individual blogs
  • Network support additional features including
    • superusers who manage a Network
    • Network options
      •  Plugin authors must decide what are plugin options that are typically available too blog administrators in a back-end administrator menu and what are network options that are only available to superusers in the network administrator menu.
  • Plugin code is called in the context of a blog with a $blog_id. This is important for reading and persisting data. For example, post data would be recalled from the current blog.

The implications for your template can be viewed through the lens of the template files,

  • my-cool-plugin.php
    • Comments to indicate that the author may set “Network: true” if the plugin is multisite compatible
  • MyCoolPlugin_Plugin.php
    • Must optionally check for deployment within a Network and have a different behaviour
  • MyCoolPlugin_LifeCycle.php
    • Lots of changes, needs to support Network Activation and/or activation of a single site within a Network
  • MyCoolPlugin_OptionsManager.php
    • Must support Network Options

At the moment it is true to say

  •  “this template does not support multisite plugins”

because there is not template code to support operation in a network.

I am not sure it is true to say

  • “this template is not multisite compatible”

The later sentence implies that a plugin written using this template must break. I think that this is not true. I have tested “Network activation” of plugin in a multisite network and it fails gracefully. That is to say that it simply returns with no message. When the plugin is activated on the site it works fine.

If upon review and further testing you agree with my conclusion you may wish to change your communication to,

Multisite Compatibility
A multisite network offers several capabilities to a plugin author such as network activation, network data storage and network options, that are not supported by this template. However a plugin written using this template should work correctly when activated within an individual site on the network.

Advertisements