diff --git a/classes/WP_Piwik.php b/classes/WP_Piwik.php index affbeea..9404f27 100644 --- a/classes/WP_Piwik.php +++ b/classes/WP_Piwik.php @@ -12,7 +12,7 @@ class WP_Piwik { * * @var Runtime environment variables */ - private static $revisionId = 2015051801, $version = '0.10.0.8', $blog_id, $pluginBasename = NULL, $logger, $settings, $request; + private static $revisionId = 2015051901, $version = '0.10.0.9', $blog_id, $pluginBasename = NULL, $logger, $settings, $request; /** * Constructor class to configure and register all WP-Piwik components @@ -933,7 +933,8 @@ public function request($id, $debug = false) { * Reset request object */ public function resetRequest() { - self::$request->reset(); + if (is_object(self::$request)) + self::$request->reset(); self::$request = NULL; } diff --git a/classes/WP_Piwik/Admin/Settings.php b/classes/WP_Piwik/Admin/Settings.php index 21cda47..a749654 100644 --- a/classes/WP_Piwik/Admin/Settings.php +++ b/classes/WP_Piwik/Admin/Settings.php @@ -18,12 +18,17 @@ public function show() { new \WP_Piwik\Admin\Sitebrowser(self::$wpPiwik); return; } - global $wp_roles; + if (isset($_GET['clear']) && $_GET['clear']) { + $this->clear($_GET['clear'] == 2); + self::$wpPiwik->resetRequest(); + self::$wpPiwik->updateTrackingCode(); + } if (isset ( $_POST ) && isset ( $_POST ['wp-piwik'] )) { $this->showBox ( 'updated', 'yes', __ ( 'Changes saved.' ) ); self::$wpPiwik->resetRequest(); self::$wpPiwik->updateTrackingCode(); } + global $wp_roles; ?>
runTestscript(); ?> -
+ @@ -543,7 +548,13 @@ public function showSupport() { _e('enabled','wp-piwik'); ?>. -

Run testscript. Sitebrowser.

+

:

+
    +
  1. +
  2. +
  3. +
  4. +

readRSSFeed('http://wordpress.org/support/rss/plugin/wp-piwik'); if (!empty($supportThreads)) { @@ -587,6 +598,33 @@ private function readRSSFeed($feed, $cnt = 5) { return $result; } + /** + * Clear cache and reset settings + * + * @param boolean $clearSettings set to true to reset settings (default: false) + */ + private function clear($clearSettings = false) { + if ($clearSettings) { + self::$settings->resetSettings(); + $this->showBox ( 'updated', 'yes', __ ( 'Settings cleared (except connection settings).' ) ); + } + global $wpdb; + if (self::$settings->checkNetworkActivation()) { + $aryBlogs = $wpdb->get_results('SELECT blog_id FROM '.$wpdb->blogs.' ORDER BY blog_id'); + if (is_array($aryBlogs)) + foreach ($aryBlogs as $aryBlog) { + switch_to_blog($aryBlog->blog_id); + $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_wp-piwik_%'"); + $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_timeout_wp-piwik_%'"); + restore_current_blog(); + } + } else { + $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_wp-piwik_%'"); + $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_timeout_wp-piwik_%'"); + } + $this->showBox ( 'updated', 'yes', __ ( 'Cache cleared.' ) ); + } + /** * Execute test script and display results */ diff --git a/classes/WP_Piwik/Settings.php b/classes/WP_Piwik/Settings.php index 4fd1ffc..e341201 100644 --- a/classes/WP_Piwik/Settings.php +++ b/classes/WP_Piwik/Settings.php @@ -91,7 +91,7 @@ class Settings { 'track_datacfasync' => false, 'track_cdnurl' => '', 'track_cdnurlssl' => '', - 'force_protocol' => 'disabled' + 'force_protocol' => 'disabled' ), $settings = array ( 'name' => '', 'site_id' => NULL, @@ -234,7 +234,8 @@ public function resetSettings($resetAll = false) { 'piwik_token' => $this->getGlobalOption ( 'piwik_token' ), 'piwik_url' => $this->getGlobalOption ( 'piwik_url' ), 'piwik_path' => $this->getGlobalOption ( 'piwik_path' ), - 'piwik_mode' => $this->getGlobalOption ( 'piwik_mode' ) + 'piwik_user' => $this->getGlobalOption ( 'piwik_user' ), + 'piwik_mode' => $this->getGlobalOption ( 'piwik_mode' ) ); if (is_plugin_active_for_network ( 'wp-piwik/wp-piwik.php' )) { delete_site_option ( 'wp-piwik_global-settings' ); diff --git a/readme.txt b/readme.txt index c1e6f2d..0952f84 100644 --- a/readme.txt +++ b/readme.txt @@ -127,6 +127,10 @@ This is a full refactored version of WP-Piwik. Please check your settings after == Changelog == += 0.10.0.9 = +* Add clear cache function. +* Add clear settings function. + = 0.10.0.8 = * Bugfix: Sitebrowser link (settings page, support) fixed * Bugfix: Use new settings directly after saving (reloading is not necessary anymore) diff --git a/uninstall.php b/uninstall.php index f41c01e..ca6f338 100644 --- a/uninstall.php +++ b/uninstall.php @@ -82,7 +82,6 @@ $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_wp-piwik_%'"); $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_timeout_wp-piwik_%'"); restore_current_blog(); - } foreach ($globalSettings as $key) delete_site_option('wp-piwik_global-'.$key); diff --git a/update/2015051101.php b/update/2015051101.php index 664639b..6036f65 100644 --- a/update/2015051101.php +++ b/update/2015051101.php @@ -12,7 +12,7 @@ $oldOptions = get_option ( 'wp-piwik_settings', array () ); delete_option('wp-piwik_settings'); -if (function_exists('is_multisite') && is_multisite()) { +if (self::$settings->checkNetworkActivation ()) { global $wpdb; $aryBlogs = $wpdb->get_results('SELECT blog_id FROM '.$wpdb->blogs.' ORDER BY blog_id'); if (is_array($aryBlogs)) diff --git a/wp-piwik.php b/wp-piwik.php index 016879b..3a785d8 100755 --- a/wp-piwik.php +++ b/wp-piwik.php @@ -6,7 +6,7 @@ Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress header. -Version: 0.10.0.8 +Version: 0.10.0.9 Author: André Bräkling Author URI: http://www.braekling.de Text Domain: wp-piwik