Version Description
Please update Piwik if not done yet (Piwik 2.7 or higher is recommended).
Download this release
Release Info
Developer | Braekling |
Plugin | WP-Matomo (WP-Piwik) |
Version | 0.10.0.2 |
Comparing to | |
See all releases |
Code changes from version 0.10.0.1 to 0.10.0.2
- cache/.htaccess +0 -1
- classes/WP_Piwik.php +31 -13
- classes/WP_Piwik/Admin/Settings.php +21 -20
- classes/WP_Piwik/Request.php +20 -3
- classes/WP_Piwik/Settings.php +3 -1
- classes/WP_Piwik/TrackingCode.php +2 -4
- css/wp-piwik.css +4 -0
- proxy/config.php +13 -2
- uninstall.php +91 -6
- update/100000.php +18 -0
- wp-piwik.php +1 -1
cache/.htaccess
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
Deny from all
|
|
classes/WP_Piwik.php
CHANGED
@@ -12,7 +12,7 @@ class WP_Piwik {
|
|
12 |
*
|
13 |
* @var Runtime environment variables
|
14 |
*/
|
15 |
-
private static $intRevisionId =
|
16 |
|
17 |
/**
|
18 |
* Constructor class to configure and register all WP-Piwik components
|
@@ -194,7 +194,7 @@ class WP_Piwik {
|
|
194 |
self::$logger->log ( 'Running WP-Piwik uninstallation' );
|
195 |
if (! defined ( 'WP_UNINSTALL_PLUGIN' ))
|
196 |
exit ();
|
197 |
-
delete_option ( 'wp-
|
198 |
self::$settings->resetSettings ( true );
|
199 |
}
|
200 |
|
@@ -229,13 +229,13 @@ class WP_Piwik {
|
|
229 |
* set to true if the message should persist (default: false)
|
230 |
*/
|
231 |
private function addNotice($type, $subject, $text, $stay = false) {
|
232 |
-
$notices = get_option ( 'wp-
|
233 |
$notices [$type] = array (
|
234 |
'subject' => $subject,
|
235 |
'text' => $text,
|
236 |
'stay' => $stay
|
237 |
);
|
238 |
-
update_option ( 'wp-
|
239 |
}
|
240 |
|
241 |
/**
|
@@ -245,14 +245,14 @@ class WP_Piwik {
|
|
245 |
*/
|
246 |
public function showNotices() {
|
247 |
$link = sprintf ( '<a href="' . $this->getSettingsURL () . '">%s</a>', __ ( 'Settings', 'wp-piwik' ) );
|
248 |
-
if ($notices = get_option ( 'wp-
|
249 |
foreach ( $notices as $type => $notice ) {
|
250 |
printf ( '<div class="updated fade"><p>%s <strong>%s:</strong> %s: %s</p></div>', $notice ['subject'], __ ( 'Important', 'wp-piwik' ), $notice ['text'], $link );
|
251 |
if (! $notice ['stay'])
|
252 |
unset ( $notices [$type] );
|
253 |
}
|
254 |
}
|
255 |
-
update_option ( 'wp-
|
256 |
}
|
257 |
|
258 |
/**
|
@@ -276,7 +276,13 @@ class WP_Piwik {
|
|
276 |
$trackingCode->is404 = (is_404 () && self::$settings->getGlobalOption ( 'track_404' ));
|
277 |
$trackingCode->isSearch = (is_search () && self::$settings->getGlobalOption ( 'track_search' ));
|
278 |
self::$logger->log ( 'Add tracking code. Blog ID: ' . self::$blog_id . ' Site ID: ' . self::$settings->getOption ( 'site_id' ) );
|
279 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
280 |
}
|
281 |
|
282 |
/**
|
@@ -456,11 +462,11 @@ class WP_Piwik {
|
|
456 |
* Prepare toolbar widget requirements
|
457 |
*/
|
458 |
public function loadToolbarRequirements() {
|
459 |
-
if (
|
460 |
wp_enqueue_script ( 'wp-piwik-sparkline', $this->getPluginURL () . 'js/sparkline/jquery.sparkline.min.js', array (
|
461 |
'jquery'
|
462 |
), self::$strVersion );
|
463 |
-
wp_enqueue_style ( 'wp-piwik', $this->getPluginURL () . 'css/wp-piwik-spark.css', array (),
|
464 |
}
|
465 |
}
|
466 |
|
@@ -543,7 +549,6 @@ class WP_Piwik {
|
|
543 |
self::definePiwikConstants ();
|
544 |
$siteId = $this->requestPiwikSiteId ();
|
545 |
$trackingCode = $this->updateTrackingCode( $siteId );
|
546 |
-
self::$settings->getOption ( 'tracking_code', $trackingCode );
|
547 |
self::$settings->getOption ( 'site_id', $siteId );
|
548 |
}
|
549 |
return true;
|
@@ -852,6 +857,17 @@ class WP_Piwik {
|
|
852 |
return self::$settings->getOption ( $key );
|
853 |
}
|
854 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
855 |
/**
|
856 |
* Get stats page URL
|
857 |
*
|
@@ -964,8 +980,6 @@ class WP_Piwik {
|
|
964 |
self::$settings->setOption ( 'site_id', $result, $blogId );
|
965 |
if (self::$settings->getGlobalOption ( 'track_mode' ) != 'disabled' && self::$settings->getGlobalOption ( 'track_mode' ) != 'manually') {
|
966 |
$code = $this->updateTrackingCode ( $result, $blogId );
|
967 |
-
self::$settings->setOption ( 'tracking_code', $code ['script'], $blogId );
|
968 |
-
self::$settings->setOption ( 'noscript_code', $code ['noscript'], $blogId );
|
969 |
}
|
970 |
$this::$settings->save ();
|
971 |
return $result;
|
@@ -1026,8 +1040,10 @@ class WP_Piwik {
|
|
1026 |
* @return string tracking code
|
1027 |
*/
|
1028 |
public function updateTrackingCode($siteId = false, $blogId = null) {
|
1029 |
-
if (! $siteId)
|
1030 |
$siteId = $this->getPiwikSiteId ();
|
|
|
|
|
1031 |
$id = WP_Piwik\Request::register ( 'SitesManager.getJavascriptTag', array (
|
1032 |
'idSite' => $siteId,
|
1033 |
'mergeSubdomains' => self::$settings->getGlobalOption ( 'track_across' ) ? 1 : 0,
|
@@ -1037,6 +1053,8 @@ class WP_Piwik {
|
|
1037 |
$result = html_entity_decode ( $this->request ( $id ) );
|
1038 |
self::$logger->log ( 'Delivered tracking code: ' . $result );
|
1039 |
$result = WP_Piwik\TrackingCode::prepareTrackingCode ( $result, self::$settings, self::$logger );
|
|
|
|
|
1040 |
return $result;
|
1041 |
}
|
1042 |
|
12 |
*
|
13 |
* @var Runtime environment variables
|
14 |
*/
|
15 |
+
private static $intRevisionId = 100000, $strVersion = '0.10.0.2', $blog_id, $intDashboardID = 30, $strPluginBasename = NULL, $bolJustActivated = false, $logger, $settings, $request;
|
16 |
|
17 |
/**
|
18 |
* Constructor class to configure and register all WP-Piwik components
|
194 |
self::$logger->log ( 'Running WP-Piwik uninstallation' );
|
195 |
if (! defined ( 'WP_UNINSTALL_PLUGIN' ))
|
196 |
exit ();
|
197 |
+
delete_option ( 'wp-piwik-notices' );
|
198 |
self::$settings->resetSettings ( true );
|
199 |
}
|
200 |
|
229 |
* set to true if the message should persist (default: false)
|
230 |
*/
|
231 |
private function addNotice($type, $subject, $text, $stay = false) {
|
232 |
+
$notices = get_option ( 'wp-piwik-notices', array () );
|
233 |
$notices [$type] = array (
|
234 |
'subject' => $subject,
|
235 |
'text' => $text,
|
236 |
'stay' => $stay
|
237 |
);
|
238 |
+
update_option ( 'wp-piwik-notices', $notices );
|
239 |
}
|
240 |
|
241 |
/**
|
245 |
*/
|
246 |
public function showNotices() {
|
247 |
$link = sprintf ( '<a href="' . $this->getSettingsURL () . '">%s</a>', __ ( 'Settings', 'wp-piwik' ) );
|
248 |
+
if ($notices = get_option ( 'wp-piwik-notices' )) {
|
249 |
foreach ( $notices as $type => $notice ) {
|
250 |
printf ( '<div class="updated fade"><p>%s <strong>%s:</strong> %s: %s</p></div>', $notice ['subject'], __ ( 'Important', 'wp-piwik' ), $notice ['text'], $link );
|
251 |
if (! $notice ['stay'])
|
252 |
unset ( $notices [$type] );
|
253 |
}
|
254 |
}
|
255 |
+
update_option ( 'wp-piwik-notices', $notices );
|
256 |
}
|
257 |
|
258 |
/**
|
276 |
$trackingCode->is404 = (is_404 () && self::$settings->getGlobalOption ( 'track_404' ));
|
277 |
$trackingCode->isSearch = (is_search () && self::$settings->getGlobalOption ( 'track_search' ));
|
278 |
self::$logger->log ( 'Add tracking code. Blog ID: ' . self::$blog_id . ' Site ID: ' . self::$settings->getOption ( 'site_id' ) );
|
279 |
+
if ( $this->isNetworkMode() && self::$settings->getGlobalOption ( 'track_mode' ) == 'manually' ) {
|
280 |
+
$siteId = $this->getPiwikSiteId();
|
281 |
+
if ($siteId != 'n/a')
|
282 |
+
echo str_replace( '{ID}', $siteId, $trackingCode->getTrackingCode () );
|
283 |
+
else echo '<!-- Site will be created and tracking code added on next request -->';
|
284 |
+
}
|
285 |
+
else echo $trackingCode->getTrackingCode ();
|
286 |
}
|
287 |
|
288 |
/**
|
462 |
* Prepare toolbar widget requirements
|
463 |
*/
|
464 |
public function loadToolbarRequirements() {
|
465 |
+
if ( is_admin_bar_showing () ) {
|
466 |
wp_enqueue_script ( 'wp-piwik-sparkline', $this->getPluginURL () . 'js/sparkline/jquery.sparkline.min.js', array (
|
467 |
'jquery'
|
468 |
), self::$strVersion );
|
469 |
+
wp_enqueue_style ( 'wp-piwik', $this->getPluginURL () . 'css/wp-piwik-spark.css', array (), $this->getPluginVersion() );
|
470 |
}
|
471 |
}
|
472 |
|
549 |
self::definePiwikConstants ();
|
550 |
$siteId = $this->requestPiwikSiteId ();
|
551 |
$trackingCode = $this->updateTrackingCode( $siteId );
|
|
|
552 |
self::$settings->getOption ( 'site_id', $siteId );
|
553 |
}
|
554 |
return true;
|
857 |
return self::$settings->getOption ( $key );
|
858 |
}
|
859 |
|
860 |
+
/**
|
861 |
+
* Get global option value
|
862 |
+
*
|
863 |
+
* @param string $key
|
864 |
+
* global option key
|
865 |
+
* @return mixed global option value
|
866 |
+
*/
|
867 |
+
public function getGlobalOption($key) {
|
868 |
+
return self::$settings->getGlobalOption ( $key );
|
869 |
+
}
|
870 |
+
|
871 |
/**
|
872 |
* Get stats page URL
|
873 |
*
|
980 |
self::$settings->setOption ( 'site_id', $result, $blogId );
|
981 |
if (self::$settings->getGlobalOption ( 'track_mode' ) != 'disabled' && self::$settings->getGlobalOption ( 'track_mode' ) != 'manually') {
|
982 |
$code = $this->updateTrackingCode ( $result, $blogId );
|
|
|
|
|
983 |
}
|
984 |
$this::$settings->save ();
|
985 |
return $result;
|
1040 |
* @return string tracking code
|
1041 |
*/
|
1042 |
public function updateTrackingCode($siteId = false, $blogId = null) {
|
1043 |
+
if ( ! $siteId )
|
1044 |
$siteId = $this->getPiwikSiteId ();
|
1045 |
+
if ( self::$settings->getGlobalOption('track_mode') == 'disabled' || self::$settings->getGlobalOption('track_mode') == 'manually' )
|
1046 |
+
return false;
|
1047 |
$id = WP_Piwik\Request::register ( 'SitesManager.getJavascriptTag', array (
|
1048 |
'idSite' => $siteId,
|
1049 |
'mergeSubdomains' => self::$settings->getGlobalOption ( 'track_across' ) ? 1 : 0,
|
1053 |
$result = html_entity_decode ( $this->request ( $id ) );
|
1054 |
self::$logger->log ( 'Delivered tracking code: ' . $result );
|
1055 |
$result = WP_Piwik\TrackingCode::prepareTrackingCode ( $result, self::$settings, self::$logger );
|
1056 |
+
self::$settings->setOption ( 'tracking_code', $result ['script'], $blogId );
|
1057 |
+
self::$settings->setOption ( 'noscript_code', $result ['noscript'], $blogId );
|
1058 |
return $result;
|
1059 |
}
|
1060 |
|
classes/WP_Piwik/Admin/Settings.php
CHANGED
@@ -96,23 +96,24 @@ class Settings extends \WP_Piwik\Admin {
|
|
96 |
|
97 |
// Site configuration
|
98 |
$piwikSiteId = self::$wpPiwik->isConfigured () ? self::$wpPiwik->getPiwikSiteId () : false;
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
$
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
|
|
116 |
|
117 |
echo $submitButton;
|
118 |
|
@@ -168,7 +169,7 @@ class Settings extends \WP_Piwik\Admin {
|
|
168 |
$isNotGeneratedTracking = $isNotTracking || self::$settings->getGlobalOption ( 'track_mode' ) == 'manually';
|
169 |
$fullGeneratedTrackingGroup = 'wp-piwik-track-option wp-piwik-track-option-default wp-piwik-track-option-js wp-piwik-track-option-proxy';
|
170 |
|
171 |
-
$description = sprintf ( '%s<br /><strong>%s:</strong> %s<br /><strong>%s:</strong> %s<br /><strong>%s:</strong> %s<br /><strong>%s:</strong> %s<br /><strong>%s:</strong> %s', __ ( 'You can choose between four tracking code modes:', 'wp-piwik' ), __ ( 'Disabled', 'wp-piwik' ), __ ( 'WP-Piwik will not add the tracking code. Use this, if you want to add the tracking code to your template files or you use another plugin to add the tracking code.', 'wp-piwik' ), __ ( 'Default tracking', 'wp-piwik' ), __ ( 'TODO', 'wp-piwik' ), __ ( 'Use js/index.php', 'wp-piwik' ), __ ( 'TODO', 'wp-piwik' ), __ ( 'Use proxy script', 'wp-piwik' ), __ ( 'TODO', 'wp-piwik' ), __ ( 'Enter manually', 'wp-piwik' ), __ ( 'TODO', 'wp-piwik' ) );
|
172 |
$this->showSelect ( 'track_mode', __ ( 'Add tracking code', 'wp-piwik' ), array (
|
173 |
'disabled' => __ ( 'Disabled', 'wp-piwik' ),
|
174 |
'default' => __ ( 'Default tracking', 'wp-piwik' ),
|
@@ -184,9 +185,9 @@ class Settings extends \WP_Piwik\Admin {
|
|
184 |
'header' => __ ( 'Header', 'wp-piwik' )
|
185 |
), __ ( 'Choose whether the JavaScript code is added to the footer or the header.', 'wp-piwik' ), '', $isNotTracking, 'wp-piwik-track-option wp-piwik-track-option-default wp-piwik-track-option-js wp-piwik-track-option-proxy wp-piwik-track-option-manually' );
|
186 |
|
187 |
-
$this->showTextarea ( 'noscript_code', __ ( 'Noscript code', 'wp-piwik' ), 2, 'TODO noscript code desc', $
|
188 |
|
189 |
-
$this->showCheckbox ( 'track_noscript', __ ( 'Add <noscript>', 'wp-piwik' ), __ ( 'Adds the <noscript> code to your footer.', 'wp-piwik' ) . ' ' . __ ( 'Disabled in proxy mode.', 'wp-piwik' ), $isNotGeneratedTracking || self::$settings->getGlobalOption ( 'track_mode' ) == 'proxy', 'wp-piwik-track-option wp-piwik-track-option-default wp-piwik-track-option-js
|
190 |
|
191 |
$this->showCheckbox ( 'track_nojavascript', __ ( 'Add rec parameter to noscript code', 'wp-piwik' ), __ ( 'Enable tracking for visitors without JavaScript (not recommended).', 'wp-piwik' ) . ' ' . sprintf ( __ ( 'See %sPiwik FAQ%s.', 'wp-piwik' ), '<a href="http://piwik.org/faq/how-to/#faq_176">', '</a>' ) . ' ' . __ ( 'Disabled in proxy mode.', 'wp-piwik' ), $isNotGeneratedTracking || self::$settings->getGlobalOption ( 'track_mode' ) == 'proxy', 'wp-piwik-track-option wp-piwik-track-option-default wp-piwik-track-option-js' );
|
192 |
|
96 |
|
97 |
// Site configuration
|
98 |
$piwikSiteId = self::$wpPiwik->isConfigured () ? self::$wpPiwik->getPiwikSiteId () : false;
|
99 |
+
if (! self::$wpPiwik->isNetworkMode() ) {
|
100 |
+
$this->showCheckbox ( 'auto_site_config', __ ( 'Auto config', 'wp-piwik' ), __ ( 'Check this to automatically choose your blog from your Piwik sites by URL. If your blog is not added to Piwik yet, WP-Piwik will add a new site.', 'wp-piwik' ), false, '$j(\'tr.wp-piwik-auto-option\').toggle(\'hidden\');' . ($piwikSiteId ? '$j(\'#site_id\').val(' . $piwikSiteId . ');' : '') );
|
101 |
+
if (self::$wpPiwik->isConfigured ()) {
|
102 |
+
$piwikSiteDetails = self::$wpPiwik->getPiwikSiteDetails ();
|
103 |
+
if (($piwikSiteId == 'n/a'))
|
104 |
+
$piwikSiteDescription = 'n/a';
|
105 |
+
elseif (! self::$settings->getGlobalOption ( 'auto_site_config' ))
|
106 |
+
$piwikSiteDescription = __ ( 'Save settings to start estimation.', 'wp-piwik' );
|
107 |
+
else
|
108 |
+
$piwikSiteDescription = $piwikSiteDetails [$piwikSiteId] ['name'] . ' (' . $piwikSiteDetails [$piwikSiteId] ['main_url'] . ')';
|
109 |
+
echo '<tr class="wp-piwik-auto-option' . (! self::$settings->getGlobalOption ( 'auto_site_config' ) ? ' hidden' : '') . '"><th scope="row">' . __ ( 'Determined site', 'wp-piwik' ) . ':</th><td>' . $piwikSiteDescription . '</td></tr>';
|
110 |
+
if (is_array ( $piwikSiteDetails ))
|
111 |
+
foreach ( $piwikSiteDetails as $key => $siteData )
|
112 |
+
$siteList [$key] = $siteData ['name'] . ' (' . $siteData ['main_url'] . ')';
|
113 |
+
if (isset($siteList))
|
114 |
+
$this->showSelect ( 'site_id', __ ( 'Select site', 'wp-piwik' ), $siteList, 'TODO Choose description', '', self::$settings->getGlobalOption ( 'auto_site_config' ), 'wp-piwik-auto-option', true, false );
|
115 |
+
}
|
116 |
+
} else echo '<tr class="hidden"><td colspan="2"><input type="hidden" name="wp-piwik[auto_site_config]" value="1" /></td></tr>';
|
117 |
|
118 |
echo $submitButton;
|
119 |
|
169 |
$isNotGeneratedTracking = $isNotTracking || self::$settings->getGlobalOption ( 'track_mode' ) == 'manually';
|
170 |
$fullGeneratedTrackingGroup = 'wp-piwik-track-option wp-piwik-track-option-default wp-piwik-track-option-js wp-piwik-track-option-proxy';
|
171 |
|
172 |
+
$description = sprintf ( '%s<br /><strong>%s:</strong> %s<br /><strong>%s:</strong> %s<br /><strong>%s:</strong> %s<br /><strong>%s:</strong> %s<br /><strong>%s:</strong> %s', __ ( 'You can choose between four tracking code modes:', 'wp-piwik' ), __ ( 'Disabled', 'wp-piwik' ), __ ( 'WP-Piwik will not add the tracking code. Use this, if you want to add the tracking code to your template files or you use another plugin to add the tracking code.', 'wp-piwik' ), __ ( 'Default tracking', 'wp-piwik' ), __ ( 'TODO', 'wp-piwik' ), __ ( 'Use js/index.php', 'wp-piwik' ), __ ( 'TODO', 'wp-piwik' ), __ ( 'Use proxy script', 'wp-piwik' ), __ ( 'TODO', 'wp-piwik' ), __ ( 'Enter manually', 'wp-piwik' ), __ ( 'TODO', 'wp-piwik' ).( self::$wpPiwik->isNetworkMode() ? ' '.__ ( 'Use the placeholder {ID} to add the Piwik site ID.', 'wp-piwik' ) : '' ) );
|
173 |
$this->showSelect ( 'track_mode', __ ( 'Add tracking code', 'wp-piwik' ), array (
|
174 |
'disabled' => __ ( 'Disabled', 'wp-piwik' ),
|
175 |
'default' => __ ( 'Default tracking', 'wp-piwik' ),
|
185 |
'header' => __ ( 'Header', 'wp-piwik' )
|
186 |
), __ ( 'Choose whether the JavaScript code is added to the footer or the header.', 'wp-piwik' ), '', $isNotTracking, 'wp-piwik-track-option wp-piwik-track-option-default wp-piwik-track-option-js wp-piwik-track-option-proxy wp-piwik-track-option-manually' );
|
187 |
|
188 |
+
$this->showTextarea ( 'noscript_code', __ ( 'Noscript code', 'wp-piwik' ), 2, 'TODO noscript code desc', $isNotGeneratedTracking || self::$settings->getGlobalOption ( 'track_mode' ) == 'proxy', 'wp-piwik-track-option wp-piwik-track-option-default wp-piwik-track-option-js', true, '', true, false );
|
189 |
|
190 |
+
$this->showCheckbox ( 'track_noscript', __ ( 'Add <noscript>', 'wp-piwik' ), __ ( 'Adds the <noscript> code to your footer.', 'wp-piwik' ) . ' ' . __ ( 'Disabled in proxy mode.', 'wp-piwik' ), $isNotGeneratedTracking || self::$settings->getGlobalOption ( 'track_mode' ) == 'proxy', 'wp-piwik-track-option wp-piwik-track-option-default wp-piwik-track-option-js' );
|
191 |
|
192 |
$this->showCheckbox ( 'track_nojavascript', __ ( 'Add rec parameter to noscript code', 'wp-piwik' ), __ ( 'Enable tracking for visitors without JavaScript (not recommended).', 'wp-piwik' ) . ' ' . sprintf ( __ ( 'See %sPiwik FAQ%s.', 'wp-piwik' ), '<a href="http://piwik.org/faq/how-to/#faq_176">', '</a>' ) . ' ' . __ ( 'Disabled in proxy mode.', 'wp-piwik' ), $isNotGeneratedTracking || self::$settings->getGlobalOption ( 'track_mode' ) == 'proxy', 'wp-piwik-track-option wp-piwik-track-option-default wp-piwik-track-option-js' );
|
193 |
|
classes/WP_Piwik/Request.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
abstract class Request {
|
6 |
|
7 |
-
protected static $wpPiwik, $settings, $requests = array(), $results = array(), $piwikVersion;
|
8 |
|
9 |
public function __construct($wpPiwik, $settings) {
|
10 |
self::$wpPiwik = $wpPiwik;
|
@@ -17,11 +17,19 @@
|
|
17 |
$id = 'global.getPiwikVersion';
|
18 |
else
|
19 |
$id = 'method='.$method.self::parameterToString($parameter);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
if (!isset(self::$requests[$id]))
|
21 |
self::$requests[$id] = array('method' => $method, 'parameter' => $parameter);
|
22 |
return $id;
|
23 |
}
|
24 |
-
|
25 |
private static function parameterToString($parameter) {
|
26 |
$return = '';
|
27 |
if (is_array($parameter))
|
@@ -31,13 +39,22 @@
|
|
31 |
}
|
32 |
|
33 |
public function perform($id) {
|
|
|
|
|
|
|
|
|
34 |
self::$wpPiwik->log("Perform request: ".$id);
|
35 |
if (!isset(self::$requests[$id]))
|
36 |
return array('result' => 'error', 'message' => 'Request '.$id.' was not registered.');
|
37 |
elseif (!isset(self::$results[$id])) {
|
38 |
$this->request($id);
|
39 |
}
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
41 |
}
|
42 |
|
43 |
protected function buildURL($config, $urlDecode = false) {
|
4 |
|
5 |
abstract class Request {
|
6 |
|
7 |
+
protected static $wpPiwik, $settings, $requests = array(), $results = array(), $isCacheable = array(), $piwikVersion;
|
8 |
|
9 |
public function __construct($wpPiwik, $settings) {
|
10 |
self::$wpPiwik = $wpPiwik;
|
17 |
$id = 'global.getPiwikVersion';
|
18 |
else
|
19 |
$id = 'method='.$method.self::parameterToString($parameter);
|
20 |
+
if (
|
21 |
+
in_array( $method, array( 'API.getPiwikVersion', 'SitesManager.getJavascriptTag', 'SitesManager.getAllSites', 'SitesManager.getSitesIdFromSiteUrl', 'SitesManager.addSite', 'SitesManager.updateSite' ) ) ||
|
22 |
+
substr($parameter['date'], 0, 4) == 'last' ||
|
23 |
+
$parameter['date'] == 'today' ||
|
24 |
+
( $parameter['period'] == 'day' && $parameter['date'] == date('Ymd') ) ||
|
25 |
+
( $parameter['period'] == 'month' && $parameter['date'] == date('Ym') ) ||
|
26 |
+
( $parameter['period'] == 'week' && $parameter['date'] == date( 'Ymd', strtotime( "last Monday" ) ) )
|
27 |
+
) self::$isCacheable[$id] = false;
|
28 |
+
else self::$isCacheable[$id] = $method.'-'.$parameter['period'].'-'.$parameter['date'];
|
29 |
if (!isset(self::$requests[$id]))
|
30 |
self::$requests[$id] = array('method' => $method, 'parameter' => $parameter);
|
31 |
return $id;
|
32 |
}
|
|
|
33 |
private static function parameterToString($parameter) {
|
34 |
$return = '';
|
35 |
if (is_array($parameter))
|
39 |
}
|
40 |
|
41 |
public function perform($id) {
|
42 |
+
if ( self::$settings->getGlobalOption('cache') && false !== ( $cached = get_transient( 'wp-piwik_c_'.md5(self::$isCacheable[$id] ) ) ) ) {
|
43 |
+
self::$wpPiwik->log("Deliver cached data: ".$id);
|
44 |
+
return $cached;
|
45 |
+
}
|
46 |
self::$wpPiwik->log("Perform request: ".$id);
|
47 |
if (!isset(self::$requests[$id]))
|
48 |
return array('result' => 'error', 'message' => 'Request '.$id.' was not registered.');
|
49 |
elseif (!isset(self::$results[$id])) {
|
50 |
$this->request($id);
|
51 |
}
|
52 |
+
if ( isset ( self::$results[$id] )) {
|
53 |
+
if ( self::$settings->getGlobalOption('cache') && self::$isCacheable[$id] ) {
|
54 |
+
set_transient( 'wp-piwik_c_'.md5(self::$isCacheable[$id]) , self::$results[$id], WEEK_IN_SECONDS );
|
55 |
+
}
|
56 |
+
return self::$results[$id];
|
57 |
+
} else return false;
|
58 |
}
|
59 |
|
60 |
protected function buildURL($config, $urlDecode = false) {
|
classes/WP_Piwik/Settings.php
CHANGED
@@ -155,7 +155,7 @@ class Settings {
|
|
155 |
$objRole->remove_cap ( 'wp-piwik_' . $strCap );
|
156 |
}
|
157 |
}
|
158 |
-
$this->
|
159 |
}
|
160 |
|
161 |
/**
|
@@ -343,6 +343,8 @@ class Settings {
|
|
343 |
private function prepareTrackingCode($value, $in) {
|
344 |
if ($in ['track_mode'] == 'manually' || $in ['track_mode'] == 'disabled') {
|
345 |
$value = stripslashes ( $value );
|
|
|
|
|
346 |
return $value;
|
347 |
}
|
348 |
$result = self::$wpPiwik->updateTrackingCode ();
|
155 |
$objRole->remove_cap ( 'wp-piwik_' . $strCap );
|
156 |
}
|
157 |
}
|
158 |
+
$this->settingsChanged = false;
|
159 |
}
|
160 |
|
161 |
/**
|
343 |
private function prepareTrackingCode($value, $in) {
|
344 |
if ($in ['track_mode'] == 'manually' || $in ['track_mode'] == 'disabled') {
|
345 |
$value = stripslashes ( $value );
|
346 |
+
if ( $this->checkNetworkActivation() )
|
347 |
+
add_site_option( 'wp-piwik-manually', $value );
|
348 |
return $value;
|
349 |
}
|
350 |
$result = self::$wpPiwik->updateTrackingCode ();
|
classes/WP_Piwik/TrackingCode.php
CHANGED
@@ -11,11 +11,9 @@
|
|
11 |
|
12 |
public function __construct($wpPiwik) {
|
13 |
self::$wpPiwik = $wpPiwik;
|
14 |
-
if (!self::$wpPiwik->isCurrentTrackingCode())
|
15 |
-
self::$wpPiwik->getPiwikSiteId();
|
16 |
self::$wpPiwik->updateTrackingCode();
|
17 |
-
|
18 |
-
$this->trackingCode = self::$wpPiwik->getOption('tracking_code');
|
19 |
}
|
20 |
|
21 |
public function getTrackingCode() {
|
11 |
|
12 |
public function __construct($wpPiwik) {
|
13 |
self::$wpPiwik = $wpPiwik;
|
14 |
+
if ( !self::$wpPiwik->isCurrentTrackingCode() || !self::$wpPiwik->getOption('tracking_code') )
|
|
|
15 |
self::$wpPiwik->updateTrackingCode();
|
16 |
+
$this->trackingCode = ( self::$wpPiwik->isNetworkMode() && self::$wpPiwik->getGlobalOption('track_mode') == 'manually' ) ? get_site_option( 'wp-piwik-manually' ) : self::$wpPiwik->getOption('tracking_code');
|
|
|
17 |
}
|
18 |
|
19 |
public function getTrackingCode() {
|
css/wp-piwik.css
CHANGED
@@ -16,4 +16,8 @@ table.wp-piwik-table tbody.clickable {
|
|
16 |
|
17 |
#wp-piwik_stats_vistors_graph {
|
18 |
overflow:hidden;
|
|
|
|
|
|
|
|
|
19 |
}
|
16 |
|
17 |
#wp-piwik_stats_vistors_graph {
|
18 |
overflow:hidden;
|
19 |
+
}
|
20 |
+
|
21 |
+
.wp-piwik_dynbar canvas {
|
22 |
+
padding-top:5px !important
|
23 |
}
|
proxy/config.php
CHANGED
@@ -8,7 +8,18 @@ require_once('../classes/WP_Piwik/Logger/Dummy.php');
|
|
8 |
$logger = new WP_Piwik\Logger\Dummy(__CLASS__);
|
9 |
$settings = new WP_Piwik\Settings($logger);
|
10 |
|
11 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
if (substr($PIWIK_URL, 0, 2) == '//')
|
14 |
$PIWIK_URL = (isset($_SERVER['HTTPS'])?'https:':'http:').$PIWIK_URL;
|
@@ -16,4 +27,4 @@ if (substr($PIWIK_URL, 0, 2) == '//')
|
|
16 |
$TOKEN_AUTH = $settings->getGlobalOption('piwik_token');
|
17 |
$timeout = $settings->getGlobalOption('connection_timeout');
|
18 |
|
19 |
-
ini_set('display_errors',
|
8 |
$logger = new WP_Piwik\Logger\Dummy(__CLASS__);
|
9 |
$settings = new WP_Piwik\Settings($logger);
|
10 |
|
11 |
+
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')?'https':'http';
|
12 |
+
|
13 |
+
switch ( $settings->getGlobalOption('piwik_mode') ) {
|
14 |
+
case 'php':
|
15 |
+
$PIWIK_URL = $protocol.':'.$settings->getGlobalOption('proxy_url');
|
16 |
+
break;
|
17 |
+
case 'pro':
|
18 |
+
$PIWIK_URL = 'https://'.$settings->getGlobalOption('piwik_user').'.piwik.pro/';
|
19 |
+
break;
|
20 |
+
default:
|
21 |
+
$PIWIK_URL = $settings->getGlobalOption('piwik_url');
|
22 |
+
}
|
23 |
|
24 |
if (substr($PIWIK_URL, 0, 2) == '//')
|
25 |
$PIWIK_URL = (isset($_SERVER['HTTPS'])?'https:':'http:').$PIWIK_URL;
|
27 |
$TOKEN_AUTH = $settings->getGlobalOption('piwik_token');
|
28 |
$timeout = $settings->getGlobalOption('connection_timeout');
|
29 |
|
30 |
+
ini_set('display_errors',0);
|
uninstall.php
CHANGED
@@ -1,17 +1,102 @@
|
|
1 |
<?php
|
2 |
|
3 |
// Check if uninstall call is valid
|
4 |
-
if (!defined('WP_UNINSTALL_PLUGIN'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
global $wpdb;
|
7 |
|
8 |
if (function_exists('is_multisite') && is_multisite()) {
|
9 |
-
delete_site_option('wp-piwik_global-settings');
|
10 |
$aryBlogs = $wpdb->get_results('SELECT blog_id FROM '.$wpdb->blogs.' ORDER BY blog_id');
|
11 |
if (is_array($aryBlogs))
|
12 |
-
foreach ($aryBlogs as $aryBlog)
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
}
|
15 |
|
16 |
-
|
17 |
-
delete_option('wp-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
|
3 |
// Check if uninstall call is valid
|
4 |
+
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
|
5 |
+
exit();
|
6 |
+
|
7 |
+
$globalSettings = array(
|
8 |
+
'revision',
|
9 |
+
'last_settings_update',
|
10 |
+
'piwik_mode',
|
11 |
+
'piwik_url',
|
12 |
+
'piwik_path',
|
13 |
+
'piwik_user',
|
14 |
+
'piwik_token',
|
15 |
+
'auto_site_config',
|
16 |
+
'default_date',
|
17 |
+
'stats_seo',
|
18 |
+
'dashboard_widget',
|
19 |
+
'dashboard_chart',
|
20 |
+
'dashboard_seo',
|
21 |
+
'toolbar',
|
22 |
+
'capability_read_stats',
|
23 |
+
'perpost_stats',
|
24 |
+
'plugin_display_name',
|
25 |
+
'piwik_shortcut',
|
26 |
+
'shortcodes',
|
27 |
+
'track_mode',
|
28 |
+
'track_codeposition',
|
29 |
+
'track_noscript',
|
30 |
+
'track_nojavascript',
|
31 |
+
'proxy_url',
|
32 |
+
'track_search',
|
33 |
+
'track_404',
|
34 |
+
'add_post_annotations',
|
35 |
+
'add_customvars_box',
|
36 |
+
'add_download_extensions',
|
37 |
+
'disable_cookies',
|
38 |
+
'limit_cookies',
|
39 |
+
'limit_cookies_visitor',
|
40 |
+
'limit_cookies_session',
|
41 |
+
'track_admin',
|
42 |
+
'capability_stealth',
|
43 |
+
'track_across',
|
44 |
+
'track_across_alias',
|
45 |
+
'track_feed',
|
46 |
+
'track_feed_addcampaign',
|
47 |
+
'track_feed_campaign',
|
48 |
+
'cache',
|
49 |
+
'disable_timelimit',
|
50 |
+
'connection_timeout',
|
51 |
+
'disable_ssl_verify',
|
52 |
+
'piwik_useragent',
|
53 |
+
'piwik_useragent_string',
|
54 |
+
'track_datacfasync',
|
55 |
+
'track_cdnurl',
|
56 |
+
'track_cdnurlssl',
|
57 |
+
'force_protocol'
|
58 |
+
);
|
59 |
+
|
60 |
+
$settings = array (
|
61 |
+
'name',
|
62 |
+
'site_id',
|
63 |
+
'noscript_code',
|
64 |
+
'tracking_code',
|
65 |
+
'last_tracking_code_update',
|
66 |
+
'dashboard_revision'
|
67 |
+
);
|
68 |
|
69 |
global $wpdb;
|
70 |
|
71 |
if (function_exists('is_multisite') && is_multisite()) {
|
|
|
72 |
$aryBlogs = $wpdb->get_results('SELECT blog_id FROM '.$wpdb->blogs.' ORDER BY blog_id');
|
73 |
if (is_array($aryBlogs))
|
74 |
+
foreach ($aryBlogs as $aryBlog) {
|
75 |
+
foreach ($settings as $key) {
|
76 |
+
delete_blog_option($aryBlog->blog_id, 'wp-piwik-'.$key);
|
77 |
+
}
|
78 |
+
switch_to_blog($aryBlog->blog_id);
|
79 |
+
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key LIKE 'wp-piwik_%'");
|
80 |
+
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_wp-piwik_%'");
|
81 |
+
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_timeout_wp-piwik_%'");
|
82 |
+
restore_current_blog();
|
83 |
+
|
84 |
+
}
|
85 |
+
foreach ($globalSettings as $key)
|
86 |
+
delete_site_option('wp-piwik_global-'.$key);
|
87 |
+
delete_site_option('wp-piwik-manually');
|
88 |
+
delete_site_option('wp-piwik-notices');
|
89 |
}
|
90 |
|
91 |
+
foreach ($settings as $key)
|
92 |
+
delete_option('wp-piwik-'.$key);
|
93 |
+
|
94 |
+
foreach ($globalSettings as $key)
|
95 |
+
delete_option('wp-piwik_global-'.$key);
|
96 |
+
|
97 |
+
delete_option('wp-piwik-manually');
|
98 |
+
delete_option('wp-piwik-notices');
|
99 |
+
|
100 |
+
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key LIKE 'wp-piwik-%'");
|
101 |
+
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_wp-piwik_%'");
|
102 |
+
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_timeout_wp-piwik_%'");
|
update/100000.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Get & delete old version's options
|
3 |
+
if (self::$settings->checkNetworkActivation()) {
|
4 |
+
$oldGlobalOptions = get_site_option('wp-piwik_global-settings', array());
|
5 |
+
delete_site_option('wp-piwik_global-settings');
|
6 |
+
} else {
|
7 |
+
$oldGlobalOptions = get_option('wp-piwik_global-settings', array());
|
8 |
+
delete_option('wp-piwik_global-settings');
|
9 |
+
}
|
10 |
+
$oldOptions = get_option('wp-piwik_settings', array());
|
11 |
+
delete_option('wp-piwik_settings');
|
12 |
+
|
13 |
+
// Store old values in new settings
|
14 |
+
foreach ($oldGlobalOptions as $key => $value)
|
15 |
+
self::$settings->setGlobalOption($key, $value);
|
16 |
+
foreach ($oldOptions as $key => $value)
|
17 |
+
self::$settings->setOption($key, $value);
|
18 |
+
self::$settings->save();
|
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 header.
|
8 |
|
9 |
-
Version: 0.10.0.
|
10 |
Author: André Bräkling
|
11 |
Author URI: http://www.braekling.de
|
12 |
Text Domain: wp-piwik
|
6 |
|
7 |
Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress header.
|
8 |
|
9 |
+
Version: 0.10.0.2
|
10 |
Author: André Bräkling
|
11 |
Author URI: http://www.braekling.de
|
12 |
Text Domain: wp-piwik
|