WP-Matomo (WP-Piwik) - Version 0.9.9.6

Version Description

  • Bugfix: Proxy script will work again
  • Option: Enable/disable one week caching
  • Load config file using full path to avoid side effects
Download this release

Release Info

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

Code changes from version 0.9.9.5 to 0.9.9.6

classes/WP_Piwik_Settings.php CHANGED
@@ -37,7 +37,8 @@
37
  'disable_ssl_verify' => false,
38
  'disable_cookies' => false,
39
  'toolbar' => false,
40
- 'shortcodes' => false
 
41
  ),
42
  $settings = array(
43
  'name' => '',
37
  'disable_ssl_verify' => false,
38
  'disable_cookies' => false,
39
  'toolbar' => false,
40
+ 'shortcodes' => false,
41
+ 'cache' => true
42
  ),
43
  $settings = array(
44
  'name' => '',
config.php CHANGED
@@ -6,5 +6,4 @@
6
  1: Log to screen (available soon)
7
  2: Log to file (logs/YYYYMMDD_wp-piwik.log)
8
  */
9
- define('WP_PIWIK_ACTIVATE_LOGGER', 0);
10
- define('WP_PIWIK_ACTIVATE_CACHE', true);
6
  1: Log to screen (available soon)
7
  2: Log to file (logs/YYYYMMDD_wp-piwik.log)
8
  */
9
+ define('WP_PIWIK_ACTIVATE_LOGGER', 0);
 
languages/wp-piwik-de_DE.mo CHANGED
Binary file
languages/wp-piwik-de_DE.po CHANGED
@@ -680,4 +680,10 @@ msgid "Add rec parameter to noscript code"
680
  msgstr "Füge rec-Parameter zum noscript Code hinzu"
681
 
682
  msgid "Add <noscript>"
683
- msgstr "Füge <noscript> hinzu"
 
 
 
 
 
 
680
  msgstr "Füge rec-Parameter zum noscript Code hinzu"
681
 
682
  msgid "Add <noscript>"
683
+ msgstr "Füge <noscript> hinzu"
684
+
685
+ msgid "Cache API calls, which not contain today's values, for a week"
686
+ msgstr "Cache alle API-Aufrufe, die keine heutigen Daten enthalten, für eine Woche"
687
+
688
+ msgid "Enable cache"
689
+ msgstr "Cache einschalten"
piwik.php CHANGED
@@ -1,8 +1,11 @@
1
  <?php
2
 
3
- require( '../../../wp-load.php' );
 
 
4
 
5
- $arySettings = wp_piwik::loadSettings();
 
6
 
7
  /* PIWIK PROXY SCRIPT */
8
 
@@ -58,11 +61,11 @@
58
  // Edit the line below, and replace http://piwik-server.com/piwik/
59
  // with your Piwik URL ending with a slash.
60
  // This URL will never be revealed to visitors or search engines.
61
- $PIWIK_URL = $arySettings['global']['piwik_url'];
62
 
63
  // Edit the line below, and replace xyz by the token_auth for the user "UserTrackingAPI"
64
  // which you created when you followed instructions above.
65
- $TOKEN_AUTH = $arySettings['global']['piwik_token'];
66
 
67
  // Maximum time, in seconds, to wait for the Piwik server to return the 1*1 GIF
68
  $timeout = 5;
1
  <?php
2
 
3
+ require('../../../wp-load.php');
4
+ require_once('classes/WP_Piwik_Settings.php');
5
+ require_once('classes/WP_Piwik_Logger_Dummy.php');
6
 
7
+ $logger = new WP_Piwik_Logger_Dummy(__CLASS__);
8
+ $settings = new WP_Piwik_Settings($logger);
9
 
10
  /* PIWIK PROXY SCRIPT */
11
 
61
  // Edit the line below, and replace http://piwik-server.com/piwik/
62
  // with your Piwik URL ending with a slash.
63
  // This URL will never be revealed to visitors or search engines.
64
+ $PIWIK_URL = $settings->getGlobalOption('piwik_url');
65
 
66
  // Edit the line below, and replace xyz by the token_auth for the user "UserTrackingAPI"
67
  // which you created when you followed instructions above.
68
+ $TOKEN_AUTH = $settings->getGlobalOption('piwik_token');
69
 
70
  // Maximum time, in seconds, to wait for the Piwik server to return the 1*1 GIF
71
  $timeout = 5;
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.9.5
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
 
@@ -114,6 +114,11 @@ Please update Piwik if not done yet (Piwik 1.11 or higher is recommended)!
114
 
115
  == Changelog ==
116
 
 
 
 
 
 
117
  = 0.9.9.5 =
118
  * Fatal error on statistics settings page fixed
119
 
3
  Contributors: Braekling
4
  Requires at least: 3.5
5
  Tested up to: 3.5.1
6
+ Stable tag: 0.9.9.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
 
114
 
115
  == Changelog ==
116
 
117
+ = 0.9.9.6 =
118
+ * Bugfix: Proxy script will work again
119
+ * Option: Enable/disable one week caching
120
+ * Load config file using full path to avoid side effects
121
+
122
  = 0.9.9.5 =
123
  * Fatal error on statistics settings page fixed
124
 
settings/tracking.php CHANGED
@@ -80,11 +80,17 @@ if (self::$settings->getGlobalOption('add_tracking_code')) {
80
  <input type="checkbox" value="1" id="wp-piwik_404" name="wp-piwik_404"<?php echo (self::$settings->getGlobalOption('track_404')?' checked="checked"':''); ?> />
81
  <label for="wp-piwik_404"><?php echo _e('WP-Piwik can automatically add a 404-category to track 404-page-visits.', 'wp-piwik'); ?></label>
82
  </td></tr>
 
83
  <tr><th><?php _e('Avoid mod_security', 'wp-piwik'); ?>:</th><td>
84
  <input type="checkbox" value="1" id="wp-piwik_reqpost" name="wp-piwik_reqpost"<?php echo (self::$settings->getGlobalOption('track_post')?' checked="checked"':''); ?> />
85
  <label for="wp-piwik_reqpost"><?php _e('WP-Piwik can automatically force the Tracking Code to sent data in POST. See', 'wp-piwik'); ?> <a href="http://piwik.org/faq/troubleshooting/#faq_100">Piwik FAQ</a>. <?php _e('Disabled in proxy mode.', 'wp-piwik'); ?></label>
86
  </td></tr>
87
 
 
 
 
 
 
88
  <tr><th><?php _e('CDN URL', 'wp-piwik'); ?>:</th><td>
89
  http://<input type="text" value="<?php echo self::$settings->getGlobalOption('track_cdnurl'); ?>" id="wp-piwik_cdnurl" name="wp-piwik_cdnurl" /> https://<input type="text" value="<?php echo self::$settings->getGlobalOption('track_cdnurlssl'); ?>" id="wp-piwik_cdnurlssl" name="wp-piwik_cdnurlssl" /><br />
90
  <label for="wp-piwik_reqpost"><?php _e('Leave blank if you do not want to define a CDN URL or you do not know what this is.', 'wp-piwik'); ?></label>
80
  <input type="checkbox" value="1" id="wp-piwik_404" name="wp-piwik_404"<?php echo (self::$settings->getGlobalOption('track_404')?' checked="checked"':''); ?> />
81
  <label for="wp-piwik_404"><?php echo _e('WP-Piwik can automatically add a 404-category to track 404-page-visits.', 'wp-piwik'); ?></label>
82
  </td></tr>
83
+
84
  <tr><th><?php _e('Avoid mod_security', 'wp-piwik'); ?>:</th><td>
85
  <input type="checkbox" value="1" id="wp-piwik_reqpost" name="wp-piwik_reqpost"<?php echo (self::$settings->getGlobalOption('track_post')?' checked="checked"':''); ?> />
86
  <label for="wp-piwik_reqpost"><?php _e('WP-Piwik can automatically force the Tracking Code to sent data in POST. See', 'wp-piwik'); ?> <a href="http://piwik.org/faq/troubleshooting/#faq_100">Piwik FAQ</a>. <?php _e('Disabled in proxy mode.', 'wp-piwik'); ?></label>
87
  </td></tr>
88
 
89
+ <tr><th><?php _e('Enable cache', 'wp-piwik'); ?>:</th><td>
90
+ <input type="checkbox" value="1" id="wp-piwik_cache" name="wp-piwik_cache"<?php echo (self::$settings->getGlobalOption('cache')?' checked="checked"':''); ?> />
91
+ <label for="wp-piwik_cache"><?php _e('Cache API calls, which not contain today\'s values, for a week', 'wp-piwik'); ?>.</label>
92
+ </td></tr>
93
+
94
  <tr><th><?php _e('CDN URL', 'wp-piwik'); ?>:</th><td>
95
  http://<input type="text" value="<?php echo self::$settings->getGlobalOption('track_cdnurl'); ?>" id="wp-piwik_cdnurl" name="wp-piwik_cdnurl" /> https://<input type="text" value="<?php echo self::$settings->getGlobalOption('track_cdnurlssl'); ?>" id="wp-piwik_cdnurlssl" name="wp-piwik_cdnurlssl" /><br />
96
  <label for="wp-piwik_reqpost"><?php _e('Leave blank if you do not want to define a CDN URL or you do not know what this is.', 'wp-piwik'); ?></label>
update/90961.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ self::$settings->setGlobalOption('cache', true);
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.9.9.5
10
  Author: Andr&eacute; Br&auml;kling
11
  Author URI: http://www.braekling.de
12
 
@@ -38,11 +38,12 @@ if (!function_exists ('add_action')) {
38
  if (!function_exists('is_plugin_active_for_network'))
39
  require_once(ABSPATH.'/wp-admin/includes/plugin.php');
40
 
 
41
  class wp_piwik {
42
 
43
  private static
44
- $intRevisionId = 90950,
45
- $strVersion = '0.9.9.5',
46
  $blog_id,
47
  $intDashboardID = 30,
48
  $strPluginBasename = NULL,
@@ -169,6 +170,8 @@ class wp_piwik {
169
  self::includeFile('update/90920');
170
  if (self::$settings->getGlobalOption('revision') < 90940)
171
  self::includeFile('update/90940');
 
 
172
 
173
  // Install new version
174
  $this->installPlugin();
@@ -882,7 +885,7 @@ class wp_piwik {
882
  // Create unique cache key
883
  $strKey = 'wp-piwik'.md5($strMethod.'_'.$strPeriod.'_'.$strDate.'_'.$intLimit);
884
  // Call API if data not cached
885
- $result = (WP_PIWIK_ACTIVATE_CACHE?get_transient($strKey):false);
886
  if (false === $result) {
887
  $strToken = self::$settings->getGlobalOption('piwik_token');
888
  // If multisite stats are shown, maybe the super admin wants to show other blog's stats.
@@ -926,8 +929,12 @@ class wp_piwik {
926
  }
927
  // Otherwise return error message
928
  } else $result = array('result' => 'error', 'message' => 'Unknown site/blog.');
929
- if ($strMethod != 'SitesManager.getJavascriptTag' && $strDate != 'today' && $strDate != date('Ymd') && substr($strDate, 0, 4) != 'last' && WP_PIWIK_ACTIVATE_CACHE)
930
- set_transient($strKey, $result, WEEK_IN_SECONDS);
 
 
 
 
931
  }
932
  return $result;
933
  }
@@ -1166,6 +1173,7 @@ class wp_piwik {
1166
  self::$settings->setGlobalOption('track_noscript', (isset($_POST['wp-piwik_noscript'])?$_POST['wp-piwik_noscript']:false));
1167
  self::$settings->setGlobalOption('track_nojavascript', (isset($_POST['wp-piwik_nojavascript'])?$_POST['wp-piwik_nojavascript']:false));
1168
  self::$settings->setGlobalOption('capability_stealth', (isset($_POST['wp-piwik_filter'])?$_POST['wp-piwik_filter']:array()));
 
1169
  self::$settings->setGlobalOption('disable_cookies', (isset($_POST['wp-piwik_disable_cookies'])?$_POST['wp-piwik_disable_cookies']:false));
1170
  self::$settings->setOption('tracking_code', $this->callPiwikAPI('SitesManager.getJavascriptTag'));
1171
  break;
@@ -1364,7 +1372,9 @@ class wp_piwik {
1364
 
1365
  }
1366
 
1367
- require_once('config.php');
 
 
1368
 
1369
  if (class_exists('wp_piwik'))
1370
  $GLOBALS['wp_piwik'] = new wp_piwik();
6
 
7
  Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress header.
8
 
9
+ Version: 0.9.9.6
10
  Author: Andr&eacute; Br&auml;kling
11
  Author URI: http://www.braekling.de
12
 
38
  if (!function_exists('is_plugin_active_for_network'))
39
  require_once(ABSPATH.'/wp-admin/includes/plugin.php');
40
 
41
+ if (!class_exists('wp_piwik')) {
42
  class wp_piwik {
43
 
44
  private static
45
+ $intRevisionId = 90961,
46
+ $strVersion = '0.9.9.6',
47
  $blog_id,
48
  $intDashboardID = 30,
49
  $strPluginBasename = NULL,
170
  self::includeFile('update/90920');
171
  if (self::$settings->getGlobalOption('revision') < 90940)
172
  self::includeFile('update/90940');
173
+ if (self::$settings->getGlobalOption('revision') < 90961)
174
+ self::includeFile('update/90961');
175
 
176
  // Install new version
177
  $this->installPlugin();
885
  // Create unique cache key
886
  $strKey = 'wp-piwik'.md5($strMethod.'_'.$strPeriod.'_'.$strDate.'_'.$intLimit);
887
  // Call API if data not cached
888
+ $result = (self::$settings->getGlobalOption('cache')?get_transient($strKey):false);
889
  if (false === $result) {
890
  $strToken = self::$settings->getGlobalOption('piwik_token');
891
  // If multisite stats are shown, maybe the super admin wants to show other blog's stats.
929
  }
930
  // Otherwise return error message
931
  } else $result = array('result' => 'error', 'message' => 'Unknown site/blog.');
932
+ if (
933
+ $strMethod != 'SitesManager.getJavascriptTag' &&
934
+ $strDate != 'today' && $strDate != date('Ymd') && substr($strDate, 0, 4) != 'last' &&
935
+ self::$settings->getGlobalOption('cache') &&
936
+ !(isset($result['result']) && $result['result'] == 'error')
937
+ ) set_transient($strKey, $result, WEEK_IN_SECONDS);
938
  }
939
  return $result;
940
  }
1173
  self::$settings->setGlobalOption('track_noscript', (isset($_POST['wp-piwik_noscript'])?$_POST['wp-piwik_noscript']:false));
1174
  self::$settings->setGlobalOption('track_nojavascript', (isset($_POST['wp-piwik_nojavascript'])?$_POST['wp-piwik_nojavascript']:false));
1175
  self::$settings->setGlobalOption('capability_stealth', (isset($_POST['wp-piwik_filter'])?$_POST['wp-piwik_filter']:array()));
1176
+ self::$settings->setGlobalOption('cache', (isset($_POST['wp-piwik_cache'])?$_POST['wp-piwik_cache']:false));
1177
  self::$settings->setGlobalOption('disable_cookies', (isset($_POST['wp-piwik_disable_cookies'])?$_POST['wp-piwik_disable_cookies']:false));
1178
  self::$settings->setOption('tracking_code', $this->callPiwikAPI('SitesManager.getJavascriptTag'));
1179
  break;
1372
 
1373
  }
1374
 
1375
+ }
1376
+
1377
+ require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'config.php');
1378
 
1379
  if (class_exists('wp_piwik'))
1380
  $GLOBALS['wp_piwik'] = new wp_piwik();