[wp-hackers] Plugins and network activations
johnbillion+wp at gmail.com
Tue Jun 28 12:21:48 UTC 2011
On 28 June 2011 12:42, Dino Termini <dino at duechiacchiere.it> wrote:
> Hi all,
> I've developed a plugin for Wordpress that needs some extra tables in order
> to work properly. A few users have complained that when they try to
> "network-activate" it, it only works on the main blog.
> So I found this discussion about how Wordpress should support these
> activations, but I don't understand how we plugin developers should handle
> the activation process
> Can someone please elaborate on it, maybe posting an example or a snippet of
This  is the code I use in one of my plugins. Basically you detect
if the activation is network-wide or not, and loop over each blog,
installing the tables in turn.
*Beware* though, that this code is likely to timeout (ie. hit PHP's
script execution time limit) if you have hundreds of blogs in your
network, especially if you're adding tables to each blog. My plugin is
only deployed in controlled environments so I know it'll be fine. If
your plugin is going to be made publicly available you should look
into a method similar to what scribu does in his Proper Network
Activation plugin .
More information about the wp-hackers