Skip to content
Snippets Groups Projects
Commit 1b48135f authored by lucha's avatar lucha
Browse files

rename-blogs: deactivate old plugin name, and activates the new one

parent 1ced60c6
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment