buffer
1 year ago
script_loader_tag
1 year ago
traits
1 year ago
Account_Service.php
1 year ago
Consent_API_Helper.php
1 year ago
Cookie_Consent.php
1 year ago
Cookie_Consent_Interface.php
1 year ago
Cookiebot_Activated.php
1 year ago
Cookiebot_Admin_Links.php
1 year ago
Cookiebot_Automatic_Updates.php
1 year ago
Cookiebot_Deactivated.php
1 year ago
Cookiebot_Frame.php
1 year ago
Cookiebot_Javascript_Helper.php
1 year ago
Cookiebot_Review.php
1 year ago
Cookiebot_WP.php
1 year 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
1 year ago
Cookiebot_Activated.php
93 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_addons_default_settings(); |
| 21 | |
| 22 | // Set a transient to indicate plugin was just activated |
| 23 | set_transient( 'cookiebot_just_activated', true, 30 ); |
| 24 | } |
| 25 | |
| 26 | public function __construct() { |
| 27 | // Add script to track activation on next page load |
| 28 | add_action( |
| 29 | 'admin_head', |
| 30 | function() { |
| 31 | if ( get_transient( 'cookiebot_just_activated' ) ) { |
| 32 | delete_transient( 'cookiebot_just_activated' ); |
| 33 | ?> |
| 34 | <script> |
| 35 | // Load Amplitude SDK |
| 36 | (function() { |
| 37 | const script = document.createElement('script'); |
| 38 | script.src = 'https://cdn.eu.amplitude.com/script/3573fa11b8c5b4bcf577ec4c8e9d5cb6.js'; |
| 39 | script.async = true; |
| 40 | script.onload = function() { |
| 41 | const amplitude = window.amplitude; |
| 42 | amplitude.init('3573fa11b8c5b4bcf577ec4c8e9d5cb6', { |
| 43 | serverZone: 'EU', |
| 44 | fetchRemoteConfig: true, |
| 45 | defaultTracking: false |
| 46 | }); |
| 47 | |
| 48 | // Track activation event |
| 49 | amplitude.track('Plugin Activated', { |
| 50 | source: 'Plugin Directory', |
| 51 | wordpress_role: '<?php echo esc_js( current_user_can( 'manage_options' ) ? 'Admin' : 'Editor' ); ?>', |
| 52 | plugin_version: '<?php echo esc_js( Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION ); ?>', |
| 53 | wp_version: '<?php echo esc_js( get_bloginfo( 'version' ) ); ?>', |
| 54 | }); |
| 55 | }; |
| 56 | document.head.appendChild(script); |
| 57 | })(); |
| 58 | </script> |
| 59 | <?php |
| 60 | } |
| 61 | } |
| 62 | ); |
| 63 | } |
| 64 | |
| 65 | private function delay_notice_recommandation_when_it_is_first_activation() { |
| 66 | // Delay display of recommendation notice in 3 days if not activated earlier |
| 67 | if ( get_option( Cookiebot_Recommendation_Notice::COOKIEBOT_NOTICE_OPTION_KEY, false ) === false ) { |
| 68 | // Not set yet - this must be first activation - delay in 3 days |
| 69 | update_option( Cookiebot_Recommendation_Notice::COOKIEBOT_NOTICE_OPTION_KEY, strtotime( '+3 days' ) ); |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | private function set_to_mode_auto_when_no_cookiebot_id_is_set() { |
| 74 | if ( Cookiebot_WP::get_cbid() === '' ) { |
| 75 | if ( is_multisite() ) { |
| 76 | update_site_option( 'cookiebot-cookie-blocking-mode', 'auto' ); |
| 77 | update_site_option( 'cookiebot-nooutput-admin', true ); |
| 78 | } else { |
| 79 | update_option( 'cookiebot-cookie-blocking-mode', 'auto' ); |
| 80 | update_option( 'cookiebot-nooutput-admin', true ); |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * @throws Exception |
| 87 | */ |
| 88 | private function set_addons_default_settings() { |
| 89 | $cookiebot_addons = Cookiebot_Addons::instance(); |
| 90 | $cookiebot_addons->cookiebot_activated(); |
| 91 | } |
| 92 | } |
| 93 |