Version Description
- Bugfix: Settings link in admin notices fixed
- Bugfix: Shortcode result will appear where expected
- Bugfix: 0.9.9.18 settings will be kept (if WP-Piwik was not reconfigured after updating to 0.10.0.3, yet)
- Feature: If Piwik returns an error instead of a tracking code, this error will be visible
Download this release
Release Info
Developer | Braekling |
Plugin | WP-Matomo (WP-Piwik) |
Version | 0.10.0.4 |
Comparing to | |
See all releases |
Code changes from version 0.10.0.3 to 0.10.0.4
- classes/WP_Piwik.php +19 -10
- classes/WP_Piwik/Shortcode.php +6 -1
- classes/WP_Piwik/Widget.php +40 -22
- readme.txt +7 -1
- update/100000.php +0 -23
- update/2015051101.php +40 -0
- wp-piwik.php +2 -2
classes/WP_Piwik.php
CHANGED
@@ -12,7 +12,7 @@ class WP_Piwik {
|
|
12 |
*
|
13 |
* @var Runtime environment variables
|
14 |
*/
|
15 |
-
private static $intRevisionId =
|
16 |
|
17 |
/**
|
18 |
* Constructor class to configure and register all WP-Piwik components
|
@@ -54,10 +54,6 @@ class WP_Piwik {
|
|
54 |
*/
|
55 |
private function addActions() {
|
56 |
if ( is_admin () ) {
|
57 |
-
add_action ( 'admin_notices', array (
|
58 |
-
$this,
|
59 |
-
'showNotices'
|
60 |
-
) );
|
61 |
add_action ( 'admin_menu', array (
|
62 |
$this,
|
63 |
'buildAdminMenu'
|
@@ -75,6 +71,10 @@ class WP_Piwik {
|
|
75 |
'addPostMetaboxes'
|
76 |
) );
|
77 |
if ($this->isNetworkMode ()) {
|
|
|
|
|
|
|
|
|
78 |
add_action ( 'network_admin_menu', array (
|
79 |
$this,
|
80 |
'buildNetworkAdminMenu'
|
@@ -86,8 +86,12 @@ class WP_Piwik {
|
|
86 |
add_action ( 'update_site_option_siteurl', array (
|
87 |
$this,
|
88 |
'onSiteUrlChange'
|
89 |
-
) );
|
90 |
} else {
|
|
|
|
|
|
|
|
|
91 |
add_action ( 'update_option_blogname', array (
|
92 |
$this,
|
93 |
'onBlogNameChange'
|
@@ -207,7 +211,7 @@ class WP_Piwik {
|
|
207 |
*/
|
208 |
private function updatePlugin() {
|
209 |
self::$logger->log ( 'Upgrade WP-Piwik to ' . self::$version );
|
210 |
-
$patches = glob ( dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . 'update' . DIRECTORY_SEPARATOR . '*.php' );
|
211 |
if (is_array ( $patches )) {
|
212 |
sort ( $patches );
|
213 |
foreach ( $patches as $patch ) {
|
@@ -591,6 +595,9 @@ class WP_Piwik {
|
|
591 |
* @return boolean Is WP-Piwik installed?
|
592 |
*/
|
593 |
private function isInstalled() {
|
|
|
|
|
|
|
594 |
return self::$settings->getGlobalOption ( 'revision' );
|
595 |
}
|
596 |
|
@@ -845,7 +852,7 @@ class WP_Piwik {
|
|
845 |
* @return array updated list of column settings
|
846 |
*/
|
847 |
public function onScreenLayoutColumns($columns, $screen) {
|
848 |
-
if ($screen == $this->statsPageId)
|
849 |
$columns [$this->statsPageId] = 3;
|
850 |
return $columns;
|
851 |
}
|
@@ -938,7 +945,8 @@ class WP_Piwik {
|
|
938 |
'range' => false,
|
939 |
'key' => 'sum_daily_nb_uniq_visitors'
|
940 |
), $attributes );
|
941 |
-
new \WP_Piwik\Shortcode ( $attributes, $this, self::$settings );
|
|
|
942 |
}
|
943 |
|
944 |
/**
|
@@ -1062,7 +1070,8 @@ class WP_Piwik {
|
|
1062 |
'mergeAliasUrls' => self::$settings->getGlobalOption ( 'track_across_alias' ) ? 1 : 0,
|
1063 |
'disableCookies' => self::$settings->getGlobalOption ( 'disable_cookies' ) ? 1 : 0
|
1064 |
) );
|
1065 |
-
$
|
|
|
1066 |
self::$logger->log ( 'Delivered tracking code: ' . $result );
|
1067 |
$result = WP_Piwik\TrackingCode::prepareTrackingCode ( $result, self::$settings, self::$logger );
|
1068 |
self::$settings->setOption ( 'tracking_code', $result ['script'], $blogId );
|
12 |
*
|
13 |
* @var Runtime environment variables
|
14 |
*/
|
15 |
+
private static $intRevisionId = 2015051101, $version = '0.10.0.4', $blog_id, $pluginBasename = NULL, $logger, $settings, $request;
|
16 |
|
17 |
/**
|
18 |
* Constructor class to configure and register all WP-Piwik components
|
54 |
*/
|
55 |
private function addActions() {
|
56 |
if ( is_admin () ) {
|
|
|
|
|
|
|
|
|
57 |
add_action ( 'admin_menu', array (
|
58 |
$this,
|
59 |
'buildAdminMenu'
|
71 |
'addPostMetaboxes'
|
72 |
) );
|
73 |
if ($this->isNetworkMode ()) {
|
74 |
+
add_action ( 'network_admin_notices', array (
|
75 |
+
$this,
|
76 |
+
'showNotices'
|
77 |
+
) );
|
78 |
add_action ( 'network_admin_menu', array (
|
79 |
$this,
|
80 |
'buildNetworkAdminMenu'
|
86 |
add_action ( 'update_site_option_siteurl', array (
|
87 |
$this,
|
88 |
'onSiteUrlChange'
|
89 |
+
) );
|
90 |
} else {
|
91 |
+
add_action ( 'admin_notices', array (
|
92 |
+
$this,
|
93 |
+
'showNotices'
|
94 |
+
) );
|
95 |
add_action ( 'update_option_blogname', array (
|
96 |
$this,
|
97 |
'onBlogNameChange'
|
211 |
*/
|
212 |
private function updatePlugin() {
|
213 |
self::$logger->log ( 'Upgrade WP-Piwik to ' . self::$version );
|
214 |
+
$patches = glob ( dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'update' . DIRECTORY_SEPARATOR . '*.php' );
|
215 |
if (is_array ( $patches )) {
|
216 |
sort ( $patches );
|
217 |
foreach ( $patches as $patch ) {
|
595 |
* @return boolean Is WP-Piwik installed?
|
596 |
*/
|
597 |
private function isInstalled() {
|
598 |
+
$oldSettings = ($this->isNetworkMode () ? get_site_option ( 'wp-piwik_global-settings', false ) : get_option ( 'wp-piwik_global-settings', false ));
|
599 |
+
if ($oldSettings && isset( $oldSettings['revision'] ))
|
600 |
+
self::$settings->setGlobalOption ( 'revision', $oldSettings['revision'] );
|
601 |
return self::$settings->getGlobalOption ( 'revision' );
|
602 |
}
|
603 |
|
852 |
* @return array updated list of column settings
|
853 |
*/
|
854 |
public function onScreenLayoutColumns($columns, $screen) {
|
855 |
+
if (isset( $this->statsPageId ) && $screen == $this->statsPageId)
|
856 |
$columns [$this->statsPageId] = 3;
|
857 |
return $columns;
|
858 |
}
|
945 |
'range' => false,
|
946 |
'key' => 'sum_daily_nb_uniq_visitors'
|
947 |
), $attributes );
|
948 |
+
$shortcodeObject = new \WP_Piwik\Shortcode ( $attributes, $this, self::$settings );
|
949 |
+
return $shortcodeObject->get();
|
950 |
}
|
951 |
|
952 |
/**
|
1070 |
'mergeAliasUrls' => self::$settings->getGlobalOption ( 'track_across_alias' ) ? 1 : 0,
|
1071 |
'disableCookies' => self::$settings->getGlobalOption ( 'disable_cookies' ) ? 1 : 0
|
1072 |
) );
|
1073 |
+
$code = $this->request ( $id );
|
1074 |
+
$result = !is_array( $code ) ? html_entity_decode ( $code ) : '<!-- '.serialize($code).' -->';
|
1075 |
self::$logger->log ( 'Delivered tracking code: ' . $result );
|
1076 |
$result = WP_Piwik\TrackingCode::prepareTrackingCode ( $result, self::$settings, self::$logger );
|
1077 |
self::$settings->setOption ( 'tracking_code', $result ['script'], $blogId );
|
classes/WP_Piwik/Shortcode.php
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
'opt-out' => 'OptOut',
|
9 |
'post' => 'Post',
|
10 |
'overview' => 'Overview'
|
11 |
-
);
|
12 |
|
13 |
public function __construct($attributes, $wpPiwik, $settings) {
|
14 |
$wpPiwik->log('Check requested shortcode widget '.$attributes['module']);
|
@@ -17,7 +17,12 @@
|
|
17 |
$class = '\\WP_Piwik\\Widget\\'.$this->available[$attributes['module']];
|
18 |
$widget = new $class($wpPiwik, $settings, null, null, null, $attributes, true);
|
19 |
$widget->show();
|
|
|
20 |
}
|
21 |
}
|
22 |
|
|
|
|
|
|
|
|
|
23 |
}
|
8 |
'opt-out' => 'OptOut',
|
9 |
'post' => 'Post',
|
10 |
'overview' => 'Overview'
|
11 |
+
), $content;
|
12 |
|
13 |
public function __construct($attributes, $wpPiwik, $settings) {
|
14 |
$wpPiwik->log('Check requested shortcode widget '.$attributes['module']);
|
17 |
$class = '\\WP_Piwik\\Widget\\'.$this->available[$attributes['module']];
|
18 |
$widget = new $class($wpPiwik, $settings, null, null, null, $attributes, true);
|
19 |
$widget->show();
|
20 |
+
$this->content = $widget->get();
|
21 |
}
|
22 |
}
|
23 |
|
24 |
+
public function get() {
|
25 |
+
return $this->content;
|
26 |
+
}
|
27 |
+
|
28 |
}
|
classes/WP_Piwik/Widget.php
CHANGED
@@ -20,7 +20,7 @@ abstract class Widget {
|
|
20 |
*
|
21 |
* @var Configuration parameters
|
22 |
*/
|
23 |
-
protected $isShortcode = false, $method = '', $title = '', $context = 'side', $priority = 'core', $parameter = array (), $apiID = array (), $pageId = 'dashboard', $blogId = null, $name = 'Value', $limit = 10;
|
24 |
|
25 |
/**
|
26 |
* Widget constructor
|
@@ -88,7 +88,7 @@ abstract class Widget {
|
|
88 |
public function show() {
|
89 |
$response = self::$wpPiwik->request ( $this->apiID [$this->method] );
|
90 |
if (! empty ( $response ['result'] ) && $response ['result'] = 'error')
|
91 |
-
|
92 |
else {
|
93 |
if (isset ( $response [0] ['nb_uniq_visitors'] ))
|
94 |
$unique = 'nb_uniq_visitors';
|
@@ -118,6 +118,22 @@ abstract class Widget {
|
|
118 |
}
|
119 |
}
|
120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
/**
|
122 |
* Display a HTML table
|
123 |
*
|
@@ -133,18 +149,20 @@ abstract class Widget {
|
|
133 |
* array of javascript code to apply on body rows
|
134 |
*/
|
135 |
protected function table($thead, $tbody = array(), $tfoot = array(), $class = false, $javaScript = array()) {
|
136 |
-
|
137 |
-
if ($this->isShortcode && $this->title)
|
138 |
-
|
|
|
|
|
139 |
if (! empty ( $thead ))
|
140 |
$this->tabHead ( $thead, $class );
|
141 |
if (! empty ( $tbody ))
|
142 |
$this->tabBody ( $tbody, $class, $javaScript );
|
143 |
else
|
144 |
-
|
145 |
if (! empty ( $tfoot ))
|
146 |
$this->tabFoot ( $tfoot, $class );
|
147 |
-
|
148 |
}
|
149 |
|
150 |
/**
|
@@ -156,11 +174,11 @@ abstract class Widget {
|
|
156 |
* CSS class to apply
|
157 |
*/
|
158 |
private function tabHead($thead, $class = false) {
|
159 |
-
|
160 |
$count = 0;
|
161 |
foreach ( $thead as $value )
|
162 |
-
|
163 |
-
|
164 |
}
|
165 |
|
166 |
/**
|
@@ -174,10 +192,10 @@ abstract class Widget {
|
|
174 |
* array of javascript code to apply (one item per row)
|
175 |
*/
|
176 |
private function tabBody($tbody, $class = false, $javaScript = array()) {
|
177 |
-
|
178 |
foreach ( $tbody as $key => $trow )
|
179 |
$this->tabRow ( $trow, isset( $javaScript [$key] ) ?$javaScript [$key] : '');
|
180 |
-
|
181 |
}
|
182 |
|
183 |
/**
|
@@ -189,11 +207,11 @@ abstract class Widget {
|
|
189 |
* CSS class to apply
|
190 |
*/
|
191 |
private function tabFoot($tfoot, $class = false) {
|
192 |
-
|
193 |
$count = 0;
|
194 |
foreach ( $tfoot as $value )
|
195 |
-
|
196 |
-
|
197 |
}
|
198 |
|
199 |
/**
|
@@ -205,11 +223,11 @@ abstract class Widget {
|
|
205 |
* javascript code to apply
|
206 |
*/
|
207 |
private function tabRow($trow, $javaScript = '') {
|
208 |
-
|
209 |
$count = 0;
|
210 |
foreach ( $trow as $tcell )
|
211 |
-
|
212 |
-
|
213 |
}
|
214 |
|
215 |
/**
|
@@ -331,13 +349,13 @@ abstract class Widget {
|
|
331 |
* array chart data array(array(0 => name, 1 => value))
|
332 |
*/
|
333 |
public function pieChart($data) {
|
334 |
-
|
335 |
-
|
336 |
$list = '';
|
337 |
foreach ( $data as $dataSet )
|
338 |
$list .= '["' . $dataSet [0] . '", ' . $dataSet [1] . '],';
|
339 |
-
|
340 |
-
|
341 |
}
|
342 |
|
343 |
/**
|
20 |
*
|
21 |
* @var Configuration parameters
|
22 |
*/
|
23 |
+
protected $isShortcode = false, $method = '', $title = '', $context = 'side', $priority = 'core', $parameter = array (), $apiID = array (), $pageId = 'dashboard', $blogId = null, $name = 'Value', $limit = 10, $content = '';
|
24 |
|
25 |
/**
|
26 |
* Widget constructor
|
88 |
public function show() {
|
89 |
$response = self::$wpPiwik->request ( $this->apiID [$this->method] );
|
90 |
if (! empty ( $response ['result'] ) && $response ['result'] = 'error')
|
91 |
+
$this->out( '<strong>' . __ ( 'Piwik error', 'wp-piwik' ) . ':</strong> ' . htmlentities ( $response ['message'], ENT_QUOTES, 'utf-8' ) );
|
92 |
else {
|
93 |
if (isset ( $response [0] ['nb_uniq_visitors'] ))
|
94 |
$unique = 'nb_uniq_visitors';
|
118 |
}
|
119 |
}
|
120 |
|
121 |
+
/**
|
122 |
+
* Display or store shortcode output
|
123 |
+
*/
|
124 |
+
protected function out($output) {
|
125 |
+
if ($this->isShortcode)
|
126 |
+
$this->output .= $output;
|
127 |
+
else echo $output;
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Return shortcode output
|
132 |
+
*/
|
133 |
+
public function get() {
|
134 |
+
return $this->output;
|
135 |
+
}
|
136 |
+
|
137 |
/**
|
138 |
* Display a HTML table
|
139 |
*
|
149 |
* array of javascript code to apply on body rows
|
150 |
*/
|
151 |
protected function table($thead, $tbody = array(), $tfoot = array(), $class = false, $javaScript = array()) {
|
152 |
+
$this->out( '<div class="table"><table class="widefat wp-piwik-table">' );
|
153 |
+
if ($this->isShortcode && $this->title) {
|
154 |
+
$colspan = !empty ( $tbody ) ? count( $tbody[0] ) : 2 ;
|
155 |
+
$this->out( '<tr><th colspan="'.$colspan.'">' . $this->title . '</th></tr>' );
|
156 |
+
}
|
157 |
if (! empty ( $thead ))
|
158 |
$this->tabHead ( $thead, $class );
|
159 |
if (! empty ( $tbody ))
|
160 |
$this->tabBody ( $tbody, $class, $javaScript );
|
161 |
else
|
162 |
+
$this->out( '<tr><td colspan="10">' . __ ( 'No data available.', 'wp-piwik' ) . '</td></tr>' );
|
163 |
if (! empty ( $tfoot ))
|
164 |
$this->tabFoot ( $tfoot, $class );
|
165 |
+
$this->out( '</table></div>' );
|
166 |
}
|
167 |
|
168 |
/**
|
174 |
* CSS class to apply
|
175 |
*/
|
176 |
private function tabHead($thead, $class = false) {
|
177 |
+
$this->out( '<thead' . ($class ? ' class="' . $class . '"' : '') . '><tr>' );
|
178 |
$count = 0;
|
179 |
foreach ( $thead as $value )
|
180 |
+
$this->out( '<th' . ($count ++ ? ' class="right"' : '') . '>' . $value . '</th>' );
|
181 |
+
$this->out( '</tr></thead>' );
|
182 |
}
|
183 |
|
184 |
/**
|
192 |
* array of javascript code to apply (one item per row)
|
193 |
*/
|
194 |
private function tabBody($tbody, $class = false, $javaScript = array()) {
|
195 |
+
$this->out( '<tbody' . ($class ? ' class="' . $class . '"' : '') . '>' );
|
196 |
foreach ( $tbody as $key => $trow )
|
197 |
$this->tabRow ( $trow, isset( $javaScript [$key] ) ?$javaScript [$key] : '');
|
198 |
+
$this->out( '</tbody>' );
|
199 |
}
|
200 |
|
201 |
/**
|
207 |
* CSS class to apply
|
208 |
*/
|
209 |
private function tabFoot($tfoot, $class = false) {
|
210 |
+
$this->out( '<tfoot' . ($class ? ' class="' . $class . '"' : '') . '><tr>' );
|
211 |
$count = 0;
|
212 |
foreach ( $tfoot as $value )
|
213 |
+
$this->out( '<td' . ($count ++ ? ' class="right"' : '') . '>' . $value . '</td>' );
|
214 |
+
$this->out( '</tr></tfoot>' );
|
215 |
}
|
216 |
|
217 |
/**
|
223 |
* javascript code to apply
|
224 |
*/
|
225 |
private function tabRow($trow, $javaScript = '') {
|
226 |
+
$this->out( '<tr' . (! empty ( $javaScript ) ? ' onclick="' . $javaScript . '"' : '') . '>' );
|
227 |
$count = 0;
|
228 |
foreach ( $trow as $tcell )
|
229 |
+
$this->out( '<td' . ($count ++ ? ' class="right"' : '') . '>' . $tcell . '</td>' );
|
230 |
+
$this->out( '</tr>' );
|
231 |
}
|
232 |
|
233 |
/**
|
349 |
* array chart data array(array(0 => name, 1 => value))
|
350 |
*/
|
351 |
public function pieChart($data) {
|
352 |
+
$this->out( '<div id="wp-piwik_stats_' . $this->getName () . '_graph" style="height:310px;width:100%"></div>' );
|
353 |
+
$this->out( '<script type="text/javascript">$plotBrowsers = $j.jqplot("wp-piwik_stats_' . $this->getName () . '_graph", [[' );
|
354 |
$list = '';
|
355 |
foreach ( $data as $dataSet )
|
356 |
$list .= '["' . $dataSet [0] . '", ' . $dataSet [1] . '],';
|
357 |
+
$this->out( substr ( $list, 0, - 1 ) );
|
358 |
+
$this->out( ']], {seriesDefaults:{renderer:$j.jqplot.PieRenderer, rendererOptions:{sliceMargin:8}},legend:{show:true}});</script>' );
|
359 |
}
|
360 |
|
361 |
/**
|
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,12 @@ This is a full refactored version of WP-Piwik. Please check your settings after
|
|
127 |
|
128 |
== Changelog ==
|
129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
= 0.10.0.3 =
|
131 |
* Public beta of WP-Piwik 1.0
|
132 |
* Full refactored code
|
3 |
Contributors: Braekling
|
4 |
Requires at least: 4.0
|
5 |
Tested up to: 4.2.2
|
6 |
+
Stable tag: 0.10.0.4
|
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.4 =
|
131 |
+
* Bugfix: Settings link in admin notices fixed
|
132 |
+
* Bugfix: Shortcode result will appear where expected
|
133 |
+
* Bugfix: 0.9.9.18 settings will be kept (if WP-Piwik was not reconfigured after updating to 0.10.0.3, yet)
|
134 |
+
* Feature: If Piwik returns an error instead of a tracking code, this error will be visible
|
135 |
+
|
136 |
= 0.10.0.3 =
|
137 |
* Public beta of WP-Piwik 1.0
|
138 |
* Full refactored code
|
update/100000.php
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
// Get & delete old version's options
|
3 |
-
if (self::$settings->checkNetworkActivation ()) {
|
4 |
-
$oldGlobalOptions = get_site_option ( 'wp-piwik_global-settings', array () );
|
5 |
-
delete_site_option ( 'wp-piwik_global-settings' );
|
6 |
-
} else {
|
7 |
-
$oldGlobalOptions = get_option ( 'wp-piwik_global-settings', array () );
|
8 |
-
delete_option ( 'wp-piwik_global-settings' );
|
9 |
-
}
|
10 |
-
$oldOptions = get_option ( 'wp-piwik_settings', array () );
|
11 |
-
delete_option ( 'wp-piwik_settings' );
|
12 |
-
|
13 |
-
if (!$oldGlobalOptions['add_tracking_code']) $oldGlobalOptions['track_mode'] = 'disabled';
|
14 |
-
elseif ($oldGlobalOptions['track_mode'] == 0) $oldGlobalOptions['track_mode'] = 'default';
|
15 |
-
elseif ($oldGlobalOptions['track_mode'] == 1) $oldGlobalOptions['track_mode'] = 'js';
|
16 |
-
elseif ($oldGlobalOptions['track_mode'] == 2) $oldGlobalOptions['track_mode'] = 'proxy';
|
17 |
-
|
18 |
-
// Store old values in new settings
|
19 |
-
foreach ( $oldGlobalOptions as $key => $value )
|
20 |
-
self::$settings->setGlobalOption ( $key, $value );
|
21 |
-
foreach ( $oldOptions as $key => $value )
|
22 |
-
self::$settings->setOption ( $key, $value );
|
23 |
-
self::$settings->save ();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
update/2015051101.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!$this->isConfigured()) {
|
4 |
+
// Get & delete old version's options
|
5 |
+
if (self::$settings->checkNetworkActivation ()) {
|
6 |
+
$oldGlobalOptions = get_site_option ( 'wp-piwik_global-settings', array () );
|
7 |
+
delete_site_option('wp-piwik_global-settings');
|
8 |
+
} else {
|
9 |
+
$oldGlobalOptions = get_option ( 'wp-piwik_global-settings', array () );
|
10 |
+
delete_option('wp-piwik_global-settings');
|
11 |
+
}
|
12 |
+
|
13 |
+
$oldOptions = get_option ( 'wp-piwik_settings', array () );
|
14 |
+
delete_option('wp-piwik_settings');
|
15 |
+
|
16 |
+
if (!$oldGlobalOptions['add_tracking_code']) $oldGlobalOptions['track_mode'] = 'disabled';
|
17 |
+
elseif (!$oldGlobalOptions['track_mode']) $oldGlobalOptions['track_mode'] = 'default';
|
18 |
+
elseif ($oldGlobalOptions['track_mode'] == 1) $oldGlobalOptions['track_mode'] = 'js';
|
19 |
+
elseif ($oldGlobalOptions['track_mode'] == 2) $oldGlobalOptions['track_mode'] = 'proxy';
|
20 |
+
|
21 |
+
// Store old values in new settings
|
22 |
+
foreach ( $oldGlobalOptions as $key => $value )
|
23 |
+
self::$settings->setGlobalOption ( $key, $value );
|
24 |
+
foreach ( $oldOptions as $key => $value )
|
25 |
+
self::$settings->setOption ( $key, $value );
|
26 |
+
|
27 |
+
if (function_exists('is_multisite') && is_multisite()) {
|
28 |
+
global $wpdb;
|
29 |
+
$aryBlogs = $wpdb->get_results('SELECT blog_id FROM '.$wpdb->blogs.' ORDER BY blog_id');
|
30 |
+
if (is_array($aryBlogs))
|
31 |
+
foreach ($aryBlogs as $aryBlog) {
|
32 |
+
$oldOptions = get_blog_option ( $aryBlog->blog_id, 'wp-piwik_settings', array () );
|
33 |
+
foreach ( $oldOptions as $key => $value )
|
34 |
+
self::$settings->setOption ( $key, $value, $aryBlog->blog_id );
|
35 |
+
delete_blog_option($aryBlog->blog_id, 'wp-piwik_settings');
|
36 |
+
}
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
self::$settings->save ();
|
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
|
@@ -74,4 +74,4 @@ else {
|
|
74 |
$GLOBALS ['wp-piwik_debug'] = false;
|
75 |
if (class_exists ( 'WP_Piwik' ))
|
76 |
$GLOBALS ['wp-piwik'] = new WP_Piwik ();
|
77 |
-
}
|
6 |
|
7 |
Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress header.
|
8 |
|
9 |
+
Version: 0.10.0.4
|
10 |
Author: André Bräkling
|
11 |
Author URI: http://www.braekling.de
|
12 |
Text Domain: wp-piwik
|
74 |
$GLOBALS ['wp-piwik_debug'] = false;
|
75 |
if (class_exists ( 'WP_Piwik' ))
|
76 |
$GLOBALS ['wp-piwik'] = new WP_Piwik ();
|
77 |
+
}
|