functionmyplugin_activate( $network_wide ){
global $wpdb;
if ( $network_wide ) {
$site_ids = $wpdb->get_col(
"SELECT blog_id FROM $wpdb->blogs"
);
foreach ( $site_ids as $site_id ) {
switch_to_blog( $site_id );
myplugin_install_table();
restore_current_blog();
}
} else {
myplugin_install_table();
}
}
Bad Example:
Multisite is handled, but Multinetwork is ignored.
Developer Best Practices
Plugins
functionmyplugin_activate( $network_wide ){
global $wpdb;
if ( $network_wide ) {
$site_ids = $wpdb->get_col(
"SELECT blog_id FROM $wpdb->blogs WHERE site_id = $wpdb->siteid"
);
foreach ( $site_ids as $site_id ) {
switch_to_blog( $site_id );
myplugin_install_table();
restore_current_blog();
}
} else {
myplugin_install_table();
}
}
Good Example:
Multisite and Multinetwork are handled.
Gist
if this session got you interested, I‘d love for you to start playing around with Multisite (and Multinetwork)
if you‘re a plugin developer, please make sure your code runs properly on Multisite/Multinetwork
if you find issues with Multisite, consider contributing to the Multisite component in WordPress Core – it is a pretty small team, so your help will be much appreciated
if you find issues with Multinetwork, consider helping out with the WP Multi Network plugin