Version Description
- Bugfix: Option storage bug if WP-Piwik is used as single site plugin on blog networks
- Bugfix: WP-Piwik will work without Piwik superuser access, again
Download this release
Release Info
Developer | Braekling |
Plugin | WP-Matomo (WP-Piwik) |
Version | 0.10.0.6 |
Comparing to | |
See all releases |
Code changes from version 0.10.0.5 to 0.10.0.6
- classes/WP_Piwik.php +43 -8
- classes/WP_Piwik/Admin/Settings.php +7 -3
- classes/WP_Piwik/Request.php +1 -1
- readme.txt +5 -1
- wp-piwik.php +1 -1
classes/WP_Piwik.php
CHANGED
@@ -12,7 +12,7 @@ class WP_Piwik {
|
|
12 |
*
|
13 |
* @var Runtime environment variables
|
14 |
*/
|
15 |
-
private static $intRevisionId = 2015051101, $version = '0.10.0.
|
16 |
|
17 |
/**
|
18 |
* Constructor class to configure and register all WP-Piwik components
|
@@ -202,7 +202,7 @@ class WP_Piwik {
|
|
202 |
self::$logger->log ( 'Running WP-Piwik uninstallation' );
|
203 |
if (! defined ( 'WP_UNINSTALL_PLUGIN' ))
|
204 |
exit ();
|
205 |
-
|
206 |
self::$settings->resetSettings ( true );
|
207 |
}
|
208 |
|
@@ -237,13 +237,13 @@ class WP_Piwik {
|
|
237 |
* set to true if the message should persist (default: false)
|
238 |
*/
|
239 |
private function addNotice($type, $subject, $text, $stay = false) {
|
240 |
-
$notices =
|
241 |
$notices [$type] = array (
|
242 |
'subject' => $subject,
|
243 |
'text' => $text,
|
244 |
'stay' => $stay
|
245 |
);
|
246 |
-
|
247 |
}
|
248 |
|
249 |
/**
|
@@ -253,14 +253,14 @@ class WP_Piwik {
|
|
253 |
*/
|
254 |
public function showNotices() {
|
255 |
$link = sprintf ( '<a href="' . $this->getSettingsURL () . '">%s</a>', __ ( 'Settings', 'wp-piwik' ) );
|
256 |
-
if ($notices =
|
257 |
foreach ( $notices as $type => $notice ) {
|
258 |
printf ( '<div class="updated fade"><p>%s <strong>%s:</strong> %s: %s</p></div>', $notice ['subject'], __ ( 'Important', 'wp-piwik' ), $notice ['text'], $link );
|
259 |
if (! $notice ['stay'])
|
260 |
unset ( $notices [$type] );
|
261 |
}
|
262 |
}
|
263 |
-
|
264 |
}
|
265 |
|
266 |
/**
|
@@ -595,7 +595,7 @@ class WP_Piwik {
|
|
595 |
* @return boolean Is WP-Piwik installed?
|
596 |
*/
|
597 |
private function isInstalled() {
|
598 |
-
$oldSettings =
|
599 |
if ($oldSettings && isset( $oldSettings['revision'] ))
|
600 |
self::$settings->setGlobalOption ( 'revision', $oldSettings['revision'] );
|
601 |
return self::$settings->getGlobalOption ( 'revision' );
|
@@ -969,7 +969,7 @@ class WP_Piwik {
|
|
969 |
* @return array Piwik sites
|
970 |
*/
|
971 |
public function getPiwikSiteDetails() {
|
972 |
-
$id = WP_Piwik\Request::register ( 'SitesManager.
|
973 |
$piwikSiteDetails = $this->request ( $id );
|
974 |
return $piwikSiteDetails;
|
975 |
}
|
@@ -1165,4 +1165,39 @@ class WP_Piwik {
|
|
1165 |
check_admin_referer ( 'wp-piwik_stats' );
|
1166 |
wp_redirect ( $_POST ['_wp_http_referer'] );
|
1167 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1168 |
}
|
12 |
*
|
13 |
* @var Runtime environment variables
|
14 |
*/
|
15 |
+
private static $intRevisionId = 2015051101, $version = '0.10.0.6', $blog_id, $pluginBasename = NULL, $logger, $settings, $request;
|
16 |
|
17 |
/**
|
18 |
* Constructor class to configure and register all WP-Piwik components
|
202 |
self::$logger->log ( 'Running WP-Piwik uninstallation' );
|
203 |
if (! defined ( 'WP_UNINSTALL_PLUGIN' ))
|
204 |
exit ();
|
205 |
+
$this->deleteWordPressOption ( 'wp-piwik-notices' );
|
206 |
self::$settings->resetSettings ( true );
|
207 |
}
|
208 |
|
237 |
* set to true if the message should persist (default: false)
|
238 |
*/
|
239 |
private function addNotice($type, $subject, $text, $stay = false) {
|
240 |
+
$notices = $this->getWordPressOption ( 'wp-piwik-notices', array () );
|
241 |
$notices [$type] = array (
|
242 |
'subject' => $subject,
|
243 |
'text' => $text,
|
244 |
'stay' => $stay
|
245 |
);
|
246 |
+
$this->updateWordPressOption ( 'wp-piwik-notices', $notices );
|
247 |
}
|
248 |
|
249 |
/**
|
253 |
*/
|
254 |
public function showNotices() {
|
255 |
$link = sprintf ( '<a href="' . $this->getSettingsURL () . '">%s</a>', __ ( 'Settings', 'wp-piwik' ) );
|
256 |
+
if ($notices = $this->getWordPressOption ( 'wp-piwik-notices' )) {
|
257 |
foreach ( $notices as $type => $notice ) {
|
258 |
printf ( '<div class="updated fade"><p>%s <strong>%s:</strong> %s: %s</p></div>', $notice ['subject'], __ ( 'Important', 'wp-piwik' ), $notice ['text'], $link );
|
259 |
if (! $notice ['stay'])
|
260 |
unset ( $notices [$type] );
|
261 |
}
|
262 |
}
|
263 |
+
$this->updateWordPressOption ( 'wp-piwik-notices', $notices );
|
264 |
}
|
265 |
|
266 |
/**
|
595 |
* @return boolean Is WP-Piwik installed?
|
596 |
*/
|
597 |
private function isInstalled() {
|
598 |
+
$oldSettings = $this->getWordPressOption ( 'wp-piwik_global-settings', false );
|
599 |
if ($oldSettings && isset( $oldSettings['revision'] ))
|
600 |
self::$settings->setGlobalOption ( 'revision', $oldSettings['revision'] );
|
601 |
return self::$settings->getGlobalOption ( 'revision' );
|
969 |
* @return array Piwik sites
|
970 |
*/
|
971 |
public function getPiwikSiteDetails() {
|
972 |
+
$id = WP_Piwik\Request::register ( 'SitesManager.getSitesWithAtLeastViewAccess', array () );
|
973 |
$piwikSiteDetails = $this->request ( $id );
|
974 |
return $piwikSiteDetails;
|
975 |
}
|
1165 |
check_admin_referer ( 'wp-piwik_stats' );
|
1166 |
wp_redirect ( $_POST ['_wp_http_referer'] );
|
1167 |
}
|
1168 |
+
|
1169 |
+
/**
|
1170 |
+
* Get option value, choose method depending on network mode
|
1171 |
+
*
|
1172 |
+
* @param string $option option key
|
1173 |
+
* @return string option value
|
1174 |
+
*/
|
1175 |
+
private function getWordPressOption($option, $default = null) {
|
1176 |
+
return ($this->isNetworkMode () ? get_site_option ( $option, $default ) : get_option ( $option, $default ));
|
1177 |
+
}
|
1178 |
+
|
1179 |
+
/**
|
1180 |
+
* Delete option, choose method depending on network mode
|
1181 |
+
*
|
1182 |
+
* @param string $option option key
|
1183 |
+
*/
|
1184 |
+
private function deleteWordPressOption($option) {
|
1185 |
+
if ( $this->isNetworkMode () )
|
1186 |
+
delete_site_option ( $option );
|
1187 |
+
else
|
1188 |
+
delete_option ( $option );
|
1189 |
+
}
|
1190 |
+
|
1191 |
+
/**
|
1192 |
+
* Set option value, choose method depending on network mode
|
1193 |
+
*
|
1194 |
+
* @param string $option option key
|
1195 |
+
* @param mixed $value option value
|
1196 |
+
*/
|
1197 |
+
private function updateWordPressOption($option, $value) {
|
1198 |
+
if ( $this->isNetworkMode () )
|
1199 |
+
update_site_option ( $option, $value );
|
1200 |
+
else
|
1201 |
+
update_option ( $option, $value );
|
1202 |
+
}
|
1203 |
}
|
classes/WP_Piwik/Admin/Settings.php
CHANGED
@@ -107,7 +107,11 @@ class Settings extends \WP_Piwik\Admin {
|
|
107 |
if (! self::$wpPiwik->isNetworkMode() ) {
|
108 |
$this->showCheckbox ( 'auto_site_config', __ ( 'Auto config', 'wp-piwik' ), __ ( 'Check this to automatically choose your blog from your Piwik sites by URL. If your blog is not added to Piwik yet, WP-Piwik will add a new site.', 'wp-piwik' ), false, '$j(\'tr.wp-piwik-auto-option\').toggle(\'hidden\');' . ($piwikSiteId ? '$j(\'#site_id\').val(' . $piwikSiteId . ');' : '') );
|
109 |
if (self::$wpPiwik->isConfigured ()) {
|
110 |
-
$
|
|
|
|
|
|
|
|
|
111 |
if (($piwikSiteId == 'n/a'))
|
112 |
$piwikSiteDescription = 'n/a';
|
113 |
elseif (! self::$settings->getGlobalOption ( 'auto_site_config' ))
|
@@ -117,7 +121,7 @@ class Settings extends \WP_Piwik\Admin {
|
|
117 |
echo '<tr class="wp-piwik-auto-option' . (! self::$settings->getGlobalOption ( 'auto_site_config' ) ? ' hidden' : '') . '"><th scope="row">' . __ ( 'Determined site', 'wp-piwik' ) . ':</th><td>' . $piwikSiteDescription . '</td></tr>';
|
118 |
if (is_array ( $piwikSiteDetails ))
|
119 |
foreach ( $piwikSiteDetails as $key => $siteData )
|
120 |
-
$siteList [$
|
121 |
if (isset($siteList))
|
122 |
$this->showSelect ( 'site_id', __ ( 'Select site', 'wp-piwik' ), $siteList, 'Choose the Piwik site corresponding to this blog.', '', self::$settings->getGlobalOption ( 'auto_site_config' ), 'wp-piwik-auto-option', true, false );
|
123 |
}
|
@@ -601,7 +605,7 @@ class Settings extends \WP_Piwik\Admin {
|
|
601 |
$id = \WP_Piwik\Request::register ( 'SitesManager.getSitesWithAtLeastViewAccess' );
|
602 |
echo "\n\n"; var_dump( self::$wpPiwik->request( $id ) ); echo "\n";
|
603 |
$GLOBALS ['wp-piwik_debug'] = false;
|
604 |
-
?>Test 3/3: SitesManager.
|
605 |
$GLOBALS ['wp-piwik_debug'] = true;
|
606 |
$id = \WP_Piwik\Request::register ( 'SitesManager.getSitesIdFromSiteUrl', array (
|
607 |
'url' => get_bloginfo ( 'url' )
|
107 |
if (! self::$wpPiwik->isNetworkMode() ) {
|
108 |
$this->showCheckbox ( 'auto_site_config', __ ( 'Auto config', 'wp-piwik' ), __ ( 'Check this to automatically choose your blog from your Piwik sites by URL. If your blog is not added to Piwik yet, WP-Piwik will add a new site.', 'wp-piwik' ), false, '$j(\'tr.wp-piwik-auto-option\').toggle(\'hidden\');' . ($piwikSiteId ? '$j(\'#site_id\').val(' . $piwikSiteId . ');' : '') );
|
109 |
if (self::$wpPiwik->isConfigured ()) {
|
110 |
+
$piwikSiteList = self::$wpPiwik->getPiwikSiteDetails ();
|
111 |
+
if (is_array($piwikSiteList))
|
112 |
+
foreach ($piwikSiteList as $details)
|
113 |
+
$piwikSiteDetails[$details['idsite']] = $details;
|
114 |
+
unset($piwikSiteList);
|
115 |
if (($piwikSiteId == 'n/a'))
|
116 |
$piwikSiteDescription = 'n/a';
|
117 |
elseif (! self::$settings->getGlobalOption ( 'auto_site_config' ))
|
121 |
echo '<tr class="wp-piwik-auto-option' . (! self::$settings->getGlobalOption ( 'auto_site_config' ) ? ' hidden' : '') . '"><th scope="row">' . __ ( 'Determined site', 'wp-piwik' ) . ':</th><td>' . $piwikSiteDescription . '</td></tr>';
|
122 |
if (is_array ( $piwikSiteDetails ))
|
123 |
foreach ( $piwikSiteDetails as $key => $siteData )
|
124 |
+
$siteList [$siteData['idsite']] = $siteData ['name'] . ' (' . $siteData ['main_url'] . ')';
|
125 |
if (isset($siteList))
|
126 |
$this->showSelect ( 'site_id', __ ( 'Select site', 'wp-piwik' ), $siteList, 'Choose the Piwik site corresponding to this blog.', '', self::$settings->getGlobalOption ( 'auto_site_config' ), 'wp-piwik-auto-option', true, false );
|
127 |
}
|
605 |
$id = \WP_Piwik\Request::register ( 'SitesManager.getSitesWithAtLeastViewAccess' );
|
606 |
echo "\n\n"; var_dump( self::$wpPiwik->request( $id ) ); echo "\n";
|
607 |
$GLOBALS ['wp-piwik_debug'] = false;
|
608 |
+
?>Test 3/3: SitesManager.getSitesIdFromSiteUrl<?php
|
609 |
$GLOBALS ['wp-piwik_debug'] = true;
|
610 |
$id = \WP_Piwik\Request::register ( 'SitesManager.getSitesIdFromSiteUrl', array (
|
611 |
'url' => get_bloginfo ( 'url' )
|
classes/WP_Piwik/Request.php
CHANGED
@@ -18,7 +18,7 @@
|
|
18 |
else
|
19 |
$id = 'method='.$method.self::parameterToString($parameter);
|
20 |
if (
|
21 |
-
in_array( $method, array( 'API.getPiwikVersion', 'SitesManager.getJavascriptTag', 'SitesManager.
|
22 |
substr($parameter['date'], 0, 4) == 'last' ||
|
23 |
$parameter['date'] == 'today' ||
|
24 |
( $parameter['period'] == 'day' && $parameter['date'] == date('Ymd') ) ||
|
18 |
else
|
19 |
$id = 'method='.$method.self::parameterToString($parameter);
|
20 |
if (
|
21 |
+
in_array( $method, array( 'API.getPiwikVersion', 'SitesManager.getJavascriptTag', 'SitesManager.getSitesWithAtLeastViewAccess', 'SitesManager.getSitesIdFromSiteUrl', 'SitesManager.addSite', 'SitesManager.updateSite', 'SitesManager.getSitesWithAtLeastViewAccess' ) ) ||
|
22 |
substr($parameter['date'], 0, 4) == 'last' ||
|
23 |
$parameter['date'] == 'today' ||
|
24 |
( $parameter['period'] == 'day' && $parameter['date'] == date('Ymd') ) ||
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Contributors: Braekling
|
4 |
Requires at least: 4.0
|
5 |
Tested up to: 4.2.2
|
6 |
-
Stable tag: 0.10.0.
|
7 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6046779
|
8 |
Tags: statistics, stats, analytics, piwik, wpmu
|
9 |
|
@@ -127,6 +127,10 @@ This is a full refactored version of WP-Piwik. Please check your settings after
|
|
127 |
|
128 |
== Changelog ==
|
129 |
|
|
|
|
|
|
|
|
|
130 |
= 0.10.0.5 =
|
131 |
* Bugfix: In some cases the update message did not disappear -> fixed
|
132 |
* Important change: If you want to upgrade from 0.8.x to 0.10.x, please install 0.9.9.18 first: https://downloads.wordpress.org/plugin/wp-piwik.0.9.9.18.zip
|
3 |
Contributors: Braekling
|
4 |
Requires at least: 4.0
|
5 |
Tested up to: 4.2.2
|
6 |
+
Stable tag: 0.10.0.6
|
7 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6046779
|
8 |
Tags: statistics, stats, analytics, piwik, wpmu
|
9 |
|
127 |
|
128 |
== Changelog ==
|
129 |
|
130 |
+
= 0.10.0.6 =
|
131 |
+
* Bugfix: Option storage bug if WP-Piwik is used as single site plugin on blog networks
|
132 |
+
* Bugfix: WP-Piwik will work without Piwik superuser access, again
|
133 |
+
|
134 |
= 0.10.0.5 =
|
135 |
* Bugfix: In some cases the update message did not disappear -> fixed
|
136 |
* Important change: If you want to upgrade from 0.8.x to 0.10.x, please install 0.9.9.18 first: https://downloads.wordpress.org/plugin/wp-piwik.0.9.9.18.zip
|
wp-piwik.php
CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://wordpress.org/extend/plugins/wp-piwik/
|
|
6 |
|
7 |
Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress header.
|
8 |
|
9 |
-
Version: 0.10.0.
|
10 |
Author: André Bräkling
|
11 |
Author URI: http://www.braekling.de
|
12 |
Text Domain: wp-piwik
|
6 |
|
7 |
Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress header.
|
8 |
|
9 |
+
Version: 0.10.0.6
|
10 |
Author: André Bräkling
|
11 |
Author URI: http://www.braekling.de
|
12 |
Text Domain: wp-piwik
|