WP-Matomo (WP-Piwik) - Version 0.9.8.1

Version Description

  • Warning on empty data removed (overview table)
  • Removed a possible deadlock
  • Bugfix: Apply tracking code settings everytime the tracking code is updated
  • Reset/uninstall script bugfix regarding network mode
Download this release

Release Info

Developer Braekling
Plugin Icon 128x128 WP-Matomo (WP-Piwik)
Version 0.9.8.1
Comparing to
See all releases

Code changes from version 0.9.8 to 0.9.8.1

dashboard/.htaccess ADDED
@@ -0,0 +1 @@
 
1
+ Deny from all
dashboard/overview.php CHANGED
@@ -27,14 +27,15 @@
27
  else {
28
  if ($aryConf['params']['date'] == 'last30') {
29
  $intValCnt = 0;
30
- foreach ($aryConf['data'] as $aryDay)
31
- foreach ($aryDay as $strKey => $strValue) {
32
- $intValCnt++;
33
- if (!in_array($strKey, array('max_actions','bounce_rate','nb_actions_per_visit','avg_time_on_site')))
34
- $aryTmp[$strKey] += $strValue;
35
- elseif ($aryTmp[$strKey] < $strValue)
36
- $aryTmp[$strKey] = $strValue;
37
- }
 
38
  $aryConf['data'] = $aryTmp;
39
  if ($intValCnt > 1 && $aryConf['data']['nb_visits'] >0) $aryConf['data']['bounce_rate'] = round($aryConf['data']['bounce_count']/$aryConf['data']['nb_visits']*100).'%';
40
  }
27
  else {
28
  if ($aryConf['params']['date'] == 'last30') {
29
  $intValCnt = 0;
30
+ if (is_array($aryConf['data']))
31
+ foreach ($aryConf['data'] as $aryDay)
32
+ foreach ($aryDay as $strKey => $strValue) {
33
+ $intValCnt++;
34
+ if (!in_array($strKey, array('max_actions','bounce_rate','nb_actions_per_visit','avg_time_on_site')))
35
+ $aryTmp[$strKey] += $strValue;
36
+ elseif ($aryTmp[$strKey] < $strValue)
37
+ $aryTmp[$strKey] = $strValue;
38
+ }
39
  $aryConf['data'] = $aryTmp;
40
  if ($intValCnt > 1 && $aryConf['data']['nb_visits'] >0) $aryConf['data']['bounce_rate'] = round($aryConf['data']['bounce_count']/$aryConf['data']['nb_visits']*100).'%';
41
  }
debug/.htaccess ADDED
@@ -0,0 +1 @@
 
1
+ Deny from all
languages/.htaccess ADDED
@@ -0,0 +1 @@
 
1
+ Deny from all
readme.txt CHANGED
@@ -3,7 +3,7 @@
3
  Contributors: Braekling
4
  Requires at least: 3.5
5
  Tested up to: 3.5.1
6
- Stable tag: 0.9.8
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
 
@@ -46,7 +46,7 @@ See section "Installation".
46
  * Graphs powered by [jqPlot](http://www.jqplot.com/) (GPL 2.0 and MIT) and and [jQuery Sparklines](http://omnipotent.net/jquery.sparkline/) (New BSD License).
47
  * Metabox support inspired by [Heiko Rabe's metabox demo plugin](http://www.code-styling.de/english/how-to-use-wordpress-metaboxes-at-own-plugins).
48
  * Translation credits see plugin settings
49
- * Donations: Marco L., Rolf W., Tobias U., Lars K., Donna F., Kevin D., Ramos S, Thomas M., Andreas G., Ben M., the Piwik team itself, and all people flattering this.
50
  * All users who send me mails containing criticism, commendation, feature requests and bug reports - you help me to make WP-Piwik much better!
51
 
52
  Thank you all!
@@ -114,6 +114,12 @@ Please update Piwik if not done yet (Piwik 1.9 or higher is recommended)!
114
 
115
  == Changelog ==
116
 
 
 
 
 
 
 
117
  = 0.9.8 =
118
  * WordPress 3.5 compatibility fix: http://wordpress.org/support/topic/v35-errors-fix?replies=5 (Thanks Christian Foellmann!)
119
  * Advanced Search Result Analytics, see http://piwik.org/docs/javascript-tracking/#toc-tracking-internal-search-keywords-categories-and-no-result-search-keywords
3
  Contributors: Braekling
4
  Requires at least: 3.5
5
  Tested up to: 3.5.1
6
+ Stable tag: 0.9.8.1
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
 
46
  * Graphs powered by [jqPlot](http://www.jqplot.com/) (GPL 2.0 and MIT) and and [jQuery Sparklines](http://omnipotent.net/jquery.sparkline/) (New BSD License).
47
  * Metabox support inspired by [Heiko Rabe's metabox demo plugin](http://www.code-styling.de/english/how-to-use-wordpress-metaboxes-at-own-plugins).
48
  * Translation credits see plugin settings
49
+ * Donations: Marco L., Rolf W., Tobias U., Lars K., Donna F., Kevin D., Ramos S, Thomas M., John C., Andreas G., Ben M., the Piwik team itself, and all people flattering this.
50
  * All users who send me mails containing criticism, commendation, feature requests and bug reports - you help me to make WP-Piwik much better!
51
 
52
  Thank you all!
114
 
115
  == Changelog ==
116
 
117
+ = 0.9.8.1 =
118
+ * Warning on empty data removed (overview table)
119
+ * Removed a possible deadlock
120
+ * Bugfix: Apply tracking code settings everytime the tracking code is updated
121
+ * Reset/uninstall script bugfix regarding network mode
122
+
123
  = 0.9.8 =
124
  * WordPress 3.5 compatibility fix: http://wordpress.org/support/topic/v35-errors-fix?replies=5 (Thanks Christian Foellmann!)
125
  * Advanced Search Result Analytics, see http://piwik.org/docs/javascript-tracking/#toc-tracking-internal-search-keywords-categories-and-no-result-search-keywords
settings/.htaccess ADDED
@@ -0,0 +1 @@
 
1
+ Deny from all
settings/credits.php CHANGED
@@ -1,6 +1,6 @@
1
  <tr>
2
  <td>
3
- <strong><?php _e('Thank you very much for your donation', 'wp-piwik'); ?>:</strong> Marco L., Rolf W., Tobias U., Lars K., Donna F., Kevin D., Ramos S., Thomas M., Andreas G., Ben M., <?php _e('the Piwik team itself','wp-piwik');?><?php _e(', and all people flattering this','wp-piwik'); ?>!
4
  </td>
5
  </tr>
6
  <tr>
1
  <tr>
2
  <td>
3
+ <strong><?php _e('Thank you very much for your donation', 'wp-piwik'); ?>:</strong> Marco L., Rolf W., Tobias U., Lars K., Donna F., Kevin D., Ramos S., Thomas M., John C., Andreas G., Ben M., <?php _e('the Piwik team itself','wp-piwik');?><?php _e(', and all people flattering this','wp-piwik'); ?>!
4
  </td>
5
  </tr>
6
  <tr>
settings/tracking.php CHANGED
@@ -21,8 +21,6 @@ if (self::$aryGlobalSettings['add_tracking_code']) {
21
  if (isset($strJavaScript['result']) && $strJavaScript['result'] == 'error')
22
  self::showErrorMessage(__($strJavaScript['message'],'wp-piwik'));
23
  } else {
24
- // Change Tracking code if configured
25
- $strJavaScript = $this->applyJSCodeChanges(html_entity_decode($strJavaScript));
26
  // Save javascript code
27
  self::$arySettings['tracking_code'] = $strJavaScript;
28
  }
21
  if (isset($strJavaScript['result']) && $strJavaScript['result'] == 'error')
22
  self::showErrorMessage(__($strJavaScript['message'],'wp-piwik'));
23
  } else {
 
 
24
  // Save javascript code
25
  self::$arySettings['tracking_code'] = $strJavaScript;
26
  }
uninstall.php CHANGED
@@ -7,7 +7,7 @@ global $wpdb;
7
 
8
  if (function_exists('is_multisite') && is_multisite()) {
9
  delete_site_option('wp-piwik_global-settings');
10
- $aryBlogs = $wpdb->get_results($wpdb->prepare('SELECT blog_id FROM %s ORDER BY blog_id', $wpdb->blogs));
11
  if (is_array($aryBlogs))
12
  foreach ($aryBlogs as $aryBlog)
13
  delete_blog_option($aryBlog->blog_id, 'wp-piwik_settings');
7
 
8
  if (function_exists('is_multisite') && is_multisite()) {
9
  delete_site_option('wp-piwik_global-settings');
10
+ $aryBlogs = $wpdb->get_results('SELECT blog_id FROM '.$wpdb->blogs.' ORDER BY blog_id');
11
  if (is_array($aryBlogs))
12
  foreach ($aryBlogs as $aryBlog)
13
  delete_blog_option($aryBlog->blog_id, 'wp-piwik_settings');
update/.htaccess ADDED
@@ -0,0 +1 @@
 
1
+ Deny from all
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 footer.
8
 
9
- Version: 0.9.8
10
  Author: Andr&eacute; Br&auml;kling
11
  Author URI: http://www.braekling.de
12
 
@@ -51,13 +51,13 @@ if (!function_exists('is_plugin_active_for_network'))
51
  class wp_piwik {
52
 
53
  private static
54
- $intRevisionId = 90805,
55
- $strVersion = '0.9.8',
56
  $intDashboardID = 30,
57
  $strPluginBasename = NULL,
58
  $bolJustActivated = false,
59
  $aryGlobalSettings = array(
60
- 'revision' => 90805,
61
  'add_tracking_code' => false,
62
  'last_settings_update' => 0,
63
  'piwik_token' => '',
@@ -326,9 +326,7 @@ class wp_piwik {
326
  $aryReturn = $this->addPiwikSite();
327
  // Update/get code if outdated/unknown
328
  if (self::$arySettings['last_tracking_code_update'] < self::$aryGlobalSettings['last_settings_update'] || empty(self::$arySettings['tracking_code'])) {
329
- $strJSCode = $this->callPiwikAPI('SitesManager.getJavascriptTag');
330
- self::$arySettings['tracking_code'] = html_entity_decode((is_string($strJSCode)?$this->applyJSCodeChanges($strJSCode):'<!-- WP-Piwik ERROR: Tracking code not availbale -->'."\n"));
331
- self::$arySettings['last_tracking_code_update'] = time();
332
  self::saveSettings();
333
  }
334
  // Change code if 404
@@ -336,7 +334,7 @@ class wp_piwik {
336
  $strTrackingCode = str_replace('piwikTracker.trackPageView();', 'piwikTracker.setDocumentTitle(\'404/URL = \'+encodeURIComponent(document.location.pathname+document.location.search) + \'/From = \' + encodeURIComponent(document.referrer));piwikTracker.trackPageView();', self::$arySettings['tracking_code']);
337
  // Change code if search result
338
  elseif (is_search() && self::$aryGlobalSettings['track_search']) {
339
- $objSearch = &new WP_Query("s=" . get_search_query() . '&showposts=-1');
340
  $intResultCount = $objSearch->post_count;
341
  $strTrackingCode = str_replace('piwikTracker.trackPageView();', 'piwikTracker.trackSiteSearch("'.get_search_query().'", false, '.$intResultCount.');', self::$arySettings['tracking_code']);
342
  // Use default tracking code
@@ -861,15 +859,13 @@ class wp_piwik {
861
  $strURL .= '&format=PHP';
862
  $strURL .= '&token_auth='.self::$aryGlobalSettings['piwik_token'];
863
  $strResult = unserialize($this->getRemoteFile($strURL));
864
- if (!empty($strResult)) self::$arySettings['site_id'] = $strResult;
865
  }
866
- // Store new data
867
- $mixAPIResult = $this->callPiwikAPI('SitesManager.getJavascriptTag');
868
- self::$arySettings['tracking_code'] = (!is_array($mixAPIResult)?html_entity_decode($mixAPIResult):'');
869
- self::$arySettings['last_tracking_code_update'] = time();
870
- // Change Tracking code if configured
871
- self::$arySettings['tracking_code'] = $this->applyJSCodeChanges(self::$arySettings['tracking_code']);
872
- self::saveSettings();
873
  if (isset($_GET['wpmu_show_stats']) && is_plugin_active_for_network('wp-piwik/wp-piwik.php'))
874
  restore_current_blog();
875
  return array('js' => self::$arySettings['tracking_code'], 'id' => self::$arySettings['site_id']);
@@ -891,11 +887,7 @@ class wp_piwik {
891
  $strURL .= '&token_auth='.self::$aryGlobalSettings['piwik_token'];
892
  $strResult = unserialize($this->getRemoteFile($strURL));
893
  // Store new data
894
- $mixAPIResult = $this->callPiwikAPI('SitesManager.getJavascriptTag');
895
- self::$arySettings['tracking_code'] = (!is_array($mixAPIResult)?html_entity_decode($mixAPIResult):'');
896
- self::$arySettings['last_tracking_code_update'] = time();
897
- // Change Tracking code if configured
898
- self::$arySettings['tracking_code'] = $this->applyJSCodeChanges(self::$arySettings['tracking_code']);
899
  self::saveSettings();
900
  }
901
 
@@ -988,6 +980,11 @@ class wp_piwik {
988
  if (!empty($intSite) || $strMethod='SitesManager.getSitesWithAtLeastViewAccess') {
989
  $strResult = (string) $this->getRemoteFile($strURL);
990
  $this->aryCache[$strKey] = ($strFormat == 'PHP'?unserialize($strResult):$strResult);
 
 
 
 
 
991
  // Otherwise return error message
992
  } else $this->aryCache[$strKey] = array('result' => 'error', 'message' => 'Unknown site/blog.');
993
  }
@@ -1418,7 +1415,7 @@ class wp_piwik {
1418
  // Reset network settings
1419
  if (is_plugin_active_for_network('wp-piwik/wp-piwik.php')) {
1420
  delete_site_option('wp-piwik_global-settings');
1421
- $aryBlogs = $wpdb->get_results($wpdb->prepare('SELECT blog_id FROM %s ORDER BY blog_id', $wpdb->blogs));
1422
  foreach ($aryBlogs as $aryBlog)
1423
  delete_blog_option($aryBlog->blog_id, 'wp-piwik_settings');
1424
  if (!$bolFull) update_site_option('wp-piwik_global-settings', $aryKeep);
6
 
7
  Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress footer.
8
 
9
+ Version: 0.9.8.1
10
  Author: Andr&eacute; Br&auml;kling
11
  Author URI: http://www.braekling.de
12
 
51
  class wp_piwik {
52
 
53
  private static
54
+ $intRevisionId = 90810,
55
+ $strVersion = '0.9.8.1',
56
  $intDashboardID = 30,
57
  $strPluginBasename = NULL,
58
  $bolJustActivated = false,
59
  $aryGlobalSettings = array(
60
+ 'revision' => 90810,
61
  'add_tracking_code' => false,
62
  'last_settings_update' => 0,
63
  'piwik_token' => '',
326
  $aryReturn = $this->addPiwikSite();
327
  // Update/get code if outdated/unknown
328
  if (self::$arySettings['last_tracking_code_update'] < self::$aryGlobalSettings['last_settings_update'] || empty(self::$arySettings['tracking_code'])) {
329
+ self::$arySettings['tracking_code'] = $this->callPiwikAPI('SitesManager.getJavascriptTag');
 
 
330
  self::saveSettings();
331
  }
332
  // Change code if 404
334
  $strTrackingCode = str_replace('piwikTracker.trackPageView();', 'piwikTracker.setDocumentTitle(\'404/URL = \'+encodeURIComponent(document.location.pathname+document.location.search) + \'/From = \' + encodeURIComponent(document.referrer));piwikTracker.trackPageView();', self::$arySettings['tracking_code']);
335
  // Change code if search result
336
  elseif (is_search() && self::$aryGlobalSettings['track_search']) {
337
+ $objSearch = new WP_Query("s=" . get_search_query() . '&showposts=-1');
338
  $intResultCount = $objSearch->post_count;
339
  $strTrackingCode = str_replace('piwikTracker.trackPageView();', 'piwikTracker.trackSiteSearch("'.get_search_query().'", false, '.$intResultCount.');', self::$arySettings['tracking_code']);
340
  // Use default tracking code
859
  $strURL .= '&format=PHP';
860
  $strURL .= '&token_auth='.self::$aryGlobalSettings['piwik_token'];
861
  $strResult = unserialize($this->getRemoteFile($strURL));
862
+ if (!empty($strResult)) self::$arySettings['site_id'] = (int) $strResult;
863
  }
864
+ // Store new data if site created
865
+ if (!empty(self::$arySettings['site_id'])) {
866
+ self::$arySettings['tracking_code'] = $this->callPiwikAPI('SitesManager.getJavascriptTag');
867
+ self::saveSettings();
868
+ } else self::$arySettings['tracking_code'] = '';
 
 
869
  if (isset($_GET['wpmu_show_stats']) && is_plugin_active_for_network('wp-piwik/wp-piwik.php'))
870
  restore_current_blog();
871
  return array('js' => self::$arySettings['tracking_code'], 'id' => self::$arySettings['site_id']);
887
  $strURL .= '&token_auth='.self::$aryGlobalSettings['piwik_token'];
888
  $strResult = unserialize($this->getRemoteFile($strURL));
889
  // Store new data
890
+ self::$arySettings['tracking_code'] = $this->callPiwikAPI('SitesManager.getJavascriptTag');
 
 
 
 
891
  self::saveSettings();
892
  }
893
 
980
  if (!empty($intSite) || $strMethod='SitesManager.getSitesWithAtLeastViewAccess') {
981
  $strResult = (string) $this->getRemoteFile($strURL);
982
  $this->aryCache[$strKey] = ($strFormat == 'PHP'?unserialize($strResult):$strResult);
983
+ // Apply tracking code changes if configured
984
+ if ($strMethod == 'SitesManager.getJavascriptTag') {
985
+ $this->aryCache[$strKey] = html_entity_decode((is_string($this->aryCache[$strKey])?$this->applyJSCodeChanges($this->aryCache[$strKey]):'<!-- WP-Piwik ERROR: Tracking code not availbale -->'."\n"));
986
+ self::$arySettings['last_tracking_code_update'] = time();
987
+ }
988
  // Otherwise return error message
989
  } else $this->aryCache[$strKey] = array('result' => 'error', 'message' => 'Unknown site/blog.');
990
  }
1415
  // Reset network settings
1416
  if (is_plugin_active_for_network('wp-piwik/wp-piwik.php')) {
1417
  delete_site_option('wp-piwik_global-settings');
1418
+ $aryBlogs = $wpdb->get_results('SELECT blog_id FROM '.$wpdb->blogs.' ORDER BY blog_id');
1419
  foreach ($aryBlogs as $aryBlog)
1420
  delete_blog_option($aryBlog->blog_id, 'wp-piwik_settings');
1421
  if (!$bolFull) update_site_option('wp-piwik_global-settings', $aryKeep);