Version Description
- Auto-configuration
- No code change required to enable WPMU mode anymore (Still experimental. Please create a backup before trying 0.9.0!)
- All features in WPMU available
- Bugfix: Removed unnecessary API calls done with each site request - Thank you, Martin B.!
- Bugfix: No stats on dashboard (sometimes this issue still occured, should be fixed now)
- Code cleanup (still not finished)
- Minor UI fixes
- Minor language/gettext improvements
- Security improvements
- Show SEO rank stats (very slow, caching will be added in 0.9.1)
- WordPress dashboard SEO rank widget (very slow, caching will be added in 0.9.1)
- New option: use js/index.php
- New option: avoid mod_security
- Mulisite: Order blog list alphabetically (Network Admin stats site)
- Settings: Order site list alphabetically (site list shown if order conf is disabled)
Download this release
Release Info
Developer | Braekling |
Plugin | WP-Matomo (WP-Piwik) |
Version | 0.9.0 |
Comparing to | |
See all releases |
Code changes from version 0.8.10 to 0.9.0
- css/wp-piwik.css +28 -15
- dashboard/browsers.php +5 -2
- dashboard/keywords.php +7 -2
- dashboard/overview.php +49 -47
- dashboard/pages.php +8 -2
- dashboard/plugins.php +10 -4
- dashboard/screens.php +5 -1
- dashboard/seo.php +36 -0
- dashboard/systems.php +5 -2
- dashboard/visitors.php +40 -35
- dashboard/websites.php +8 -2
- index.php +2 -0
- js/wp-piwik.js +2 -2
- languages/wp-piwik-de_DE.mo +0 -0
- languages/wp-piwik-de_DE.po +81 -5
- readme.txt +35 -20
- update/.htaccess +1 -0
- update/80403.php +47 -0
- update/80502.php +2 -0
- update/80602.php +2 -0
- update/80800.php +2 -0
- update/90001.php +12 -0
- wp-piwik.php +492 -397
css/wp-piwik.css
CHANGED
@@ -27,18 +27,27 @@ table.wp-piwik-table tr:hover {
|
|
27 |
background-color:#ccc;
|
28 |
}
|
29 |
div.wp-piwik-sidebox {
|
30 |
-
width:
|
31 |
-
padding:10px;
|
32 |
float:right;
|
33 |
-
border:1px solid black;
|
34 |
-
background:#ffc
|
35 |
}
|
|
|
36 |
div.wp-piwik-sidebox div {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
width:190px;
|
38 |
text-align:center;
|
39 |
-
border
|
|
|
40 |
padding:5px
|
41 |
}
|
|
|
42 |
div.wp-piwik-settings-container {
|
43 |
margin-right:250px;
|
44 |
max-width:1024px;
|
@@ -48,9 +57,9 @@ div.wp-piwik-settings h4 {
|
|
48 |
font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif !important;
|
49 |
font-size:12px !important;
|
50 |
font-weight:normal;
|
51 |
-
padding-top:
|
52 |
text-align:right;
|
53 |
-
width:
|
54 |
}
|
55 |
div.wp-piwik-settings h4 label {
|
56 |
margin-right:10px;
|
@@ -58,28 +67,32 @@ div.wp-piwik-settings h4 label {
|
|
58 |
}
|
59 |
div.wp-piwik-settings .input-text-wrap input,
|
60 |
div.wp-piwik-settings .input-text-wrap select,
|
61 |
-
div.wp-piwik-settings .input-text-wrap textarea
|
62 |
-
div.wp-piwik-settings .input-wrap input {
|
63 |
border:0 none;
|
64 |
color:#333333;
|
65 |
-
margin:0;
|
66 |
outline:medium none;
|
67 |
padding:0;
|
68 |
width:99%;
|
69 |
}
|
|
|
70 |
div.wp-piwik-settings .input-wrap {
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
73 |
}
|
74 |
|
75 |
div.wp-piwik-settings .input-text-wrap {
|
76 |
-
margin:0 0 1em
|
77 |
border:1px solid #CCCCCC;
|
78 |
-
padding:2px 3px;
|
79 |
}
|
|
|
80 |
div.wp-piwik_desc {
|
81 |
font-size:11px;
|
82 |
-
margin:0 0 10px
|
83 |
padding:0;
|
84 |
}
|
85 |
|
27 |
background-color:#ccc;
|
28 |
}
|
29 |
div.wp-piwik-sidebox {
|
30 |
+
width:220px;
|
|
|
31 |
float:right;
|
|
|
|
|
32 |
}
|
33 |
+
|
34 |
div.wp-piwik-sidebox div {
|
35 |
+
padding:10px;
|
36 |
+
border:1px solid black;
|
37 |
+
margin-bottom:10px;
|
38 |
+
}
|
39 |
+
|
40 |
+
div.wp-piwik-donate {background:#ffc}
|
41 |
+
div.wp-piwik-support {background:#eef}
|
42 |
+
|
43 |
+
div.wp-piwik-sidebox div div {
|
44 |
width:190px;
|
45 |
text-align:center;
|
46 |
+
border:solid black;
|
47 |
+
border-width:1px 0 0 0 ;
|
48 |
padding:5px
|
49 |
}
|
50 |
+
|
51 |
div.wp-piwik-settings-container {
|
52 |
margin-right:250px;
|
53 |
max-width:1024px;
|
57 |
font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif !important;
|
58 |
font-size:12px !important;
|
59 |
font-weight:normal;
|
60 |
+
padding-top:0px !important;
|
61 |
text-align:right;
|
62 |
+
width:160px;
|
63 |
}
|
64 |
div.wp-piwik-settings h4 label {
|
65 |
margin-right:10px;
|
67 |
}
|
68 |
div.wp-piwik-settings .input-text-wrap input,
|
69 |
div.wp-piwik-settings .input-text-wrap select,
|
70 |
+
div.wp-piwik-settings .input-text-wrap textarea {
|
|
|
71 |
border:0 none;
|
72 |
color:#333333;
|
|
|
73 |
outline:medium none;
|
74 |
padding:0;
|
75 |
width:99%;
|
76 |
}
|
77 |
+
|
78 |
div.wp-piwik-settings .input-wrap {
|
79 |
+
padding-top:0px;
|
80 |
+
}
|
81 |
+
|
82 |
+
div.wp-piwik-settings .input-wrap input {
|
83 |
+
border:0 none;
|
84 |
+
color:#333333;
|
85 |
+
padding:0;
|
86 |
}
|
87 |
|
88 |
div.wp-piwik-settings .input-text-wrap {
|
89 |
+
margin:0 0 1em 160px;
|
90 |
border:1px solid #CCCCCC;
|
|
|
91 |
}
|
92 |
+
|
93 |
div.wp-piwik_desc {
|
94 |
font-size:11px;
|
95 |
+
margin:0 0 10px 160px;
|
96 |
padding:0;
|
97 |
}
|
98 |
|
dashboard/browsers.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
WP-Piwik::Stats:Browser
|
4 |
**********************************/
|
5 |
|
6 |
-
$aryConf['data'] = $this->
|
7 |
'UserSettings.getBrowser',
|
8 |
$aryConf['params']['period'],
|
9 |
$aryConf['params']['date'],
|
@@ -21,11 +21,14 @@
|
|
21 |
}
|
22 |
if ($intMore) $strValues .= '["'.__('Others', 'wp-piwik').'",'.$intMore.'],';
|
23 |
$strValues = substr($strValues, 0, -1);
|
24 |
-
|
25 |
/***************************************************************************/ ?>
|
26 |
<div class="wp-piwik-graph-wide">
|
27 |
<div id="wp-piwik_stats_browsers_graph" style="height:310px;width:490px"></div>
|
28 |
</div>
|
|
|
|
|
|
|
29 |
<div class="table">
|
30 |
<table class="widefat wp-piwik-table">
|
31 |
<thead>
|
3 |
WP-Piwik::Stats:Browser
|
4 |
**********************************/
|
5 |
|
6 |
+
$aryConf['data'] = $this->callPiwikAPI(
|
7 |
'UserSettings.getBrowser',
|
8 |
$aryConf['params']['period'],
|
9 |
$aryConf['params']['date'],
|
21 |
}
|
22 |
if ($intMore) $strValues .= '["'.__('Others', 'wp-piwik').'",'.$intMore.'],';
|
23 |
$strValues = substr($strValues, 0, -1);
|
24 |
+
if ($intSum) {
|
25 |
/***************************************************************************/ ?>
|
26 |
<div class="wp-piwik-graph-wide">
|
27 |
<div id="wp-piwik_stats_browsers_graph" style="height:310px;width:490px"></div>
|
28 |
</div>
|
29 |
+
<?php /************************************************************************/
|
30 |
+
}
|
31 |
+
/***************************************************************************/ ?>
|
32 |
<div class="table">
|
33 |
<table class="widefat wp-piwik-table">
|
34 |
<thead>
|
dashboard/keywords.php
CHANGED
@@ -3,13 +3,16 @@
|
|
3 |
WP-Piwik::Stats:Keywords
|
4 |
**********************************/
|
5 |
|
6 |
-
$aryConf['data'] = $this->
|
7 |
'Referers.getKeywords',
|
8 |
$aryConf['params']['period'],
|
9 |
$aryConf['params']['date'],
|
10 |
$aryConf['params']['limit']
|
11 |
);
|
12 |
$aryConf['title'] = __('Keywords', 'wp-piwik');
|
|
|
|
|
|
|
13 |
/***************************************************************************/ ?>
|
14 |
<table class="widefat">
|
15 |
<thead>
|
@@ -22,4 +25,6 @@
|
|
22 |
else echo '<tr><td colspan="2">'.__('No data available.', 'wp-piwik').'</td></tr>';
|
23 |
/***************************************************************************/ ?>
|
24 |
</tbody>
|
25 |
-
</table>
|
|
|
|
3 |
WP-Piwik::Stats:Keywords
|
4 |
**********************************/
|
5 |
|
6 |
+
$aryConf['data'] = $this->callPiwikAPI(
|
7 |
'Referers.getKeywords',
|
8 |
$aryConf['params']['period'],
|
9 |
$aryConf['params']['date'],
|
10 |
$aryConf['params']['limit']
|
11 |
);
|
12 |
$aryConf['title'] = __('Keywords', 'wp-piwik');
|
13 |
+
if (isset($aryConf['data']['result']) && $aryConf['data']['result'] = 'error')
|
14 |
+
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($aryConf['data']['message'], ENT_QUOTES, 'utf-8');
|
15 |
+
else {
|
16 |
/***************************************************************************/ ?>
|
17 |
<table class="widefat">
|
18 |
<thead>
|
25 |
else echo '<tr><td colspan="2">'.__('No data available.', 'wp-piwik').'</td></tr>';
|
26 |
/***************************************************************************/ ?>
|
27 |
</tbody>
|
28 |
+
</table>
|
29 |
+
<?php /************************************************************************/
|
30 |
+
}
|
dashboard/overview.php
CHANGED
@@ -2,66 +2,68 @@
|
|
2 |
/*********************************
|
3 |
WP-Piwik::Stats:Overview
|
4 |
**********************************/
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
'VisitsSummary.get',
|
8 |
$aryConf['params']['period'],
|
9 |
$aryConf['params']['date'],
|
10 |
$aryConf['params']['limit']
|
11 |
);
|
12 |
$aryConf['title'] = __('Overview', 'wp-piwik');
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
'
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
$aryTmp[$strKey] += $strValue;
|
32 |
-
elseif ($aryTmp[$strKey] < $strValue)
|
33 |
-
$aryTmp[$strKey] = $strValue;
|
34 |
-
}
|
35 |
-
$aryConf['data'] = $aryTmp;
|
36 |
-
if ($intValCnt > 1 && $aryConf['data']['nb_visits'] >0) $aryConf['data']['bounce_rate'] = round($aryConf['data']['bounce_count']/$aryConf['data']['nb_visits']*100).'%';
|
37 |
-
}
|
38 |
/***************************************************************************/ ?>
|
39 |
<div class="table">
|
40 |
<table class="widefat">
|
41 |
<tbody>
|
42 |
<?php /************************************************************************/
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
/***************************************************************************/ ?>
|
62 |
</tbody>
|
63 |
</table>
|
64 |
</div>
|
65 |
<?php /************************************************************************/
|
66 |
-
|
67 |
-
/* EOF */
|
2 |
/*********************************
|
3 |
WP-Piwik::Stats:Overview
|
4 |
**********************************/
|
5 |
+
$aryTmp = array(
|
6 |
+
'bounce_count' => 0,
|
7 |
+
'max_actions' => 0,
|
8 |
+
'nb_actions' => 0,
|
9 |
+
'nb_uniq_visitors' => 0,
|
10 |
+
'nb_visits' => 0,
|
11 |
+
'nb_visits_converted' => 0,
|
12 |
+
'sum_visit_length' => 0,
|
13 |
+
'bounce_rate' => 0,
|
14 |
+
'nb_actions_per_visit' => 0,
|
15 |
+
'avg_time_on_site' => 0
|
16 |
+
);
|
17 |
+
$aryConf['data'] = $this->callPiwikAPI(
|
18 |
'VisitsSummary.get',
|
19 |
$aryConf['params']['period'],
|
20 |
$aryConf['params']['date'],
|
21 |
$aryConf['params']['limit']
|
22 |
);
|
23 |
$aryConf['title'] = __('Overview', 'wp-piwik');
|
24 |
+
|
25 |
+
if (isset($aryConf['data']['result']) && $aryConf['data']['result'] ='error')
|
26 |
+
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($aryConf['data']['message'], ENT_QUOTES, 'utf-8');
|
27 |
+
else {
|
28 |
+
if ($aryConf['params']['date'] == 'last30') {
|
29 |
+
$intValCnt = 0;
|
30 |
+
foreach ($aryConf['data'] as $aryDay)
|
31 |
+
foreach ($aryDay as $strKey => $strValue) {
|
32 |
+
$intValCnt++;
|
33 |
+
if (!in_array($strKey, array('max_actions','bounce_rate','nb_actions_per_visit','avg_time_on_site')))
|
34 |
+
$aryTmp[$strKey] += $strValue;
|
35 |
+
elseif ($aryTmp[$strKey] < $strValue)
|
36 |
+
$aryTmp[$strKey] = $strValue;
|
37 |
+
}
|
38 |
+
$aryConf['data'] = $aryTmp;
|
39 |
+
if ($intValCnt > 1 && $aryConf['data']['nb_visits'] >0) $aryConf['data']['bounce_rate'] = round($aryConf['data']['bounce_count']/$aryConf['data']['nb_visits']*100).'%';
|
40 |
+
}
|
41 |
+
if (empty($aryConf['data'])) $aryConf['data'] = $aryTmp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
/***************************************************************************/ ?>
|
43 |
<div class="table">
|
44 |
<table class="widefat">
|
45 |
<tbody>
|
46 |
<?php /************************************************************************/
|
47 |
+
$strTime =
|
48 |
+
floor($aryConf['data']['sum_visit_length']/3600).'h '.
|
49 |
+
floor(($aryConf['data']['sum_visit_length'] % 3600)/60).'m '.
|
50 |
+
floor(($aryConf['data']['sum_visit_length'] % 3600) % 60).'s';
|
51 |
+
$strAvgTime =
|
52 |
+
floor($aryConf['data']['avg_time_on_site']/3600).'h '.
|
53 |
+
floor(($aryConf['data']['avg_time_on_site'] % 3600)/60).'m '.
|
54 |
+
floor(($aryConf['data']['avg_time_on_site'] % 3600) % 60).'s';
|
55 |
+
echo '<tr><td>'.__('Visitors', 'wp-piwik').':</td><td>'.$aryConf['data']['nb_visits'].'</td></tr>';
|
56 |
+
echo '<tr><td>'.__('Unique visitors', 'wp-piwik').':</td><td>'.$aryConf['data']['nb_uniq_visitors'].'</td></tr>';
|
57 |
+
echo '<tr><td>'.__('Page views', 'wp-piwik').':</td><td>'.$aryConf['data']['nb_actions'].' (Ø '.$aryConf['data']['nb_actions_per_visit'].')</td></tr>';
|
58 |
+
echo '<tr><td>'.__('Max. page views in one visit', 'wp-piwik').':</td><td>'.$aryConf['data']['max_actions'].'</td></tr>';
|
59 |
+
echo '<tr><td>'.__('Total time spent', 'wp-piwik').':</td><td>'.$strTime.'</td></tr>';
|
60 |
+
echo '<tr><td>'.__('Time/visit', 'wp-piwik').':</td><td>'.$strAvgTime.'</td></tr>';
|
61 |
+
echo '<tr><td>'.__('Bounce count', 'wp-piwik').':</td><td>'.$aryConf['data']['bounce_count'].' ('.$aryConf['data']['bounce_rate'].')</td></tr>';
|
62 |
+
if (self::$aryGlobalSettings['piwik_shortcut'])
|
63 |
+
echo '<tr><td>'.__('Shortcut', 'wp-piwik').':</td><td><a href="'.self::$aryGlobalSettings['piwik_url'].'">Piwik</a>'.(isset($aryConf['inline']) && $aryConf['inline']?' - <a href="?page=wp-piwik_stats">WP-Piwik</a>':'').'</td></tr>';
|
|
|
64 |
/***************************************************************************/ ?>
|
65 |
</tbody>
|
66 |
</table>
|
67 |
</div>
|
68 |
<?php /************************************************************************/
|
69 |
+
}
|
|
dashboard/pages.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
WP-Piwik::Stats:Pages
|
4 |
**********************************/
|
5 |
|
6 |
-
$aryConf['data'] = $this->
|
7 |
'Actions.getPageTitles',
|
8 |
$aryConf['params']['period'],
|
9 |
$aryConf['params']['date'],
|
@@ -11,6 +11,10 @@
|
|
11 |
);
|
12 |
$intMax = 9;
|
13 |
$aryConf['title'] = __('Pages', 'wp-piwik');
|
|
|
|
|
|
|
|
|
14 |
/***************************************************************************/ ?>
|
15 |
<div class="table">
|
16 |
<table class="widefat wp-piwik-table">
|
@@ -48,4 +52,6 @@
|
|
48 |
/***************************************************************************/ ?>
|
49 |
</tbody>
|
50 |
</table>
|
51 |
-
</div>
|
|
|
|
3 |
WP-Piwik::Stats:Pages
|
4 |
**********************************/
|
5 |
|
6 |
+
$aryConf['data'] = $this->callPiwikAPI(
|
7 |
'Actions.getPageTitles',
|
8 |
$aryConf['params']['period'],
|
9 |
$aryConf['params']['date'],
|
11 |
);
|
12 |
$intMax = 9;
|
13 |
$aryConf['title'] = __('Pages', 'wp-piwik');
|
14 |
+
|
15 |
+
if (isset($aryConf['data']['result']) && $aryConf['data']['result'] = 'error')
|
16 |
+
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($aryConf['data']['message'], ENT_QUOTES, 'utf-8');
|
17 |
+
else {
|
18 |
/***************************************************************************/ ?>
|
19 |
<div class="table">
|
20 |
<table class="widefat wp-piwik-table">
|
52 |
/***************************************************************************/ ?>
|
53 |
</tbody>
|
54 |
</table>
|
55 |
+
</div>
|
56 |
+
<?php /************************************************************************/
|
57 |
+
}
|
dashboard/plugins.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
WP-Piwik::Stats:Plugins
|
4 |
**********************************/
|
5 |
|
6 |
-
$aryConf['data'] = $this->
|
7 |
'UserSettings.getPlugin',
|
8 |
$aryConf['params']['period'],
|
9 |
$aryConf['params']['date'],
|
@@ -11,16 +11,20 @@
|
|
11 |
);
|
12 |
$aryConf['title'] = __('Plugins', 'wp-piwik');
|
13 |
|
14 |
-
$aryOverview = $this->
|
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 |
<div class="table">
|
26 |
<table class="widefat wp-piwik-table">
|
@@ -49,4 +53,6 @@
|
|
49 |
/***************************************************************************/ ?>
|
50 |
</tbody>
|
51 |
</table>
|
52 |
-
</div>
|
|
|
|
3 |
WP-Piwik::Stats:Plugins
|
4 |
**********************************/
|
5 |
|
6 |
+
$aryConf['data'] = $this->callPiwikAPI(
|
7 |
'UserSettings.getPlugin',
|
8 |
$aryConf['params']['period'],
|
9 |
$aryConf['params']['date'],
|
11 |
);
|
12 |
$aryConf['title'] = __('Plugins', 'wp-piwik');
|
13 |
|
14 |
+
$aryOverview = $this->callPiwikAPI(
|
15 |
'VisitsSummary.get',
|
16 |
$aryConf['params']['period'],
|
17 |
$aryConf['params']['date'],
|
18 |
$aryConf['params']['limit']
|
19 |
);
|
20 |
|
21 |
+
$intTotalVisits = (isset($aryOverview['nb_visits'])?$aryOverview['nb_visits']:0);
|
22 |
|
23 |
unset($aryOverview);
|
24 |
+
|
25 |
+
if (isset($aryConf['data']['result']) && $aryConf['data']['result'] = 'error')
|
26 |
+
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($aryConf['data']['message'], ENT_QUOTES, 'utf-8');
|
27 |
+
else {
|
28 |
/***************************************************************************/ ?>
|
29 |
<div class="table">
|
30 |
<table class="widefat wp-piwik-table">
|
53 |
/***************************************************************************/ ?>
|
54 |
</tbody>
|
55 |
</table>
|
56 |
+
</div>
|
57 |
+
<?php /************************************************************************/
|
58 |
+
}
|
dashboard/screens.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
WP-Piwik::Stats:Screens
|
4 |
**********************************/
|
5 |
|
6 |
-
$aryConf['data'] = $this->
|
7 |
'UserSettings.getResolution',
|
8 |
$aryConf['params']['period'],
|
9 |
$aryConf['params']['date'],
|
@@ -21,10 +21,14 @@
|
|
21 |
}
|
22 |
if ($intMore) $strValues .= '["'.__('Others', 'wp-piwik').'",'.$intMore.'],';
|
23 |
$strValues = substr($strValues, 0, -1);
|
|
|
24 |
/***************************************************************************/ ?>
|
25 |
<div class="wp-piwik-graph-wide">
|
26 |
<div id="wp-piwik_stats_screens_graph" style="height:310px;width:490px"></div>
|
27 |
</div>
|
|
|
|
|
|
|
28 |
<div class="table">
|
29 |
<table class="widefat wp-piwik-table">
|
30 |
<thead>
|
3 |
WP-Piwik::Stats:Screens
|
4 |
**********************************/
|
5 |
|
6 |
+
$aryConf['data'] = $this->callPiwikAPI(
|
7 |
'UserSettings.getResolution',
|
8 |
$aryConf['params']['period'],
|
9 |
$aryConf['params']['date'],
|
21 |
}
|
22 |
if ($intMore) $strValues .= '["'.__('Others', 'wp-piwik').'",'.$intMore.'],';
|
23 |
$strValues = substr($strValues, 0, -1);
|
24 |
+
if ($intSum) {
|
25 |
/***************************************************************************/ ?>
|
26 |
<div class="wp-piwik-graph-wide">
|
27 |
<div id="wp-piwik_stats_screens_graph" style="height:310px;width:490px"></div>
|
28 |
</div>
|
29 |
+
<?php /************************************************************************/
|
30 |
+
}
|
31 |
+
/***************************************************************************/ ?>
|
32 |
<div class="table">
|
33 |
<table class="widefat wp-piwik-table">
|
34 |
<thead>
|
dashboard/seo.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*********************************
|
3 |
+
WP-Piwik::Stats:SEO
|
4 |
+
**********************************/
|
5 |
+
$aryConf['data'] = $GLOBALS['wp_piwik']->callPiwikAPI(
|
6 |
+
'SEO.getRank',
|
7 |
+
$aryConf['params']['period'],
|
8 |
+
$aryConf['params']['date'],
|
9 |
+
$aryConf['params']['limit'],
|
10 |
+
false,
|
11 |
+
false,
|
12 |
+
'csv'
|
13 |
+
);
|
14 |
+
|
15 |
+
if (substr($aryConf['data'], 0, 6) == 'Error:') {
|
16 |
+
$strMessage = str_replace('Error:', '', $aryConf['data']);
|
17 |
+
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($strMessage, ENT_QUOTES, 'utf-8');
|
18 |
+
} else {
|
19 |
+
|
20 |
+
$aryConf['title'] = __('SEO', 'wp-piwik');
|
21 |
+
$aryLines = explode("\n", $aryConf['data']);
|
22 |
+
foreach ($aryLines as $strLine)
|
23 |
+
$aryData[] = explode(',', $strLine);
|
24 |
+
unset($aryData[0]);
|
25 |
+
/***************************************************************************/ ?>
|
26 |
+
<div class="table">
|
27 |
+
<table class="widefat">
|
28 |
+
<tbody>
|
29 |
+
<?php foreach ($aryData as $aryVal) { ?>
|
30 |
+
<tr><td><?php echo $aryVal[0]; ?></td><td><?php echo $aryVal[1]; ?></td></tr>
|
31 |
+
<?php } ?>
|
32 |
+
</tbody>
|
33 |
+
</table>
|
34 |
+
</div>
|
35 |
+
<?php /************************************************************************/
|
36 |
+
}
|
dashboard/systems.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
WP-Piwik::Stats:Systems
|
4 |
**********************************/
|
5 |
|
6 |
-
$aryConf['data'] = $this->
|
7 |
'UserSettings.getOS',
|
8 |
$aryConf['params']['period'],
|
9 |
$aryConf['params']['date'],
|
@@ -22,11 +22,14 @@
|
|
22 |
if ($intMore) $strValues .= '["'.__('Others', 'wp-piwik').'",'.$intMore.'],';
|
23 |
$strValues = substr($strValues, 0, -1);
|
24 |
|
25 |
-
|
26 |
/***************************************************************************/ ?>
|
27 |
<div class="wp-piwik-graph-wide">
|
28 |
<div id="wp-piwik_stats_systems_graph" style="height:310px;width:490px"></div>
|
29 |
</div>
|
|
|
|
|
|
|
30 |
<div class="table">
|
31 |
<table class="widefat wp-piwik-table">
|
32 |
<thead>
|
3 |
WP-Piwik::Stats:Systems
|
4 |
**********************************/
|
5 |
|
6 |
+
$aryConf['data'] = $this->callPiwikAPI(
|
7 |
'UserSettings.getOS',
|
8 |
$aryConf['params']['period'],
|
9 |
$aryConf['params']['date'],
|
22 |
if ($intMore) $strValues .= '["'.__('Others', 'wp-piwik').'",'.$intMore.'],';
|
23 |
$strValues = substr($strValues, 0, -1);
|
24 |
|
25 |
+
if ($intSum) {
|
26 |
/***************************************************************************/ ?>
|
27 |
<div class="wp-piwik-graph-wide">
|
28 |
<div id="wp-piwik_stats_systems_graph" style="height:310px;width:490px"></div>
|
29 |
</div>
|
30 |
+
<?php /************************************************************************/
|
31 |
+
}
|
32 |
+
/***************************************************************************/ ?>
|
33 |
<div class="table">
|
34 |
<table class="widefat wp-piwik-table">
|
35 |
<thead>
|
dashboard/visitors.php
CHANGED
@@ -3,43 +3,46 @@
|
|
3 |
WP-Piwik::Stats:Vistors
|
4 |
**********************************/
|
5 |
|
6 |
-
$aryConf['data']['Visitors'] = $this->
|
7 |
'VisitsSummary.getVisits',
|
8 |
$aryConf['params']['period'],
|
9 |
$aryConf['params']['date'],
|
10 |
$aryConf['params']['limit']
|
11 |
);
|
12 |
-
$aryConf['data']['Unique'] = $this->
|
13 |
'VisitsSummary.getUniqueVisitors',
|
14 |
$aryConf['params']['period'],
|
15 |
$aryConf['params']['date'],
|
16 |
$aryConf['params']['limit']
|
17 |
);
|
18 |
-
$aryConf['data']['Bounced'] = $this->
|
19 |
'VisitsSummary.getBounceCount',
|
20 |
$aryConf['params']['period'],
|
21 |
$aryConf['params']['date'],
|
22 |
$aryConf['params']['limit']
|
23 |
-
);
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
43 |
|
44 |
/***************************************************************************/ ?>
|
45 |
<div class="wp-piwik-graph-wide">
|
@@ -58,18 +61,18 @@
|
|
58 |
</thead>
|
59 |
<tbody style="cursor:pointer;">
|
60 |
<?php /************************************************************************/
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
/***************************************************************************/ ?>
|
74 |
</tbody>
|
75 |
</table>
|
@@ -82,4 +85,6 @@ $j.jqplot('wp-piwik_stats_vistors_graph', [[<?php echo $strValues; ?>],[<?php ec
|
|
82 |
seriesDefaults:{showMarker:false,lineWidth:1,fill:true,fillAndStroke:true,fillAlpha:0.9,trendline:{show:false,color:'#C00',lineWidth:1.5,type:'exp'}},
|
83 |
series:[{color:'#90AAD9',fillColor:'#D4E2ED'},{color:'#A3BCEA',fillColor:'#E4F2FD',trendline:{show:true,label:'Unique visitor trend'}},{color:'#E9A0BA',fillColor:'#FDE4F2'}],
|
84 |
});
|
85 |
-
</script>
|
|
|
|
3 |
WP-Piwik::Stats:Vistors
|
4 |
**********************************/
|
5 |
|
6 |
+
$aryConf['data']['Visitors'] = $this->callPiwikAPI(
|
7 |
'VisitsSummary.getVisits',
|
8 |
$aryConf['params']['period'],
|
9 |
$aryConf['params']['date'],
|
10 |
$aryConf['params']['limit']
|
11 |
);
|
12 |
+
$aryConf['data']['Unique'] = $this->callPiwikAPI(
|
13 |
'VisitsSummary.getUniqueVisitors',
|
14 |
$aryConf['params']['period'],
|
15 |
$aryConf['params']['date'],
|
16 |
$aryConf['params']['limit']
|
17 |
);
|
18 |
+
$aryConf['data']['Bounced'] = $this->callPiwikAPI(
|
19 |
'VisitsSummary.getBounceCount',
|
20 |
$aryConf['params']['period'],
|
21 |
$aryConf['params']['date'],
|
22 |
$aryConf['params']['limit']
|
23 |
+
);
|
24 |
|
25 |
+
if (isset($aryConf['data']['Visitors']['result']) && $aryConf['data']['Visitors']['result'] ='error')
|
26 |
+
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($aryConf['data']['Visitors']['message'], ENT_QUOTES, 'utf-8');
|
27 |
+
else {
|
28 |
+
$strValues = $strLabels = $strBounced = $strValuesU = $strCounter = '';
|
29 |
+
$intUSum = $intCount = 0;
|
30 |
+
if (is_array($aryConf['data']['Visitors']))
|
31 |
+
foreach ($aryConf['data']['Visitors'] as $strDate => $intValue) {
|
32 |
+
$intCount++;
|
33 |
+
$strValues .= $intValue.',';
|
34 |
+
$strValuesU .= $aryConf['data']['Unique'][$strDate].',';
|
35 |
+
$strBounced .= $aryConf['data']['Bounced'][$strDate].',';
|
36 |
+
$strLabels .= '['.$intCount.',"'.substr($strDate,-2).'"],';
|
37 |
+
$intUSum += $aryConf['data']['Unique'][$strDate];
|
38 |
+
}
|
39 |
+
else {$strValues = '0,'; $strLabels = '[0,"-"],'; $strValuesU = '0,'; $strBounced = '0,'; }
|
40 |
+
$intAvg = round($intUSum/30,0);
|
41 |
+
$strValues = substr($strValues, 0, -1);
|
42 |
+
$strValuesU = substr($strValuesU, 0, -1);
|
43 |
+
$strLabels = substr($strLabels, 0, -1);
|
44 |
+
$strBounced = substr($strBounced, 0, -1);
|
45 |
+
$strCounter = substr($strCounter, 0, -1);
|
46 |
|
47 |
/***************************************************************************/ ?>
|
48 |
<div class="wp-piwik-graph-wide">
|
61 |
</thead>
|
62 |
<tbody style="cursor:pointer;">
|
63 |
<?php /************************************************************************/
|
64 |
+
if (is_array($aryConf['data']['Visitors'])) {
|
65 |
+
$aryTmp = array_reverse($aryConf['data']['Visitors']);
|
66 |
+
foreach ($aryTmp as $strDate => $intValue)
|
67 |
+
echo '<tr onclick="javascript:datelink(\''.urlencode('wp-piwik_stats').'\',\''.str_replace('-', '', $strDate).'\',\''.(isset($_GET['wpmu_show_stats'])?(int) $_GET['wpmu_show_stats']:'').'\');"><td>'.$strDate.'</td><td class="n">'.
|
68 |
+
$intValue.'</td><td class="n">'.
|
69 |
+
$aryConf['data']['Unique'][$strDate].
|
70 |
+
'</td><td class="n">'.
|
71 |
+
$aryConf['data']['Bounced'][$strDate].
|
72 |
+
'</td></tr>'."\n";
|
73 |
+
}
|
74 |
+
echo '<tr><td class="n" colspan="4"><strong>'.__('Unique TOTAL', 'wp-piwik').'</strong> '.__('Sum', 'wp-piwik').': '.$intUSum.' '.__('Avg', 'wp-piwik').': '.$intAvg.'</td></tr>';
|
75 |
+
unset($aryTmp);
|
76 |
/***************************************************************************/ ?>
|
77 |
</tbody>
|
78 |
</table>
|
85 |
seriesDefaults:{showMarker:false,lineWidth:1,fill:true,fillAndStroke:true,fillAlpha:0.9,trendline:{show:false,color:'#C00',lineWidth:1.5,type:'exp'}},
|
86 |
series:[{color:'#90AAD9',fillColor:'#D4E2ED'},{color:'#A3BCEA',fillColor:'#E4F2FD',trendline:{show:true,label:'Unique visitor trend'}},{color:'#E9A0BA',fillColor:'#FDE4F2'}],
|
87 |
});
|
88 |
+
</script>
|
89 |
+
<?php
|
90 |
+
}
|
dashboard/websites.php
CHANGED
@@ -3,13 +3,17 @@
|
|
3 |
WP-Piwik::Stats:Websites
|
4 |
**********************************/
|
5 |
|
6 |
-
$aryConf['data'] = $this->
|
7 |
'Referers.getWebsites',
|
8 |
$aryConf['params']['period'],
|
9 |
$aryConf['params']['date'],
|
10 |
$aryConf['params']['limit']
|
11 |
);
|
12 |
$aryConf['title'] = __('Websites', 'wp-piwik');
|
|
|
|
|
|
|
|
|
13 |
/***************************************************************************/ ?>
|
14 |
<table class="widefat">
|
15 |
<thead>
|
@@ -25,4 +29,6 @@
|
|
25 |
else echo '<tr><td colspan="2">'.__('No data available.', 'wp-piwik').'</td></tr>';
|
26 |
/***************************************************************************/ ?>
|
27 |
</tbody>
|
28 |
-
</table>
|
|
|
|
3 |
WP-Piwik::Stats:Websites
|
4 |
**********************************/
|
5 |
|
6 |
+
$aryConf['data'] = $this->callPiwikAPI(
|
7 |
'Referers.getWebsites',
|
8 |
$aryConf['params']['period'],
|
9 |
$aryConf['params']['date'],
|
10 |
$aryConf['params']['limit']
|
11 |
);
|
12 |
$aryConf['title'] = __('Websites', 'wp-piwik');
|
13 |
+
|
14 |
+
if (isset($aryConf['data']['result']) && $aryConf['data']['result'] = 'error')
|
15 |
+
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($aryConf['data']['message'], ENT_QUOTES, 'utf-8');
|
16 |
+
else {
|
17 |
/***************************************************************************/ ?>
|
18 |
<table class="widefat">
|
19 |
<thead>
|
29 |
else echo '<tr><td colspan="2">'.__('No data available.', 'wp-piwik').'</td></tr>';
|
30 |
/***************************************************************************/ ?>
|
31 |
</tbody>
|
32 |
+
</table>
|
33 |
+
<?php /************************************************************************/
|
34 |
+
}
|
index.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Nothing to see...
|
js/wp-piwik.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
function datelink(strPage,strDate) {
|
2 |
-
window.location.href='index.php?page='+strPage+'&date='+strDate;
|
3 |
}
|
1 |
+
function datelink(strPage,strDate,intSite) {
|
2 |
+
window.location.href='index.php?page='+strPage+'&date='+strDate+'&wpmu_show_stats='+intSite;
|
3 |
}
|
languages/wp-piwik-de_DE.mo
CHANGED
Binary file
|
languages/wp-piwik-de_DE.po
CHANGED
@@ -153,9 +153,13 @@ msgstr "gestern"
|
|
153 |
msgid "today"
|
154 |
msgstr "heute"
|
155 |
|
|
|
|
|
|
|
|
|
156 |
#: wp-piwik.php:144 wp-piwik.php:559
|
157 |
msgid "last 30 days"
|
158 |
-
msgstr "
|
159 |
|
160 |
#: wp-piwik.php:179
|
161 |
msgid "Settings"
|
@@ -239,8 +243,8 @@ msgid "Track 404"
|
|
239 |
msgstr "404-Tracking"
|
240 |
|
241 |
#: wp-piwik.php:532
|
242 |
-
msgid "
|
243 |
-
msgstr "
|
244 |
|
245 |
#: wp-piwik.php:536 wp-piwik.php:644
|
246 |
msgid "Tracking filter"
|
@@ -337,7 +341,7 @@ msgid "Thank you very much for your donation"
|
|
337 |
msgstr "Vielen Dank für eure Spenden"
|
338 |
|
339 |
msgid "and all people flattering this"
|
340 |
-
msgstr "und
|
341 |
|
342 |
msgid "Graphs powered by <a href=\"http://www.jqplot.com/\">jqPlot</a>, an open source project by Chris Leonello. Give it a try! (License: GPL 2.0 and MIT)"
|
343 |
msgstr "Die Graphen werden mit <a href=\"http://www.jqplot.com/\">jqPlot</a> erstellt, einem Open-Source-Projekt von Chris Leonello. Probiere es mal aus! (Lizenz: GPL 2.0 und MIT)"
|
@@ -381,7 +385,7 @@ msgstr "Board-Daten"
|
|
381 |
msgid "Display an overview widget to your WordPress dashboard."
|
382 |
msgstr "Zeigt ein Übersichts-Widget auf dem WordPress-Dashboard."
|
383 |
|
384 |
-
msgid "
|
385 |
msgstr "Board-Chart"
|
386 |
|
387 |
msgid "Display a visitor graph widget to your WordPress dashboard."
|
@@ -389,3 +393,75 @@ msgstr "Zeigt einen Besucher-Graph als Widget auf dem WordPress-Dashboard."
|
|
389 |
|
390 |
msgid "No data available."
|
391 |
msgstr "Keine Daten vorhanden."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
msgid "today"
|
154 |
msgstr "heute"
|
155 |
|
156 |
+
#: wp-piwik.php:144 wp-piwik.php:559
|
157 |
+
msgid "last30"
|
158 |
+
msgstr "letzte 30 Tage"
|
159 |
+
|
160 |
#: wp-piwik.php:144 wp-piwik.php:559
|
161 |
msgid "last 30 days"
|
162 |
+
msgstr "letzte 30 Tage"
|
163 |
|
164 |
#: wp-piwik.php:179
|
165 |
msgid "Settings"
|
243 |
msgstr "404-Tracking"
|
244 |
|
245 |
#: wp-piwik.php:532
|
246 |
+
msgid "WP-Piwik can automatically add a 404-category to track 404-page-visits."
|
247 |
+
msgstr "kann WP-Piwik automatisch eine eigene Kategorie für 404-Seiten hinzufügen."
|
248 |
|
249 |
#: wp-piwik.php:536 wp-piwik.php:644
|
250 |
msgid "Tracking filter"
|
341 |
msgstr "Vielen Dank für eure Spenden"
|
342 |
|
343 |
msgid "and all people flattering this"
|
344 |
+
msgstr "und alle Nutzern, die bei Flatter klicken"
|
345 |
|
346 |
msgid "Graphs powered by <a href=\"http://www.jqplot.com/\">jqPlot</a>, an open source project by Chris Leonello. Give it a try! (License: GPL 2.0 and MIT)"
|
347 |
msgstr "Die Graphen werden mit <a href=\"http://www.jqplot.com/\">jqPlot</a> erstellt, einem Open-Source-Projekt von Chris Leonello. Probiere es mal aus! (Lizenz: GPL 2.0 und MIT)"
|
385 |
msgid "Display an overview widget to your WordPress dashboard."
|
386 |
msgstr "Zeigt ein Übersichts-Widget auf dem WordPress-Dashboard."
|
387 |
|
388 |
+
msgid "Board chart"
|
389 |
msgstr "Board-Chart"
|
390 |
|
391 |
msgid "Display a visitor graph widget to your WordPress dashboard."
|
393 |
|
394 |
msgid "No data available."
|
395 |
msgstr "Keine Daten vorhanden."
|
396 |
+
|
397 |
+
msgid "Check this to automatically choose your blog from your Piwik sites by URL. If your blog is not added to Piwik yet, WP-Piwik will add a new site."
|
398 |
+
msgstr "Aktiviere diesen Haken, um Dein Blog über seine URL automatisch aus Deinen Piwik-Seiten auszuwählen. Wenn Dein Blog bisher nicht zu Piwik hinzugefügt wurde, wird WP-Piwik eine neue Seite hinzufügen."
|
399 |
+
|
400 |
+
msgid "If you add the Piwik javascript code by wp_footer(),"
|
401 |
+
msgstr "Wenn Du den Piwik-Code per wp_footer() in Dein Blog einbindest,"
|
402 |
+
|
403 |
+
msgid "WP-Piwik can automatically use js/index.php instead of piwik.js. See"
|
404 |
+
msgstr "kann WP-Piwik automatisch js/index.php statt piwik.js verwenden. Siehe"
|
405 |
+
|
406 |
+
msgid "WP-Piwik can automatically force the Tracking Code to sent data in POST. See"
|
407 |
+
msgstr "kann WP-Piwik automatisch den Tracking Code zwingen, die Daten via POST zu senden. Siehe"
|
408 |
+
|
409 |
+
msgid "Avoid mod_security"
|
410 |
+
msgstr "Umgehe mod_security"
|
411 |
+
|
412 |
+
msgid "Determined site"
|
413 |
+
msgstr "Ermittelte Seite"
|
414 |
+
|
415 |
+
msgid "Auto config"
|
416 |
+
msgstr "Auto-Konfiguration"
|
417 |
+
|
418 |
+
msgid "Use js/index.php"
|
419 |
+
msgstr "Nutze js/index.php"
|
420 |
+
|
421 |
+
msgid "Show overview"
|
422 |
+
msgstr "Zeige Übersicht"
|
423 |
+
|
424 |
+
msgid "Hide overview"
|
425 |
+
msgstr "Zeige keine Übersicht"
|
426 |
+
|
427 |
+
msgid "SEO <em>(slow!)</em>"
|
428 |
+
msgstr "SEO <em>(langsam!)</em>"
|
429 |
+
|
430 |
+
msgid "Display SEO ranking data on statistics page. <em>(Slow!)</em>"
|
431 |
+
msgstr "Zeige SEO-Rankingdaten auf der Statistik-Seite. <em>(Langsam!)</em>"
|
432 |
+
|
433 |
+
msgid "Configure WP-Piwik widgets to be shown on your WordPress Home Dashboard."
|
434 |
+
msgstr "Konfiguriere WP-Piwik-Widgets, die auf Deinem WordPress Home Dashboard erscheinen sollen."
|
435 |
+
|
436 |
+
msgid "SEO data"
|
437 |
+
msgstr "SEO-Daten"
|
438 |
+
|
439 |
+
msgid "the Piwik team itself"
|
440 |
+
msgstr "das Piwik-Team selbst"
|
441 |
+
|
442 |
+
msgid "Metabox support inspired by"
|
443 |
+
msgstr "Die Metabox-Unterstützung wurde inspiriert von"
|
444 |
+
|
445 |
+
msgid "WP-Piwik support board"
|
446 |
+
msgstr "WP-Piwik Support Board"
|
447 |
+
|
448 |
+
msgid "no registration required, English & German"
|
449 |
+
msgstr "keine Registrierung erforderlich, Englisch & Deutsch"
|
450 |
+
|
451 |
+
msgid "WordPress.org forum about WP-Piwik"
|
452 |
+
msgstr "WordPress.org Forum über WP-Piwik"
|
453 |
+
|
454 |
+
msgid "WordPress.org registration required, English"
|
455 |
+
msgstr "Registrierung bei WordPress.org notwendig, Englisch"
|
456 |
+
|
457 |
+
msgid "Please don't forget to vote the compatibility at the"
|
458 |
+
msgstr "Bitte denke daran, eine Kompatibilitätsbewertung abzugeben:"
|
459 |
+
|
460 |
+
msgid "Donate"
|
461 |
+
msgstr "Spenden"
|
462 |
+
|
463 |
+
msgid "My Amazon.de wishlist"
|
464 |
+
msgstr "Meine Wunschliste bei Amazon.de"
|
465 |
+
|
466 |
+
msgid "Piwik error"
|
467 |
+
msgstr "Piwik-Fehler"
|
readme.txt
CHANGED
@@ -1,48 +1,43 @@
|
|
1 |
=== WP-Piwik ===
|
2 |
|
3 |
Contributors: Braekling
|
4 |
-
Requires at least: 3.
|
5 |
-
Tested up to: 3.
|
6 |
-
Stable tag: 0.
|
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 |
|
10 |
-
This plugin adds a
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
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.
|
15 |
|
16 |
-
**You need a running Piwik installation** and at least view access to your stats. Also PHP 5 or higher is strictly required.
|
17 |
-
|
18 |
|
19 |
Look at the [Piwik website](http://piwik.org/) to get further information about Piwik.
|
20 |
|
21 |
*This plugin is not created or provided by the Piwik project team.*
|
22 |
|
23 |
-
Languages: English, Albanian, Belorussian, Dutch, French,
|
24 |
|
25 |
-
*Note: If you vote "It's broken", please tell me about your problem. It's hard to fix a bug I don't know about!
|
26 |
|
27 |
= WP multisite =
|
28 |
|
29 |
-
Version 0.6.0
|
30 |
|
31 |
**Experimental**
|
32 |
|
33 |
-
The WP multisite support is
|
34 |
|
35 |
**Simple**
|
36 |
|
37 |
-
Just add WP-Piwik to your /wp-content/plugins folder. So each user can enable WP-Piwik and use his own Piwik instance.
|
38 |
|
39 |
**Extended (WPMU-Piwik)**
|
40 |
|
41 |
-
|
42 |
-
2. Go to line 30 ($GLOBALS['wp-piwik_wpmu'] = false;)
|
43 |
-
3. Change to $GLOBALS['wp-piwik_wpmu'] = true;
|
44 |
-
4. You should use a clear Piwik installation and a token with full admin rights due to avoid conflicts. WPMU-Piwik will add a new site to Piwik each time a new blog is visited the first time.
|
45 |
-
5. Users have access to their own statistics, site admins can access each blog's statistics. Please test it on your own (e.g. using a local copy of your WPMU) before you use it in an user context.
|
46 |
|
47 |
= Credits =
|
48 |
|
@@ -57,19 +52,22 @@ Just add WP-Piwik to your /wp-content/plugins folder. So each user can enable WP
|
|
57 |
* Russian [ru_RU] language file by [Natalya](http://www.luxpar.de).
|
58 |
* Swedish [sv_SE] language file by [EzBizNiz](http://ezbizniz.com/).
|
59 |
* Norwegian [nb_NO] language file by Gormer.
|
|
|
|
|
60 |
|
61 |
-
Thank you
|
62 |
|
63 |
== Installation ==
|
64 |
|
65 |
1. Upload the full `wp-piwik` directory into your `wp-content/plugins` directory.
|
66 |
|
67 |
-
2. Activate the plugin through the 'Plugins' menu in WordPress.
|
68 |
|
69 |
3. Open the new 'Settings/WP-Piwik Settings' menu, enter your Piwik base URL and your auth token. Save settings.
|
70 |
-
4. If you have view access to multiple site stats, choose your blog and save settings again.
|
71 |
-
5. Look at 'Dashboard/WP-Piwik' to get your site stats.
|
72 |
|
|
|
|
|
|
|
73 |
|
74 |
== Screenshots ==
|
75 |
|
@@ -79,6 +77,23 @@ Thank you, guys!
|
|
79 |
|
80 |
== Changelog ==
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
= 0.8.10 =
|
83 |
* jqplot update (IE 9 compatibility) - Thank you, Martin!
|
84 |
* Bugfix: [No stats on dashboard](http://wordpress.org/support/topic/no-stats-on-dashboard-new-install)
|
1 |
=== WP-Piwik ===
|
2 |
|
3 |
Contributors: Braekling
|
4 |
+
Requires at least: 3.3
|
5 |
+
Tested up to: 3.3.1
|
6 |
+
Stable tag: 0.9.0
|
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 |
|
10 |
+
This plugin adds a Piwik stats site to your WordPress or WordPress multisite dashboard.
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
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.
|
15 |
|
16 |
+
**You need a running Piwik (at least 1.6) installation** and at least view access to your stats. Also PHP 5 or higher is strictly required.
|
|
|
17 |
|
18 |
Look at the [Piwik website](http://piwik.org/) to get further information about Piwik.
|
19 |
|
20 |
*This plugin is not created or provided by the Piwik project team.*
|
21 |
|
22 |
+
Languages: English, German, Albanian, Azerbaijani, Belorussian, Dutch, French, Greek, Russian, Swedish, Norwegian
|
23 |
|
24 |
+
*Note: If you vote "It's broken", please tell me about your problem. It's hard to fix a bug I don't know about! ;-)*
|
25 |
|
26 |
= WP multisite =
|
27 |
|
28 |
+
Version 0.6.0 (or newer) includes experimental WP multisite support.
|
29 |
|
30 |
**Experimental**
|
31 |
|
32 |
+
The WP multisite support is still experimental. Please test it on your own (e.g. using a local copy of your WP multisite) before you use it in an user context.
|
33 |
|
34 |
**Simple**
|
35 |
|
36 |
+
Just add WP-Piwik to your /wp-content/plugins folder and enable the Plugins page for individual site administrators. So each user can enable WP-Piwik and use his own Piwik instance.
|
37 |
|
38 |
**Extended (WPMU-Piwik)**
|
39 |
|
40 |
+
Add WP-Piwik to your /wp-content/plugins folder and enable it as [Network Plugin](http://codex.wordpress.org/Create_A_Network#WordPress_Plugins). Users have access to their own statistics, site admins can access each blog's statistics. Please test it on your own (e.g. using a local copy of your WPMU) before you use it in an user context.
|
|
|
|
|
|
|
|
|
41 |
|
42 |
= Credits =
|
43 |
|
52 |
* Russian [ru_RU] language file by [Natalya](http://www.luxpar.de).
|
53 |
* Swedish [sv_SE] language file by [EzBizNiz](http://ezbizniz.com/).
|
54 |
* Norwegian [nb_NO] language file by Gormer.
|
55 |
+
* Donations: Marco L., Rolf W., Tobias U., Lars K., Donna F., the Piwik team itself, and all people flattering this.
|
56 |
+
* All users who send me mails containing criticism, commendation, feature requests and bug reports - you help me to make WP-Piwik much better!
|
57 |
|
58 |
+
Thank you all!
|
59 |
|
60 |
== Installation ==
|
61 |
|
62 |
1. Upload the full `wp-piwik` directory into your `wp-content/plugins` directory.
|
63 |
|
64 |
+
2. Activate the plugin through the 'Plugins' menu in WordPress. (As a multisite admin you can enable WP-Piwik as *experimental* [Network Plugin](http://codex.wordpress.org/Create_A_Network#WordPress_Plugins) also.)
|
65 |
|
66 |
3. Open the new 'Settings/WP-Piwik Settings' menu, enter your Piwik base URL and your auth token. Save settings.
|
|
|
|
|
67 |
|
68 |
+
4. If you have view access to multiple site stats and did not enable "auto config", choose your blog and save settings again.
|
69 |
+
|
70 |
+
5. Look at 'Dashboard/WP-Piwik' to get your site stats.
|
71 |
|
72 |
== Screenshots ==
|
73 |
|
77 |
|
78 |
== Changelog ==
|
79 |
|
80 |
+
= 0.9.0 =
|
81 |
+
* Auto-configuration
|
82 |
+
* No code change required to enable WPMU mode anymore (Still experimental. Please create a backup before trying 0.9.0!)
|
83 |
+
* All features in WPMU available
|
84 |
+
* Bugfix: Removed unnecessary API calls done with each site request - Thank you, Martin B.!
|
85 |
+
* Bugfix: [No stats on dashboard](http://wordpress.org/support/topic/no-stats-on-dashboard-new-install) (sometimes this issue still occured, should be fixed now)
|
86 |
+
* Code cleanup (still not finished)
|
87 |
+
* Minor UI fixes
|
88 |
+
* Minor language/gettext improvements
|
89 |
+
* Security improvements
|
90 |
+
* Show SEO rank stats (very slow, caching will be added in 0.9.1)
|
91 |
+
* WordPress dashboard SEO rank widget (very slow, caching will be added in 0.9.1)
|
92 |
+
* New option: use js/index.php
|
93 |
+
* New option: avoid mod_security
|
94 |
+
* Mulisite: Order blog list alphabetically (Network Admin stats site)
|
95 |
+
* Settings: Order site list alphabetically (site list shown if order conf is disabled)
|
96 |
+
|
97 |
= 0.8.10 =
|
98 |
* jqplot update (IE 9 compatibility) - Thank you, Martin!
|
99 |
* Bugfix: [No stats on dashboard](http://wordpress.org/support/topic/no-stats-on-dashboard-new-install)
|
update/.htaccess
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
Deny from all
|
update/80403.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Capability read stats: Translate level to role
|
3 |
+
$aryTranslate = array(
|
4 |
+
'level_10' => array('administrator' => true),
|
5 |
+
'level_7' => array('editor' => true, 'administrator' => true),
|
6 |
+
'level_2' => array('author' => true, 'editor' => true, 'administrator' => true),
|
7 |
+
'level_1' => array('contributor' => true, 'author' => true, 'editor' => true, 'administrator' => true),
|
8 |
+
'level_0' => array('subscriber' => true, 'contributor' => true, 'author' => true, 'editor' => true, 'administrator' => true)
|
9 |
+
);
|
10 |
+
$strDisplayToLevel = get_option('wp-piwik_displayto','level_10');
|
11 |
+
if (!is_array($strDisplayToLevel) && isset($aryTranslate[$strDisplayToLevel])) $aryDisplayToCap = $aryTranslate[$strDisplayToLevel];
|
12 |
+
else $aryDisplayToCap = array('administrator' => true);
|
13 |
+
// Build settings arrays
|
14 |
+
$aryDashboardWidgetRange = array(0 => false, 1 => 'yesterday', 2 => 'today', 3 => 'last30');
|
15 |
+
if (self::$bolWPMU) self::$aryGlobalSettings = array(
|
16 |
+
'revision' => get_site_option('wpmu-piwik_revision', 0),
|
17 |
+
'add_tracking_code' => true,
|
18 |
+
'last_settings_update' => get_site_option('wpmu-piwik_settingsupdate', time()),
|
19 |
+
'piwik_token' => get_site_option('wpmu-piwik_token', ''),
|
20 |
+
'piwik_url' => get_site_option('wpmu-piwik_url', ''),
|
21 |
+
'dashboard_widget' => false,
|
22 |
+
'capability_stealth' => get_site_option('wpmu-piwik_filter', array()),
|
23 |
+
'capability_read_stats' => $aryDisplayToCap,
|
24 |
+
'piwik_shortcut' => false,
|
25 |
+
);
|
26 |
+
else self::$aryGlobalSettings = array(
|
27 |
+
'revision' => get_option('wp-piwik_revision',0),
|
28 |
+
'add_tracking_code' => get_option('wp-piwik_addjs'),
|
29 |
+
'last_settings_update' => get_option('wp-piwik_settingsupdate', time()),
|
30 |
+
'piwik_token' => get_option('wp-piwik_token', ''),
|
31 |
+
'piwik_url' => get_option('wp-piwik_url', ''),
|
32 |
+
'dashboard_widget' => $aryDashboardWidgetRange[get_option('wp-piwik_dbwidget', 0)],
|
33 |
+
'capability_stealth' => get_option('wp-piwik_filter', array()),
|
34 |
+
'capability_read_stats' => $aryDisplayToCap,
|
35 |
+
'piwik_shortcut' => get_option('wp-piwik_piwiklink',false),
|
36 |
+
);
|
37 |
+
$this->installSite(false);
|
38 |
+
// Remove deprecated option values
|
39 |
+
$aryRemoveOptions = array(
|
40 |
+
'wp-piwik_disable_gapi','wp-piwik_displayto',
|
41 |
+
'wp-piwik_revision','wp-piwik_addjs','wp-piwik_settingsupdate','wp-piwik_token',
|
42 |
+
'wp-piwik_url','wp-piwik_dbwidget','wp-piwik_filter','wp-piwik_piwiklink'
|
43 |
+
);
|
44 |
+
foreach ($aryRemoveOptions as $strRemoveOption) {
|
45 |
+
if (self::$bolWPMU) delete_site_option($strRemoveOption);
|
46 |
+
else delete_option($strRemoveOption);
|
47 |
+
}
|
update/80502.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
self::$aryGlobalSettings['default_date'] = 'yesterday';
|
update/80602.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
self::$aryGlobalSettings['dashboard_chart'] = false;
|
update/80800.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
self::$aryGlobalSettings['piwik_url'] = self::check_url(self::$aryGlobalSettings['piwik_url']);
|
update/90001.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$aryWPMUConfig = get_site_option('wpmu-piwik_global-settings',false);
|
3 |
+
if (is_plugin_active_for_network('wp-piwik/wp-piwik.php') && $aryWPMUConfig) {
|
4 |
+
self::$aryGlobalSettings = $aryWPMUConfig;
|
5 |
+
delete_site_option('wpmu-piwik_global-settings');
|
6 |
+
self::$aryGlobalSettings['auto_site_config'] = true;
|
7 |
+
} else self::$aryGlobalSettings['auto_site_config'] = false;
|
8 |
+
self::$aryGlobalSettings['dashboard_seo'] = false;
|
9 |
+
self::$aryGlobalSettings['stats_seo'] = false;
|
10 |
+
self::$aryGlobalSettings['track_404'] = self::$arySettings['track_404'];
|
11 |
+
self::$aryGlobalSettings['track_compress'] = false;
|
12 |
+
self::$aryGlobalSettings['track_post'] = false;
|
wp-piwik.php
CHANGED
@@ -2,11 +2,11 @@
|
|
2 |
/*
|
3 |
Plugin Name: WP-Piwik
|
4 |
|
5 |
-
Plugin URI: http://
|
6 |
|
7 |
Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress footer.
|
8 |
|
9 |
-
Version: 0.
|
10 |
Author: André Bräkling
|
11 |
Author URI: http://www.braekling.de
|
12 |
|
@@ -27,44 +27,64 @@ Author URI: http://www.braekling.de
|
|
27 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
28 |
*******************************************************************************************/
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
33 |
if (!function_exists ('add_action')) {
|
34 |
header('Status: 403 Forbidden');
|
35 |
header('HTTP/1.1 403 Forbidden');
|
36 |
exit();
|
37 |
}
|
38 |
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
class wp_piwik {
|
43 |
|
44 |
private static
|
45 |
-
$intRevisionId =
|
46 |
-
$strVersion = '0.
|
47 |
$intDashboardID = 30,
|
48 |
-
$bolWPMU = false,
|
49 |
-
$bolOverall = false,
|
50 |
$strPluginBasename = NULL,
|
51 |
$aryGlobalSettings = array(
|
52 |
-
'revision' =>
|
53 |
'add_tracking_code' => false,
|
54 |
'last_settings_update' => 0,
|
55 |
'piwik_token' => '',
|
56 |
'piwik_url' => '',
|
57 |
'dashboard_widget' => false,
|
58 |
'dashboard_chart' => false,
|
|
|
|
|
59 |
'capability_stealth' => array(),
|
60 |
'capability_read_stats' => array('administrator' => true),
|
61 |
'piwik_shortcut' => false,
|
62 |
-
'default_date' => 'yesterday'
|
|
|
|
|
|
|
|
|
63 |
),
|
64 |
$arySettings = array(
|
65 |
'tracking_code' => '',
|
66 |
'site_id' => NULL,
|
67 |
-
'track_404' => false,
|
68 |
'last_tracking_code_update' => 0,
|
69 |
'dashboard_revision' => 0
|
70 |
);
|
@@ -76,15 +96,9 @@ class wp_piwik {
|
|
76 |
* Load plugin settings
|
77 |
*/
|
78 |
static function loadSettings() {
|
79 |
-
//
|
80 |
-
|
81 |
-
// Get
|
82 |
-
self::$aryGlobalSettings =
|
83 |
-
(self::$bolWPMU?
|
84 |
-
get_site_option('wpmu-piwik_global-settings',self::$aryGlobalSettings):
|
85 |
-
get_option('wp-piwik_global-settings',self::$aryGlobalSettings)
|
86 |
-
);
|
87 |
-
// Get mode-independent settings
|
88 |
self::$arySettings = get_option('wp-piwik_settings',self::$arySettings);
|
89 |
}
|
90 |
|
@@ -92,22 +106,24 @@ class wp_piwik {
|
|
92 |
* Save plugin settings
|
93 |
*/
|
94 |
static function saveSettings() {
|
95 |
-
// Save global settings
|
96 |
-
|
97 |
-
|
98 |
-
// Save mode-independent settings
|
99 |
update_option('wp-piwik_settings',self::$arySettings);
|
100 |
-
//
|
101 |
global $wp_roles;
|
102 |
-
if (is_object($wp_roles))
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
|
|
|
|
111 |
}
|
112 |
|
113 |
/**
|
@@ -117,7 +133,7 @@ class wp_piwik {
|
|
117 |
// Store plugin basename
|
118 |
self::$strPluginBasename = plugin_basename(__FILE__);
|
119 |
// Load current settings
|
120 |
-
self::loadSettings();
|
121 |
// Upgrade?
|
122 |
if (self::$aryGlobalSettings['revision'] < self::$intRevisionId) $this->install();
|
123 |
// Settings changed?
|
@@ -128,16 +144,23 @@ class wp_piwik {
|
|
128 |
// Call install function on activation
|
129 |
register_activation_hook(__FILE__, array($this, 'install'));
|
130 |
// Add meta links to plugin details
|
131 |
-
|
132 |
// Register columns
|
133 |
-
|
134 |
-
|
|
|
|
|
|
|
|
|
|
|
135 |
add_action('admin_menu', array($this, 'buildAdminMenu'));
|
136 |
// Register the callback been used if options of page been submitted and needs to be processed
|
137 |
add_action('admin_post_save_wp-piwik_stats', array(&$this, 'onStatsPageSaveChanges'));
|
138 |
// Add dashboard widget if enabled
|
139 |
-
|
140 |
-
|
|
|
|
|
141 |
// Add tracking code to footer if enabled
|
142 |
if (self::$aryGlobalSettings['add_tracking_code']) add_action('wp_footer', array($this, 'footer'));
|
143 |
}
|
@@ -147,68 +170,30 @@ class wp_piwik {
|
|
147 |
*/
|
148 |
function __destruct() {}
|
149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
/**
|
151 |
* Install or upgrade
|
152 |
*/
|
153 |
function install() {
|
154 |
// Update: Translate options
|
155 |
-
if (self::$aryGlobalSettings['revision'] < 80403)
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
else $aryDisplayToCap = array('administrator' => true);
|
167 |
-
// Build settings arrays
|
168 |
-
$aryDashboardWidgetRange = array(0 => false, 1 => 'yesterday', 2 => 'today', 3 => 'last30');
|
169 |
-
if (self::$bolWPMU) self::$aryGlobalSettings = array(
|
170 |
-
'revision' => get_site_option('wpmu-piwik_revision', 0),
|
171 |
-
'add_tracking_code' => true,
|
172 |
-
'last_settings_update' => get_site_option('wpmu-piwik_settingsupdate', time()),
|
173 |
-
'piwik_token' => get_site_option('wpmu-piwik_token', ''),
|
174 |
-
'piwik_url' => get_site_option('wpmu-piwik_url', ''),
|
175 |
-
'dashboard_widget' => false,
|
176 |
-
'capability_stealth' => get_site_option('wpmu-piwik_filter', array()),
|
177 |
-
'capability_read_stats' => $aryDisplayToCap,
|
178 |
-
'piwik_shortcut' => false,
|
179 |
-
);
|
180 |
-
else self::$aryGlobalSettings = array(
|
181 |
-
'revision' => get_option('wp-piwik_revision',0),
|
182 |
-
'add_tracking_code' => get_option('wp-piwik_addjs'),
|
183 |
-
'last_settings_update' => get_option('wp-piwik_settingsupdate', time()),
|
184 |
-
'piwik_token' => get_option('wp-piwik_token', ''),
|
185 |
-
'piwik_url' => get_option('wp-piwik_url', ''),
|
186 |
-
'dashboard_widget' => $aryDashboardWidgetRange[get_option('wp-piwik_dbwidget', 0)],
|
187 |
-
'capability_stealth' => get_option('wp-piwik_filter', array()),
|
188 |
-
'capability_read_stats' => $aryDisplayToCap,
|
189 |
-
'piwik_shortcut' => get_option('wp-piwik_piwiklink',false),
|
190 |
-
);
|
191 |
-
$this->installSite(false);
|
192 |
-
// Remove deprecated option values
|
193 |
-
$aryRemoveOptions = array(
|
194 |
-
'wp-piwik_disable_gapi','wp-piwik_displayto',
|
195 |
-
'wp-piwik_revision','wp-piwik_addjs','wp-piwik_settingsupdate','wp-piwik_token',
|
196 |
-
'wp-piwik_url','wp-piwik_dbwidget','wp-piwik_filter','wp-piwik_piwiklink'
|
197 |
-
);
|
198 |
-
foreach ($aryRemoveOptions as $strRemoveOption) {
|
199 |
-
if (self::$bolWPMU) delete_site_option($strRemoveOption);
|
200 |
-
else delete_option($strRemoveOption);
|
201 |
-
}
|
202 |
-
};
|
203 |
-
if (self::$aryGlobalSettings['revision'] < 80502) {
|
204 |
-
self::$aryGlobalSettings['default_date'] = 'yesterday';
|
205 |
-
}
|
206 |
-
if (self::$aryGlobalSettings['revision'] < 80602) {
|
207 |
-
self::$aryGlobalSettings['dashboard_chart'] = false;
|
208 |
-
}
|
209 |
-
if (self::$aryGlobalSettings['revision'] < 80800) {
|
210 |
-
self::$aryGlobalSettings['piwik_url'] = self::check_url(self::$aryGlobalSettings['piwik_url']);
|
211 |
-
}
|
212 |
add_action('admin_footer', array($this, 'updateMessage'));
|
213 |
// Set current revision ID
|
214 |
self::$aryGlobalSettings['revision'] = self::$intRevisionId;
|
@@ -220,42 +205,38 @@ class wp_piwik {
|
|
220 |
}
|
221 |
|
222 |
/**
|
223 |
-
*
|
224 |
*/
|
225 |
-
function
|
226 |
self::$arySettings = array(
|
227 |
'tracking_code' => '',
|
228 |
'site_id' => get_option('wp-piwik_siteid', NULL),
|
229 |
-
'track_404' => get_option('wp-piwik_404', false),
|
230 |
'last_tracking_code_update' => get_option('wp-piwik_scriptupdate', 0),
|
231 |
'dashboard_revision' => get_option('wp-piwik_dashboardid', 0)
|
232 |
);
|
233 |
-
|
234 |
// Remove deprecated option values
|
235 |
-
$aryRemoveOptions = array(
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
if ($bolSave) {
|
242 |
-
// Save upgraded or default settings
|
243 |
-
self::saveSettings();
|
244 |
-
// Reload settings
|
245 |
-
self::loadSettings();
|
246 |
-
}
|
247 |
}
|
248 |
|
249 |
/**
|
250 |
* Send a message after installing/updating
|
251 |
*/
|
252 |
function updateMessage() {
|
|
|
253 |
$strText = 'WP-Piwik '.self::$strVersion.' '.__('installed','wp-piwik').'.';
|
|
|
254 |
$strSettings = (empty(self::$aryGlobalSettings['piwik_token']) && empty(self::$aryGlobalSettings['piwik_url'])?
|
255 |
__('Next you should connect to Piwik','wp-piwik'):
|
256 |
__('Please validate your configuration','wp-piwik')
|
257 |
);
|
|
|
258 |
$strLink = sprintf('<a href="options-general.php?page=%s">%s</a>', self::$strPluginBasename, __('Settings', 'wp-piwik'));
|
|
|
259 |
echo '<div id="message" class="updated fade"><p>'.$strText.' '.$strSettings.': '.$strLink.'.</p></div>';
|
260 |
}
|
261 |
|
@@ -264,35 +245,29 @@ class wp_piwik {
|
|
264 |
*/
|
265 |
function footer() {
|
266 |
// Hotfix: Custom capability problem with WP multisite
|
267 |
-
if (
|
268 |
foreach (self::$aryGlobalSettings['capability_stealth'] as $strKey => $strVal)
|
269 |
if ($strVal && current_user_can($strKey))
|
270 |
return;
|
271 |
-
//
|
272 |
} elseif (current_user_can('wp-piwik_stealth')) return;
|
273 |
-
// Hotfix: Update
|
274 |
-
if (
|
275 |
-
//
|
276 |
-
if (
|
277 |
-
$aryReturn = $this->
|
278 |
self::$arySettings['tracking_code'] = $aryReturn['js'];
|
279 |
self::saveSettings();
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
self::$arySettings['tracking_code'] = html_entity_decode((is_string($strJSCode)?$strJSCode:'<!-- WP-Piwik ERROR: Tracking code not availbale -->'."\n"));
|
285 |
-
self::$arySettings['last_tracking_code_update'] = time();
|
286 |
-
self::saveSettings();
|
287 |
-
}
|
288 |
-
// Get code if not known
|
289 |
-
} elseif (empty($strJSCode)) {
|
290 |
-
$strJSCode = $this->call_API('SitesManager.getJavascriptTag');
|
291 |
self::$arySettings['tracking_code'] = html_entity_decode((is_string($strJSCode)?$strJSCode:'<!-- WP-Piwik ERROR: Tracking code not availbale -->'."\n"));
|
292 |
-
|
|
|
293 |
}
|
294 |
// Change code if 404
|
295 |
-
if (is_404() and self::$
|
296 |
else $strTrackingCode = self::$arySettings['tracking_code'];
|
297 |
// Send tracking code
|
298 |
echo '<!-- *** WP-Piwik - see http://www.braekling.de/wp-piwik-wpmu-piwik-wordpress/ -->'."\n";
|
@@ -303,84 +278,120 @@ class wp_piwik {
|
|
303 |
/**
|
304 |
* Add pages to admin menu
|
305 |
*/
|
306 |
-
function buildAdminMenu() {
|
307 |
// Show stats dashboard page if WP-Piwik is configured
|
308 |
if (!empty(self::$aryGlobalSettings['piwik_token']) && !empty(self::$aryGlobalSettings['piwik_url'])) {
|
309 |
// Add dashboard page
|
310 |
$this->intStatsPage = add_dashboard_page(
|
311 |
__('Piwik Statistics', 'wp-piwik'),
|
312 |
__('WP-Piwik', 'wp-piwik'),
|
313 |
-
|
314 |
'wp-piwik_stats',
|
315 |
array($this, 'showStats')
|
316 |
);
|
317 |
// Add required scripts
|
318 |
-
add_action('admin_print_scripts-'.$this->intStatsPage, array($this, '
|
319 |
// Add required styles
|
320 |
-
add_action('admin_print_styles-'.$this->intStatsPage, array($this, '
|
321 |
// Add required header tags
|
322 |
-
add_action('admin_head-'.$this->intStatsPage, array($this, '
|
323 |
// Stats page onload callback
|
324 |
add_action('load-'.$this->intStatsPage, array(&$this, 'onloadStatsPage'));
|
325 |
}
|
326 |
-
|
327 |
-
if (!self::$bolWPMU)
|
328 |
// Add options page
|
329 |
$intOptionsPage = add_options_page(
|
330 |
__('WP-Piwik', 'wp-piwik'),
|
331 |
__('WP-Piwik', 'wp-piwik'),
|
332 |
-
'activate_plugins',
|
333 |
__FILE__,
|
334 |
array($this, 'show_settings')
|
335 |
);
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
345 |
);
|
346 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
347 |
// Add styles required by options page
|
348 |
-
|
349 |
-
add_action('admin_print_styles-'.$intOptionsPage, array($this, 'add_admin_style'));
|
350 |
}
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
|
|
|
|
|
|
355 |
function onScreenLayoutColumns($aryColumns, $strScreen) {
|
356 |
if ($strScreen == $this->intStatsPage)
|
357 |
$aryColumns[$this->intStatsPage] = 4;
|
358 |
return $aryColumns;
|
359 |
}
|
360 |
|
361 |
-
|
|
|
|
|
|
|
|
|
362 |
if (current_user_can('wp-piwik_read_stats')) {
|
|
|
|
|
363 |
if (self::$aryGlobalSettings['dashboard_widget'])
|
364 |
-
$this->
|
|
|
365 |
if (self::$aryGlobalSettings['dashboard_chart']) {
|
366 |
// Add required scripts
|
367 |
-
add_action('admin_print_scripts-index.php', array($this, '
|
368 |
// Add required styles
|
369 |
-
add_action('admin_print_styles-index.php', array($this, '
|
370 |
// Add required header tags
|
371 |
-
add_action('admin_head-index.php', array($this, '
|
372 |
-
$this->
|
373 |
}
|
|
|
|
|
|
|
374 |
}
|
375 |
}
|
376 |
|
377 |
-
|
|
|
|
|
|
|
378 |
$aryConfig = array(
|
379 |
-
'params' => array(
|
380 |
-
'period' => 'day',
|
381 |
-
'date' => self::$aryGlobalSettings['dashboard_widget'],
|
382 |
-
'limit' => null
|
383 |
-
),
|
384 |
'inline' => true,
|
385 |
);
|
386 |
$strFile = 'overview';
|
@@ -398,13 +409,9 @@ class wp_piwik {
|
|
398 |
/**
|
399 |
* Add a visitor chart to the WordPress dashboard
|
400 |
*/
|
401 |
-
function
|
402 |
$aryConfig = array(
|
403 |
-
'params' => array(
|
404 |
-
'period' => 'day',
|
405 |
-
'date' => 'last30',
|
406 |
-
'limit' => null
|
407 |
-
),
|
408 |
'inline' => true,
|
409 |
);
|
410 |
$strFile = 'visitors';
|
@@ -419,6 +426,26 @@ class wp_piwik {
|
|
419 |
);
|
420 |
}
|
421 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
422 |
/**
|
423 |
* Add plugin meta links to plugin details
|
424 |
*
|
@@ -442,36 +469,36 @@ class wp_piwik {
|
|
442 |
/**
|
443 |
* Load required scripts to admin pages
|
444 |
*/
|
445 |
-
function
|
446 |
// Load WP-Piwik script
|
447 |
-
wp_enqueue_script('wp-piwik', $this->
|
448 |
// Load jqPlot
|
449 |
-
wp_enqueue_script('wp-piwik-jqplot',$this->
|
450 |
}
|
451 |
|
452 |
/**
|
453 |
* Load required styles to admin pages
|
454 |
*/
|
455 |
-
function
|
456 |
// Load WP-Piwik styles
|
457 |
-
wp_enqueue_style('wp-piwik', $this->
|
458 |
}
|
459 |
|
460 |
/**
|
461 |
* Add required header tags to admin pages
|
462 |
*/
|
463 |
-
function
|
464 |
// Load jqPlot IE compatibility script
|
465 |
-
echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.$this->
|
466 |
// Load jqPlot styles
|
467 |
-
echo '<link rel="stylesheet" href="'.$this->
|
468 |
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
|
469 |
}
|
470 |
|
471 |
/**
|
472 |
* Get this plugin's URL
|
473 |
*/
|
474 |
-
function
|
475 |
// Return plugins URL + /wp-piwik/
|
476 |
return trailingslashit(plugins_url().'/wp-piwik/');
|
477 |
}
|
@@ -481,7 +508,7 @@ class wp_piwik {
|
|
481 |
*
|
482 |
* @param String $strURL Remote file URL
|
483 |
*/
|
484 |
-
function
|
485 |
// Use cURL if available
|
486 |
if (function_exists('curl_init')) {
|
487 |
// Init cURL
|
@@ -507,61 +534,59 @@ class wp_piwik {
|
|
507 |
return $strResult;
|
508 |
}
|
509 |
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
if (self::$bolWPMU && empty($intSite)) {
|
517 |
-
$aryReturn = $this->create_wpmu_site();
|
518 |
-
$intSite = $aryReturn['id'];
|
519 |
-
}
|
520 |
-
if (self::$bolOverall) $intSite = 'all';
|
521 |
-
if (empty($strToken) || empty($strURL)) {
|
522 |
-
$this->aryCache[$key] = array(
|
523 |
-
'result' => 'error',
|
524 |
-
'message' => 'Piwik base URL or auth token not set.'
|
525 |
-
);
|
526 |
-
return $this->aryCache[$strKey];
|
527 |
-
}
|
528 |
-
$strURL .= '?module=API&method='.$strMethod;
|
529 |
-
$strURL .= '&idSite='.$intSite.'&period='.$strPeriod.'&date='.$strDate;
|
530 |
-
$strURL .= '&format=PHP&filter_limit='.$intLimit;
|
531 |
-
$strURL .= '&token_auth='.$strToken;
|
532 |
-
$strURL .= '&expanded='.$bolExpanded;
|
533 |
-
$strResult = $this->get_remote_file($strURL);
|
534 |
-
$this->aryCache[$strKey] = unserialize($strResult);
|
535 |
-
}
|
536 |
-
return $this->aryCache[$strKey];
|
537 |
-
}
|
538 |
-
|
539 |
-
function create_wpmu_site() {
|
540 |
$strURL = self::$aryGlobalSettings['piwik_url'];
|
541 |
-
|
542 |
-
if (
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
self::$
|
559 |
-
|
|
|
560 |
}
|
561 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
562 |
}
|
563 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
564 |
function createDashboardWidget($objPost, $aryMetabox) {
|
|
|
565 |
$strDesc = $strID = '';
|
566 |
$aryConfig = $aryMetabox['args']['aryConfig'];
|
567 |
foreach ($aryConfig['params'] as $strParam)
|
@@ -569,27 +594,75 @@ class wp_piwik {
|
|
569 |
$strDesc .= $strParam.', ';
|
570 |
$strID .= '_'.$strParam;
|
571 |
}
|
|
|
572 |
$strFile = str_replace('.', '', $aryMetabox['args']['strFile']);
|
|
|
573 |
$aryConf = array_merge($aryConfig, array(
|
574 |
'id' => $strFile.$strID,
|
575 |
'desc' => substr($strDesc, 0, -2)));
|
576 |
-
|
577 |
-
if (file_exists(
|
578 |
-
include(
|
579 |
}
|
580 |
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
588 |
}
|
|
|
589 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
590 |
|
591 |
function onloadStatsPage() {
|
592 |
-
|
593 |
wp_enqueue_script('wp-lists');
|
594 |
wp_enqueue_script('postbox');
|
595 |
$strToken = self::$aryGlobalSettings['piwik_token'];
|
@@ -599,10 +672,11 @@ class wp_piwik {
|
|
599 |
$arySortOrder = array(
|
600 |
'side' => array(
|
601 |
'overview' => array(__('Overview', 'wp-piwik'), 'day', 'yesterday'),
|
|
|
602 |
'pages' => array(__('Pages', 'wp-piwik'), 'day', 'yesterday'),
|
603 |
'keywords' => array(__('Keywords', 'wp-piwik'), 'day', 'yesterday', 10),
|
604 |
'websites' => array(__('Websites', 'wp-piwik'), 'day', 'yesterday', 10),
|
605 |
-
'plugins' => array(__('Plugins', 'wp-piwik'), 'day', 'yesterday')
|
606 |
),
|
607 |
'normal' => array(
|
608 |
'visitors' => array(__('Visitors', 'wp-piwik'), 'day', 'last30'),
|
@@ -611,6 +685,10 @@ class wp_piwik {
|
|
611 |
'systems' => array(__('Operating System', 'wp-piwik'), 'day', 'yesterday')
|
612 |
)
|
613 |
);
|
|
|
|
|
|
|
|
|
614 |
foreach ($arySortOrder as $strCol => $aryWidgets) {
|
615 |
if (is_array($aryWidgets)) foreach ($aryWidgets as $strFile => $aryParams) {
|
616 |
$aryDashboard[$strCol][$strFile] = array(
|
@@ -632,7 +710,7 @@ class wp_piwik {
|
|
632 |
$intSideBoxCnt++;
|
633 |
add_meta_box(
|
634 |
'wp-piwik_stats-sidebox-'.$intSideBoxCnt,
|
635 |
-
$aryConfig['params']['title'].' '
|
636 |
array(&$this, 'createDashboardWidget'),
|
637 |
$this->intStatsPage,
|
638 |
'side',
|
@@ -644,7 +722,7 @@ class wp_piwik {
|
|
644 |
$intContentBox++;
|
645 |
add_meta_box(
|
646 |
'wp-piwik_stats-contentbox-'.$intContentBox,
|
647 |
-
$aryConfig['params']['title'].' '
|
648 |
array(&$this, 'createDashboardWidget'),
|
649 |
$this->intStatsPage,
|
650 |
'normal',
|
@@ -662,21 +740,28 @@ class wp_piwik {
|
|
662 |
<?php screen_icon('options-general'); ?>
|
663 |
<h2><?php _e('Piwik Statistics', 'wp-piwik'); ?></h2>
|
664 |
<?php /************************************************************************/
|
665 |
-
if (
|
666 |
-
if (isset($_POST['wpmu_show_stats']))
|
667 |
-
switch_to_blog((int) $_POST['wpmu_show_stats']);
|
668 |
global $blog_id;
|
669 |
global $wpdb;
|
670 |
$aryBlogs = $wpdb->get_results($wpdb->prepare('SELECT blog_id FROM '.$wpdb->prefix.'blogs ORDER BY blog_id'));
|
671 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
672 |
echo '<select name="wpmu_show_stats">'."\n";
|
|
|
673 |
foreach ($aryBlogs as $aryBlog) {
|
674 |
$objBlog = get_blog_details($aryBlog->blog_id, true);
|
675 |
-
|
676 |
}
|
|
|
|
|
|
|
677 |
echo '</select><input type="submit" value="'.__('Change').'" />'."\n ";
|
678 |
-
|
679 |
-
else _e('Current shown stats: <strong>Overall</strong>');
|
680 |
echo '</form>'."\n";
|
681 |
}
|
682 |
/***************************************************************************/ ?>
|
@@ -687,11 +772,11 @@ class wp_piwik {
|
|
687 |
<input type="hidden" name="action" value="save_wp-piwik_stats_general" />
|
688 |
<div id="poststuff" class="metabox-holder has-right-sidebar" style="width:<?php echo 528+281; ?>px;">
|
689 |
<div id="side-info-column" class="inner-sidebar wp-piwik-side">
|
690 |
-
<?php do_meta_boxes($this->intStatsPage, 'side',
|
691 |
</div>
|
692 |
<div id="post-body" class="has-sidebar">
|
693 |
<div id="post-body-content" class="postbox-container has-sidebar-content">
|
694 |
-
<?php $meta_boxes = do_meta_boxes($this->intStatsPage, 'normal',
|
695 |
</div>
|
696 |
</div>
|
697 |
<br class="clear"/>
|
@@ -709,8 +794,8 @@ class wp_piwik {
|
|
709 |
//]]>
|
710 |
</script>
|
711 |
<?php /************************************************************************/
|
712 |
-
if (
|
713 |
-
restore_current_blog();
|
714 |
}
|
715 |
}
|
716 |
|
@@ -728,21 +813,35 @@ class wp_piwik {
|
|
728 |
wp_redirect($_POST['_wp_http_referer']);
|
729 |
}
|
730 |
|
|
|
|
|
|
|
731 |
function applySettings() {
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
self::$aryGlobalSettings['default_date'] = (isset($_POST['wp-piwik_default_date'])?$_POST['wp-piwik_default_date']:'yesterday');
|
740 |
-
}
|
741 |
self::$aryGlobalSettings['piwik_token'] = (isset($_POST['wp-piwik_token'])?$_POST['wp-piwik_token']:'');
|
742 |
self::$aryGlobalSettings['piwik_url'] = self::check_url((isset($_POST['wp-piwik_url'])?$_POST['wp-piwik_url']:''));
|
743 |
self::$aryGlobalSettings['capability_stealth'] = (isset($_POST['wp-piwik_filter'])?$_POST['wp-piwik_filter']:array());
|
744 |
self::$aryGlobalSettings['capability_read_stats'] = (isset($_POST['wp-piwik_displayto'])?$_POST['wp-piwik_displayto']:array());
|
745 |
self::$aryGlobalSettings['last_settings_update'] = time();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
746 |
self::saveSettings();
|
747 |
}
|
748 |
|
@@ -756,12 +855,43 @@ class wp_piwik {
|
|
756 |
$strToken = self::$aryGlobalSettings['piwik_token'];
|
757 |
$strURL = self::$aryGlobalSettings['piwik_url'];
|
758 |
$intSite = self::$arySettings['site_id'];
|
759 |
-
if (isset($_POST['action']) && $_POST['action'] == 'save_settings')
|
760 |
echo '<div id="message" class="updated fade"><p>'.__('Changes saved','wp-piwik').'</p></div>';
|
|
|
761 |
/***************************************************************************/ ?>
|
762 |
<div class="wrap">
|
763 |
<h2><?php _e('WP-Piwik Settings', 'wp-piwik') ?></h2>
|
764 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
765 |
<form method="post" action="">
|
766 |
<div id="dashboard-widgets-wrap">
|
767 |
<div id="dashboard-widgets" class="metabox-holder">
|
@@ -793,9 +923,19 @@ class wp_piwik {
|
|
793 |
'wp-piwik'
|
794 |
); ?>
|
795 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
796 |
<?php /************************************************************************/
|
797 |
if (!empty($strToken) && !empty($strURL)) {
|
798 |
-
$aryData = $this->
|
799 |
if (empty($aryData)) {
|
800 |
echo '<div class="wp-piwik_desc"><strong>'.__('An error occured', 'wp-piwik').': </strong>'.
|
801 |
__('Please check URL and auth token. You need at least view access to one site.', 'wp-piwik').
|
@@ -804,25 +944,47 @@ class wp_piwik {
|
|
804 |
echo '<div class="wp-piwik_desc"><strong><strong>'.__('An error occured', 'wp-piwik').
|
805 |
': </strong>'.$aryData['message'].'</div>';
|
806 |
} else {
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
'
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
818 |
}
|
819 |
$intSite = self::$arySettings['site_id'];
|
820 |
-
$int404 = self::$
|
821 |
$intAddJS = self::$aryGlobalSettings['add_tracking_code'];
|
822 |
$intDashboardWidget = self::$aryGlobalSettings['dashboard_widget'];
|
823 |
$intShowLink = self::$aryGlobalSettings['piwik_shortcut'];
|
824 |
-
$strJavaScript = html_entity_decode($this->
|
825 |
if ($intAddJS) {
|
|
|
|
|
|
|
826 |
self::$arySettings['tracking_code'] = $strJavaScript;
|
827 |
self::saveSettings();
|
828 |
}
|
@@ -848,9 +1010,26 @@ class wp_piwik {
|
|
848 |
'<div class="input-wrap"><input type="checkbox" value="1" id="wp-piwik_404" name="wp-piwik_404" '.
|
849 |
($int404?' checked="checked"':'').'/></div>';
|
850 |
echo '<div class="wp-piwik_desc">'.
|
851 |
-
__('If you add the Piwik javascript code by wp_footer(), '.
|
852 |
-
'WP-Piwik can automatically add a 404-category to track 404-page-visits.', 'wp-piwik').
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
853 |
'</div>';
|
|
|
854 |
global $wp_roles;
|
855 |
echo '<h4><label>'.__('Tracking filter', 'wp-piwik').':</label></h4>';
|
856 |
echo '<div class="input-wrap">';
|
@@ -870,27 +1049,27 @@ class wp_piwik {
|
|
870 |
<h3 class='hndle'><span><?php _e('Statistic view settings', 'wp-piwik'); ?></span></h3>
|
871 |
<div class="inside">
|
872 |
<?php
|
873 |
-
echo '<h4><label for="wp-piwik_dbwidget">'.__('Dashboard
|
874 |
'<div class="input-wrap"><select id="wp-piwik_dbwidget" name="wp-piwik_dbwidget">'.
|
875 |
-
'<option value="0"'.(!$intDashboardWidget?' selected="selected"':'').'>'.__('
|
876 |
-
'<option value="yesterday"'.($intDashboardWidget == 'yesterday'?' selected="selected"':'').'>'.__('
|
877 |
-
'<option value="today"'.($intDashboardWidget == 'today'?' selected="selected"':'').'>'.__('
|
878 |
-
'<option value="last30"'.($intDashboardWidget == 'last30'?' selected="selected"':'').'>'.__('
|
879 |
-
'</select
|
880 |
-
echo '<
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
(self::$aryGlobalSettings['dashboard_chart']?' checked="checked"':"").'/></div>';
|
886 |
echo '<div class="wp-piwik_desc">'.
|
887 |
-
__('
|
888 |
-
|
889 |
echo '<h4><label for="wp-piwik_piwiklink">'.__('Shortcut', 'wp-piwik').':</label></h4>'.
|
890 |
'<div class="input-wrap"><input type="checkbox" value="1" name="wp-piwik_piwiklink" id="wp-piwik_piwiklink" '.
|
891 |
($intShowLink?' checked="checked"':"").'/></div>';
|
892 |
echo '<div class="wp-piwik_desc">'.
|
893 |
__('Display a shortcut to Piwik itself.', 'wp-piwik').'</div>';
|
|
|
894 |
echo '<h4><label for="wp-piwik_default_date">'.__('Default date', 'wp-piwik').':</label></h4>'.
|
895 |
'<div class="input-wrap"><select id="wp-piwik_default_date" name="wp-piwik_default_date">'.
|
896 |
'<option value="yesterday"'.(self::$aryGlobalSettings['default_date'] == 'yesterday'?' selected="selected"':'').'> '.__('yesterday', 'wp-piwik').'</option>'.
|
@@ -898,6 +1077,13 @@ class wp_piwik {
|
|
898 |
'</select></div>';
|
899 |
echo '<div class="wp-piwik_desc">'.
|
900 |
__('Default date shown on statistics page.', 'wp-piwik').'</div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
901 |
echo '<h4><label>'.__('Display to', 'wp-piwik').':</label></h4>';
|
902 |
echo '<div class="input-wrap">';
|
903 |
$intDisplayTo = self::$aryGlobalSettings['capability_read_stats'];
|
@@ -924,97 +1110,6 @@ class wp_piwik {
|
|
924 |
<?php /************************************************************************/
|
925 |
}
|
926 |
|
927 |
-
function show_mu_settings() {
|
928 |
-
$strToken = self::$aryGlobalSettings['piwik_token'];
|
929 |
-
$strURL = self::$aryGlobalSettings['piwik_url'];
|
930 |
-
if (isset($_POST['action']) && $_POST['action'] == 'save_settings')
|
931 |
-
echo '<div id="message" class="updated fade"><p>'.__('Changes saved','wp-piwik').'</p></div>';
|
932 |
-
/***************************************************************************/ ?>
|
933 |
-
<div class="wrap">
|
934 |
-
<h2><?php _e('WPMU-Piwik Settings', 'wp-piwik') ?></h2>
|
935 |
-
<?php $this->donate(); ?>
|
936 |
-
<form method="post" action="">
|
937 |
-
<div id="dashboard-widgets-wrap">
|
938 |
-
<div id="dashboard-widgets" class="metabox-holder">
|
939 |
-
<div class="wp-piwik-settings-container" id="postbox-container">
|
940 |
-
<div class="postbox wp-piwik-settings" >
|
941 |
-
<h3 class='hndle'><span><?php _e('Account settings', 'wp-piwik'); ?></span></h3>
|
942 |
-
<div class="inside">
|
943 |
-
<h4><label for="wp-piwik_url"><?php _e('Piwik URL', 'wp-piwik'); ?>:</label></h4>
|
944 |
-
<div class="input-text-wrap">
|
945 |
-
<input type="text" name="wp-piwik_url" id="wp-piwik_url" value="<?php echo $strURL; ?>" />
|
946 |
-
</div>
|
947 |
-
<h4><label for="wp-piwik_token"><?php _e('Auth token', 'wp-piwik'); ?>:</label></h4>
|
948 |
-
<div class="input-text-wrap">
|
949 |
-
<input type="text" name="wp-piwik_token" id="wp-piwik_token" value="<?php echo $strToken; ?>" />
|
950 |
-
</div>
|
951 |
-
<div class="wp-piwik_desc">
|
952 |
-
<?php _e(
|
953 |
-
'To enable Piwik statistics, please enter your Piwik'.
|
954 |
-
' base URL (like http://mydomain.com/piwik) and your'.
|
955 |
-
' personal authentification token. You can get the token'.
|
956 |
-
' on the API page inside your Piwik interface. It looks'.
|
957 |
-
' like "1234a5cd6789e0a12345b678cd9012ef".'
|
958 |
-
, 'wp-piwik'
|
959 |
-
); ?>
|
960 |
-
</div>
|
961 |
-
<div class="wp-piwik_desc">
|
962 |
-
<?php _e(
|
963 |
-
'<strong>Important note:</strong> You have to choose a token which provides administration access. WPMU-Piwik will create new Piwik sites for each blog if it is shown the first time and it is not added yet. All users can access their own statistics only, while site admins can access all statistics. To avoid conflicts, you should use a clean Piwik installation without other sites added. The provided themes should use wp_footer, because it adds the Piwik javascript code to each page.', 'wp-piwik');
|
964 |
-
?>
|
965 |
-
</div>
|
966 |
-
<?php /************************************************************************/
|
967 |
-
if (!empty($strToken) && !empty($strURL)) {
|
968 |
-
global $wp_roles;
|
969 |
-
echo '<h4><label>'.__('Tracking filter', 'wp-piwik').':</label></h4>';
|
970 |
-
echo '<div class="input-wrap">';
|
971 |
-
$aryFilter = self::$aryGlobalSettings['capability_stealth'];
|
972 |
-
foreach($wp_roles->role_names as $strKey => $strName) {
|
973 |
-
echo '<input type="checkbox" '.(isset($aryFilter[$strKey]) && $aryFilter[$strKey]?'checked="checked" ':'').'value="1" name="wp-piwik_filter['.$strKey.']" /> '.$strName.' ';
|
974 |
-
};
|
975 |
-
echo '</div>';
|
976 |
-
echo '<div class="wp-piwik_desc">'.
|
977 |
-
__('Choose users by user role you do <strong>not</strong> want to track.', 'wp-piwik').'</div>';
|
978 |
-
}
|
979 |
-
/***************************************************************************/ ?>
|
980 |
-
<div><input type="submit" name="Submit" value="<?php _e('Save settings', 'wp-piwik') ?>" /></div>
|
981 |
-
</div>
|
982 |
-
</div>
|
983 |
-
</div>
|
984 |
-
<input type="hidden" name="action" value="save_settings" />
|
985 |
-
</div></div>
|
986 |
-
</form>
|
987 |
-
<?php $this->credits(); ?>
|
988 |
-
</div>
|
989 |
-
<?php /************************************************************************/
|
990 |
-
}
|
991 |
-
|
992 |
-
function donate() {
|
993 |
-
/***************************************************************************/ ?>
|
994 |
-
<div class="wp-piwik-sidebox">
|
995 |
-
<strong>Donate</strong>
|
996 |
-
<p><?php _e('If you like WP-Piwik, you can support its development by a donation:', 'wp-piwik'); ?></p>
|
997 |
-
<div>
|
998 |
-
<script type="text/javascript">
|
999 |
-
var flattr_url = 'http://www.braekling.de/wp-piwik-wpmu-piwik-wordpress';
|
1000 |
-
</script>
|
1001 |
-
<script src="http<?php echo (self::isSSL()?'s':''); ?>://api.flattr.com/button/load.js" type="text/javascript"></script>
|
1002 |
-
</div>
|
1003 |
-
<div>Paypal
|
1004 |
-
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
1005 |
-
<input type="hidden" name="cmd" value="_s-xclick" />
|
1006 |
-
<input type="hidden" name="hosted_button_id" value="6046779" />
|
1007 |
-
<input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_donateCC_LG.gif" name="submit" alt="PayPal - The safer, easier way to pay online." />
|
1008 |
-
<img alt="" border="0" src="https://www.paypal.com/de_DE/i/scr/pixel.gif" width="1" height="1" />
|
1009 |
-
</form>
|
1010 |
-
</div>
|
1011 |
-
<div>
|
1012 |
-
<a href="http://www.amazon.de/gp/registry/wishlist/111VUJT4HP1RA?reveal=unpurchased&filter=all&sort=priority&layout=standard&x=12&y=14"><?php _e('My Amazon.de wishlist (German)', 'wp-piwik'); ?></a>
|
1013 |
-
</div>
|
1014 |
-
</div>
|
1015 |
-
<?php /************************************************************************/
|
1016 |
-
}
|
1017 |
-
|
1018 |
private static function isSSL() {
|
1019 |
return (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off');
|
1020 |
}
|
@@ -1023,9 +1118,9 @@ class wp_piwik {
|
|
1023 |
/***************************************************************************/ ?>
|
1024 |
<h2 style="clear:left;"><?php _e('Credits', 'wp-piwik'); ?></h2>
|
1025 |
<div class="inside">
|
1026 |
-
<p><strong><?php _e('Thank you very much for your donation', 'wp-piwik'); ?>:</strong> Marco L., Rolf W., Tobias U., Lars K., Donna F
|
1027 |
<p><?php _e('Graphs powered by <a href="http://www.jqplot.com/">jqPlot</a>, an open source project by Chris Leonello. Give it a try! (License: GPL 2.0 and MIT)','wp-piwik'); ?></p>
|
1028 |
-
<p><?php _e('Metabox support inspired by <a href="http://www.code-styling.de/english/how-to-use-wordpress-metaboxes-at-own-plugins">Heiko Rabe\'s metabox demo plugin</a>.'
|
1029 |
<p><?php _e('Thank you very much','wp-piwik'); ?>, <a href="http://blogu.programeshqip.org/">Besnik Bleta</a>, <a href="http://www.fatcow.com/">FatCow</a>, <a href="http://www.pamukkaleturkey.com/">Rene</a>, Fab, <a href="http://ezbizniz.com/">EzBizNiz</a>, Gormer, Natalya, <a href="www.aggeliopolis.gr">AggelioPolis</a><?php _e(', and', 'wp-piwik'); ?> <a href="http://wwww.webhostinggeeks.com">Galina Miklosic</a> <?php _e('for your translation work','wp-piwik'); ?>!</p>
|
1030 |
<p><?php _e('Thank you very much, all users who send me mails containing criticism, commendation, feature requests and bug reports! You help me to make WP-Piwik much better.','wp-piwik'); ?></p>
|
1031 |
<p><?php _e('Thank <strong>you</strong> for using my plugin. It is the best commendation if my piece of code is really used!','wp-piwik'); ?></p>
|
2 |
/*
|
3 |
Plugin Name: WP-Piwik
|
4 |
|
5 |
+
Plugin URI: http://wordpress.org/extend/plugins/wp-piwik/
|
6 |
|
7 |
Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress footer.
|
8 |
|
9 |
+
Version: 0.9.0
|
10 |
Author: André Bräkling
|
11 |
Author URI: http://www.braekling.de
|
12 |
|
27 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
28 |
*******************************************************************************************/
|
29 |
|
30 |
+
/**
|
31 |
+
* Avoid direct calls to this file if wp core files not present
|
32 |
+
* seen (as some other parts) in Heiko Rabe's metabox demo plugin
|
33 |
+
*
|
34 |
+
* @see http://tinyurl.com/5r5vnzs
|
35 |
+
*/
|
36 |
if (!function_exists ('add_action')) {
|
37 |
header('Status: 403 Forbidden');
|
38 |
header('HTTP/1.1 403 Forbidden');
|
39 |
exit();
|
40 |
}
|
41 |
|
42 |
+
/**
|
43 |
+
* Makes sure /wp-admin/includes/plugin.php is loaded before trying to use it
|
44 |
+
*
|
45 |
+
* @see http://codex.wordpress.org/Function_Reference/is_plugin_active_for_network
|
46 |
+
*/
|
47 |
+
if (!function_exists('is_plugin_active_for_network'))
|
48 |
+
require_once(ABSPATH.'/wp-admin/includes/plugin.php');
|
49 |
+
|
50 |
+
/*****************************************************************************************
|
51 |
+
IMPORTANT NOTICE - WPMU - MULTISITE - NETWORK
|
52 |
+
******************************************************************************************
|
53 |
+
If you are using WP-Piwik as WordPress Network Plugin (Multisite/"WPMU"),
|
54 |
+
you don't have to change values anymore.
|
55 |
+
PLEASE BACKUP YOUR WP & DATABASE _BEFORE_ TESTING THIS NEW WP-PIWIK RELEASE.
|
56 |
+
REMEMBER: MULTISITE SUPPORT IS STILL EXPERIMENTAL. USE AT YOUR OWN RISK.
|
57 |
+
******************************************************************************************/
|
58 |
|
59 |
class wp_piwik {
|
60 |
|
61 |
private static
|
62 |
+
$intRevisionId = 90001,
|
63 |
+
$strVersion = '0.9.0',
|
64 |
$intDashboardID = 30,
|
|
|
|
|
65 |
$strPluginBasename = NULL,
|
66 |
$aryGlobalSettings = array(
|
67 |
+
'revision' => 90001,
|
68 |
'add_tracking_code' => false,
|
69 |
'last_settings_update' => 0,
|
70 |
'piwik_token' => '',
|
71 |
'piwik_url' => '',
|
72 |
'dashboard_widget' => false,
|
73 |
'dashboard_chart' => false,
|
74 |
+
'dashboard_seo' => false,
|
75 |
+
'stats_seo' => false,
|
76 |
'capability_stealth' => array(),
|
77 |
'capability_read_stats' => array('administrator' => true),
|
78 |
'piwik_shortcut' => false,
|
79 |
+
'default_date' => 'yesterday',
|
80 |
+
'auto_site_config' => true,
|
81 |
+
'track_404' => false,
|
82 |
+
'track_compress' => false,
|
83 |
+
'track_post' => false
|
84 |
),
|
85 |
$arySettings = array(
|
86 |
'tracking_code' => '',
|
87 |
'site_id' => NULL,
|
|
|
88 |
'last_tracking_code_update' => 0,
|
89 |
'dashboard_revision' => 0
|
90 |
);
|
96 |
* Load plugin settings
|
97 |
*/
|
98 |
static function loadSettings() {
|
99 |
+
// Get global settings
|
100 |
+
self::$aryGlobalSettings = get_site_option('wp-piwik_global-settings',self::$aryGlobalSettings);
|
101 |
+
// Get site settings
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
self::$arySettings = get_option('wp-piwik_settings',self::$arySettings);
|
103 |
}
|
104 |
|
106 |
* Save plugin settings
|
107 |
*/
|
108 |
static function saveSettings() {
|
109 |
+
// Save global settings
|
110 |
+
update_site_option('wp-piwik_global-settings',self::$aryGlobalSettings);
|
111 |
+
// Save site settings
|
|
|
112 |
update_option('wp-piwik_settings',self::$arySettings);
|
113 |
+
// Load WP_Roles class
|
114 |
global $wp_roles;
|
115 |
+
if (!is_object($wp_roles))
|
116 |
+
$wp_roles = new WP_Roles();
|
117 |
+
if (!is_object($wp_roles)) die("STILL NO OBJECT");
|
118 |
+
// Assign capabilities to roles
|
119 |
+
foreach($wp_roles->role_names as $strKey => $strName) {
|
120 |
+
$objRole = get_role($strKey);
|
121 |
+
foreach (array('stealth', 'read_stats') as $strCap)
|
122 |
+
if (isset(self::$aryGlobalSettings['capability_'.$strCap][$strKey]) && self::$aryGlobalSettings['capability_'.$strCap][$strKey])
|
123 |
+
$objRole->add_cap('wp-piwik_'.$strCap);
|
124 |
+
else
|
125 |
+
$objRole->remove_cap('wp-piwik_'.$strCap);
|
126 |
+
}
|
127 |
}
|
128 |
|
129 |
/**
|
133 |
// Store plugin basename
|
134 |
self::$strPluginBasename = plugin_basename(__FILE__);
|
135 |
// Load current settings
|
136 |
+
self::loadSettings();
|
137 |
// Upgrade?
|
138 |
if (self::$aryGlobalSettings['revision'] < self::$intRevisionId) $this->install();
|
139 |
// Settings changed?
|
144 |
// Call install function on activation
|
145 |
register_activation_hook(__FILE__, array($this, 'install'));
|
146 |
// Add meta links to plugin details
|
147 |
+
add_filter('plugin_row_meta', array($this, 'setPluginMeta'), 10, 2);
|
148 |
// Register columns
|
149 |
+
/* TODO: currently not working
|
150 |
+
* add_filter('screen_layout_columns', array(&$this, 'onScreenLayoutColumns'), 10, 2);
|
151 |
+
*/
|
152 |
+
// Add network admin menu if required
|
153 |
+
if (is_plugin_active_for_network('wp-piwik/wp-piwik.php'))
|
154 |
+
add_action('network_admin_menu', array($this, 'buildNetworkAdminMenu'));
|
155 |
+
// Add admin menu
|
156 |
add_action('admin_menu', array($this, 'buildAdminMenu'));
|
157 |
// Register the callback been used if options of page been submitted and needs to be processed
|
158 |
add_action('admin_post_save_wp-piwik_stats', array(&$this, 'onStatsPageSaveChanges'));
|
159 |
// Add dashboard widget if enabled
|
160 |
+
/* TODO: Use bitmask here
|
161 |
+
*/
|
162 |
+
if (self::$aryGlobalSettings['dashboard_widget'] || self::$aryGlobalSettings['dashboard_chart'] || self::$aryGlobalSettings['dashboard_seo'])
|
163 |
+
add_action('wp_dashboard_setup', array($this, 'extendWordPressDashboard'));
|
164 |
// Add tracking code to footer if enabled
|
165 |
if (self::$aryGlobalSettings['add_tracking_code']) add_action('wp_footer', array($this, 'footer'));
|
166 |
}
|
170 |
*/
|
171 |
function __destruct() {}
|
172 |
|
173 |
+
/**
|
174 |
+
* Include WP-Piwik files
|
175 |
+
*/
|
176 |
+
private function includeFile($strFile) {
|
177 |
+
if (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR.$strFile.'.php'))
|
178 |
+
include(dirname(__FILE__).DIRECTORY_SEPARATOR.$strFile.'.php');
|
179 |
+
}
|
180 |
+
|
181 |
/**
|
182 |
* Install or upgrade
|
183 |
*/
|
184 |
function install() {
|
185 |
// Update: Translate options
|
186 |
+
if (self::$aryGlobalSettings['revision'] < 80403)
|
187 |
+
self::includeFile('update/80403.php');
|
188 |
+
if (self::$aryGlobalSettings['revision'] < 80502)
|
189 |
+
self::includeFile('update/80502.php');
|
190 |
+
if (self::$aryGlobalSettings['revision'] < 80602)
|
191 |
+
self::includeFile('update/80602.php');
|
192 |
+
if (self::$aryGlobalSettings['revision'] < 80800)
|
193 |
+
self::includeFile('update/80800.php');
|
194 |
+
if (self::$aryGlobalSettings['revision'] < 90001)
|
195 |
+
self::includeFile('update/90001.php');
|
196 |
+
// Show an info message after upgrade/install
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
add_action('admin_footer', array($this, 'updateMessage'));
|
198 |
// Set current revision ID
|
199 |
self::$aryGlobalSettings['revision'] = self::$intRevisionId;
|
205 |
}
|
206 |
|
207 |
/**
|
208 |
+
* Upgrade outdated site settings
|
209 |
*/
|
210 |
+
function updateSite() {
|
211 |
self::$arySettings = array(
|
212 |
'tracking_code' => '',
|
213 |
'site_id' => get_option('wp-piwik_siteid', NULL),
|
|
|
214 |
'last_tracking_code_update' => get_option('wp-piwik_scriptupdate', 0),
|
215 |
'dashboard_revision' => get_option('wp-piwik_dashboardid', 0)
|
216 |
);
|
|
|
217 |
// Remove deprecated option values
|
218 |
+
$aryRemoveOptions = array('wp-piwik_siteid','wp-piwik_404','wp-piwik_scriptupdate','wp-piwik_dashboardid','wp-piwik_jscode');
|
219 |
+
foreach ($aryRemoveOptions as $strRemoveOption) delete_option($strRemoveOption);
|
220 |
+
// Save upgraded or default settings
|
221 |
+
self::saveSettings();
|
222 |
+
// Reload settings
|
223 |
+
self::loadSettings();
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
}
|
225 |
|
226 |
/**
|
227 |
* Send a message after installing/updating
|
228 |
*/
|
229 |
function updateMessage() {
|
230 |
+
// Message text
|
231 |
$strText = 'WP-Piwik '.self::$strVersion.' '.__('installed','wp-piwik').'.';
|
232 |
+
// Next step information
|
233 |
$strSettings = (empty(self::$aryGlobalSettings['piwik_token']) && empty(self::$aryGlobalSettings['piwik_url'])?
|
234 |
__('Next you should connect to Piwik','wp-piwik'):
|
235 |
__('Please validate your configuration','wp-piwik')
|
236 |
);
|
237 |
+
// Create settings Link
|
238 |
$strLink = sprintf('<a href="options-general.php?page=%s">%s</a>', self::$strPluginBasename, __('Settings', 'wp-piwik'));
|
239 |
+
// Display message
|
240 |
echo '<div id="message" class="updated fade"><p>'.$strText.' '.$strSettings.': '.$strLink.'.</p></div>';
|
241 |
}
|
242 |
|
245 |
*/
|
246 |
function footer() {
|
247 |
// Hotfix: Custom capability problem with WP multisite
|
248 |
+
if (is_multisite()) {
|
249 |
foreach (self::$aryGlobalSettings['capability_stealth'] as $strKey => $strVal)
|
250 |
if ($strVal && current_user_can($strKey))
|
251 |
return;
|
252 |
+
// Don't add tracking code?
|
253 |
} elseif (current_user_can('wp-piwik_stealth')) return;
|
254 |
+
// Hotfix: Update network site if not done yet
|
255 |
+
if (is_plugin_active_for_network('wp-piwik/wp-piwik.php') && get_option('wp-piwik_siteid', false)) $this->updateSite();
|
256 |
+
// Autohandle site if no tracking code available
|
257 |
+
if (empty(self::$arySettings['tracking_code'])) {
|
258 |
+
$aryReturn = $this->addPiwikSite();
|
259 |
self::$arySettings['tracking_code'] = $aryReturn['js'];
|
260 |
self::saveSettings();
|
261 |
+
}
|
262 |
+
// Update/get code if outdated/unknown
|
263 |
+
if (self::$arySettings['last_tracking_code_update'] < self::$aryGlobalSettings['last_settings_update'] || empty(self::$arySettings['tracking_code'])) {
|
264 |
+
$strJSCode = $this->callPiwikAPI('SitesManager.getJavascriptTag');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
self::$arySettings['tracking_code'] = html_entity_decode((is_string($strJSCode)?$strJSCode:'<!-- WP-Piwik ERROR: Tracking code not availbale -->'."\n"));
|
266 |
+
self::$arySettings['last_tracking_code_update'] = time();
|
267 |
+
self::saveSettings();
|
268 |
}
|
269 |
// Change code if 404
|
270 |
+
if (is_404() and self::$aryGlobalSettings['track_404']) $strTrackingCode = str_replace('piwikTracker.trackPageView();', 'piwikTracker.setDocumentTitle(\'404/URL = \'+encodeURIComponent(document.location.pathname+document.location.search) + \'/From = \' + encodeURIComponent(document.referrer));piwikTracker.trackPageView();', self::$arySettings['tracking_code']);
|
271 |
else $strTrackingCode = self::$arySettings['tracking_code'];
|
272 |
// Send tracking code
|
273 |
echo '<!-- *** WP-Piwik - see http://www.braekling.de/wp-piwik-wpmu-piwik-wordpress/ -->'."\n";
|
278 |
/**
|
279 |
* Add pages to admin menu
|
280 |
*/
|
281 |
+
function buildAdminMenu() {
|
282 |
// Show stats dashboard page if WP-Piwik is configured
|
283 |
if (!empty(self::$aryGlobalSettings['piwik_token']) && !empty(self::$aryGlobalSettings['piwik_url'])) {
|
284 |
// Add dashboard page
|
285 |
$this->intStatsPage = add_dashboard_page(
|
286 |
__('Piwik Statistics', 'wp-piwik'),
|
287 |
__('WP-Piwik', 'wp-piwik'),
|
288 |
+
'wp-piwik_read_stats',
|
289 |
'wp-piwik_stats',
|
290 |
array($this, 'showStats')
|
291 |
);
|
292 |
// Add required scripts
|
293 |
+
add_action('admin_print_scripts-'.$this->intStatsPage, array($this, 'loadScripts'));
|
294 |
// Add required styles
|
295 |
+
add_action('admin_print_styles-'.$this->intStatsPage, array($this, 'addAdminStyle'));
|
296 |
// Add required header tags
|
297 |
+
add_action('admin_head-'.$this->intStatsPage, array($this, 'addAdminHeader'));
|
298 |
// Stats page onload callback
|
299 |
add_action('load-'.$this->intStatsPage, array(&$this, 'onloadStatsPage'));
|
300 |
}
|
301 |
+
if (!is_plugin_active_for_network('wp-piwik/wp-piwik.php')) {
|
|
|
302 |
// Add options page
|
303 |
$intOptionsPage = add_options_page(
|
304 |
__('WP-Piwik', 'wp-piwik'),
|
305 |
__('WP-Piwik', 'wp-piwik'),
|
306 |
+
'activate_plugins',
|
307 |
__FILE__,
|
308 |
array($this, 'show_settings')
|
309 |
);
|
310 |
+
// Add styles required by options page
|
311 |
+
add_action('admin_print_styles-'.$intOptionsPage, array($this, 'addAdminStyle'));
|
312 |
+
}
|
313 |
+
}
|
314 |
+
|
315 |
+
/**
|
316 |
+
* Add pages to network admin menu
|
317 |
+
*/
|
318 |
+
function buildNetworkAdminMenu() {
|
319 |
+
// Show stats dashboard page if WP-Piwik is configured
|
320 |
+
if (!empty(self::$aryGlobalSettings['piwik_token']) && !empty(self::$aryGlobalSettings['piwik_url'])) {
|
321 |
+
// Add dashboard page
|
322 |
+
$this->intStatsPage = add_dashboard_page(
|
323 |
+
__('Piwik Statistics', 'wp-piwik'),
|
324 |
+
__('WP-Piwik', 'wp-piwik'),
|
325 |
+
'manage_sites',
|
326 |
+
'wp-piwik_stats',
|
327 |
+
array($this, 'showStats')
|
328 |
);
|
329 |
+
// Add required scripts
|
330 |
+
add_action('admin_print_scripts-'.$this->intStatsPage, array($this, 'loadScripts'));
|
331 |
+
// Add required styles
|
332 |
+
add_action('admin_print_styles-'.$this->intStatsPage, array($this, 'addAdminStyle'));
|
333 |
+
// Add required header tags
|
334 |
+
add_action('admin_head-'.$this->intStatsPage, array($this, 'addAdminHeader'));
|
335 |
+
// Stats page onload callback
|
336 |
+
add_action('load-'.$this->intStatsPage, array(&$this, 'onloadStatsPage'));
|
337 |
+
}
|
338 |
+
$intOptionsPage = add_submenu_page(
|
339 |
+
'settings.php',
|
340 |
+
__('WP-Piwik', 'wp-piwik'),
|
341 |
+
__('WP-Piwik', 'wp-piwik'),
|
342 |
+
'manage_sites',
|
343 |
+
__FILE__,
|
344 |
+
array($this, 'show_settings')
|
345 |
+
);
|
346 |
+
|
347 |
// Add styles required by options page
|
348 |
+
add_action('admin_print_styles-'.$intOptionsPage, array($this, 'addAdminStyle'));
|
|
|
349 |
}
|
350 |
+
|
351 |
+
/**
|
352 |
+
* Support two columns
|
353 |
+
* seen in Heiko Rabe's metabox demo plugin
|
354 |
+
*
|
355 |
+
* @see http://tinyurl.com/5r5vnzs
|
356 |
+
*/
|
357 |
function onScreenLayoutColumns($aryColumns, $strScreen) {
|
358 |
if ($strScreen == $this->intStatsPage)
|
359 |
$aryColumns[$this->intStatsPage] = 4;
|
360 |
return $aryColumns;
|
361 |
}
|
362 |
|
363 |
+
/**
|
364 |
+
* Add widgets to WordPress dashboard
|
365 |
+
*/
|
366 |
+
function extendWordPressDashboard() {
|
367 |
+
// Is user allowed to see stats?
|
368 |
if (current_user_can('wp-piwik_read_stats')) {
|
369 |
+
// TODO: Use bitmask here
|
370 |
+
// Add data widget if enabled
|
371 |
if (self::$aryGlobalSettings['dashboard_widget'])
|
372 |
+
$this->addWordPressDashboardWidget();
|
373 |
+
// Add chart widget if enabled
|
374 |
if (self::$aryGlobalSettings['dashboard_chart']) {
|
375 |
// Add required scripts
|
376 |
+
add_action('admin_print_scripts-index.php', array($this, 'loadScripts'));
|
377 |
// Add required styles
|
378 |
+
add_action('admin_print_styles-index.php', array($this, 'addAdminStyle'));
|
379 |
// Add required header tags
|
380 |
+
add_action('admin_head-index.php', array($this, 'addAdminHeader'));
|
381 |
+
$this->addWordPressDashboardChart();
|
382 |
}
|
383 |
+
// Add SEO widget if enabled
|
384 |
+
if (self::$aryGlobalSettings['dashboard_seo'])
|
385 |
+
$this->addWordPressDashboardSEO();
|
386 |
}
|
387 |
}
|
388 |
|
389 |
+
/**
|
390 |
+
* Add a data widget to the WordPress dashboard
|
391 |
+
*/
|
392 |
+
function addWordPressDashboardWidget() {
|
393 |
$aryConfig = array(
|
394 |
+
'params' => array('period' => 'day','date' => self::$aryGlobalSettings['dashboard_widget'],'limit' => null),
|
|
|
|
|
|
|
|
|
395 |
'inline' => true,
|
396 |
);
|
397 |
$strFile = 'overview';
|
409 |
/**
|
410 |
* Add a visitor chart to the WordPress dashboard
|
411 |
*/
|
412 |
+
function addWordPressDashboardChart() {
|
413 |
$aryConfig = array(
|
414 |
+
'params' => array('period' => 'day','date' => 'last30','limit' => null),
|
|
|
|
|
|
|
|
|
415 |
'inline' => true,
|
416 |
);
|
417 |
$strFile = 'visitors';
|
426 |
);
|
427 |
}
|
428 |
|
429 |
+
/**
|
430 |
+
* Add a SEO widget to the WordPress dashboard
|
431 |
+
*/
|
432 |
+
function addWordPressDashboardSEO() {
|
433 |
+
$aryConfig = array(
|
434 |
+
'params' => array('period' => 'day','date' => self::$aryGlobalSettings['dashboard_widget'],'limit' => null),
|
435 |
+
'inline' => true,
|
436 |
+
);
|
437 |
+
$strFile = 'seo';
|
438 |
+
add_meta_box(
|
439 |
+
'wp-piwik_stats-dashboard-seo',
|
440 |
+
__('WP-Piwik', 'wp-piwik').' - '.__('SEO', 'wp-piwik'),
|
441 |
+
array(&$this, 'createDashboardWidget'),
|
442 |
+
'dashboard',
|
443 |
+
'side',
|
444 |
+
'high',
|
445 |
+
array('strFile' => $strFile, 'aryConfig' => $aryConfig)
|
446 |
+
);
|
447 |
+
}
|
448 |
+
|
449 |
/**
|
450 |
* Add plugin meta links to plugin details
|
451 |
*
|
469 |
/**
|
470 |
* Load required scripts to admin pages
|
471 |
*/
|
472 |
+
function loadScripts() {
|
473 |
// Load WP-Piwik script
|
474 |
+
wp_enqueue_script('wp-piwik', $this->getPluginURL().'js/wp-piwik.js', array(), self::$strVersion, true);
|
475 |
// Load jqPlot
|
476 |
+
wp_enqueue_script('wp-piwik-jqplot',$this->getPluginURL().'js/jqplot/wp-piwik.jqplot.js',array('jquery'));
|
477 |
}
|
478 |
|
479 |
/**
|
480 |
* Load required styles to admin pages
|
481 |
*/
|
482 |
+
function addAdminStyle() {
|
483 |
// Load WP-Piwik styles
|
484 |
+
wp_enqueue_style('wp-piwik', $this->getPluginURL().'css/wp-piwik.css');
|
485 |
}
|
486 |
|
487 |
/**
|
488 |
* Add required header tags to admin pages
|
489 |
*/
|
490 |
+
function addAdminHeader() {
|
491 |
// Load jqPlot IE compatibility script
|
492 |
+
echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.$this->getPluginURL().'js/jqplot/excanvas.min.js"></script><![endif]-->';
|
493 |
// Load jqPlot styles
|
494 |
+
echo '<link rel="stylesheet" href="'.$this->getPluginURL().'js/jqplot/jquery.jqplot.min.css" type="text/css"/>';
|
495 |
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
|
496 |
}
|
497 |
|
498 |
/**
|
499 |
* Get this plugin's URL
|
500 |
*/
|
501 |
+
function getPluginURL() {
|
502 |
// Return plugins URL + /wp-piwik/
|
503 |
return trailingslashit(plugins_url().'/wp-piwik/');
|
504 |
}
|
508 |
*
|
509 |
* @param String $strURL Remote file URL
|
510 |
*/
|
511 |
+
function getRemoteFile($strURL) {
|
512 |
// Use cURL if available
|
513 |
if (function_exists('curl_init')) {
|
514 |
// Init cURL
|
534 |
return $strResult;
|
535 |
}
|
536 |
|
537 |
+
/**
|
538 |
+
* Add a new site to Piwik if a new blog was requested,
|
539 |
+
* or get its ID by URL
|
540 |
+
*/
|
541 |
+
function addPiwikSite() {
|
542 |
+
$strBlogURL = get_bloginfo('url');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
543 |
$strURL = self::$aryGlobalSettings['piwik_url'];
|
544 |
+
// Check if blog URL already known
|
545 |
+
if (substr($strURL, -1, 1) != '/') $strURL .= '/';
|
546 |
+
$strURL .= '?module=API&method=SitesManager.getSitesIdFromSiteUrl';
|
547 |
+
$strURL .= '&url='.urlencode($strBlogURL);
|
548 |
+
$strURL .= '&format=PHP';
|
549 |
+
$strURL .= '&token_auth='.self::$aryGlobalSettings['piwik_token'];
|
550 |
+
$aryResult = unserialize($this->getRemoteFile($strURL));
|
551 |
+
if (!empty($aryResult) && isset($aryResult[0]['idsite'])) {
|
552 |
+
self::$arySettings['site_id'] = $aryResult[0]['idsite'];
|
553 |
+
self::$arySettings['last_tracking_code_update'] = time();
|
554 |
+
// Otherwise create new site
|
555 |
+
} elseif (!empty(self::$aryGlobalSettings['piwik_token']) && !empty($strURL)) {
|
556 |
+
$strName = get_bloginfo('name');
|
557 |
+
if (substr($strURL, -1, 1) != '/') $strURL .= '/';
|
558 |
+
$strURL .= '?module=API&method=SitesManager.addSite';
|
559 |
+
$strURL .= '&siteName='.urlencode($strName).'&urls='.urlencode($strBlogURL);
|
560 |
+
$strURL .= '&format=PHP';
|
561 |
+
$strURL .= '&token_auth='.self::$aryGlobalSettings['piwik_token'];
|
562 |
+
$strResult = unserialize($this->getRemoteFile($strURL));
|
563 |
+
if (!empty($strResult)) self::$arySettings['site_id'] = $strResult;
|
564 |
}
|
565 |
+
// Store new data
|
566 |
+
self::$arySettings['tracking_code'] = html_entity_decode($this->callPiwikAPI('SitesManager.getJavascriptTag'));
|
567 |
+
self::$arySettings['last_tracking_code_update'] = time();
|
568 |
+
// Change Tracking code if configured
|
569 |
+
self::$arySettings['tracking_code'] = $this->applyJSCodeChanges(self::$arySettings['tracking_code']);
|
570 |
+
self::saveSettings();
|
571 |
+
return array('js' => self::$arySettings['tracking_code'], 'id' => self::$arySettings['site_id']);
|
572 |
}
|
573 |
|
574 |
+
/**
|
575 |
+
* Apply configured Tracking Code changes
|
576 |
+
*/
|
577 |
+
function applyJSCodeChanges($strCode) {
|
578 |
+
// Change code if js/index.php should be used
|
579 |
+
if (self::$aryGlobalSettings['track_compress']) $strCode = str_replace('pkBaseURL + "piwik.js\'', 'pkBaseURL + "js/\'', $strCode);
|
580 |
+
// Change code if POST is forced to be used
|
581 |
+
if (self::$aryGlobalSettings['track_post']) $strCode = str_replace('piwikTracker.trackPageView();', 'piwikTracker.setRequestMethod(\'POST\');'."\n".' piwikTracker.trackPageView();', $strCode);
|
582 |
+
return $strCode;
|
583 |
+
}
|
584 |
+
|
585 |
+
/**
|
586 |
+
* Create a WordPress dashboard widget
|
587 |
+
*/
|
588 |
function createDashboardWidget($objPost, $aryMetabox) {
|
589 |
+
// Create description and ID
|
590 |
$strDesc = $strID = '';
|
591 |
$aryConfig = $aryMetabox['args']['aryConfig'];
|
592 |
foreach ($aryConfig['params'] as $strParam)
|
594 |
$strDesc .= $strParam.', ';
|
595 |
$strID .= '_'.$strParam;
|
596 |
}
|
597 |
+
// Remove dots from filename
|
598 |
$strFile = str_replace('.', '', $aryMetabox['args']['strFile']);
|
599 |
+
// Finalize configuration
|
600 |
$aryConf = array_merge($aryConfig, array(
|
601 |
'id' => $strFile.$strID,
|
602 |
'desc' => substr($strDesc, 0, -2)));
|
603 |
+
// Include widget file
|
604 |
+
if (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR.'dashboard/'.$strFile.'.php'))
|
605 |
+
include(dirname(__FILE__).DIRECTORY_SEPARATOR.'dashboard/'.$strFile.'.php');
|
606 |
}
|
607 |
|
608 |
+
/**
|
609 |
+
* Call Piwik's API
|
610 |
+
*/
|
611 |
+
function callPiwikAPI($strMethod, $strPeriod='', $strDate='', $intLimit='',$bolExpanded=false, $intId = false, $strFormat = 'PHP') {
|
612 |
+
// Create unique cache key
|
613 |
+
$strKey = $strMethod.'_'.$strPeriod.'_'.$strDate.'_'.$intLimit;
|
614 |
+
// Call API if data not cached
|
615 |
+
if (empty($this->aryCache[$strKey])) {
|
616 |
+
$strToken = self::$aryGlobalSettings['piwik_token'];
|
617 |
+
$strURL = self::$aryGlobalSettings['piwik_url'];
|
618 |
+
// If multisite stats are shown, maybe the super admin wants to show other blog's stats.
|
619 |
+
if (is_plugin_active_for_network('wp-piwik/wp-piwik.php') && function_exists('is_super_admin') && function_exists('wp_get_current_user') && is_super_admin() && isset($_GET['wpmu_show_stats'])) {
|
620 |
+
$aryOptions = get_blog_option((int) $_GET['wpmu_show_stats'], 'wp-piwik_settings' , array());
|
621 |
+
if (!empty($aryOptions) && isset($aryOptions['site_id']))
|
622 |
+
$intSite = $aryOptions['site_id'];
|
623 |
+
else $intSite = self::$arySettings['site_id'];
|
624 |
+
// Otherwise use the current site's id.
|
625 |
+
} else $intSite = self::$arySettings['site_id'];
|
626 |
+
// Create error message if WP-Piwik isn't configured
|
627 |
+
if (empty($strToken) || empty($strURL)) {
|
628 |
+
$this->aryCache[$key] = array(
|
629 |
+
'result' => 'error',
|
630 |
+
'message' => 'Piwik base URL or auth token not set.'
|
631 |
+
);
|
632 |
+
return $this->aryCache[$strKey];
|
633 |
+
}
|
634 |
+
// Build URL
|
635 |
+
$strURL .= '?module=API&method='.$strMethod;
|
636 |
+
$strURL .= '&idSite='.$intSite.'&period='.$strPeriod.'&date='.$strDate;
|
637 |
+
$strURL .= '&filter_limit='.$intLimit;
|
638 |
+
$strURL .= '&token_auth='.$strToken;
|
639 |
+
$strURL .= '&expanded='.$bolExpanded;
|
640 |
+
$strURL .= '&url='.urlencode(get_bloginfo('url'));
|
641 |
+
$strURL .= '&format='.$strFormat;
|
642 |
+
// Fetch data if site exists
|
643 |
+
if (!empty($intSite)) {
|
644 |
+
$strResult = (string) $this->getRemoteFile($strURL);
|
645 |
+
$this->aryCache[$strKey] = ($strFormat == 'PHP'?unserialize($strResult):$strResult);
|
646 |
+
// Otherwise return error message
|
647 |
+
} else $this->aryCache[$strKey] = array('result' => 'error', 'message' => 'Unknown site/blog.');
|
648 |
}
|
649 |
+
return $this->aryCache[$strKey];
|
650 |
}
|
651 |
+
|
652 |
+
/* TODO: Add post stats
|
653 |
+
* function display_post_unique_column($aryCols) {
|
654 |
+
* $aryCols['wp-piwik_unique'] = __('Unique');
|
655 |
+
* return $aryCols;
|
656 |
+
* }
|
657 |
+
*
|
658 |
+
* function display_post_unique_content($strCol, $intID) {
|
659 |
+
* if( $strCol == 'wp-piwik_unique' ) {
|
660 |
+
* }
|
661 |
+
* }
|
662 |
+
*/
|
663 |
|
664 |
function onloadStatsPage() {
|
665 |
+
wp_enqueue_script('common');
|
666 |
wp_enqueue_script('wp-lists');
|
667 |
wp_enqueue_script('postbox');
|
668 |
$strToken = self::$aryGlobalSettings['piwik_token'];
|
672 |
$arySortOrder = array(
|
673 |
'side' => array(
|
674 |
'overview' => array(__('Overview', 'wp-piwik'), 'day', 'yesterday'),
|
675 |
+
'seo' => array(__('SEO', 'wp-piwik'), 'day', 'yesterday'),
|
676 |
'pages' => array(__('Pages', 'wp-piwik'), 'day', 'yesterday'),
|
677 |
'keywords' => array(__('Keywords', 'wp-piwik'), 'day', 'yesterday', 10),
|
678 |
'websites' => array(__('Websites', 'wp-piwik'), 'day', 'yesterday', 10),
|
679 |
+
'plugins' => array(__('Plugins', 'wp-piwik'), 'day', 'yesterday'),
|
680 |
),
|
681 |
'normal' => array(
|
682 |
'visitors' => array(__('Visitors', 'wp-piwik'), 'day', 'last30'),
|
685 |
'systems' => array(__('Operating System', 'wp-piwik'), 'day', 'yesterday')
|
686 |
)
|
687 |
);
|
688 |
+
// Don't show SEO stats if disabled
|
689 |
+
if (!self::$aryGlobalSettings['stats_seo'])
|
690 |
+
unset($arySortOrder['side']['seo']);
|
691 |
+
|
692 |
foreach ($arySortOrder as $strCol => $aryWidgets) {
|
693 |
if (is_array($aryWidgets)) foreach ($aryWidgets as $strFile => $aryParams) {
|
694 |
$aryDashboard[$strCol][$strFile] = array(
|
710 |
$intSideBoxCnt++;
|
711 |
add_meta_box(
|
712 |
'wp-piwik_stats-sidebox-'.$intSideBoxCnt,
|
713 |
+
$aryConfig['params']['title'].' '.($aryConfig['params']['title']!='SEO'?__($aryConfig['params']['date'], 'wp-piwik'):''),
|
714 |
array(&$this, 'createDashboardWidget'),
|
715 |
$this->intStatsPage,
|
716 |
'side',
|
722 |
$intContentBox++;
|
723 |
add_meta_box(
|
724 |
'wp-piwik_stats-contentbox-'.$intContentBox,
|
725 |
+
$aryConfig['params']['title'].' '.($aryConfig['params']['title']!='SEO'?__($aryConfig['params']['date'], 'wp-piwik'):''),
|
726 |
array(&$this, 'createDashboardWidget'),
|
727 |
$this->intStatsPage,
|
728 |
'normal',
|
740 |
<?php screen_icon('options-general'); ?>
|
741 |
<h2><?php _e('Piwik Statistics', 'wp-piwik'); ?></h2>
|
742 |
<?php /************************************************************************/
|
743 |
+
if (is_plugin_active_for_network('wp-piwik/wp-piwik.php') && function_exists('is_super_admin') && is_super_admin()) {
|
|
|
|
|
744 |
global $blog_id;
|
745 |
global $wpdb;
|
746 |
$aryBlogs = $wpdb->get_results($wpdb->prepare('SELECT blog_id FROM '.$wpdb->prefix.'blogs ORDER BY blog_id'));
|
747 |
+
if (isset($_GET['wpmu_show_stats'])) {
|
748 |
+
switch_to_blog((int) $_GET['wpmu_show_stats']);
|
749 |
+
self::loadSettings();
|
750 |
+
}
|
751 |
+
echo '<form method="GET" action="">'."\n";
|
752 |
+
echo '<input type="hidden" name="page" value="wp-piwik_stats" />';
|
753 |
+
echo '<input type="hidden" name="date" value="'.(isset($_GET['date']) && preg_match('/^[0-9]{8}$/', $_GET['date'])?$_GET['date']:'').'" />';
|
754 |
echo '<select name="wpmu_show_stats">'."\n";
|
755 |
+
$aryOptions = array();
|
756 |
foreach ($aryBlogs as $aryBlog) {
|
757 |
$objBlog = get_blog_details($aryBlog->blog_id, true);
|
758 |
+
$aryOptions[$objBlog->blogname.'#'.$objBlog->blog_id] = '<option value="'.$objBlog->blog_id.'"'.($blog_id == $objBlog->blog_id?' selected="selected"':'').'>'.$objBlog->blogname.'</option>'."\n";
|
759 |
}
|
760 |
+
// Show blogs in alphabetical order
|
761 |
+
ksort($aryOptions);
|
762 |
+
foreach ($aryOptions as $strOption) echo $strOption;
|
763 |
echo '</select><input type="submit" value="'.__('Change').'" />'."\n ";
|
764 |
+
echo __('Currently shown stats:').' <a href="'.get_bloginfo('url').'">'.get_bloginfo('name').'</a>'."\n";
|
|
|
765 |
echo '</form>'."\n";
|
766 |
}
|
767 |
/***************************************************************************/ ?>
|
772 |
<input type="hidden" name="action" value="save_wp-piwik_stats_general" />
|
773 |
<div id="poststuff" class="metabox-holder has-right-sidebar" style="width:<?php echo 528+281; ?>px;">
|
774 |
<div id="side-info-column" class="inner-sidebar wp-piwik-side">
|
775 |
+
<?php do_meta_boxes($this->intStatsPage, 'side', ''); ?>
|
776 |
</div>
|
777 |
<div id="post-body" class="has-sidebar">
|
778 |
<div id="post-body-content" class="postbox-container has-sidebar-content">
|
779 |
+
<?php $meta_boxes = do_meta_boxes($this->intStatsPage, 'normal', ''); ?>
|
780 |
</div>
|
781 |
</div>
|
782 |
<br class="clear"/>
|
794 |
//]]>
|
795 |
</script>
|
796 |
<?php /************************************************************************/
|
797 |
+
if (is_plugin_active_for_network('wp-piwik/wp-piwik.php') && function_exists('is_super_admin') && is_super_admin()) {
|
798 |
+
restore_current_blog();
|
799 |
}
|
800 |
}
|
801 |
|
813 |
wp_redirect($_POST['_wp_http_referer']);
|
814 |
}
|
815 |
|
816 |
+
/**
|
817 |
+
* Apply & store new settings
|
818 |
+
*/
|
819 |
function applySettings() {
|
820 |
+
self::$aryGlobalSettings['add_tracking_code'] = (isset($_POST['wp-piwik_addjs'])?$_POST['wp-piwik_addjs']:'');
|
821 |
+
self::$aryGlobalSettings['dashboard_widget'] = (isset($_POST['wp-piwik_dbwidget'])?$_POST['wp-piwik_dbwidget']:false);
|
822 |
+
self::$aryGlobalSettings['dashboard_chart'] = (isset($_POST['wp-piwik_dbchart'])?$_POST['wp-piwik_dbchart']:false);
|
823 |
+
self::$aryGlobalSettings['dashboard_seo'] = (isset($_POST['wp-piwik_dbseo'])?$_POST['wp-piwik_dbseo']:false);
|
824 |
+
self::$aryGlobalSettings['stats_seo'] = (isset($_POST['wp-piwik_statsseo'])?$_POST['wp-piwik_statsseo']:false);
|
825 |
+
self::$aryGlobalSettings['piwik_shortcut'] = (isset($_POST['wp-piwik_piwiklink'])?$_POST['wp-piwik_piwiklink']:false);
|
826 |
+
self::$aryGlobalSettings['default_date'] = (isset($_POST['wp-piwik_default_date'])?$_POST['wp-piwik_default_date']:'yesterday');
|
|
|
|
|
827 |
self::$aryGlobalSettings['piwik_token'] = (isset($_POST['wp-piwik_token'])?$_POST['wp-piwik_token']:'');
|
828 |
self::$aryGlobalSettings['piwik_url'] = self::check_url((isset($_POST['wp-piwik_url'])?$_POST['wp-piwik_url']:''));
|
829 |
self::$aryGlobalSettings['capability_stealth'] = (isset($_POST['wp-piwik_filter'])?$_POST['wp-piwik_filter']:array());
|
830 |
self::$aryGlobalSettings['capability_read_stats'] = (isset($_POST['wp-piwik_displayto'])?$_POST['wp-piwik_displayto']:array());
|
831 |
self::$aryGlobalSettings['last_settings_update'] = time();
|
832 |
+
self::$aryGlobalSettings['track_404'] = (isset($_POST['wp-piwik_404'])?$_POST['wp-piwik_404']:false);
|
833 |
+
self::$aryGlobalSettings['track_compress'] = (isset($_POST['wp-piwik_compress'])?$_POST['wp-piwik_compress']:false);
|
834 |
+
self::$aryGlobalSettings['track_post'] = (isset($_POST['wp-piwik_reqpost'])?$_POST['wp-piwik_reqpost']:false);
|
835 |
+
if (!is_plugin_active_for_network('wp-piwik/wp-piwik.php')) {
|
836 |
+
self::$aryGlobalSettings['auto_site_config'] = (isset($_POST['wp-piwik_auto_site_config'])?$_POST['wp-piwik_auto_site_config']:false);
|
837 |
+
if (!self::$aryGlobalSettings['auto_site_config'])
|
838 |
+
self::$arySettings['site_id'] = (isset($_POST['wp-piwik_siteid'])?$_POST['wp-piwik_siteid']:NULL);
|
839 |
+
} else self::$aryGlobalSettings['auto_site_config'] = true;
|
840 |
+
if (self::$aryGlobalSettings['auto_site_config']) {
|
841 |
+
$aryReturn = $this->addPiwikSite();
|
842 |
+
self::$arySettings['tracking_code'] = $aryReturn['js'];
|
843 |
+
self::$arySettings['site_id'] = $aryReturn['id'];
|
844 |
+
}
|
845 |
self::saveSettings();
|
846 |
}
|
847 |
|
855 |
$strToken = self::$aryGlobalSettings['piwik_token'];
|
856 |
$strURL = self::$aryGlobalSettings['piwik_url'];
|
857 |
$intSite = self::$arySettings['site_id'];
|
858 |
+
if (isset($_POST['action']) && $_POST['action'] == 'save_settings')
|
859 |
echo '<div id="message" class="updated fade"><p>'.__('Changes saved','wp-piwik').'</p></div>';
|
860 |
+
|
861 |
/***************************************************************************/ ?>
|
862 |
<div class="wrap">
|
863 |
<h2><?php _e('WP-Piwik Settings', 'wp-piwik') ?></h2>
|
864 |
+
|
865 |
+
<div class="wp-piwik-sidebox">
|
866 |
+
<div class="wp-piwik-support">
|
867 |
+
<p><strong>Support</strong></p>
|
868 |
+
<p><a href="http://peepbo.de/board/viewforum.php?f=3"><?php _e('WP-Piwik support board','wp-piwik'); ?></a> (<?php _e('no registration required, English & German','wp-piwik'); ?>)</p>
|
869 |
+
<p><a href="http://wordpress.org/tags/wp-piwik?forum_id=10"><?php _e('WordPress.org forum about WP-Piwik','wp-piwik'); ?></a> (<?php _e('WordPress.org registration required, English','wp-piwik'); ?>)</p>
|
870 |
+
<p><?php _e('Please don\'t forget to vote the compatibility at the','wp-piwik'); ?> <a href="http://wordpress.org/extend/plugins/wp-piwik/">WordPress.org Plugin Directory</a>.</p>
|
871 |
+
</div>
|
872 |
+
<div class="wp-piwik-donate">
|
873 |
+
<p><strong><?php _e('Donate','wp-piwik'); ?></strong></p>
|
874 |
+
<p><?php _e('If you like WP-Piwik, you can support its development by a donation:', 'wp-piwik'); ?></p>
|
875 |
+
<div>
|
876 |
+
<script type="text/javascript">
|
877 |
+
var flattr_url = 'http://www.braekling.de/wp-piwik-wpmu-piwik-wordpress';
|
878 |
+
</script>
|
879 |
+
<script src="http<?php echo (self::isSSL()?'s':''); ?>://api.flattr.com/button/load.js" type="text/javascript"></script>
|
880 |
+
</div>
|
881 |
+
<div>Paypal
|
882 |
+
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
883 |
+
<input type="hidden" name="cmd" value="_s-xclick" />
|
884 |
+
<input type="hidden" name="hosted_button_id" value="6046779" />
|
885 |
+
<input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_donateCC_LG.gif" name="submit" alt="PayPal - The safer, easier way to pay online." />
|
886 |
+
<img alt="" border="0" src="https://www.paypal.com/de_DE/i/scr/pixel.gif" width="1" height="1" />
|
887 |
+
</form>
|
888 |
+
</div>
|
889 |
+
<div>
|
890 |
+
<a href="http://www.amazon.de/gp/registry/wishlist/111VUJT4HP1RA?reveal=unpurchased&filter=all&sort=priority&layout=standard&x=12&y=14"><?php _e('My Amazon.de wishlist', 'wp-piwik'); ?></a>
|
891 |
+
</div>
|
892 |
+
</div>
|
893 |
+
</div>
|
894 |
+
|
895 |
<form method="post" action="">
|
896 |
<div id="dashboard-widgets-wrap">
|
897 |
<div id="dashboard-widgets" class="metabox-holder">
|
923 |
'wp-piwik'
|
924 |
); ?>
|
925 |
</div>
|
926 |
+
<?php if (!is_plugin_active_for_network('wp-piwik/wp-piwik.php')) { ?>
|
927 |
+
<h4><label for="wp-piwik_addjs"><?php _e('Auto config', 'wp-piwik') ?>:</label></h4>
|
928 |
+
<div class="input-wrap">
|
929 |
+
<input type="checkbox" value="1" id="wp-piwik_auto_site_config" name="wp-piwik_auto_site_config"<?php echo (self::$aryGlobalSettings['auto_site_config']?' checked="checked"':'') ?>/>
|
930 |
+
</div>
|
931 |
+
<div class="wp-piwik_desc">
|
932 |
+
<?php _e('Check this to automatically choose your blog from your Piwik sites by URL. If your blog is not added to Piwik yet, WP-Piwik will add a new site.', 'wp-piwik') ?>
|
933 |
+
</div>
|
934 |
+
<?php } ?>
|
935 |
+
|
936 |
<?php /************************************************************************/
|
937 |
if (!empty($strToken) && !empty($strURL)) {
|
938 |
+
$aryData = $this->callPiwikAPI('SitesManager.getSitesWithAtLeastViewAccess');
|
939 |
if (empty($aryData)) {
|
940 |
echo '<div class="wp-piwik_desc"><strong>'.__('An error occured', 'wp-piwik').': </strong>'.
|
941 |
__('Please check URL and auth token. You need at least view access to one site.', 'wp-piwik').
|
944 |
echo '<div class="wp-piwik_desc"><strong><strong>'.__('An error occured', 'wp-piwik').
|
945 |
': </strong>'.$aryData['message'].'</div>';
|
946 |
} else {
|
947 |
+
if (!is_plugin_active_for_network('wp-piwik/wp-piwik.php')) {
|
948 |
+
if (empty($intSite)) {
|
949 |
+
self::$arySettings['site_id'] = $aryData[0]['idsite'];
|
950 |
+
self::saveSettings();
|
951 |
+
}
|
952 |
+
if (!self::$aryGlobalSettings['auto_site_config']) {
|
953 |
+
echo '<h4><label for="wp-piwik_siteid">'.__('Choose site', 'wp-piwik').':</label></h4>';
|
954 |
+
echo '<div class="input-wrap">';
|
955 |
+
echo '<select name="wp-piwik_siteid" id="wp-piwik_siteid">';
|
956 |
+
$aryOptions = array();
|
957 |
+
foreach ($aryData as $arySite)
|
958 |
+
$aryOptions[$arySite['name'].'#'.$arySite['idsite']] = '<option value="'.$arySite['idsite'].
|
959 |
+
'"'.($arySite['idsite']==$intSite?' selected="selected"':'').
|
960 |
+
'>'.htmlentities($arySite['name'], ENT_QUOTES, 'utf-8').
|
961 |
+
'</option>';
|
962 |
+
|
963 |
+
ksort($aryOptions);
|
964 |
+
foreach ($aryOptions as $strOption) echo $strOption;
|
965 |
+
echo '</select></div>';
|
966 |
+
} else {
|
967 |
+
echo '<h4><label for="wp-piwik_siteid">'.__('Determined site', 'wp-piwik').':</label></h4>';
|
968 |
+
echo '<div class="input-text-wrap">';
|
969 |
+
foreach ($aryData as $arySite)
|
970 |
+
if ($arySite['idsite'] == $intSite) {
|
971 |
+
echo '<input type="text" value="'.htmlentities($arySite['name'], ENT_QUOTES, 'utf-8').'" disabled="disabled" />';
|
972 |
+
break;
|
973 |
+
}
|
974 |
+
echo '</div>';
|
975 |
+
echo '<input type="hidden" name="wp-piwik_siteid" id="wp-piwik_siteid" value="'.$intSite.'" />';
|
976 |
+
}
|
977 |
}
|
978 |
$intSite = self::$arySettings['site_id'];
|
979 |
+
$int404 = self::$aryGlobalSettings['track_404'];
|
980 |
$intAddJS = self::$aryGlobalSettings['add_tracking_code'];
|
981 |
$intDashboardWidget = self::$aryGlobalSettings['dashboard_widget'];
|
982 |
$intShowLink = self::$aryGlobalSettings['piwik_shortcut'];
|
983 |
+
$strJavaScript = html_entity_decode($this->callPiwikAPI('SitesManager.getJavascriptTag'));
|
984 |
if ($intAddJS) {
|
985 |
+
// Change Tracking code if configured
|
986 |
+
$strJavaScript = $this->applyJSCodeChanges($strJavaScript);
|
987 |
+
// Save javascript code
|
988 |
self::$arySettings['tracking_code'] = $strJavaScript;
|
989 |
self::saveSettings();
|
990 |
}
|
1010 |
'<div class="input-wrap"><input type="checkbox" value="1" id="wp-piwik_404" name="wp-piwik_404" '.
|
1011 |
($int404?' checked="checked"':'').'/></div>';
|
1012 |
echo '<div class="wp-piwik_desc">'.
|
1013 |
+
__('If you add the Piwik javascript code by wp_footer(),', 'wp-piwik').' '.
|
1014 |
+
__('WP-Piwik can automatically add a 404-category to track 404-page-visits.', 'wp-piwik').
|
1015 |
+
'</div>';
|
1016 |
+
|
1017 |
+
echo '<h4><label for="wp-piwik_compress">'.__('Use js/index.php', 'wp-piwik').':</label></h4>'.
|
1018 |
+
'<div class="input-wrap"><input type="checkbox" value="1" id="wp-piwik_compress" name="wp-piwik_compress" '.
|
1019 |
+
(self::$aryGlobalSettings['track_compress']?' checked="checked"':'').'/></div>';
|
1020 |
+
echo '<div class="wp-piwik_desc">'.
|
1021 |
+
__('If you add the Piwik javascript code by wp_footer(),', 'wp-piwik').' '.
|
1022 |
+
__('WP-Piwik can automatically use js/index.php instead of piwik.js. See', 'wp-piwik').' <a href="http://demo.piwik.org/js/README">js/README</a>.'.
|
1023 |
+
'</div>';
|
1024 |
+
|
1025 |
+
echo '<h4><label for="wp-piwik_reqpost">'.__('Avoid mod_security', 'wp-piwik').':</label></h4>'.
|
1026 |
+
'<div class="input-wrap"><input type="checkbox" value="1" id="wp-piwik_reqpost" name="wp-piwik_reqpost" '.
|
1027 |
+
(self::$aryGlobalSettings['track_post']?' checked="checked"':'').'/></div>';
|
1028 |
+
echo '<div class="wp-piwik_desc">'.
|
1029 |
+
__('If you add the Piwik javascript code by wp_footer(),', 'wp-piwik').' '.
|
1030 |
+
__('WP-Piwik can automatically force the Tracking Code to sent data in POST. See', 'wp-piwik').' <a href="http://piwik.org/faq/troubleshooting/#faq_100">Piwik FAQ</a>.'.
|
1031 |
'</div>';
|
1032 |
+
|
1033 |
global $wp_roles;
|
1034 |
echo '<h4><label>'.__('Tracking filter', 'wp-piwik').':</label></h4>';
|
1035 |
echo '<div class="input-wrap">';
|
1049 |
<h3 class='hndle'><span><?php _e('Statistic view settings', 'wp-piwik'); ?></span></h3>
|
1050 |
<div class="inside">
|
1051 |
<?php
|
1052 |
+
echo '<h4><label for="wp-piwik_dbwidget">'.__('Home Dashboard', 'wp-piwik').':</label></h4>'.
|
1053 |
'<div class="input-wrap"><select id="wp-piwik_dbwidget" name="wp-piwik_dbwidget">'.
|
1054 |
+
'<option value="0"'.(!$intDashboardWidget?' selected="selected"':'').'>'.__('Hide overview', 'wp-piwik').'</option>'.
|
1055 |
+
'<option value="yesterday"'.($intDashboardWidget == 'yesterday'?' selected="selected"':'').'>'.__('Show Overview','wp-piwik').' ('.__('yesterday', 'wp-piwik').').</option>'.
|
1056 |
+
'<option value="today"'.($intDashboardWidget == 'today'?' selected="selected"':'').'>'.__('Show overview','wp-piwik').' ('.__('today', 'wp-piwik').').</option>'.
|
1057 |
+
'<option value="last30"'.($intDashboardWidget == 'last30'?' selected="selected"':'').'>'.__('Show overview','wp-piwik').' ('.__('last 30 days','wp-piwik').').</option>'.
|
1058 |
+
'</select>';
|
1059 |
+
echo ' <input type="checkbox" value="1" name="wp-piwik_dbchart" id="wp-piwik_dbchart" '.
|
1060 |
+
(self::$aryGlobalSettings['dashboard_chart']?' checked="checked"':"").'/> '.__('Chart');
|
1061 |
+
echo ' <input type="checkbox" value="1" name="wp-piwik_dbseo" id="wp-piwik_dbseo" '.
|
1062 |
+
(self::$aryGlobalSettings['dashboard_seo']?' checked="checked"':"").'/> '.__('SEO <em>(slow!)</em>', 'wp-piwik');
|
1063 |
+
echo '</div>';
|
|
|
1064 |
echo '<div class="wp-piwik_desc">'.
|
1065 |
+
__('Configure WP-Piwik widgets to be shown on your WordPress Home Dashboard.', 'wp-piwik').'</div>';
|
1066 |
+
|
1067 |
echo '<h4><label for="wp-piwik_piwiklink">'.__('Shortcut', 'wp-piwik').':</label></h4>'.
|
1068 |
'<div class="input-wrap"><input type="checkbox" value="1" name="wp-piwik_piwiklink" id="wp-piwik_piwiklink" '.
|
1069 |
($intShowLink?' checked="checked"':"").'/></div>';
|
1070 |
echo '<div class="wp-piwik_desc">'.
|
1071 |
__('Display a shortcut to Piwik itself.', 'wp-piwik').'</div>';
|
1072 |
+
|
1073 |
echo '<h4><label for="wp-piwik_default_date">'.__('Default date', 'wp-piwik').':</label></h4>'.
|
1074 |
'<div class="input-wrap"><select id="wp-piwik_default_date" name="wp-piwik_default_date">'.
|
1075 |
'<option value="yesterday"'.(self::$aryGlobalSettings['default_date'] == 'yesterday'?' selected="selected"':'').'> '.__('yesterday', 'wp-piwik').'</option>'.
|
1077 |
'</select></div>';
|
1078 |
echo '<div class="wp-piwik_desc">'.
|
1079 |
__('Default date shown on statistics page.', 'wp-piwik').'</div>';
|
1080 |
+
|
1081 |
+
echo '<h4><label for="wp-piwik_piwiklink">'.__('SEO data', 'wp-piwik').':</label></h4>'.
|
1082 |
+
'<div class="input-wrap"><input type="checkbox" value="1" name="wp-piwik_statsseo" id="wp-piwik_statsseo" '.
|
1083 |
+
(self::$aryGlobalSettings['stats_seo']?' checked="checked"':"").'/></div>';
|
1084 |
+
echo '<div class="wp-piwik_desc">'.
|
1085 |
+
__('Display SEO ranking data on statistics page. <em>(Slow!)</em>', 'wp-piwik').'</div>';
|
1086 |
+
|
1087 |
echo '<h4><label>'.__('Display to', 'wp-piwik').':</label></h4>';
|
1088 |
echo '<div class="input-wrap">';
|
1089 |
$intDisplayTo = self::$aryGlobalSettings['capability_read_stats'];
|
1110 |
<?php /************************************************************************/
|
1111 |
}
|
1112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1113 |
private static function isSSL() {
|
1114 |
return (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off');
|
1115 |
}
|
1118 |
/***************************************************************************/ ?>
|
1119 |
<h2 style="clear:left;"><?php _e('Credits', 'wp-piwik'); ?></h2>
|
1120 |
<div class="inside">
|
1121 |
+
<p><strong><?php _e('Thank you very much for your donation', 'wp-piwik'); ?>:</strong> Marco L., Rolf W., Tobias U., Lars K., Donna F., <?php _e('the Piwik team itself','wp-piwik');?> <?php _e('and all people flattering this','wp-piwik'); ?>!</p>
|
1122 |
<p><?php _e('Graphs powered by <a href="http://www.jqplot.com/">jqPlot</a>, an open source project by Chris Leonello. Give it a try! (License: GPL 2.0 and MIT)','wp-piwik'); ?></p>
|
1123 |
+
<p><?php _e('Metabox support inspired by', 'wp-piwik'); echo ' <a href="http://www.code-styling.de/english/how-to-use-wordpress-metaboxes-at-own-plugins">Heiko Rabe\'s metabox demo plugin</a>.'?></p>
|
1124 |
<p><?php _e('Thank you very much','wp-piwik'); ?>, <a href="http://blogu.programeshqip.org/">Besnik Bleta</a>, <a href="http://www.fatcow.com/">FatCow</a>, <a href="http://www.pamukkaleturkey.com/">Rene</a>, Fab, <a href="http://ezbizniz.com/">EzBizNiz</a>, Gormer, Natalya, <a href="www.aggeliopolis.gr">AggelioPolis</a><?php _e(', and', 'wp-piwik'); ?> <a href="http://wwww.webhostinggeeks.com">Galina Miklosic</a> <?php _e('for your translation work','wp-piwik'); ?>!</p>
|
1125 |
<p><?php _e('Thank you very much, all users who send me mails containing criticism, commendation, feature requests and bug reports! You help me to make WP-Piwik much better.','wp-piwik'); ?></p>
|
1126 |
<p><?php _e('Thank <strong>you</strong> for using my plugin. It is the best commendation if my piece of code is really used!','wp-piwik'); ?></p>
|