Last active
September 21, 2015 19:31
-
-
Save boonebgorges/25ba440369b875372656 to your computer and use it in GitHub Desktop.
Fix changed plugin filename across a network
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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