WP-Matomo (WP-Piwik) - Version 0.3.1

Version Description

Download this release

Release Info

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

Code changes from version 0.3.0 to 0.3.1

css/wp-piwik.css CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  span.wp-piwik-details {
2
  font-size:0.8em;
3
  font-weight:normal;
1
+ div.wp-piwik-sortables {
2
+ margin:0 5px;
3
+ }
4
+
5
  span.wp-piwik-details {
6
  font-size:0.8em;
7
  font-weight:normal;
dashboard/browsers.php CHANGED
@@ -1,48 +1,61 @@
1
  <?php
2
- $aryConf['data'] = $this->call_API(
3
- 'UserSettings.getBrowser',
 
 
 
 
4
  $aryConf['params']['period'],
5
  $aryConf['params']['date'],
6
- $aryConf['params']['limit']
7
- );
8
- $aryConf['title'] = __('Browser', 'wp-piwik');
9
- include('header.php');
10
- $strValues = $strLabels = '';
11
-
12
- $intSum = 0;
13
- foreach ($aryConf['data'] as $aryValues)
14
- $intSum += $aryValues['nb_uniq_visitors'];
15
-
16
- foreach ($aryConf['data'] as $aryValues) {
17
- $strValues .= round(($aryValues['nb_uniq_visitors']/$intSum*100), 2).',';
18
- $strLabels .= '|'.urlencode($aryValues['shortLabel']);
19
- }
20
-
21
- $strValues = substr($strValues, 0, -1);
22
- $strLabels = substr($strLabels, 1);
23
-
24
- $strBase = 'http://chart.apis.google.com/chart?';
25
- $strGraph = 'cht=p&amp;';
26
- $strGraph .= 'chs=500x220&amp;';
27
- $strGraph .= 'chd=t:'.$strValues.'&amp;';
28
- $strGraph .= 'chl='.$strLabels.'&amp;';
29
- $strGraph .= '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><th><?php _e('Browser', 'wp-piwik'); ?></th><th class="n"><?php _e('Unique', 'wp-piwik'); ?></th><th class="n"><?php _e('Percent', 'wp-piwik'); ?></tr>
38
- </thead>
39
- <tbody>
40
- <?php
41
- foreach ($aryConf['data'] as $aryValues)
42
- echo '<tr><td>'.$aryValues['shortLabel'].'</td><td class="n">'.$aryValues['nb_uniq_visitors'].'</td><td class="n">'.number_format(($aryValues['nb_uniq_visitors']*$intSum/100),2).'%</td></tr>';
43
- unset($aryTmp);
44
- ?>
45
- </tbody>
46
- </table>
 
 
 
 
 
 
 
 
 
 
47
  </div>
48
- <?php include ('footer.php');
 
 
 
1
  <?php
2
+ /*********************************
3
+ WP-Piwik::Stats:Browser
4
+ **********************************/
5
+
6
+ $aryConf['data'] = $this->call_API(
7
+ 'UserSettings.getBrowser',
8
  $aryConf['params']['period'],
9
  $aryConf['params']['date'],
10
+ $aryConf['params']['limit']
11
+ );
12
+ $aryConf['title'] = __('Browser', '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['shortLabel']);
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('Browser', '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['shortLabel'].
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/footer.php CHANGED
@@ -1,2 +1,7 @@
1
- </div>
 
 
 
 
 
2
  </div>
1
+ <?php
2
+ /*********************************
3
+ WP-Piwik::Stats:Footer
4
+ **********************************/
5
+ ?>
6
+ </div>
7
  </div>
dashboard/header.php CHANGED
@@ -1,3 +1,15 @@
 
 
 
 
 
1
  <div id="<?php echo $aryConf['id']; ?>" class="postbox <?php echo ($aryConf['closed']?'if-js-closed':''); ?>" >
2
- <div class="handlediv" title="Zum Umschalten klicken"><br /></div><h3 class='hndle'><span><?php echo $aryConf['title']; echo ' <span class="wp-piwik-details">('.$aryConf['desc'].')</span>'; ?></span></h3>
3
- <div class="inside">
 
 
 
 
 
 
 
1
+ <?php
2
+ /*********************************
3
+ WP-Piwik::Stats:Header
4
+ **********************************/
5
+ ?>
6
  <div id="<?php echo $aryConf['id']; ?>" class="postbox <?php echo ($aryConf['closed']?'if-js-closed':''); ?>" >
7
+ <div class="handlediv" title="Zum Umschalten klicken">
8
+ <br />
9
+ </div>
10
+ <h3 class='hndle'>
11
+ <span>
12
+ <?php echo $aryConf['title']; echo ' <span class="wp-piwik-details">('.$aryConf['desc'].')</span>'; ?>
13
+ </span>
14
+ </h3>
15
+ <div class="inside">
dashboard/keywords.php CHANGED
@@ -1,22 +1,29 @@
1
  <?php
2
- $aryConf['data'] = $this->call_API(
3
- 'Referers.getKeywords',
4
- $aryConf['params']['period'],
5
- $aryConf['params']['date'],
6
- $aryConf['params']['limit']
7
- );
8
- $aryConf['title'] = __('Keywords', 'wp-piwik');
9
- include('header.php');
10
- ?>
 
 
 
 
11
  <table class="widefat">
12
- <thead>
13
- <tr><th><?php _e('Keyword', 'wp-piwik'); ?></th><th><?php _e('Unique', 'wp-piwik'); ?></th></tr>
14
- </thead>
15
- <tbody>
16
- <?php
17
- foreach ($aryConf['data'] as $aryValues)
18
- echo '<tr><td>'.$aryValues['label'].'</td><td>'.$aryValues['nb_uniq_visitors'].'</td></tr>';
19
- ?>
20
- </tbody>
21
  </table>
22
- <?php include('footer.php'); ?>
 
 
 
1
  <?php
2
+ /*********************************
3
+ WP-Piwik::Stats:Keywords
4
+ **********************************/
5
+
6
+ $aryConf['data'] = $this->call_API(
7
+ 'Referers.getKeywords',
8
+ $aryConf['params']['period'],
9
+ $aryConf['params']['date'],
10
+ $aryConf['params']['limit']
11
+ );
12
+ $aryConf['title'] = __('Keywords', 'wp-piwik');
13
+ include('header.php');
14
+ /***************************************************************************/ ?>
15
  <table class="widefat">
16
+ <thead>
17
+ <tr><th><?php _e('Keyword', 'wp-piwik'); ?></th><th><?php _e('Unique', 'wp-piwik'); ?></th></tr>
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>
26
+ <?php /************************************************************************/
27
+ include ('footer.php');
28
+
29
+ /* EOF */
dashboard/overview.php CHANGED
@@ -1,24 +1,36 @@
1
  <?php
2
- $aryConf['data'] = $this->call_API(
3
- 'VisitsSummary.get',
4
- $aryConf['params']['period'],
5
- $aryConf['params']['date'],
6
- $aryConf['params']['limit']
7
- );
8
- $aryConf['title'] = __('Overview', 'wp-piwik');
9
- include('header.php');
10
- ?>
 
 
 
 
11
  <div class="table">
12
- <table class="widefat">
13
- <tbody>
14
- <?php
15
- $strTime = floor($aryConf['data']['sum_visit_length']/3600).'h '.floor(($aryConf['data']['sum_visit_length'] % 3600)/60).'m '.floor(($aryConf['data']['sum_visit_length'] % 3600) % 60).'s';
16
- echo '<tr><td>'.__('Visitors', 'wp-piwik').':</td><td>'.$aryConf['data']['nb_visits'].'</td></tr>';
17
- echo '<tr><td>'.__('Unique visitors', 'wp-piwik').':</td><td>'.$aryConf['data']['nb_uniq_visitors'].'</td></tr>';
18
- echo '<tr><td>'.__('Page views', 'wp-piwik').':</td><td>'.$aryConf['data']['nb_actions'].'</td></tr>';
19
- echo '<tr><td>'.__('Max. page views in one visit', 'wp-piwik').':</td><td>'.$aryConf['data']['max_actions'].'</td></tr>';
20
- echo '<tr><td>'.__('Total time spent by visitors', 'wp-piwik').':</td><td>'.$strTime.'</td></tr>';
21
- echo '<tr><td>'.__('Bounce count', 'wp-piwik').':</td><td>'.$aryConf['data']['bounce_count'].'</td></tr>';
22
- echo '</tbody></table>';
23
- ?></div>
24
- <?php include('footer.php');
 
 
 
 
 
 
 
 
1
  <?php
2
+ /*********************************
3
+ WP-Piwik::Stats:Overview
4
+ **********************************/
5
+
6
+ $aryConf['data'] = $this->call_API(
7
+ 'VisitsSummary.get',
8
+ $aryConf['params']['period'],
9
+ $aryConf['params']['date'],
10
+ $aryConf['params']['limit']
11
+ );
12
+ $aryConf['title'] = __('Overview', 'wp-piwik');
13
+ include('header.php');
14
+ /***************************************************************************/ ?>
15
  <div class="table">
16
+ <table class="widefat">
17
+ <tbody>
18
+ <?php /************************************************************************/
19
+ $strTime =
20
+ floor($aryConf['data']['sum_visit_length']/3600).'h '.
21
+ floor(($aryConf['data']['sum_visit_length'] % 3600)/60).'m '.
22
+ floor(($aryConf['data']['sum_visit_length'] % 3600) % 60).'s';
23
+ echo '<tr><td>'.__('Visitors', 'wp-piwik').':</td><td>'.$aryConf['data']['nb_visits'].'</td></tr>';
24
+ echo '<tr><td>'.__('Unique visitors', 'wp-piwik').':</td><td>'.$aryConf['data']['nb_uniq_visitors'].'</td></tr>';
25
+ echo '<tr><td>'.__('Page views', 'wp-piwik').':</td><td>'.$aryConf['data']['nb_actions'].'</td></tr>';
26
+ echo '<tr><td>'.__('Max. page views in one visit', 'wp-piwik').':</td><td>'.$aryConf['data']['max_actions'].'</td></tr>';
27
+ echo '<tr><td>'.__('Total time spent by visitors', 'wp-piwik').':</td><td>'.$strTime.'</td></tr>';
28
+ echo '<tr><td>'.__('Bounce count', 'wp-piwik').':</td><td>'.$aryConf['data']['bounce_count'].'</td></tr>';
29
+ /***************************************************************************/ ?>
30
+ </tbody>
31
+ </table>
32
+ </div>
33
+ <?php /************************************************************************/
34
+ include ('footer.php');
35
+
36
+ /* EOF */
dashboard/visitors.php CHANGED
@@ -1,68 +1,82 @@
1
  <?php
2
- $aryConf['data']['Visitors'] = $this->call_API(
3
- 'VisitsSummary.getVisits',
4
- $aryConf['params']['period'],
5
- $aryConf['params']['date'],
6
- $aryConf['params']['limit']
7
- );
8
- $aryConf['data']['Unique'] = $this->call_API(
9
- 'VisitsSummary.getUniqueVisitors',
10
- $aryConf['params']['period'],
11
- $aryConf['params']['date'],
12
- $aryConf['params']['limit']
13
- );
14
- $aryConf['data']['Bounced'] = $this->call_API(
15
- 'VisitsSummary.getBounceCount',
16
- $aryConf['params']['period'],
17
- $aryConf['params']['date'],
18
- $aryConf['params']['limit']
19
- );
20
 
21
- $aryConf['title'] = __('Visitors', 'wp-piwik');
22
- include('header.php');
23
- $strValues = $strLabels = $strBounced = $strValuesU = '';
24
- $intMax = max($aryConf['data']['Visitors']);
25
- while ($intMax % 10 != 0 || $intMax == 0) $intMax++;
26
- $intStep = $intMax / 5;
27
- while ($intStep % 10 != 0 && $intStep != 1) $intStep--;
28
-
29
- foreach ($aryConf['data']['Visitors'] as $strDate => $intValue) {
30
- $strValues .= round($intValue/($intMax/100),2).',';
31
- $strValuesU .= round($aryConf['data']['Unique'][$strDate]/($intMax/100),2).',';
32
- $strBounced .= round($aryConf['data']['Bounced'][$strDate]/($intMax/100),2).',';
33
- $strLabels .= '|'.substr($strDate,-2);
34
- }
35
- $strValues = substr($strValues, 0, -1);
36
- $strValuesU = substr($strValuesU, 0, -1);
37
- $strBounced = substr($strBounced, 0, -1);
38
-
39
- $strBase = 'http://chart.apis.google.com/chart?';
40
- $strGraph = 'cht=lc&amp;';
41
- $strGraph .= 'chg=0,'.round($intStep/($intMax/100),2).',2,2&amp;';
42
- $strGraph .= 'chs=500x220&amp;';
43
- $strGraph .= 'chd=t:'.$strValues.'|'.$strValuesU.'|'.$strBounced.'&amp;';
44
- $strGraph .= 'chxl=0:'.$strLabels.'&amp;';
45
- $strGraph .= 'chco=90AAD9,A0BAE9,E9A0BA&amp;';
46
- $strGraph .= 'chm=B,D4E2ED,0,1,0|B,E4F2FD,1,2,0|B,FDE4F2,2,3,0&amp;';
47
- $strGraph .= 'chxt=x,y&amp;';
48
- $strGraph .= 'chxr=1,0,'.$intMax.','.$intStep;
49
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  <div class="wp-piwik-graph-wide">
51
- <img src="<?php echo $strBase.$strGraph; ?>" width="500" height="220" alt="Visits graph" />
52
  </div>
53
  <div class="table">
54
- <table class="widefat wp-piwik-table">
55
- <thead>
56
- <tr><th><?php _e('Date', 'wp-piwik'); ?></th><th class="n"><?php _e('Visits', 'wp-piwik'); ?></th><th class="n"><?php _e('Unique', 'wp-piwik'); ?></th><th class="n"><?php _e('Bounced', 'wp-piwik'); ?></tr>
57
- </thead>
58
- <tbody>
59
- <?php
60
- $aryTmp = array_reverse($aryConf['data']['Visitors']);
61
- foreach ($aryTmp as $strDate => $intValue)
62
- echo '<tr><td>'.$strDate.'</td><td class="n">'.$intValue.'</td><td class="n">'.$aryConf['data']['Unique'][$strDate].'</td><td class="n">'.$aryConf['data']['Bounced'][$strDate].'</td></tr>';
63
- unset($aryTmp);
64
- ?>
65
- </tbody>
66
- </table>
 
 
 
 
 
 
 
 
 
 
67
  </div>
68
- <?php include ('footer.php');
 
 
 
1
  <?php
2
+ /*********************************
3
+ WP-Piwik::Stats:Vistors
4
+ **********************************/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
+ $aryConf['data']['Visitors'] = $this->call_API(
7
+ 'VisitsSummary.getVisits',
8
+ $aryConf['params']['period'],
9
+ $aryConf['params']['date'],
10
+ $aryConf['params']['limit']
11
+ );
12
+ $aryConf['data']['Unique'] = $this->call_API(
13
+ 'VisitsSummary.getUniqueVisitors',
14
+ $aryConf['params']['period'],
15
+ $aryConf['params']['date'],
16
+ $aryConf['params']['limit']
17
+ );
18
+ $aryConf['data']['Bounced'] = $this->call_API(
19
+ 'VisitsSummary.getBounceCount',
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 = '';
27
+ $intMax = max($aryConf['data']['Visitors']);
28
+ while ($intMax % 10 != 0 || $intMax == 0) $intMax++;
29
+ $intStep = $intMax / 5;
30
+ while ($intStep % 10 != 0 && $intStep != 1) $intStep--;
31
+ foreach ($aryConf['data']['Visitors'] as $strDate => $intValue) {
32
+ $strValues .= round($intValue/($intMax/100),2).',';
33
+ $strValuesU .= round($aryConf['data']['Unique'][$strDate]/($intMax/100),2).',';
34
+ $strBounced .= round($aryConf['data']['Bounced'][$strDate]/($intMax/100),2).',';
35
+ $strLabels .= '|'.substr($strDate,-2);
36
+ }
37
+ $strValues = substr($strValues, 0, -1);
38
+ $strValuesU = substr($strValuesU, 0, -1);
39
+ $strBounced = substr($strBounced, 0, -1);
40
+ $strBase = 'http://chart.apis.google.com/chart?';
41
+ $strGraph = 'cht=lc&amp;'.
42
+ 'chg=0,'.round($intStep/($intMax/100),2).',2,2&amp;'.
43
+ 'chs=500x220&amp;'.
44
+ 'chd=t:'.$strValues.'|'.$strValuesU.'|'.$strBounced.'&amp;'.
45
+ 'chxl=0:'.$strLabels.'&amp;'.
46
+ 'chco=90AAD9,A0BAE9,E9A0BA&amp;'.
47
+ 'chm=B,D4E2ED,0,1,0|B,E4F2FD,1,2,0|B,FDE4F2,2,3,0&amp;'.
48
+ 'chxt=x,y&amp;'.
49
+ 'chxr=1,0,'.$intMax.','.$intStep;
50
+ /***************************************************************************/ ?>
51
  <div class="wp-piwik-graph-wide">
52
+ <img src="<?php echo $strBase.$strGraph; ?>" width="500" height="220" alt="Visits graph" />
53
  </div>
54
  <div class="table">
55
+ <table class="widefat wp-piwik-table">
56
+ <thead>
57
+ <tr>
58
+ <th><?php _e('Date', 'wp-piwik'); ?></th>
59
+ <th class="n"><?php _e('Visits', 'wp-piwik'); ?></th>
60
+ <th class="n"><?php _e('Unique', 'wp-piwik'); ?></th>
61
+ <th class="n"><?php _e('Bounced', 'wp-piwik'); ?></th>
62
+ </tr>
63
+ </thead>
64
+ <tbody>
65
+ <?php /************************************************************************/
66
+ $aryTmp = array_reverse($aryConf['data']['Visitors']);
67
+ foreach ($aryTmp as $strDate => $intValue)
68
+ echo '<tr><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>';
74
+ unset($aryTmp);
75
+ /***************************************************************************/ ?>
76
+ </tbody>
77
+ </table>
78
  </div>
79
+ <?php /************************************************************************/
80
+ include ('footer.php');
81
+
82
+ /* EOF */
dashboard/websites.php CHANGED
@@ -1,22 +1,32 @@
1
  <?php
2
- $aryConf['data'] = $this->call_API(
3
- 'Referers.getWebsites',
4
- $aryConf['params']['period'],
5
- $aryConf['params']['date'],
6
- $aryConf['params']['limit']
7
- );
8
- $aryConf['title'] = __('Websites', 'wp-piwik');
9
- include('header.php');
10
- ?>
 
 
 
 
11
  <table class="widefat">
12
- <thead>
13
- <tr><th><?php _e('Website', 'wp-piwik'); ?></th><th><?php _e('Unique', 'wp-piwik'); ?></th></tr>
14
- </thead>
15
- <tbody>
16
- <?php
17
- foreach ($aryConf['data'] as $aryValues)
18
- echo '<tr><td>'.$aryValues['label'].'</td><td>'.$aryValues['nb_uniq_visitors'].'</td></tr>';
19
- ?>
20
- </tbody>
 
 
 
21
  </table>
22
- <?php include('footer.php'); ?>
 
 
 
1
  <?php
2
+ /*********************************
3
+ WP-Piwik::Stats:Websites
4
+ **********************************/
5
+
6
+ $aryConf['data'] = $this->call_API(
7
+ 'Referers.getWebsites',
8
+ $aryConf['params']['period'],
9
+ $aryConf['params']['date'],
10
+ $aryConf['params']['limit']
11
+ );
12
+ $aryConf['title'] = __('Websites', 'wp-piwik');
13
+ include('header.php');
14
+ /***************************************************************************/ ?>
15
  <table class="widefat">
16
+ <thead>
17
+ <tr>
18
+ <th><?php _e('Website', 'wp-piwik'); ?></th>
19
+ <th><?php _e('Unique', 'wp-piwik'); ?></th>
20
+ </tr>
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>
29
+ <?php /************************************************************************/
30
+ include ('footer.php');
31
+
32
+ /* EOF */
js/wp-piwik.js CHANGED
@@ -1,7 +1,5 @@
1
-
2
  jQuery( function($) {
3
-
4
- // close postboxes that should be closed
5
- jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
6
- postboxes.add_postbox_toggles('wppiwik');
7
  } );
 
1
  jQuery( function($) {
2
+ // close postboxes that should be closed
3
+ jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
4
+ postboxes.add_postbox_toggles('wppiwik');
 
5
  } );
readme.txt CHANGED
@@ -1,9 +1,8 @@
1
  === WP-Piwik ===
2
  Contributors: braekling
3
  Requires at least: 2.7
4
- Tested up to: 2.7.1
5
- Stable tag: 0.3.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
 
9
  This plugin adds a piwik stats site to your WordPress dashboard.
@@ -18,6 +17,7 @@ Look at the [Piwik website](http://piwik.org/) to get further information about
18
  *This plugin is not created or provided by the Piwik project team.*
19
 
20
  License: GNU General Public License Version 3, 29 June 2007
 
21
  Languages: English, German
22
 
23
  == Installation ==
1
  === WP-Piwik ===
2
  Contributors: braekling
3
  Requires at least: 2.7
4
+ Tested up to: 2.8
5
+ Stable tag: 0.3.1
 
6
  Tags: statistics, stats, analytics, piwik
7
 
8
  This plugin adds a piwik stats site to your WordPress dashboard.
17
  *This plugin is not created or provided by the Piwik project team.*
18
 
19
  License: GNU General Public License Version 3, 29 June 2007
20
+
21
  Languages: English, German
22
 
23
  == Installation ==
screenshot-1.gif CHANGED
Binary file
wp-piwik.php CHANGED
@@ -6,45 +6,44 @@ 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.0
10
  Author: Andr&eacute; Br&auml;kling
11
  Author URI: http://www.braekling.de
12
 
13
  ******************************************************************************************
14
- Copyright (C) 2009 Andre Braekling (email: webmaster@braekling.de)
15
 
16
- This program is free software: you can redistribute it and/or modify
17
- it under the terms of the GNU General Public License as published by
18
- the Free Software Foundation, either version 3 of the License, or
19
- (at your option) any later version.
20
 
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
 
26
- You should have received a copy of the GNU General Public License
27
- along with this program. If not, see <http://www.gnu.org/licenses/>.
28
  *******************************************************************************************/
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';
36
- load_textdomain('wp-piwik', $strMOfile);
37
- }
38
-
39
  register_activation_hook(__FILE__, array($this, 'install'));
40
  add_action('admin_menu', array($this, 'build_menu'));
41
- add_filter('plugin_row_meta', array($this, 'set_plugin_meta', 10, 2));
42
  if (get_option('wp-piwik_addjs') == 1)
43
  add_action('wp_footer', array($this, 'footer'));
44
  }
45
-
46
  function install() {
47
-
48
  }
49
 
50
  function footer() {
@@ -52,22 +51,43 @@ class wp_piwik {
52
  }
53
 
54
  function build_menu() {
55
- $intPage = add_dashboard_page(__('Piwik Statistics', 'wp-piwik'), __('WP-Piwik', 'wp-piwik'), 8, __FILE__, array($this, 'show_stats'));
56
- add_action('admin_print_scripts-'.$intPage, array($this, 'load_scripts'));
57
- add_action('admin_head-'.$intPage, array($this, 'add_admin_header'));
 
 
 
 
 
 
58
 
59
- add_options_page(__('WP-Piwik Settings', 'wp-piwik'), __('WP-Piwik Settings', 'wp-piwik'), 8, __FILE__, array($this, 'show_settings'));
 
 
 
 
 
 
60
  }
61
 
62
- function set_plugin_meta($strLinks, $strFile) {
63
  $strPlugin = plugin_basename(__FILE__);
64
  if ($strFile == $strPlugin)
65
- return array_merge($strLinks, array( sprintf( '<a href="options-general.php?page=%s">%s</a>', $strPlugin, __('Settings', 'wp-piwik') ) ));
 
 
 
 
 
66
  return $strLinks;
67
  }
68
-
69
  function load_scripts() {
70
- wp_enqueue_script('wp-piwik', $this->get_plugin_url().'js/wp-piwik.js', array( 'jquery', 'admin-comments', 'postbox' ));
 
 
 
 
71
  }
72
 
73
  function add_admin_header() {
@@ -81,8 +101,8 @@ function set_plugin_meta($strLinks, $strFile) {
81
  function call_API($strMethod, $strPeriod='', $strDate='', $intLimit='') {
82
  $strKey = $strMethod.'_'.$strPeriod.'_'.$strDate.'_'.$intLimit;
83
  if (empty($this->aryCache[$strKey])) {
84
- $strToken = get_option('wp-piwik_token');
85
- $strURL = get_option('wp-piwik_url');
86
  $intSite = get_option('wp-piwik_siteid');
87
  if (empty($strToken) || empty($strURL)) {
88
  $this->aryCache[$key] = array(
@@ -91,47 +111,43 @@ function set_plugin_meta($strLinks, $strFile) {
91
  );
92
  return $this->aryCache[$strKey];
93
  }
94
- if (substr($strURL, -1, 1) != '/') $strURL .= '/';
95
- $strURL .= '?module=API&method='.$strMethod;
96
- $strURL .= '&idSite='.$intSite.'&period='.$strPeriod.'&date='.$strDate;
97
- $strURL .= '&format=PHP&filter_limit='.$intLimit;
98
- $strURL .= '&token_auth='.$strToken;
99
- $strResult = file_get_contents($strURL);
100
- $this->aryCache[$strKey] = unserialize($strResult);
101
  }
102
  return $this->aryCache[$strKey];
103
  }
104
 
105
  function create_dashboard_widget($strFile, $aryConfig) {
106
- foreach ($aryConfig['params'] as $strParam) {
107
  if (!empty($strParam)) {
108
  $strDesc .= $strParam.', ';
109
- $strID .= '_'.$strParam;
110
  }
111
- }
112
  $strFile = str_replace('.', '', $strFile);
113
-
114
- $aryConf = array_merge($aryConfig, array(
115
- 'id' => $strFile.$strID,
116
- 'desc' => substr($strDesc, 0, -2)));
117
  $strRoot = dirname(__FILE__);
118
  if (file_exists($strRoot.DIRECTORY_SEPARATOR.'dashboard/'.$strFile.'.php'))
119
- include($strRoot.DIRECTORY_SEPARATOR.'dashboard/'.$strFile.'.php');
120
  }
121
 
122
  function show_stats() {
123
  $arySortOrder = get_user_option('meta-box-order_wppiwik');
124
  $aryClosed = get_user_option('closedpostboxes_wppiwik');
125
  if (empty($aryClosed)) $aryClosed = array();
126
-
127
  $aryDashboard = array();
128
  if (!$arySortOrder) {
129
  // Set default configuration
130
  $arySortOrder = array(
131
  'side' => 'overview_day_yesterday,keywords_day_yesterday_10,websites_day_yesterday_10',
132
  'normal' => 'visitors_day_last30,browsers_day_yesterday'
133
- );
134
-
135
  update_user_option($GLOBALS['current_user']->ID, 'meta-box-order_wppiwik', $arySortOrder);
136
  }
137
  foreach ($arySortOrder as $strCol => $strWidgets) {
@@ -148,99 +164,121 @@ function set_plugin_meta($strLinks, $strFile) {
148
  );
149
  }
150
  }
151
- ?>
152
- <div class="wrap"><div id="icon-post" class="icon32"><br /></div>
153
- <h2><?php _e('Piwik Statistics', 'wp-piwik'); ?></h2>
154
- <div id="wppiwik-widgets-wrap">
155
- <div id="wppiwik-widgets" class="metabox-holder">
156
- <div id="side-info-column" class="inner-sidebar wp-piwik-side">
157
- <div id="side-sortables" class="meta-box-sortables">
158
- <?php
159
- foreach ($aryDashboard['side'] as $strFile => $aryConfig)
160
- $this->create_dashboard_widget($strFile, $aryConfig);
161
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  </div>
163
  </div>
164
- <div id='post-body' class="has-sidebar">
165
- <div id='wppiwik-widgets-main-content' class='has-sidebar-content'>
166
- <div id='normal-sortables' class='meta-box-sortables'>
167
- <?php
168
- foreach ($aryDashboard['normal'] as $strFile => $aryConfig)
169
- $this->create_dashboard_widget($strFile, $aryConfig);
170
- wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
171
- wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
172
- ?>
173
-
174
- <div class="clear"></div>
175
- </div><!-- wppiwik-widgets-wrap -->
176
-
177
- </div>
178
- </div>
179
- </div>
180
- </div>
181
- </div>
182
- <?php
183
  }
184
 
185
  function show_settings() {
186
  $strToken = get_option('wp-piwik_token');
187
  $strURL = get_option('wp-piwik_url');
188
  $intSite = get_option('wp-piwik_siteid');
189
- ?>
190
  <div class="wrap">
191
- <h2><?php _e('WP-Piwik Settings', 'wp-piwik') ?></h2>
192
- <div class="inside">
193
- <form method="post" action="options.php">
194
- <?php wp_nonce_field('update-options'); ?>
195
- <table class="form-table">
196
- <tr><td colspan="2"><h3><?php _e('Account settings', 'wp-piwik'); ?></h3></td></tr>
197
- <tr>
198
- <td><?php _e('Piwik URL', 'wp-piwik'); ?>:</td>
199
- <td><input type="text" name="wp-piwik_url" id="wp-piwik_url" value="<?php echo $strURL; ?>" /></td>
200
- </tr>
201
- <tr>
202
- <td><?php _e('Auth token', 'wp-piwik'); ?>:</td>
203
- <td><input type="text" name="wp-piwik_token" id="wp-piwik_token" value="<?php echo $strToken; ?>" /></td>
204
- </tr>
205
-
206
- <tr><td colspan="2"><span class="setting-description"><?php _e('To enable Piwik statistics, please enter your Piwik base URL (like http://mydomain.com/piwik) and your personal authentification token. You can get the token on the API page inside your Piwik interface. It looks like &quot;1234a5cd6789e0a12345b678cd9012ef&quot;.', 'wp-piwik'); ?></span></td></tr>
207
- <?php
 
 
 
 
 
 
 
 
208
  if (!empty($strToken) && !empty($strURL)) {
209
  $aryData = $this->call_API('SitesManager.getSitesWithAtLeastViewAccess');
210
  if (empty($aryData)) {
211
- echo '<tr><td colspan="2"><p><strong>'.__('An error occured', 'wp-piwik').': </strong>'.__('Please check URL and auth token. You need at least view access to one site.', 'wp-piwik').'</p></td></tr>';
 
 
212
  } elseif ($aryData['result'] == 'error') {
213
- echo '<tr><td colspan="2"><p><strong>'.__('An error occured', 'wp-piwik').': </strong>'.$aryData['message'].'</p></td></tr>';
214
- } else {
215
- echo '<tr><td>'.__('Choose site', 'wp-piwik').':</td><td><select name="wp-piwik_siteid" id="wp-piwik_siteid">';
216
- foreach ($aryData as $arySite) {
217
- echo '<option value="'.$arySite['idsite'].'"'.($arySite['idsite']==$intSite?' selected':'').'>'.htmlentities($arySite['name'], ENT_QUOTES, 'utf-8').'</option>';
218
- }
 
 
 
 
219
  echo '</select></td></tr>';
220
- if (empty($intSite)) update_option('wp-piwik_siteid', $aryData[0]['idsite']);
 
221
  $intSite = get_option('wp-piwik_siteid');
222
  $intAddJS = get_option('wp-piwik_addjs');
223
  $strJavaScript = $this->call_API('SitesManager.getJavascriptTag');
224
- if ($intAddJS) update_option('wp-piwik_jscode', $strJavaScript);
225
- echo '<tr><td>JavaScript:</td><td><textarea readonly rows="17" cols="80">'.($strJavaScript).'</textarea></td></tr>';
226
- echo '<tr><td>'.__('Add script to wp_footer()', 'wp-piwik').':</td><td><input type="checkbox" value="1" name="wp-piwik_addjs" '.($intAddJS?' checked':'').'/></td></tr>';
227
- echo '<tr><td colspan="2"><span class="setting-description">'.__('If your template uses wp_footer(), WP-Piwik can automatically add the Piwik javascript code to your blog.', 'wp-piwik').'</span></td></tr>';
 
 
 
 
 
 
 
228
  }
229
- }
230
- ?>
231
- </table>
232
- <input type="hidden" name="action" value="update" />
233
- <input type="hidden" name="page_options" value="wp-piwik_token,wp-piwik_url,wp-piwik_siteid,wp-piwik_addjs" />
234
- <p class="submit">
235
- <input type="submit" name="Submit" value="<?php _e('Save settings', 'wp-piwik') ?>" />
236
- </p>
237
- </form>
238
- </div>
239
  </div>
240
- <?php
241
  }
242
  }
243
 
244
- if (class_exists('wp_piwik')) {
245
  $GLOBALS['wp_piwik'] = new wp_piwik();
246
- }
 
6
 
7
  Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress footer.
8
 
9
+ Version: 0.3.1
10
  Author: Andr&eacute; Br&auml;kling
11
  Author URI: http://www.braekling.de
12
 
13
  ******************************************************************************************
14
+ Copyright (C) 2009 Andre Braekling (email: webmaster@braekling.de)
15
 
16
+ This program is free software: you can redistribute it and/or modify
17
+ it under the terms of the GNU General Public License as published by
18
+ the Free Software Foundation, either version 3 of the License, or
19
+ at your option) any later version.
20
 
21
+ This program is distributed in the hope that it will be useful,
22
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
+ GNU General Public License for more details.
25
 
26
+ You should have received a copy of the GNU General Public License
27
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
28
  *******************************************************************************************/
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';
36
+ load_textdomain('wp-piwik', $strMOfile);
37
+ }
 
38
  register_activation_hook(__FILE__, array($this, 'install'));
39
  add_action('admin_menu', array($this, 'build_menu'));
40
+ add_filter('plugin_row_meta', array($this, 'set_plugin_meta'), 10, 2);
41
  if (get_option('wp-piwik_addjs') == 1)
42
  add_action('wp_footer', array($this, 'footer'));
43
  }
44
+
45
  function install() {
46
+ // not used
47
  }
48
 
49
  function footer() {
51
  }
52
 
53
  function build_menu() {
54
+ $intStatsPage = add_dashboard_page(
55
+ __('Piwik Statistics', 'wp-piwik'),
56
+ __('WP-Piwik', 'wp-piwik'),
57
+ 8,
58
+ __FILE__,
59
+ array($this, 'show_stats')
60
+ );
61
+ add_action('admin_print_scripts-'.$intStatsPage, array($this, 'load_scripts'));
62
+ add_action('admin_head-'.$intStatsPage, array($this, 'add_admin_header'));
63
 
64
+ add_options_page(
65
+ __('WP-Piwik', 'wp-piwik'),
66
+ __('WP-Piwik', 'wp-piwik'),
67
+ 8,
68
+ __FILE__,
69
+ array($this, 'show_settings')
70
+ );
71
  }
72
 
73
+ function set_plugin_meta($strLinks, $strFile) {
74
  $strPlugin = plugin_basename(__FILE__);
75
  if ($strFile == $strPlugin)
76
+ return array_merge(
77
+ $strLinks,
78
+ array(
79
+ sprintf('<a href="options-general.php?page=%s">%s</a>', $strPlugin, __('Settings', 'wp-piwik'))
80
+ )
81
+ );
82
  return $strLinks;
83
  }
84
+
85
  function load_scripts() {
86
+ wp_enqueue_script(
87
+ 'wp-piwik',
88
+ $this->get_plugin_url().'js/wp-piwik.js',
89
+ array('jquery', 'admin-comments', 'postbox')
90
+ );
91
  }
92
 
93
  function add_admin_header() {
101
  function call_API($strMethod, $strPeriod='', $strDate='', $intLimit='') {
102
  $strKey = $strMethod.'_'.$strPeriod.'_'.$strDate.'_'.$intLimit;
103
  if (empty($this->aryCache[$strKey])) {
104
+ $strToken = get_option('wp-piwik_token');
105
+ $strURL = get_option('wp-piwik_url');
106
  $intSite = get_option('wp-piwik_siteid');
107
  if (empty($strToken) || empty($strURL)) {
108
  $this->aryCache[$key] = array(
111
  );
112
  return $this->aryCache[$strKey];
113
  }
114
+ if (substr($strURL, -1, 1) != '/') $strURL .= '/';
115
+ $strURL .= '?module=API&method='.$strMethod;
116
+ $strURL .= '&idSite='.$intSite.'&period='.$strPeriod.'&date='.$strDate;
117
+ $strURL .= '&format=PHP&filter_limit='.$intLimit;
118
+ $strURL .= '&token_auth='.$strToken;
119
+ $strResult = file_get_contents($strURL);
120
+ $this->aryCache[$strKey] = unserialize($strResult);
121
  }
122
  return $this->aryCache[$strKey];
123
  }
124
 
125
  function create_dashboard_widget($strFile, $aryConfig) {
126
+ foreach ($aryConfig['params'] as $strParam)
127
  if (!empty($strParam)) {
128
  $strDesc .= $strParam.', ';
129
+ $strID .= '_'.$strParam;
130
  }
 
131
  $strFile = str_replace('.', '', $strFile);
132
+ $aryConf = array_merge($aryConfig, array(
133
+ 'id' => $strFile.$strID,
134
+ 'desc' => substr($strDesc, 0, -2)));
 
135
  $strRoot = dirname(__FILE__);
136
  if (file_exists($strRoot.DIRECTORY_SEPARATOR.'dashboard/'.$strFile.'.php'))
137
+ include($strRoot.DIRECTORY_SEPARATOR.'dashboard/'.$strFile.'.php');
138
  }
139
 
140
  function show_stats() {
141
  $arySortOrder = get_user_option('meta-box-order_wppiwik');
142
  $aryClosed = get_user_option('closedpostboxes_wppiwik');
143
  if (empty($aryClosed)) $aryClosed = array();
 
144
  $aryDashboard = array();
145
  if (!$arySortOrder) {
146
  // Set default configuration
147
  $arySortOrder = array(
148
  'side' => 'overview_day_yesterday,keywords_day_yesterday_10,websites_day_yesterday_10',
149
  'normal' => 'visitors_day_last30,browsers_day_yesterday'
150
+ );
 
151
  update_user_option($GLOBALS['current_user']->ID, 'meta-box-order_wppiwik', $arySortOrder);
152
  }
153
  foreach ($arySortOrder as $strCol => $strWidgets) {
164
  );
165
  }
166
  }
167
+ /***************************************************************************/ ?>
168
+ <div class="wrap">
169
+ <div id="icon-post" class="icon32"><br /></div>
170
+ <h2><?php _e('Piwik Statistics', 'wp-piwik'); ?></h2>
171
+ <div id="dashboard-widgets-wrap">
172
+ <div id="dashboard-widgets" class="metabox-holder">
173
+ <div id="postbox-container" class="wp-piwik-side" style="width:300px; float:left;">
174
+ <div id="side-sortables" class="meta-box-sortables ui-sortable wp-piwik-sortables">
175
+ <?php /************************************************************************/
176
+ foreach ($aryDashboard['side'] as $strFile => $aryConfig)
177
+ $this->create_dashboard_widget($strFile, $aryConfig);
178
+ /***************************************************************************/ ?>
179
+ </div>
180
+ </div>
181
+ <div id="postbox-container" class="" style="width:520px; float:left; ">
182
+ <div id="wppiwik-widgets-main-content" class="has-sidebar-content">
183
+ <div id="normal-sortables" class="meta-box-sortables ui-sortable wp-piwik-sortables">
184
+ <?php /************************************************************************/
185
+ foreach ($aryDashboard['normal'] as $strFile => $aryConfig)
186
+ $this->create_dashboard_widget($strFile, $aryConfig);
187
+ wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
188
+ wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
189
+ /***************************************************************************/ ?>
190
+ <div class="clear"></div>
191
+ </div>
192
+ </div>
193
+ </div>
194
+ </div>
195
  </div>
196
  </div>
197
+ <?php /************************************************************************/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  }
199
 
200
  function show_settings() {
201
  $strToken = get_option('wp-piwik_token');
202
  $strURL = get_option('wp-piwik_url');
203
  $intSite = get_option('wp-piwik_siteid');
204
+ /***************************************************************************/ ?>
205
  <div class="wrap">
206
+ <h2><?php _e('WP-Piwik Settings', 'wp-piwik') ?></h2>
207
+ <div class="inside">
208
+ <form method="post" action="options.php">
209
+ <?php wp_nonce_field('update-options'); ?>
210
+ <table class="form-table">
211
+ <tr><td colspan="2"><h3><?php _e('Account settings', 'wp-piwik'); ?></h3></td></tr>
212
+ <tr>
213
+ <td><?php _e('Piwik URL', 'wp-piwik'); ?>:</td>
214
+ <td><input type="text" name="wp-piwik_url" id="wp-piwik_url" value="<?php echo $strURL; ?>" /></td>
215
+ </tr>
216
+ <tr>
217
+ <td><?php _e('Auth token', 'wp-piwik'); ?>:</td>
218
+ <td><input type="text" name="wp-piwik_token" id="wp-piwik_token" value="<?php echo $strToken; ?>" /></td>
219
+ </tr>
220
+ <tr><td colspan="2"><span class="setting-description">
221
+ <?php _e(
222
+ 'To enable Piwik statistics, please enter your Piwik'.
223
+ ' base URL (like http://mydomain.com/piwik) and your'.
224
+ ' personal authentification token. You can get the token'.
225
+ ' on the API page inside your Piwik interface. It looks'.
226
+ ' like &quot;1234a5cd6789e0a12345b678cd9012ef&quot;.'
227
+ , 'wp-piwik'
228
+ ); ?>
229
+ </span></td></tr>
230
+ <?php /************************************************************************/
231
  if (!empty($strToken) && !empty($strURL)) {
232
  $aryData = $this->call_API('SitesManager.getSitesWithAtLeastViewAccess');
233
  if (empty($aryData)) {
234
+ echo '<tr><td colspan="2"><p><strong>'.__('An error occured', 'wp-piwik').': </strong>'.
235
+ __('Please check URL and auth token. You need at least view access to one site.', 'wp-piwik').
236
+ '</p></td></tr>';
237
  } elseif ($aryData['result'] == 'error') {
238
+ echo '<tr><td colspan="2"><p><strong>'.__('An error occured', 'wp-piwik').
239
+ ': </strong>'.$aryData['message'].'</p></td></tr>';
240
+ } else {
241
+ echo '<tr><td>'.__('Choose site', 'wp-piwik').
242
+ ':</td><td><select name="wp-piwik_siteid" id="wp-piwik_siteid">';
243
+ foreach ($aryData as $arySite)
244
+ echo '<option value="'.$arySite['idsite'].
245
+ '"'.($arySite['idsite']==$intSite?' selected':'').
246
+ '>'.htmlentities($arySite['name'], ENT_QUOTES, 'utf-8').
247
+ '</option>';
248
  echo '</select></td></tr>';
249
+ if (empty($intSite))
250
+ update_option('wp-piwik_siteid', $aryData[0]['idsite']);
251
  $intSite = get_option('wp-piwik_siteid');
252
  $intAddJS = get_option('wp-piwik_addjs');
253
  $strJavaScript = $this->call_API('SitesManager.getJavascriptTag');
254
+ if ($intAddJS)
255
+ update_option('wp-piwik_jscode', $strJavaScript);
256
+ echo '<tr><td>JavaScript:</td><td><textarea readonly rows="17" cols="80">'.
257
+ ($strJavaScript).'</textarea></td></tr>';
258
+ echo '<tr><td>'.__('Add script to wp_footer()', 'wp-piwik').
259
+ ':</td><td><input type="checkbox" value="1" name="wp-piwik_addjs" '.
260
+ ($intAddJS?' checked':'').'/></td></tr>';
261
+ echo '<tr><td colspan="2"><span class="setting-description">'.
262
+ __('If your template uses wp_footer(), WP-Piwik can automatically'.
263
+ ' add the Piwik javascript code to your blog.', 'wp-piwik').
264
+ '</span></td></tr>';
265
  }
266
+ }
267
+ /***************************************************************************/ ?>
268
+ </table>
269
+ <input type="hidden" name="action" value="update" />
270
+ <input type="hidden" name="page_options" value="wp-piwik_token,wp-piwik_url,wp-piwik_siteid,wp-piwik_addjs" />
271
+ <p class="submit">
272
+ <input type="submit" name="Submit" value="<?php _e('Save settings', 'wp-piwik') ?>" />
273
+ </p>
274
+ </form>
275
+ </div>
276
  </div>
277
+ <?php /************************************************************************/
278
  }
279
  }
280
 
281
+ if (class_exists('wp_piwik'))
282
  $GLOBALS['wp_piwik'] = new wp_piwik();
283
+
284
+ /* EOF */