Skip to content

Instantly share code, notes, and snippets.

@boonebgorges
Last active September 21, 2015 19:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boonebgorges/25ba440369b875372656 to your computer and use it in GitHub Desktop.
Save boonebgorges/25ba440369b875372656 to your computer and use it in GitHub Desktop.
Fix changed plugin filename across a network
<?php
// Use: $ wp eval-file fix-changed-plugin-filename.php
global $wpdb;
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
$p = 'list-category-posts/list_cat_posts.php';
$new_p = 'list-category-posts/list-category-posts.php';
foreach ( $blog_ids as $blog_id ) {
$bplugins = (array) get_blog_option( $blog_id, 'active_plugins' );
$ploc = array_search( $p, $bplugins );
if ( false !== $ploc && ! in_array( $p_new, $bplugins ) ) {
unset( $bplugins[ $ploc ] );
$bplugins[] = $new_p;
sort( $bplugins );
update_blog_option( $blog_id, 'active_plugins', $bplugins );
echo "Reactivated plugin on $blog_id\n";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment