diff --git a/bin/noblogs.in b/bin/noblogs.in index 91cb7103957ab1eabb77f6e13618fdd6ecce6218..980e618bb3fe553f1f1ef53eb74565fd673f8095 100755 --- a/bin/noblogs.in +++ b/bin/noblogs.in @@ -78,6 +78,9 @@ Known commands: fix-cdn BLOG Sets the correct CDN config. + rename-plugins BLOG + Disables old plugins and enables new ones, when there has been a change in names. + <?php exit(1); } @@ -505,6 +508,37 @@ function do_fix_cdn($args){ } } +// handles renaming of plugin: disables the old one, enables the new one +function do_rename_plugins($args){ + include_once(NOBLOGS_ROOT . '/wp-admin/includes/plugin.php'); + $rename = array( + 'wordpress-popular-post/wordpress-popular-posts.php' => 'wordpress-popular-posts/wordpress-popular-posts.php', + 'french-creative-commons-license-widget/ccLicense.php' => 'creative-commons-license-widget/ccLicense.php' + ); + foreach ($args as $arg) { + $blog = noblogs_get_blog($arg); + if (!$blog) { + echo "{$arg}: blog not found.\n"; + continue; + } + switch_to_blog($blog->blog_id); + + $plugin_dir = NOBLOGS_ROOT . '/wp-content/plugins/'; + foreach ($rename as $old => $new){ + if (is_plugin_active( $plugin_dir . $old )){ + deactivate_plugins($plugin_dir . $old, false, false); + $result = activate_plugin($plugin_dir . $new); + if (is_wp_error($result)){ + echo "{$arg}: " . $result->get_error_message(); + } else { + echo "{$arg}: $old \n"; + } + } + } + restore_currnt_blog(): + } +} + // Command-line parsing. $cmd = $argv[1]; if (!$cmd) {