Cookiebot | GDPR Compliant Cookie Consent and Notice - Version 3.5.0

Version Description

Download this release

Release Info

Developer cookiebot
Plugin Icon 128x128 Cookiebot | GDPR Compliant Cookie Consent and Notice
Version 3.5.0
Comparing to
See all releases

Code changes from version 3.4.2 to 3.5.0

addons/cookiebot-addons-init.php CHANGED
@@ -23,7 +23,7 @@ define( 'COOKIEBOT_ADDONS_BASE_NAME', dirname( plugin_basename( __FILE__ ) ) );
23
/**
24
* Same version as the CookiebotWP
25
*/
26
- define( 'COOKIEBOT_ADDONS_VERSION', '3.4.2' );
27
28
/**
29
* Register autoloader to load files/classes dynamically
23
/**
24
* Same version as the CookiebotWP
25
*/
26
+ define( 'COOKIEBOT_ADDONS_VERSION', '3.5.0' );
27
28
/**
29
* Register autoloader to load files/classes dynamically
cookiebot.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Cookiebot | GDPR/CCPA Compliant Cookie Consent and Control
4
Plugin URI: https://cookiebot.com/
5
Description: Cookiebot is a cloud-driven solution that automatically controls cookies and trackers, enabling full GDPR/ePrivacy and CCPA compliance for websites.
6
Author: Cybot A/S
7
- Version: 3.4.2
8
Author URI: http://cookiebot.com
9
Text Domain: cookiebot
10
Domain Path: /langs
@@ -21,7 +21,7 @@ final class Cookiebot_WP {
21
* @var string
22
* @since 1.0.0
23
*/
24
- public $version = '3.4.2';
25
26
/**
27
* @var Cookiebot_WP The single instance of the class
@@ -57,9 +57,9 @@ final class Cookiebot_WP {
57
add_action('plugins_loaded', array($this, 'cookiebot_init'), 5);
58
register_activation_hook( __FILE__ , array($this, 'activation'));
59
register_deactivation_hook( __FILE__, 'cookiebot_addons_plugin_deactivated' );
60
-
61
$this->cookiebot_fix_plugin_conflicts();
62
-
63
}
64
65
/**
@@ -161,6 +161,10 @@ final class Cookiebot_WP {
161
}
162
}
163
164
165
// Set up localisation
166
load_plugin_textdomain('cookiebot', false, dirname( plugin_basename( __FILE__ ) ) . '/langs/' );
@@ -178,7 +182,7 @@ final class Cookiebot_WP {
178
if(is_admin() || (defined('DOING_CRON') && DOING_CRON)) {
179
add_filter('auto_update_plugin', array($this,'automatic_updates'), 10, 2);
180
}
181
-
182
//Loading widgets
183
include_once( dirname( __FILE__ ) . '/widgets/cookiebot-declaration-widget.php' );
184
add_action( 'widgets_init', array($this,'register_widgets') );
@@ -194,10 +198,10 @@ final class Cookiebot_WP {
194
function load_textdomain() {
195
load_plugin_textdomain( 'cookiebot', false, basename( dirname( __FILE__ ) ) . '/langs' );
196
}
197
-
198
/**
199
* Cookiebot_WP Register widgets
200
- *
201
* @version 2.5.0
202
* @since 2.5.0
203
*/
@@ -296,6 +300,7 @@ final class Cookiebot_WP {
296
register_setting('cookiebot', 'cookiebot-script-tag-uc-attribute');
297
register_setting('cookiebot', 'cookiebot-script-tag-cd-attribute');
298
register_setting('cookiebot', 'cookiebot-cookie-blocking-mode');
299
register_setting('cookiebot-iab', 'cookiebot-iab');
300
}
301
@@ -400,6 +405,8 @@ final class Cookiebot_WP {
400
* @since 1.0.0
401
*/
402
function settings_page() {
403
/* Check if multisite */
404
if($is_ms = is_multisite()) {
405
//Receive settings from multisite - this might change the way we render the form
@@ -415,7 +422,7 @@ final class Cookiebot_WP {
415
<img src="<?php echo plugins_url( 'cookiebot-logo.png', __FILE__ ); ?>" style="float:right;margin-left:1em;">
416
</a>
417
<p>
418
- <?php _e('Cookiebot enables your website to comply with current legislation in the EU on the use of cookies for user tracking and profiling. The EU ePrivacy Directive requires prior, informed consent of your site users, while the <a href="https://www.cookiebot.com/en/gdpr" target="_blank">General Data Protection Regulation (GDPR)</a> requires you to document each consent. At the same time you must be able to account for what user data you share with embedded third-party services on your website and where in the world the user data is sent.','cookiebot'); ?>
419
</p>
420
<form method="post" action="options.php">
421
<?php settings_fields( 'cookiebot' ); ?>
@@ -427,7 +434,7 @@ final class Cookiebot_WP {
427
<input type="text" name="cookiebot-cbid" value="<?php echo esc_attr( get_option('cookiebot-cbid') ); ?>"<?php echo ($is_ms) ? ' placeholder="'.$network_cbid.'"' : ''; ?> style="width:300px" />
428
<p class="description">
429
<?php _e('Need an ID?','cookiebot'); ?>
430
- <a href="https://www.cookiebot.com/en/signup" target="_blank"><?php _e('Sign up for free on cookiebot.com','cookiebot'); ?></a>
431
</p>
432
</td>
433
</tr>
@@ -551,29 +558,29 @@ final class Cookiebot_WP {
551
</table>
552
<script>
553
jQuery(document).ready(function($) {
554
- $('#advanced_settings_link').on('click',function(e) {
555
e.preventDefault();
556
- $('#advanced_settings').slideToggle();
557
- $('#advanced_settings_link').toggleClass('active');
558
});
559
});
560
</script>
561
<style type="text/css">
562
- #advanced_settings_link {
563
cursor:pointer;
564
}
565
- #advanced_settings_link::after {
566
content: "\f140";
567
font: normal 24px/1 dashicons;
568
position: relative;
569
top: 5px;
570
}
571
- #advanced_settings_link.active::after {
572
content: "\f142";
573
}
574
</style>
575
- <h3 id="advanced_settings_link"><?php _e('Advanced settings', 'cookiebot'); ?></h3>
576
- <div id="advanced_settings" style="display:none;">
577
<table class="form-table">
578
<tr valign="top" id="cookiebot-setting-async">
579
<th scope="row">
@@ -704,6 +711,96 @@ final class Cookiebot_WP {
704
</tr>
705
</table>
706
</div>
707
<?php submit_button(); ?>
708
</form>
709
</div>
@@ -724,7 +821,7 @@ final class Cookiebot_WP {
724
<img src="<?php echo plugins_url( 'cookiebot-logo.png', __FILE__ ); ?>" style="float:right;margin-left:1em;">
725
</a>
726
<p>
727
- <?php _e('Cookiebot enables your website to comply with current legislation in the EU on the use of cookies for user tracking and profiling. The EU ePrivacy Directive requires prior, informed consent of your site users, while the <a href="https://www.cookiebot.com/en/gdpr" target="_blank">General Data Protection Regulation (GDPR)</a> requires you to document each consent. At the same time you must be able to account for what user data you share with embedded third-party services on your website and where in the world the user data is sent.','cookiebot'); ?>
728
</p>
729
<p>
730
<b><big style="color:red;"><?php _e('The settings below is network wide settings. See notes below each field.'); ?></big></b>
@@ -740,7 +837,7 @@ final class Cookiebot_WP {
740
<b><?php _e('If added this will be the default Cookiebot ID for all subsites. Subsites are able to override the Cookiebot ID.'); ?></b>
741
<br />
742
<?php _e('Need an ID?','cookiebot'); ?>
743
- <a href="https://www.cookiebot.com/en/signup" target="_blank"><?php _e('Sign up for free on cookiebot.com','cookiebot'); ?></a>
744
</p>
745
</td>
746
</tr>
@@ -929,7 +1026,7 @@ final class Cookiebot_WP {
929
<h2><?php _e('How to find my Cookiebot ID','cookiebot'); ?></h2>
930
<p>
931
<ol>
932
- <li><?php _e('Log in to your <a href="https://www.cookiebot.com/en/account" target="_blank">Cookiebot account</a>.','cookiebot'); ?></li>
933
<li><?php _e('Go to <b>Manage</b> > <b>Settings</b> and add setup your Cookiebot','cookiebot'); ?></li>
934
<li><?php _e('Go to the <b>"Your scripts"</b> tab','cookiebot'); ?></li>
935
<li><?php _e('Copy the value inside the data-cid parameter - eg.: abcdef12-3456-7890-abcd-ef1234567890','cookiebot'); ?></li>
@@ -1037,7 +1134,7 @@ final class Cookiebot_WP {
1037
else {
1038
$tagAttr = get_site_option('cookiebot-script-tag-uc-attribute');
1039
}
1040
-
1041
if($this->get_cookie_blocking_mode() == 'auto') {
1042
$tagAttr = 'data-blockingmode="auto"';
1043
}
@@ -1125,7 +1222,7 @@ final class Cookiebot_WP {
1125
}
1126
return $cbid;
1127
}
1128
-
1129
/**
1130
* Cookiebot_WP Get cookie blocking mode (auto | manual)
1131
*
@@ -1146,7 +1243,7 @@ final class Cookiebot_WP {
1146
1147
/**
1148
* Cookiebot_WP Check if Cookiebot is active in admin
1149
- *
1150
* @version 3.1.0
1151
* @since 3.1.0
1152
*/
@@ -1201,6 +1298,90 @@ final class Cookiebot_WP {
1201
return $external_js_hosts;
1202
}
1203
1204
/**
1205
* Display admin notice for recommending cookiebot
1206
*
@@ -1280,12 +1461,12 @@ final class Cookiebot_WP {
1280
}
1281
}
1282
}
1283
-
1284
-
1285
-
1286
1287
/**
1288
- * Cookiebot_WP Fix plugin conflicts related to Cookiebot
1289
*
1290
* @version 3.2.0
1291
* @since 3.3.0
@@ -1298,11 +1479,10 @@ final class Cookiebot_WP {
1298
//Fix for Elementor and WPBakery Page Builder Builder
1299
//Disabled - using another method now (can_current_user_edit_theme())
1300
//add_filter( 'script_loader_tag', array( $this, '_cookiebot_plugin_conflict_scripttags' ), 10, 2 );
1301
-
1302
}
1303
-
1304
/**
1305
- * Cookiebot_WP Fix Divi builder conflict when blocking mode is in auto.
1306
*
1307
* @version 3.2.0
1308
* @since 3.2.0
@@ -1318,21 +1498,21 @@ final class Cookiebot_WP {
1318
}
1319
}
1320
}
1321
-
1322
/**
1323
* Cookiebot_WP Fix plugin conflicts with page builders - whitelist JS files in automode
1324
- *
1325
* @version 3.2.0
1326
* @since 3.3.0
1327
*/
1328
function _cookiebot_plugin_conflict_scripttags( $tag, $handle ) {
1329
-
1330
//Check if Elementor Page Builder active
1331
if( defined( 'ELEMENTOR_VERSION' ) ) {
1332
- if( in_array( $handle, [
1333
- 'jquery-core',
1334
- 'elementor-frontend-modules',
1335
- 'elementor-frontend',
1336
'wp-tinymce' ,
1337
'underscore',
1338
'backbone',
@@ -1345,7 +1525,7 @@ final class Cookiebot_WP {
1345
$tag = str_replace( '<script ', '<script data-cookieconsent="ignore" ', $tag );
1346
}
1347
}
1348
-
1349
//Check if WPBakery Page Builder active
1350
if ( defined( 'WPB_VC_VERSION' ) ) {
1351
if( in_array( $handle, [
@@ -1362,7 +1542,7 @@ final class Cookiebot_WP {
1362
$tag = str_replace( '<script ', '<script data-cookieconsent="ignore" ', $tag );
1363
}
1364
}
1365
-
1366
return $tag;
1367
}
1368
4
Plugin URI: https://cookiebot.com/
5
Description: Cookiebot is a cloud-driven solution that automatically controls cookies and trackers, enabling full GDPR/ePrivacy and CCPA compliance for websites.
6
Author: Cybot A/S
7
+ Version: 3.5.0
8
Author URI: http://cookiebot.com
9
Text Domain: cookiebot
10
Domain Path: /langs
21
* @var string
22
* @since 1.0.0
23
*/
24
+ public $version = '3.5.0';
25
26
/**
27
* @var Cookiebot_WP The single instance of the class
57
add_action('plugins_loaded', array($this, 'cookiebot_init'), 5);
58
register_activation_hook( __FILE__ , array($this, 'activation'));
59
register_deactivation_hook( __FILE__, 'cookiebot_addons_plugin_deactivated' );
60
+
61
$this->cookiebot_fix_plugin_conflicts();
62
+
63
}
64
65
/**
161
}
162
}
163
164
+ //Include integration to WP Consent Level API if available
165
+ if($this->is_wp_consent_api_active()) {
166
+ add_action( 'wp_enqueue_scripts', array($this, 'cookiebot_enqueue_consent_api_scripts') );
167
+ }
168
169
// Set up localisation
170
load_plugin_textdomain('cookiebot', false, dirname( plugin_basename( __FILE__ ) ) . '/langs/' );
182
if(is_admin() || (defined('DOING_CRON') && DOING_CRON)) {
183
add_filter('auto_update_plugin', array($this,'automatic_updates'), 10, 2);
184
}
185
+
186
//Loading widgets
187
include_once( dirname( __FILE__ ) . '/widgets/cookiebot-declaration-widget.php' );
188
add_action( 'widgets_init', array($this,'register_widgets') );
198
function load_textdomain() {
199
load_plugin_textdomain( 'cookiebot', false, basename( dirname( __FILE__ ) ) . '/langs' );
200
}
201
+
202
/**
203
* Cookiebot_WP Register widgets
204
+ *
205
* @version 2.5.0
206
* @since 2.5.0
207
*/
300
register_setting('cookiebot', 'cookiebot-script-tag-uc-attribute');
301
register_setting('cookiebot', 'cookiebot-script-tag-cd-attribute');
302
register_setting('cookiebot', 'cookiebot-cookie-blocking-mode');
303
+ register_setting('cookiebot', 'cookiebot-consent-mapping');
304
register_setting('cookiebot-iab', 'cookiebot-iab');
305
}
306
405
* @since 1.0.0
406
*/
407
function settings_page() {
408
+ wp_enqueue_style( 'cookiebot-consent-mapping-table', plugins_url( 'css/consent_mapping_table.css', __FILE__ ), array(), '3.5.0' );
409
+
410
/* Check if multisite */
411
if($is_ms = is_multisite()) {
412
//Receive settings from multisite - this might change the way we render the form
422
<img src="<?php echo plugins_url( 'cookiebot-logo.png', __FILE__ ); ?>" style="float:right;margin-left:1em;">
423
</a>
424
<p>
425
+ <?php _e('Cookiebot enables your website to comply with current legislation in the EU on the use of cookies for user tracking and profiling. The EU ePrivacy Directive requires prior, informed consent of your site users, while the <a href="https://www.cookiebot.com/goto/gdpr" target="_blank">General Data Protection Regulation (GDPR)</a> requires you to document each consent. At the same time you must be able to account for what user data you share with embedded third-party services on your website and where in the world the user data is sent.','cookiebot'); ?>
426
</p>
427
<form method="post" action="options.php">
428
<?php settings_fields( 'cookiebot' ); ?>
434
<input type="text" name="cookiebot-cbid" value="<?php echo esc_attr( get_option('cookiebot-cbid') ); ?>"<?php echo ($is_ms) ? ' placeholder="'.$network_cbid.'"' : ''; ?> style="width:300px" />
435
<p class="description">
436
<?php _e('Need an ID?','cookiebot'); ?>
437
+ <a href="https://www.cookiebot.com/goto/signup" target="_blank"><?php _e('Sign up for free on cookiebot.com','cookiebot'); ?></a>
438
</p>
439
</td>
440
</tr>
558
</table>
559
<script>
560
jQuery(document).ready(function($) {
561
+ $('.cookiebot_fieldset_header').on('click',function(e) {
562
e.preventDefault();
563
+ $(this).next().slideToggle();
564
+ $(this).toggleClass('active');
565
});
566
});
567
</script>
568
<style type="text/css">
569
+ .cookiebot_fieldset_header {
570
cursor:pointer;
571
}
572
+ .cookiebot_fieldset_header::after {
573
content: "\f140";
574
font: normal 24px/1 dashicons;
575
position: relative;
576
top: 5px;
577
}
578
+ .cookiebot_fieldset_header.active::after {
579
content: "\f142";
580
}
581
</style>
582
+ <h3 id="advanced_settings_link" class="cookiebot_fieldset_header"><?php _e('Advanced settings', 'cookiebot'); ?></h3>
583
+ <div id="advanced_settings" style="display:none;">
584
<table class="form-table">
585
<tr valign="top" id="cookiebot-setting-async">
586
<th scope="row">
711
</tr>
712
</table>
713
</div>
714
+ <?php if($this->is_wp_consent_api_active()) { ?>
715
+ <h3 id="consent_level_api_settings" class="cookiebot_fieldset_header"><?php _e('Consent Level API Settings', 'cookiebot'); ?></h3>
716
+ <div id="consent_level_api_settings" style="display:none;">
717
+ <p><?php _e('WP Consent Level API and Cookiebot categorise cookies a bit different. The default settings should fit mosts needs - but if you need to change the mapping you are able to do it below.','cookiebot'); ?></p>
718
+
719
+ <?php
720
+ $mDefault = $this->get_default_wp_consent_api_mapping();
721
+
722
+ $m = $this->get_wp_consent_api_mapping();
723
+
724
+ $consentTypes = ['preferences', 'statistics', 'marketing'];
725
+ $states = array_reduce($consentTypes, function ($t, $v) {
726
+ $newt = [];
727
+ if (empty($t)) {
728
+ $newt = [
729
+ [$v => true],
730
+ [$v => false],
731
+ ];
732
+ } else {
733
+ foreach ($t as $item) {
734
+ $newt[] = array_merge($item, [$v => true]);
735
+ $newt[] = array_merge($item, [$v => false]);
736
+ }
737
+ }
738
+
739
+ return $newt;
740
+ }, []);
741
+
742
+ ?>
743
+
744
+
745
+ <table class="widefat striped consent_mapping_table">
746
+ <thead>
747
+ <tr>
748
+ <th>Cookiebot categories</th>
749
+ <th class="consent_mapping">WP Consent Level categories</th>
750
+ </tr>
751
+ </thead>
752
+ <?php
753
+ foreach($states as $state) {
754
+
755
+ $key = [];
756
+ $key[] = 'n=1';
757
+ $key[] = 'p='.($state['preferences'] ? '1' : '0');
758
+ $key[] = 's='.($state['statistics'] ? '1' : '0');
759
+ $key[] = 'm='.($state['marketing'] ? '1' : '0');
760
+ $key = implode(';',$key);
761
+ ?>
762
+ <tr valign="top">
763
+ <td>
764
+ <div class="cb_consent">
765
+ <span class="forceconsent">Necessary</span>
766
+ <span class="<?php echo ($state['preferences'] ? 'consent' : 'noconsent'); ?>">Preferences</span>
767
+ <span class="<?php echo ($state['statistics'] ? 'consent' : 'noconsent'); ?>">Statistics</span>
768
+ <span class="<?php echo ($state['marketing'] ? 'consent' : 'noconsent'); ?>">Marketing</span>
769
+ </div>
770
+ </td>
771
+ <td>
772
+ <div class="consent_mapping">
773
+ <label><input type="checkbox" name="cookiebot-consent-mapping[<?php echo $key; ?>][functional]" data-default-value="1" value="1" checked disabled> Functional </label>
774
+ <label><input type="checkbox" name="cookiebot-consent-mapping[<?php echo $key; ?>][preferences]" data-default-value="<?php echo $mDefault[$key]['preferences']; ?>" value="1" <?php if($m[$key]['preferences']) { echo 'checked'; } ?>> Preferences </label>
775
+ <label><input type="checkbox" name="cookiebot-consent-mapping[<?php echo $key; ?>][statistics]" data-default-value="<?php echo $mDefault[$key]['statistics']; ?>" value="1" <?php if($m[$key]['statistics']) { echo 'checked'; } ?>> Statistics </label>
776
+ <label><input type="checkbox" name="cookiebot-consent-mapping[<?php echo $key; ?>][statistics-anonymous]" data-default-value="<?php echo $mDefault[$key]['statistics-anonymous']; ?>" value="1" <?php if($m[$key]['statistics-anonymous']) { echo 'checked'; } ?>> Statistics Anonymous</label>
777
+ <label><input type="checkbox" name="cookiebot-consent-mapping[<?php echo $key; ?>][marketing]" data-default-value="<?php echo $mDefault[$key]['marketing']; ?>" value="1" <?php if($m[$key]['marketing']) { echo 'checked'; } ?>> Marketing</label>
778
+ </div>
779
+ </td>
780
+ </tr>
781
+ <?php
782
+ }
783
+ ?>
784
+ <tfoot>
785
+ <tr>
786
+ <td colspan="2" style="text-align:right;"><button class="button" onclick="return resetConsentMapping();">Reset to default mapping</button></td>
787
+ </tr>
788
+ </tfoot>
789
+ </table>
790
+ <script>
791
+ function resetConsentMapping() {
792
+ if(confirm('Are you sure you want to reset to default consent mapping?')) {
793
+ jQuery('.consent_mapping_table input[type=checkbox]').each(function () {
794
+ if(!this.disabled) {
795
+ this.checked = (jQuery(this).data('default-value') == '1') ? true : false;
796
+ }
797
+ });
798
+ }
799
+ return false;
800
+ }
801
+ </script>
802
+ </div>
803
+ <?php } ?>
804
<?php submit_button(); ?>
805
</form>
806
</div>
821
<img src="<?php echo plugins_url( 'cookiebot-logo.png', __FILE__ ); ?>" style="float:right;margin-left:1em;">
822
</a>
823
<p>
824
+ <?php _e('Cookiebot enables your website to comply with current legislation in the EU on the use of cookies for user tracking and profiling. The EU ePrivacy Directive requires prior, informed consent of your site users, while the <a href="https://www.cookiebot.com/goto/gdpr" target="_blank">General Data Protection Regulation (GDPR)</a> requires you to document each consent. At the same time you must be able to account for what user data you share with embedded third-party services on your website and where in the world the user data is sent.','cookiebot'); ?>
825
</p>
826
<p>
827
<b><big style="color:red;"><?php _e('The settings below is network wide settings. See notes below each field.'); ?></big></b>
837
<b><?php _e('If added this will be the default Cookiebot ID for all subsites. Subsites are able to override the Cookiebot ID.'); ?></b>
838
<br />
839
<?php _e('Need an ID?','cookiebot'); ?>
840
+ <a href="https://www.cookiebot.com/goto/signup" target="_blank"><?php _e('Sign up for free on cookiebot.com','cookiebot'); ?></a>
841
</p>
842
</td>
843
</tr>
1026
<h2><?php _e('How to find my Cookiebot ID','cookiebot'); ?></h2>
1027
<p>
1028
<ol>
1029
+ <li><?php _e('Log in to your <a href="https://www.cookiebot.com/goto/account" target="_blank">Cookiebot account</a>.','cookiebot'); ?></li>
1030
<li><?php _e('Go to <b>Manage</b> > <b>Settings</b> and add setup your Cookiebot','cookiebot'); ?></li>
1031
<li><?php _e('Go to the <b>"Your scripts"</b> tab','cookiebot'); ?></li>
1032
<li><?php _e('Copy the value inside the data-cid parameter - eg.: abcdef12-3456-7890-abcd-ef1234567890','cookiebot'); ?></li>
1134
else {
1135
$tagAttr = get_site_option('cookiebot-script-tag-uc-attribute');
1136
}
1137
+
1138
if($this->get_cookie_blocking_mode() == 'auto') {
1139
$tagAttr = 'data-blockingmode="auto"';
1140
}
1222
}
1223
return $cbid;
1224
}
1225
+
1226
/**
1227
* Cookiebot_WP Get cookie blocking mode (auto | manual)
1228
*
1243
1244
/**
1245
* Cookiebot_WP Check if Cookiebot is active in admin
1246
+ *
1247
* @version 3.1.0
1248
* @since 3.1.0
1249
*/
1298
return $external_js_hosts;
1299
}
1300
1301
+
1302
+ /**
1303
+ * Cookiebot_WP Check if WP Cookie Consent API is active
1304
+ *
1305
+ * @version 3.5.0
1306
+ * @since 3.5.0
1307
+ */
1308
+ public function is_wp_consent_api_active() {
1309
+ if ( class_exists( 'WP_CONSENT_API' ) ) {
1310
+ return true;
1311
+ }
1312
+ return false;
1313
+ }
1314
+
1315
+ /**
1316
+ * Cookiebot_WP Default consent level mappings
1317
+ *
1318
+ * @version 3.5.0
1319
+ * @since 3.5.0
1320
+ */
1321
+ public function get_default_wp_consent_api_mapping() {
1322
+ return array(
1323
+ 'n=1;p=1;s=1;m=1' =>
1324
+ array('preferences'=>1,'statistics'=>1,'statistics-anonymous'=>0,'marketing'=>1),
1325
+ 'n=1;p=1;s=1;m=0' =>
1326
+ array('preferences'=>1,'statistics'=>1,'statistics-anonymous'=>1,'marketing'=>0),
1327
+ 'n=1;p=1;s=0;m=1' =>
1328
+ array('preferences'=>1,'statistics'=>0,'statistics-anonymous'=>0,'marketing'=>1),
1329
+ 'n=1;p=1;s=0;m=0' =>
1330
+ array('preferences'=>1,'statistics'=>0,'statistics-anonymous'=>0,'marketing'=>0),
1331
+ 'n=1;p=0;s=1;m=1' =>
1332
+ array('preferences'=>0,'statistics'=>1,'statistics-anonymous'=>0,'marketing'=>1),
1333
+ 'n=1;p=0;s=1;m=0' =>
1334
+ array('preferences'=>0,'statistics'=>1,'statistics-anonymous'=>0,'marketing'=>0),
1335
+ 'n=1;p=0;s=0;m=1' =>
1336
+ array('preferences'=>0,'statistics'=>0,'statistics-anonymous'=>0,'marketing'=>1),
1337
+ 'n=1;p=0;s=0;m=0' =>
1338
+ array('preferences'=>0,'statistics'=>0,'statistics-anonymous'=>0,'marketing'=>0),
1339
+ );
1340
+
1341
+ }
1342
+
1343
+ /**
1344
+ * Cookiebot_WP Get the mapping between Consent Level API and Cookiebot
1345
+ * Returns array where key is the consent level api category and value
1346
+ * is the mapped Cookiebot category.
1347
+ *
1348
+ * @version 3.5.0
1349
+ * @since 3.5.0
1350
+ */
1351
+ public function get_wp_consent_api_mapping() {
1352
+ $mDefault = $this->get_default_wp_consent_api_mapping();
1353
+ $mapping = get_option( 'cookiebot-consent-mapping', $mDefault);
1354
+
1355
+ $mapping = ( '' === $mapping ) ? $mDefault : $mapping;
1356
+
1357
+ foreach($mDefault as $k=>$v) {
1358
+ if(!isset($mapping[$k])) {
1359
+ $mapping[$k] = $v;
1360
+ }
1361
+ else {
1362
+ foreach($v as $vck=>$vcv) {
1363
+ if(!isset($mapping[$k][$vck])) {
1364
+ $mapping[$k][$vck] = $vcv;
1365
+ }
1366
+ }
1367
+ }
1368
+ }
1369
+ return $mapping;
1370
+ }
1371
+
1372
+ /**
1373
+ * Cookiebot_WP Enqueue JS for integration with WP Consent Level API
1374
+ *
1375
+ * @version 3.5.0
1376
+ * @since 3.5.0
1377
+ */
1378
+ function cookiebot_enqueue_consent_api_scripts() {
1379
+ wp_register_script( 'cookiebot-wp-consent-level-api-integration', plugins_url( 'cookiebot/js/cookiebot-wp-consent-level-api-integration.js', 'cookiebot' ) );
1380
+ wp_enqueue_script( 'cookiebot-wp-consent-level-api-integration' );
1381
+ wp_localize_script( 'cookiebot-wp-consent-level-api-integration', 'cookiebot_category_mapping', $this->get_wp_consent_api_mapping() );
1382
+ }
1383
+
1384
+
1385
/**
1386
* Display admin notice for recommending cookiebot
1387
*
1461
}
1462
}
1463
}
1464
+
1465
+
1466
+
1467
1468
/**
1469
+ * Cookiebot_WP Fix plugin conflicts related to Cookiebot
1470
*
1471
* @version 3.2.0
1472
* @since 3.3.0
1479
//Fix for Elementor and WPBakery Page Builder Builder
1480
//Disabled - using another method now (can_current_user_edit_theme())
1481
//add_filter( 'script_loader_tag', array( $this, '_cookiebot_plugin_conflict_scripttags' ), 10, 2 );
1482
}
1483
+
1484
/**
1485
+ * Cookiebot_WP Fix Divi builder conflict when blocking mode is in auto.
1486
*
1487
* @version 3.2.0
1488
* @since 3.2.0
1498
}
1499
}
1500
}
1501
+
1502
/**
1503
* Cookiebot_WP Fix plugin conflicts with page builders - whitelist JS files in automode
1504
+ *
1505
* @version 3.2.0
1506
* @since 3.3.0
1507
*/
1508
function _cookiebot_plugin_conflict_scripttags( $tag, $handle ) {
1509
+
1510
//Check if Elementor Page Builder active
1511
if( defined( 'ELEMENTOR_VERSION' ) ) {
1512
+ if( in_array( $handle, [
1513
+ 'jquery-core',
1514
+ 'elementor-frontend-modules',
1515
+ 'elementor-frontend',
1516
'wp-tinymce' ,
1517
'underscore',
1518
'backbone',
1525
$tag = str_replace( '<script ', '<script data-cookieconsent="ignore" ', $tag );
1526
}
1527
}
1528
+
1529
//Check if WPBakery Page Builder active
1530
if ( defined( 'WPB_VC_VERSION' ) ) {
1531
if( in_array( $handle, [
1542
$tag = str_replace( '<script ', '<script data-cookieconsent="ignore" ', $tag );
1543
}
1544
}
1545
+
1546
return $tag;
1547
}
1548
css/consent_mapping_table.css ADDED
@@ -0,0 +1,48 @@
1
+ table.consent_mapping_table {
2
+ max-width:80em;
3
+ }
4
+ table.consent_mapping_table tr td:first-of-type,
5
+ table.consent_mapping_table tr th:first-of-type {
6
+ width:30em;
7
+ max-width:50%;
8
+ }
9
+ table.consent_mapping_table tr td:first-of-type {
10
+ border-right:1px solid rgba(0,0,0,0.2);
11
+ }
12
+ table.consent_mapping_table th.consent_mapping {
13
+ min-width:8em;
14
+ }
15
+
16
+ table.consent_mapping_table .consent,
17
+ table.consent_mapping_table .forceconsent,
18
+ table.consent_mapping_table .noconsent {
19
+ font-weight:bold;
20
+ display:inline-block;
21
+ margin-right:1em;
22
+ background-repeat:no-repeat;
23
+ background-position:0 50%;
24
+ padding-left:1.3em;
25
+ background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyBpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM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EuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBXaW5kb3dzIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjgzMjc3NEM2QkJDMjExRTNBN0ExOUJFMzFCMzdBRjdEIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjgzMjc3NEM3QkJDMjExRTNBN0ExOUJFMzFCMzdBRjdEIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6ODMyNzc0QzRCQkMyMTFFM0E3QTE5QkUzMUIzN0FGN0QiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6ODMyNzc0QzVCQkMyMTFFM0E3QTE5QkUzMUIzN0FGN0QiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz54CbH2AAABFElEQVR42oxSLQ/CQAy9I6hZMrVgQW4aCdnvGIoER8Lm+AcbWBIcFo0cFuw0dkxMMAlyvC69y/hek6VN19e+16ssy1JIKUUTC8Owh9o+wkNbNDSADICmCA18w1ZTIEAeg8juMkmS8h+oKAqR57nIsmzD0pYVVcdx5A+KHRQuLMuaEYj0+b5/br0UdT9QHANgcJwGQbCjWAOjKPKoM/yglhvB9dTW0WCrG5LGOI77SM5rz0IFKXILniRs2564rqsL2tzpQjQQKqoectdao9Q0zScJFVXwvsGteIr612F/Q279ql1rxKYqME8WNV17NL5+BSowCmnykUFngA6fnunt5Jj2Fhs9wV++XlKTy1GGzeptPQQYAF1/e0nsKZ1HAAAAAElFTkSuQmCC);
32
+ }
33
+ table.consent_mapping_table .cb_consent {
34
+ border:1px solid #cccccc;
35
+ background-color:#fff;
36
+ border-radius:4px;
37
+ padding:4px 3px 3px 9px;
38
+ display:inline-block;
39
+ }
40
+
41
+ table.consent_mapping_table .consent_mapping {
42
+ margin:0.5em 0;
43
+ line-height:140%;
44
+ }
45
+ table.consent_mapping_table .consent_mapping label {
46
+ display:inline-block;
47
+ margin-right:1em;
48
+ }
js/cookiebot-wp-consent-level-api-integration.js ADDED
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ window.wp_consent_type = 'optin';
4
+ window.addEventListener('CookiebotOnAccept', cookiebot_update_consent_level, false);
5
+ window.addEventListener('CookiebotOnDecline', cookiebot_update_consent_level, false);
6
+ window.addEventListener('load', cookiebot_update_consent_level, false);
7
+
8
+
9
+ function cookiebot_update_consent_level(e) {
10
+
11
+ wp_set_consent( 'functional', 'allow' ); //always allow functional cookies
12
+
13
+ if ( typeof Cookiebot === 'undefined' ) {
14
+ var consentMappingKey = 'n=1;p=1;s=1;m=1';
15
+ }
16
+ else {
17
+ var consentMappingKey = 'n=1;';
18
+ consentMappingKey = consentMappingKey + 'p=' + ( ( Cookiebot.consent.preferences ) ? '1' : '0' ) + ';';
19
+ consentMappingKey = consentMappingKey + 's=' + ( ( Cookiebot.consent.statistics ) ? '1' : '0' ) + ';';
20
+ consentMappingKey = consentMappingKey + 'm=' + ( ( Cookiebot.consent.marketing ) ? '1' : '0' );
21
+ }
22
+
23
+ for( var key in cookiebot_category_mapping[consentMappingKey] ) {
24
+
25
+ var strValue = cookiebot_category_mapping[consentMappingKey][key] ? 'allow' : 'deny';
26
+
27
+ if( ( wp_has_consent( key ) && strValue != 'allow' ) || ( !wp_has_consent(key) && strValue == 'allow' ) ) {
28
+ wp_set_consent( key, strValue );
29
+ }
30
+
31
+ }
32
+
33
+
34
+ }
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
* Contributors: cookiebot,phpgeekdk,aytac
3
* Tags: cookie, compliance, eu, gdpr, europe, cookie consent, consent, ccpa
4
* Requires at least: 4.4
5
- * Tested up to: 5.2
6
- * Stable tag: 3.4.2
7
* Requires PHP: 5.6
8
* License: GPLv2 or later
9
@@ -182,9 +182,16 @@ Cookiebot works with GTM, however you need to enable the "Hide Cookie Popup" opt
182
183
[Please see our article on how to deploy Cookiebot with GTM](https://support.cookiebot.com/hc/en-us/articles/360003793854-Google-Tag-Manager-deployment).
184
185
186
## Changelog ##
187
188
189
### 3.4.2 - 2020-02-06 ###
190
* Fix for DIVI editor
2
* Contributors: cookiebot,phpgeekdk,aytac
3
* Tags: cookie, compliance, eu, gdpr, europe, cookie consent, consent, ccpa
4
* Requires at least: 4.4
5
+ * Tested up to: 5.3.2
6
+ * Stable tag: 3.5.0
7
* Requires PHP: 5.6
8
* License: GPLv2 or later
9
182
183
[Please see our article on how to deploy Cookiebot with GTM](https://support.cookiebot.com/hc/en-us/articles/360003793854-Google-Tag-Manager-deployment).
184
185
+ ### Does Cookiebot integrate with WP Consent API? ###
186
+ Cookiebot is fully integrated with the WP Consent API. When your visitors give consent using Cookiebot, the consent will automatically be sent to the [WP Consent API](https://wordpress.org/plugins/wp-consent-api/).
187
+
188
+ You are able to define the mapping between Cookiebot and the WP Consent API in the administration interface (Cookiebot WP plugin).
189
+
190
191
## Changelog ##
192
193
+ ### 3.5.0 - 2020-02-10 ###
194
+ * Adding integration with WP Consent API
195
196
### 3.4.2 - 2020-02-06 ###
197
* Fix for DIVI editor