Version Description
WordPress metabox concept used properly, different bugfixes, custom variables feature added.
=
Download this release
Release Info
Developer | Braekling |
Plugin | WP-Matomo (WP-Piwik) |
Version | 0.9.6 |
Comparing to | |
See all releases |
Code changes from version 0.9.5 to 0.9.6
- css/wp-piwik.css +9 -13
- dashboard/browsers.php +26 -22
- dashboard/screens.php +27 -23
- dashboard/systems.php +27 -23
- dashboard/visitors.php +2 -2
- debug/testscript.php +18 -6
- languages/wp-piwik-de_DE.mo +0 -0
- languages/wp-piwik-de_DE.po +19 -1
- readme.txt +16 -5
- settings/piwik.php +37 -3
- settings/sitebrowser.php +13 -8
- settings/support.php +2 -2
- settings/tracking.php +11 -6
- update/90601.php +3 -0
- wp-piwik.php +175 -41
css/wp-piwik.css
CHANGED
@@ -1,24 +1,16 @@
|
|
1 |
-
div.wp-piwik-sortables {
|
2 |
-
margin:0 5px;
|
3 |
-
}
|
4 |
-
|
5 |
span.wp-piwik-details {
|
6 |
font-size:0.8em;
|
7 |
font-weight:normal;
|
8 |
}
|
9 |
|
10 |
-
|
11 |
-
display: none;
|
12 |
-
}
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
#wp-piwik_stats_vistors_graph{margin: 0 0 0 0}
|
21 |
-
|
22 |
table.wp-piwik-table th.n, td.n {
|
23 |
text-align: right;
|
24 |
}
|
@@ -119,4 +111,8 @@ strong.wp-piwik-error {color:#f00}
|
|
119 |
|
120 |
.wp-piwik-wide-content {
|
121 |
width:512px !important;
|
|
|
|
|
|
|
|
|
122 |
}
|
|
|
|
|
|
|
|
|
1 |
span.wp-piwik-details {
|
2 |
font-size:0.8em;
|
3 |
font-weight:normal;
|
4 |
}
|
5 |
|
6 |
+
#wp-piwik_stats_vistors_graph{margin: 0 0 0 0}
|
|
|
|
|
7 |
|
8 |
+
p.wp-piwik-eyecatcher {
|
9 |
+
border:1px solid #c00;
|
10 |
+
background:#ff0;
|
11 |
+
padding:5px;
|
12 |
}
|
13 |
|
|
|
|
|
14 |
table.wp-piwik-table th.n, td.n {
|
15 |
text-align: right;
|
16 |
}
|
111 |
|
112 |
.wp-piwik-wide-content {
|
113 |
width:512px !important;
|
114 |
+
}
|
115 |
+
|
116 |
+
.wp-piwik-graph-wide {
|
117 |
+
overflow:hidden;
|
118 |
}
|
dashboard/browsers.php
CHANGED
@@ -12,22 +12,25 @@
|
|
12 |
$aryConf['title'] = __('Browser', 'wp-piwik');
|
13 |
$strValues = '';
|
14 |
$intCount = 0; $intMore = 0; $intSum = 0;
|
15 |
-
if (
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
25 |
/***************************************************************************/ ?>
|
26 |
<div class="wp-piwik-graph-wide">
|
27 |
-
<div id="wp-piwik_stats_browsers_graph" style="height:310px;width:
|
28 |
</div>
|
29 |
<?php /************************************************************************/
|
30 |
-
|
31 |
/***************************************************************************/ ?>
|
32 |
<div class="table">
|
33 |
<table class="widefat wp-piwik-table">
|
@@ -40,25 +43,26 @@
|
|
40 |
</thead>
|
41 |
<tbody>
|
42 |
<?php /************************************************************************/
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
$aryValues['shortLabel'].
|
47 |
-
|
48 |
$aryValues['nb_uniq_visitors'].
|
49 |
-
|
50 |
number_format($aryValues['nb_uniq_visitors']/$intSum*100, 2).
|
51 |
'%</td></tr>';
|
52 |
-
|
53 |
-
|
54 |
/***************************************************************************/ ?>
|
55 |
</tbody>
|
56 |
</table>
|
57 |
</div>
|
58 |
<script type="text/javascript">
|
59 |
-
$j.jqplot('wp-piwik_stats_browsers_graph', [[<?php echo $strValues; ?>]], {
|
60 |
seriesDefaults:{renderer:$j.jqplot.PieRenderer, rendererOptions:{sliceMargin:8}},
|
61 |
legend:{show:true}
|
62 |
-
|
63 |
});
|
64 |
-
</script>
|
|
|
|
12 |
$aryConf['title'] = __('Browser', 'wp-piwik');
|
13 |
$strValues = '';
|
14 |
$intCount = 0; $intMore = 0; $intSum = 0;
|
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 |
+
if (is_array($aryConf['data']))
|
19 |
+
foreach ($aryConf['data'] as $key => $aryValues) {
|
20 |
+
$intCount++;
|
21 |
+
if ($intCount <= 9) $strValues .= '["'.$aryValues['shortLabel'].'",'.$aryValues['nb_uniq_visitors'].'],';
|
22 |
+
else $intMore += $aryValues['nb_uniq_visitors'];
|
23 |
+
$intSum += $aryValues['nb_uniq_visitors'];
|
24 |
+
}
|
25 |
+
if ($intMore) $strValues .= '["'.__('Others', 'wp-piwik').'",'.$intMore.'],';
|
26 |
+
$strValues = substr($strValues, 0, -1);
|
27 |
+
if ($intSum) {
|
28 |
/***************************************************************************/ ?>
|
29 |
<div class="wp-piwik-graph-wide">
|
30 |
+
<div id="wp-piwik_stats_browsers_graph" style="height:310px;width:100%"></div>
|
31 |
</div>
|
32 |
<?php /************************************************************************/
|
33 |
+
}
|
34 |
/***************************************************************************/ ?>
|
35 |
<div class="table">
|
36 |
<table class="widefat wp-piwik-table">
|
43 |
</thead>
|
44 |
<tbody>
|
45 |
<?php /************************************************************************/
|
46 |
+
if ($intSum)
|
47 |
+
foreach ($aryConf['data'] as $aryValues)
|
48 |
+
echo '<tr><td>'.
|
49 |
$aryValues['shortLabel'].
|
50 |
+
'</td><td class="n">'.
|
51 |
$aryValues['nb_uniq_visitors'].
|
52 |
+
'</td><td class="n">'.
|
53 |
number_format($aryValues['nb_uniq_visitors']/$intSum*100, 2).
|
54 |
'%</td></tr>';
|
55 |
+
else echo '<tr><td colspan="3">'.__('No data available.', 'wp-piwik').'</td></tr>';
|
56 |
+
unset($aryTmp);
|
57 |
/***************************************************************************/ ?>
|
58 |
</tbody>
|
59 |
</table>
|
60 |
</div>
|
61 |
<script type="text/javascript">
|
62 |
+
$plotBrowsers = $j.jqplot('wp-piwik_stats_browsers_graph', [[<?php echo $strValues; ?>]], {
|
63 |
seriesDefaults:{renderer:$j.jqplot.PieRenderer, rendererOptions:{sliceMargin:8}},
|
64 |
legend:{show:true}
|
|
|
65 |
});
|
66 |
+
</script>
|
67 |
+
<?php
|
68 |
+
}
|
dashboard/screens.php
CHANGED
@@ -12,22 +12,25 @@
|
|
12 |
$aryConf['title'] = __('Resolution', 'wp-piwik');
|
13 |
$strValues = '';
|
14 |
$intCount = 0; $intMore = 0; $intSum = 0;
|
15 |
-
if (
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
25 |
/***************************************************************************/ ?>
|
26 |
<div class="wp-piwik-graph-wide">
|
27 |
-
<div id="wp-piwik_stats_screens_graph" style="height:310px;width:
|
28 |
</div>
|
29 |
<?php /************************************************************************/
|
30 |
-
|
31 |
/***************************************************************************/ ?>
|
32 |
<div class="table">
|
33 |
<table class="widefat wp-piwik-table">
|
@@ -40,25 +43,26 @@
|
|
40 |
</thead>
|
41 |
<tbody>
|
42 |
<?php /************************************************************************/
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
$aryValues['label'].
|
47 |
-
|
48 |
$aryValues['nb_uniq_visitors'].
|
49 |
-
|
50 |
number_format($aryValues['nb_uniq_visitors']/$intSum*100, 2).
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
/***************************************************************************/ ?>
|
55 |
</tbody>
|
56 |
</table>
|
57 |
</div>
|
58 |
<script type="text/javascript">
|
59 |
-
$j.jqplot('wp-piwik_stats_screens_graph', [[<?php echo $strValues; ?>]], {
|
60 |
seriesDefaults:{renderer:$j.jqplot.PieRenderer, rendererOptions:{sliceMargin:8}},
|
61 |
legend:{show:true}
|
62 |
-
|
63 |
});
|
64 |
-
</script>
|
|
|
|
12 |
$aryConf['title'] = __('Resolution', 'wp-piwik');
|
13 |
$strValues = '';
|
14 |
$intCount = 0; $intMore = 0; $intSum = 0;
|
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 |
+
if (is_array($aryConf['data']))
|
19 |
+
foreach ($aryConf['data'] as $key => $aryValues) {
|
20 |
+
$intCount++;
|
21 |
+
if ($intCount <= 9) $strValues .= '["'.$aryValues['label'].'",'.$aryValues['nb_uniq_visitors'].'],';
|
22 |
+
else $intMore += $aryValues['nb_uniq_visitors'];
|
23 |
+
$intSum += $aryValues['nb_uniq_visitors'];
|
24 |
+
}
|
25 |
+
if ($intMore) $strValues .= '["'.__('Others', 'wp-piwik').'",'.$intMore.'],';
|
26 |
+
$strValues = substr($strValues, 0, -1);
|
27 |
+
if ($intSum) {
|
28 |
/***************************************************************************/ ?>
|
29 |
<div class="wp-piwik-graph-wide">
|
30 |
+
<div id="wp-piwik_stats_screens_graph" style="height:310px;width:100%"></div>
|
31 |
</div>
|
32 |
<?php /************************************************************************/
|
33 |
+
}
|
34 |
/***************************************************************************/ ?>
|
35 |
<div class="table">
|
36 |
<table class="widefat wp-piwik-table">
|
43 |
</thead>
|
44 |
<tbody>
|
45 |
<?php /************************************************************************/
|
46 |
+
if ($intSum)
|
47 |
+
foreach ($aryConf['data'] as $aryValues)
|
48 |
+
echo '<tr><td>'.
|
49 |
$aryValues['label'].
|
50 |
+
'</td><td class="n">'.
|
51 |
$aryValues['nb_uniq_visitors'].
|
52 |
+
'</td><td class="n">'.
|
53 |
number_format($aryValues['nb_uniq_visitors']/$intSum*100, 2).
|
54 |
+
'%</td></tr>';
|
55 |
+
else echo '<tr><td colspan="3">'.__('No data available.', 'wp-piwik').'</td></tr>';
|
56 |
+
unset($aryTmp);
|
57 |
/***************************************************************************/ ?>
|
58 |
</tbody>
|
59 |
</table>
|
60 |
</div>
|
61 |
<script type="text/javascript">
|
62 |
+
$plotScreens = $j.jqplot('wp-piwik_stats_screens_graph', [[<?php echo $strValues; ?>]], {
|
63 |
seriesDefaults:{renderer:$j.jqplot.PieRenderer, rendererOptions:{sliceMargin:8}},
|
64 |
legend:{show:true}
|
|
|
65 |
});
|
66 |
+
</script>
|
67 |
+
<?php
|
68 |
+
}
|
dashboard/systems.php
CHANGED
@@ -12,23 +12,26 @@
|
|
12 |
$aryConf['title'] = __('Operating System', 'wp-piwik');
|
13 |
$strValues = '';
|
14 |
$intCount = 0; $intMore = 0; $intSum = 0;
|
15 |
-
if (
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
24 |
|
25 |
-
|
26 |
/***************************************************************************/ ?>
|
27 |
<div class="wp-piwik-graph-wide">
|
28 |
-
<div id="wp-piwik_stats_systems_graph" style="height:310px;width:
|
29 |
</div>
|
30 |
<?php /************************************************************************/
|
31 |
-
|
32 |
/***************************************************************************/ ?>
|
33 |
<div class="table">
|
34 |
<table class="widefat wp-piwik-table">
|
@@ -41,25 +44,26 @@
|
|
41 |
</thead>
|
42 |
<tbody>
|
43 |
<?php /************************************************************************/
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
$aryValues['label'].
|
48 |
-
|
49 |
$aryValues['nb_uniq_visitors'].
|
50 |
-
|
51 |
number_format($aryValues['nb_uniq_visitors']/$intSum*100, 2).
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
/***************************************************************************/ ?>
|
56 |
</tbody>
|
57 |
</table>
|
58 |
</div>
|
59 |
<script type="text/javascript">
|
60 |
-
$j.jqplot('wp-piwik_stats_systems_graph', [[<?php echo $strValues; ?>]], {
|
61 |
seriesDefaults:{renderer:$j.jqplot.PieRenderer, rendererOptions:{sliceMargin:8}},
|
62 |
legend:{show:true}
|
63 |
-
|
64 |
});
|
65 |
-
</script>
|
|
|
|
12 |
$aryConf['title'] = __('Operating System', 'wp-piwik');
|
13 |
$strValues = '';
|
14 |
$intCount = 0; $intMore = 0; $intSum = 0;
|
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 |
+
if (is_array($aryConf['data']))
|
19 |
+
foreach ($aryConf['data'] as $key => $aryValues) {
|
20 |
+
$intCount++;
|
21 |
+
if ($intCount <= 9) $strValues .= '["'.$aryValues['label'].'",'.$aryValues['nb_uniq_visitors'].'],';
|
22 |
+
else $intMore += $aryValues['nb_uniq_visitors'];
|
23 |
+
$intSum += $aryValues['nb_uniq_visitors'];
|
24 |
+
}
|
25 |
+
if ($intMore) $strValues .= '["'.__('Others', 'wp-piwik').'",'.$intMore.'],';
|
26 |
+
$strValues = substr($strValues, 0, -1);
|
27 |
|
28 |
+
if ($intSum) {
|
29 |
/***************************************************************************/ ?>
|
30 |
<div class="wp-piwik-graph-wide">
|
31 |
+
<div id="wp-piwik_stats_systems_graph" style="height:310px;width:100%"></div>
|
32 |
</div>
|
33 |
<?php /************************************************************************/
|
34 |
+
}
|
35 |
/***************************************************************************/ ?>
|
36 |
<div class="table">
|
37 |
<table class="widefat wp-piwik-table">
|
44 |
</thead>
|
45 |
<tbody>
|
46 |
<?php /************************************************************************/
|
47 |
+
if ($intSum)
|
48 |
+
foreach ($aryConf['data'] as $aryValues)
|
49 |
+
echo '<tr><td>'.
|
50 |
$aryValues['label'].
|
51 |
+
'</td><td class="n">'.
|
52 |
$aryValues['nb_uniq_visitors'].
|
53 |
+
'</td><td class="n">'.
|
54 |
number_format($aryValues['nb_uniq_visitors']/$intSum*100, 2).
|
55 |
+
'%</td></tr>';
|
56 |
+
else echo '<tr><td colspan="3">'.__('No data available.', 'wp-piwik').'</td></tr>';
|
57 |
+
unset($aryTmp);
|
58 |
/***************************************************************************/ ?>
|
59 |
</tbody>
|
60 |
</table>
|
61 |
</div>
|
62 |
<script type="text/javascript">
|
63 |
+
$plotSystems = $j.jqplot('wp-piwik_stats_systems_graph', [[<?php echo $strValues; ?>]], {
|
64 |
seriesDefaults:{renderer:$j.jqplot.PieRenderer, rendererOptions:{sliceMargin:8}},
|
65 |
legend:{show:true}
|
|
|
66 |
});
|
67 |
+
</script>
|
68 |
+
<?php
|
69 |
+
}
|
dashboard/visitors.php
CHANGED
@@ -46,7 +46,7 @@
|
|
46 |
|
47 |
/***************************************************************************/ ?>
|
48 |
<div class="wp-piwik-graph-wide">
|
49 |
-
<div id="wp-piwik_stats_vistors_graph" style="height:220px;<?php if (!isset($aryConf['inline']) || $aryConf['inline'] != true) { ?>width:
|
50 |
</div>
|
51 |
<?php if (!isset($aryConf['inline']) || $aryConf['inline'] != true) { ?>
|
52 |
<div class="table">
|
@@ -79,7 +79,7 @@
|
|
79 |
</div>
|
80 |
<?php } ?>
|
81 |
<script type="text/javascript">
|
82 |
-
$j.jqplot('wp-piwik_stats_vistors_graph', [[<?php echo $strValues; ?>],[<?php echo $strValuesU; ?>],[<?php echo $strBounced;?>]],
|
83 |
{
|
84 |
axes:{yaxis:{min:0, tickOptions:{formatString:'%.0f'}},xaxis:{min:1,max:30,ticks:[<?php echo $strLabels; ?>]}},
|
85 |
seriesDefaults:{showMarker:false,lineWidth:1,fill:true,fillAndStroke:true,fillAlpha:0.9,trendline:{show:false,color:'#C00',lineWidth:1.5,type:'exp'}},
|
46 |
|
47 |
/***************************************************************************/ ?>
|
48 |
<div class="wp-piwik-graph-wide">
|
49 |
+
<div id="wp-piwik_stats_vistors_graph" style="height:220px;<?php if (!isset($aryConf['inline']) || $aryConf['inline'] != true) { ?>width:100%<?php } ?>"></div>
|
50 |
</div>
|
51 |
<?php if (!isset($aryConf['inline']) || $aryConf['inline'] != true) { ?>
|
52 |
<div class="table">
|
79 |
</div>
|
80 |
<?php } ?>
|
81 |
<script type="text/javascript">
|
82 |
+
$plotVisitors = $j.jqplot('wp-piwik_stats_vistors_graph', [[<?php echo $strValues; ?>],[<?php echo $strValuesU; ?>],[<?php echo $strBounced;?>]],
|
83 |
{
|
84 |
axes:{yaxis:{min:0, tickOptions:{formatString:'%.0f'}},xaxis:{min:1,max:30,ticks:[<?php echo $strLabels; ?>]}},
|
85 |
seriesDefaults:{showMarker:false,lineWidth:1,fill:true,fillAndStroke:true,fillAlpha:0.9,trendline:{show:false,color:'#C00',lineWidth:1.5,type:'exp'}},
|
debug/testscript.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* WP-Piwik
|
4 |
-
* Piwik API call test script revision
|
5 |
*/
|
6 |
|
7 |
/*****************
|
@@ -14,6 +14,8 @@ $strPiwikURL = self::$aryGlobalSettings['piwik_url'];
|
|
14 |
$strPiwikAuthToken = self::$aryGlobalSettings['piwik_token'];
|
15 |
// YOUR BLOG'S URL, e.g. http://www.website.example
|
16 |
$strPiwikYourBlogURL = get_bloginfo('url');
|
|
|
|
|
17 |
|
18 |
/* That's all, stop editing! */
|
19 |
|
@@ -22,17 +24,24 @@ $strPiwikYourBlogURL = get_bloginfo('url');
|
|
22 |
*
|
23 |
* @param String $strURL Remote file URL
|
24 |
*/
|
25 |
-
function getRemoteFile($strURL, $strToken) {
|
26 |
// Use cURL if available
|
27 |
if (function_exists('curl_init')) {
|
28 |
// Init cURL
|
29 |
$c = curl_init($strURL.$strToken);
|
30 |
// Configure cURL CURLOPT_RETURNTRANSFER = 1
|
31 |
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
|
32 |
-
//
|
33 |
-
curl_setopt($c,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
// Get result
|
35 |
-
$strResult = curl_exec($c);
|
36 |
// Close connection
|
37 |
curl_close($c);
|
38 |
// cURL not available but url fopen allowed
|
@@ -62,9 +71,12 @@ $intTest = 0;
|
|
62 |
foreach ($aryURLs as $strMethod => $strURL) {
|
63 |
$intTest++;
|
64 |
echo '*** Test '.$intTest.'/'.count($aryURLs).': '.$strMethod.' ***'."\n";
|
|
|
|
|
|
|
65 |
echo 'Call: '.$strURL.'&token_auth= + TOKEN'."\n";
|
66 |
$x = microtime(true);
|
67 |
-
$strResult = getRemoteFile($strURL,$strToken);
|
68 |
$x = microtime(true) - $x;
|
69 |
echo 'Result:'."\n";
|
70 |
echo htmlentities($strResult)."\n";
|
1 |
<?php
|
2 |
/**
|
3 |
* WP-Piwik
|
4 |
+
* Piwik API call test script revision 4
|
5 |
*/
|
6 |
|
7 |
/*****************
|
14 |
$strPiwikAuthToken = self::$aryGlobalSettings['piwik_token'];
|
15 |
// YOUR BLOG'S URL, e.g. http://www.website.example
|
16 |
$strPiwikYourBlogURL = get_bloginfo('url');
|
17 |
+
// User agent
|
18 |
+
$strUA = self::$aryGlobalSettings['piwik_useragent']=='php'?ini_get('user_agent'):self::$aryGlobalSettings['piwik_useragent_string'];
|
19 |
|
20 |
/* That's all, stop editing! */
|
21 |
|
24 |
*
|
25 |
* @param String $strURL Remote file URL
|
26 |
*/
|
27 |
+
function getRemoteFile($strURL, $strToken, $bolSSL, $strUA) {
|
28 |
// Use cURL if available
|
29 |
if (function_exists('curl_init')) {
|
30 |
// Init cURL
|
31 |
$c = curl_init($strURL.$strToken);
|
32 |
// Configure cURL CURLOPT_RETURNTRANSFER = 1
|
33 |
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
|
34 |
+
// Verbose = 1
|
35 |
+
curl_setopt($c, CURLOPT_VERBOSE, 1);
|
36 |
+
// Configure cURL CURLOPT_HEADER = 1 & CURLINFO_HEADER_OUT = 1
|
37 |
+
curl_setopt($c, CURLOPT_HEADER, 1);
|
38 |
+
curl_setopt($c, CURLINFO_HEADER_OUT, 1);
|
39 |
+
// Configure SSL peer verification
|
40 |
+
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, $bolSSL);
|
41 |
+
// Set user agent
|
42 |
+
curl_setopt($c, CURLOPT_USERAGENT, $strUA);
|
43 |
// Get result
|
44 |
+
$strResult = curl_exec($c);
|
45 |
// Close connection
|
46 |
curl_close($c);
|
47 |
// cURL not available but url fopen allowed
|
71 |
foreach ($aryURLs as $strMethod => $strURL) {
|
72 |
$intTest++;
|
73 |
echo '*** Test '.$intTest.'/'.count($aryURLs).': '.$strMethod.' ***'."\n";
|
74 |
+
echo 'Using: '.(function_exists('curl_init')?'cURL':'fopen')."\n";
|
75 |
+
echo 'SSL peer verification: '.(function_exists('curl_init') && !self::$aryGlobalSettings['disable_ssl_verify']?'enabled':'disabled')."\n";
|
76 |
+
echo 'User Agent: '.$strUA."\n";
|
77 |
echo 'Call: '.$strURL.'&token_auth= + TOKEN'."\n";
|
78 |
$x = microtime(true);
|
79 |
+
$strResult = getRemoteFile($strURL,$strToken,!self::$aryGlobalSettings['disable_ssl_verify'],$strUA);
|
80 |
$x = microtime(true) - $x;
|
81 |
echo 'Result:'."\n";
|
82 |
echo htmlentities($strResult)."\n";
|
languages/wp-piwik-de_DE.mo
CHANGED
Binary file
|
languages/wp-piwik-de_DE.po
CHANGED
@@ -605,4 +605,22 @@ msgid "Tabbed settings page suggested by the"
|
|
605 |
msgstr "Die Tabs für die Einstellungen wurden inspiriert von einem Artikel im"
|
606 |
|
607 |
msgid "If you like to use the PHP API and also to enable tracking by WP-Piwik, please enter your Piwik URL, too. Otherwise your tracking code may be erroneous."
|
608 |
-
msgstr "Falls Du die PHP API verwenden und das Tracking per WP-Piwik aktivieren willst, gib bitte auch Deine Piwik URL an. Andernfalls könnte Dein Tracking Code fehlerhaft sein."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
605 |
msgstr "Die Tabs für die Einstellungen wurden inspiriert von einem Artikel im"
|
606 |
|
607 |
msgid "If you like to use the PHP API and also to enable tracking by WP-Piwik, please enter your Piwik URL, too. Otherwise your tracking code may be erroneous."
|
608 |
+
msgstr "Falls Du die PHP API verwenden und das Tracking per WP-Piwik aktivieren willst, gib bitte auch Deine Piwik URL an. Andernfalls könnte Dein Tracking Code fehlerhaft sein."
|
609 |
+
|
610 |
+
msgid "Title"
|
611 |
+
msgstr "Titel"
|
612 |
+
|
613 |
+
msgid "Site ID (Piwik)"
|
614 |
+
msgstr "Seiten-ID (Piwik)"
|
615 |
+
|
616 |
+
msgid "Expert Settings"
|
617 |
+
msgstr "Expertenkonfiguration"
|
618 |
+
|
619 |
+
msgid "Disable SSL peer verification"
|
620 |
+
msgstr "SSL Peer-Verifikation deaktivieren"
|
621 |
+
|
622 |
+
msgid "not recommended"
|
623 |
+
msgstr "Nicht empfohlen"
|
624 |
+
|
625 |
+
msgid "Invalid path. Please enter the file path to Piwik."
|
626 |
+
msgstr "Ungültiger Pfad. Bitte gib den Dateipfad von Piwik an."
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== WP-Piwik ===
|
2 |
|
3 |
Contributors: Braekling
|
4 |
-
Requires at least: 3.
|
5 |
-
Tested up to: 3.4
|
6 |
-
Stable tag: 0.9.
|
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 |
|
@@ -92,11 +92,22 @@ Add WP-Piwik to your /wp-content/plugins folder and enable it as [Network Plugin
|
|
92 |
|
93 |
== Upgrade Notice ==
|
94 |
|
95 |
-
= 0.9.
|
96 |
-
|
97 |
|
98 |
== Changelog ==
|
99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
= 0.9.5 =
|
101 |
* WordPress 3.4 compatible (workaround)
|
102 |
|
1 |
=== WP-Piwik ===
|
2 |
|
3 |
Contributors: Braekling
|
4 |
+
Requires at least: 3.4
|
5 |
+
Tested up to: 3.4.2
|
6 |
+
Stable tag: 0.9.6
|
7 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6046779
|
8 |
Tags: statistics, stats, analytics, piwik, wpmu
|
9 |
|
92 |
|
93 |
== Upgrade Notice ==
|
94 |
|
95 |
+
= 0.9.6 =
|
96 |
+
WordPress metabox concept used properly, different bugfixes, custom variables feature added.
|
97 |
|
98 |
== Changelog ==
|
99 |
|
100 |
+
= 0.9.6 =
|
101 |
+
* Option: Disable SSL peer verification (REST API)
|
102 |
+
* Option: Use own user agent
|
103 |
+
* Test script displays additional information (e.g. response headers)
|
104 |
+
* Using WordPress metabox concept properly
|
105 |
+
* Bugfix: Sparkline script only loaded if required
|
106 |
+
* Stats site supports up to 3 columns
|
107 |
+
* Network admin stats: Choose site using a paged table (instead of a select box).
|
108 |
+
* Feature: [Custom variables](http://piwik.org/docs/javascript-tracking/#toc-custom-variables), using [custom post meta boxes](http://wp.smashingmagazine.com/2011/10/04/create-custom-post-meta-boxes-wordpress/).
|
109 |
+
* Some minor bugfixes
|
110 |
+
|
111 |
= 0.9.5 =
|
112 |
* WordPress 3.4 compatible (workaround)
|
113 |
|
settings/piwik.php
CHANGED
@@ -31,6 +31,10 @@ if (!$bolFOpen && !$bolCURL) {
|
|
31 |
<input type="radio" name="wp-piwik_mode" onchange="javascript:$j('#wp-piwik_path,#wp-piwik_path-label').toggleClass('wp-piwik-input-hide');" value="php" <?php echo (self::$aryGlobalSettings['piwik_mode']=='php'?'checked="checked" ':''); ?>/>
|
32 |
<input <?php echo (self::$aryGlobalSettings['piwik_mode']!='php'?'class="wp-piwik-input-hide" ':''); ?>id="wp-piwik_path" name="wp-piwik_path" type="text" value="<?php echo self::$aryGlobalSettings['piwik_path']; ?>" />
|
33 |
<label <?php echo (self::$aryGlobalSettings['piwik_mode']!='php'?'class="wp-piwik-input-hide" ':''); ?>id="wp-piwik_path-label" for="wp-piwik_path"><?php _e('If you like to use the PHP API and also to enable tracking by WP-Piwik, please enter your Piwik URL, too. Otherwise your tracking code may be erroneous.','wp-piwik'); ?> [<a href="http://dev.piwik.org/trac/ticket/3220">Details</a>]</label>
|
|
|
|
|
|
|
|
|
34 |
</td>
|
35 |
</tr><tr>
|
36 |
<th><?php _e('Auth token', 'wp-piwik'); ?>:</th>
|
@@ -70,11 +74,41 @@ if (!empty(self::$aryGlobalSettings['piwik_url']) && !empty(self::$aryGlobalSett
|
|
70 |
foreach ($aryOptions as $strOption) echo $strOption;
|
71 |
echo '</select></td></tr>';
|
72 |
} else {
|
|
|
|
|
73 |
echo '<tr><th>'.__('Determined site', 'wp-piwik').':</th><td>';
|
74 |
echo '<div class="input-text-wrap">';
|
75 |
-
|
|
|
|
|
76 |
if ($arySite['idsite'] == self::$arySettings['site_id']) {echo '<em>'.htmlentities($arySite['name'], ENT_QUOTES, 'utf-8').'</em>'; break;}
|
77 |
-
echo '<input type="hidden" name="wp-piwik_siteid" id="wp-piwik_siteid" value="'.self::$arySettings['site_id'].'" /></td></tr>';
|
78 |
}
|
79 |
}
|
80 |
-
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
<input type="radio" name="wp-piwik_mode" onchange="javascript:$j('#wp-piwik_path,#wp-piwik_path-label').toggleClass('wp-piwik-input-hide');" value="php" <?php echo (self::$aryGlobalSettings['piwik_mode']=='php'?'checked="checked" ':''); ?>/>
|
32 |
<input <?php echo (self::$aryGlobalSettings['piwik_mode']!='php'?'class="wp-piwik-input-hide" ':''); ?>id="wp-piwik_path" name="wp-piwik_path" type="text" value="<?php echo self::$aryGlobalSettings['piwik_path']; ?>" />
|
33 |
<label <?php echo (self::$aryGlobalSettings['piwik_mode']!='php'?'class="wp-piwik-input-hide" ':''); ?>id="wp-piwik_path-label" for="wp-piwik_path"><?php _e('If you like to use the PHP API and also to enable tracking by WP-Piwik, please enter your Piwik URL, too. Otherwise your tracking code may be erroneous.','wp-piwik'); ?> [<a href="http://dev.piwik.org/trac/ticket/3220">Details</a>]</label>
|
34 |
+
<?php
|
35 |
+
if (isset($_POST['wp-piwik_path']) && !empty($_POST['wp-piwik_path']) && realpath($_POST['wp-piwik_path']) === false)
|
36 |
+
echo '<p class="wp-piwik-eyecatcher">'.__('Invalid path. Please enter the file path to Piwik.', 'wp-piwik').'</p>';
|
37 |
+
?>
|
38 |
</td>
|
39 |
</tr><tr>
|
40 |
<th><?php _e('Auth token', 'wp-piwik'); ?>:</th>
|
74 |
foreach ($aryOptions as $strOption) echo $strOption;
|
75 |
echo '</select></td></tr>';
|
76 |
} else {
|
77 |
+
if (empty(self::$arySettings['site_id']))
|
78 |
+
$this->addPiwikSite();
|
79 |
echo '<tr><th>'.__('Determined site', 'wp-piwik').':</th><td>';
|
80 |
echo '<div class="input-text-wrap">';
|
81 |
+
if (is_array(self::$arySettings['site_id']) && self::$arySettings['site_id']['result'] == 'error')
|
82 |
+
self::showErrorMessage(self::$arySettings['site_id']['message']);
|
83 |
+
else foreach ($aryData as $arySite)
|
84 |
if ($arySite['idsite'] == self::$arySettings['site_id']) {echo '<em>'.htmlentities($arySite['name'], ENT_QUOTES, 'utf-8').'</em>'; break;}
|
85 |
+
echo '<input type="hidden" name="wp-piwik_siteid" id="wp-piwik_siteid" value="'.(int)self::$arySettings['site_id'].'" /></td></tr>';
|
86 |
}
|
87 |
}
|
88 |
+
}}
|
89 |
+
// Expert settings (cURL only)
|
90 |
+
?><tr>
|
91 |
+
<th colspan="2"><strong><?php _e('Expert Settings', 'wp-piwik'); ?>:</strong></th>
|
92 |
+
</tr>
|
93 |
+
<?php if (function_exists('curl_init')) { ?>
|
94 |
+
<tr>
|
95 |
+
<th><label <?php echo (self::$aryGlobalSettings['piwik_mode']=='php'?'class="wp-piwik-input-hide" ':''); ?>id="wp-piwik_disable_ssl_verify-label"><?php _e('Disable SSL peer verification', 'wp-piwik'); ?>:</label></th>
|
96 |
+
<td>
|
97 |
+
<input <?php echo (self::$aryGlobalSettings['piwik_mode']=='php'?'class="wp-piwik-input-hide" ':''); ?>id="wp-piwik_disable_ssl_verify" name="wp-piwik_disable_ssl_verify" type="checkbox"<?php echo (self::$aryGlobalSettings['disable_ssl_verify']?'checked="checked"':''); ?> /> (<?php _e('not recommended','wp-piwik'); ?>)
|
98 |
+
</td>
|
99 |
+
</tr><tr>
|
100 |
+
<th><label>User agent:</label></th>
|
101 |
+
<td>
|
102 |
+
<input type="radio" onchange="javascript:$j('#wp-piwik-useragent').toggleClass('readonly="readonly"');" name="wp-piwik_useragent" value="php" <?php echo (self::$aryGlobalSettings['piwik_useragent']=='php'?'checked="checked" ':''); ?>/> PHP default (<?php echo ini_get('user_agent'); ?>)
|
103 |
+
</td>
|
104 |
+
</tr><tr>
|
105 |
+
<th></th>
|
106 |
+
<td>
|
107 |
+
<input type="radio" onchange="javascript:$j('#wp-piwik-useragent').toggleClass('wp-piwik-useragent-disable');" name="wp-piwik_useragent" value="own" <?php echo (self::$aryGlobalSettings['piwik_useragent']=='own'?'checked="checked" ':''); ?>/> <input type="text" id="wp-piwik-useragent" name="wp-piwik_useragent_string" value="<?php echo self::$aryGlobalSettings['piwik_useragent_string']; ?>" />
|
108 |
+
</td>
|
109 |
+
</tr>
|
110 |
+
<?php } else { ?>
|
111 |
+
<tr>
|
112 |
+
<td colspan="2">cURL required. See <a href="http://www.php.net/manual/curl.setup.php">PHP manual</a>.</td>
|
113 |
+
</tr>
|
114 |
+
<?php }
|
settings/sitebrowser.php
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
<?php
|
2 |
$bolCURL = function_exists('curl_init');
|
3 |
$bolFOpen = ini_get('allow_url_fopen');
|
|
|
|
|
4 |
if (!$bolFOpen && !$bolCURL) {
|
5 |
?><tr>
|
6 |
<td colspan="2">
|
@@ -22,15 +24,15 @@ class SiteBrowser extends WP_List_Table {
|
|
22 |
|
23 |
function get_columns(){
|
24 |
$columns = array(
|
25 |
-
'id' => 'ID',
|
26 |
-
'name' => 'Title',
|
27 |
-
'siteurl' => 'URL',
|
28 |
-
'piwikid' => 'Site ID (Piwik)'
|
29 |
);
|
30 |
return $columns;
|
31 |
}
|
32 |
|
33 |
-
function prepare_items() {
|
34 |
$current_page = $this->get_pagenum();
|
35 |
$per_page = 10;
|
36 |
global $blog_id;
|
@@ -66,9 +68,12 @@ class SiteBrowser extends WP_List_Table {
|
|
66 |
'total_items' => $total_items,
|
67 |
'per_page' => $per_page
|
68 |
));
|
69 |
-
foreach ($this->aryData as $intKey => $aryDataset)
|
70 |
-
if (empty($aryDataset['piwikid']))
|
71 |
$this->aryData[$intKey]['piwikid'] = '<a href="'.admin_url(($pagenow == 'settings.php'?'network/':'')).$pagenow.'?page=wp-piwik/wp-piwik.php&tab=sitebrowser'.($aryDataset['id'] != '-'?'&wpmu_show_stats='.$aryDataset['id']:'').'">Create Piwik site</a>';
|
|
|
|
|
|
|
72 |
$this->items = $this->aryData;
|
73 |
return count($this->items);
|
74 |
}
|
@@ -86,7 +91,7 @@ class SiteBrowser extends WP_List_Table {
|
|
86 |
}
|
87 |
}
|
88 |
$objSiteBrowser = new SiteBrowser();
|
89 |
-
$intCnt = $objSiteBrowser->prepare_items();
|
90 |
if ($intCnt > 0) $objSiteBrowser->display();
|
91 |
else echo '<p>No site configured yet.</p>'
|
92 |
?>
|
1 |
<?php
|
2 |
$bolCURL = function_exists('curl_init');
|
3 |
$bolFOpen = ini_get('allow_url_fopen');
|
4 |
+
if (!isset($bolNetwork))
|
5 |
+
$bolNetwork = false;
|
6 |
if (!$bolFOpen && !$bolCURL) {
|
7 |
?><tr>
|
8 |
<td colspan="2">
|
24 |
|
25 |
function get_columns(){
|
26 |
$columns = array(
|
27 |
+
'id' => __('ID','wp-piwik'),
|
28 |
+
'name' => __('Title','wp-piwik'),
|
29 |
+
'siteurl' => __('URL','wp-piwik'),
|
30 |
+
'piwikid' => __('Site ID (Piwik)','wp-piwik')
|
31 |
);
|
32 |
return $columns;
|
33 |
}
|
34 |
|
35 |
+
function prepare_items($bolNetwork = false) {
|
36 |
$current_page = $this->get_pagenum();
|
37 |
$per_page = 10;
|
38 |
global $blog_id;
|
68 |
'total_items' => $total_items,
|
69 |
'per_page' => $per_page
|
70 |
));
|
71 |
+
foreach ($this->aryData as $intKey => $aryDataset) {
|
72 |
+
if (empty($aryDataset['piwikid']) || !is_int($aryDataset['piwikid']))
|
73 |
$this->aryData[$intKey]['piwikid'] = '<a href="'.admin_url(($pagenow == 'settings.php'?'network/':'')).$pagenow.'?page=wp-piwik/wp-piwik.php&tab=sitebrowser'.($aryDataset['id'] != '-'?'&wpmu_show_stats='.$aryDataset['id']:'').'">Create Piwik site</a>';
|
74 |
+
if ($bolNetwork)
|
75 |
+
$this->aryData[$intKey]['name'] = '<a href="?page=wp-piwik_stats&wpmu_show_stats='.$aryDataset['id'].'">'.$aryDataset['name'].'</a>';
|
76 |
+
}
|
77 |
$this->items = $this->aryData;
|
78 |
return count($this->items);
|
79 |
}
|
91 |
}
|
92 |
}
|
93 |
$objSiteBrowser = new SiteBrowser();
|
94 |
+
$intCnt = $objSiteBrowser->prepare_items($bolNetwork);
|
95 |
if ($intCnt > 0) $objSiteBrowser->display();
|
96 |
else echo '<p>No site configured yet.</p>'
|
97 |
?>
|
settings/support.php
CHANGED
@@ -32,13 +32,13 @@
|
|
32 |
self::loadTestscript();
|
33 |
break;
|
34 |
case 'reset':
|
35 |
-
echo '<p><strong class="wp-piwik-error">'.__('Please confirm your reset request','wp-piwik').':</strong> <a href="?page=wp-piwik/wp-piwik.php&tab=support&mode=resetconfirmed">'.__('YES, please reset <strong>all</strong> WP-Piwik settings <strong>except</strong> auth token and Piwi URL.', 'wp-piwik').'</a></p>';
|
36 |
break;
|
37 |
case 'resetconfirmed':
|
38 |
// Increase time limit before resetting
|
39 |
set_time_limit(0);
|
40 |
self::resetSettings();
|
41 |
-
echo '<p><strong>'.__('WP-Piwik reset done','wp-piwik').'</p>';
|
42 |
default:
|
43 |
}
|
44 |
}
|
32 |
self::loadTestscript();
|
33 |
break;
|
34 |
case 'reset':
|
35 |
+
echo '<p class="wp-piwik-eyecatcher"><strong class="wp-piwik-error">'.__('Please confirm your reset request','wp-piwik').':</strong> <a href="?page=wp-piwik/wp-piwik.php&tab=support&mode=resetconfirmed">'.__('YES, please reset <strong>all</strong> WP-Piwik settings <strong>except</strong> auth token and Piwi URL.', 'wp-piwik').'</a></p>';
|
36 |
break;
|
37 |
case 'resetconfirmed':
|
38 |
// Increase time limit before resetting
|
39 |
set_time_limit(0);
|
40 |
self::resetSettings();
|
41 |
+
echo '<p class="wp-piwik-eyecatcher"><strong>'.__('WP-Piwik reset done','wp-piwik').'</strong></p>';
|
42 |
default:
|
43 |
}
|
44 |
}
|
settings/tracking.php
CHANGED
@@ -7,7 +7,7 @@ if (!$bolFOpen && !$bolCURL) {
|
|
7 |
<strong><?php _e('Error: cURL is not enabled and fopen is not allowed to open URLs. WP-Piwik won\'t be able to connect to Piwik.'); ?></strong>
|
8 |
</td>
|
9 |
</tr><?php } else { ?>
|
10 |
-
<tr><
|
11 |
<input
|
12 |
onchange="javascript:$j('#wp-piwik-tracking-settings').toggleClass('wp-piwik-form-table-hide');"
|
13 |
type="checkbox" value="1" id="wp-piwik_addjs" name="wp-piwik_addjs"<?php echo (self::$aryGlobalSettings['add_tracking_code']?' checked="checked"':''); ?> />
|
@@ -16,11 +16,16 @@ if (!$bolFOpen && !$bolCURL) {
|
|
16 |
</table>
|
17 |
<?php
|
18 |
if (self::$aryGlobalSettings['add_tracking_code']) {
|
19 |
-
$strJavaScript =
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
24 |
self::saveSettings();
|
25 |
}
|
26 |
?>
|
7 |
<strong><?php _e('Error: cURL is not enabled and fopen is not allowed to open URLs. WP-Piwik won\'t be able to connect to Piwik.'); ?></strong>
|
8 |
</td>
|
9 |
</tr><?php } else { ?>
|
10 |
+
<tr><td colspan="2"><?php _e('Add tracking code', 'wp-piwik'); ?>:
|
11 |
<input
|
12 |
onchange="javascript:$j('#wp-piwik-tracking-settings').toggleClass('wp-piwik-form-table-hide');"
|
13 |
type="checkbox" value="1" id="wp-piwik_addjs" name="wp-piwik_addjs"<?php echo (self::$aryGlobalSettings['add_tracking_code']?' checked="checked"':''); ?> />
|
16 |
</table>
|
17 |
<?php
|
18 |
if (self::$aryGlobalSettings['add_tracking_code']) {
|
19 |
+
$strJavaScript = $this->callPiwikAPI('SitesManager.getJavascriptTag');
|
20 |
+
if (is_array($strJavaScript)) {
|
21 |
+
if (isset($strJavaScript['result']) && $strJavaScript['result'] == 'error')
|
22 |
+
self::showErrorMessage(__($strJavaScript['message'],'wp-piwik'));
|
23 |
+
} else {
|
24 |
+
// Change Tracking code if configured
|
25 |
+
$strJavaScript = $this->applyJSCodeChanges(html_entity_decode($strJavaScript));
|
26 |
+
// Save javascript code
|
27 |
+
self::$arySettings['tracking_code'] = $strJavaScript;
|
28 |
+
}
|
29 |
self::saveSettings();
|
30 |
}
|
31 |
?>
|
update/90601.php
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
self::$aryGlobalSettings['piwik_useragent'] = 'php';
|
3 |
+
self::$aryGlobalSettings['piwik_useragent_string'] = 'WP-Piwik';
|
wp-piwik.php
CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://wordpress.org/extend/plugins/wp-piwik/
|
|
6 |
|
7 |
Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress footer.
|
8 |
|
9 |
-
Version: 0.9.
|
10 |
Author: André Bräkling
|
11 |
Author URI: http://www.braekling.de
|
12 |
|
@@ -60,19 +60,21 @@ if (!function_exists('is_plugin_active_for_network'))
|
|
60 |
class wp_piwik {
|
61 |
|
62 |
private static
|
63 |
-
$intRevisionId =
|
64 |
-
$strVersion = '0.9.
|
65 |
$intDashboardID = 30,
|
66 |
$strPluginBasename = NULL,
|
67 |
$bolJustActivated = false,
|
68 |
$aryGlobalSettings = array(
|
69 |
-
'revision' =>
|
70 |
'add_tracking_code' => false,
|
71 |
'last_settings_update' => 0,
|
72 |
'piwik_token' => '',
|
73 |
'piwik_url' => '',
|
74 |
'piwik_path' => '',
|
75 |
'piwik_mode' => 'http',
|
|
|
|
|
76 |
'dashboard_widget' => false,
|
77 |
'dashboard_chart' => false,
|
78 |
'dashboard_seo' => false,
|
@@ -86,6 +88,7 @@ class wp_piwik {
|
|
86 |
'track_compress' => false,
|
87 |
'track_post' => false,
|
88 |
'disable_timelimit' => false,
|
|
|
89 |
'disable_cookies' => false,
|
90 |
'toolbar' => false
|
91 |
),
|
@@ -161,9 +164,7 @@ class wp_piwik {
|
|
161 |
// Add meta links to plugin details
|
162 |
add_filter('plugin_row_meta', array($this, 'setPluginMeta'), 10, 2);
|
163 |
// Register columns
|
164 |
-
|
165 |
-
* add_filter('screen_layout_columns', array(&$this, 'onScreenLayoutColumns'), 10, 2);
|
166 |
-
*/
|
167 |
// Add network admin menu if required
|
168 |
if (is_plugin_active_for_network('wp-piwik/wp-piwik.php'))
|
169 |
add_action('network_admin_menu', array($this, 'buildNetworkAdminMenu'));
|
@@ -171,6 +172,9 @@ class wp_piwik {
|
|
171 |
add_action('admin_menu', array($this, 'buildAdminMenu'));
|
172 |
// Register the callback been used if options of page been submitted and needs to be processed
|
173 |
add_action('admin_post_save_wp-piwik_stats', array(&$this, 'onStatsPageSaveChanges'));
|
|
|
|
|
|
|
174 |
// Add dashboard widget if enabled
|
175 |
/* TODO: Use bitmask here */
|
176 |
if (self::$aryGlobalSettings['dashboard_widget'] || self::$aryGlobalSettings['dashboard_chart'] || self::$aryGlobalSettings['dashboard_seo'])
|
@@ -234,6 +238,8 @@ class wp_piwik {
|
|
234 |
self::includeFile('update/90206');
|
235 |
if (self::$aryGlobalSettings['revision'] < 90405)
|
236 |
self::includeFile('update/90405');
|
|
|
|
|
237 |
// Install new version
|
238 |
$this->installPlugin();
|
239 |
}
|
@@ -307,10 +313,100 @@ class wp_piwik {
|
|
307 |
else $strTrackingCode = self::$arySettings['tracking_code'];
|
308 |
// Send tracking code
|
309 |
echo '<!-- *** WP-Piwik - see http://www.braekling.de/wp-piwik-wpmu-piwik-wordpress/ -->'."\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
echo $strTrackingCode;
|
311 |
echo '<!-- *** /WP-Piwik *********************************************************** -->'."\n";
|
312 |
}
|
313 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
314 |
/**
|
315 |
* Add pages to admin menu
|
316 |
*/
|
@@ -364,7 +460,7 @@ class wp_piwik {
|
|
364 |
__('WP-Piwik', 'wp-piwik'),
|
365 |
'manage_sites',
|
366 |
'wp-piwik_stats',
|
367 |
-
array($this, '
|
368 |
);
|
369 |
// Add required scripts
|
370 |
add_action('admin_print_scripts-'.$this->intStatsPage, array($this, 'loadStatsScripts'));
|
@@ -397,7 +493,7 @@ class wp_piwik {
|
|
397 |
*/
|
398 |
function onScreenLayoutColumns($aryColumns, $strScreen) {
|
399 |
if ($strScreen == $this->intStatsPage)
|
400 |
-
$aryColumns[$this->intStatsPage] =
|
401 |
return $aryColumns;
|
402 |
}
|
403 |
|
@@ -432,7 +528,7 @@ class wp_piwik {
|
|
432 |
*/
|
433 |
public function extendWordPressToolbar(&$objToolbar) {
|
434 |
// Is user allowed to see stats?
|
435 |
-
if (current_user_can('wp-piwik_read_stats')) {
|
436 |
$aryUnique = $this->callPiwikAPI('VisitsSummary.getUniqueVisitors','day','last30',null);
|
437 |
$strGraph = '<script type="text/javascript">';
|
438 |
$strGraph .= "var \$jSpark = jQuery.noConflict();\$jSpark(function() {var piwikSparkVals=[".implode(',',$aryUnique)."];\$jSpark('.wp-piwik_dynbar').sparkline(piwikSparkVals, {type: 'bar', barColor: '#ccc', barWidth:2});});";
|
@@ -540,10 +636,13 @@ class wp_piwik {
|
|
540 |
* Load scripts required by Toolbar graphs
|
541 |
*/
|
542 |
function loadToolbarRequirements() {
|
543 |
-
//
|
544 |
-
|
545 |
-
|
546 |
-
|
|
|
|
|
|
|
547 |
}
|
548 |
|
549 |
/**
|
@@ -600,6 +699,10 @@ class wp_piwik {
|
|
600 |
if (function_exists('curl_init')) {
|
601 |
// Init cURL
|
602 |
$c = curl_init($strURL);
|
|
|
|
|
|
|
|
|
603 |
// Configure cURL CURLOPT_RETURNTRANSFER = 1
|
604 |
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
|
605 |
// Configure cURL CURLOPT_HEADER = 0
|
@@ -629,13 +732,18 @@ class wp_piwik {
|
|
629 |
function callPHP($strParams) {
|
630 |
if (PIWIK_INCLUDE_PATH === FALSE)
|
631 |
return serialize(array('result' => 'error', 'message' => __('Could not resolve','wp-piwik').' "'.htmlentities(self::$aryGlobalSettings['piwik_path']).'": '.__('realpath() returns false','wp-piwik').'.'));
|
632 |
-
|
633 |
-
|
634 |
-
|
|
|
|
|
|
|
635 |
// Add Piwik URL to params
|
636 |
$strParams .= '&piwikUrl='.urlencode(self::$aryGlobalSettings['piwik_url']);
|
637 |
// This inits the API Request with the specified parameters
|
638 |
-
|
|
|
|
|
639 |
// Calls the API and fetch XML data back
|
640 |
return $objRequest->process();
|
641 |
}
|
@@ -669,7 +777,7 @@ class wp_piwik {
|
|
669 |
$strURL .= '&token_auth='.self::$aryGlobalSettings['piwik_token'];
|
670 |
$aryResult = unserialize($this->getRemoteFile($strURL));
|
671 |
if (!empty($aryResult) && isset($aryResult[0]['idsite'])) {
|
672 |
-
self::$arySettings['site_id'] = $aryResult[0]['idsite'];
|
673 |
self::$arySettings['last_tracking_code_update'] = time();
|
674 |
// Otherwise create new site
|
675 |
} elseif (self::isConfigured() && !empty($strURL)) {
|
@@ -746,7 +854,11 @@ class wp_piwik {
|
|
746 |
$intSite = $aryOptions['site_id'];
|
747 |
else $intSite = self::$arySettings['site_id'];
|
748 |
// Otherwise use the current site's id.
|
749 |
-
} else
|
|
|
|
|
|
|
|
|
750 |
// Create error message if WP-Piwik isn't configured
|
751 |
if (!self::isConfigured()) {
|
752 |
$this->aryCache[$strKey] = array(
|
@@ -757,7 +869,7 @@ class wp_piwik {
|
|
757 |
}
|
758 |
// Build URL
|
759 |
$strURL = '&method='.$strMethod;
|
760 |
-
$strURL .= '&idSite='
|
761 |
$strURL .= '&filter_limit='.$intLimit;
|
762 |
$strURL .= '&token_auth='.$strToken;
|
763 |
$strURL .= '&expanded='.$bolExpanded;
|
@@ -855,20 +967,26 @@ class wp_piwik {
|
|
855 |
);
|
856 |
}
|
857 |
}
|
858 |
-
|
859 |
-
|
|
|
|
|
|
|
|
|
|
|
860 |
// Disabled time limit if required
|
861 |
if (isset(self::$aryGlobalSettings['disable_timelimit']) && self::$aryGlobalSettings['disable_timelimit'])
|
862 |
set_time_limit(0);
|
863 |
//we need the global screen column value to be able to have a sidebar in WordPress 2.8
|
864 |
-
global $screen_layout_columns;
|
|
|
865 |
/***************************************************************************/ ?>
|
866 |
<div id="wp-piwik-stats-general" class="wrap">
|
867 |
<?php screen_icon('options-general'); ?>
|
868 |
<h2><?php _e('Piwik Statistics', 'wp-piwik'); ?></h2>
|
869 |
<?php /************************************************************************/
|
870 |
-
if (is_plugin_active_for_network('wp-piwik/wp-piwik.php') && function_exists('is_super_admin') && is_super_admin()) {
|
871 |
-
global $blog_id;
|
872 |
global $wpdb;
|
873 |
$aryBlogs = $wpdb->get_results($wpdb->prepare('SELECT blog_id FROM '.$wpdb->blogs.' ORDER BY blog_id'));
|
874 |
if (isset($_GET['wpmu_show_stats'])) {
|
@@ -887,8 +1005,15 @@ class wp_piwik {
|
|
887 |
// Show blogs in alphabetical order
|
888 |
ksort($aryOptions);
|
889 |
foreach ($aryOptions as $strOption) echo $strOption;
|
890 |
-
echo '</select><input type="submit" value="'.__('Change').'" />'."\n ";
|
891 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
892 |
echo '</form>'."\n";
|
893 |
}
|
894 |
/***************************************************************************/ ?>
|
@@ -897,16 +1022,19 @@ class wp_piwik {
|
|
897 |
<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false ); ?>
|
898 |
<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false ); ?>
|
899 |
<input type="hidden" name="action" value="save_wp-piwik_stats_general" />
|
900 |
-
<div id="
|
901 |
-
|
902 |
-
|
903 |
-
</div>
|
904 |
-
<div id="post-body" class="has-sidebar">
|
905 |
-
<div id="post-body-content" class="postbox-container has-sidebar-content wp-piwik-wide-content">
|
906 |
-
<?php $meta_boxes = do_meta_boxes($this->intStatsPage, 'normal', ''); ?>
|
907 |
</div>
|
908 |
-
|
909 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
910 |
</div>
|
911 |
</form>
|
912 |
</div>
|
@@ -921,7 +1049,7 @@ class wp_piwik {
|
|
921 |
//]]>
|
922 |
</script>
|
923 |
<?php /************************************************************************/
|
924 |
-
if (is_plugin_active_for_network('wp-piwik/wp-piwik.php') && function_exists('is_super_admin') && is_super_admin()) {
|
925 |
restore_current_blog();
|
926 |
}
|
927 |
}
|
@@ -1000,6 +1128,9 @@ class wp_piwik {
|
|
1000 |
self::$aryGlobalSettings['piwik_url'] = self::checkURL((isset($_POST['wp-piwik_url'])?$_POST['wp-piwik_url']:''));
|
1001 |
self::$aryGlobalSettings['piwik_path'] = (isset($_POST['wp-piwik_path']) && !empty($_POST['wp-piwik_path'])?realpath($_POST['wp-piwik_path']):'');
|
1002 |
self::$aryGlobalSettings['piwik_mode'] = (isset($_POST['wp-piwik_mode'])?$_POST['wp-piwik_mode']:'http');
|
|
|
|
|
|
|
1003 |
if (!is_plugin_active_for_network('wp-piwik/wp-piwik.php')) {
|
1004 |
self::$aryGlobalSettings['auto_site_config'] = (isset($_POST['wp-piwik_auto_site_config'])?$_POST['wp-piwik_auto_site_config']:false);
|
1005 |
if (!self::$aryGlobalSettings['auto_site_config'])
|
@@ -1079,7 +1210,7 @@ class wp_piwik {
|
|
1079 |
require_once('settings/'.$strTab.'.php');
|
1080 |
// Show submit button
|
1081 |
if (!in_array($strTab, array('homepage','credits','support','sitebrowser')))
|
1082 |
-
echo '<tr><td><p class="submit" style="clear: both;"><input type="submit" name="Submit" class="button-primary" value="'.__('Save settings', 'wp-piwik').'" /><input type="hidden" name="wp-piwik_settings_submit" value="Y" /></p></td></tr>';
|
1083 |
echo '</table>';
|
1084 |
}
|
1085 |
// Close form
|
@@ -1152,7 +1283,10 @@ class wp_piwik {
|
|
1152 |
'track_post' => false,
|
1153 |
'disable_timelimit' => false,
|
1154 |
'disable_cookies' => false,
|
1155 |
-
'toolbar' => false
|
|
|
|
|
|
|
1156 |
);
|
1157 |
// Reset network settings
|
1158 |
if (is_plugin_active_for_network('wp-piwik/wp-piwik.php')) {
|
@@ -1178,7 +1312,7 @@ class wp_piwik {
|
|
1178 |
$aryResult = get_blog_option($intBlogID, 'wp-piwik_settings');
|
1179 |
$intResult = $aryResult['site_id'];
|
1180 |
}
|
1181 |
-
return $intResult;
|
1182 |
}
|
1183 |
|
1184 |
/**
|
6 |
|
7 |
Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress footer.
|
8 |
|
9 |
+
Version: 0.9.6
|
10 |
Author: André Bräkling
|
11 |
Author URI: http://www.braekling.de
|
12 |
|
60 |
class wp_piwik {
|
61 |
|
62 |
private static
|
63 |
+
$intRevisionId = 90601,
|
64 |
+
$strVersion = '0.9.6',
|
65 |
$intDashboardID = 30,
|
66 |
$strPluginBasename = NULL,
|
67 |
$bolJustActivated = false,
|
68 |
$aryGlobalSettings = array(
|
69 |
+
'revision' => 90601,
|
70 |
'add_tracking_code' => false,
|
71 |
'last_settings_update' => 0,
|
72 |
'piwik_token' => '',
|
73 |
'piwik_url' => '',
|
74 |
'piwik_path' => '',
|
75 |
'piwik_mode' => 'http',
|
76 |
+
'piwik_useragent' => 'php',
|
77 |
+
'piwik_useragent_string' => 'WP-Piwik',
|
78 |
'dashboard_widget' => false,
|
79 |
'dashboard_chart' => false,
|
80 |
'dashboard_seo' => false,
|
88 |
'track_compress' => false,
|
89 |
'track_post' => false,
|
90 |
'disable_timelimit' => false,
|
91 |
+
'disable_ssl_verify' => false,
|
92 |
'disable_cookies' => false,
|
93 |
'toolbar' => false
|
94 |
),
|
164 |
// Add meta links to plugin details
|
165 |
add_filter('plugin_row_meta', array($this, 'setPluginMeta'), 10, 2);
|
166 |
// Register columns
|
167 |
+
add_filter('screen_layout_columns', array(&$this, 'onScreenLayoutColumns'), 10, 2);
|
|
|
|
|
168 |
// Add network admin menu if required
|
169 |
if (is_plugin_active_for_network('wp-piwik/wp-piwik.php'))
|
170 |
add_action('network_admin_menu', array($this, 'buildNetworkAdminMenu'));
|
172 |
add_action('admin_menu', array($this, 'buildAdminMenu'));
|
173 |
// Register the callback been used if options of page been submitted and needs to be processed
|
174 |
add_action('admin_post_save_wp-piwik_stats', array(&$this, 'onStatsPageSaveChanges'));
|
175 |
+
// Register own post meta boxes
|
176 |
+
add_action('load-post.php', array(&$this, 'postMetaboxes'));
|
177 |
+
add_action('load-post-new.php', array(&$this, 'postMetaboxes'));
|
178 |
// Add dashboard widget if enabled
|
179 |
/* TODO: Use bitmask here */
|
180 |
if (self::$aryGlobalSettings['dashboard_widget'] || self::$aryGlobalSettings['dashboard_chart'] || self::$aryGlobalSettings['dashboard_seo'])
|
238 |
self::includeFile('update/90206');
|
239 |
if (self::$aryGlobalSettings['revision'] < 90405)
|
240 |
self::includeFile('update/90405');
|
241 |
+
if (self::$aryGlobalSettings['revision'] < 90601)
|
242 |
+
self::includeFile('update/90601');
|
243 |
// Install new version
|
244 |
$this->installPlugin();
|
245 |
}
|
313 |
else $strTrackingCode = self::$arySettings['tracking_code'];
|
314 |
// Send tracking code
|
315 |
echo '<!-- *** WP-Piwik - see http://www.braekling.de/wp-piwik-wpmu-piwik-wordpress/ -->'."\n";
|
316 |
+
// Add custom variables if set:
|
317 |
+
if (is_single()) {
|
318 |
+
$strCustomVars = '';
|
319 |
+
for ($i = 1; $i <= 5; $i++) {
|
320 |
+
// Get post ID
|
321 |
+
$intID = get_the_ID();
|
322 |
+
// Get key
|
323 |
+
$strMetaKey = get_post_meta($intID, 'wp-piwik_custom_cat'.$i, true);
|
324 |
+
// Get value
|
325 |
+
$strMetaVal = get_post_meta($intID, 'wp-piwik_custom_val'.$i, true);
|
326 |
+
if (!empty($strMetaKey) && !empty($strMetaVal)) {
|
327 |
+
$strCustomVars .= 'piwikTracker.setCustomVariable('.$i.', "'.$strMetaKey.'", "'.$strMetaVal.'", "page");';
|
328 |
+
}
|
329 |
+
}
|
330 |
+
if (!empty($strMetaKey)) $strTrackingCode = str_replace('piwikTracker.trackPageView();', $strCustomVars.'piwikTracker.trackPageView();', $strTrackingCode);
|
331 |
+
}
|
332 |
echo $strTrackingCode;
|
333 |
echo '<!-- *** /WP-Piwik *********************************************************** -->'."\n";
|
334 |
}
|
335 |
|
336 |
+
/**
|
337 |
+
* Add metaboxes to posts
|
338 |
+
*/
|
339 |
+
function postMetaboxes() {
|
340 |
+
add_action('add_meta_boxes', array(&$this, 'postAddMetaboxes'));
|
341 |
+
add_action('save_post', array(&$this, 'postCustomvarsSave'), 10, 2);
|
342 |
+
}
|
343 |
+
|
344 |
+
/**
|
345 |
+
* Create post meta boxes
|
346 |
+
*/
|
347 |
+
function postAddMetaboxes() {
|
348 |
+
add_meta_box(
|
349 |
+
'wp-piwik_post_customvars',
|
350 |
+
__('Piwik Custom Variables', 'wp-piwik'),
|
351 |
+
array(&$this, 'postCustomvars'),
|
352 |
+
'post',
|
353 |
+
'side',
|
354 |
+
'default'
|
355 |
+
);
|
356 |
+
}
|
357 |
+
|
358 |
+
/**
|
359 |
+
* Display custom variables meta box
|
360 |
+
*/
|
361 |
+
function postCustomvars($objPost, $objBox ) {
|
362 |
+
wp_nonce_field(basename( __FILE__ ), 'wp-piwik_post_customvars_nonce'); ?>
|
363 |
+
<table>
|
364 |
+
<tr><th></th><th><?php _e('Name', 'wp-piwik'); ?></th><th><?php _e('Value', 'wp-piwik'); ?></th></tr>
|
365 |
+
<?php for($i = 1; $i <= 5; $i++) { ?>
|
366 |
+
<tr>
|
367 |
+
<th><label for="wp-piwik_customvar1"><?php echo $i; ?>: </label></th>
|
368 |
+
<td><input class="widefat" type="text" name="wp-piwik_custom_cat<?php echo $i; ?>" value="<?php echo esc_attr(get_post_meta($objPost->ID, 'wp-piwik_custom_cat'.$i, true ) ); ?>" size="200" /></td>
|
369 |
+
<td><input class="widefat" type="text" name="wp-piwik_custom_val<?php echo $i; ?>" value="<?php echo esc_attr(get_post_meta($objPost->ID, 'wp-piwik_custom_val'.$i, true ) ); ?>" size="200" /></td>
|
370 |
+
</tr>
|
371 |
+
<?php } ?>
|
372 |
+
</table>
|
373 |
+
<p><?php _e('Set custom variables for a page view', 'wp-piwik'); ?>. (<a href="http://piwik.org/docs/custom-variables/"><?php _e('More information', 'wp-piwik'); ?></a>.)</p>
|
374 |
+
<?php
|
375 |
+
}
|
376 |
+
|
377 |
+
/**
|
378 |
+
* Save post custom variables
|
379 |
+
*/
|
380 |
+
function postCustomvarsSave($intID, $objPost) {
|
381 |
+
// Verify the nonce before proceeding.
|
382 |
+
if (!isset( $_POST['wp-piwik_post_customvars_nonce'] ) || !wp_verify_nonce( $_POST['wp-piwik_post_customvars_nonce'], basename( __FILE__ ) ) )
|
383 |
+
return $intID;
|
384 |
+
// Get post type object
|
385 |
+
$objPostType = get_post_type_object($objPost->post_type);
|
386 |
+
// Check if the current user has permission to edit the post.
|
387 |
+
if (!current_user_can($objPostType->cap->edit_post, $intID))
|
388 |
+
return $intID;
|
389 |
+
$aryNames = array('cat', 'val');
|
390 |
+
for ($i = 1; $i <= 5; $i++)
|
391 |
+
for ($j = 0; $j <= 1; $j++) {
|
392 |
+
// Get data
|
393 |
+
$strMetaVal = (isset($_POST['wp-piwik_custom_'.$aryNames[$j].$i])?htmlentities($_POST['wp-piwik_custom_'.$aryNames[$j].$i]):'');
|
394 |
+
// Create key
|
395 |
+
$strMetaKey = 'wp-piwik_custom_'.$aryNames[$j].$i;
|
396 |
+
// Get the meta value of the custom field key
|
397 |
+
$strCurVal = get_post_meta($intID, $strMetaKey, true);
|
398 |
+
// Add meta val:
|
399 |
+
if ($strMetaVal && '' == $strCurVal)
|
400 |
+
add_post_meta($intID, $strMetaKey, $strMetaVal, true);
|
401 |
+
// Update meta val:
|
402 |
+
elseif ($strMetaVal && $strMetaVal != $strCurVal)
|
403 |
+
update_post_meta($intID, $strMetaKey, $strMetaVal);
|
404 |
+
// Delete meta val:
|
405 |
+
elseif (''==$strMetaVal && $strCurVal)
|
406 |
+
delete_post_meta($intID, $strMetaKey, $strCurVal);
|
407 |
+
}
|
408 |
+
}
|
409 |
+
|
410 |
/**
|
411 |
* Add pages to admin menu
|
412 |
*/
|
460 |
__('WP-Piwik', 'wp-piwik'),
|
461 |
'manage_sites',
|
462 |
'wp-piwik_stats',
|
463 |
+
array($this, 'showStatsNetwork')
|
464 |
);
|
465 |
// Add required scripts
|
466 |
add_action('admin_print_scripts-'.$this->intStatsPage, array($this, 'loadStatsScripts'));
|
493 |
*/
|
494 |
function onScreenLayoutColumns($aryColumns, $strScreen) {
|
495 |
if ($strScreen == $this->intStatsPage)
|
496 |
+
$aryColumns[$this->intStatsPage] = 3;
|
497 |
return $aryColumns;
|
498 |
}
|
499 |
|
528 |
*/
|
529 |
public function extendWordPressToolbar(&$objToolbar) {
|
530 |
// Is user allowed to see stats?
|
531 |
+
if (current_user_can('wp-piwik_read_stats') && is_array($aryUnique)) {
|
532 |
$aryUnique = $this->callPiwikAPI('VisitsSummary.getUniqueVisitors','day','last30',null);
|
533 |
$strGraph = '<script type="text/javascript">';
|
534 |
$strGraph .= "var \$jSpark = jQuery.noConflict();\$jSpark(function() {var piwikSparkVals=[".implode(',',$aryUnique)."];\$jSpark('.wp-piwik_dynbar').sparkline(piwikSparkVals, {type: 'bar', barColor: '#ccc', barWidth:2});});";
|
636 |
* Load scripts required by Toolbar graphs
|
637 |
*/
|
638 |
function loadToolbarRequirements() {
|
639 |
+
// Only load if user is allowed to see stats
|
640 |
+
if (current_user_can('wp-piwik_read_stats')) {
|
641 |
+
// Load Sparklines
|
642 |
+
wp_enqueue_script('wp-piwik-sparkline',$this->getPluginURL().'js/sparkline/jquery.sparkline.min.js',array('jquery'));
|
643 |
+
// Load CSS
|
644 |
+
wp_enqueue_style('wp-piwik', $this->getPluginURL().'css/wp-piwik-spark.css');
|
645 |
+
}
|
646 |
}
|
647 |
|
648 |
/**
|
699 |
if (function_exists('curl_init')) {
|
700 |
// Init cURL
|
701 |
$c = curl_init($strURL);
|
702 |
+
// Disable SSL peer verification if asked to
|
703 |
+
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, !self::$aryGlobalSettings['disable_ssl_verify']);
|
704 |
+
// Set user agent
|
705 |
+
curl_setopt($c, CURLOPT_USERAGENT, self::$aryGlobalSettings['piwik_useragent']=='php'?ini_get('user_agent'):self::$aryGlobalSettings['piwik_useragent_string']);
|
706 |
// Configure cURL CURLOPT_RETURNTRANSFER = 1
|
707 |
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
|
708 |
// Configure cURL CURLOPT_HEADER = 0
|
732 |
function callPHP($strParams) {
|
733 |
if (PIWIK_INCLUDE_PATH === FALSE)
|
734 |
return serialize(array('result' => 'error', 'message' => __('Could not resolve','wp-piwik').' "'.htmlentities(self::$aryGlobalSettings['piwik_path']).'": '.__('realpath() returns false','wp-piwik').'.'));
|
735 |
+
if (file_exists(PIWIK_INCLUDE_PATH . "/index.php"))
|
736 |
+
require_once PIWIK_INCLUDE_PATH . "/index.php";
|
737 |
+
if (file_exists(PIWIK_INCLUDE_PATH . "/core/API/Request.php"))
|
738 |
+
require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";
|
739 |
+
if (class_exists('Piwik_FrontController'))
|
740 |
+
Piwik_FrontController::getInstance()->init();
|
741 |
// Add Piwik URL to params
|
742 |
$strParams .= '&piwikUrl='.urlencode(self::$aryGlobalSettings['piwik_url']);
|
743 |
// This inits the API Request with the specified parameters
|
744 |
+
if (class_exists('Piwik_API_Request'))
|
745 |
+
$objRequest = new Piwik_API_Request($strParams);
|
746 |
+
else return NULL;
|
747 |
// Calls the API and fetch XML data back
|
748 |
return $objRequest->process();
|
749 |
}
|
777 |
$strURL .= '&token_auth='.self::$aryGlobalSettings['piwik_token'];
|
778 |
$aryResult = unserialize($this->getRemoteFile($strURL));
|
779 |
if (!empty($aryResult) && isset($aryResult[0]['idsite'])) {
|
780 |
+
self::$arySettings['site_id'] = (int)$aryResult[0]['idsite'];
|
781 |
self::$arySettings['last_tracking_code_update'] = time();
|
782 |
// Otherwise create new site
|
783 |
} elseif (self::isConfigured() && !empty($strURL)) {
|
854 |
$intSite = $aryOptions['site_id'];
|
855 |
else $intSite = self::$arySettings['site_id'];
|
856 |
// Otherwise use the current site's id.
|
857 |
+
} else {
|
858 |
+
if (empty(self::$arySettings['site_id']))
|
859 |
+
$aryNewSite = self::addPiwikSite();
|
860 |
+
$intSite = self::$arySettings['site_id'];
|
861 |
+
}
|
862 |
// Create error message if WP-Piwik isn't configured
|
863 |
if (!self::isConfigured()) {
|
864 |
$this->aryCache[$strKey] = array(
|
869 |
}
|
870 |
// Build URL
|
871 |
$strURL = '&method='.$strMethod;
|
872 |
+
$strURL .= '&idSite='.(int)$intSite.'&period='.$strPeriod.'&date='.$strDate;
|
873 |
$strURL .= '&filter_limit='.$intLimit;
|
874 |
$strURL .= '&token_auth='.$strToken;
|
875 |
$strURL .= '&expanded='.$bolExpanded;
|
967 |
);
|
968 |
}
|
969 |
}
|
970 |
+
|
971 |
+
// Open stats page as network admin
|
972 |
+
function showStatsNetwork() {
|
973 |
+
$this->showStats(true);
|
974 |
+
}
|
975 |
+
|
976 |
+
function showStats($bolNetwork = false) {
|
977 |
// Disabled time limit if required
|
978 |
if (isset(self::$aryGlobalSettings['disable_timelimit']) && self::$aryGlobalSettings['disable_timelimit'])
|
979 |
set_time_limit(0);
|
980 |
//we need the global screen column value to be able to have a sidebar in WordPress 2.8
|
981 |
+
global $screen_layout_columns;
|
982 |
+
if (empty($screen_layout_columns)) $screen_layout_columns = 2;
|
983 |
/***************************************************************************/ ?>
|
984 |
<div id="wp-piwik-stats-general" class="wrap">
|
985 |
<?php screen_icon('options-general'); ?>
|
986 |
<h2><?php _e('Piwik Statistics', 'wp-piwik'); ?></h2>
|
987 |
<?php /************************************************************************/
|
988 |
+
if (is_plugin_active_for_network('wp-piwik/wp-piwik.php') && function_exists('is_super_admin') && is_super_admin() && $bolNetwork) {
|
989 |
+
/* global $blog_id;
|
990 |
global $wpdb;
|
991 |
$aryBlogs = $wpdb->get_results($wpdb->prepare('SELECT blog_id FROM '.$wpdb->blogs.' ORDER BY blog_id'));
|
992 |
if (isset($_GET['wpmu_show_stats'])) {
|
1005 |
// Show blogs in alphabetical order
|
1006 |
ksort($aryOptions);
|
1007 |
foreach ($aryOptions as $strOption) echo $strOption;
|
1008 |
+
echo '</select><input type="submit" value="'.__('Change').'" />'."\n "; */
|
1009 |
+
if (isset($_GET['wpmu_show_stats'])) {
|
1010 |
+
switch_to_blog((int) $_GET['wpmu_show_stats']);
|
1011 |
+
self::loadSettings();
|
1012 |
+
} else {
|
1013 |
+
require_once('settings/sitebrowser.php');
|
1014 |
+
return;
|
1015 |
+
}
|
1016 |
+
echo '<p>'.__('Currently shown stats:').' <a href="'.get_bloginfo('url').'">'.(int) $_GET['wpmu_show_stats'].' - '.get_bloginfo('name').'</a>.'.' <a href="?page=wp-piwik_stats">Show site overview</a>.</p>'."\n";
|
1017 |
echo '</form>'."\n";
|
1018 |
}
|
1019 |
/***************************************************************************/ ?>
|
1022 |
<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false ); ?>
|
1023 |
<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false ); ?>
|
1024 |
<input type="hidden" name="action" value="save_wp-piwik_stats_general" />
|
1025 |
+
<div id="dashboard-widgets" class="metabox-holder columns-<?php echo $screen_layout_columns; ?><?php echo 2 <= $screen_layout_columns?' has-right-sidebar':''; ?>">
|
1026 |
+
<div id='postbox-container-1' class='postbox-container'>
|
1027 |
+
<?php $meta_boxes = do_meta_boxes($this->intStatsPage, 'normal', null); ?>
|
|
|
|
|
|
|
|
|
1028 |
</div>
|
1029 |
+
|
1030 |
+
<div id='postbox-container-2' class='postbox-container'>
|
1031 |
+
<?php do_meta_boxes($this->intStatsPage, 'side', null); ?>
|
1032 |
+
</div>
|
1033 |
+
|
1034 |
+
<div id='postbox-container-3' class='postbox-container'>
|
1035 |
+
<?php do_meta_boxes($this->intStatsPage, 'column3', null); ?>
|
1036 |
+
</div>
|
1037 |
+
|
1038 |
</div>
|
1039 |
</form>
|
1040 |
</div>
|
1049 |
//]]>
|
1050 |
</script>
|
1051 |
<?php /************************************************************************/
|
1052 |
+
if (is_plugin_active_for_network('wp-piwik/wp-piwik.php') && function_exists('is_super_admin') && is_super_admin() && $bolNetwork) {
|
1053 |
restore_current_blog();
|
1054 |
}
|
1055 |
}
|
1128 |
self::$aryGlobalSettings['piwik_url'] = self::checkURL((isset($_POST['wp-piwik_url'])?$_POST['wp-piwik_url']:''));
|
1129 |
self::$aryGlobalSettings['piwik_path'] = (isset($_POST['wp-piwik_path']) && !empty($_POST['wp-piwik_path'])?realpath($_POST['wp-piwik_path']):'');
|
1130 |
self::$aryGlobalSettings['piwik_mode'] = (isset($_POST['wp-piwik_mode'])?$_POST['wp-piwik_mode']:'http');
|
1131 |
+
self::$aryGlobalSettings['piwik_useragent'] = (isset($_POST['wp-piwik_useragent'])?$_POST['wp-piwik_useragent']:'php');
|
1132 |
+
self::$aryGlobalSettings['piwik_useragent_string'] = (isset($_POST['wp-piwik_useragent_string'])?$_POST['wp-piwik_useragent_string']:'WP-Piwik');
|
1133 |
+
self::$aryGlobalSettings['disable_ssl_verify'] = (isset($_POST['wp-piwik_disable_ssl_verify'])?$_POST['wp-piwik_disable_ssl_verify']:false);
|
1134 |
if (!is_plugin_active_for_network('wp-piwik/wp-piwik.php')) {
|
1135 |
self::$aryGlobalSettings['auto_site_config'] = (isset($_POST['wp-piwik_auto_site_config'])?$_POST['wp-piwik_auto_site_config']:false);
|
1136 |
if (!self::$aryGlobalSettings['auto_site_config'])
|
1210 |
require_once('settings/'.$strTab.'.php');
|
1211 |
// Show submit button
|
1212 |
if (!in_array($strTab, array('homepage','credits','support','sitebrowser')))
|
1213 |
+
echo '<tr><td><p class="submit" style="clear: both;padding:0;margin:0"><input type="submit" name="Submit" class="button-primary" value="'.__('Save settings', 'wp-piwik').'" /><input type="hidden" name="wp-piwik_settings_submit" value="Y" /></p></td></tr>';
|
1214 |
echo '</table>';
|
1215 |
}
|
1216 |
// Close form
|
1283 |
'track_post' => false,
|
1284 |
'disable_timelimit' => false,
|
1285 |
'disable_cookies' => false,
|
1286 |
+
'toolbar' => false,
|
1287 |
+
'piwik_useragent' => 'php',
|
1288 |
+
'piwik_useragent_string' => 'WP-Piwik',
|
1289 |
+
'disable_ssl_verify' => false
|
1290 |
);
|
1291 |
// Reset network settings
|
1292 |
if (is_plugin_active_for_network('wp-piwik/wp-piwik.php')) {
|
1312 |
$aryResult = get_blog_option($intBlogID, 'wp-piwik_settings');
|
1313 |
$intResult = $aryResult['site_id'];
|
1314 |
}
|
1315 |
+
return (is_int($intResult)?$intResult:'n/a');
|
1316 |
}
|
1317 |
|
1318 |
/**
|