Skip to content

Commit

Permalink
0.10.0.9 release
Browse files Browse the repository at this point in the history
git-svn-id: https://plugins.svn.wordpress.org/wp-piwik/trunk@1163684 b8457f37-d9ea-0310-8a92-e5e31aec5664
  • Loading branch information
Braekling authored and Braekling committed May 19, 2015
1 parent 7548743 commit 865c888
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 43 deletions.
4 changes: 3 additions & 1 deletion classes/WP_Piwik.php
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,10 @@ private function isUpdated() {
*/
private function isInstalled() {
$oldSettings = $this->getWordPressOption ( 'wp-piwik_global-settings', false );
if ($oldSettings && isset( $oldSettings['revision'] ))
if ($oldSettings && isset( $oldSettings['revision'] )) {
self::log('Save old settings');
self::$settings->setGlobalOption ( 'revision', $oldSettings['revision'] );
} else self::log( 'Current revision '.self::$settings->getGlobalOption ( 'revision' ) );
return self::$settings->getGlobalOption ( 'revision' ) > 0;
}

Expand Down
8 changes: 4 additions & 4 deletions classes/WP_Piwik/Admin/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public function show() {
if (isset($_GET['clear']) && $_GET['clear']) {
$this->clear($_GET['clear'] == 2);
self::$wpPiwik->resetRequest();
self::$wpPiwik->updateTrackingCode();
}
if (isset ( $_POST ) && isset ( $_POST ['wp-piwik'] )) {
echo '<form method="post" action="?page='.$_GET['page'].'"><input type="submit" value="'.__('Reload', 'wp-piwik').'" /></form>';
return;
} elseif (isset ( $_POST ) && isset ( $_POST ['wp-piwik'] )) {
$this->showBox ( 'updated', 'yes', __ ( 'Changes saved.' ) );
self::$wpPiwik->resetRequest();
self::$wpPiwik->updateTrackingCode();
Expand Down Expand Up @@ -553,7 +553,7 @@ public function showSupport() {
<li><a href="<?php echo admin_url( (self::$settings->checkNetworkActivation () ? 'network/settings' : 'options-general').'.php?page='.$_GET['page'].'&testscript=1' ); ?>"><?php _e('Run testscript', 'wp-piwik'); ?></a></li>
<li><a href="<?php echo admin_url( (self::$settings->checkNetworkActivation () ? 'network/settings' : 'options-general').'.php?page='.$_GET['page'].'&sitebrowser=1' ); ?>"><?php _e('Sitebrowser', 'wp-piwik'); ?></a></li>
<li><a href="<?php echo admin_url( (self::$settings->checkNetworkActivation () ? 'network/settings' : 'options-general').'.php?page='.$_GET['page'].'&clear=1' ); ?>"><?php _e('Clear cache', 'wp-piwik'); ?></a></li>
<li><a onclick="return confirm('<?php _e('Are you sure you want to clear all settings except the connection settings?', 'wp-piwik'); ?>')" href="<?php echo admin_url( (self::$settings->checkNetworkActivation () ? 'network/settings' : 'options-general').'.php?page='.$_GET['page'].'&clear=2' ); ?>"><?php _e('Clear cache and settings except connection settings', 'wp-piwik'); ?></a></li>
<li><a onclick="return confirm('<?php _e('Are you sure you want to clear all settings?', 'wp-piwik'); ?>')" href="<?php echo admin_url( (self::$settings->checkNetworkActivation () ? 'network/settings' : 'options-general').'.php?page='.$_GET['page'].'&clear=2' ); ?>"><?php _e('Reset WP-Piwik', 'wp-piwik'); ?></a></li>
</ol>
<h3><?php _e('Latest support threads on WordPress.org', 'wp-piwik'); ?></h3><?php
$supportThreads = $this->readRSSFeed('http://wordpress.org/support/rss/plugin/wp-piwik');
Expand Down
2 changes: 1 addition & 1 deletion classes/WP_Piwik/Admin/Sitebrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function prepare_items() {
if (empty ( $dataset ['piwikid'] ) || $dataset ['piwikid'] == 'n/a')
$this->data [$key] ['piwikid'] = __ ( 'Site not created yet.', 'wp-piwik' );
if ($this->wpPiwik->isNetworkMode ())
$this->data [$key] ['name'] = '<a href="?page=wp-piwik_stats&wpmu_show_stats=' . $dataset ['id'] . '">' . $dataset ['name'] . '</a>';
$this->data [$key] ['name'] = '<a href="index.php?page=wp-piwik_stats&wpmu_show_stats=' . $dataset ['id'] . '">' . $dataset ['name'] . '</a>';
}
$this->items = $this->data;
return count ( $this->items );
Expand Down
49 changes: 14 additions & 35 deletions classes/WP_Piwik/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function save() {
}
self::$wpPiwik->log ( 'Save settings' );
foreach ( $this->globalSettings as $key => $value ) {
if (is_plugin_active_for_network ( 'wp-piwik/wp-piwik.php' ))
if ( $this->checkNetworkActivation() )
update_site_option ( 'wp-piwik_global-' . $key, $value );
else
update_option ( 'wp-piwik_global-' . $key, $value );
Expand Down Expand Up @@ -183,7 +183,7 @@ public function getGlobalOption($key) {
*/
public function getOption($key, $blogID = null) {
if ($this->checkNetworkActivation () && ! empty ( $blogID )) {
return get_blog_option ( $blogID, $key );
return get_blog_option ( $blogID, 'wp-piwik-'.$key );
}
return isset ( $this->settings [$key] ) ? $this->settings [$key] : self::$defaultSettings ['settings'] [$key];
}
Expand Down Expand Up @@ -216,49 +216,28 @@ public function setOption($key, $value, $blogID = null) {
$this->settingsChanged = true;
self::$wpPiwik->log ( 'Changed option ' . $key . ': ' . $value );
if ($this->checkNetworkActivation () && ! empty ( $blogID )) {
add_blog_option ( $blogID, $key, $value );
add_blog_option ( $blogID, 'wp-piwik-'.$key, $value );
} else
$this->settings [$key] = $value;
}

/**
* Reset settings to default
*
* @param bool $resetAll
* set to true to clear authentification settings, too
*/
public function resetSettings($resetAll = false) {
public function resetSettings() {
self::$wpPiwik->log ( 'Reset WP-Piwik settings' );
global $wpdb;
$keepSettings = array (
'piwik_token' => $this->getGlobalOption ( 'piwik_token' ),
'piwik_url' => $this->getGlobalOption ( 'piwik_url' ),
'piwik_path' => $this->getGlobalOption ( 'piwik_path' ),
'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' );
$blogs = $wpdb->get_results ( 'SELECT blog_id FROM ' . $wpdb->blogs . ' ORDER BY blog_id' );
foreach ( $blogs as $blog )
foreach ( $this->settings as $key => $value )
delete_blog_option ( $blog->blog_id, 'wp-piwik-' . $key );
if (! $resetAll)
update_site_option ( 'wp-piwik_global-settings', $keepSettings );
} else {
foreach ( $this->globalSettings as $key => $value )
delete_option ( 'wp-piwik_global-' . $key );
foreach ( $this->settings as $key => $value )
delete_option ( 'wp-piwik-' . $key );
if ( $this->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 'wp-piwik-%'");
restore_current_blog();
}
$wpdb->query("DELETE FROM $wpdb->sitemeta WHERE meta_key LIKE 'wp-piwik_global-%'");
}
$this->globalSettings = self::$defaultSettings ['globalSettings'];
$this->settings = self::$defaultSettings ['settings'];
if (! $resetAll) {
self::$wpPiwik->log ( 'Restore connection settings' );
foreach ( $keepSettings as $key => $value )
$this->setGlobalOption ( $key, $value );
}
$this->save ();
else $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'wp-piwik_global-%'");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion languages/wp-piwik.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WP-Piwik 0.10.0.9\n"
"Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/wp-piwik\n"
"POT-Creation-Date: 2015-05-19 20:12:29+00:00\n"
"POT-Creation-Date: 2015-05-19 22:00:43+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ This is a full refactored version of WP-Piwik. Please check your settings after

= 0.10.0.9 =
* Add clear cache function.
* Add clear settings function.
* Add clear settings (reset) function.

= 0.10.0.8 =
* Bugfix: Sitebrowser link (settings page, support) fixed
Expand Down

0 comments on commit 865c888

Please sign in to comment.