Version Description
- Requires at least Piwik 1.8.2!
- Choose between HTTP API or PHP API
- Show graph on WordPress Toolbar
- Add option to disable cookies - Thanks to Mathias T.!
- Update bugfix: Upgrading from WP-Piwik 0.8.7 or less will work again
- Some minor bugfixes
Download this release
Release Info
Developer | Braekling |
Plugin | WP-Matomo (WP-Piwik) |
Version | 0.9.4 |
Comparing to | |
See all releases |
Code changes from version 0.9.2 to 0.9.4
- css/wp-piwik-spark.css +1 -0
- css/wp-piwik.css +9 -3
- languages/wp-piwik-de_DE.mo +0 -0
- languages/wp-piwik-de_DE.po +40 -1
- readme.txt +31 -3
- screenshot-4.gif +0 -0
- settings/credits.php +1 -1
- settings/homepage.php +1 -1
- settings/piwik.php +19 -7
- settings/support.php +2 -2
- settings/tracking.php +4 -0
- settings/views.php +4 -0
- update/80800.php +1 -1
- update/90405.php +5 -0
- wp-piwik.php +157 -41
css/wp-piwik-spark.css
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
.wp-piwik_dynbar canvas {padding-top:5px !important}
|
css/wp-piwik.css
CHANGED
@@ -34,8 +34,12 @@ form.wp-piwik-settings {
|
|
34 |
table.wp-piwik-form-table {
|
35 |
clear:none !important;
|
36 |
}
|
37 |
-
table.wp-piwik-form-table-hide {
|
38 |
-
display:none;
|
|
|
|
|
|
|
|
|
39 |
}
|
40 |
|
41 |
div.wp-piwik-donate {
|
@@ -109,4 +113,6 @@ strong.wp-piwik-error {color:#f00}
|
|
109 |
.wp-list-table .column-id {width:20%}
|
110 |
.wp-list-table .column-name {width:30%}
|
111 |
.wp-list-table .column-siteurl {width:30%}
|
112 |
-
.wp-list-table .column-piwikid {width:20%}
|
|
|
|
34 |
table.wp-piwik-form-table {
|
35 |
clear:none !important;
|
36 |
}
|
37 |
+
table.wp-piwik-form-table-hide, label.wp-piwik-input-hide {
|
38 |
+
display:none;
|
39 |
+
}
|
40 |
+
|
41 |
+
input.wp-piwik-input-hide {
|
42 |
+
visibility:hidden;
|
43 |
}
|
44 |
|
45 |
div.wp-piwik-donate {
|
113 |
.wp-list-table .column-id {width:20%}
|
114 |
.wp-list-table .column-name {width:30%}
|
115 |
.wp-list-table .column-siteurl {width:30%}
|
116 |
+
.wp-list-table .column-piwikid {width:20%}
|
117 |
+
|
118 |
+
.wp-piwik_dynbar canvas {padding-top:5px !important}
|
languages/wp-piwik-de_DE.mo
CHANGED
Binary file
|
languages/wp-piwik-de_DE.po
CHANGED
@@ -566,4 +566,43 @@ msgid "Use set_time_limit(0) if stats page causes a time out."
|
|
566 |
msgstr "Verwende set_time_limit(0) falls die Statistik-Seite einen Timeout erzeugt."
|
567 |
|
568 |
msgid "in network mode"
|
569 |
-
msgstr "im Netzwerk-Modus"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
566 |
msgstr "Verwende set_time_limit(0) falls die Statistik-Seite einen Timeout erzeugt."
|
567 |
|
568 |
msgid "in network mode"
|
569 |
+
msgstr "im Netzwerk-Modus"
|
570 |
+
|
571 |
+
msgid "To enable Piwik statistics, please enter"
|
572 |
+
msgstr "Um die Piwik-Statistiken zu aktivieren, gibt bitte die folgenden Daten ein:"
|
573 |
+
|
574 |
+
msgid "your Piwik base URL (like http://mydomain.com/piwik) or your Piwik server path (like /var/www/mydomain.com/httpdocs/piwik/)"
|
575 |
+
msgstr "Die URL Deiner Piwik-Installation (z.B. http://mydomain.com/piwik) oder den Serverpfad zu Deiner Piwik-Installation (z.B. /var/www/mydomain.com/httpdocs/piwik/)"
|
576 |
+
|
577 |
+
msgid "your personal Piwik authentification token. You can get the token on the API page inside your Piwik interface. It looks like "1234a5cd6789e0a12345b678cd9012ef"."
|
578 |
+
msgstr "Deinen persönlichen Piwik Authentifikations-Token. Du findest ihn auf der API-Seite des Piwik-Interfaces. Er sieht z.B. so aus: "1234a5cd6789e0a12345b678cd9012ef"."
|
579 |
+
|
580 |
+
msgid "No idea what I'm talking about?"
|
581 |
+
msgstr "Keine Idee, wovon ich rede?"
|
582 |
+
|
583 |
+
msgid "Get help."
|
584 |
+
msgstr "Hier gibt es Hilfe."
|
585 |
+
|
586 |
+
msgid "Piwik path"
|
587 |
+
msgstr "Piwik Pfad"
|
588 |
+
|
589 |
+
msgid "Disable cookies"
|
590 |
+
msgstr "Cookies deaktivieren"
|
591 |
+
|
592 |
+
msgid "Disable all tracking cookies for a visitor."
|
593 |
+
msgstr "Schalte alle Tracking-Cookies für Besucher ab."
|
594 |
+
|
595 |
+
msgid "Show graph on WordPress Toolbar"
|
596 |
+
msgstr "Zeige einen Graphen in der WordPress Toolbar"
|
597 |
+
|
598 |
+
msgid "Display the last 30 days visitor stats on WordPress Toolbar."
|
599 |
+
msgstr "Zeige die Besucherstatistik der letzten 30 Tage in der WordPress Toolbar an."
|
600 |
+
|
601 |
+
msgid "Graphs powered by <a href=\"http://www.jqplot.com/\">jqPlot</a> (License: GPL 2.0 and MIT) and <a href=\"http://omnipotent.net/jquery.sparkline/\">jQuery Sparklines</a> (License: New BSD License)."
|
602 |
+
msgstr "Die Graphen werden mit <a href=\"http://www.jqplot.com/\">jqPlot</a> (Lizenz: GPL 2.0 and MIT) und <a href=\"http://omnipotent.net/jquery.sparkline/\">jQuery Sparklines</a> (Lizenz: New BSD License) erstellt."
|
603 |
+
|
604 |
+
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."
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Contributors: Braekling
|
4 |
Requires at least: 3.3
|
5 |
Tested up to: 3.3.2
|
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 |
|
@@ -13,7 +13,7 @@ This plugin adds a Piwik stats site to your WordPress or WordPress multisite das
|
|
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.
|
17 |
|
18 |
Look at the [Piwik website](http://piwik.org/) to get further information about Piwik.
|
19 |
|
@@ -29,7 +29,7 @@ See section "Installation".
|
|
29 |
|
30 |
= Credits =
|
31 |
|
32 |
-
* Graphs powered by [jqPlot](http://www.jqplot.com/)
|
33 |
* Metabox support inspired by [Heiko Rabe's metabox demo plugin](http://www.code-styling.de/english/how-to-use-wordpress-metaboxes-at-own-plugins).
|
34 |
* Translation credits see plugin settings
|
35 |
* Donations: Marco L., Rolf W., Tobias U., Lars K., Donna F., Kevin D., Ramos S, the Piwik team itself, and all people flattering this.
|
@@ -37,6 +37,22 @@ See section "Installation".
|
|
37 |
|
38 |
Thank you all!
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
== Installation ==
|
41 |
|
42 |
= Install WP-Piwik on a simple WordPress blog =
|
@@ -72,9 +88,21 @@ Add WP-Piwik to your /wp-content/plugins folder and enable it as [Network Plugin
|
|
72 |
1. WP-Piwik settings.
|
73 |
2. WP-Piwik statistics page.
|
74 |
3. Closer look to a pie chart.
|
|
|
75 |
|
76 |
== Changelog ==
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
= 0.9.2 =
|
79 |
* Uses $wpdb->blogs instead of $wpdb->prefix.'blogs' to keep it compatible to different database plugins
|
80 |
* Bugfix: SEO dashboard widget will work even if "last 30" is selected
|
3 |
Contributors: Braekling
|
4 |
Requires at least: 3.3
|
5 |
Tested up to: 3.3.2
|
6 |
+
Stable tag: 0.9.4
|
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 |
|
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.8.2) 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 |
|
29 |
|
30 |
= Credits =
|
31 |
|
32 |
+
* Graphs powered by [jqPlot](http://www.jqplot.com/) (GPL 2.0 and MIT) and and [jQuery Sparklines](http://omnipotent.net/jquery.sparkline/) (New BSD License).
|
33 |
* Metabox support inspired by [Heiko Rabe's metabox demo plugin](http://www.code-styling.de/english/how-to-use-wordpress-metaboxes-at-own-plugins).
|
34 |
* Translation credits see plugin settings
|
35 |
* Donations: Marco L., Rolf W., Tobias U., Lars K., Donna F., Kevin D., Ramos S, the Piwik team itself, and all people flattering this.
|
37 |
|
38 |
Thank you all!
|
39 |
|
40 |
+
== Frequently Asked Questions ==
|
41 |
+
|
42 |
+
= Where can I find the Piwik URL and the Piwik auth token? =
|
43 |
+
|
44 |
+
WP-Piwik requires Piwik. If you did not install Piwik yet, first get it at the [Piwik website](http://www.piwik.org).
|
45 |
+
|
46 |
+
If Piwik works, you'll be able to configure WP-Piwik: The Piwik URL is the same URL you use to access your Piwik, e.g. for the demo site: http://demo.piwik.org. The auth token is some kind of secret password, which allows WP-Piwik to get the necessary data from Piwik. The super user's auth token, i.e. a full access password for your Piwik, can be found on Piwik's API site. You can find a detailed description [here](http://peepbo.de/board/viewtopic.php?f=5&t=10).
|
47 |
+
|
48 |
+
= Tracking does not work on HostGator! =
|
49 |
+
|
50 |
+
Try to enable the "avoid mod_security" option (WP-Piwik settings, Tracking tab) or create a mod_security whitelist.
|
51 |
+
|
52 |
+
= WP-Piwik does not work with SSL! =
|
53 |
+
|
54 |
+
See [this support thread](http://wordpress.org/support/topic/plugin-wp-piwik-https-ssl-support?replies=3).
|
55 |
+
|
56 |
== Installation ==
|
57 |
|
58 |
= Install WP-Piwik on a simple WordPress blog =
|
88 |
1. WP-Piwik settings.
|
89 |
2. WP-Piwik statistics page.
|
90 |
3. Closer look to a pie chart.
|
91 |
+
4. WordPress toolbar graph.
|
92 |
|
93 |
== Changelog ==
|
94 |
|
95 |
+
= 0.9.4 =
|
96 |
+
* Requires at least Piwik 1.8.2!
|
97 |
+
* Choose between HTTP API or PHP API
|
98 |
+
* Show graph on WordPress Toolbar
|
99 |
+
* Add option to disable cookies - Thanks to Mathias T.!
|
100 |
+
* Update bugfix: Upgrading from WP-Piwik 0.8.7 or less will work again
|
101 |
+
* Some minor bugfixes
|
102 |
+
|
103 |
+
= 0.9.3 =
|
104 |
+
* Bugfix: Adding a new site will work again.
|
105 |
+
|
106 |
= 0.9.2 =
|
107 |
* Uses $wpdb->blogs instead of $wpdb->prefix.'blogs' to keep it compatible to different database plugins
|
108 |
* Bugfix: SEO dashboard widget will work even if "last 30" is selected
|
screenshot-4.gif
ADDED
Binary file
|
settings/credits.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
</tr>
|
6 |
<tr>
|
7 |
<td>
|
8 |
-
<?php _e('Graphs powered by <a href="http://www.jqplot.com/">jqPlot</a
|
9 |
</td>
|
10 |
</tr>
|
11 |
<tr>
|
5 |
</tr>
|
6 |
<tr>
|
7 |
<td>
|
8 |
+
<?php _e('Graphs powered by <a href="http://www.jqplot.com/">jqPlot</a> (License: GPL 2.0 and MIT) and <a href="http://omnipotent.net/jquery.sparkline/">jQuery Sparklines</a> (License: New BSD License).','wp-piwik'); ?>
|
9 |
</td>
|
10 |
</tr>
|
11 |
<tr>
|
settings/homepage.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
-
$strVersion = $this->callPiwikAPI('
|
3 |
// http://wordpress.org/support/rss/tags/wp-piwik
|
4 |
?><tr><td><strong><?php _e('Thanks for using WP-Piwik!', 'wp-piwik'); ?></strong></td></tr>
|
5 |
<tr><td><?php
|
1 |
<?php
|
2 |
+
$strVersion = $this->callPiwikAPI('API.getPiwikVersion');
|
3 |
// http://wordpress.org/support/rss/tags/wp-piwik
|
4 |
?><tr><td><strong><?php _e('Thanks for using WP-Piwik!', 'wp-piwik'); ?></strong></td></tr>
|
5 |
<tr><td><?php
|
settings/piwik.php
CHANGED
@@ -8,18 +8,30 @@ if (!$bolFOpen && !$bolCURL) {
|
|
8 |
</td>
|
9 |
</tr><?php } else { ?><tr>
|
10 |
<th colspan="2">
|
11 |
-
<?php _e('To enable Piwik statistics, please enter
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
</th>
|
13 |
-
</tr
|
14 |
-
<th
|
15 |
-
<?php _e('<strong>Important note:</strong> If you do not host this blog on your own, your site admin is able to get your auth token from the database.', 'wp-piwik'); ?>
|
16 |
-
</th>
|
17 |
-
</tr><?php } ?><tr>
|
18 |
-
<th><?php _e('Piwik URL', 'wp-piwik'); ?>:</th>
|
19 |
<td>
|
|
|
20 |
<input id="wp-piwik_url" name="wp-piwik_url" type="text" value="<?php echo self::$aryGlobalSettings['piwik_url']; ?>" />
|
21 |
<label for="wp-piwik_url"></label>
|
22 |
</td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
</tr><tr>
|
24 |
<th><?php _e('Auth token', 'wp-piwik'); ?>:</th>
|
25 |
<td>
|
8 |
</td>
|
9 |
</tr><?php } else { ?><tr>
|
10 |
<th colspan="2">
|
11 |
+
<?php _e('To enable Piwik statistics, please enter', 'wp-piwik'); ?>:
|
12 |
+
<ol>
|
13 |
+
<li><?php _e('your Piwik base URL (like http://mydomain.com/piwik) or your Piwik server path (like /var/www/mydomain.com/httpdocs/piwik/)', 'wp-piwik'); ?></li>
|
14 |
+
<li><?php _e('your personal Piwik authentification token. You can get the token on the API page inside your Piwik interface. It looks like "1234a5cd6789e0a12345b678cd9012ef".', 'wp-piwik'); ?></li>
|
15 |
+
</ol>
|
16 |
+
<?php _e('No idea what I\'m talking about?', 'wp-piwik'); ?> <a href="http://peepbo.de/board/viewtopic.php?f=5&t=10"><?php _e('Get help.', 'wp-piwik'); ?></a>
|
17 |
+
<?php if (!is_plugin_active_for_network('wp-piwik/wp-piwik.php')) { ?>
|
18 |
+
<p><?php _e('<strong>Important note:</strong> If you do not host this blog on your own, your site admin is able to get your auth token from the database.', 'wp-piwik'); ?></p>
|
19 |
+
<?php } ?>
|
20 |
</th>
|
21 |
+
</tr><tr>
|
22 |
+
<th><?php _e('Piwik URL', 'wp-piwik'); ?> (REST API):</th>
|
|
|
|
|
|
|
|
|
23 |
<td>
|
24 |
+
<input type="radio" name="wp-piwik_mode" onchange="javascript:$j('#wp-piwik_path,#wp-piwik_path-label').toggleClass('wp-piwik-input-hide');" value="http" <?php echo (self::$aryGlobalSettings['piwik_mode']=='http'?'checked="checked" ':''); ?>/>
|
25 |
<input id="wp-piwik_url" name="wp-piwik_url" type="text" value="<?php echo self::$aryGlobalSettings['piwik_url']; ?>" />
|
26 |
<label for="wp-piwik_url"></label>
|
27 |
</td>
|
28 |
+
</tr><tr>
|
29 |
+
<th><?php _e('Piwik path', 'wp-piwik'); ?> (PHP API, beta):</th>
|
30 |
+
<td>
|
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>
|
37 |
<td>
|
settings/support.php
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
<tr>
|
11 |
<td>
|
12 |
<h3><?php _e('Debugging', 'wp-piwik'); ?></h3>
|
13 |
-
<p><?php _e('Either allow_url_fopen has to be enabled <em>or</em> cURL has to be available:') ?></p>
|
14 |
<ol>
|
15 |
<li><?php
|
16 |
_e('cURL is','wp-piwik');
|
@@ -54,7 +54,7 @@
|
|
54 |
</tr>
|
55 |
<tr><td><h3><?php _e('Latest support threads on WordPress.org', 'wp-piwik'); ?></h3>
|
56 |
<?php
|
57 |
-
$arySupportThreads = self::readRSSFeed('http://wordpress.org/support/rss/
|
58 |
if (!empty($arySupportThreads)) {
|
59 |
echo '<ol>';
|
60 |
foreach ($arySupportThreads as $arySupportThread) echo '<li><a href="'.$arySupportThread['url'].'">'.$arySupportThread['title'].'</a></li>';
|
10 |
<tr>
|
11 |
<td>
|
12 |
<h3><?php _e('Debugging', 'wp-piwik'); ?></h3>
|
13 |
+
<p><?php _e('Either allow_url_fopen has to be enabled <em>or</em> cURL has to be available:', 'wp-piwik'); ?></p>
|
14 |
<ol>
|
15 |
<li><?php
|
16 |
_e('cURL is','wp-piwik');
|
54 |
</tr>
|
55 |
<tr><td><h3><?php _e('Latest support threads on WordPress.org', 'wp-piwik'); ?></h3>
|
56 |
<?php
|
57 |
+
$arySupportThreads = self::readRSSFeed('http://wordpress.org/support/rss/plugin/wp-piwik');
|
58 |
if (!empty($arySupportThreads)) {
|
59 |
echo '<ol>';
|
60 |
foreach ($arySupportThreads as $arySupportThread) echo '<li><a href="'.$arySupportThread['url'].'">'.$arySupportThread['title'].'</a></li>';
|
settings/tracking.php
CHANGED
@@ -30,6 +30,10 @@ if (self::$aryGlobalSettings['add_tracking_code']) {
|
|
30 |
<?php echo (is_plugin_active_for_network('wp-piwik/wp-piwik.php')?'*** SITE SPECIFIC EXAMPLE CODE ***'."\n":'').htmlentities(self::$arySettings['tracking_code']); ?>
|
31 |
</textarea>
|
32 |
</td></tr>
|
|
|
|
|
|
|
|
|
33 |
<tr><th><?php _e('Track 404', 'wp-piwik'); ?>:</th><td>
|
34 |
<input type="checkbox" value="1" id="wp-piwik_404" name="wp-piwik_404"<?php echo (self::$aryGlobalSettings['track_404']?' checked="checked"':''); ?> />
|
35 |
<label for="wp-piwik_404"><?php echo _e('WP-Piwik can automatically add a 404-category to track 404-page-visits.', 'wp-piwik'); ?></label>
|
30 |
<?php echo (is_plugin_active_for_network('wp-piwik/wp-piwik.php')?'*** SITE SPECIFIC EXAMPLE CODE ***'."\n":'').htmlentities(self::$arySettings['tracking_code']); ?>
|
31 |
</textarea>
|
32 |
</td></tr>
|
33 |
+
<tr><th><?php _e('Disable cookies', 'wp-piwik'); ?>:</th><td>
|
34 |
+
<input type="checkbox" value="1" id="wp-piwik_disable_cookies" name="wp-piwik_disable_cookies"<?php echo (self::$aryGlobalSettings['disable_cookies']?' checked="checked"':''); ?> />
|
35 |
+
<label for="wp-piwik_disable_cookies"><?php echo _e('Disable all tracking cookies for a visitor.', 'wp-piwik'); ?></label>
|
36 |
+
</td></tr>
|
37 |
<tr><th><?php _e('Track 404', 'wp-piwik'); ?>:</th><td>
|
38 |
<input type="checkbox" value="1" id="wp-piwik_404" name="wp-piwik_404"<?php echo (self::$aryGlobalSettings['track_404']?' checked="checked"':''); ?> />
|
39 |
<label for="wp-piwik_404"><?php echo _e('WP-Piwik can automatically add a 404-category to track 404-page-visits.', 'wp-piwik'); ?></label>
|
settings/views.php
CHANGED
@@ -25,6 +25,10 @@ if (!$bolFOpen && !$bolCURL) {
|
|
25 |
<input type="checkbox" value="1" name="wp-piwik_dbseo" id="wp-piwik_dbseo"<?php echo (self::$aryGlobalSettings['dashboard_seo']?' checked="checked"':""); ?>/> <?php _e('SEO <em>(slow!)</em>', 'wp-piwik'); ?>
|
26 |
<br><?php _e('Configure WP-Piwik widgets to be shown on your WordPress Home Dashboard.', 'wp-piwik'); ?>
|
27 |
</td></tr>
|
|
|
|
|
|
|
|
|
28 |
<tr><th><?php _e('SEO data', 'wp-piwik'); ?>:</th><td>
|
29 |
<input type="checkbox" value="1" id="wp-piwik_statsseo" name="wp-piwik_statsseo"<?php echo (self::$aryGlobalSettings['stats_seo']?' checked="checked"':''); ?> />
|
30 |
<label for="wp-piwik_statsseo"><?php echo _e('Display SEO ranking data on statistics page. <em>(Slow!)</em>', 'wp-piwik'); ?></label>
|
25 |
<input type="checkbox" value="1" name="wp-piwik_dbseo" id="wp-piwik_dbseo"<?php echo (self::$aryGlobalSettings['dashboard_seo']?' checked="checked"':""); ?>/> <?php _e('SEO <em>(slow!)</em>', 'wp-piwik'); ?>
|
26 |
<br><?php _e('Configure WP-Piwik widgets to be shown on your WordPress Home Dashboard.', 'wp-piwik'); ?>
|
27 |
</td></tr>
|
28 |
+
<tr><th><?php _e('Show graph on WordPress Toolbar', 'wp-piwik'); ?>:</th><td>
|
29 |
+
<input type="checkbox" value="1" id="wp-piwik_toolbar" name="wp-piwik_toolbar"<?php echo (self::$aryGlobalSettings['toolbar']?' checked="checked"':''); ?> />
|
30 |
+
<label for="wp-piwik_toolbar"><?php echo _e('Display the last 30 days visitor stats on WordPress Toolbar.', 'wp-piwik'); ?></label>
|
31 |
+
</td></tr>
|
32 |
<tr><th><?php _e('SEO data', 'wp-piwik'); ?>:</th><td>
|
33 |
<input type="checkbox" value="1" id="wp-piwik_statsseo" name="wp-piwik_statsseo"<?php echo (self::$aryGlobalSettings['stats_seo']?' checked="checked"':''); ?> />
|
34 |
<label for="wp-piwik_statsseo"><?php echo _e('Display SEO ranking data on statistics page. <em>(Slow!)</em>', 'wp-piwik'); ?></label>
|
update/80800.php
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
<?php
|
2 |
-
self::$aryGlobalSettings['piwik_url'] = self::
|
1 |
<?php
|
2 |
+
self::$aryGlobalSettings['piwik_url'] = self::checkURL(self::$aryGlobalSettings['piwik_url']);
|
update/90405.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
self::$aryGlobalSettings['piwik_mode'] = 'http';
|
3 |
+
self::$aryGlobalSettings['piwik_path'] = '';
|
4 |
+
self::$aryGlobalSettings['toolbar'] = false;
|
5 |
+
self::$aryGlobalSettings['disable_cookies'] = false;
|
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 |
|
@@ -40,9 +40,10 @@ if (!function_exists ('add_action')) {
|
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
-
* Makes sure
|
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');
|
@@ -59,17 +60,19 @@ if (!function_exists('is_plugin_active_for_network'))
|
|
59 |
class wp_piwik {
|
60 |
|
61 |
private static
|
62 |
-
$intRevisionId =
|
63 |
-
$strVersion = '0.9.
|
64 |
$intDashboardID = 30,
|
65 |
$strPluginBasename = NULL,
|
66 |
$bolJustActivated = false,
|
67 |
$aryGlobalSettings = array(
|
68 |
-
'revision' =>
|
69 |
'add_tracking_code' => false,
|
70 |
'last_settings_update' => 0,
|
71 |
'piwik_token' => '',
|
72 |
'piwik_url' => '',
|
|
|
|
|
73 |
'dashboard_widget' => false,
|
74 |
'dashboard_chart' => false,
|
75 |
'dashboard_seo' => false,
|
@@ -82,7 +85,9 @@ class wp_piwik {
|
|
82 |
'track_404' => false,
|
83 |
'track_compress' => false,
|
84 |
'track_post' => false,
|
85 |
-
'disable_timelimit' => false
|
|
|
|
|
86 |
),
|
87 |
$arySettings = array(
|
88 |
'tracking_code' => '',
|
@@ -142,12 +147,15 @@ class wp_piwik {
|
|
142 |
// Store plugin basename
|
143 |
self::$strPluginBasename = plugin_basename(__FILE__);
|
144 |
// Load current settings
|
145 |
-
self::loadSettings();
|
146 |
// Upgrade?
|
147 |
if (self::$aryGlobalSettings['revision'] < self::$intRevisionId) $this->upgradePlugin();
|
148 |
// Settings changed?
|
149 |
if (isset($_POST['action']) && $_POST['action'] == 'save_wp-piwik_settings')
|
150 |
$this->applySettings();
|
|
|
|
|
|
|
151 |
// Load language file
|
152 |
load_plugin_textdomain('wp-piwik', false, dirname(self::$strPluginBasename)."/languages/");
|
153 |
// Add meta links to plugin details
|
@@ -164,12 +172,16 @@ class wp_piwik {
|
|
164 |
// Register the callback been used if options of page been submitted and needs to be processed
|
165 |
add_action('admin_post_save_wp-piwik_stats', array(&$this, 'onStatsPageSaveChanges'));
|
166 |
// Add dashboard widget if enabled
|
167 |
-
/* TODO: Use bitmask here
|
168 |
-
*/
|
169 |
if (self::$aryGlobalSettings['dashboard_widget'] || self::$aryGlobalSettings['dashboard_chart'] || self::$aryGlobalSettings['dashboard_seo'])
|
170 |
-
add_action('wp_dashboard_setup', array($this, 'extendWordPressDashboard'));
|
|
|
|
|
|
|
|
|
|
|
171 |
// Add tracking code to footer if enabled
|
172 |
-
if (self::$aryGlobalSettings['add_tracking_code']) add_action('wp_footer', array($this, 'footer'));
|
173 |
}
|
174 |
|
175 |
/**
|
@@ -220,6 +232,8 @@ class wp_piwik {
|
|
220 |
self::includeFile('update/90001');
|
221 |
if (self::$aryGlobalSettings['revision'] < 90206)
|
222 |
self::includeFile('update/90206');
|
|
|
|
|
223 |
// Install new version
|
224 |
$this->installPlugin();
|
225 |
}
|
@@ -250,12 +264,12 @@ class wp_piwik {
|
|
250 |
// Message text
|
251 |
$strText = 'WP-Piwik '.self::$strVersion.' '.__('installed','wp-piwik').'.';
|
252 |
// Next step information
|
253 |
-
$strSettings = (
|
254 |
__('Next you should connect to Piwik','wp-piwik'):
|
255 |
__('Please validate your configuration','wp-piwik')
|
256 |
);
|
257 |
// Create settings Link
|
258 |
-
$strLink = sprintf('<a href="options-general.php?page=%s">%s</a>', self::$strPluginBasename, __('Settings', 'wp-piwik'));
|
259 |
// Display message
|
260 |
echo '<div class="updated fade"><p>'.$strText.' <strong>'.__('Important', 'wp-piwik').':</strong> '.$strSettings.': '.$strLink.'.</p></div>';
|
261 |
}
|
@@ -270,7 +284,12 @@ class wp_piwik {
|
|
270 |
if ($strVal && current_user_can($strKey))
|
271 |
return;
|
272 |
// Don't add tracking code?
|
273 |
-
} elseif (current_user_can('wp-piwik_stealth'))
|
|
|
|
|
|
|
|
|
|
|
274 |
// Hotfix: Update network site if not done yet
|
275 |
if (is_plugin_active_for_network('wp-piwik/wp-piwik.php') && get_option('wp-piwik_siteid', false)) $this->updateSite();
|
276 |
// Autohandle site if no tracking code available
|
@@ -297,7 +316,7 @@ class wp_piwik {
|
|
297 |
*/
|
298 |
function buildAdminMenu() {
|
299 |
// Show stats dashboard page if WP-Piwik is configured
|
300 |
-
if (
|
301 |
// Add dashboard page
|
302 |
$this->intStatsPage = add_dashboard_page(
|
303 |
__('Piwik Statistics', 'wp-piwik'),
|
@@ -338,7 +357,7 @@ class wp_piwik {
|
|
338 |
*/
|
339 |
function buildNetworkAdminMenu() {
|
340 |
// Show stats dashboard page if WP-Piwik is configured
|
341 |
-
if (
|
342 |
// Add dashboard page
|
343 |
$this->intStatsPage = add_dashboard_page(
|
344 |
__('Piwik Statistics', 'wp-piwik'),
|
@@ -407,6 +426,25 @@ class wp_piwik {
|
|
407 |
$this->addWordPressDashboardSEO();
|
408 |
}
|
409 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
410 |
|
411 |
/**
|
412 |
* Add a data widget to the WordPress dashboard
|
@@ -481,7 +519,7 @@ class wp_piwik {
|
|
481 |
return array_merge(
|
482 |
$strLinks,
|
483 |
array(
|
484 |
-
sprintf('<a href="options-general.php?page=%s">%s</a>', self::$strPluginBasename, __('Settings', 'wp-piwik'))
|
485 |
)
|
486 |
);
|
487 |
// Don't affect other plugins details
|
@@ -499,7 +537,17 @@ class wp_piwik {
|
|
499 |
}
|
500 |
|
501 |
/**
|
502 |
-
* Load required
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
503 |
*/
|
504 |
function loadSettingsScripts() {
|
505 |
wp_enqueue_script('jquery');
|
@@ -540,11 +588,14 @@ class wp_piwik {
|
|
540 |
}
|
541 |
|
542 |
/**
|
543 |
-
*
|
544 |
*
|
545 |
-
* @param
|
546 |
*/
|
547 |
-
function
|
|
|
|
|
|
|
548 |
// Use cURL if available
|
549 |
if (function_exists('curl_init')) {
|
550 |
// Init cURL
|
@@ -569,6 +620,37 @@ class wp_piwik {
|
|
569 |
// Return result
|
570 |
return $strResult;
|
571 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
572 |
|
573 |
/**
|
574 |
* Add a new site to Piwik if a new blog was requested,
|
@@ -580,10 +662,8 @@ class wp_piwik {
|
|
580 |
self::loadSettings();
|
581 |
}
|
582 |
$strBlogURL = get_bloginfo('url');
|
583 |
-
$strURL = self::$aryGlobalSettings['piwik_url'];
|
584 |
// Check if blog URL already known
|
585 |
-
|
586 |
-
$strURL .= '?module=API&method=SitesManager.getSitesIdFromSiteUrl';
|
587 |
$strURL .= '&url='.urlencode($strBlogURL);
|
588 |
$strURL .= '&format=PHP';
|
589 |
$strURL .= '&token_auth='.self::$aryGlobalSettings['piwik_token'];
|
@@ -592,16 +672,13 @@ class wp_piwik {
|
|
592 |
self::$arySettings['site_id'] = $aryResult[0]['idsite'];
|
593 |
self::$arySettings['last_tracking_code_update'] = time();
|
594 |
// Otherwise create new site
|
595 |
-
} elseif (
|
596 |
$strName = get_bloginfo('name');
|
597 |
if (empty($strName)) $strName = $strBlogURL;
|
598 |
-
|
599 |
-
$strURL .= '?module=API&method=SitesManager.addSite';
|
600 |
$strURL .= '&siteName='.urlencode($strName).'&urls='.urlencode($strBlogURL);
|
601 |
$strURL .= '&format=PHP';
|
602 |
$strURL .= '&token_auth='.self::$aryGlobalSettings['piwik_token'];
|
603 |
-
echo $strURL;
|
604 |
-
die();
|
605 |
$strResult = unserialize($this->getRemoteFile($strURL));
|
606 |
if (!empty($strResult)) self::$arySettings['site_id'] = $strResult;
|
607 |
}
|
@@ -625,6 +702,8 @@ class wp_piwik {
|
|
625 |
if (self::$aryGlobalSettings['track_compress']) $strCode = str_replace('pkBaseURL + "piwik.js\'', 'pkBaseURL + "js/\'', $strCode);
|
626 |
// Change code if POST is forced to be used
|
627 |
if (self::$aryGlobalSettings['track_post']) $strCode = str_replace('piwikTracker.trackPageView();', 'piwikTracker.setRequestMethod(\'POST\');'."\n".' piwikTracker.trackPageView();', $strCode);
|
|
|
|
|
628 |
return $strCode;
|
629 |
}
|
630 |
|
@@ -660,7 +739,6 @@ class wp_piwik {
|
|
660 |
// Call API if data not cached
|
661 |
if (empty($this->aryCache[$strKey])) {
|
662 |
$strToken = self::$aryGlobalSettings['piwik_token'];
|
663 |
-
$strURL = self::$aryGlobalSettings['piwik_url'];
|
664 |
// If multisite stats are shown, maybe the super admin wants to show other blog's stats.
|
665 |
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'])) {
|
666 |
$aryOptions = get_blog_option((int) $_GET['wpmu_show_stats'], 'wp-piwik_settings' , array());
|
@@ -670,15 +748,15 @@ class wp_piwik {
|
|
670 |
// Otherwise use the current site's id.
|
671 |
} else $intSite = self::$arySettings['site_id'];
|
672 |
// Create error message if WP-Piwik isn't configured
|
673 |
-
if (
|
674 |
-
$this->aryCache[$
|
675 |
'result' => 'error',
|
676 |
-
'message' => 'Piwik
|
677 |
);
|
678 |
return $this->aryCache[$strKey];
|
679 |
}
|
680 |
// Build URL
|
681 |
-
$strURL
|
682 |
$strURL .= '&idSite='.$intSite.'&period='.$strPeriod.'&date='.$strDate;
|
683 |
$strURL .= '&filter_limit='.$intLimit;
|
684 |
$strURL .= '&token_auth='.$strToken;
|
@@ -896,7 +974,7 @@ class wp_piwik {
|
|
896 |
*/
|
897 |
function applySettings() {
|
898 |
$strTab = (isset($_GET['tab'])?$_GET['tab']:'homepage');
|
899 |
-
self::$aryGlobalSettings['last_settings_update']
|
900 |
switch ($strTab) {
|
901 |
case 'views':
|
902 |
self::$aryGlobalSettings['dashboard_widget'] = (isset($_POST['wp-piwik_dbwidget'])?$_POST['wp-piwik_dbwidget']:0);
|
@@ -907,17 +985,21 @@ class wp_piwik {
|
|
907 |
self::$aryGlobalSettings['default_date'] = (isset($_POST['wp-piwik_default_date'])?$_POST['wp-piwik_default_date']:'yesterday');
|
908 |
self::$aryGlobalSettings['capability_read_stats'] = (isset($_POST['wp-piwik_displayto'])?$_POST['wp-piwik_displayto']:array());
|
909 |
self::$aryGlobalSettings['disable_timelimit'] = (isset($_POST['wp-piwik_disabletimelimit'])?$_POST['wp-piwik_disabletimelimit']:false);
|
|
|
910 |
break;
|
911 |
case 'tracking':
|
912 |
self::$aryGlobalSettings['add_tracking_code'] = (isset($_POST['wp-piwik_addjs'])?$_POST['wp-piwik_addjs']:false);
|
913 |
self::$aryGlobalSettings['track_404'] = (isset($_POST['wp-piwik_404'])?$_POST['wp-piwik_404']:false);
|
914 |
self::$aryGlobalSettings['track_compress'] = (isset($_POST['wp-piwik_compress'])?$_POST['wp-piwik_compress']:false);
|
915 |
self::$aryGlobalSettings['track_post'] = (isset($_POST['wp-piwik_reqpost'])?$_POST['wp-piwik_reqpost']:false);
|
916 |
-
self::$aryGlobalSettings['capability_stealth']
|
|
|
917 |
break;
|
918 |
case 'piwik':
|
919 |
self::$aryGlobalSettings['piwik_token'] = (isset($_POST['wp-piwik_token'])?$_POST['wp-piwik_token']:'');
|
920 |
self::$aryGlobalSettings['piwik_url'] = self::checkURL((isset($_POST['wp-piwik_url'])?$_POST['wp-piwik_url']:''));
|
|
|
|
|
921 |
if (!is_plugin_active_for_network('wp-piwik/wp-piwik.php')) {
|
922 |
self::$aryGlobalSettings['auto_site_config'] = (isset($_POST['wp-piwik_auto_site_config'])?$_POST['wp-piwik_auto_site_config']:false);
|
923 |
if (!self::$aryGlobalSettings['auto_site_config'])
|
@@ -925,7 +1007,9 @@ class wp_piwik {
|
|
925 |
} else self::$aryGlobalSettings['auto_site_config'] = true;
|
926 |
break;
|
927 |
}
|
928 |
-
if (self::$aryGlobalSettings['auto_site_config']) {
|
|
|
|
|
929 |
$aryReturn = $this->addPiwikSite();
|
930 |
self::$arySettings['tracking_code'] = $aryReturn['js'];
|
931 |
self::$arySettings['site_id'] = $aryReturn['id'];
|
@@ -937,6 +1021,7 @@ class wp_piwik {
|
|
937 |
* Check & prepare URL
|
938 |
*/
|
939 |
static function checkURL($strURL) {
|
|
|
940 |
if (substr($strURL, -1, 1) != '/' && substr($strURL, -10, 10) != '/index.php')
|
941 |
$strURL .= '/';
|
942 |
return $strURL;
|
@@ -955,7 +1040,7 @@ class wp_piwik {
|
|
955 |
// Show settings page title
|
956 |
echo '<div class="wrap"><h2>'.__('WP-Piwik Settings', 'wp-piwik').'</h2>';
|
957 |
// Show tabs
|
958 |
-
$strTab = $this->showSettingsTabs(
|
959 |
if ($strTab != 'sitebrowser') {
|
960 |
/***************************************************************************/ ?>
|
961 |
<div class="wp-piwik-donate">
|
@@ -983,7 +1068,7 @@ class wp_piwik {
|
|
983 |
</div>
|
984 |
</div>
|
985 |
<?php /***************************************************************************/
|
986 |
-
}
|
987 |
echo '<form class="'.($strTab != 'sitebrowser'?'wp-piwik-settings':'').'" method="post" action="'.admin_url(($pagenow == 'settings.php'?'network/':'').$pagenow.'?page=wp-piwik/wp-piwik.php&tab='.$strTab).'">';
|
988 |
echo '<input type="hidden" name="action" value="save_wp-piwik_settings" />';
|
989 |
wp_nonce_field('wp-piwik_settings');
|
@@ -1012,7 +1097,7 @@ class wp_piwik {
|
|
1012 |
* Show an error message extended by a support site link
|
1013 |
*/
|
1014 |
private static function showErrorMessage($strMessage) {
|
1015 |
-
echo '<strong class="wp-piwik-error">'.__('An error occured', 'wp-piwik').':</strong> '.$strMessage.' [<a href="page=wp-piwik/wp-piwik.php&tab=support">'.__('Support','wp-piwik').'</a>]';
|
1016 |
}
|
1017 |
|
1018 |
/**
|
@@ -1051,6 +1136,8 @@ class wp_piwik {
|
|
1051 |
'last_settings_update' => 0,
|
1052 |
'piwik_token' => ($bolFull?'':self::$aryGlobalSettings['piwik_token']),
|
1053 |
'piwik_url' => ($bolFull?'':self::$aryGlobalSettings['piwik_url']),
|
|
|
|
|
1054 |
'dashboard_widget' => false,
|
1055 |
'dashboard_chart' => false,
|
1056 |
'dashboard_seo' => false,
|
@@ -1063,7 +1150,9 @@ class wp_piwik {
|
|
1063 |
'track_404' => false,
|
1064 |
'track_compress' => false,
|
1065 |
'track_post' => false,
|
1066 |
-
'disable_timelimit' => false
|
|
|
|
|
1067 |
);
|
1068 |
// Reset network settings
|
1069 |
if (is_plugin_active_for_network('wp-piwik/wp-piwik.php')) {
|
@@ -1091,6 +1180,33 @@ class wp_piwik {
|
|
1091 |
}
|
1092 |
return $intResult;
|
1093 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1094 |
}
|
1095 |
|
1096 |
if (class_exists('wp_piwik'))
|
6 |
|
7 |
Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress footer.
|
8 |
|
9 |
+
Version: 0.9.4
|
10 |
Author: André Bräkling
|
11 |
Author URI: http://www.braekling.de
|
12 |
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
+
* Makes sure all required include files are loaded before trying to use it
|
44 |
*
|
45 |
* @see http://codex.wordpress.org/Function_Reference/is_plugin_active_for_network
|
46 |
+
* @see http://codex.wordpress.org/Function_Reference/get_current_screen
|
47 |
*/
|
48 |
if (!function_exists('is_plugin_active_for_network'))
|
49 |
require_once(ABSPATH.'/wp-admin/includes/plugin.php');
|
60 |
class wp_piwik {
|
61 |
|
62 |
private static
|
63 |
+
$intRevisionId = 90405,
|
64 |
+
$strVersion = '0.9.4',
|
65 |
$intDashboardID = 30,
|
66 |
$strPluginBasename = NULL,
|
67 |
$bolJustActivated = false,
|
68 |
$aryGlobalSettings = array(
|
69 |
+
'revision' => 90405,
|
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,
|
85 |
'track_404' => false,
|
86 |
'track_compress' => false,
|
87 |
'track_post' => false,
|
88 |
+
'disable_timelimit' => false,
|
89 |
+
'disable_cookies' => false,
|
90 |
+
'toolbar' => false
|
91 |
),
|
92 |
$arySettings = array(
|
93 |
'tracking_code' => '',
|
147 |
// Store plugin basename
|
148 |
self::$strPluginBasename = plugin_basename(__FILE__);
|
149 |
// Load current settings
|
150 |
+
self::loadSettings();
|
151 |
// Upgrade?
|
152 |
if (self::$aryGlobalSettings['revision'] < self::$intRevisionId) $this->upgradePlugin();
|
153 |
// Settings changed?
|
154 |
if (isset($_POST['action']) && $_POST['action'] == 'save_wp-piwik_settings')
|
155 |
$this->applySettings();
|
156 |
+
// Set Piwik globals if PHP API is used
|
157 |
+
elseif (isset(self::$aryGlobalSettings['piwik_mode']) && self::$aryGlobalSettings['piwik_mode'] == 'php')
|
158 |
+
self::definePiwikConstants();
|
159 |
// Load language file
|
160 |
load_plugin_textdomain('wp-piwik', false, dirname(self::$strPluginBasename)."/languages/");
|
161 |
// Add meta links to plugin details
|
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'])
|
177 |
+
add_action('wp_dashboard_setup', array($this, 'extendWordPressDashboard'));
|
178 |
+
// Add Toolbar graph if enabled
|
179 |
+
if (self::$aryGlobalSettings['toolbar']) {
|
180 |
+
add_action(is_admin()?'admin_head':'wp_head', array($this, 'loadToolbarRequirements'));
|
181 |
+
add_action('admin_bar_menu', array(&$this, 'extendWordPressToolbar'), 1000);
|
182 |
+
}
|
183 |
// Add tracking code to footer if enabled
|
184 |
+
if (self::$aryGlobalSettings['add_tracking_code']) add_action('wp_footer', array($this, 'footer'));
|
185 |
}
|
186 |
|
187 |
/**
|
232 |
self::includeFile('update/90001');
|
233 |
if (self::$aryGlobalSettings['revision'] < 90206)
|
234 |
self::includeFile('update/90206');
|
235 |
+
if (self::$aryGlobalSettings['revision'] < 90405)
|
236 |
+
self::includeFile('update/90405');
|
237 |
// Install new version
|
238 |
$this->installPlugin();
|
239 |
}
|
264 |
// Message text
|
265 |
$strText = 'WP-Piwik '.self::$strVersion.' '.__('installed','wp-piwik').'.';
|
266 |
// Next step information
|
267 |
+
$strSettings = (!self::isConfigured()?
|
268 |
__('Next you should connect to Piwik','wp-piwik'):
|
269 |
__('Please validate your configuration','wp-piwik')
|
270 |
);
|
271 |
// Create settings Link
|
272 |
+
$strLink = sprintf('<a href="'.(is_plugin_active_for_network('wp-piwik/wp-piwik.php')?'settings':'options-general').'.php?page=%s">%s</a>', self::$strPluginBasename, __('Settings', 'wp-piwik'));
|
273 |
// Display message
|
274 |
echo '<div class="updated fade"><p>'.$strText.' <strong>'.__('Important', 'wp-piwik').':</strong> '.$strSettings.': '.$strLink.'.</p></div>';
|
275 |
}
|
284 |
if ($strVal && current_user_can($strKey))
|
285 |
return;
|
286 |
// Don't add tracking code?
|
287 |
+
} elseif (current_user_can('wp-piwik_stealth')) {
|
288 |
+
echo '<!-- *** WP-Piwik - see http://www.braekling.de/wp-piwik-wpmu-piwik-wordpress/ -->'."\n";
|
289 |
+
echo '<!-- Current user should not be tracked. -->'."\n";
|
290 |
+
echo '<!-- *** /WP-Piwik *********************************************************** -->'."\n";
|
291 |
+
return;
|
292 |
+
}
|
293 |
// Hotfix: Update network site if not done yet
|
294 |
if (is_plugin_active_for_network('wp-piwik/wp-piwik.php') && get_option('wp-piwik_siteid', false)) $this->updateSite();
|
295 |
// Autohandle site if no tracking code available
|
316 |
*/
|
317 |
function buildAdminMenu() {
|
318 |
// Show stats dashboard page if WP-Piwik is configured
|
319 |
+
if (self::isConfigured()) {
|
320 |
// Add dashboard page
|
321 |
$this->intStatsPage = add_dashboard_page(
|
322 |
__('Piwik Statistics', 'wp-piwik'),
|
357 |
*/
|
358 |
function buildNetworkAdminMenu() {
|
359 |
// Show stats dashboard page if WP-Piwik is configured
|
360 |
+
if (self::isConfigured()) {
|
361 |
// Add dashboard page
|
362 |
$this->intStatsPage = add_dashboard_page(
|
363 |
__('Piwik Statistics', 'wp-piwik'),
|
426 |
$this->addWordPressDashboardSEO();
|
427 |
}
|
428 |
}
|
429 |
+
|
430 |
+
/**
|
431 |
+
* Add widgets to WordPress Toolbar
|
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});});";
|
439 |
+
$strGraph .= '</script>';
|
440 |
+
$strGraph .= '<span class="wp-piwik_dynbar">Loading...</span>';
|
441 |
+
$objToolbar->add_menu(array(
|
442 |
+
'id' => 'wp-piwik_stats',
|
443 |
+
'title' => $strGraph,
|
444 |
+
'href' => admin_url().'?page=wp-piwik_stats'
|
445 |
+
));
|
446 |
+
}
|
447 |
+
}
|
448 |
|
449 |
/**
|
450 |
* Add a data widget to the WordPress dashboard
|
519 |
return array_merge(
|
520 |
$strLinks,
|
521 |
array(
|
522 |
+
sprintf('<a href="'.(is_plugin_active_for_network('wp-piwik/wp-piwik.php')?'settings':'options-general').'.php?page=%s">%s</a>', self::$strPluginBasename, __('Settings', 'wp-piwik'))
|
523 |
)
|
524 |
);
|
525 |
// Don't affect other plugins details
|
537 |
}
|
538 |
|
539 |
/**
|
540 |
+
* Load scripts required by Toolbar graphs
|
541 |
+
*/
|
542 |
+
function loadToolbarRequirements() {
|
543 |
+
// Load Sparklines
|
544 |
+
wp_enqueue_script('wp-piwik-sparkline',$this->getPluginURL().'js/sparkline/jquery.sparkline.min.js',array('jquery'));
|
545 |
+
// Load CSS
|
546 |
+
wp_enqueue_style('wp-piwik', $this->getPluginURL().'css/wp-piwik-spark.css');
|
547 |
+
}
|
548 |
+
|
549 |
+
/**
|
550 |
+
* Load required scripts to settings page
|
551 |
*/
|
552 |
function loadSettingsScripts() {
|
553 |
wp_enqueue_script('jquery');
|
588 |
}
|
589 |
|
590 |
/**
|
591 |
+
* Call REST API
|
592 |
*
|
593 |
+
* @param $strURL Remote file URL
|
594 |
*/
|
595 |
+
function callREST($strURL) {
|
596 |
+
$strPiwikURL = self::$aryGlobalSettings['piwik_url'];
|
597 |
+
if (substr($strPiwikURL, -1, 1) != '/') $strPiwikURL .= '/';
|
598 |
+
$strURL = $strPiwikURL.'?module=API'.$strURL;
|
599 |
// Use cURL if available
|
600 |
if (function_exists('curl_init')) {
|
601 |
// Init cURL
|
620 |
// Return result
|
621 |
return $strResult;
|
622 |
}
|
623 |
+
|
624 |
+
/**
|
625 |
+
* Call PHP API
|
626 |
+
*
|
627 |
+
* @param $strParams API call params
|
628 |
+
*/
|
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 |
+
require_once PIWIK_INCLUDE_PATH . "/index.php";
|
633 |
+
require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";
|
634 |
+
Piwik_FrontController::getInstance()->init();
|
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 |
+
$objRequest = new Piwik_API_Request($strParams);
|
639 |
+
// Calls the API and fetch XML data back
|
640 |
+
return $objRequest->process();
|
641 |
+
}
|
642 |
+
|
643 |
+
/**
|
644 |
+
* Get remote file
|
645 |
+
*
|
646 |
+
* @param String $strURL Remote file URL
|
647 |
+
*/
|
648 |
+
function getRemoteFile($strURL) {
|
649 |
+
if (self::$aryGlobalSettings['piwik_mode'] == 'php')
|
650 |
+
return $this->callPHP($strURL);
|
651 |
+
else
|
652 |
+
return $this->callREST($strURL);
|
653 |
+
}
|
654 |
|
655 |
/**
|
656 |
* Add a new site to Piwik if a new blog was requested,
|
662 |
self::loadSettings();
|
663 |
}
|
664 |
$strBlogURL = get_bloginfo('url');
|
|
|
665 |
// Check if blog URL already known
|
666 |
+
$strURL = '&method=SitesManager.getSitesIdFromSiteUrl';
|
|
|
667 |
$strURL .= '&url='.urlencode($strBlogURL);
|
668 |
$strURL .= '&format=PHP';
|
669 |
$strURL .= '&token_auth='.self::$aryGlobalSettings['piwik_token'];
|
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)) {
|
676 |
$strName = get_bloginfo('name');
|
677 |
if (empty($strName)) $strName = $strBlogURL;
|
678 |
+
$strURL .= '&method=SitesManager.addSite';
|
|
|
679 |
$strURL .= '&siteName='.urlencode($strName).'&urls='.urlencode($strBlogURL);
|
680 |
$strURL .= '&format=PHP';
|
681 |
$strURL .= '&token_auth='.self::$aryGlobalSettings['piwik_token'];
|
|
|
|
|
682 |
$strResult = unserialize($this->getRemoteFile($strURL));
|
683 |
if (!empty($strResult)) self::$arySettings['site_id'] = $strResult;
|
684 |
}
|
702 |
if (self::$aryGlobalSettings['track_compress']) $strCode = str_replace('pkBaseURL + "piwik.js\'', 'pkBaseURL + "js/\'', $strCode);
|
703 |
// Change code if POST is forced to be used
|
704 |
if (self::$aryGlobalSettings['track_post']) $strCode = str_replace('piwikTracker.trackPageView();', 'piwikTracker.setRequestMethod(\'POST\');'."\n".' piwikTracker.trackPageView();', $strCode);
|
705 |
+
// Change code if cookies are disabled
|
706 |
+
if (self::$aryGlobalSettings['disable_cookies']) $strCode = str_replace('piwikTracker.trackPageView();', 'piwikTracker.disableCookies();'."\n".'piwikTracker.trackPageView();', $strCode);
|
707 |
return $strCode;
|
708 |
}
|
709 |
|
739 |
// Call API if data not cached
|
740 |
if (empty($this->aryCache[$strKey])) {
|
741 |
$strToken = self::$aryGlobalSettings['piwik_token'];
|
|
|
742 |
// If multisite stats are shown, maybe the super admin wants to show other blog's stats.
|
743 |
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'])) {
|
744 |
$aryOptions = get_blog_option((int) $_GET['wpmu_show_stats'], 'wp-piwik_settings' , array());
|
748 |
// Otherwise use the current site's id.
|
749 |
} else $intSite = self::$arySettings['site_id'];
|
750 |
// Create error message if WP-Piwik isn't configured
|
751 |
+
if (!self::isConfigured()) {
|
752 |
+
$this->aryCache[$strKey] = array(
|
753 |
'result' => 'error',
|
754 |
+
'message' => 'Piwik URL/path or auth token not set.'
|
755 |
);
|
756 |
return $this->aryCache[$strKey];
|
757 |
}
|
758 |
// Build URL
|
759 |
+
$strURL = '&method='.$strMethod;
|
760 |
$strURL .= '&idSite='.$intSite.'&period='.$strPeriod.'&date='.$strDate;
|
761 |
$strURL .= '&filter_limit='.$intLimit;
|
762 |
$strURL .= '&token_auth='.$strToken;
|
974 |
*/
|
975 |
function applySettings() {
|
976 |
$strTab = (isset($_GET['tab'])?$_GET['tab']:'homepage');
|
977 |
+
self::$aryGlobalSettings['last_settings_update'] = time();
|
978 |
switch ($strTab) {
|
979 |
case 'views':
|
980 |
self::$aryGlobalSettings['dashboard_widget'] = (isset($_POST['wp-piwik_dbwidget'])?$_POST['wp-piwik_dbwidget']:0);
|
985 |
self::$aryGlobalSettings['default_date'] = (isset($_POST['wp-piwik_default_date'])?$_POST['wp-piwik_default_date']:'yesterday');
|
986 |
self::$aryGlobalSettings['capability_read_stats'] = (isset($_POST['wp-piwik_displayto'])?$_POST['wp-piwik_displayto']:array());
|
987 |
self::$aryGlobalSettings['disable_timelimit'] = (isset($_POST['wp-piwik_disabletimelimit'])?$_POST['wp-piwik_disabletimelimit']:false);
|
988 |
+
self::$aryGlobalSettings['toolbar'] = (isset($_POST['wp-piwik_toolbar'])?$_POST['wp-piwik_toolbar']:false);
|
989 |
break;
|
990 |
case 'tracking':
|
991 |
self::$aryGlobalSettings['add_tracking_code'] = (isset($_POST['wp-piwik_addjs'])?$_POST['wp-piwik_addjs']:false);
|
992 |
self::$aryGlobalSettings['track_404'] = (isset($_POST['wp-piwik_404'])?$_POST['wp-piwik_404']:false);
|
993 |
self::$aryGlobalSettings['track_compress'] = (isset($_POST['wp-piwik_compress'])?$_POST['wp-piwik_compress']:false);
|
994 |
self::$aryGlobalSettings['track_post'] = (isset($_POST['wp-piwik_reqpost'])?$_POST['wp-piwik_reqpost']:false);
|
995 |
+
self::$aryGlobalSettings['capability_stealth'] = (isset($_POST['wp-piwik_filter'])?$_POST['wp-piwik_filter']:array());
|
996 |
+
self::$aryGlobalSettings['disable_cookies'] = (isset($_POST['wp-piwik_disable_cookies'])?$_POST['wp-piwik_disable_cookies']:false);
|
997 |
break;
|
998 |
case 'piwik':
|
999 |
self::$aryGlobalSettings['piwik_token'] = (isset($_POST['wp-piwik_token'])?$_POST['wp-piwik_token']:'');
|
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'])
|
1007 |
} else self::$aryGlobalSettings['auto_site_config'] = true;
|
1008 |
break;
|
1009 |
}
|
1010 |
+
if (self::$aryGlobalSettings['auto_site_config'] && self::isConfigured()) {
|
1011 |
+
if (self::$aryGlobalSettings['piwik_mode'] == 'php' && !defined('PIWIK_INCLUDE_PATH'))
|
1012 |
+
self::definePiwikConstants();
|
1013 |
$aryReturn = $this->addPiwikSite();
|
1014 |
self::$arySettings['tracking_code'] = $aryReturn['js'];
|
1015 |
self::$arySettings['site_id'] = $aryReturn['id'];
|
1021 |
* Check & prepare URL
|
1022 |
*/
|
1023 |
static function checkURL($strURL) {
|
1024 |
+
if (empty($strURL)) return '';
|
1025 |
if (substr($strURL, -1, 1) != '/' && substr($strURL, -10, 10) != '/index.php')
|
1026 |
$strURL .= '/';
|
1027 |
return $strURL;
|
1040 |
// Show settings page title
|
1041 |
echo '<div class="wrap"><h2>'.__('WP-Piwik Settings', 'wp-piwik').'</h2>';
|
1042 |
// Show tabs
|
1043 |
+
$strTab = $this->showSettingsTabs(self::isConfigured(), $strTab);
|
1044 |
if ($strTab != 'sitebrowser') {
|
1045 |
/***************************************************************************/ ?>
|
1046 |
<div class="wp-piwik-donate">
|
1068 |
</div>
|
1069 |
</div>
|
1070 |
<?php /***************************************************************************/
|
1071 |
+
}
|
1072 |
echo '<form class="'.($strTab != 'sitebrowser'?'wp-piwik-settings':'').'" method="post" action="'.admin_url(($pagenow == 'settings.php'?'network/':'').$pagenow.'?page=wp-piwik/wp-piwik.php&tab='.$strTab).'">';
|
1073 |
echo '<input type="hidden" name="action" value="save_wp-piwik_settings" />';
|
1074 |
wp_nonce_field('wp-piwik_settings');
|
1097 |
* Show an error message extended by a support site link
|
1098 |
*/
|
1099 |
private static function showErrorMessage($strMessage) {
|
1100 |
+
echo '<strong class="wp-piwik-error">'.__('An error occured', 'wp-piwik').':</strong> '.$strMessage.' [<a href="'.(is_plugin_active_for_network('wp-piwik/wp-piwik.php')?'network/settings':'options-general').'.php?page=wp-piwik/wp-piwik.php&tab=support">'.__('Support','wp-piwik').'</a>]';
|
1101 |
}
|
1102 |
|
1103 |
/**
|
1136 |
'last_settings_update' => 0,
|
1137 |
'piwik_token' => ($bolFull?'':self::$aryGlobalSettings['piwik_token']),
|
1138 |
'piwik_url' => ($bolFull?'':self::$aryGlobalSettings['piwik_url']),
|
1139 |
+
'piwik_path' => ($bolFull?'':self::$aryGlobalSettings['piwik_path']),
|
1140 |
+
'piwik_mode' => ($bolFull?'':self::$aryGlobalSettings['piwik_mode']),
|
1141 |
'dashboard_widget' => false,
|
1142 |
'dashboard_chart' => false,
|
1143 |
'dashboard_seo' => false,
|
1150 |
'track_404' => false,
|
1151 |
'track_compress' => false,
|
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')) {
|
1180 |
}
|
1181 |
return $intResult;
|
1182 |
}
|
1183 |
+
|
1184 |
+
/**
|
1185 |
+
* Is WP-Piwik configured?
|
1186 |
+
*/
|
1187 |
+
public static function isConfigured() {
|
1188 |
+
return (
|
1189 |
+
!empty(self::$aryGlobalSettings['piwik_token'])
|
1190 |
+
&& (
|
1191 |
+
(
|
1192 |
+
(self::$aryGlobalSettings['piwik_mode'] == 'http') && !empty(self::$aryGlobalSettings['piwik_url'])
|
1193 |
+
) || (
|
1194 |
+
(self::$aryGlobalSettings['piwik_mode'] == 'php') && !empty(self::$aryGlobalSettings['piwik_path'])
|
1195 |
+
)
|
1196 |
+
)
|
1197 |
+
);
|
1198 |
+
}
|
1199 |
+
|
1200 |
+
/**
|
1201 |
+
* Set Piwik PHP API constants
|
1202 |
+
*/
|
1203 |
+
private static function definePiwikConstants() {
|
1204 |
+
define('PIWIK_INCLUDE_PATH', self::$aryGlobalSettings['piwik_path']);
|
1205 |
+
define('PIWIK_USER_PATH', self::$aryGlobalSettings['piwik_path']);
|
1206 |
+
define('PIWIK_ENABLE_DISPATCH', false);
|
1207 |
+
define('PIWIK_ENABLE_ERROR_HANDLER', false);
|
1208 |
+
define('PIWIK_ENABLE_SESSION_START', false);
|
1209 |
+
}
|
1210 |
}
|
1211 |
|
1212 |
if (class_exists('wp_piwik'))
|