WP-Matomo (WP-Piwik) - Version 0.9.1

Version Description

  • Bugfix: Usage as "Site Specific Plugin" mixed up the different sites settings (network mode)
  • Hotfix: Avoid "Unknown site/blog" message without giving a chance to choose an existing site. Thank you, Taimon!
Download this release

Release Info

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

Code changes from version 0.9.0 to 0.9.1

languages/wp-piwik-de_DE.mo CHANGED
Binary file
languages/wp-piwik-de_DE.po CHANGED
@@ -464,4 +464,7 @@ msgid "My Amazon.de wishlist"
464
  msgstr "Meine Wunschliste bei Amazon.de"
465
 
466
  msgid "Piwik error"
467
- msgstr "Piwik-Fehler"
 
 
 
464
  msgstr "Meine Wunschliste bei Amazon.de"
465
 
466
  msgid "Piwik error"
467
+ msgstr "Piwik-Fehler"
468
+
469
+ msgid "Important"
470
+ msgstr "Wichtig"
readme.txt CHANGED
@@ -3,7 +3,7 @@
3
  Contributors: Braekling
4
  Requires at least: 3.3
5
  Tested up to: 3.3.1
6
- Stable tag: 0.9.0
7
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6046779
8
  Tags: statistics, stats, analytics, piwik, wpmu
9
 
@@ -25,19 +25,7 @@ Languages: English, German, Albanian, Azerbaijani, Belorussian, Dutch, French, G
25
 
26
  = WP multisite =
27
 
28
- Version 0.6.0 (or newer) includes experimental WP multisite support.
29
-
30
- **Experimental**
31
-
32
- The WP multisite support is still experimental. Please test it on your own (e.g. using a local copy of your WP multisite) before you use it in an user context.
33
-
34
- **Simple**
35
-
36
- Just add WP-Piwik to your /wp-content/plugins folder and enable the Plugins page for individual site administrators. So each user can enable WP-Piwik and use his own Piwik instance.
37
-
38
- **Extended (WPMU-Piwik)**
39
-
40
- Add WP-Piwik to your /wp-content/plugins folder and enable it as [Network Plugin](http://codex.wordpress.org/Create_A_Network#WordPress_Plugins). Users have access to their own statistics, site admins can access each blog's statistics. Please test it on your own (e.g. using a local copy of your WPMU) before you use it in an user context.
41
 
42
  = Credits =
43
 
@@ -52,16 +40,18 @@ Add WP-Piwik to your /wp-content/plugins folder and enable it as [Network Plugin
52
  * Russian [ru_RU] language file by [Natalya](http://www.luxpar.de).
53
  * Swedish [sv_SE] language file by [EzBizNiz](http://ezbizniz.com/).
54
  * Norwegian [nb_NO] language file by Gormer.
55
- * Donations: Marco L., Rolf W., Tobias U., Lars K., Donna F., the Piwik team itself, and all people flattering this.
56
  * All users who send me mails containing criticism, commendation, feature requests and bug reports - you help me to make WP-Piwik much better!
57
 
58
  Thank you all!
59
 
60
  == Installation ==
61
 
 
 
62
  1. Upload the full `wp-piwik` directory into your `wp-content/plugins` directory.
63
 
64
- 2. Activate the plugin through the 'Plugins' menu in WordPress. (As a multisite admin you can enable WP-Piwik as *experimental* [Network Plugin](http://codex.wordpress.org/Create_A_Network#WordPress_Plugins) also.)
65
 
66
  3. Open the new 'Settings/WP-Piwik Settings' menu, enter your Piwik base URL and your auth token. Save settings.
67
 
@@ -69,6 +59,22 @@ Thank you all!
69
 
70
  5. Look at 'Dashboard/WP-Piwik' to get your site stats.
71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  == Screenshots ==
73
 
74
  1. WP-Piwik settings.
@@ -77,6 +83,10 @@ Thank you all!
77
 
78
  == Changelog ==
79
 
 
 
 
 
80
  = 0.9.0 =
81
  * Auto-configuration
82
  * No code change required to enable WPMU mode anymore (Still experimental. Please create a backup before trying 0.9.0!)
3
  Contributors: Braekling
4
  Requires at least: 3.3
5
  Tested up to: 3.3.1
6
+ Stable tag: 0.9.1
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
 
25
 
26
  = WP multisite =
27
 
28
+ See section "Installation".
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  = Credits =
31
 
40
  * Russian [ru_RU] language file by [Natalya](http://www.luxpar.de).
41
  * Swedish [sv_SE] language file by [EzBizNiz](http://ezbizniz.com/).
42
  * Norwegian [nb_NO] language file by Gormer.
43
+ * Donations: Marco L., Rolf W., Tobias U., Lars K., Donna F., Kevin D., Ramos S, the Piwik team itself, and all people flattering this.
44
  * All users who send me mails containing criticism, commendation, feature requests and bug reports - you help me to make WP-Piwik much better!
45
 
46
  Thank you all!
47
 
48
  == Installation ==
49
 
50
+ = Install WP-Piwik on a simple WordPress blog =
51
+
52
  1. Upload the full `wp-piwik` directory into your `wp-content/plugins` directory.
53
 
54
+ 2. Activate the plugin through the 'Plugins' menu in WordPress.
55
 
56
  3. Open the new 'Settings/WP-Piwik Settings' menu, enter your Piwik base URL and your auth token. Save settings.
57
 
59
 
60
  5. Look at 'Dashboard/WP-Piwik' to get your site stats.
61
 
62
+ = Install WP-Piwik on a WordPress blog network (WPMU/WP multisite) =
63
+
64
+ There are two differents methods to use WP-Piwik in a multisite environment:
65
+ * As a Site Specific Plugin it behaves like a plugin installed on a simple WordPress blog. Each user can enable, configure and use WP-Piwik on his own. Users can even use their own Piwik instances (and accordingly they have to).
66
+ * Using WP-Piwik as a Network Plugin equates to a central approach. A single Piwik instance is used and the site admin configures the plugin completely. Users are just allowed to see their own statistics, site admins can see each blog's stats.
67
+
68
+ ** Site Specific Plugin **
69
+
70
+ Just add WP-Piwik to your /wp-content/plugins folder and enable the Plugins page for individual site administrators. Each user has to enable and configure WP-Piwik on his own if he want to use the plugin.
71
+
72
+ ** Network Plugin **
73
+
74
+ The Network Plugin support is still experimental. Please test it on your own (e.g. using a local copy of your WP multisite) before you use it in an user context.
75
+
76
+ Add WP-Piwik to your /wp-content/plugins folder and enable it as [Network Plugin](http://codex.wordpress.org/Create_A_Network#WordPress_Plugins). Users can access their own statistics, site admins can access each blog's statistics and the plugin's configuration.
77
+
78
  == Screenshots ==
79
 
80
  1. WP-Piwik settings.
83
 
84
  == Changelog ==
85
 
86
+ = 0.9.1 =
87
+ * Bugfix: Usage as "Site Specific Plugin" [mixed up the different sites settings](http://wordpress.org/support/topic/plugin-wp-piwik-as-simple-plugin-with-multisite-fills-auth-with-last-used-token) (network mode)
88
+ * Hotfix: Avoid "Unknown site/blog" message without giving a chance to choose an existing site. Thank you, Taimon!
89
+
90
  = 0.9.0 =
91
  * Auto-configuration
92
  * No code change required to enable WPMU mode anymore (Still experimental. Please create a backup before trying 0.9.0!)
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.0
10
  Author: André Bräkling
11
  Author URI: http://www.braekling.de
12
 
@@ -59,12 +59,12 @@ if (!function_exists('is_plugin_active_for_network'))
59
  class wp_piwik {
60
 
61
  private static
62
- $intRevisionId = 90001,
63
- $strVersion = '0.9.0',
64
  $intDashboardID = 30,
65
  $strPluginBasename = NULL,
66
  $aryGlobalSettings = array(
67
- 'revision' => 90001,
68
  'add_tracking_code' => false,
69
  'last_settings_update' => 0,
70
  'piwik_token' => '',
@@ -97,7 +97,10 @@ class wp_piwik {
97
  */
98
  static function loadSettings() {
99
  // Get global settings
100
- self::$aryGlobalSettings = get_site_option('wp-piwik_global-settings',self::$aryGlobalSettings);
 
 
 
101
  // Get site settings
102
  self::$arySettings = get_option('wp-piwik_settings',self::$arySettings);
103
  }
@@ -107,8 +110,11 @@ class wp_piwik {
107
  */
108
  static function saveSettings() {
109
  // Save global settings
110
- update_site_option('wp-piwik_global-settings',self::$aryGlobalSettings);
111
- // Save site settings
 
 
 
112
  update_option('wp-piwik_settings',self::$arySettings);
113
  // Load WP_Roles class
114
  global $wp_roles;
@@ -237,7 +243,7 @@ class wp_piwik {
237
  // Create settings Link
238
  $strLink = sprintf('<a href="options-general.php?page=%s">%s</a>', self::$strPluginBasename, __('Settings', 'wp-piwik'));
239
  // Display message
240
- echo '<div id="message" class="updated fade"><p>'.$strText.' '.$strSettings.': '.$strLink.'.</p></div>';
241
  }
242
 
243
  /**
@@ -254,11 +260,8 @@ class wp_piwik {
254
  // Hotfix: Update network site if not done yet
255
  if (is_plugin_active_for_network('wp-piwik/wp-piwik.php') && get_option('wp-piwik_siteid', false)) $this->updateSite();
256
  // Autohandle site if no tracking code available
257
- if (empty(self::$arySettings['tracking_code'])) {
258
  $aryReturn = $this->addPiwikSite();
259
- self::$arySettings['tracking_code'] = $aryReturn['js'];
260
- self::saveSettings();
261
- }
262
  // Update/get code if outdated/unknown
263
  if (self::$arySettings['last_tracking_code_update'] < self::$aryGlobalSettings['last_settings_update'] || empty(self::$arySettings['tracking_code'])) {
264
  $strJSCode = $this->callPiwikAPI('SitesManager.getJavascriptTag');
@@ -640,7 +643,7 @@ class wp_piwik {
640
  $strURL .= '&url='.urlencode(get_bloginfo('url'));
641
  $strURL .= '&format='.$strFormat;
642
  // Fetch data if site exists
643
- if (!empty($intSite)) {
644
  $strResult = (string) $this->getRemoteFile($strURL);
645
  $this->aryCache[$strKey] = ($strFormat == 'PHP'?unserialize($strResult):$strResult);
646
  // Otherwise return error message
@@ -946,8 +949,13 @@ class wp_piwik {
946
  } else {
947
  if (!is_plugin_active_for_network('wp-piwik/wp-piwik.php')) {
948
  if (empty($intSite)) {
949
- self::$arySettings['site_id'] = $aryData[0]['idsite'];
950
- self::saveSettings();
 
 
 
 
 
951
  }
952
  if (!self::$aryGlobalSettings['auto_site_config']) {
953
  echo '<h4><label for="wp-piwik_siteid">'.__('Choose site', 'wp-piwik').':</label></h4>';
@@ -998,6 +1006,7 @@ class wp_piwik {
998
  <?php /************************************************************************/
999
  echo '<h4><label for="wp-piwik_jscode">JavaScript:</label></h4>'.
1000
  '<div class="input-text-wrap"><textarea id="wp-piwik_jscode" name="wp-piwik_jscode" readonly="readonly" rows="13" cols="55">'.
 
1001
  htmlentities($strJavaScript).'</textarea></div>';
1002
  echo '<h4><label for="wp-piwik_addjs">'.__('Add script', 'wp-piwik').':</label></h4>'.
1003
  '<div class="input-wrap"><input type="checkbox" value="1" id="wp-piwik_addjs" name="wp-piwik_addjs" '.
6
 
7
  Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress footer.
8
 
9
+ Version: 0.9.1
10
  Author: Andr&eacute; Br&auml;kling
11
  Author URI: http://www.braekling.de
12
 
59
  class wp_piwik {
60
 
61
  private static
62
+ $intRevisionId = 90101,
63
+ $strVersion = '0.9.1',
64
  $intDashboardID = 30,
65
  $strPluginBasename = NULL,
66
  $aryGlobalSettings = array(
67
+ 'revision' => 90101,
68
  'add_tracking_code' => false,
69
  'last_settings_update' => 0,
70
  'piwik_token' => '',
97
  */
98
  static function loadSettings() {
99
  // Get global settings
100
+ self::$aryGlobalSettings = (is_plugin_active_for_network('wp-piwik/wp-piwik.php')?
101
+ get_site_option('wp-piwik_global-settings',self::$aryGlobalSettings):
102
+ get_option('wp-piwik_global-settings',self::$aryGlobalSettings)
103
+ );
104
  // Get site settings
105
  self::$arySettings = get_option('wp-piwik_settings',self::$arySettings);
106
  }
110
  */
111
  static function saveSettings() {
112
  // Save global settings
113
+ if (is_plugin_active_for_network('wp-piwik/wp-piwik.php'))
114
+ update_site_option('wp-piwik_global-settings',self::$aryGlobalSettings);
115
+ else
116
+ update_option('wp-piwik_global-settings',self::$aryGlobalSettings);
117
+ // Save blog settings
118
  update_option('wp-piwik_settings',self::$arySettings);
119
  // Load WP_Roles class
120
  global $wp_roles;
243
  // Create settings Link
244
  $strLink = sprintf('<a href="options-general.php?page=%s">%s</a>', self::$strPluginBasename, __('Settings', 'wp-piwik'));
245
  // Display message
246
+ echo '<div id="message" class="updated fade"><p>'.$strText.' <strong>'.__('Important', 'wp-piwik').':</strong> '.$strSettings.': '.$strLink.'.</p></div>';
247
  }
248
 
249
  /**
260
  // Hotfix: Update network site if not done yet
261
  if (is_plugin_active_for_network('wp-piwik/wp-piwik.php') && get_option('wp-piwik_siteid', false)) $this->updateSite();
262
  // Autohandle site if no tracking code available
263
+ if (empty(self::$arySettings['tracking_code']))
264
  $aryReturn = $this->addPiwikSite();
 
 
 
265
  // Update/get code if outdated/unknown
266
  if (self::$arySettings['last_tracking_code_update'] < self::$aryGlobalSettings['last_settings_update'] || empty(self::$arySettings['tracking_code'])) {
267
  $strJSCode = $this->callPiwikAPI('SitesManager.getJavascriptTag');
643
  $strURL .= '&url='.urlencode(get_bloginfo('url'));
644
  $strURL .= '&format='.$strFormat;
645
  // Fetch data if site exists
646
+ if (!empty($intSite) || $strMethod='SitesManager.getSitesWithAtLeastViewAccess') {
647
  $strResult = (string) $this->getRemoteFile($strURL);
648
  $this->aryCache[$strKey] = ($strFormat == 'PHP'?unserialize($strResult):$strResult);
649
  // Otherwise return error message
949
  } else {
950
  if (!is_plugin_active_for_network('wp-piwik/wp-piwik.php')) {
951
  if (empty($intSite)) {
952
+ if (self::$aryGlobalSettings['auto_site_config'])
953
+ $aryReturn = $this->addPiwikSite();
954
+ else {
955
+ self::$arySettings['site_id'] = $aryData[0]['idsite'];
956
+ self::saveSettings();
957
+ }
958
+ $intSite = self::$arySettings['site_id'];
959
  }
960
  if (!self::$aryGlobalSettings['auto_site_config']) {
961
  echo '<h4><label for="wp-piwik_siteid">'.__('Choose site', 'wp-piwik').':</label></h4>';
1006
  <?php /************************************************************************/
1007
  echo '<h4><label for="wp-piwik_jscode">JavaScript:</label></h4>'.
1008
  '<div class="input-text-wrap"><textarea id="wp-piwik_jscode" name="wp-piwik_jscode" readonly="readonly" rows="13" cols="55">'.
1009
+ (is_plugin_active_for_network('wp-piwik/wp-piwik.php')?'*** SITE SPECIFIC EXAMPLE CODE ***'."\n":'').
1010
  htmlentities($strJavaScript).'</textarea></div>';
1011
  echo '<h4><label for="wp-piwik_addjs">'.__('Add script', 'wp-piwik').':</label></h4>'.
1012
  '<div class="input-wrap"><input type="checkbox" value="1" id="wp-piwik_addjs" name="wp-piwik_addjs" '.