WP-Matomo (WP-Piwik) - Version 0.8.6

Version Description

  • Added an optional visitor chart to the WordPress dashboard
  • WPMU/multisite bug fixed
  • Minor bugfixes
Download this release

Release Info

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

Code changes from version 0.8.5 to 0.8.6

dashboard/browsers.php CHANGED
@@ -13,12 +13,13 @@
13
  include('header.php');
14
  $strValues = '';
15
  $intCount = 0; $intMore = 0; $intSum = 0;
16
- foreach ($aryConf['data'] as $key => $aryValues) {
17
- $intCount++;
18
- if ($intCount <= 9) $strValues .= '["'.$aryValues['shortLabel'].'",'.$aryValues['nb_uniq_visitors'].'],';
19
- else $intMore += $aryValues['nb_uniq_visitors'];
20
- $intSum += $aryValues['nb_uniq_visitors'];
21
- }
 
22
  if ($intMore) $strValues .= '["'.__('Others', 'wp-piwik').'",'.$intMore.'],';
23
  $strValues = substr($strValues, 0, -1);
24
 
@@ -37,14 +38,16 @@
37
  </thead>
38
  <tbody>
39
  <?php /************************************************************************/
40
- foreach ($aryConf['data'] as $aryValues)
41
- echo '<tr><td>'.
42
- $aryValues['shortLabel'].
43
- '</td><td class="n">'.
44
- $aryValues['nb_uniq_visitors'].
45
- '</td><td class="n">'.
46
- number_format($aryValues['nb_uniq_visitors']/$intSum*100, 2).
47
- '%</td></tr>';
 
 
48
  unset($aryTmp);
49
  /***************************************************************************/ ?>
50
  </tbody>
13
  include('header.php');
14
  $strValues = '';
15
  $intCount = 0; $intMore = 0; $intSum = 0;
16
+ if (is_array($aryConf['data']))
17
+ foreach ($aryConf['data'] as $key => $aryValues) {
18
+ $intCount++;
19
+ if ($intCount <= 9) $strValues .= '["'.$aryValues['shortLabel'].'",'.$aryValues['nb_uniq_visitors'].'],';
20
+ else $intMore += $aryValues['nb_uniq_visitors'];
21
+ $intSum += $aryValues['nb_uniq_visitors'];
22
+ }
23
  if ($intMore) $strValues .= '["'.__('Others', 'wp-piwik').'",'.$intMore.'],';
24
  $strValues = substr($strValues, 0, -1);
25
 
38
  </thead>
39
  <tbody>
40
  <?php /************************************************************************/
41
+ if ($intSum)
42
+ foreach ($aryConf['data'] as $aryValues)
43
+ echo '<tr><td>'.
44
+ $aryValues['shortLabel'].
45
+ '</td><td class="n">'.
46
+ $aryValues['nb_uniq_visitors'].
47
+ '</td><td class="n">'.
48
+ number_format($aryValues['nb_uniq_visitors']/$intSum*100, 2).
49
+ '%</td></tr>';
50
+ else echo '<tr><td colspan="3">'.__('No data available.', 'wp-piwik').'</td></tr>';
51
  unset($aryTmp);
52
  /***************************************************************************/ ?>
53
  </tbody>
dashboard/keywords.php CHANGED
@@ -18,8 +18,9 @@
18
  </thead>
19
  <tbody>
20
  <?php /************************************************************************/
21
- foreach ($aryConf['data'] as $aryValues)
22
  echo '<tr><td>'.$aryValues['label'].'</td><td>'.$aryValues['nb_uniq_visitors'].'</td></tr>';
 
23
  /***************************************************************************/ ?>
24
  </tbody>
25
  </table>
18
  </thead>
19
  <tbody>
20
  <?php /************************************************************************/
21
+ if (is_array($aryConf['data'])) foreach ($aryConf['data'] as $aryValues)
22
  echo '<tr><td>'.$aryValues['label'].'</td><td>'.$aryValues['nb_uniq_visitors'].'</td></tr>';
23
+ else echo '<tr><td colspan="2">'.__('No data available.', 'wp-piwik').'</td></tr>';
24
  /***************************************************************************/ ?>
25
  </tbody>
26
  </table>
dashboard/pages.php CHANGED
@@ -26,7 +26,7 @@
26
  <tbody>
27
  <?php /************************************************************************/
28
  $intCount = 0; $aryOthers = array('u' => 0, 'v' => 0);
29
- foreach ($aryConf['data'] as $aryValues) {
30
  $intCount++;
31
  if ($intCount > $intMax) {
32
  $aryOthers['u'] += $aryValues['nb_uniq_visitors'];
@@ -38,7 +38,7 @@
38
  '</td><td class="n">'.
39
  $aryValues['nb_visits'].
40
  '</td></tr>';
41
- }
42
  if (!empty($aryOthers['v'])) echo '<tr><td>'.
43
  __('Others', 'wp-piwik').
44
  '</td><td class="n">'.
26
  <tbody>
27
  <?php /************************************************************************/
28
  $intCount = 0; $aryOthers = array('u' => 0, 'v' => 0);
29
+ if (is_array($aryConf['data'])) foreach ($aryConf['data'] as $aryValues) {
30
  $intCount++;
31
  if ($intCount > $intMax) {
32
  $aryOthers['u'] += $aryValues['nb_uniq_visitors'];
38
  '</td><td class="n">'.
39
  $aryValues['nb_visits'].
40
  '</td></tr>';
41
+ } else echo '<tr><td colspan="3">'.__('No data available.', 'wp-piwik').'</td></tr>';
42
  if (!empty($aryOthers['v'])) echo '<tr><td>'.
43
  __('Others', 'wp-piwik').
44
  '</td><td class="n">'.
dashboard/plugins.php CHANGED
@@ -35,7 +35,7 @@
35
  </thead>
36
  <tbody>
37
  <?php /************************************************************************/
38
- foreach ($aryConf['data'] as $aryValues)
39
  echo '<tr><td>'.
40
  $aryValues['label'].
41
  '</td><td class="n">'.
@@ -46,6 +46,7 @@
46
  '0.00%'
47
  ).
48
  '%</td></tr>';
 
49
  unset($aryTmp);
50
  /***************************************************************************/ ?>
51
  </tbody>
35
  </thead>
36
  <tbody>
37
  <?php /************************************************************************/
38
+ if (is_array($aryConf['data'])) foreach ($aryConf['data'] as $aryValues)
39
  echo '<tr><td>'.
40
  $aryValues['label'].
41
  '</td><td class="n">'.
46
  '0.00%'
47
  ).
48
  '%</td></tr>';
49
+ else echo '<tr><td colspan="3">'.__('No data available.', 'wp-piwik').'</td></tr>';
50
  unset($aryTmp);
51
  /***************************************************************************/ ?>
52
  </tbody>
dashboard/screens.php CHANGED
@@ -13,12 +13,13 @@
13
  include('header.php');
14
  $strValues = '';
15
  $intCount = 0; $intMore = 0; $intSum = 0;
16
- foreach ($aryConf['data'] as $key => $aryValues) {
17
- $intCount++;
18
- if ($intCount <= 9) $strValues .= '["'.$aryValues['label'].'",'.$aryValues['nb_uniq_visitors'].'],';
19
- else $intMore += $aryValues['nb_uniq_visitors'];
20
- $intSum += $aryValues['nb_uniq_visitors'];
21
- }
 
22
  if ($intMore) $strValues .= '["'.__('Others', 'wp-piwik').'",'.$intMore.'],';
23
  $strValues = substr($strValues, 0, -1);
24
  /***************************************************************************/ ?>
@@ -36,14 +37,16 @@
36
  </thead>
37
  <tbody>
38
  <?php /************************************************************************/
39
- foreach ($aryConf['data'] as $aryValues)
40
- echo '<tr><td>'.
41
- $aryValues['label'].
42
- '</td><td class="n">'.
43
- $aryValues['nb_uniq_visitors'].
44
- '</td><td class="n">'.
45
- number_format($aryValues['nb_uniq_visitors']/$intSum*100, 2).
46
- '%</td></tr>';
 
 
47
  unset($aryTmp);
48
  /***************************************************************************/ ?>
49
  </tbody>
13
  include('header.php');
14
  $strValues = '';
15
  $intCount = 0; $intMore = 0; $intSum = 0;
16
+ if (is_array($aryConf['data']))
17
+ foreach ($aryConf['data'] as $key => $aryValues) {
18
+ $intCount++;
19
+ if ($intCount <= 9) $strValues .= '["'.$aryValues['label'].'",'.$aryValues['nb_uniq_visitors'].'],';
20
+ else $intMore += $aryValues['nb_uniq_visitors'];
21
+ $intSum += $aryValues['nb_uniq_visitors'];
22
+ }
23
  if ($intMore) $strValues .= '["'.__('Others', 'wp-piwik').'",'.$intMore.'],';
24
  $strValues = substr($strValues, 0, -1);
25
  /***************************************************************************/ ?>
37
  </thead>
38
  <tbody>
39
  <?php /************************************************************************/
40
+ if ($intSum)
41
+ foreach ($aryConf['data'] as $aryValues)
42
+ echo '<tr><td>'.
43
+ $aryValues['label'].
44
+ '</td><td class="n">'.
45
+ $aryValues['nb_uniq_visitors'].
46
+ '</td><td class="n">'.
47
+ number_format($aryValues['nb_uniq_visitors']/$intSum*100, 2).
48
+ '%</td></tr>';
49
+ else echo '<tr><td colspan="3">'.__('No data available.', 'wp-piwik').'</td></tr>';
50
  unset($aryTmp);
51
  /***************************************************************************/ ?>
52
  </tbody>
dashboard/systems.php CHANGED
@@ -13,12 +13,13 @@
13
  include('header.php');
14
  $strValues = '';
15
  $intCount = 0; $intMore = 0; $intSum = 0;
16
- foreach ($aryConf['data'] as $key => $aryValues) {
17
- $intCount++;
18
- if ($intCount <= 9) $strValues .= '["'.$aryValues['label'].'",'.$aryValues['nb_uniq_visitors'].'],';
19
- else $intMore += $aryValues['nb_uniq_visitors'];
20
- $intSum += $aryValues['nb_uniq_visitors'];
21
- }
 
22
  if ($intMore) $strValues .= '["'.__('Others', 'wp-piwik').'",'.$intMore.'],';
23
  $strValues = substr($strValues, 0, -1);
24
 
@@ -38,14 +39,16 @@
38
  </thead>
39
  <tbody>
40
  <?php /************************************************************************/
41
- foreach ($aryConf['data'] as $aryValues)
42
- echo '<tr><td>'.
43
- $aryValues['label'].
44
- '</td><td class="n">'.
45
- $aryValues['nb_uniq_visitors'].
46
- '</td><td class="n">'.
47
- number_format($aryValues['nb_uniq_visitors']/$intSum*100, 2).
48
- '%</td></tr>';
 
 
49
  unset($aryTmp);
50
  /***************************************************************************/ ?>
51
  </tbody>
13
  include('header.php');
14
  $strValues = '';
15
  $intCount = 0; $intMore = 0; $intSum = 0;
16
+ if (is_array($aryConf['data']))
17
+ foreach ($aryConf['data'] as $key => $aryValues) {
18
+ $intCount++;
19
+ if ($intCount <= 9) $strValues .= '["'.$aryValues['label'].'",'.$aryValues['nb_uniq_visitors'].'],';
20
+ else $intMore += $aryValues['nb_uniq_visitors'];
21
+ $intSum += $aryValues['nb_uniq_visitors'];
22
+ }
23
  if ($intMore) $strValues .= '["'.__('Others', 'wp-piwik').'",'.$intMore.'],';
24
  $strValues = substr($strValues, 0, -1);
25
 
39
  </thead>
40
  <tbody>
41
  <?php /************************************************************************/
42
+ if ($intSum)
43
+ foreach ($aryConf['data'] as $aryValues)
44
+ echo '<tr><td>'.
45
+ $aryValues['label'].
46
+ '</td><td class="n">'.
47
+ $aryValues['nb_uniq_visitors'].
48
+ '</td><td class="n">'.
49
+ number_format($aryValues['nb_uniq_visitors']/$intSum*100, 2).
50
+ '%</td></tr>';
51
+ else echo '<tr><td colspan="3">'.__('No data available.', 'wp-piwik').'</td></tr>';
52
  unset($aryTmp);
53
  /***************************************************************************/ ?>
54
  </tbody>
dashboard/visitors.php CHANGED
@@ -20,19 +20,24 @@
20
  $aryConf['params']['period'],
21
  $aryConf['params']['date'],
22
  $aryConf['params']['limit']
23
- );
24
  $aryConf['title'] = __('Visitors', 'wp-piwik');
25
- include('header.php');
 
 
 
26
  $strValues = $strLabels = $strBounced = $strValuesU = $strCounter = '';
27
  $intUSum = $intCount = 0;
28
- foreach ($aryConf['data']['Visitors'] as $strDate => $intValue) {
29
- $intCount++;
30
- $strValues .= $intValue.',';
31
- $strValuesU .= $aryConf['data']['Unique'][$strDate].',';
32
- $strBounced .= $aryConf['data']['Bounced'][$strDate].',';
33
- $strLabels .= '['.$intCount.',"'.substr($strDate,-2).'"],';
34
- $intUSum += $aryConf['data']['Unique'][$strDate];
35
- }
 
 
36
  $intAvg = round($intUSum/30,0);
37
  $strValues = substr($strValues, 0, -1);
38
  $strValuesU = substr($strValuesU, 0, -1);
@@ -42,8 +47,9 @@
42
 
43
  /***************************************************************************/ ?>
44
  <div class="wp-piwik-graph-wide">
45
- <div id="wp-piwik_stats_vistors_graph" style="height:220px;width:490px"></div>
46
  </div>
 
47
  <div class="table">
48
  <table class="widefat wp-piwik-table">
49
  <thead>
@@ -56,20 +62,23 @@
56
  </thead>
57
  <tbody style="cursor:pointer;">
58
  <?php /************************************************************************/
59
- $aryTmp = array_reverse($aryConf['data']['Visitors']);
60
- foreach ($aryTmp as $strDate => $intValue)
61
- echo '<tr onclick="javascript:datelink(\''.urlencode(self::$strPluginBasename).'\',\''.str_replace('-', '', $strDate).'\');"><td>'.$strDate.'</td><td class="n">'.
62
- $intValue.'</td><td class="n">'.
63
- $aryConf['data']['Unique'][$strDate].
64
- '</td><td class="n">'.
65
- $aryConf['data']['Bounced'][$strDate].
66
- '</td></tr>'."\n";
 
 
67
  echo '<tr><td class="n" colspan="4"><strong>'.__('Unique TOTAL', 'wp-piwik').'</strong> '.__('Sum', 'wp-piwik').': '.$intUSum.' '.__('Avg', 'wp-piwik').': '.$intAvg.'</td></tr>';
68
  unset($aryTmp);
69
  /***************************************************************************/ ?>
70
  </tbody>
71
  </table>
72
  </div>
 
73
  <script type="text/javascript">
74
  $j.jqplot('wp-piwik_stats_vistors_graph', [[<?php echo $strValues; ?>],[<?php echo $strValuesU; ?>],[<?php echo $strBounced;?>]],
75
  {
@@ -79,6 +88,7 @@ $j.jqplot('wp-piwik_stats_vistors_graph', [[<?php echo $strValues; ?>],[<?php ec
79
  });
80
  </script>
81
  <?php /************************************************************************/
82
- include ('footer.php');
 
83
 
84
  /* EOF */
20
  $aryConf['params']['period'],
21
  $aryConf['params']['date'],
22
  $aryConf['params']['limit']
23
+ );
24
  $aryConf['title'] = __('Visitors', 'wp-piwik');
25
+
26
+ if (!isset($aryConf['inline']) || $aryConf['inline'] != true)
27
+ include('header.php');
28
+
29
  $strValues = $strLabels = $strBounced = $strValuesU = $strCounter = '';
30
  $intUSum = $intCount = 0;
31
+ if (is_array($aryConf['data']['Visitors']))
32
+ foreach ($aryConf['data']['Visitors'] as $strDate => $intValue) {
33
+ $intCount++;
34
+ $strValues .= $intValue.',';
35
+ $strValuesU .= $aryConf['data']['Unique'][$strDate].',';
36
+ $strBounced .= $aryConf['data']['Bounced'][$strDate].',';
37
+ $strLabels .= '['.$intCount.',"'.substr($strDate,-2).'"],';
38
+ $intUSum += $aryConf['data']['Unique'][$strDate];
39
+ }
40
+ else {$strValues = '0,'; $strLabels = '[0,"-"],'; $strValuesU = '0,'; $strBounced = '0,'; }
41
  $intAvg = round($intUSum/30,0);
42
  $strValues = substr($strValues, 0, -1);
43
  $strValuesU = substr($strValuesU, 0, -1);
47
 
48
  /***************************************************************************/ ?>
49
  <div class="wp-piwik-graph-wide">
50
+ <div id="wp-piwik_stats_vistors_graph" style="height:220px;width:100%"></div>
51
  </div>
52
+ <?php if (!isset($aryConf['inline']) || $aryConf['inline'] != true) { ?>
53
  <div class="table">
54
  <table class="widefat wp-piwik-table">
55
  <thead>
62
  </thead>
63
  <tbody style="cursor:pointer;">
64
  <?php /************************************************************************/
65
+ if (is_array($aryConf['data']['Visitors'])) {
66
+ $aryTmp = array_reverse($aryConf['data']['Visitors']);
67
+ foreach ($aryTmp as $strDate => $intValue)
68
+ echo '<tr onclick="javascript:datelink(\''.urlencode(self::$strPluginBasename).'\',\''.str_replace('-', '', $strDate).'\');"><td>'.$strDate.'</td><td class="n">'.
69
+ $intValue.'</td><td class="n">'.
70
+ $aryConf['data']['Unique'][$strDate].
71
+ '</td><td class="n">'.
72
+ $aryConf['data']['Bounced'][$strDate].
73
+ '</td></tr>'."\n";
74
+ }
75
  echo '<tr><td class="n" colspan="4"><strong>'.__('Unique TOTAL', 'wp-piwik').'</strong> '.__('Sum', 'wp-piwik').': '.$intUSum.' '.__('Avg', 'wp-piwik').': '.$intAvg.'</td></tr>';
76
  unset($aryTmp);
77
  /***************************************************************************/ ?>
78
  </tbody>
79
  </table>
80
  </div>
81
+ <?php } ?>
82
  <script type="text/javascript">
83
  $j.jqplot('wp-piwik_stats_vistors_graph', [[<?php echo $strValues; ?>],[<?php echo $strValuesU; ?>],[<?php echo $strBounced;?>]],
84
  {
88
  });
89
  </script>
90
  <?php /************************************************************************/
91
+ if (!isset($aryConf['inline']) || $aryConf['inline'] != true)
92
+ include ('footer.php');
93
 
94
  /* EOF */
dashboard/websites.php CHANGED
@@ -21,8 +21,9 @@
21
  </thead>
22
  <tbody>
23
  <?php /************************************************************************/
24
- foreach ($aryConf['data'] as $aryValues)
25
  echo '<tr><td>'.$aryValues['label'].'</td><td>'.$aryValues['nb_uniq_visitors'].'</td></tr>';
 
26
  /***************************************************************************/ ?>
27
  </tbody>
28
  </table>
21
  </thead>
22
  <tbody>
23
  <?php /************************************************************************/
24
+ if (is_array($aryConf['data'])) foreach ($aryConf['data'] as $aryValues)
25
  echo '<tr><td>'.$aryValues['label'].'</td><td>'.$aryValues['nb_uniq_visitors'].'</td></tr>';
26
+ else echo '<tr><td colspan="2">'.__('No data available.', 'wp-piwik').'</td></tr>';
27
  /***************************************************************************/ ?>
28
  </tbody>
29
  </table>
languages/wp-piwik-de_DE.mo CHANGED
Binary file
languages/wp-piwik-de_DE.po CHANGED
@@ -374,3 +374,18 @@ msgstr "Default-Datum"
374
 
375
  msgid "Default date shown on statistics page."
376
  msgstr "Default-Datum, das auf der Statistik-Seite gezeigt wird."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
374
 
375
  msgid "Default date shown on statistics page."
376
  msgstr "Default-Datum, das auf der Statistik-Seite gezeigt wird."
377
+
378
+ msgid "Dashboard data"
379
+ msgstr "Board-Daten"
380
+
381
+ msgid "Display an overview widget to your WordPress dashboard."
382
+ msgstr "Zeigt ein &Uuml;bersichts-Widget auf dem WordPress-Dashboard."
383
+
384
+ msgid "Boad chart"
385
+ msgstr "Board-Chart"
386
+
387
+ msgid "Display a visitor graph widget to your WordPress dashboard."
388
+ msgstr "Zeigt einen Besucher-Graph als Widget auf dem WordPress-Dashboard."
389
+
390
+ msgid "No data available."
391
+ msgstr "Keine Daten vorhanden."
readme.txt CHANGED
@@ -3,7 +3,7 @@
3
  Contributors: Braekling
4
  Requires at least: 3.0.1
5
  Tested up to: 3.1
6
- Stable tag: 0.8.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
 
@@ -75,10 +75,15 @@ Thank you, guys!
75
 
76
  == Changelog ==
77
 
 
 
 
 
 
78
  = 0.8.5 =
79
  * Select default date (today or yesterday) shown on statistics page
80
  * Bugfix: Shortcut links are shown again
81
- * German language fixes
82
  * Minor optical fixes (text length)
83
 
84
  = 0.8.4 =
3
  Contributors: Braekling
4
  Requires at least: 3.0.1
5
  Tested up to: 3.1
6
+ Stable tag: 0.8.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
 
75
 
76
  == Changelog ==
77
 
78
+ = 0.8.6 =
79
+ * Added an optional visitor chart to the WordPress dashboard
80
+ * [WPMU/multisite bug](http://wordpress.org/support/topic/plugin-wp-piwik-multisite-update-procedure) fixed
81
+ * Minor bugfixes
82
+
83
  = 0.8.5 =
84
  * Select default date (today or yesterday) shown on statistics page
85
  * Bugfix: Shortcut links are shown again
86
+ * German language file update
87
  * Minor optical fixes (text length)
88
 
89
  = 0.8.4 =
wp-piwik.php CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://www.braekling.de/wp-piwik-wpmu-piwik-wordpress/
6
 
7
  Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress footer.
8
 
9
- Version: 0.8.5
10
  Author: Andr&eacute; Br&auml;kling
11
  Author URI: http://www.braekling.de
12
 
@@ -33,30 +33,31 @@ $GLOBALS['wp-piwik_wpmu'] = false;
33
  class wp_piwik {
34
 
35
  private static
36
- $intRevisionId = 80502,
37
- $strVersion = '0.8.5',
38
  $intDashboardID = 6,
39
  $bolWPMU = false,
40
  $bolOverall = false,
41
  $strPluginBasename = NULL,
42
  $aryGlobalSettings = array(
43
- 'revision' => 0,
44
- 'add_tracking_code' => false,
45
- 'last_settings_update' => 0,
46
- 'piwik_token' => '',
47
- 'piwik_url' => '',
48
- 'dashboard_widget' => false,
49
- 'capability_stealth' => array(),
 
50
  'capability_read_stats' => array('administrator' => true),
51
- 'piwik_shortcut' => false,
52
- 'default_date' => 'yesterday'
53
  ),
54
  $arySettings = array(
55
- 'tracking_code' => '',
56
- 'site_id' => NULL,
57
- 'track_404' => false,
58
  'last_tracking_code_update' => 0,
59
- 'dashboard_revision' => 0
60
  );
61
 
62
  /**
@@ -121,7 +122,8 @@ class wp_piwik {
121
  // Add admin menu
122
  add_action('admin_menu', array($this, 'build_menu'));
123
  // Add dashboard widget if enabled
124
- if (self::$aryGlobalSettings['dashboard_widget']) add_action('wp_dashboard_setup', array($this, 'extend_wp_dashboard_setup'));
 
125
  }
126
 
127
  /**
@@ -153,46 +155,44 @@ class wp_piwik {
153
  'revision' => get_site_option('wpmu-piwik_revision', 0),
154
  'add_tracking_code' => true,
155
  'last_settings_update' => get_site_option('wpmu-piwik_settingsupdate', time()),
156
- 'piwik_token' => get_site_option('wpmu-piwik_token', ''),
157
- 'piwik_url' => get_site_option('wpmu-piwik_url', ''),
158
- 'dashboard_widget' => false,
159
  'capability_stealth' => get_site_option('wpmu-piwik_filter', array()),
160
  'capability_read_stats' => $aryDisplayToCap,
161
- 'piwik_shortcut' => false,
162
  );
163
  else self::$aryGlobalSettings = array(
164
- 'revision' => get_option('wp-piwik_revision',0),
165
  'add_tracking_code' => get_option('wp-piwik_addjs'),
166
  'last_settings_update' => get_option('wp-piwik_settingsupdate', time()),
167
- 'piwik_token' => get_option('wp-piwik_token', ''),
168
- 'piwik_url' => get_option('wp-piwik_url', ''),
169
- 'dashboard_widget' => $aryDashboardWidgetRange[get_option('wp-piwik_dbwidget', 0)],
170
  'capability_stealth' => get_option('wp-piwik_filter', array()),
171
  'capability_read_stats' => $aryDisplayToCap,
172
- 'piwik_shortcut' => get_option('wp-piwik_piwiklink',false),
173
- );
174
- self::$arySettings = array(
175
- 'tracking_code' => '',
176
- 'site_id' => get_option('wp-piwik_siteid', NULL),
177
- 'track_404' => get_option('wp-piwik_404', false),
178
- 'last_tracking_code_update' => get_option('wp-piwik_scriptupdate', 0),
179
- 'dashboard_revision' => get_option('wp-piwik_dashboardid', 0)
180
  );
 
 
181
 
182
  // Remove deprecated option values
183
  $aryRemoveOptions = array(
184
- 'wp-piwik_disable_gapi','wp-piwik_displayto','wp-piwik_siteid','wp-piwik_404','wp-piwik_scriptupdate',
185
- 'wp-piwik_dashboardid','wp-piwik_revision','wp-piwik_addjs','wp-piwik_settingsupdate','wp-piwik_token',
186
- 'wp-piwik_url','wp-piwik_dbwidget','wp-piwik_filter','wp-piwik_piwiklink','wp-piwik_jscode'
187
  );
188
- foreach ($aryRemoveOptions as $strRemoveOption) {
189
- delete_option($strRemoveOption);
190
  if (self::$bolWPMU) delete_site_option($strRemoveOption);
 
191
  }
192
  };
193
  if (self::$aryGlobalSettings['revision'] < 80502) {
194
  self::$aryGlobalSettings['default_date'] = 'yesterday';
195
  }
 
 
 
196
  add_action('admin_footer', array($this, 'updateMessage'));
197
  // Set current revision ID
198
  self::$aryGlobalSettings['revision'] = self::$intRevisionId;
@@ -204,6 +204,33 @@ class wp_piwik {
204
  self::loadSettings();
205
  }
206
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  /**
208
  * Send a message after installing/updating
209
  */
@@ -228,6 +255,8 @@ class wp_piwik {
228
  return;
229
  // Add tracking code?
230
  } elseif (current_user_can('wp-piwik_stealth')) return;
 
 
231
  // Handle new WPMU site
232
  if (self::$bolWPMU && empty(self::$arySettings['tracking_code'])) {
233
  $aryReturn = $this->create_wpmu_site();
@@ -301,12 +330,27 @@ class wp_piwik {
301
  }
302
 
303
  function extend_wp_dashboard_setup() {
304
- if (current_user_can('wp-piwik_read_stats'))
305
- wp_add_dashboard_widget(
306
- 'wp-piwik_dashboard_widget',
307
- __('WP-Piwik', 'wp-piwik').' - '.__(self::$aryGlobalSettings['dashboard_widget'], 'wp-piwik'),
308
- array (&$this, 'add_wp_dashboard_widget')
309
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  }
311
 
312
  function add_wp_dashboard_widget() {
@@ -320,6 +364,21 @@ class wp_piwik {
320
  );
321
  $this->create_dashboard_widget('overview', $arySetup);
322
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
 
324
  /**
325
  * Add plugin meta links to plugin details
@@ -367,6 +426,7 @@ class wp_piwik {
367
  echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.$this->get_plugin_url().(self::$bolWPMU?'wp-piwik/':'').'js/jqplot/excanvas.min.js"></script><![endif]-->';
368
  // Load jqPlot styles
369
  echo '<link rel="stylesheet" href="'.$this->get_plugin_url().'js/jqplot/jquery.jqplot.min.css" type="text/css"/>';
 
370
  }
371
 
372
  /**
@@ -541,7 +601,6 @@ class wp_piwik {
541
  }
542
  }
543
  /***************************************************************************/ ?>
544
- <script type="text/javascript">var $j = jQuery.noConflict();</script>
545
  <div class="wrap">
546
  <div id="icon-post" class="icon32"><br /></div>
547
  <h2><?php _e('Piwik Statistics', 'wp-piwik'); ?></h2>
@@ -603,6 +662,7 @@ class wp_piwik {
603
  if (!self::$bolWPMU) {
604
  self::$aryGlobalSettings['add_tracking_code'] = (isset($_POST['wp-piwik_addjs'])?$_POST['wp-piwik_addjs']:'');
605
  self::$aryGlobalSettings['dashboard_widget'] = (isset($_POST['wp-piwik_dbwidget'])?$_POST['wp-piwik_dbwidget']:false);
 
606
  self::$aryGlobalSettings['piwik_shortcut'] = (isset($_POST['wp-piwik_piwiklink'])?$_POST['wp-piwik_piwiklink']:false);
607
  self::$arySettings['site_id'] = (isset($_POST['wp-piwik_siteid'])?$_POST['wp-piwik_siteid']:NULL);
608
  self::$arySettings['track_404'] = (isset($_POST['wp-piwik_404'])?$_POST['wp-piwik_404']:false);
@@ -699,7 +759,7 @@ class wp_piwik {
699
  <div class="inside">
700
  <?php /************************************************************************/
701
  echo '<h4><label for="wp-piwik_jscode">JavaScript:</label></h4>'.
702
- '<div class="input-text-wrap"><textarea id="wp-piwik_jscode" name="wp-piwik_jscode" readonly="readonly" rows="17" cols="55">'.
703
  htmlentities($strJavaScript).'</textarea></div>';
704
  echo '<h4><label for="wp-piwik_addjs">'.__('Add script', 'wp-piwik').':</label></h4>'.
705
  '<div class="input-wrap"><input type="checkbox" value="1" id="wp-piwik_addjs" name="wp-piwik_addjs" '.
@@ -734,7 +794,7 @@ class wp_piwik {
734
  <h3 class='hndle'><span><?php _e('Statistic view settings', 'wp-piwik'); ?></span></h3>
735
  <div class="inside">
736
  <?php
737
- echo '<h4><label for="wp-piwik_dbwidget">'.__('Dashboard', 'wp-piwik').':</label></h4>'.
738
  '<div class="input-wrap"><select id="wp-piwik_dbwidget" name="wp-piwik_dbwidget">'.
739
  '<option value="0"'.(!$intDashboardWidget?' selected="selected"':'').'>'.__('No', 'wp-piwik').'</option>'.
740
  '<option value="yesterday"'.($intDashboardWidget == 'yesterday'?' selected="selected"':'').'>'.__('Yes','wp-piwik').' ('.__('yesterday', 'wp-piwik').').</option>'.
@@ -742,7 +802,14 @@ class wp_piwik {
742
  '<option value="last30"'.($intDashboardWidget == 'last30'?' selected="selected"':'').'>'.__('Yes','wp-piwik').' ('.__('last 30 days','wp-piwik').').</option>'.
743
  '</select></div>';
744
  echo '<div class="wp-piwik_desc">'.
745
- __('Display a dashboard widget to your WordPress dashboard.', 'wp-piwik').'</div>';
 
 
 
 
 
 
 
746
  echo '<h4><label for="wp-piwik_piwiklink">'.__('Shortcut', 'wp-piwik').':</label></h4>'.
747
  '<div class="input-wrap"><input type="checkbox" value="1" name="wp-piwik_piwiklink" id="wp-piwik_piwiklink" '.
748
  ($intShowLink?' checked="checked"':"").'/></div>';
@@ -900,4 +967,4 @@ class wp_piwik {
900
  if (class_exists('wp_piwik'))
901
  $GLOBALS['wp_piwik'] = new wp_piwik();
902
 
903
- /* EOF */
6
 
7
  Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress footer.
8
 
9
+ Version: 0.8.6
10
  Author: Andr&eacute; Br&auml;kling
11
  Author URI: http://www.braekling.de
12
 
33
  class wp_piwik {
34
 
35
  private static
36
+ $intRevisionId = 80602,
37
+ $strVersion = '0.8.6',
38
  $intDashboardID = 6,
39
  $bolWPMU = false,
40
  $bolOverall = false,
41
  $strPluginBasename = NULL,
42
  $aryGlobalSettings = array(
43
+ 'revision' => 0,
44
+ 'add_tracking_code' => false,
45
+ 'last_settings_update' => 0,
46
+ 'piwik_token' => '',
47
+ 'piwik_url' => '',
48
+ 'dashboard_widget' => false,
49
+ 'dashboard_chart' => false,
50
+ 'capability_stealth' => array(),
51
  'capability_read_stats' => array('administrator' => true),
52
+ 'piwik_shortcut' => false,
53
+ 'default_date' => 'yesterday'
54
  ),
55
  $arySettings = array(
56
+ 'tracking_code' => '',
57
+ 'site_id' => NULL,
58
+ 'track_404' => false,
59
  'last_tracking_code_update' => 0,
60
+ 'dashboard_revision' => 0
61
  );
62
 
63
  /**
122
  // Add admin menu
123
  add_action('admin_menu', array($this, 'build_menu'));
124
  // Add dashboard widget if enabled
125
+ if (self::$aryGlobalSettings['dashboard_widget'] || self::$aryGlobalSettings['dashboard_chart'])
126
+ add_action('wp_dashboard_setup', array($this, 'extend_wp_dashboard_setup'));
127
  }
128
 
129
  /**
155
  'revision' => get_site_option('wpmu-piwik_revision', 0),
156
  'add_tracking_code' => true,
157
  'last_settings_update' => get_site_option('wpmu-piwik_settingsupdate', time()),
158
+ 'piwik_token' => get_site_option('wpmu-piwik_token', ''),
159
+ 'piwik_url' => get_site_option('wpmu-piwik_url', ''),
160
+ 'dashboard_widget' => false,
161
  'capability_stealth' => get_site_option('wpmu-piwik_filter', array()),
162
  'capability_read_stats' => $aryDisplayToCap,
163
+ 'piwik_shortcut' => false,
164
  );
165
  else self::$aryGlobalSettings = array(
166
+ 'revision' => get_option('wp-piwik_revision',0),
167
  'add_tracking_code' => get_option('wp-piwik_addjs'),
168
  'last_settings_update' => get_option('wp-piwik_settingsupdate', time()),
169
+ 'piwik_token' => get_option('wp-piwik_token', ''),
170
+ 'piwik_url' => get_option('wp-piwik_url', ''),
171
+ 'dashboard_widget' => $aryDashboardWidgetRange[get_option('wp-piwik_dbwidget', 0)],
172
  'capability_stealth' => get_option('wp-piwik_filter', array()),
173
  'capability_read_stats' => $aryDisplayToCap,
174
+ 'piwik_shortcut' => get_option('wp-piwik_piwiklink',false),
 
 
 
 
 
 
 
175
  );
176
+
177
+ $this->installSite(false);
178
 
179
  // Remove deprecated option values
180
  $aryRemoveOptions = array(
181
+ 'wp-piwik_disable_gapi','wp-piwik_displayto',
182
+ 'wp-piwik_revision','wp-piwik_addjs','wp-piwik_settingsupdate','wp-piwik_token',
183
+ 'wp-piwik_url','wp-piwik_dbwidget','wp-piwik_filter','wp-piwik_piwiklink'
184
  );
185
+ foreach ($aryRemoveOptions as $strRemoveOption) {
 
186
  if (self::$bolWPMU) delete_site_option($strRemoveOption);
187
+ else delete_option($strRemoveOption);
188
  }
189
  };
190
  if (self::$aryGlobalSettings['revision'] < 80502) {
191
  self::$aryGlobalSettings['default_date'] = 'yesterday';
192
  }
193
+ if (self::$aryGlobalSettings['revision'] < 80602) {
194
+ self::$aryGlobalSettings['dashboard_chart'] = false;
195
+ }
196
  add_action('admin_footer', array($this, 'updateMessage'));
197
  // Set current revision ID
198
  self::$aryGlobalSettings['revision'] = self::$intRevisionId;
204
  self::loadSettings();
205
  }
206
 
207
+ /**
208
+ * Install or upgrade site settings
209
+ */
210
+ function installSite($bolSave = true) {
211
+ self::$arySettings = array(
212
+ 'tracking_code' => '',
213
+ 'site_id' => get_option('wp-piwik_siteid', NULL),
214
+ 'track_404' => get_option('wp-piwik_404', false),
215
+ 'last_tracking_code_update' => get_option('wp-piwik_scriptupdate', 0),
216
+ 'dashboard_revision' => get_option('wp-piwik_dashboardid', 0)
217
+ );
218
+
219
+ // Remove deprecated option values
220
+ $aryRemoveOptions = array(
221
+ 'wp-piwik_siteid','wp-piwik_404','wp-piwik_scriptupdate','wp-piwik_dashboardid','wp-piwik_jscode'
222
+ );
223
+ foreach ($aryRemoveOptions as $strRemoveOption) {
224
+ delete_option($strRemoveOption);
225
+ };
226
+ if ($bolSave) {
227
+ // Save upgraded or default settings
228
+ self::saveSettings();
229
+ // Reload settings
230
+ self::loadSettings();
231
+ }
232
+ }
233
+
234
  /**
235
  * Send a message after installing/updating
236
  */
255
  return;
256
  // Add tracking code?
257
  } elseif (current_user_can('wp-piwik_stealth')) return;
258
+ // Hotfix: Update WPMU site if not done yet
259
+ if (self::$bolWPMU && get_option('wp-piwik_siteid', false)) $this->installSite();
260
  // Handle new WPMU site
261
  if (self::$bolWPMU && empty(self::$arySettings['tracking_code'])) {
262
  $aryReturn = $this->create_wpmu_site();
330
  }
331
 
332
  function extend_wp_dashboard_setup() {
333
+ if (current_user_can('wp-piwik_read_stats')) {
334
+ if (self::$aryGlobalSettings['dashboard_widget'])
335
+ wp_add_dashboard_widget(
336
+ 'wp-piwik_dashboard_widget',
337
+ __('WP-Piwik', 'wp-piwik').' - '.__(self::$aryGlobalSettings['dashboard_widget'], 'wp-piwik'),
338
+ array (&$this, 'add_wp_dashboard_widget')
339
+ );
340
+ if (self::$aryGlobalSettings['dashboard_chart']) {
341
+ // Add required scripts
342
+ add_action('admin_print_scripts-index.php', array($this, 'load_scripts'));
343
+ // Add required styles
344
+ add_action('admin_print_styles-index.php', array($this, 'add_admin_style'));
345
+ // Add required header tags
346
+ add_action('admin_head-index.php', array($this, 'add_admin_header'));
347
+ wp_add_dashboard_widget(
348
+ 'wp-piwik_dashboard_chart',
349
+ __('WP-Piwik', 'wp-piwik').' - '.__('Visitors', 'wp-piwik'),
350
+ array (&$this, 'add_wp_dashboard_chart')
351
+ );
352
+ }
353
+ }
354
  }
355
 
356
  function add_wp_dashboard_widget() {
364
  );
365
  $this->create_dashboard_widget('overview', $arySetup);
366
  }
367
+
368
+ /**
369
+ * Add a visitor chart to the WordPress dashboard
370
+ */
371
+ function add_wp_dashboard_chart() {
372
+ $arySetup = array(
373
+ 'params' => array(
374
+ 'period' => 'day',
375
+ 'date' => 'last30',
376
+ 'limit' => null
377
+ ),
378
+ 'inline' => true,
379
+ );
380
+ $this->create_dashboard_widget('visitors', $arySetup);
381
+ }
382
 
383
  /**
384
  * Add plugin meta links to plugin details
426
  echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.$this->get_plugin_url().(self::$bolWPMU?'wp-piwik/':'').'js/jqplot/excanvas.min.js"></script><![endif]-->';
427
  // Load jqPlot styles
428
  echo '<link rel="stylesheet" href="'.$this->get_plugin_url().'js/jqplot/jquery.jqplot.min.css" type="text/css"/>';
429
+ echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
430
  }
431
 
432
  /**
601
  }
602
  }
603
  /***************************************************************************/ ?>
 
604
  <div class="wrap">
605
  <div id="icon-post" class="icon32"><br /></div>
606
  <h2><?php _e('Piwik Statistics', 'wp-piwik'); ?></h2>
662
  if (!self::$bolWPMU) {
663
  self::$aryGlobalSettings['add_tracking_code'] = (isset($_POST['wp-piwik_addjs'])?$_POST['wp-piwik_addjs']:'');
664
  self::$aryGlobalSettings['dashboard_widget'] = (isset($_POST['wp-piwik_dbwidget'])?$_POST['wp-piwik_dbwidget']:false);
665
+ self::$aryGlobalSettings['dashboard_chart'] = (isset($_POST['wp-piwik_dbchart'])?$_POST['wp-piwik_dbchart']:false);
666
  self::$aryGlobalSettings['piwik_shortcut'] = (isset($_POST['wp-piwik_piwiklink'])?$_POST['wp-piwik_piwiklink']:false);
667
  self::$arySettings['site_id'] = (isset($_POST['wp-piwik_siteid'])?$_POST['wp-piwik_siteid']:NULL);
668
  self::$arySettings['track_404'] = (isset($_POST['wp-piwik_404'])?$_POST['wp-piwik_404']:false);
759
  <div class="inside">
760
  <?php /************************************************************************/
761
  echo '<h4><label for="wp-piwik_jscode">JavaScript:</label></h4>'.
762
+ '<div class="input-text-wrap"><textarea id="wp-piwik_jscode" name="wp-piwik_jscode" readonly="readonly" rows="13" cols="55">'.
763
  htmlentities($strJavaScript).'</textarea></div>';
764
  echo '<h4><label for="wp-piwik_addjs">'.__('Add script', 'wp-piwik').':</label></h4>'.
765
  '<div class="input-wrap"><input type="checkbox" value="1" id="wp-piwik_addjs" name="wp-piwik_addjs" '.
794
  <h3 class='hndle'><span><?php _e('Statistic view settings', 'wp-piwik'); ?></span></h3>
795
  <div class="inside">
796
  <?php
797
+ echo '<h4><label for="wp-piwik_dbwidget">'.__('Dashboard data', 'wp-piwik').':</label></h4>'.
798
  '<div class="input-wrap"><select id="wp-piwik_dbwidget" name="wp-piwik_dbwidget">'.
799
  '<option value="0"'.(!$intDashboardWidget?' selected="selected"':'').'>'.__('No', 'wp-piwik').'</option>'.
800
  '<option value="yesterday"'.($intDashboardWidget == 'yesterday'?' selected="selected"':'').'>'.__('Yes','wp-piwik').' ('.__('yesterday', 'wp-piwik').').</option>'.
802
  '<option value="last30"'.($intDashboardWidget == 'last30'?' selected="selected"':'').'>'.__('Yes','wp-piwik').' ('.__('last 30 days','wp-piwik').').</option>'.
803
  '</select></div>';
804
  echo '<div class="wp-piwik_desc">'.
805
+ __('Display an overview widget to your WordPress dashboard.', 'wp-piwik').'</div>';
806
+
807
+ echo '<h4><label for="wp-piwik_dbwidget">'.__('Boad chart', 'wp-piwik').':</label></h4>'.
808
+ '<div class="input-wrap"><input type="checkbox" value="1" name="wp-piwik_dbchart" id="wp-piwik_dbchart" '.
809
+ (self::$aryGlobalSettings['dashboard_chart']?' checked="checked"':"").'/></div>';
810
+ echo '<div class="wp-piwik_desc">'.
811
+ __('Display a visitor graph widget to your WordPress dashboard.', 'wp-piwik').'</div>';
812
+
813
  echo '<h4><label for="wp-piwik_piwiklink">'.__('Shortcut', 'wp-piwik').':</label></h4>'.
814
  '<div class="input-wrap"><input type="checkbox" value="1" name="wp-piwik_piwiklink" id="wp-piwik_piwiklink" '.
815
  ($intShowLink?' checked="checked"':"").'/></div>';
967
  if (class_exists('wp_piwik'))
968
  $GLOBALS['wp_piwik'] = new wp_piwik();
969
 
970
+ /* EOF */