Commit 2ab91ecb authored by lucha's avatar lucha

added wp-piwik-clear-conf command

parent 7c8532b4
Pipeline #1528 passed with stages
in 1 minute and 11 seconds
......@@ -84,6 +84,9 @@ Known commands:
uninstall-plugin PLUGIN BLOG
Runs unistall action for PLUGIN.
wp-piwik-clear-config BLOG
Clear the configuration for wp-piwik plugin.
<?php
exit(1);
}
......
......@@ -10,6 +10,7 @@ require_once(dirname(__FILE__) . '/blogs.php');
require_once(dirname(__FILE__) . '/cron.php');
require_once(dirname(__FILE__) . '/friends.php');
require_once(dirname(__FILE__) . '/editfiles.php');
require_once(dirname(__FILE__) . '/wp-piwik.php');
// Load the Wordpress api.
define('WP_CACHE',false);
......
<?php
$wp_piwik_options_to_delete = array(
'wp-piwik_displayto',
'wp-piwik_revision',
'wp-piwik-track_404'
);
$wp_piwik_options_to_blank = array(
'wp-piwik-name',
'wp-piwik-noscript_code',
'wp-piwik-site_id',
'wp-piwik-tracking_code'
);
function do_wp_piwik_clear_config($args){
foreach ($args as $arg) {
$blog = noblogs_get_blog($arg);
if (!$blog) {
echo "Blog {$arg} not found.\n";
continue;
}
switch_to_blog($blog->blog_id);
echo "Clearing options for wp-piwik for blog {$arg}\n";
foreach ($opt in $wp_piwik_options_to_delete) {
if (get_option($opt))
delete_option($opt);
}
foreach ($opt in $wp_piwik_options_to_blank) {
update_option($opt,'');
}
restore_current_blog();
}
}
// [*] functioning site
// * wp-piwik-dashboard_revision
// wp-piwik_displayto
// * wp-piwik-last_tracking_code_update
// * wp-piwik-name
// * wp-piwik-noscript_code
// wp-piwik_revision
// * wp-piwik-site_id
// wp-piwik-track_404
// * wp-piwik-tracking_code
// +------------------------------------+--------------+
// | option_name | option_value |
// +------------------------------------+--------------+
// | wp-piwik-dashboard_revision | 0 |
// | wp-piwik-last_tracking_code_update | 1541989337 |
// | wp-piwik-name | |
// | wp-piwik-noscript_code | |
// | wp-piwik-site_id | |
// | wp-piwik-tracking_code | |
// +------------------------------------+--------------+
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment