Guest User

Untitled

a guest
Jun 28th, 2011
55
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. register_activation_hook( __FILE__ 'my_plugin_activation' );
  2.  
  3. function my_plugin_activation( $network_wide = false ) {
  4.  
  5.     global $wpdb;
  6.  
  7.     if ( $network_wide ) {
  8.  
  9.         $blogids = $wpdb->get_col($wpdb->prepare("
  10.             SELECT blog_id
  11.             FROM $wpdb->blogs
  12.             WHERE site_id = %d
  13.             AND deleted = 0
  14.             AND spam = 0
  15.         ", $wpdb->siteid));
  16.  
  17.         foreach ($blogids as $blog_id) {
  18.             switch_to_blog($blog_id);
  19.             my_plugin_install();
  20.         }
  21.  
  22.         restore_current_blog();
  23.  
  24.     } else {
  25.  
  26.         my_plugin_install();
  27.  
  28.     }
  29.  
  30. }
  31.  
  32. function my_plugin_install() {
  33.     /* Setup your tables here */
  34. }
RAW Paste Data