Skip to content

Commit

Permalink
* Bugfix: Opt-out shortcode will also work in "pro" and "php" mode
Browse files Browse the repository at this point in the history
* Bugfix: http/pro - after configuration the settings page had to be reloaded once to start working


git-svn-id: https://plugins.svn.wordpress.org/wp-piwik/trunk@1161497 b8457f37-d9ea-0310-8a92-e5e31aec5664
  • Loading branch information
Braekling authored and Braekling committed May 15, 2015
1 parent d1870c9 commit e5514d8
Show file tree
Hide file tree
Showing 8 changed files with 1,165 additions and 371 deletions.
13 changes: 8 additions & 5 deletions classes/WP_Piwik.php
Original file line number Diff line number Diff line change
Expand Up @@ -557,16 +557,17 @@ public function addPiwikAnnotation($postID) {
* @return boolean settings update applied
*/
private function applySettings() {
$_POST ['wp-piwik']['last_settings_update'] = time();
$_POST ['wp-piwik']['revision'] = self::$revisionId;
self::$settings->applyChanges ( $_POST ['wp-piwik'] );
echo 'Settings gespeichert';
if (self::$settings->getGlobalOption ( 'auto_site_config' ) && self::isConfigured ()) {
if ($this->isPHPMode () && ! defined ( 'PIWIK_INCLUDE_PATH' ))
self::definePiwikConstants ();
$siteId = $this->requestPiwikSiteId ();
$siteId = $this->getPiwikSiteId ();
$trackingCode = $this->updateTrackingCode ( $siteId );
self::$settings->getOption ( 'site_id', $siteId );
self::$settings->setOption ( 'site_id', $siteId );
}
self::$settings->setGlobalOption ( 'revision', self::$revisionId );
self::$settings->setGlobalOption ( 'last_settings_update', time () );
return true;
}

Expand Down Expand Up @@ -919,6 +920,8 @@ private static function showErrorMessage($message) {
* @return mixed request result
*/
public function request($id, $debug = false) {
if ( self::$settings->getGlobalOption ( 'piwik_mode' ) == 'disabled' )
return 'n/a';
if (! isset ( self::$request ))
self::$request = (self::$settings->getGlobalOption ( 'piwik_mode' ) == 'http' || self::$settings->getGlobalOption ( 'piwik_mode' ) == 'pro' ? new WP_Piwik\Request\Rest ( $this, self::$settings ) : new WP_Piwik\Request\Php ( $this, self::$settings ));
if ($debug)
Expand Down Expand Up @@ -992,7 +995,7 @@ private function requestPiwikSiteId($blogId = null) {
$this->log ( 'Tried to identify current site, result: ' . serialize ( $result ) );
if (empty ( $result ) || ! isset ( $result [0] ))
$result = $this->addPiwikSite ( $blogId );
else
elseif ( $result != 'n/a' )
$result = $result [0] ['idsite'];
} else
$result = null;
Expand Down
2 changes: 2 additions & 0 deletions classes/WP_Piwik/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public static function register($method, $parameter) {
$id = 'method='.$method.self::parameterToString($parameter);
if (
in_array( $method, array( 'API.getPiwikVersion', 'SitesManager.getJavascriptTag', 'SitesManager.getSitesWithAtLeastViewAccess', 'SitesManager.getSitesIdFromSiteUrl', 'SitesManager.addSite', 'SitesManager.updateSite', 'SitesManager.getSitesWithAtLeastViewAccess' ) ) ||
!isset( $parameter['date'] ) ||
!isset( $parameter['period'] ) ||
substr($parameter['date'], 0, 4) == 'last' ||
$parameter['date'] == 'today' ||
( $parameter['period'] == 'day' && $parameter['date'] == date('Ymd') ) ||
Expand Down
13 changes: 12 additions & 1 deletion classes/WP_Piwik/Widget/OptOut.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@ protected function configure($prefix = '', $params = array()) {
}

public function show() {
$this->out ( '<iframe frameborder="no" width="'.(isset($this->parameter['width'])?$this->parameter['width']:'').'" height="'.(isset($this->parameter['height'])?$this->parameter['height']:'').'" src="'.self::$settings->getGlobalOption('piwik_url').'index.php?module=CoreAdminHome&action=optOut&language='.(isset($this->parameter['language'])?$this->parameter['language']:'en').'"></iframe>' );
$protocol = (isset ( $_SERVER ['HTTPS'] ) && $_SERVER ['HTTPS'] != 'off') ? 'https' : 'http';
switch (self::$settings->getGlobalOption ( 'piwik_mode' )) {
case 'php' :
$PIWIK_URL = $protocol . ':' . self::$settings->getGlobalOption ( 'proxy_url' );
break;
case 'pro' :
$PIWIK_URL = 'https://' . self::$settings->getGlobalOption ( 'piwik_user' ) . '.piwik.pro/';
break;
default :
$PIWIK_URL = self::$settings->getGlobalOption ( 'piwik_url' );
}
$this->out ( '<iframe frameborder="no" width="'.(isset($this->parameter['width'])?$this->parameter['width']:'').'" height="'.(isset($this->parameter['height'])?$this->parameter['height']:'').'" src="'.$PIWIK_URL.'index.php?module=CoreAdminHome&action=optOut&language='.(isset($this->parameter['language'])?$this->parameter['language']:'en').'"></iframe>' );
}

}
Binary file modified languages/wp-piwik-de_DE.mo
Binary file not shown.
247 changes: 63 additions & 184 deletions languages/wp-piwik-de_DE.po

Large diffs are not rendered by default.

Binary file modified languages/wp-piwik-fr_FR.mo
Binary file not shown.
Loading

0 comments on commit e5514d8

Please sign in to comment.