WP-Matomo (WP-Piwik) - Version 1.0.11

Version Description

  • Security improvements
  • Removed some division by zero warnings
  • Option to disable SSL host verification (additional to peer verification)
  • Overview widget: Do not show unique visitors row if value is not available
  • Bugfix: Post shortcode is fixed and will work again
Download this release

Release Info

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

Code changes from version 1.0.10 to 1.0.11

classes/WP_Piwik.php CHANGED
@@ -12,7 +12,7 @@ class WP_Piwik {
12
  *
13
  * @var Runtime environment variables
14
  */
15
- private static $revisionId = 2016082901, $version = '1.0.10', $blog_id, $pluginBasename = NULL, $logger, $settings, $request, $optionsPageId;
16
 
17
  /**
18
  * Constructor class to configure and register all WP-Piwik components
@@ -614,8 +614,8 @@ class WP_Piwik {
614
  *
615
  * @return boolean Are new settings submitted?
616
  */
617
- private function isConfigSubmitted() {
618
- return self::isOptionsPage() && isset ( $_POST ) && isset ( $_POST ['wp-piwik'] );
619
  }
620
 
621
  /**
@@ -1240,9 +1240,7 @@ class WP_Piwik {
1240
  *
1241
  * @return boolean True if current page is WP-Piwik's option page
1242
  */
1243
- public static function isOptionsPage() {
1244
- require_once(ABSPATH . 'wp-admin/includes/screen.php');
1245
- $screen = get_current_screen();
1246
- return $screen == self::$optionsPageId;
1247
  }
1248
  }
12
  *
13
  * @var Runtime environment variables
14
  */
15
+ private static $revisionId = 2016090101, $version = '1.0.11', $blog_id, $pluginBasename = NULL, $logger, $settings, $request, $optionsPageId;
16
 
17
  /**
18
  * Constructor class to configure and register all WP-Piwik components
614
  *
615
  * @return boolean Are new settings submitted?
616
  */
617
+ public static function isConfigSubmitted() {
618
+ return isset ( $_POST ) && isset ( $_POST ['wp-piwik'] ) && self::isValidOptionsPost();
619
  }
620
 
621
  /**
1240
  *
1241
  * @return boolean True if current page is WP-Piwik's option page
1242
  */
1243
+ public static function isValidOptionsPost() {
1244
+ return is_admin() && check_admin_referer( 'wp-piwik_settings' ) && current_user_can( 'manage_options' ) ;
 
 
1245
  }
1246
  }
classes/WP_Piwik/Admin/Settings.php CHANGED
@@ -23,7 +23,7 @@ class Settings extends \WP_Piwik\Admin {
23
  self::$wpPiwik->resetRequest();
24
  echo '<form method="post" action="?page='.htmlentities($_GET['page']).'"><input type="submit" value="'.__('Reload', 'wp-piwik').'" /></form>';
25
  return;
26
- } elseif (isset ( $_POST ) && isset ( $_POST ['wp-piwik'] )) {
27
  $this->showBox ( 'updated', 'yes', __ ( 'Changes saved.' ) );
28
  self::$wpPiwik->resetRequest();
29
  self::$wpPiwik->updateTrackingCode();
@@ -298,6 +298,7 @@ class Settings extends \WP_Piwik\Admin {
298
  $this->showInput ( 'connection_timeout', __ ( 'Connection timeout', 'wp-piwik' ), 'Define a connection timeout for all HTTP requests done by WP-Piwik in seconds.' );
299
 
300
  $this->showCheckbox ( 'disable_ssl_verify', __ ( 'Disable SSL peer verification', 'wp-piwik' ), '(' . __ ( 'not recommended', 'wp-piwik' ) . ')' );
 
301
 
302
  $this->showSelect ( 'piwik_useragent', __ ( 'User agent', 'wp-piwik' ), array (
303
  'php' => __ ( 'Use the PHP default user agent', 'wp-piwik' ) . (ini_get ( 'user_agent' ) ? '(' . ini_get ( 'user_agent' ) . ')' : ' (' . __ ( 'empty', 'wp-piwik' ) . ')'),
@@ -550,7 +551,7 @@ class Settings extends \WP_Piwik\Admin {
550
  */
551
  public function showCredits() {
552
  ?>
553
- <p><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., Myra R. I., Carlos U. R.-S., Oleg I., M. N., Daniel K., James L., Jochen K., Cyril P., Thomas K., Patrik K., Zach, Sebastian W., Peakkom, Patrik K., Kati K., <?php _e('the Piwik team itself','wp-piwik');?><?php _e(', and all people flattering this','wp-piwik'); ?>!</p>
554
  <p><?php _e('Graphs powered by <a href="http://www.jqplot.com/">jqPlot</a> (License: GPL 2.0 and MIT) and <a href="http://omnipotent.net/jquery.sparkline/">jQuery Sparklines</a> (License: New BSD License).','wp-piwik'); ?></p>
555
  <p><?php _e('Thank you very much','wp-piwik'); ?> <a href="https://www.transifex.com/projects/p/wp-piwik/">Transifex Translation Community</a> <?php _e('for your translation work','wp-piwik'); ?>!</p>
556
  <p><?php _e('Thank you very much, all users who send me mails containing criticism, commendation, feature requests and bug reports! You help me to make WP-Piwik much better.','wp-piwik'); ?></p>
23
  self::$wpPiwik->resetRequest();
24
  echo '<form method="post" action="?page='.htmlentities($_GET['page']).'"><input type="submit" value="'.__('Reload', 'wp-piwik').'" /></form>';
25
  return;
26
+ } elseif (self::$wpPiwik->isConfigSubmitted()) {
27
  $this->showBox ( 'updated', 'yes', __ ( 'Changes saved.' ) );
28
  self::$wpPiwik->resetRequest();
29
  self::$wpPiwik->updateTrackingCode();
298
  $this->showInput ( 'connection_timeout', __ ( 'Connection timeout', 'wp-piwik' ), 'Define a connection timeout for all HTTP requests done by WP-Piwik in seconds.' );
299
 
300
  $this->showCheckbox ( 'disable_ssl_verify', __ ( 'Disable SSL peer verification', 'wp-piwik' ), '(' . __ ( 'not recommended', 'wp-piwik' ) . ')' );
301
+ $this->showCheckbox ( 'disable_ssl_verify_host', __ ( 'Disable SSL host verification', 'wp-piwik' ), '(' . __ ( 'not recommended', 'wp-piwik' ) . ')' );
302
 
303
  $this->showSelect ( 'piwik_useragent', __ ( 'User agent', 'wp-piwik' ), array (
304
  'php' => __ ( 'Use the PHP default user agent', 'wp-piwik' ) . (ini_get ( 'user_agent' ) ? '(' . ini_get ( 'user_agent' ) . ')' : ' (' . __ ( 'empty', 'wp-piwik' ) . ')'),
551
  */
552
  public function showCredits() {
553
  ?>
554
+ <p><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., Myra R. I., Carlos U. R.-S., Oleg I., M. N., Daniel K., James L., Jochen K., Cyril P., Thomas K., Patrik K., Zach, Sebastian W., Peakkom, Patrik K., Kati K., Helmut O., <?php _e('the Piwik team itself','wp-piwik');?><?php _e(', and all people flattering this','wp-piwik'); ?>!</p>
555
  <p><?php _e('Graphs powered by <a href="http://www.jqplot.com/">jqPlot</a> (License: GPL 2.0 and MIT) and <a href="http://omnipotent.net/jquery.sparkline/">jQuery Sparklines</a> (License: New BSD License).','wp-piwik'); ?></p>
556
  <p><?php _e('Thank you very much','wp-piwik'); ?> <a href="https://www.transifex.com/projects/p/wp-piwik/">Transifex Translation Community</a> <?php _e('for your translation work','wp-piwik'); ?>!</p>
557
  <p><?php _e('Thank you very much, all users who send me mails containing criticism, commendation, feature requests and bug reports! You help me to make WP-Piwik much better.','wp-piwik'); ?></p>
classes/WP_Piwik/Request/Php.php CHANGED
@@ -11,7 +11,7 @@
11
  $url = self::$settings->getGlobalOption('piwik_url');
12
  foreach (self::$requests as $requestID => $config) {
13
  if (!isset(self::$results[$requestID])) {
14
- $params = 'module=API&format=json&'.$this->buildURL($config);
15
  $map[$count] = $requestID;
16
  $result = $this->call($id, $url, $params);
17
  self::$results[$map[$count]] = $result;
11
  $url = self::$settings->getGlobalOption('piwik_url');
12
  foreach (self::$requests as $requestID => $config) {
13
  if (!isset(self::$results[$requestID])) {
14
+ $params = 'module=API&format=json&'.$this->buildURL($config, true);
15
  $map[$count] = $requestID;
16
  $result = $this->call($id, $url, $params);
17
  self::$results[$map[$count]] = $result;
classes/WP_Piwik/Request/Rest.php CHANGED
@@ -30,6 +30,7 @@
30
  curl_setopt($c, CURLOPT_POSTFIELDS, $params.'&token_auth='.self::$settings->getGlobalOption('piwik_token'));
31
  } else $c = curl_init($url.'?'.$params.'&token_auth='.self::$settings->getGlobalOption('piwik_token'));
32
  curl_setopt($c, CURLOPT_SSL_VERIFYPEER, !self::$settings->getGlobalOption('disable_ssl_verify'));
 
33
  curl_setopt($c, CURLOPT_USERAGENT, self::$settings->getGlobalOption('piwik_useragent')=='php'?ini_get('user_agent'):self::$settings->getGlobalOption('piwik_useragent_string'));
34
  curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
35
  curl_setopt($c, CURLOPT_HEADER, $GLOBALS ['wp-piwik_debug'] );
@@ -56,8 +57,11 @@
56
 
57
  private function fopen($id, $url, $params) {
58
  $contextDefinition = array('http'=>array('timeout' => self::$settings->getGlobalOption('connection_timeout')) );
 
59
  if (self::$settings->getGlobalOption('disable_ssl_verify'))
60
- $contextDefinition['ssl'] = array('allow_self_signed' => true);
 
 
61
  if (self::$settings->getGlobalOption('http_method')=='post') {
62
  $fullUrl = $url;
63
  $contextDefinition['http']['method'] = 'POST';
30
  curl_setopt($c, CURLOPT_POSTFIELDS, $params.'&token_auth='.self::$settings->getGlobalOption('piwik_token'));
31
  } else $c = curl_init($url.'?'.$params.'&token_auth='.self::$settings->getGlobalOption('piwik_token'));
32
  curl_setopt($c, CURLOPT_SSL_VERIFYPEER, !self::$settings->getGlobalOption('disable_ssl_verify'));
33
+ curl_setopt($c, CURLOPT_SSL_VERIFYHOST, !self::$settings->getGlobalOption('disable_ssl_verify_host')?2:0);
34
  curl_setopt($c, CURLOPT_USERAGENT, self::$settings->getGlobalOption('piwik_useragent')=='php'?ini_get('user_agent'):self::$settings->getGlobalOption('piwik_useragent_string'));
35
  curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
36
  curl_setopt($c, CURLOPT_HEADER, $GLOBALS ['wp-piwik_debug'] );
57
 
58
  private function fopen($id, $url, $params) {
59
  $contextDefinition = array('http'=>array('timeout' => self::$settings->getGlobalOption('connection_timeout')) );
60
+ $contextDefinition['ssl'] = array();
61
  if (self::$settings->getGlobalOption('disable_ssl_verify'))
62
+ $contextDefinition['ssl'] = array('allow_self_signed' => true, 'verify_peer' => false );
63
+ if (self::$settings->getGlobalOption('disable_ssl_verify_host'))
64
+ $contextDefinition['ssl']['verify_peer_name'] = false;
65
  if (self::$settings->getGlobalOption('http_method')=='post') {
66
  $fullUrl = $url;
67
  $contextDefinition['http']['method'] = 'POST';
classes/WP_Piwik/Settings.php CHANGED
@@ -91,6 +91,7 @@ class Settings {
91
  'disable_timelimit' => false,
92
  'connection_timeout' => 5,
93
  'disable_ssl_verify' => false,
 
94
  'piwik_useragent' => 'php',
95
  'piwik_useragent_string' => 'WP-Piwik',
96
  'track_datacfasync' => false,
@@ -275,7 +276,7 @@ class Settings {
275
  * new configuration set
276
  */
277
  public function applyChanges($in) {
278
- if (!self::$wpPiwik->isOptionsPage())
279
  die("Invalid config changes.");
280
  $in = $this->checkSettings ( $in );
281
  self::$wpPiwik->log ( 'Apply changed settings:' );
91
  'disable_timelimit' => false,
92
  'connection_timeout' => 5,
93
  'disable_ssl_verify' => false,
94
+ 'disable_ssl_verify_host' => false,
95
  'piwik_useragent' => 'php',
96
  'piwik_useragent_string' => 'WP-Piwik',
97
  'track_datacfasync' => false,
276
  * new configuration set
277
  */
278
  public function applyChanges($in) {
279
+ if (!self::$wpPiwik->isValidOptionsPost())
280
  die("Invalid config changes.");
281
  $in = $this->checkSettings ( $in );
282
  self::$wpPiwik->log ( 'Apply changed settings:' );
classes/WP_Piwik/Widget/Overview.php CHANGED
@@ -32,18 +32,19 @@
32
  $result[$key] += $value;
33
  else
34
  $result[$key] = $value;
35
- $result['nb_actions_per_visit'] = round($result['nb_actions'] / $result['nb_visits'], 1);
36
- $result['bounce_rate'] = round($result['bounce_count'] / $result['nb_visits'] * 100, 1) . '%';
37
- $result['avg_time_on_site'] = round($result['sum_visit_length'] / $result['nb_visits'], 0);
38
  }
39
  $response = $result;
40
  }
41
  $time = isset($response['sum_visit_length'])?$this->timeFormat($response['sum_visit_length']):'-';
42
  $avgTime = isset($response['avg_time_on_site'])?$this->timeFormat($response['avg_time_on_site']):'-';
43
  $tableHead = null;
44
- $tableBody = array(
45
- array(__('Visitors', 'wp-piwik').':', $this->value($response, 'nb_visits')),
46
- array(__('Unique visitors', 'wp-piwik').':', $this->value($response, 'nb_uniq_visitors')),
 
47
  array(__('Page views', 'wp-piwik').':', $this->value($response, 'nb_actions').' (&#216; '.$this->value($response, 'nb_actions_per_visit').')'),
48
  array(__('Total time spent', 'wp-piwik').':', $time.' (&#216; '.$avgTime.')'),
49
  array(__('Bounce count', 'wp-piwik').':', $this->value($response, 'bounce_count').' ('.$this->value($response, 'bounce_rate').')')
32
  $result[$key] += $value;
33
  else
34
  $result[$key] = $value;
35
+ $result['nb_actions_per_visit'] = $result['nb_visits'] > 0 ? round($result['nb_actions'] / $result['nb_visits'], 1) : 0;
36
+ $result['bounce_rate'] = $result['nb_visits'] > 0 ? round($result['bounce_count'] / $result['nb_visits'] * 100, 1) . '%' : 0;
37
+ $result['avg_time_on_site'] = $result['nb_visits'] > 0 ? round($result['sum_visit_length'] / $result['nb_visits'], 0) : 0;
38
  }
39
  $response = $result;
40
  }
41
  $time = isset($response['sum_visit_length'])?$this->timeFormat($response['sum_visit_length']):'-';
42
  $avgTime = isset($response['avg_time_on_site'])?$this->timeFormat($response['avg_time_on_site']):'-';
43
  $tableHead = null;
44
+ $tableBody = array(array(__('Visitors', 'wp-piwik').':', $this->value($response, 'nb_visits')));
45
+ if ($this->value($response, 'nb_uniq_visitors') != '-')
46
+ array_push($tableBody, array(__('Unique visitors', 'wp-piwik').':', $this->value($response, 'nb_uniq_visitors')));
47
+ array_push($tableBody,
48
  array(__('Page views', 'wp-piwik').':', $this->value($response, 'nb_actions').' (&#216; '.$this->value($response, 'nb_actions_per_visit').')'),
49
  array(__('Total time spent', 'wp-piwik').':', $time.' (&#216; '.$avgTime.')'),
50
  array(__('Bounce count', 'wp-piwik').':', $this->value($response, 'bounce_count').' ('.$this->value($response, 'bounce_rate').')')
languages/wp-piwik-it_IT.mo CHANGED
Binary file
languages/wp-piwik-it_IT.po CHANGED
@@ -10,8 +10,8 @@ msgstr ""
10
  "Project-Id-Version: WP-Piwik\n"
11
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-piwik\n"
12
  "POT-Creation-Date: 2016-03-13 21:32:45+00:00\n"
13
- "PO-Revision-Date: 2016-08-17 14:49+0000\n"
14
- "Last-Translator: Enzo Ferrara\n"
15
  "Language-Team: Italian (Italy) (http://www.transifex.com/piwik/wp-piwik/language/it_IT/)\n"
16
  "MIME-Version: 1.0\n"
17
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Project-Id-Version: WP-Piwik\n"
11
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-piwik\n"
12
  "POT-Creation-Date: 2016-03-13 21:32:45+00:00\n"
13
+ "PO-Revision-Date: 2016-09-02 20:56+0000\n"
14
+ "Last-Translator: André Bräkling\n"
15
  "Language-Team: Italian (Italy) (http://www.transifex.com/piwik/wp-piwik/language/it_IT/)\n"
16
  "MIME-Version: 1.0\n"
17
  "Content-Type: text/plain; charset=UTF-8\n"
readme.txt CHANGED
@@ -3,7 +3,7 @@
3
  Contributors: Braekling
4
  Requires at least: 4.0
5
  Tested up to: 4.6.0
6
- Stable tag: 1.0.10
7
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6046779
8
  Tags: piwik, tracking, statistics, stats, analytics
9
 
@@ -40,7 +40,7 @@ is equal to *[wp-piwik module="overview" title="" period="day" date="yesterday"]
40
 
41
  * 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).
42
  * All translators at the [Transifex translation community](https://www.transifex.com/projects/p/wp-piwik/).
43
- * Donations: Marco L., Rolf W., Tobias U., Lars K., Donna F., Kevin D., Ramos S., Thomas M., John C., Andreas G., Ben M., Myra R. I., Carlos U. R.-S., Oleg I., M. N., Daniel K., James L., Jochen K., Cyril P., Thomas K., Patrik K., Zach, Sebastian W., Peakkom, Patrik K., Kati K., the Piwik team itself, and all people flattering this.
44
  * All users who send me mails containing criticism, commendation, feature requests and bug reports - you help me to make WP-Piwik much better!
45
 
46
  Thank you all!
@@ -117,6 +117,13 @@ Add WP-Piwik to your /wp-content/plugins folder and enable it as [Network Plugin
117
 
118
  == Changelog ==
119
 
 
 
 
 
 
 
 
120
  = 1.0.10 =
121
  * Security fix
122
 
3
  Contributors: Braekling
4
  Requires at least: 4.0
5
  Tested up to: 4.6.0
6
+ Stable tag: 1.0.11
7
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6046779
8
  Tags: piwik, tracking, statistics, stats, analytics
9
 
40
 
41
  * 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).
42
  * All translators at the [Transifex translation community](https://www.transifex.com/projects/p/wp-piwik/).
43
+ * Donations: Marco L., Rolf W., Tobias U., Lars K., Donna F., Kevin D., Ramos S., Thomas M., John C., Andreas G., Ben M., Myra R. I., Carlos U. R.-S., Oleg I., M. N., Daniel K., James L., Jochen K., Cyril P., Thomas K., Patrik K., Zach, Sebastian W., Peakkom, Patrik K., Kati K., Helmut O., the Piwik team itself, and all people flattering this.
44
  * All users who send me mails containing criticism, commendation, feature requests and bug reports - you help me to make WP-Piwik much better!
45
 
46
  Thank you all!
117
 
118
  == Changelog ==
119
 
120
+ = 1.0.11 =
121
+ * Security improvements
122
+ * Removed some division by zero warnings
123
+ * Option to disable SSL host verification (additional to peer verification)
124
+ * Overview widget: Do not show unique visitors row if value is not available
125
+ * Bugfix: Post shortcode is fixed and will work again
126
+
127
  = 1.0.10 =
128
  * Security fix
129
 
uninstall.php CHANGED
@@ -51,6 +51,7 @@ $globalSettings = array(
51
  'disable_timelimit',
52
  'connection_timeout',
53
  'disable_ssl_verify',
 
54
  'piwik_useragent',
55
  'piwik_useragent_string',
56
  'track_datacfasync',
51
  'disable_timelimit',
52
  'connection_timeout',
53
  'disable_ssl_verify',
54
+ 'disable_ssl_verify_host',
55
  'piwik_useragent',
56
  'piwik_useragent_string',
57
  'track_datacfasync',
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: 1.0.10
10
  Author: Andr&eacute; Br&auml;kling
11
  Author URI: http://www.braekling.de
12
  Text Domain: wp-piwik
@@ -73,5 +73,9 @@ else {
73
  spl_autoload_register ( 'wp_piwik_autoloader' );
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: 1.0.11
10
  Author: Andr&eacute; Br&auml;kling
11
  Author URI: http://www.braekling.de
12
  Text Domain: wp-piwik
73
  spl_autoload_register ( 'wp_piwik_autoloader' );
74
  $GLOBALS ['wp-piwik_debug'] = false;
75
  if (class_exists ( 'WP_Piwik' ))
76
+ add_action( 'init', 'wp_piwik_loader' );
77
  }
78
+
79
+ function wp_piwik_loader() {
80
+ $GLOBALS ['wp-piwik'] = new WP_Piwik ();
81
+ }