PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 1.3.1
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v1.3.1
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / classes / WpMatomo / OptOut.php
matomo / classes / WpMatomo Last commit date
Admin 5 years ago Commands 6 years ago Db 6 years ago Ecommerce 6 years ago Report 6 years ago Site 5 years ago TrackingCode 5 years ago User 5 years ago views 6 years ago API.php 5 years ago Access.php 6 years ago AjaxTracker.php 5 years ago Annotations.php 6 years ago Bootstrap.php 6 years ago Capabilities.php 6 years ago Compatibility.php 6 years ago Email.php 5 years ago Installer.php 6 years ago Logger.php 5 years ago OptOut.php 5 years ago Paths.php 6 years ago PrivacyBadge.php 6 years ago Referral.php 6 years ago Roles.php 6 years ago ScheduledTasks.php 6 years ago Settings.php 5 years ago Site.php 6 years ago TrackingCode.php 5 years ago Uninstaller.php 6 years ago Updater.php 6 years ago User.php 6 years ago
OptOut.php
94 lines
1 <?php
2 /**
3 * Matomo - free/libre analytics platform
4 *
5 * @link https://matomo.org
6 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
7 * @package matomo
8 */
9
10 namespace WpMatomo;
11
12 use Piwik\Piwik;
13 use Piwik\Plugins\PrivacyManager\DoNotTrackHeaderChecker;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit; // if accessed directly
17 }
18
19 class OptOut {
20
21 private $language = null;
22
23 public function register_hooks() {
24 add_shortcode( 'matomo_opt_out', array( $this, 'show_opt_out' ) );
25 add_action( 'wp_enqueue_scripts', array( $this, 'load_scripts' ) );
26 }
27
28 public function load_scripts() {
29 if (!is_admin()) {
30 wp_register_script( 'matomo_opt_out_js', plugins_url( 'assets/js/optout.js', MATOMO_ANALYTICS_FILE ), array(), null, true );
31 }
32 }
33
34 private function translate($id)
35 {
36 return esc_html(Piwik::translate($id, array(), $this->language));
37 }
38
39 public function show_opt_out( $atts ) {
40 $a = shortcode_atts(
41 array(
42 'language' => null,
43 ),
44 $atts
45 );
46 if (!empty($a['language']) && strlen($a['language']) < 6) {
47 $this->language = $a['language'];
48 }
49
50 try {
51 Bootstrap::do_bootstrap();
52 } catch (\Throwable $e ) {
53 $logger = new Logger();
54 $logger->log_exception('optout', $e);
55 return '<p>An error occurred. Please check Matomo system report in WP-Admin.</p>';
56 }
57
58 $dnt_checker = new DoNotTrackHeaderChecker();
59 $dnt_enabled = $dnt_checker->isDoNotTrackFound();
60
61 if (!empty($dnt_enabled)) {
62 return '<p>'. $this->translate('CoreAdminHome_OptOutDntFound').'</p>';
63 }
64
65 wp_enqueue_script( 'matomo_opt_out_js' );
66
67 $track_visits = empty($_COOKIE['mtm_consent_removed']);
68
69 $style_tracking_enabled = '';
70 $style_tracking_disabled = '';
71 $checkbox_attr = '';
72 if ($track_visits) {
73 $style_tracking_enabled = 'style="display:none;"';
74 $checkbox_attr = 'checked="checked"';
75 } else {
76 $style_tracking_disabled = 'style="display:none;"';
77 }
78
79 $content = '<p id="matomo_opted_out_intro" ' . $style_tracking_enabled . '>' . $this->translate('CoreAdminHome_OptOutComplete') . ' ' . $this->translate('CoreAdminHome_OptOutCompleteBis') . '</p>';
80 $content .= '<p id="matomo_opted_in_intro" ' .$style_tracking_disabled . '>' . $this->translate('CoreAdminHome_YouMayOptOut2') . ' ' . $this->translate('CoreAdminHome_YouMayOptOut3') . '</p>';
81
82 $content .= '<form>
83 <input type="checkbox" id="matomo_optout_checkbox" '.$checkbox_attr.'/>
84 <label for="matomo_optout_checkbox"><strong>
85 <span id="matomo_opted_in_label" '.$style_tracking_disabled.'>'.$this->translate('CoreAdminHome_YouAreNotOptedOut') .' ' . $this->translate('CoreAdminHome_UncheckToOptOut') . '</span>
86 <span id="matomo_opted_out_label" '.$style_tracking_enabled.'>'.$this->translate('CoreAdminHome_YouAreOptedOut') .' ' . $this->translate('CoreAdminHome_CheckToOptIn') . '</span>
87 </strong></label></form>';
88 $content .= '<noscript><p><strong style="color: #ff0000;">This opt out feature requires JavaScript.</strong></p></noscript>';
89 $content .= '<p id="matomo_outout_err_cookies" style="display: none;"><strong>' . $this->translate('CoreAdminHome_OptOutErrorNoCookies') . '</strong></p>';
90 return $content;
91 }
92
93 }
94