PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 4.6.3
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v4.6.3
4.7.2 4.7.1 trunk 2.3.0 2.4.0 2.4.1 2.4.2 2.5.0 3.0.0 3.0.1 3.1.0 3.10.0 3.10.1 3.11.1 3.11.2 3.11.3 3.2.0 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.1 3.6.2 3.6.5 3.6.6 3.7.0 3.7.1 3.8.0 3.9.0 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.2.0 4.2.1 4.2.10 4.2.11 4.2.12 4.2.13 4.2.14 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.3.10 4.3.11 4.3.12 4.3.2 4.3.3 4.3.4 4.3.5 4.3.6 4.3.7 4.3.7.1 4.3.8 4.3.9 4.3.9.1 4.4.0 4.4.1 4.4.2 4.5.0 4.5.1 4.5.10 4.5.11 4.5.2 4.5.3 4.5.4 4.5.5 4.5.6 4.5.7 4.5.8 4.5.9 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.6.7 4.7.0
cookiebot / src / lib / Cookiebot_Activated.php
cookiebot / src / lib Last commit date
buffer 1 year ago script_loader_tag 5 months ago traits 1 year ago Account_Service.php 10 months ago Consent_API_Helper.php 1 year ago Cookie_Consent.php 1 year ago Cookie_Consent_Interface.php 1 year ago Cookiebot_Activated.php 5 months ago Cookiebot_Admin_Links.php 1 year ago Cookiebot_Automatic_Updates.php 1 year ago Cookiebot_Deactivated.php 5 months ago Cookiebot_Frame.php 1 year ago Cookiebot_Javascript_Helper.php 7 months ago Cookiebot_Review.php 6 months ago Cookiebot_WP.php 5 months ago Dependency_Container.php 1 year ago Settings_Page_Tab.php 1 year ago Settings_Service.php 1 year ago Settings_Service_Interface.php 1 year ago Supported_Languages.php 1 year ago Supported_Regions.php 1 year ago WP_Rocket_Helper.php 1 year ago Widgets.php 1 year ago global-deprecations.php 1 year ago helper.php 6 months ago
Cookiebot_Activated.php
111 lines
1 <?php
2
3 namespace cybot\cookiebot\lib;
4
5 use cybot\cookiebot\addons\Cookiebot_Addons;
6 use cybot\cookiebot\admin_notices\Cookiebot_Recommendation_Notice;
7 use Exception;
8
9 class Cookiebot_Activated {
10
11
12 /**
13 * @throws Exception
14 */
15 public function run() {
16 $this->delay_notice_recommandation_when_it_is_first_activation();
17
18 $this->set_to_mode_auto_when_no_cookiebot_id_is_set();
19
20 $this->set_banner_enabled_by_default();
21
22 $this->set_addons_default_settings();
23
24 // Set a transient to indicate plugin was just activated
25 set_transient( 'cookiebot_just_activated', true, 30 );
26 }
27
28 public function __construct() {
29 // Add script to track activation on next page load
30 add_action(
31 'admin_head',
32 function() {
33 if ( get_transient( 'cookiebot_just_activated' ) ) {
34 delete_transient( 'cookiebot_just_activated' );
35 ?>
36 <script>
37 // Load Amplitude SDK
38 (function() {
39 const script = document.createElement('script');
40 script.src = 'https://cdn.eu.amplitude.com/script/3573fa11b8c5b4bcf577ec4c8e9d5cb6.js';
41 script.async = true;
42 script.onload = function() {
43 const amplitude = window.amplitude;
44 amplitude.init('3573fa11b8c5b4bcf577ec4c8e9d5cb6', {
45 serverZone: 'EU',
46 fetchRemoteConfig: true,
47 defaultTracking: false
48 });
49
50 // Track activation event
51 amplitude.track('Plugin Activated', {
52 source: 'Plugin Directory',
53 wordpress_role: '<?php echo esc_js( current_user_can( 'manage_options' ) ? 'Admin' : 'Editor' ); ?>',
54 plugin_version: '<?php echo esc_js( Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION ); ?>',
55 wp_version: '<?php echo esc_js( get_bloginfo( 'version' ) ); ?>',
56 });
57 };
58 document.head.appendChild(script);
59 })();
60 </script>
61 <?php
62 }
63 }
64 );
65 }
66
67 private function delay_notice_recommandation_when_it_is_first_activation() {
68 // Delay display of recommendation notice in 3 days if not activated earlier
69 if ( get_option( Cookiebot_Recommendation_Notice::COOKIEBOT_NOTICE_OPTION_KEY, false ) === false ) {
70 // Not set yet - this must be first activation - delay in 3 days
71 update_option( Cookiebot_Recommendation_Notice::COOKIEBOT_NOTICE_OPTION_KEY, strtotime( '+3 days' ) );
72 }
73 }
74
75 private function set_to_mode_auto_when_no_cookiebot_id_is_set() {
76 if ( Cookiebot_WP::get_cbid() === '' ) {
77 if ( is_multisite() ) {
78 update_site_option( 'cookiebot-cookie-blocking-mode', 'auto' );
79 update_site_option( 'cookiebot-nooutput-admin', true );
80 } else {
81 update_option( 'cookiebot-cookie-blocking-mode', 'auto' );
82 update_option( 'cookiebot-nooutput-admin', true );
83 }
84 }
85 }
86
87 private function set_banner_enabled_by_default() {
88 $enabled = get_option( 'cookiebot-banner-enabled', 'default' );
89 $cbid = Cookiebot_WP::get_cbid();
90
91 // Set to enabled if it's a fresh install (default)
92 if ( $enabled === 'default' ) {
93 $enabled = '1';
94 update_option( 'cookiebot-banner-enabled', $enabled );
95 }
96
97 // If banner is disabled but CBID is configured, it was disabled by hosting or plugin update. Re-enable it.
98 if ( $enabled === '0' && ! empty( $cbid ) ) {
99 update_option( 'cookiebot-banner-enabled', '1' );
100 }
101 }
102
103 /**
104 * @throws Exception
105 */
106 private function set_addons_default_settings() {
107 $cookiebot_addons = Cookiebot_Addons::instance();
108 $cookiebot_addons->cookiebot_activated();
109 }
110 }
111