updated plugin `Connect Matomo` version 1.0.30

This commit is contained in:
KawaiiPunk 2023-10-22 22:21:31 +00:00 committed by Gitium
parent 9e3fa792d7
commit 959829cf69
24 changed files with 3619 additions and 3462 deletions

View File

@ -0,0 +1,2 @@
.idea/

View File

@ -1,4 +1,4 @@
# WP-Matomo (former WP-Piwik)
# Connect Matomo (former WP-Matomo, WP-Piwik)
This [WordPress](https://wordpress.org) plugin adds a [Matomo](http://matomo.org) stats site to your blog's dashboard. It's also able to add the Matomo tracking code to your blog.
@ -6,4 +6,4 @@ This [WordPress](https://wordpress.org) plugin adds a [Matomo](http://matomo.org
To use this plugin you will need your own Matomo instance. If you do not already have a Matomo setup, you have two simple options: use either [self-hosted](http://matomo.org/) or [cloud-hosted](http://matomo.org/hosting/).
This repository was created to develop and maintain WP-Matomo (WP-Piwik). Please see the WordPress plugin directory if you like to use this plugin: https://wordpress.org/plugins/wp-piwik/
This repository was created to develop and maintain Connect Matomo (WP-Matomo, WP-Piwik). Please see the WordPress plugin directory if you like to use this plugin: https://wordpress.org/plugins/wp-piwik/

View File

@ -3,16 +3,17 @@
use WP_Piwik\Widget\Post;
/**
* The main WP-Matomo class configures, registers and manages the plugin
* The main Connect Matomo class configures, registers and manages the plugin
*
* @author Andr&eacute; Br&auml;kling <webmaster@braekling.de>
* @package WP_Piwik
*/
class WP_Piwik {
private static $revisionId = 2023052101, $version = '1.0.28', $blog_id, $pluginBasename = NULL, $logger, $settings, $request, $optionsPageId;
private static $revisionId = 2023092201, $version = '1.0.30', $blog_id, $pluginBasename = NULL, $logger, $settings, $request, $optionsPageId;
public $statsPageId;
/**
/**
* Constructor class to configure and register all WP-Piwik components
*/
public function __construct() {
@ -196,7 +197,7 @@ class WP_Piwik {
* Install WP-Piwik for the first time
*/
private function installPlugin($isUpdate = false) {
self::$logger->log ( 'Running WP-Matomo installation' );
self::$logger->log ( 'Running Connect Matomo installation' );
if (! $isUpdate)
$this->addNotice ( 'install', sprintf ( __ ( '%s %s installed.', 'wp-piwik' ), self::$settings->getNotEmptyGlobalOption ( 'plugin_display_name' ), self::$version ), __ ( 'Next you should connect to Matomo', 'wp-piwik' ) );
self::$settings->setGlobalOption ( 'revision', self::$revisionId );
@ -207,7 +208,7 @@ class WP_Piwik {
* Uninstall WP-Piwik
*/
public function uninstallPlugin() {
self::$logger->log ( 'Running WP-Matomo uninstallation' );
self::$logger->log ( 'Running Connect Matomo uninstallation' );
if (! defined ( 'WP_UNINSTALL_PLUGIN' ))
exit ();
self::deleteWordPressOption ( 'wp-piwik-notices' );
@ -218,7 +219,7 @@ class WP_Piwik {
* Update WP-Piwik
*/
private function updatePlugin() {
self::$logger->log ( 'Upgrade WP-Matomo to ' . self::$version );
self::$logger->log ( 'Upgrade Connect Matomo to ' . self::$version );
$patches = glob ( dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'update' . DIRECTORY_SEPARATOR . '*.php' );
$isPatched = false;
if (is_array ( $patches )) {
@ -657,13 +658,6 @@ class WP_Piwik {
*/
private function applySettings() {
self::$settings->applyChanges ( $_POST ['wp-piwik'] );
if (self::$settings->getGlobalOption ( 'auto_site_config' ) && self::isConfigured ()) {
if ($this->isPHPMode () && ! defined ( 'PIWIK_INCLUDE_PATH' ))
self::definePiwikConstants ();
$siteId = $this->getPiwikSiteId ();
$trackingCode = $this->updateTrackingCode ( $siteId );
self::$settings->setOption ( 'site_id', $siteId );
}
self::$settings->setGlobalOption ( 'revision', self::$revisionId );
self::$settings->setGlobalOption ( 'last_settings_update', time () );
return true;
@ -1084,12 +1078,12 @@ class WP_Piwik {
* which blog's Piwik site ID to get, default is the current blog
* @return mixed Piwik site ID or n/a
*/
public function getPiwikSiteId($blogId = null) {
public function getPiwikSiteId($blogId = null, $forceFetch = false) {
if (! $blogId && $this->isNetworkMode ())
$blogId = get_current_blog_id ();
$result = self::$settings->getOption ( 'site_id', $blogId );
$result = self::$settings->getOption ( 'site_id' );
self::$logger->log ( 'Database result: ' . $result );
return (! empty ( $result ) ? $result : $this->requestPiwikSiteId ( $blogId ));
return (! empty ( $result ) && ! $forceFetch ? $result : $this->requestPiwikSiteId ( $blogId ));
}
/**

View File

@ -26,7 +26,16 @@ class Settings extends \WP_Piwik\Admin {
} elseif (self::$wpPiwik->isConfigSubmitted()) {
$this->showBox ( 'updated', 'yes', __ ( 'Changes saved.' ) );
self::$wpPiwik->resetRequest();
self::$wpPiwik->updateTrackingCode();
if (self::$settings->getGlobalOption('piwik_mode') == 'php') {
self::$wpPiwik->definePiwikConstants();
}
if (self::$settings->getGlobalOption ( 'auto_site_config' ) && self::$wpPiwik->isConfigured ()) {
$siteId = self::$wpPiwik->getPiwikSiteId (null, true);
self::$wpPiwik->updateTrackingCode ( $siteId );
self::$settings->setOption ( 'site_id', $siteId );
} else {
self::$wpPiwik->updateTrackingCode();
}
}
global $wp_roles;
?>
@ -103,7 +112,7 @@ class Settings extends \WP_Piwik\Admin {
echo '</h2></td></tr></tbody></table><table id="connect" class="wp-piwik_menu-tab"><tbody>';
if (! self::$wpPiwik->isConfigured ())
$this->showBox ( 'updated', 'info', sprintf ( '%s <a href="%s">%s</a> %s <a href="%s">%s</a>.', __ ( 'WP-Matomo is a WordPress plugin to show a selection of Matomo stats in your WordPress admin dashboard and to add and configure your Matomo tracking code. To use this you will need your own Matomo instance. If you do not already have a Matomo setup, you have two simple options: use either', 'wp-piwik' ), 'http://piwik.org/', __ ( 'a self-hosted Matomo', 'wp-piwik' ), __ ( 'or', 'wp-piwik' ), 'https://www.innocraft.cloud/?pk_campaign=WP-Matomo', __ ( 'a cloud-hosted Matomo by InnoCraft', 'wp-piwik' ) ) );
$this->showBox ( 'updated', 'info', __ ( 'Before you can complete the setup, make sure you have a Matomo instance running. If you don\'t have one, you can', 'wp-piwik' ) .' <a href="https://matomo.org/start-free-analytics-trial/" target="_blank">' . __ ('create a free account', 'wp-piwik' ) .'</a> ' . __ ('or ', 'wp-piwik' ) .'<a href="https://wordpress.org/plugins/matomo/" target="_blank">' . __ ('install the "Matomo for WordPress" plugin', 'wp-piwik' ) .'</a> ' . __ ('instead.', 'wp-piwik' ) );
if (! function_exists ( 'curl_init' ) && ! ini_get ( 'allow_url_fopen' ))
$this->showBox ( 'error', 'no', __ ( 'Neither cURL nor fopen are available. So WP-Matomo can not use the HTTP API and not connect to InnoCraft Cloud.' ) . ' ' . sprintf ( '<a href="%s">%s.</a>', 'https://wordpress.org/plugins/wp-piwik/faq/', __ ( 'More information', 'wp-piwik' ) ) );
@ -115,7 +124,7 @@ class Settings extends \WP_Piwik\Admin {
'php' => __ ( 'Self-hosted (PHP API)', 'wp-piwik' ),
'cloud-matomo' => __('Cloud-hosted (Innocraft Cloud, *.matomo.cloud)', 'wp-piwik'),
'cloud' => __ ( 'Cloud-hosted (InnoCraft Cloud, *.innocraft.cloud)', 'wp-piwik' )
), $description, 'jQuery(\'tr.wp-piwik-mode-option\').addClass(\'hidden\'); jQuery(\'#wp-piwik-mode-option-\' + jQuery(\'#piwik_mode\').val()).removeClass(\'hidden\');', false, '', self::$wpPiwik->isConfigured () );
), $description, 'jQuery(\'tr.wp-piwik-mode-option\').addClass(\'hidden\'); jQuery(\'.wp-piwik-mode-option-\' + jQuery(\'#piwik_mode\').val()).removeClass(\'hidden\');', false, '', self::$wpPiwik->isConfigured () );
$this->showInput ( 'piwik_url', __ ( 'Matomo URL', 'wp-piwik' ), __( 'Enter your Matomo URL. This is the same URL you use to access your Matomo instance, e.g. http://www.example.com/matomo/.', 'wp-piwik' ), self::$settings->getGlobalOption ( 'piwik_mode' ) != 'http', 'wp-piwik-mode-option', 'http', self::$wpPiwik->isConfigured (), true );
$this->showInput ( 'piwik_path', __ ( 'Matomo path', 'wp-piwik' ), __( 'Enter the file path to your Matomo instance, e.g. /var/www/matomo/.', 'wp-piwik' ), self::$settings->getGlobalOption ( 'piwik_mode' ) != 'php', 'wp-piwik-mode-option', 'php', self::$wpPiwik->isConfigured (), true );
@ -126,7 +135,15 @@ class Settings extends \WP_Piwik\Admin {
// Site configuration
$piwikSiteId = self::$wpPiwik->isConfigured () ? self::$wpPiwik->getPiwikSiteId () : false;
if (! self::$wpPiwik->isNetworkMode() ) {
$this->showCheckbox ( 'auto_site_config', __ ( 'Auto config', 'wp-piwik' ), __ ( 'Check this to automatically choose your blog from your Matomo sites by URL. If your blog is not added to Matomo yet, WP-Matomo will add a new site.', 'wp-piwik' ), false, 'jQuery(\'tr.wp-piwik-auto-option\').toggle(\'hidden\');' . ($piwikSiteId ? 'jQuery(\'#site_id\').val(' . $piwikSiteId . ');' : '') );
$this->showCheckbox (
'auto_site_config',
__ ( 'Auto config', 'wp-piwik' ),
__ ( 'Check this to automatically choose your blog from your Matomo sites by URL. If your blog is not added to Matomo yet, WP-Matomo will add a new site.', 'wp-piwik' ),
false,
'',
'',
'jQuery(\'tr.wp-piwik-auto-option\').toggle(\'hidden\');' . ($piwikSiteId ? 'jQuery(\'#site_id\').val(' . $piwikSiteId . ');' : '')
);
if (self::$wpPiwik->isConfigured ()) {
$piwikSiteList = self::$wpPiwik->getPiwikSiteDetails ();
if (isset($piwikSiteList['result']) && $piwikSiteList['result'] == 'error') {
@ -393,18 +410,6 @@ class Settings extends \WP_Piwik\Admin {
<?php
}
/**
* Show an option's description
*
* @param string $id option id
* @param string $description option description
* @param boolean $hideDescription set to false to show description initially (default: true)
* @return string full description HTML
*/
private function getDescription($id, $description, $hideDescription = true) {
return sprintf ( '<span class="dashicons dashicons-editor-help" onclick="jQuery(\'#%s-desc\').toggleClass(\'hidden\');"></span> <p class="description' . ($hideDescription ? ' hidden' : '') . '" id="%1$s-desc">%s</p>', $id, $description );
}
/**
* Show a checkbox option
*
@ -417,8 +422,44 @@ class Settings extends \WP_Piwik\Admin {
* @param string $onChange javascript for onchange event (default: empty)
*/
private function showCheckbox($id, $name, $description, $isHidden = false, $groupName = '', $hideDescription = true, $onChange = '') {
printf ( '<tr class="' . $groupName . ($isHidden ? ' hidden' : '') . '"><th scope="row"><label for="%2$s">%s</label>:</th><td><input type="checkbox" value="1"' . (self::$settings->getGlobalOption ( $id ) ? ' checked="checked"' : '') . ' onchange="jQuery(\'#%s\').val(this.checked?1:0);%s" /><input id="%2$s" type="hidden" name="wp-piwik[%2$s]" value="' . ( int ) self::$settings->getGlobalOption ( $id ) . '" /> %s</td></tr>', $name, $id, $onChange, $this->getDescription ( $id, $description, $hideDescription ) );
}
$this->showInputWrapper($id, $name, $description, $isHidden, $groupName, $hideDescription, function() use ($id, $onChange) {
?>
<input type="checkbox" value="1" <?=(self::$settings->getGlobalOption ( $id ) ? ' checked="checked"' : '')?> onchange="jQuery('#<?=$id ?>').val(this.checked?1:0); <?=$onChange ?>" />
<input id="<?=$id?>" type="hidden" name="wp-piwik[<?=$id?>]" value="<?=( int ) self::$settings->getGlobalOption ( $id )?>" />
<?php
});
}
/**
* Display the input with the extra elements around it
*
* @param string $id option id
* @param string $name descriptive option name
* @param string $description option description
* @param boolean $isHidden set to true to initially hide the option (default: false)
* @param string $groupName define a class name to access a group of option rows by javascript (default: empty)
* @param boolean $hideDescription $hideDescription set to false to show description initially (default: true)
* @param callable $input function to inject the input into the wrapper
* @param string $rowName define a class name to access the specific option row by javascript (default: empty)
*
* @return void
*/
private function showInputWrapper($id, $name, $description, $isHidden, $groupName, $hideDescription, $input, $rowName = false) {
?>
<tr class="<?=$groupName?> <?=$groupName?>-<?=$rowName?> <?=$isHidden ? 'hidden': ''?>">
<td colspan="2" class="wp-piwik-input-row">
<label for="<?=$id?>"><?= __( $name, 'wp-piwik' ) ?>:</label>
<?php $input()?>
<?php if (!empty($description)) : ?>
<span class="dashicons dashicons-editor-help" onclick="jQuery('#<?=$id?>-desc').toggleClass('hidden');"></span>
<p class="description <?=$hideDescription ? 'hidden' : '' ?>" id="<?=$id?>-desc">
<?= __( $description, 'wp-piwik' ) ?>
</p>
<?php endif; ?>
</td>
</tr>
<?php
}
/**
* Show a textarea option
@ -435,8 +476,13 @@ class Settings extends \WP_Piwik\Admin {
* @param boolean $global set to false if the textarea shows a site-specific option (default: true)
*/
private function showTextarea($id, $name, $rows, $description, $isHidden, $groupName, $hideDescription = true, $onChange = '', $isReadonly = false, $global = true) {
printf (
'<tr class="' . $groupName . ($isHidden ? ' hidden' : '') . '"><th scope="row"><label for="%2$s">%s</label>:</th><td><textarea cols="80" rows="' . $rows . '" id="%s" name="wp-piwik[%2$s]" onchange="%s"' . ($isReadonly ? ' readonly="readonly"' : '') . '>%s</textarea> %s</td></tr>', $name, $id, $onChange, ($global ? self::$settings->getGlobalOption ( $id ) : self::$settings->getOption ( $id )), $this->getDescription ( $id, $description, $hideDescription ) );
$this->showInputWrapper($id, $name, $description, $isHidden, $groupName, $hideDescription, function() use ($id, $onChange, $rows, $isReadonly, $global) {
?>
<textarea cols="80" rows="<?=$rows?>" id="<?=$id?>" name="wp-piwik[<?=$id?>]" onchange="<?=$onChange?>" <?=($isReadonly ? ' readonly="readonly"' : '')?>>
<?=($global ? self::$settings->getGlobalOption ( $id ) : self::$settings->getOption ( $id ))?>
</textarea>
<?php
});
}
/**
@ -461,7 +507,11 @@ class Settings extends \WP_Piwik\Admin {
* @param boolean $wide Create a wide box (default: false)
*/
private function showInput($id, $name, $description, $isHidden = false, $groupName = '', $rowName = false, $hideDescription = true, $wide = false) {
printf ( '<tr class="%s%s"%s><th scope="row"><label for="%5$s">%s:</label></th><td><input '.($wide?'class="wp-piwik-wide" ':'').'name="wp-piwik[%s]" id="%5$s" value="%s" /> %s</td></tr>', $isHidden ? 'hidden ' : '', $groupName ? $groupName : '', $rowName ? ' id="' . $groupName . '-' . $rowName . '"' : '', $name, $id, htmlentities(self::$settings->getGlobalOption( $id ), ENT_QUOTES, 'UTF-8', false), !empty($description) ? $this->getDescription ( $id, $description, $hideDescription ) : '' );
$this->showInputWrapper($id, $name, $description, $isHidden, $groupName, $hideDescription, function() use ($id) {
?>
<input name="wp-piwik[<?=$id?>]" id="<?=$id?>" value="<?=htmlentities(self::$settings->getGlobalOption( $id ), ENT_QUOTES, 'UTF-8', false)?>" >
<?php
}, $rowName);
}
/**
@ -478,12 +528,17 @@ class Settings extends \WP_Piwik\Admin {
* @param boolean $global set to false if the textarea shows a site-specific option (default: true)
*/
private function showSelect($id, $name, $options = array(), $description = '', $onChange = '', $isHidden = false, $groupName = '', $hideDescription = true, $global = true) {
$optionList = '';
$default = $global ? self::$settings->getGlobalOption ( $id ) : self::$settings->getOption ( $id );
if (is_array ( $options ))
foreach ( $options as $key => $value )
$optionList .= sprintf ( '<option value="%s"' . ($key == $default ? ' selected="selected"' : '') . '>%s</option>', $key, $value );
printf ( '<tr class="' . $groupName . ($isHidden ? ' hidden' : '') . '"><th scope="row"><label for="%2$s">%s:</label></th><td><select name="wp-piwik[%s]" id="%2$s" onchange="%s">%s</select> %s</td></tr>', $name, $id, $onChange, $optionList, $this->getDescription ( $id, $description, $hideDescription ) );
$this->showInputWrapper($id, $name, $description, $isHidden, $groupName, $hideDescription, function() use ($id, $onChange, $options, $default) {
?>
<select name="wp-piwik[<?=$id?>]" id="<?=$id?>" onchange="<?=$onChange?>">
<?php foreach ($options as $key => $value) : ?>
<option value="<?=$key?>" <?=($key == $default ? ' selected="selected"' : '')?> ><?=$value?></option>
<?php endforeach; ?>
</select>
<?php
});
}
/**
@ -585,8 +640,38 @@ class Settings extends \WP_Piwik\Admin {
* Show support information
*/
public function showSupport() {
?><ul>
<li><?php _e('The best place to get help:', 'wp-piwik'); ?> <a href="https://wordpress.org/support/plugin/wp-piwik" target="_BLANK"><?php _e('WP-Matomo support forum','wp-piwik'); ?></a></li>
?>
<h2><?php _e('How can we help?', 'wp-piwik'); ?></h2>
<form method="get" action="https://matomo.org" target="_blank" rel="noreferrer noopener">
<input type="text" name="s" style="width:300px;"><input type="submit" class="button-secondary" value="<?php _e('Search on', 'wp-piwik'); ?> matomo.org">
</form>
<ul class="wp-piwik-help-list">
<li><a target="_blank" rel="noreferrer noopener"
href="https://matomo.org/docs/"><?php _e('User guides', 'wp-piwik'); ?></a>
- <?php _e('Learn how to configure Matomo and how to effectively analyse your data', 'wp-piwik'); ?></li>
<li><a target="_blank" rel="noreferrer noopener"
href="https://matomo.org/faq/wordpress/"><?php _e('Matomo for WordPress FAQs', 'wp-piwik'); ?></a>
- <?php _e('Get answers to frequently asked questions', 'wp-piwik'); ?></li>
<li><a target="_blank" rel="noreferrer noopener"
href="https://matomo.org/faq/"><?php _e('General FAQs', 'wp-piwik'); ?></a>
- <?php _e('Get answers to frequently asked questions', 'wp-piwik'); ?></li>
<li><a target="_blank" rel="noreferrer noopener"
href="https://forum.matomo.org/"><?php _e('Forums', 'wp-piwik'); ?></a>
- <?php _e('Get help directly from the community of Matomo users', 'wp-piwik'); ?></li>
<li><a target="_blank" rel="noreferrer noopener"
href="https://glossary.matomo.org"><?php _e('Glossary', 'wp-piwik'); ?></a>
- <?php _e('Learn about commonly used terms to make the most of Matomo Analytics', 'wp-piwik'); ?></li>
<li><a target="_blank" rel="noreferrer noopener"
href="https://matomo.org/support-plans/"><?php _e('Support Plans', 'wp-piwik'); ?></a>
- <?php _e('Let our experienced team assist you online on how to best utilise Matomo', 'wp-piwik'); ?></li>
<li><a href="https://local.wordpressplugin.matomo.org/wp-admin/admin.php?page=matomo-systemreport&#038;tab=troubleshooting"><?php _e('Troubleshooting', 'wp-piwik'); ?></a>
- <?php _e('Click here if you are having Trouble with Matomo', 'wp-piwik'); ?></li>
</ul>
<ul>
<li><?php _e('Contact Matomo support here:', 'wp-piwik'); ?> <a href="https://matomo.org/contact/" target="_BLANK"><?php _e('https://matomo.org/contact/','wp-piwik'); ?></a></li>
<li><?php _e('Find support for this plugin here:', 'wp-piwik'); ?> <a href="https://wordpress.org/support/plugin/wp-piwik" target="_BLANK"><?php _e('WP-Matomo support forum','wp-piwik'); ?></a></li>
<li><?php _e('Please don\'t forget to vote the compatibility at the','wp-piwik'); ?> <a href="http://wordpress.org/extend/plugins/wp-piwik/" target="_BLANK">WordPress.org Plugin Directory</a>.</li>
</ul>
<h3><?php _e('Debugging', 'wp-piwik'); ?></h3>

View File

@ -52,4 +52,13 @@
self::$debug[$id] = array ( $params.'&token_auth=...' );
return $result;
}
public function reset() {
if (class_exists('\Piwik\Application\Environment') && !self::$piwikEnvironment) {
self::$piwikEnvironment->destroy();
}
if (class_exists('Piwik\FrontController'))
\Piwik\FrontController::unsetInstance();
parent::reset();
}
}

View File

@ -57,7 +57,7 @@ class Settings {
'administrator' => true
),
'perpost_stats' => "disabled",
'plugin_display_name' => 'WP-Matomo',
'plugin_display_name' => 'Connect Matomo',
'piwik_shortcut' => false,
'shortcodes' => false,
// User settings: Tracking configuration

View File

@ -1,31 +1,38 @@
<?php
namespace WP_Piwik\Widget;
namespace WP_Piwik\Widget;
class OptOut extends \WP_Piwik\Widget {
class OptOut extends \WP_Piwik\Widget
{
public $className = __CLASS__;
public $className = __CLASS__;
protected function configure($prefix = '', $params = array()) {
$this->parameter = $params;
}
protected function configure($prefix = '', $params = array())
{
$this->parameter = $params;
}
public function show() {
$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 'cloud' :
$PIWIK_URL = 'https://' . self::$settings->getGlobalOption ( 'piwik_user' ) . '.innocraft.cloud/';
break;
case 'cloud-matomo':
$PIWIK_URL = 'https://' . self::$settings->getGlobalOption ( 'matomo_user' ) . '.matomo.cloud/';
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&'.(isset($this->parameter['idsite'])?'idsite='.$this->parameter['idsite'].'&':'').'language='.(isset($this->parameter['language'])?$this->parameter['language']:'en').'"></iframe>' );
}
public function show()
{
$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 'cloud' :
$PIWIK_URL = 'https://' . self::$settings->getGlobalOption('piwik_user') . '.innocraft.cloud/';
break;
case 'cloud-matomo':
$PIWIK_URL = 'https://' . self::$settings->getGlobalOption('matomo_user') . '.matomo.cloud/';
break;
default :
$PIWIK_URL = self::$settings->getGlobalOption('piwik_url');
}
$width = (isset($this->parameter['width']) ? esc_attr($this->parameter['width']) : '');
$height = (isset($this->parameter['height']) ? esc_attr($this->parameter['height']) : '');
$idSite = (isset($this->parameter['idsite']) ? 'idsite=' . (int)$this->parameter['idsite'] . '&' : '');
$language = (isset($this->parameter['language']) ? esc_attr($this->parameter['language']) : 'en');
$this->out('<iframe frameborder="no" width="' . $width . '" height="' . $height . '" src="' . $PIWIK_URL . 'index.php?module=CoreAdminHome&action=optOut&' . $idSite . 'language=' . $language . '"></iframe>');
}
}
}

View File

@ -2,6 +2,23 @@
display: none;
}
.wp-piwik-help-list {
list-style-type: disc;
margin-left: 20px;
}
.wp-piwik-input-row label {
display: block;
}
.wp-piwik-input-row input[type=text], .wp-piwik-input-row input:not([type]) {
width: 70%;
}
.wp-piwik-input-row p {
width: 70%;
}
table.wp-piwik-table th.right, td.right {
text-align: right;
}

View File

@ -80,6 +80,8 @@ msgid ""
"You are running a WordPress %s blog network (WPMU). WP-Matomo will handle "
"your sites as different websites."
msgstr ""
"You are running a WordPress %s blog network (WPMU). Connect Matomo will handle "
"your sites as different websites."
#: classes/WP_Piwik/Admin/Settings.php:62
#, php-format
@ -87,6 +89,8 @@ msgid ""
"WP-Matomo %s was not able to connect to Matomo using your configuration. Check "
"the &raquo;Connect to Matomo&laquo; section below."
msgstr ""
"Connect Matomo %s was not able to connect to Matomo using your configuration. Check "
"the &raquo;Connect to Matomo&laquo; section below."
#: classes/WP_Piwik/Admin/Settings.php:64
#, php-format
@ -94,6 +98,8 @@ msgid ""
"WP-Matomo %s was not able to connect to Matomo using your configuration. "
"During connection the following error occured: <br /><code>%s</code>"
msgstr ""
"Connect Matomo %s was not able to connect to Matomo using your configuration. "
"During connection the following error occured: <br /><code>%s</code>"
#: classes/WP_Piwik/Admin/Settings.php:67
#, php-format
@ -101,6 +107,8 @@ msgid ""
"WP-Matomo %s has to be connected to Matomo first. Check the &raquo;Connect to "
"Matomo&laquo; section below."
msgstr ""
"Connect Matomo %s has to be connected to Matomo first. Check the &raquo;Connect to "
"Matomo&laquo; section below."
#: classes/WP_Piwik/Admin/Settings.php:71
msgid "Connect to Matomo"
@ -129,6 +137,10 @@ msgid ""
"To use this you will need your own Matomo instance. If you do not already "
"have a Matomo setup, you have two simple options: use either"
msgstr ""
"Connect Matomo is a WordPress plugin to show a selection of Matomo stats in your "
"WordPress admin dashboard and to add and configure your Matomo tracking code. "
"To use this you will need your own Matomo instance. If you do not already "
"have a Matomo setup, you have two simple options: use either"
#: classes/WP_Piwik/Admin/Settings.php:106
msgid "a self-hosted Matomo"
@ -147,6 +159,8 @@ msgid ""
"Neither cURL nor fopen are available. So WP-Matomo can not use the HTTP API "
"and not connect to InnoCraft Cloud."
msgstr ""
"Neither cURL nor fopen are available. So Connect Matomo can not use the HTTP API "
"and not connect to InnoCraft Cloud."
#: classes/WP_Piwik/Admin/Settings.php:109
#: classes/WP_Piwik/Template/MetaBoxCustomVars.php:30
@ -167,6 +181,8 @@ msgid ""
"This is the default option for a self-hosted Matomo and should work for most "
"configurations. WP-Matomo will connect to Matomo using http(s)."
msgstr ""
"This is the default option for a self-hosted Matomo and should work for most "
"configurations. Connect Matomo will connect to Matomo using http(s)."
#: classes/WP_Piwik/Admin/Settings.php:111
#: classes/WP_Piwik/Admin/Settings.php:115
@ -250,13 +266,16 @@ msgid ""
"Check this to automatically choose your blog from your Matomo sites by URL. "
"If your blog is not added to Matomo yet, WP-Matomo will add a new site."
msgstr ""
"Check this to automatically choose your blog from your Matomo sites by URL. "
"If your blog is not added to Matomo yet, Connect Matomo will add a new site."
#: classes/WP_Piwik/Admin/Settings.php:131
#, php-format
msgid ""
"WP-Matomo %s was not able to get sites with at least view access: <br /><code>"
"%s</code>"
msgstr ""
msgstr "Connect Matomo %s was not able to get sites with at least view access: <br /><code>"
"%s</code>"
#: classes/WP_Piwik/Admin/Settings.php:141
msgid "Determined site"
@ -400,7 +419,7 @@ msgstr ""
#: classes/WP_Piwik/Admin/Settings.php:195
msgid "WP-Matomo display name"
msgstr ""
msgstr "Connect Matomo display name"
#: classes/WP_Piwik/Admin/Settings.php:195
msgid "Plugin name shown in WordPress."
@ -424,6 +443,9 @@ msgid ""
"tracking code to your template files or you use another plugin to add the "
"tracking code."
msgstr ""
"Connect Matomo 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."
#: classes/WP_Piwik/Admin/Settings.php:208
#: classes/WP_Piwik/Admin/Settings.php:211
@ -778,6 +800,8 @@ msgid ""
"Choose whether WP-Matomo should use cURL or fopen to connect to Matomo in HTTP "
"or Cloud mode."
msgstr ""
"Choose whether Connect Matomo should use cURL or fopen to connect to Matomo in HTTP "
"or Cloud mode."
#: classes/WP_Piwik/Admin/Settings.php:305
msgid "HTTP method"
@ -795,7 +819,7 @@ msgstr ""
#: classes/WP_Piwik/Admin/Settings.php:308
msgid "Choose whether WP-Matomo should use POST or GET in HTTP or Cloud mode."
msgstr ""
msgstr "Choose whether Connect Matomo should use POST or GET in HTTP or Cloud mode."
#: classes/WP_Piwik/Admin/Settings.php:310
msgid "Disable time limit"
@ -906,11 +930,11 @@ msgstr ""
#: classes/WP_Piwik/Admin/Settings.php:338
msgid "Show always if WP-Matomo is updated"
msgstr ""
msgstr "Show always if Connect Matomo is updated"
#: classes/WP_Piwik/Admin/Settings.php:339
msgid "Show only if WP-Matomo is updated and settings were changed"
msgstr ""
msgstr "Show only if Connect Matomo is updated and settings were changed"
#: classes/WP_Piwik/Admin/Settings.php:341
msgid "Choose if you want to get an update notice if WP-Matomo is updated."
@ -1004,6 +1028,9 @@ msgid ""
"commendation, feature requests and bug reports! You help me to make WP-Matomo "
"much better."
msgstr ""
"Thank you very much, all users who send me mails containing criticism, "
"commendation, feature requests and bug reports! You help me to make Connect Matomo "
"much better."
#: classes/WP_Piwik/Admin/Settings.php:565
msgid ""

View File

@ -1,9 +1,9 @@
=== WP-Matomo Integration (WP-Piwik) ===
=== Connect Matomo (WP-Matomo, WP-Piwik) ===
Contributors: Braekling
Requires at least: 5.0
Tested up to: 6.2
Stable tag: 1.0.28
Tested up to: 6.3
Stable tag: 1.0.30
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6046779
Tags: matomo, tracking, statistics, stats, analytics
@ -70,9 +70,11 @@ You can get a more detailed description here: https://matomo.org/blog/2015/05/wo
First, please make sure your configuration is valid, e.g., if you are using the right Matomo URL (see description above). Then, go to the "Support" tab and run the test script. This test script will try to get some information from Matomo and shows the full response. Usually, the response output gives a clear hint what's wrong:
The response output contains...
* **bool(false)** and **HTTP/1.1 403 Forbidden**: WP-Matomo is not allowed to connect to Matomo. Please check your Matomo server's configuration. Maybe you are using a password protection via .htaccess or you are blocking requests from localhost/127.0.0.1. If you arent sure about this, please contact your web hoster for support.
* **bool(false)** and **HTTP/1.1 404 Not Found**: The Matomo URL is wrong. Try to copy & paste the URL you use to access Matomo itself via browser.
* **bool(false)** and no further HTTP response code: The Matomo server does not respond. Very often, this is caused by firewall or mod_security settings. Check your server logfiles to get further information. If you arent sure about this, please contact your web hoster for support.
- **bool(false)** and **HTTP/1.1 403 Forbidden**: WP-Matomo is not allowed to connect to Matomo. Please check your Matomo server's configuration. Maybe you are using a password protection via .htaccess or you are blocking requests from localhost/127.0.0.1. If you arent sure about this, please contact your web hoster for support.
- **bool(false)** and **HTTP/1.1 404 Not Found**: The Matomo URL is wrong. Try to copy & paste the URL you use to access Matomo itself via browser.
- **bool(false)** and no further HTTP response code: The Matomo server does not respond. Very often, this is caused by firewall or mod_security settings. Check your server logfiles to get further information. If you arent sure about this, please contact your web hoster for support.
If this does not help as well, feel free to open a [topic in the support forum](https://wordpress.org/support/plugin/wp-piwik/). Please share all available information including the test script result, if possible.
= PHP Compatibility Checker reports PHP7 compatbility issues with WP-Matomo. =
@ -143,6 +145,16 @@ Add WP-Matomo to your /wp-content/plugins folder and enable it as [Network Plugi
== Changelog ==
= 1.0.30 =
* Fix settings behavior
* Fix auto configuration in PHP API mode
* Fix Opt-Out shortcode language attribute
* Remove deprecated dynamic property (PHP 8.2)
= 1.0.29 =
* Rename plugin to "Connect Matomo"
* Fix a XSS vulnerability
= 1.0.28 =
* Encode plugin display name
* Option to set requireConsent or requireCookieConsent

View File

@ -0,0 +1,4 @@
<?php
self::$settings->setGlobalOption('plugin_display_name', "Connect Matomo");
self::$settings->save ();

View File

@ -1,12 +1,12 @@
<?php
/*
Plugin Name: WP-Matomo Integration
Plugin Name: Connect Matomo
Plugin URI: http://wordpress.org/extend/plugins/wp-piwik/
Description: Adds Matomo statistics to your WordPress dashboard and is also able to add the Matomo Tracking Code to your blog.
Version: 1.0.28
Version: 1.0.30
Author: Andr&eacute; Br&auml;kling
Author URI: https://www.braekling.de
Text Domain: wp-piwik