diff --git a/wp-content/plugins/wp-piwik/classes/WP_Piwik.php b/wp-content/plugins/wp-piwik/classes/WP_Piwik.php index ee370040..1eddaa9c 100644 --- a/wp-content/plugins/wp-piwik/classes/WP_Piwik.php +++ b/wp-content/plugins/wp-piwik/classes/WP_Piwik.php @@ -10,7 +10,7 @@ use WP_Piwik\Widget\Post; */ class WP_Piwik { - private static $revisionId = 2022020701, $version = '1.0.27', $blog_id, $pluginBasename = NULL, $logger, $settings, $request, $optionsPageId; + private static $revisionId = 2023052101, $version = '1.0.28', $blog_id, $pluginBasename = NULL, $logger, $settings, $request, $optionsPageId; /** * Constructor class to configure and register all WP-Piwik components @@ -1152,7 +1152,12 @@ class WP_Piwik { 'urls' => $isCurrent ? get_bloginfo ( 'url' ) : get_blog_details ( $blogId )->siteurl, 'siteName' => urlencode( $isCurrent ? get_bloginfo ( 'name' ) : get_blog_details ( $blogId )->blogname ) ) ); - $result = (int) $this->request ( $id ); + $result = $this->request ( $id ); + if ( is_array( $result ) && isset( $result['value'] ) ) { + $result = (int) $result['value']; + } else { + $result = (int) $result; + } self::$logger->log ( 'Create Matomo ID: WordPress site ' . ($isCurrent ? get_bloginfo ( 'url' ) : get_blog_details ( $blogId )->siteurl) . ' = Matomo ID ' . $result ); if (empty ( $result )) return null; @@ -1319,7 +1324,7 @@ class WP_Piwik { * Get option value, choose method depending on network mode * * @param string $option option key - * @return string option value + * @return string|array option value */ private function getWordPressOption($option, $default = null) { return ($this->isNetworkMode () ? get_site_option ( $option, $default ) : get_option ( $option, $default )); diff --git a/wp-content/plugins/wp-piwik/classes/WP_Piwik/Admin/Settings.php b/wp-content/plugins/wp-piwik/classes/WP_Piwik/Admin/Settings.php index 3cb19b92..d06f5a1a 100644 --- a/wp-content/plugins/wp-piwik/classes/WP_Piwik/Admin/Settings.php +++ b/wp-content/plugins/wp-piwik/classes/WP_Piwik/Admin/Settings.php @@ -260,7 +260,13 @@ class Settings extends \WP_Piwik\Admin { $this->showInput ( 'add_download_extensions', __ ( 'Add new file types for download tracking', 'wp-piwik' ), __ ( 'Add file extensions for download tracking, divided by a vertical bar (|).', 'wp-piwik' ) . ' ' . sprintf ( __ ( 'See %sMatomo documentation%s.', 'wp-piwik' ), '', '' ), $isNotGeneratedTracking, $fullGeneratedTrackingGroup ); - $this->showCheckbox ( 'disable_cookies', __ ( 'Disable cookies', 'wp-piwik' ), __ ( 'Disable all tracking cookies for a visitor.', 'wp-piwik' ), $isNotGeneratedTracking, $fullGeneratedTrackingGroup ); + $this->showSelect ( 'require_consent', __ ( 'Tracking or cookie consent', 'wp-piwik' ), array ( + 'disabled' => __ ( 'Disabled', 'wp-piwik' ), + 'consent' => __ ( 'Require consent', 'wp-piwik' ), + 'cookieconsent' => __ ( 'Require cookie consent', 'wp-piwik' ) + ), __ ( 'Enable support for consent managers.' ) . ' ' . sprintf ( __ ( 'See %sMatomo documentation%s.', 'wp-piwik' ), '', '' ), '', $isNotGeneratedTracking, $fullGeneratedTrackingGroup ); + + $this->showCheckbox ( 'disable_cookies', __ ( 'Disable cookies', 'wp-piwik' ), __ ( 'Disable all tracking cookies for a visitor.', 'wp-piwik' ), $isNotGeneratedTracking, $fullGeneratedTrackingGroup ); $this->showCheckbox ( 'limit_cookies', __ ( 'Limit cookie lifetime', 'wp-piwik' ), __ ( 'You can limit the cookie lifetime to avoid tracking your users over a longer period as necessary.', 'wp-piwik' ), $isNotGeneratedTracking, $fullGeneratedTrackingGroup, true, 'jQuery(\'tr.wp-piwik-cookielifetime-option\').toggleClass(\'wp-piwik-hidden\');' ); @@ -526,9 +532,6 @@ class Settings extends \WP_Piwik\Admin {

-
- -
Paypal
@@ -545,9 +548,6 @@ class Settings extends \WP_Piwik\Admin {
-
- WordPress.org Plugin Directory. -
'.__('Currently shown stats:').' '.get_bloginfo('name').'.'.' Show site overview.

'; - echo ''."\n"; } echo '
'; wp_nonce_field('wp-piwik_stats-general'); diff --git a/wp-content/plugins/wp-piwik/classes/WP_Piwik/Settings.php b/wp-content/plugins/wp-piwik/classes/WP_Piwik/Settings.php index 1b509013..f88613df 100644 --- a/wp-content/plugins/wp-piwik/classes/WP_Piwik/Settings.php +++ b/wp-content/plugins/wp-piwik/classes/WP_Piwik/Settings.php @@ -75,6 +75,7 @@ class Settings { 'set_download_extensions' => '', 'set_link_classes' => '', 'set_download_classes' => '', + 'require_consent' => 'disabled', 'disable_cookies' => false, 'limit_cookies' => false, 'limit_cookies_visitor' => 34186669, // Piwik default 13 months @@ -147,6 +148,7 @@ class Settings { return; } self::$wpPiwik->log ( 'Save settings' ); + $this->globalSettings['plugin_display_name'] = htmlspecialchars($this->globalSettings['plugin_display_name'], ENT_QUOTES, 'utf-8'); foreach ( $this->globalSettings as $key => $value ) { if ( $this->checkNetworkActivation() ) update_site_option ( 'wp-piwik_global-' . $key, $value ); diff --git a/wp-content/plugins/wp-piwik/classes/WP_Piwik/TrackingCode.php b/wp-content/plugins/wp-piwik/classes/WP_Piwik/TrackingCode.php index 8a739c51..1abd3e46 100644 --- a/wp-content/plugins/wp-piwik/classes/WP_Piwik/TrackingCode.php +++ b/wp-content/plugins/wp-piwik/classes/WP_Piwik/TrackingCode.php @@ -82,7 +82,7 @@ class TrackingCode { $code = str_replace ( "_paq.push(['trackPageView']);", "_paq.push(['setDownloadClasses', '" . ($settings->getGlobalOption ( 'set_download_classes' )) . "']);\n_paq.push(['trackPageView']);", $code ); if ($settings->getGlobalOption ( 'set_link_classes' )) $code = str_replace ( "_paq.push(['trackPageView']);", "_paq.push(['setLinkClasses', '" . ($settings->getGlobalOption ( 'set_link_classes' )) . "']);\n_paq.push(['trackPageView']);", $code ); - if ($settings->getGlobalOption ( 'limit_cookies' )) + if ($settings->getGlobalOption ( 'limit_cookies' )) $code = str_replace ( "_paq.push(['trackPageView']);", "_paq.push(['setVisitorCookieTimeout', '" . $settings->getGlobalOption ( 'limit_cookies_visitor' ) . "']);\n_paq.push(['setSessionCookieTimeout', '" . $settings->getGlobalOption ( 'limit_cookies_session' ) . "']);\n_paq.push(['setReferralCookieTimeout', '" . $settings->getGlobalOption ( 'limit_cookies_referral' ) . "']);\n_paq.push(['trackPageView']);", $code ); if ($settings->getGlobalOption ( 'force_protocol' ) != 'disabled') $code = str_replace ( '"//', '"' . $settings->getGlobalOption ( 'force_protocol' ) . '://', $code ); @@ -92,6 +92,11 @@ class TrackingCode { $code = str_replace ( "_paq.push(['trackPageView']);", "_paq.push(['trackPageView']);\n_paq.push(['trackVisibleContentImpressions']);", $code ); if ((int) $settings->getGlobalOption ( 'track_heartbeat' ) > 0) $code = str_replace ( "_paq.push(['trackPageView']);", "_paq.push(['trackPageView']);\n_paq.push(['enableHeartBeatTimer', ".(int) $settings->getGlobalOption ( 'track_heartbeat' )."]);", $code ); + if ($settings->getGlobalOption ( 'require_consent' ) == 'consent') { + $code = str_replace ( "_paq.push(['trackPageView']);", "_paq.push(['requireConsent']);\n_paq.push(['trackPageView']);", $code ); + } elseif ($settings->getGlobalOption ( 'require_consent' ) == 'cookieconsent') { + $code = str_replace ( "_paq.push(['trackPageView']);", "_paq.push(['requireCookieConsent']);\n_paq.push(['trackPageView']);", $code ); + } $noScript = array (); preg_match ( '/