WP-Matomo (WP-Piwik) - Version 0.4.0

Version Description

  • Tracking filter added
  • Resolution stats
  • Operating System stats
  • Plugin stats
Download this release

Release Info

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

Code changes from version 0.3.2 to 0.4.0

dashboard/plugins.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*********************************
3
+ WP-Piwik::Stats:Plugins
4
+ **********************************/
5
+
6
+ $aryConf['data'] = $this->call_API(
7
+ 'UserSettings.getPlugin',
8
+ $aryConf['params']['period'],
9
+ $aryConf['params']['date'],
10
+ $aryConf['params']['limit']
11
+ );
12
+ $aryConf['title'] = __('Plugins', 'wp-piwik');
13
+
14
+ $aryOverview = $this->call_API(
15
+ 'VisitsSummary.get',
16
+ $aryConf['params']['period'],
17
+ $aryConf['params']['date'],
18
+ $aryConf['params']['limit']
19
+ );
20
+
21
+ $intTotalVisits = $aryOverview['nb_visits'];
22
+
23
+ unset($aryOverview);
24
+
25
+ include('header.php');
26
+ /***************************************************************************/ ?>
27
+ <div class="table">
28
+ <table class="widefat wp-piwik-table">
29
+ <thead>
30
+ <tr>
31
+ <th><?php _e('Plugins', 'wp-piwik'); ?></th>
32
+ <th class="n"><?php _e('Visits', 'wp-piwik'); ?></th>
33
+ <th class="n"><?php _e('Percent', 'wp-piwik'); ?></th>
34
+ </tr>
35
+ </thead>
36
+ <tbody>
37
+ <?php /************************************************************************/
38
+ foreach ($aryConf['data'] as $aryValues)
39
+ echo '<tr><td>'.
40
+ $aryValues['label'].
41
+ '</td><td class="n">'.
42
+ $aryValues['nb_visits'].
43
+ '</td><td class="n">'.
44
+ number_format(($aryValues['nb_visits']/$intTotalVisits*100),2).
45
+ '%</td></tr>';
46
+ unset($aryTmp);
47
+ /***************************************************************************/ ?>
48
+ </tbody>
49
+ </table>
50
+ </div>
51
+ <?php /************************************************************************/
52
+ include ('footer.php');
53
+
54
+ /* EOF */
dashboard/screens.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*********************************
3
+ WP-Piwik::Stats:Screens
4
+ **********************************/
5
+
6
+ $aryConf['data'] = $this->call_API(
7
+ 'UserSettings.getResolution',
8
+ $aryConf['params']['period'],
9
+ $aryConf['params']['date'],
10
+ $aryConf['params']['limit']
11
+ );
12
+ $aryConf['title'] = __('Resolution', 'wp-piwik');
13
+ include('header.php');
14
+ $strValues = $strLabels = '';
15
+ $intSum = 0;
16
+ foreach ($aryConf['data'] as $aryValues)
17
+ $intSum += $aryValues['nb_uniq_visitors'];
18
+ foreach ($aryConf['data'] as $aryValues) {
19
+ $strValues .= round(($aryValues['nb_uniq_visitors']/$intSum*100), 2).',';
20
+ $strLabels .= '|'.urlencode($aryValues['label']);
21
+ }
22
+ $strValues = substr($strValues, 0, -1);
23
+ $strLabels = substr($strLabels, 1);
24
+ $strBase = 'http://chart.apis.google.com/chart?'.
25
+ 'cht=p&amp;'.
26
+ 'chs=500x220&amp;'.
27
+ 'chd=t:'.$strValues.'&amp;'.
28
+ 'chl='.$strLabels.'&amp;'.
29
+ 'chco=90AAD9,A0BAE9&amp;';
30
+ /***************************************************************************/ ?>
31
+ <div class="wp-piwik-graph-wide">
32
+ <img src="<?php echo $strBase.$strGraph; ?>" width="500" height="220" alt="Visits graph" />
33
+ </div>
34
+ <div class="table">
35
+ <table class="widefat wp-piwik-table">
36
+ <thead>
37
+ <tr>
38
+ <th><?php _e('Resolution', 'wp-piwik'); ?></th>
39
+ <th class="n"><?php _e('Unique', 'wp-piwik'); ?></th>
40
+ <th class="n"><?php _e('Percent', 'wp-piwik'); ?></th>
41
+ </tr>
42
+ </thead>
43
+ <tbody>
44
+ <?php /************************************************************************/
45
+ foreach ($aryConf['data'] as $aryValues)
46
+ echo '<tr><td>'.
47
+ $aryValues['label'].
48
+ '</td><td class="n">'.
49
+ $aryValues['nb_uniq_visitors'].
50
+ '</td><td class="n">'.
51
+ number_format(($aryValues['nb_uniq_visitors']*$intSum/100),2).
52
+ '%</td></tr>';
53
+ unset($aryTmp);
54
+ /***************************************************************************/ ?>
55
+ </tbody>
56
+ </table>
57
+ </div>
58
+ <?php /************************************************************************/
59
+ include ('footer.php');
60
+
61
+ /* EOF */
dashboard/systems.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*********************************
3
+ WP-Piwik::Stats:Systems
4
+ **********************************/
5
+
6
+ $aryConf['data'] = $this->call_API(
7
+ 'UserSettings.getOS',
8
+ $aryConf['params']['period'],
9
+ $aryConf['params']['date'],
10
+ $aryConf['params']['limit']
11
+ );
12
+ $aryConf['title'] = __('Operating System', 'wp-piwik');
13
+ include('header.php');
14
+ $strValues = $strLabels = '';
15
+ $intSum = 0;
16
+ foreach ($aryConf['data'] as $aryValues)
17
+ $intSum += $aryValues['nb_uniq_visitors'];
18
+ foreach ($aryConf['data'] as $aryValues) {
19
+ $strValues .= round(($aryValues['nb_uniq_visitors']/$intSum*100), 2).',';
20
+ $strLabels .= '|'.urlencode($aryValues['label']);
21
+ }
22
+ $strValues = substr($strValues, 0, -1);
23
+ $strLabels = substr($strLabels, 1);
24
+ $strBase = 'http://chart.apis.google.com/chart?'.
25
+ 'cht=p&amp;'.
26
+ 'chs=500x220&amp;'.
27
+ 'chd=t:'.$strValues.'&amp;'.
28
+ 'chl='.$strLabels.'&amp;'.
29
+ 'chco=90AAD9,A0BAE9&amp;';
30
+ /***************************************************************************/ ?>
31
+ <div class="wp-piwik-graph-wide">
32
+ <img src="<?php echo $strBase.$strGraph; ?>" width="500" height="220" alt="Visits graph" />
33
+ </div>
34
+ <div class="table">
35
+ <table class="widefat wp-piwik-table">
36
+ <thead>
37
+ <tr>
38
+ <th><?php _e('Operating System', 'wp-piwik'); ?></th>
39
+ <th class="n"><?php _e('Unique', 'wp-piwik'); ?></th>
40
+ <th class="n"><?php _e('Percent', 'wp-piwik'); ?></th>
41
+ </tr>
42
+ </thead>
43
+ <tbody>
44
+ <?php /************************************************************************/
45
+ foreach ($aryConf['data'] as $aryValues)
46
+ echo '<tr><td>'.
47
+ $aryValues['label'].
48
+ '</td><td class="n">'.
49
+ $aryValues['nb_uniq_visitors'].
50
+ '</td><td class="n">'.
51
+ number_format(($aryValues['nb_uniq_visitors']*$intSum/100),2).
52
+ '%</td></tr>';
53
+ unset($aryTmp);
54
+ /***************************************************************************/ ?>
55
+ </tbody>
56
+ </table>
57
+ </div>
58
+ <?php /************************************************************************/
59
+ include ('footer.php');
60
+
61
+ /* EOF */
languages/wp-piwik-de_DE.mo CHANGED
Binary file
languages/wp-piwik-de_DE.po CHANGED
@@ -19,6 +19,12 @@ msgstr ""
19
  msgid "Browser"
20
  msgstr "Browser"
21
 
 
 
 
 
 
 
22
  #: dashboard/browsers.php:37 dashboard/keywords.php:13
23
  #: dashboard/visitors.php:56 dashboard/websites.php:13
24
  msgid "Unique"
@@ -154,6 +160,15 @@ msgstr "Wenn Dein Template wp_footer() benutzt, kann WP-Piwik den Piwik "
154
  msgid "Add script to wp_footer()"
155
  msgstr "Skript zu wp_footer() hinzuf&uuml;gen"
156
 
 
 
 
 
 
 
 
 
 
157
  #: wp-piwik.php:229
158
  msgid "Save settings"
159
  msgstr "Einstellungen speichern"
19
  msgid "Browser"
20
  msgstr "Browser"
21
 
22
+ msgid "Resolution"
23
+ msgstr "Aufl&ouml;sung"
24
+
25
+ msgid "Operating System"
26
+ msgstr "Betriebssystem"
27
+
28
  #: dashboard/browsers.php:37 dashboard/keywords.php:13
29
  #: dashboard/visitors.php:56 dashboard/websites.php:13
30
  msgid "Unique"
160
  msgid "Add script to wp_footer()"
161
  msgstr "Skript zu wp_footer() hinzuf&uuml;gen"
162
 
163
+ msgid "Tracking filter"
164
+ msgstr "Tracking-Filter"
165
+
166
+ msgid "Choose users by user role you do <strong>not</strong> want to track. "
167
+ "Requires enabled &quot;Add script to wp_footer()&quot;-functionality."
168
+ msgstr "W&auml;hle Nutzer anhand ihrer Nutzerrolle, die <strong>nicht</strong> erfasst "
169
+ "werden sollen. Die Funktion &quot;Skript zu wp_footer() hinzuf&uuml;gen&quot; muss "
170
+ "dazu verwendet werden."
171
+
172
  #: wp-piwik.php:229
173
  msgid "Save settings"
174
  msgstr "Einstellungen speichern"
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: braekling
3
  Requires at least: 2.7
4
  Tested up to: 2.8
5
- Stable tag: 0.3.2
6
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6046779
7
  Tags: statistics, stats, analytics, piwik
8
 
@@ -11,7 +11,7 @@ This plugin adds a piwik stats site to your WordPress dashboard.
11
  == Description ==
12
  This plugin adds a Piwik stats site to your WordPress dashboard. It's also able to add the Piwik tracking code to your blog using wp_footer.
13
 
14
- You need a running Piwik installation and at least view access to your stats.
15
 
16
  Look at the [Piwik website](http://piwik.org/) to get further information about Piwik.
17
 
@@ -32,3 +32,29 @@ Languages: English, German
32
 
33
  1. WP-Piwik stats page.
34
  2. WP-Piwik settings.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  Contributors: braekling
3
  Requires at least: 2.7
4
  Tested up to: 2.8
5
+ Stable tag: 0.4.0
6
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6046779
7
  Tags: statistics, stats, analytics, piwik
8
 
11
  == Description ==
12
  This plugin adds a Piwik stats site to your WordPress dashboard. It's also able to add the Piwik tracking code to your blog using wp_footer.
13
 
14
+ You need a running Piwik installation and at least view access to your stats. Also PHP 5 or higher is strictly required.
15
 
16
  Look at the [Piwik website](http://piwik.org/) to get further information about Piwik.
17
 
32
 
33
  1. WP-Piwik stats page.
34
  2. WP-Piwik settings.
35
+
36
+ == Changelog ==
37
+
38
+ = 0.4.0 =
39
+ * Tracking filter added
40
+ * Resolution stats
41
+ * Operating System stats
42
+ * Plugin stats
43
+
44
+ = 0.3.2 =
45
+ * If allow_url_fopen is disabled in php.ini, WP-Piwik tries to use CURL instead of file_get_contents.
46
+
47
+ = 0.3.1 =
48
+ * WordPress 2.8 compatible
49
+ * Bugfix: Warnings on WP 2.8 plugins site
50
+ * Dashboard revised
51
+ * Partly optimized code
52
+
53
+ = 0.3.0 =
54
+ * WP-Piwik dashboard widgetized.
55
+ * Stats-boxes sortable and closeable.
56
+ * German language file added
57
+ * Browser stats and bounced visitors
58
+
59
+ = 0.2.0 =
60
+ * First public version.
wp-piwik.php CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://dev.braekling.de/wordpress-plugins/dev/wp-piwik/index.html
6
 
7
  Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress footer.
8
 
9
- Version: 0.3.2
10
  Author: Andr&eacute; Br&auml;kling
11
  Author URI: http://www.braekling.de
12
 
@@ -29,7 +29,12 @@ Author URI: http://www.braekling.de
29
 
30
  class wp_piwik {
31
 
 
 
 
32
  function __construct() {
 
 
33
  $strLocale = get_locale();
34
  if ( !empty( $strLocale ) ) {
35
  $strMOfile = ABSPATH . 'wp-content/plugins/'.basename(dirname(__FILE__)).'/languages/wp-piwik-'.$strLocale.'.mo';
@@ -43,11 +48,20 @@ class wp_piwik {
43
  }
44
 
45
  function install() {
46
- // not used
47
  }
48
 
49
  function footer() {
50
- echo get_option('wp-piwik_jscode');
 
 
 
 
 
 
 
 
 
51
  }
52
 
53
  function build_menu() {
@@ -159,14 +173,28 @@ class wp_piwik {
159
  $aryClosed = get_user_option('closedpostboxes_wppiwik');
160
  if (empty($aryClosed)) $aryClosed = array();
161
  $aryDashboard = array();
 
 
 
162
  if (!$arySortOrder) {
163
  // Set default configuration
164
  $arySortOrder = array(
165
- 'side' => 'overview_day_yesterday,keywords_day_yesterday_10,websites_day_yesterday_10',
166
- 'normal' => 'visitors_day_last30,browsers_day_yesterday'
167
  );
168
- update_user_option($GLOBALS['current_user']->ID, 'meta-box-order_wppiwik', $arySortOrder);
 
 
 
 
 
 
 
 
 
 
169
  }
 
170
  foreach ($arySortOrder as $strCol => $strWidgets) {
171
  $aryWidgets = explode(',', $strWidgets);
172
  if (is_array($aryWidgets)) foreach ($aryWidgets as $strParams) {
@@ -234,7 +262,7 @@ class wp_piwik {
234
  <td><?php _e('Auth token', 'wp-piwik'); ?>:</td>
235
  <td><input type="text" name="wp-piwik_token" id="wp-piwik_token" value="<?php echo $strToken; ?>" /></td>
236
  </tr>
237
- <tr><td colspan="2"><span class="setting-description">
238
  <?php _e(
239
  'To enable Piwik statistics, please enter your Piwik'.
240
  ' base URL (like http://mydomain.com/piwik) and your'.
@@ -248,7 +276,7 @@ class wp_piwik {
248
  if (!empty($strToken) && !empty($strURL)) {
249
  $aryData = $this->call_API('SitesManager.getSitesWithAtLeastViewAccess');
250
  if (empty($aryData)) {
251
- echo '<tr><td colspan="2"><p><strong>'.__('An error occured', 'wp-piwik').': </strong>'.
252
  __('Please check URL and auth token. You need at least view access to one site.', 'wp-piwik').
253
  '</p></td></tr>';
254
  } elseif ($aryData['result'] == 'error') {
@@ -259,7 +287,7 @@ class wp_piwik {
259
  ':</td><td><select name="wp-piwik_siteid" id="wp-piwik_siteid">';
260
  foreach ($aryData as $arySite)
261
  echo '<option value="'.$arySite['idsite'].
262
- '"'.($arySite['idsite']==$intSite?' selected':'').
263
  '>'.htmlentities($arySite['name'], ENT_QUOTES, 'utf-8').
264
  '</option>';
265
  echo '</select></td></tr>';
@@ -275,16 +303,28 @@ class wp_piwik {
275
  echo '<tr><td>'.__('Add script to wp_footer()', 'wp-piwik').
276
  ':</td><td><input type="checkbox" value="1" name="wp-piwik_addjs" '.
277
  ($intAddJS?' checked':'').'/></td></tr>';
278
- echo '<tr><td colspan="2"><span class="setting-description">'.
279
  __('If your template uses wp_footer(), WP-Piwik can automatically'.
280
  ' add the Piwik javascript code to your blog.', 'wp-piwik').
281
  '</span></td></tr>';
 
 
 
 
 
 
 
 
 
 
 
 
282
  }
283
  }
284
  /***************************************************************************/ ?>
285
  </table>
286
  <input type="hidden" name="action" value="update" />
287
- <input type="hidden" name="page_options" value="wp-piwik_token,wp-piwik_url,wp-piwik_siteid,wp-piwik_addjs" />
288
  <p class="submit">
289
  <input type="submit" name="Submit" value="<?php _e('Save settings', 'wp-piwik') ?>" />
290
  </p>
6
 
7
  Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress footer.
8
 
9
+ Version: 0.4.0
10
  Author: Andr&eacute; Br&auml;kling
11
  Author URI: http://www.braekling.de
12
 
29
 
30
  class wp_piwik {
31
 
32
+ public static $intRevisionId = 10;
33
+ public static $intDashboardID = 5;
34
+
35
  function __construct() {
36
+ $intCurrentRevision = get_option('wp-piwik_revision',0);
37
+ if ($intCurrentRevision < self::$intRevisionId) $this->install();
38
  $strLocale = get_locale();
39
  if ( !empty( $strLocale ) ) {
40
  $strMOfile = ABSPATH . 'wp-content/plugins/'.basename(dirname(__FILE__)).'/languages/wp-piwik-'.$strLocale.'.mo';
48
  }
49
 
50
  function install() {
51
+ update_option('wp-piwik_revision', self::$intRevisionId);
52
  }
53
 
54
  function footer() {
55
+ global $current_user;
56
+ get_currentuserinfo();
57
+ $bolDisplay = true;
58
+ if (!empty($current_user->roles)) {
59
+ $aryFilter = get_option('wp-piwik_filter');
60
+ foreach ($current_user->roles as $strRole)
61
+ if (isset($aryFilter[$strRole]) && $aryFilter[$strRole])
62
+ $bolDisplay = false;
63
+ }
64
+ if ($bolDisplay) echo get_option('wp-piwik_jscode');
65
  }
66
 
67
  function build_menu() {
173
  $aryClosed = get_user_option('closedpostboxes_wppiwik');
174
  if (empty($aryClosed)) $aryClosed = array();
175
  $aryDashboard = array();
176
+
177
+ $intCurrentDashboard = get_option('wp-piwik_dashboardid',0);
178
+
179
  if (!$arySortOrder) {
180
  // Set default configuration
181
  $arySortOrder = array(
182
+ 'side' => 'overview_day_yesterday,keywords_day_yesterday_10,websites_day_yesterday_10,plugins_day_yesterday',
183
+ 'normal' => 'visitors_day_last30,browsers_day_yesterday,screens_day_yesterday,systems_day_yesterday'
184
  );
185
+ global $current_user;
186
+ get_currentuserinfo();
187
+ update_user_option($current_user->ID, 'meta-box-order_wppiwik', $arySortOrder);
188
+ update_option('wp-piwik_dashboardid', self::$intDashboardID);
189
+ } elseif ($intCurrentDashboard < self::$intDashboardID) {
190
+ $arySortOrder['normal'] .= ',screens_day_yesterday,systems_day_yesterday';
191
+ $arySortOrder['side'] .= ',plugins_day_yesterday';
192
+ global $current_user;
193
+ get_currentuserinfo();
194
+ update_user_option($current_user->ID, 'meta-box-order_wppiwik', $arySortOrder);
195
+ update_option('wp-piwik_dashboardid', self::$intDashboardID);
196
  }
197
+
198
  foreach ($arySortOrder as $strCol => $strWidgets) {
199
  $aryWidgets = explode(',', $strWidgets);
200
  if (is_array($aryWidgets)) foreach ($aryWidgets as $strParams) {
262
  <td><?php _e('Auth token', 'wp-piwik'); ?>:</td>
263
  <td><input type="text" name="wp-piwik_token" id="wp-piwik_token" value="<?php echo $strToken; ?>" /></td>
264
  </tr>
265
+ <tr><td></td><td><span class="setting-description">
266
  <?php _e(
267
  'To enable Piwik statistics, please enter your Piwik'.
268
  ' base URL (like http://mydomain.com/piwik) and your'.
276
  if (!empty($strToken) && !empty($strURL)) {
277
  $aryData = $this->call_API('SitesManager.getSitesWithAtLeastViewAccess');
278
  if (empty($aryData)) {
279
+ echo '<tr><td></td><td><p><strong>'.__('An error occured', 'wp-piwik').': </strong>'.
280
  __('Please check URL and auth token. You need at least view access to one site.', 'wp-piwik').
281
  '</p></td></tr>';
282
  } elseif ($aryData['result'] == 'error') {
287
  ':</td><td><select name="wp-piwik_siteid" id="wp-piwik_siteid">';
288
  foreach ($aryData as $arySite)
289
  echo '<option value="'.$arySite['idsite'].
290
+ '"'.($arySite['idsite']==$intSite?' selected=""':'').
291
  '>'.htmlentities($arySite['name'], ENT_QUOTES, 'utf-8').
292
  '</option>';
293
  echo '</select></td></tr>';
303
  echo '<tr><td>'.__('Add script to wp_footer()', 'wp-piwik').
304
  ':</td><td><input type="checkbox" value="1" name="wp-piwik_addjs" '.
305
  ($intAddJS?' checked':'').'/></td></tr>';
306
+ echo '<tr><td></td><td><span class="setting-description">'.
307
  __('If your template uses wp_footer(), WP-Piwik can automatically'.
308
  ' add the Piwik javascript code to your blog.', 'wp-piwik').
309
  '</span></td></tr>';
310
+ global $wp_roles;
311
+ echo '<tr><td>'.__('Tracking filter', 'wp-piwik').':</td><td>';
312
+ $aryFilter = get_option('wp-piwik_filter');
313
+ foreach($wp_roles->role_names as $strKey => $strName) {
314
+ echo '<input type="checkbox" '.(isset($aryFilter[$strKey]) && $aryFilter[$strKey]?'checked="checked" ':'').'value="1" name="wp-piwik_filter['.$strKey.']" /> '.$strName.' &nbsp; ';
315
+ }
316
+ echo '</td></tr>';
317
+ echo '<tr><td></td><td><span class="setting-description">'.
318
+ __('Choose users by user role you do <strong>not</strong> want to track.'.
319
+ ' Requires enabled &quot;Add script to wp_footer()&quot;-functionality.', 'wp-piwik').
320
+ '</span></td></tr>';
321
+
322
  }
323
  }
324
  /***************************************************************************/ ?>
325
  </table>
326
  <input type="hidden" name="action" value="update" />
327
+ <input type="hidden" name="page_options" value="wp-piwik_token,wp-piwik_url,wp-piwik_siteid,wp-piwik_addjs,wp-piwik_filter" />
328
  <p class="submit">
329
  <input type="submit" name="Submit" value="<?php _e('Save settings', 'wp-piwik') ?>" />
330
  </p>