PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 3.9.0
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v3.9.0
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 / cookiebot.php
cookiebot Last commit date
addons 5 years ago assets 7 years ago bin 5 years ago css 5 years ago documentation 7 years ago js 5 years ago langs 8 years ago tests 5 years ago widgets 5 years ago CookiebotAPI.md 7 years ago LICENSE.txt 8 years ago README.md 5 years ago cookiebot-logo.png 8 years ago cookiebot.php 5 years ago phpunit.xml 5 years ago readme.txt 5 years ago
cookiebot.php
2005 lines
1 <?php
2 /*
3 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.9.0
8 Author URI: http://cookiebot.com
9 Text Domain: cookiebot
10 Domain Path: /langs
11 */
12
13 if(!defined('ABSPATH')) exit; // Exit if accessed directly
14
15 if(!class_exists('Cookiebot_WP')):
16
17 final class Cookiebot_WP {
18 /**
19 * Plugin version.
20 *
21 * @var string
22 * @since 1.0.0
23 */
24 public $version = '3.9.0';
25
26 /**
27 * @var Cookiebot_WP The single instance of the class
28 * @since 1.0.0
29 */
30 protected static $_instance = null;
31
32 /**
33 * Main Cookiebot_WP Instance
34 *
35 * Ensures only one instance of Cookiebot_WP is loaded or can be loaded.
36 *
37 * @version 1.0.0
38 * @since 1.0.0
39 * @static
40 * @return Cookiebot_WP - Main instance
41 */
42 public static function instance() {
43 if(is_null(self::$_instance)) {
44 self::$_instance = new self();
45 }
46 return self::$_instance;
47 }
48
49 /**
50 * Cookiebot_WP Constructor.
51 *
52 * @version 2.1.4
53 * @since 1.0.0
54 * @access public
55 */
56 function __construct() {
57 add_action('after_setup_theme', 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 * Cookiebot_WP Installation actions
66 *
67 * @version 2.1.4
68 * @since 2.1.4
69 * @accces public
70 */
71 function activation() {
72 //Delay display of recommendation notice in 3 days if not activated ealier
73 if(get_option('cookiebot_notice_recommend',false) === false) {
74 //Not set yet - this must be first activation - delay in 3 days
75 update_option('cookiebot_notice_recommend', strtotime('+3 days'));
76 }
77 if($this->get_cbid() == '') {
78 if(is_multisite()) {
79 update_site_option('cookiebot-cookie-blocking-mode','auto');
80 update_site_option('cookiebot-nooutput-admin',true);
81 }
82 else {
83 update_option('cookiebot-cookie-blocking-mode','auto');
84 update_option('cookiebot-nooutput-admin',true);
85 }
86 }
87
88 /**
89 * Run through the addons and enable the default ones
90 */
91 if( (!defined('COOKIEBOT_ADDONS_STANDALONE') || COOKIEBOT_ADDONS_STANDALONE != true || !defined('COOKIE_ADDONS_LOADED')) ) {
92 //Make sure we got a PHP version that works
93 if ( version_compare( PHP_VERSION, '5.4.0', '>=' ) ) {
94 define( 'COOKIEBOT_URL', plugin_dir_url( __FILE__ ) );
95 // activation hook doesn't have the addons loaded - so load it extra when the plugin is activated
96 include_once( dirname( __FILE__ ) . '/addons/cookiebot-addons-init.php' );
97 // run activated hook on the addons
98 cookiebot_addons_plugin_activated();
99 }
100 }
101 }
102
103 /**
104 * Cookiebot_WP Init Cookiebot.
105 *
106 * @version 3.8.1
107 * @since 1.6.2
108 * @access public
109 */
110 function cookiebot_init() {
111 /* Load Cookiebot Addons Framework */
112 $dismissAddons = false;
113 if(defined('CAF_DIR')) {
114 $dismissAddons = true;
115 /*add_action('admin_notices', function() {
116 ?>
117 <div class="notice notice-warning">
118 <p>
119 <?php _e( 'You have Cookiebot Addons installed.', 'cookiebot' ); ?><br />
120 <?php _e( 'In this and future releases of Cookiebot all available Addons are bundled directly with the Cookiebot plugin.', 'cookiebot' ); ?><br />
121 <?php _e( 'To ensure up-to-date addons - please disable and remove your Cookiebot Addons plugin and configure you addons under "Prior consent" in the Cookiebot menu.', 'cookiebot' ); ?>
122 </p>
123 </div>
124 <?php
125 });*/
126 }
127 //elseif( $this->get_cookie_blocking_mode() !== 'auto' ) {
128 else {
129 if( (!defined('COOKIEBOT_ADDONS_STANDALONE') || COOKIEBOT_ADDONS_STANDALONE != true || !defined('COOKIE_ADDONS_LOADED')) && $dismissAddons !== true ) {
130 //Make sure we got a PHP version that works
131 if(version_compare(PHP_VERSION, '5.4.0', '>=')) {
132 define('COOKIEBOT_URL', plugin_dir_url( __FILE__ ));
133 include_once( dirname( __FILE__ ) . '/addons/cookiebot-addons-init.php' );
134 }
135 else {
136 define('COOKIEBOT_ADDONS_UNSUPPORTED_PHPVERSION',true);
137 }
138 }
139 else {
140 add_action('admin_notices', function() {
141 ?>
142 <div class="notice notice-warning">
143 <p>
144 <?php _e( 'You are using Cookiebot Addons Standalone.', 'cookiebot' ); ?>
145 </p>
146 </div>
147 <?php
148 });
149 }
150 }
151 if(is_admin()) {
152
153 //Adding menu to WP admin
154 add_action('admin_menu', array($this,'add_menu'),1);
155 add_action('admin_menu', array($this,'add_menu_legislations'),40);
156 add_action('admin_menu', array($this,'add_menu_debug'),50);
157
158
159 if(is_multisite()) {
160 add_action('network_admin_menu', array($this,'add_network_menu'),1);
161 add_action('network_admin_edit_cookiebot_network_settings', array($this,'network_settings_save'));
162 }
163
164 //Register settings
165 add_action('admin_init', array($this,'register_cookiebot_settings'));
166
167 //Adding dashboard widgets
168 add_action('wp_dashboard_setup', array($this,'add_dashboard_widgets'));
169
170 add_action('admin_notices', array( $this, 'cookiebot_admin_notices' ) );
171 add_action('admin_init', array($this,'save_notice_link'));
172
173 //Check if we should show cookie consent banner on admin pages
174 if(!$this->cookiebot_disabled_in_admin()) {
175 //adding cookie banner in admin area too
176 add_action('admin_head', array($this,'add_js'),-9999);
177 }
178 }
179
180 //Include integration to WP Consent Level API if available
181 if($this->is_wp_consent_api_active()) {
182 add_action( 'wp_enqueue_scripts', array($this, 'cookiebot_enqueue_consent_api_scripts') );
183 }
184
185 // Set up localisation
186 load_plugin_textdomain('cookiebot', false, dirname( plugin_basename( __FILE__ ) ) . '/langs/' );
187
188 //add JS
189 add_action('wp_head', array($this,'add_js'), -9997);
190 add_action('wp_head', array($this,'add_GTM'), -9998);
191 add_action('wp_head', array($this,'add_GCM'), -9999);
192 add_shortcode('cookie_declaration', array($this,'show_declaration'));
193
194 //Add filter if WP rocket is enabled
195 if(defined('WP_ROCKET_VERSION')) {
196 add_filter('rocket_minify_excluded_external_js', array($this,'wp_rocket_exclude_external_js'));
197 }
198
199 //Add filter
200 add_filter( 'sgo_javascript_combine_excluded_external_paths', array($this,'sgo_exclude_external_js') );
201
202 //Automatic update plugin
203 if(is_admin() || (defined('DOING_CRON') && DOING_CRON)) {
204 add_filter('auto_update_plugin', array($this,'automatic_updates'), 10, 2);
205 }
206
207 //Loading widgets
208 include_once( dirname( __FILE__ ) . '/widgets/cookiebot-declaration-widget.php' );
209 add_action( 'widgets_init', array($this,'register_widgets') );
210
211
212 //Add Gutenberg block
213 add_action( 'enqueue_block_assets', array($this,'gutenberg_block_setup') );
214 add_action( 'enqueue_block_editor_assets', array($this,'gutenberg_block_admin_assets') );
215 }
216
217
218 /**
219 * Cookiebot_WP Setup Gutenberg block
220 *
221 * @version 3.7.0
222 * @since 3.7.0
223 */
224 function gutenberg_block_setup() {
225 if ( ! function_exists( 'register_block_type' ) ) {
226 return; //gutenberg not active
227 }
228
229 register_block_type( 'cookiebot/cookie-declaration', array(
230 'render_callback' => array( $this, 'block_cookie_declaration' )
231 ) );
232 }
233
234 /**
235 * Cookiebot_WP Add block JS
236 *
237 * @version 3.7.1
238 * @since 3.7.1
239 */
240 function gutenberg_block_admin_assets() {
241 //Add Gutenberg Widget
242 wp_enqueue_script(
243 'cookiebot-declaration',
244 plugin_dir_url( __FILE__ ) . 'js/block.js',
245 array('wp-blocks', 'wp-i18n', 'wp-element'), // Required scripts for the block
246 $this->version
247 );
248 }
249
250 /**
251 * Cookiebot_WP Render Cookiebot Declaration as Gutenberg block
252 *
253 * @version 3.7.0
254 * @since 3.7.0
255 */
256 function block_cookie_declaration() {
257 return $this->show_declaration();
258 }
259
260 /**
261 * Cookiebot_WP Load text domain
262 *
263 * @version 2.0.0
264 * @since 2.0.0
265 */
266 function load_textdomain() {
267 load_plugin_textdomain( 'cookiebot', false, basename( dirname( __FILE__ ) ) . '/langs' );
268 }
269
270 /**
271 * Cookiebot_WP Register widgets
272 *
273 * @version 2.5.0
274 * @since 2.5.0
275 */
276 function register_widgets() {
277 register_widget( 'Cookiebot_Declaration_Widget' );
278 }
279
280 /**
281 * Cookiebot_WP Add dashboard widgets to admin
282 *
283 * @version 1.0.0
284 * @since 1.0.0
285 */
286
287 function add_dashboard_widgets() {
288 wp_add_dashboard_widget('cookiebot_status', __('Cookiebot Status','cookiebot'), array($this,'dashboard_widget_status'));
289 }
290
291 /**
292 * Cookiebot_WP Output Dashboard Status Widget
293 *
294 * @version 1.0.0
295 * @since 1.0.0
296 */
297 function dashboard_widget_status() {
298 $cbid = $this->get_cbid();
299 if(empty($cbid)) {
300 echo '<p>'.__('You need to enter your Cookiebot ID.','cookiebot').'</p>';
301 echo '<p><a href="options-general.php?page=cookiebot">';
302 echo __('Update your Cookiebot ID','cookiebot');
303 echo '</a></p>';
304 }
305 else {
306 echo '<p>'._e('Your Cookiebot is working!','cookiebot').'</p>';
307 }
308 }
309
310 /**
311 * Cookiebot_WP Add option menu page for Cookiebot
312 *
313 * @version 2.2.0
314 * @since 1.0.0
315 */
316 function add_menu() {
317 //Cookiebot Icon SVG base64 encoded
318 $icon = 'data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgNzIgNTQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iI0ZGRkZGRiIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNNDYuODcyNTkwMyA4Ljc3MzU4MzM0QzQxLjk0MzkwMzkgMy4zODI5NTAxMSAzNC44NDI0OTQ2IDAgMjYuOTQ4MjgxOSAwIDEyLjA2NTE1NjggMCAwIDEyLjAyNDQ3NzQgMCAyNi44NTc0MjE5YzAgMTQuODMyOTQ0NSAxMi4wNjUxNTY4IDI2Ljg1NzQyMTkgMjYuOTQ4MjgxOSAyNi44NTc0MjE5IDcuODk0MjEyNyAwIDE0Ljk5NTYyMi0zLjM4Mjk1MDIgMTkuOTI0MzA4NC04Ljc3MzU4MzQtMi44ODk2OTY3LTEuMzY4ODY2My01LjM5OTMxMS0zLjQwNTQzOS03LjMyODA4MzgtNS45MDk2MzU4LTMuMTIxNDMwNiAzLjIwOTQxMDQtNy40OTI5OTQ0IDUuMjA0MTI5MS0xMi4zMzIwMjU4IDUuMjA0MTI5MS05LjQ4NDM0NDQgMC0xNy4xNzI5MjQ3LTcuNjYyNjU3Mi0xNy4xNzI5MjQ3LTE3LjExNTAyMzhzNy42ODg1ODAzLTE3LjExNTAyMzcgMTcuMTcyOTI0Ny0xNy4xMTUwMjM3YzQuNzIzNDgyMiAwIDkuMDAxNTU1MiAxLjkwMDU5MzkgMTIuMTA2MjkyIDQuOTc2MzA5IDEuOTU2OTIzNy0yLjY0MTEzMSA0LjU1MDAyNjMtNC43ODU1MTgzIDcuNTUzODE3Ni02LjIwODQzMTg2eiIvPjxwYXRoIGQ9Ik01NS4zODAzMjgyIDQyLjY1MDE5OTFDNDYuMzMzNzIyNyA0Mi42NTAxOTkxIDM5IDM1LjM0MTIwMzEgMzkgMjYuMzI1MDk5NiAzOSAxNy4zMDg5OTYgNDYuMzMzNzIyNyAxMCA1NS4zODAzMjgyIDEwYzkuMDQ2NjA1NSAwIDE2LjM4MDMyODIgNy4zMDg5OTYgMTYuMzgwMzI4MiAxNi4zMjUwOTk2IDAgOS4wMTYxMDM1LTcuMzMzNzIyNyAxNi4zMjUwOTk1LTE2LjM4MDMyODIgMTYuMzI1MDk5NXptLjAyMTMwOTItNy43NTU2MzQyYzQuNzM3MDI3NiAwIDguNTc3MTQ3MS0zLjgyNzE3MiA4LjU3NzE0NzEtOC41NDgyMjc5IDAtNC43MjEwNTYtMy44NDAxMTk1LTguNTQ4MjI4LTguNTc3MTQ3MS04LjU0ODIyOC00LjczNzAyNzUgMC04LjU3NzE0NyAzLjgyNzE3Mi04LjU3NzE0NyA4LjU0ODIyOCAwIDQuNzIxMDU1OSAzLjg0MDExOTUgOC41NDgyMjc5IDguNTc3MTQ3IDguNTQ4MjI3OXoiLz48L2c+PC9zdmc+';
319 add_menu_page( 'Cookiebot', __('Cookiebot','cookiebot'), 'manage_options', 'cookiebot', array($this,'settings_page'),$icon);
320
321 add_submenu_page('cookiebot',__('Cookiebot Settings','cookiebot'),__('Settings','cookiebot'), 'manage_options', 'cookiebot',array($this,'settings_page'), 10 );
322 add_submenu_page('cookiebot',__('Cookiebot Support','cookiebot'),__('Support','cookiebot'), 'manage_options', 'cookiebot_support',array($this,'support_page'), 20 );
323 add_submenu_page('cookiebot',__('Google Tag Manager','cookiebot'),__('Google Tag Manager','cookiebot'), 'manage_options', 'cookiebot_GTM',array($this,'GTM_page') );
324 add_submenu_page('cookiebot',__('IAB','cookiebot'),__('IAB','cookiebot'), 'manage_options', 'cookiebot_iab',array($this,'iab_page'), 30 );
325
326 if(defined('COOKIEBOT_ADDONS_UNSUPPORTED_PHPVERSION')) {
327 //Load prior consent page anyway - but from Cookiebot WP Core plugin.
328 add_submenu_page( 'cookiebot', __( 'Prior Consent', 'cookiebot' ), __( 'Prior Consent', 'cookiebot' ), 'manage_options', 'cookiebot-addons', array($this,'setting_page_placeholder' ), 40 );
329 }
330 }
331
332 function add_menu_legislations() {
333 add_submenu_page( 'cookiebot', __( 'Legislations', 'cookiebot' ), __( 'Legislations', 'cookiebot' ), 'manage_options', 'cookiebot-legislations', array($this,'legislations_page' ), 50 );
334 }
335
336 /**
337 * Cookiebot_WP Add debug menu - we need to add this seperate to ensure it is placed last (after menu items from Addons).
338 *
339 * @version 3.6.0
340 * @since 3.6.0
341 */
342 function add_menu_debug() {
343 add_submenu_page('cookiebot',__('Debug info','cookiebot'),__('Debug info','cookiebot'), 'manage_options', 'cookiebot_debug',array($this,'debug_page') );
344 }
345
346 /**
347 * Cookiebot_WP Add menu for network sites
348 *
349 * @version 2.2.0
350 * @since 2.2.0
351 */
352 function add_network_menu() {
353 $icon = 'data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgNzIgNTQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iI0ZGRkZGRiIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNNDYuODcyNTkwMyA4Ljc3MzU4MzM0QzQxLjk0MzkwMzkgMy4zODI5NTAxMSAzNC44NDI0OTQ2IDAgMjYuOTQ4MjgxOSAwIDEyLjA2NTE1NjggMCAwIDEyLjAyNDQ3NzQgMCAyNi44NTc0MjE5YzAgMTQuODMyOTQ0NSAxMi4wNjUxNTY4IDI2Ljg1NzQyMTkgMjYuOTQ4MjgxOSAyNi44NTc0MjE5IDcuODk0MjEyNyAwIDE0Ljk5NTYyMi0zLjM4Mjk1MDIgMTkuOTI0MzA4NC04Ljc3MzU4MzQtMi44ODk2OTY3LTEuMzY4ODY2My01LjM5OTMxMS0zLjQwNTQzOS03LjMyODA4MzgtNS45MDk2MzU4LTMuMTIxNDMwNiAzLjIwOTQxMDQtNy40OTI5OTQ0IDUuMjA0MTI5MS0xMi4zMzIwMjU4IDUuMjA0MTI5MS05LjQ4NDM0NDQgMC0xNy4xNzI5MjQ3LTcuNjYyNjU3Mi0xNy4xNzI5MjQ3LTE3LjExNTAyMzhzNy42ODg1ODAzLTE3LjExNTAyMzcgMTcuMTcyOTI0Ny0xNy4xMTUwMjM3YzQuNzIzNDgyMiAwIDkuMDAxNTU1MiAxLjkwMDU5MzkgMTIuMTA2MjkyIDQuOTc2MzA5IDEuOTU2OTIzNy0yLjY0MTEzMSA0LjU1MDAyNjMtNC43ODU1MTgzIDcuNTUzODE3Ni02LjIwODQzMTg2eiIvPjxwYXRoIGQ9Ik01NS4zODAzMjgyIDQyLjY1MDE5OTFDNDYuMzMzNzIyNyA0Mi42NTAxOTkxIDM5IDM1LjM0MTIwMzEgMzkgMjYuMzI1MDk5NiAzOSAxNy4zMDg5OTYgNDYuMzMzNzIyNyAxMCA1NS4zODAzMjgyIDEwYzkuMDQ2NjA1NSAwIDE2LjM4MDMyODIgNy4zMDg5OTYgMTYuMzgwMzI4MiAxNi4zMjUwOTk2IDAgOS4wMTYxMDM1LTcuMzMzNzIyNyAxNi4zMjUwOTk1LTE2LjM4MDMyODIgMTYuMzI1MDk5NXptLjAyMTMwOTItNy43NTU2MzQyYzQuNzM3MDI3NiAwIDguNTc3MTQ3MS0zLjgyNzE3MiA4LjU3NzE0NzEtOC41NDgyMjc5IDAtNC43MjEwNTYtMy44NDAxMTk1LTguNTQ4MjI4LTguNTc3MTQ3MS04LjU0ODIyOC00LjczNzAyNzUgMC04LjU3NzE0NyAzLjgyNzE3Mi04LjU3NzE0NyA4LjU0ODIyOCAwIDQuNzIxMDU1OSAzLjg0MDExOTUgOC41NDgyMjc5IDguNTc3MTQ3IDguNTQ4MjI3OXoiLz48L2c+PC9zdmc+';
354 add_menu_page( 'Cookiebot', __('Cookiebot','cookiebot'), 'manage_network_options', 'cookiebot_network', array($this,'network_settings_page'),$icon);
355
356 add_submenu_page('cookiebot_network',__('Cookiebot Settings','cookiebot'),__('Settings','cookiebot'), 'network_settings_page', 'cookiebot_network',array($this,'network_settings_page'));
357 add_submenu_page('cookiebot_network',__('Cookiebot Support','cookiebot'),__('Support','cookiebot'), 'network_settings_page', 'cookiebot_support',array($this,'support_page'));
358
359 }
360
361 /**
362 * Cookiebot_WP Cookiebot prior consent placeholder page
363 *
364 * @version 1.4.0
365 * @since 1.0.0
366 */
367 function setting_page_placeholder() {
368 include __DIR__ . DIRECTORY_SEPARATOR . 'addons' . DIRECTORY_SEPARATOR . 'view/admin/settings/setting-page.php';
369 }
370
371 /**
372 * Cookiebot_WP Register Cookiebot settings
373 *
374 * @version 3.9.0
375 * @since 1.0.0
376 */
377 function register_cookiebot_settings() {
378 register_setting('cookiebot', 'cookiebot-cbid');
379 register_setting('cookiebot', 'cookiebot-language');
380 register_setting('cookiebot', 'cookiebot-nooutput');
381 register_setting('cookiebot', 'cookiebot-nooutput-admin');
382 register_setting('cookiebot', 'cookiebot-output-logged-in');
383 register_setting('cookiebot', 'cookiebot-autoupdate');
384 register_setting('cookiebot', 'cookiebot-script-tag-uc-attribute');
385 register_setting('cookiebot', 'cookiebot-script-tag-cd-attribute');
386 register_setting('cookiebot', 'cookiebot-cookie-blocking-mode');
387 register_setting('cookiebot', 'cookiebot-consent-mapping');
388 register_setting('cookiebot-iab', 'cookiebot-iab');
389 register_setting('cookiebot-legislations', 'cookiebot-ccpa');
390 register_setting('cookiebot-legislations', 'cookiebot-ccpa-domain-group-id');
391 register_setting('cookiebot-gtm', 'cookiebot-gtm');
392 register_setting('cookiebot-gtm', 'cookiebot-gtm-id');
393 register_setting('cookiebot-gtm', 'cookiebot-data-layer');
394 register_setting('cookiebot-gtm', 'cookiebot-gcm');
395 }
396
397 /**
398 * Cookiebot_WP Automatic update plugin if activated
399 *
400 * @version 2.2.0
401 * @since 1.5.0
402 */
403 function automatic_updates($update, $item) {
404 //Do not update from subsite on a multisite installation
405 if(is_multisite() && ! is_main_site()) {
406 return $update;
407 }
408
409 //Check if we have everything we need
410 $item = (array)$item;
411 if(!isset($item['new_version']) || !isset($item['slug'])) {
412 return $update;
413 }
414
415 //It is not Cookiebot
416 if($item['slug'] !== 'cookiebot') {
417 return $update;
418 }
419
420 // Check if cookiebot autoupdate is disabled
421 if(!get_option('cookiebot-autoupdate',false)) {
422 return $update;
423 }
424
425 // Check if multisite autoupdate is disabled
426 if(is_multisite() && !get_site_option('cookiebot-autoupdate',false)) {
427 return $update;
428 }
429
430 return true;
431 }
432
433
434 /**
435 * Cookiebot_WP Get list of supported languages
436 *
437 * @version 1.4.0
438 * @since 1.4.0
439 */
440 public static function get_supported_languages() {
441 $supportedLanguages = array();
442 $supportedLanguages['nb'] = __('Norwegian Bokmål','cookiebot');
443 $supportedLanguages['tr'] = __('Turkish','cookiebot');
444 $supportedLanguages['de'] = __('German','cookiebot');
445 $supportedLanguages['cs'] = __('Czech','cookiebot');
446 $supportedLanguages['da'] = __('Danish','cookiebot');
447 $supportedLanguages['sq'] = __('Albanian','cookiebot');
448 $supportedLanguages['he'] = __('Hebrew','cookiebot');
449 $supportedLanguages['ko'] = __('Korean','cookiebot');
450 $supportedLanguages['it'] = __('Italian','cookiebot');
451 $supportedLanguages['nl'] = __('Dutch','cookiebot');
452 $supportedLanguages['vi'] = __('Vietnamese','cookiebot');
453 $supportedLanguages['ta'] = __('Tamil','cookiebot');
454 $supportedLanguages['is'] = __('Icelandic','cookiebot');
455 $supportedLanguages['ro'] = __('Romanian','cookiebot');
456 $supportedLanguages['si'] = __('Sinhala','cookiebot');
457 $supportedLanguages['ca'] = __('Catalan','cookiebot');
458 $supportedLanguages['bg'] = __('Bulgarian','cookiebot');
459 $supportedLanguages['uk'] = __('Ukrainian','cookiebot');
460 $supportedLanguages['zh'] = __('Chinese','cookiebot');
461 $supportedLanguages['en'] = __('English','cookiebot');
462 $supportedLanguages['ar'] = __('Arabic','cookiebot');
463 $supportedLanguages['hr'] = __('Croatian','cookiebot');
464 $supportedLanguages['th'] = __('Thai','cookiebot');
465 $supportedLanguages['el'] = __('Greek','cookiebot');
466 $supportedLanguages['lt'] = __('Lithuanian','cookiebot');
467 $supportedLanguages['pl'] = __('Polish','cookiebot');
468 $supportedLanguages['lv'] = __('Latvian','cookiebot');
469 $supportedLanguages['fr'] = __('French','cookiebot');
470 $supportedLanguages['id'] = __('Indonesian','cookiebot');
471 $supportedLanguages['mk'] = __('Macedonian','cookiebot');
472 $supportedLanguages['et'] = __('Estonian','cookiebot');
473 $supportedLanguages['pt'] = __('Portuguese','cookiebot');
474 $supportedLanguages['ga'] = __('Irish','cookiebot');
475 $supportedLanguages['ms'] = __('Malay','cookiebot');
476 $supportedLanguages['sl'] = __('Slovenian','cookiebot');
477 $supportedLanguages['ru'] = __('Russian','cookiebot');
478 $supportedLanguages['ja'] = __('Japanese','cookiebot');
479 $supportedLanguages['hi'] = __('Hindi','cookiebot');
480 $supportedLanguages['sk'] = __('Slovak','cookiebot');
481 $supportedLanguages['es'] = __('Spanish','cookiebot');
482 $supportedLanguages['sv'] = __('Swedish','cookiebot');
483 $supportedLanguages['sr'] = __('Serbian','cookiebot');
484 $supportedLanguages['fi'] = __('Finnish','cookiebot');
485 $supportedLanguages['eu'] = __('Basque','cookiebot');
486 $supportedLanguages['hu'] = __('Hungarian','cookiebot');
487 asort($supportedLanguages,SORT_LOCALE_STRING);
488 return $supportedLanguages;
489 }
490
491 /**
492 * Cookiebot_WP Output settings page
493 *
494 * @version 3.9.0
495 * @since 1.0.0
496 */
497 function settings_page() {
498 wp_enqueue_style( 'cookiebot-consent-mapping-table', plugins_url( 'css/consent_mapping_table.css', __FILE__ ), array(), '3.5.0' );
499
500 /* Check if multisite */
501 if($is_ms = is_multisite()) {
502 //Receive settings from multisite - this might change the way we render the form
503 $network_cbid = get_site_option('cookiebot-cbid','');
504 $network_scrip_tag_uc_attr = get_site_option('cookiebot-script-tag-uc-attribute','custom');
505 $network_scrip_tag_cd_attr = get_site_option('cookiebot-script-tag-cd-attribute','custom');
506 $network_cookie_blocking_mode = get_site_option('cookiebot-cookie-blocking-mode','manual');
507 }
508 ?>
509 <div class="wrap">
510 <h1><?php _e('Cookiebot Settings','cookiebot'); ?></h1>
511 <a href="https://www.cookiebot.com">
512 <img src="<?php echo plugins_url( 'cookiebot-logo.png', __FILE__ ); ?>" style="float:right;margin-left:1em;">
513 </a>
514 <p>
515 <?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'); ?>
516 </p>
517 <form method="post" action="options.php">
518 <?php settings_fields( 'cookiebot' ); ?>
519 <?php do_settings_sections( 'cookiebot' ); ?>
520 <table class="form-table">
521 <tr valign="top">
522 <th scope="row"><?php _e('Cookiebot ID','cookiebot'); ?></th>
523 <td>
524 <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" />
525 <p class="description">
526 <?php _e('Need an ID?','cookiebot'); ?>
527 <a href="https://www.cookiebot.com/goto/signup" target="_blank"><?php _e('Sign up for free on cookiebot.com','cookiebot'); ?></a>
528 </p>
529 </td>
530 </tr>
531 <tr valign="top">
532 <th scope="row">
533 <?php _e('Cookie-blocking mode','cookiebot'); ?>
534 </th>
535 <td>
536 <?php
537 $cbm = get_option('cookiebot-cookie-blocking-mode','manual');
538 if($is_ms && $network_cookie_blocking_mode != 'custom') {
539 $cbm = $network_cookie_blocking_mode;
540 }
541 ?>
542 <label>
543 <input type="radio" name="cookiebot-cookie-blocking-mode" value="auto" <?php checked('auto', $cbm, true); ?> />
544 <?php _e('Automatic','cookiebot'); ?>
545 </label>
546 &nbsp; &nbsp;
547 <label>
548 <input type="radio" name="cookiebot-cookie-blocking-mode" value="manual" <?php checked('manual',$cbm, true); ?> />
549 <?php _e('Manual','cookiebot'); ?>
550 </label>
551 <p class="description">
552 <?php _e('Automatic block cookies (except necessary) until the user has given their consent.','cookiebot') ?>
553 <a href="https://support.cookiebot.com/hc/en-us/articles/360009063100-Automatic-Cookie-Blocking-How-does-it-work-" target="_blank">
554 <?php _e('Learn more','cookiebot'); ?>
555 </a>
556 </p>
557 <script>
558 jQuery(document).ready(function($) {
559 var cookieBlockingMode = '<?php echo $cbm; ?>';
560 $( 'input[type=radio][name=cookiebot-cookie-blocking-mode]' ).on( 'change', function() {
561 if(this.value == 'auto' && cookieBlockingMode != this.value ) {
562 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 );
563 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true );
564 }
565 if( this.value == 'manual' && cookieBlockingMode != this.value ) {
566 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 1 );
567 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', false );
568 }
569 cookieBlockingMode = this.value;
570 });
571 if( cookieBlockingMode == 'auto' ) {
572 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 );
573 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true );
574 }
575 });
576 </script>
577 </td>
578 </tr>
579 <tr valign="top">
580 <th scope="row"><?php _e('Cookiebot Language','cookiebot'); ?></th>
581 <td>
582 <div>
583 <select name="cookiebot-language" id="cookiebot-language">
584 <?php
585 $currentLang = $this->get_language(true);
586 ?>
587 <option value=""><?php _e('Default (Autodetect)','cookiebot'); ?></option>
588 <option value="_wp"<?php echo ($currentLang == '_wp') ? ' selected' : ''; ?>><?php _e('Use Wordpress Language','cookiebot'); ?></option>
589 <?php
590 $supportedLanguages = $this->get_supported_languages();
591 foreach($supportedLanguages as $langCode=>$langName) {
592 echo '<option value="'.$langCode.'"'.(($currentLang==$langCode) ? ' selected' : '').'>'.$langName.'</option>';
593 }
594 ?>
595 </select>
596 </div>
597 <div class="notice inline notice-warning notice-alt cookiebot-notice" style="padding:12px;font-size:13px;display:inline-block;">
598 <div style="<?php echo ($currentLang=='') ? 'display:none;' : '' ?>" id="info_lang_specified">
599 <?php _e('You need to add the language in the Cookiebot administration tool.'); ?>
600 </div>
601 <div style="<?php echo ($currentLang=='') ? '' : 'display:none;' ?>" id="info_lang_autodetect">
602 <?php _e('You need to add all languages that you want auto-detected in the Cookiebot administration tool.'); ?> <br/>
603 <?php _e('The auto-detect checkbox needs to be enabled in the Cookiebot administration tool.'); ?><br/>
604 <?php _e('If the auto-detected language is not supported, Cookiebot will use the default language.'); ?>
605 </div>
606 <br />
607
608 <a href="#" id="show_add_language_guide"><?php _e('Show guide to add languages'); ?></a>
609 &nbsp;
610 <a href="https://support.cookiebot.com/hc/en-us/articles/360003793394-How-do-I-set-the-language-of-the-consent-banner-dialog-" target="_blank">
611 <?php _e('Read more here'); ?>
612 </a>
613
614 <div id="add_language_guide" style="display:none;">
615 <img src="<?php echo plugin_dir_url( __FILE__ ); ?>/assets/guide_add_language.gif" alt="Add language in Cookiebot administration tool" />
616 <br />
617 <a href="#" id="hide_add_language_guide"><?php _e('Hide guide'); ?></a>
618 </div>
619 </div>
620 <script>
621 jQuery(document).ready(function($) {
622 $('#show_add_language_guide').on('click',function(e) {
623 e.preventDefault();
624 $('#add_language_guide').slideDown();
625 $(this).hide();
626 });
627 $('#hide_add_language_guide').on('click',function(e) {
628 e.preventDefault();
629 $('#add_language_guide').slideUp();
630 $('#show_add_language_guide').show();
631 });
632
633 $('#cookiebot-language').on('change', function() {
634 if(this.value == '') {
635 $('#info_lang_autodetect').show();
636 $('#info_lang_specified').hide();
637 }
638 else {
639 $('#info_lang_autodetect').hide();
640 $('#info_lang_specified').show();
641 }
642 });
643 });
644 </script>
645
646 </td>
647 </tr>
648 </table>
649 <script>
650 jQuery(document).ready(function($) {
651 $('.cookiebot_fieldset_header').on('click',function(e) {
652 e.preventDefault();
653 $(this).next().slideToggle();
654 $(this).toggleClass('active');
655 });
656 });
657 </script>
658 <style type="text/css">
659 .cookiebot_fieldset_header {
660 cursor:pointer;
661 }
662 .cookiebot_fieldset_header::after {
663 content: "\f140";
664 font: normal 24px/1 dashicons;
665 position: relative;
666 top: 5px;
667 }
668 .cookiebot_fieldset_header.active::after {
669 content: "\f142";
670 }
671 </style>
672 <h3 id="advanced_settings_link" class="cookiebot_fieldset_header"><?php _e('Advanced settings', 'cookiebot'); ?></h3>
673 <div id="advanced_settings" style="display:none;">
674 <table class="form-table">
675 <tr valign="top" id="cookiebot-setting-async">
676 <th scope="row">
677 <?php _e('Add async or defer attribute','cookiebot'); ?>
678 <br /><?php _e('Consent banner script tag'); ?>
679 </th>
680 <td>
681 <?php
682 $cv = get_option('cookiebot-script-tag-uc-attribute','async');
683 $disabled = false;
684 if($is_ms && $network_scrip_tag_uc_attr != 'custom') {
685 $disabled = true;
686 $cv = $network_scrip_tag_uc_attr;
687 }
688 ?>
689 <label>
690 <input type="radio" name="cookiebot-script-tag-uc-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="" <?php checked('', $cv, true); ?> />
691 <i>None</i>
692 </label>
693 &nbsp; &nbsp;
694 <label>
695 <input type="radio" name="cookiebot-script-tag-uc-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="async" <?php checked('async',$cv, true); ?> />
696 async
697 </label>
698 &nbsp; &nbsp;
699 <label>
700 <input type="radio" name="cookiebot-script-tag-uc-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="defer" <?php checked('defer',$cv, true); ?> />
701 defer
702 </label>
703 <p class="description">
704 <?php if($disabled) { echo '<b>'._('Network setting applied. Please contact website administrator to change this setting.').'</b><br />'; } ?>
705 <?php _e('Add async or defer attribute to Cookiebot script tag. Default: async','cookiebot') ?>
706 </p>
707 </td>
708 </tr>
709 <tr valign="top">
710 <th scope="row">
711 <?php _e('Add async or defer attribute','cookiebot'); ?>
712 <br /><?php _e('Cookie declaration script tag'); ?>
713 </th>
714 <td>
715 <?php
716 $cv = get_option('cookiebot-script-tag-cd-attribute','async');
717 $disabled = false;
718 if($is_ms && $network_scrip_tag_cd_attr != 'custom') {
719 $disabled = true;
720 $cv = $network_scrip_tag_cd_attr;
721 }
722 ?>
723 <label>
724 <input type="radio" name="cookiebot-script-tag-cd-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="" <?php checked('', $cv, true); ?> />
725 <i>None</i>
726 </label>
727 &nbsp; &nbsp;
728 <label>
729 <input type="radio" name="cookiebot-script-tag-cd-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="async" <?php checked('async',$cv, true); ?> />
730 async
731 </label>
732 &nbsp; &nbsp;
733 <label>
734 <input type="radio" name="cookiebot-script-tag-cd-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="defer" <?php checked('defer',$cv, true); ?> />
735 defer
736 </label>
737 <p class="description">
738 <?php if($disabled) { echo '<b>'._('Network setting applied. Please contact website administrator to change this setting.').'</b><br />'; } ?>
739 <?php _e('Add async or defer attribute to Cookiebot script tag. Default: async','cookiebot') ?>
740 </p>
741 </td>
742 </tr>
743 <?php
744 if(!is_multisite()) {
745 ?>
746 <tr valign="top">
747 <th scope="row"><?php _e('Auto-update Cookiebot','cookiebot'); ?></th>
748 <td>
749 <input type="checkbox" name="cookiebot-autoupdate" value="1" <?php checked(1,get_option('cookiebot-autoupdate',false), true); ?> />
750 <p class="description">
751 <?php _e('Automatic update your Cookiebot plugin when new releases becomes available.','cookiebot') ?>
752 </p>
753 </td>
754 </tr>
755 <?php
756 }
757 ?>
758 <tr valign="top" id="cookiebot-setting-hide-popup">
759 <th scope="row"><?php _e('Hide Cookie Popup','cookiebot'); ?></th>
760 <td>
761 <?php
762 $disabled = false;
763 if($is_ms && get_site_option('cookiebot-nooutput',false)) {
764 $disabled = true;
765 echo '<input type="checkbox" checked disabled />';
766 }
767 else {
768 ?>
769 <input type="checkbox" name="cookiebot-nooutput" value="1" <?php checked(1,get_option('cookiebot-nooutput',false), true); ?> />
770 <?php
771 }
772 ?>
773 <p class="description">
774 <?php if($disabled) { echo '<b>'._('Network setting applied. Please contact website administrator to change this setting.').'</b><br />'; } ?>
775 <b><?php _e('This checkbox will remove the cookie consent banner from your website. The <i>[cookie_declaration]</i> shortcode will still be available.','cookiebot') ?></b><br />
776 <?php _e('If you are using Google Tag Manager (or equal), you need to add the Cookiebot script in your Tag Manager.','cookiebot') ?><br />
777 <?php _e('<a href="https://support.cookiebot.com/hc/en-us/articles/360003793854-Google-Tag-Manager-deployment" target="_blank">See a detailed guide here</a>','cookiebot') ?>
778 </p>
779 </td>
780 </tr>
781 <tr valign="top">
782 <th scope="row"><?php _e('Disable Cookiebot in WP Admin','cookiebot'); ?></th>
783 <td>
784 <?php
785 $disabled = false;
786 if($is_ms && get_site_option('cookiebot-nooutput-admin',false)) {
787 echo '<input type="checkbox" checked disabled />';
788 $disabled = true;
789 }
790 else {
791 ?>
792 <input type="checkbox" name="cookiebot-nooutput-admin" value="1" <?php checked(1,get_option('cookiebot-nooutput-admin',false), true); ?> />
793 <?php
794 }
795 ?>
796 <p class="description">
797 <?php if($disabled) { echo '<b>'._('Network setting applied. Please contact website administrator to change this setting.').'</b><br />'; } ?>
798 <b><?php _e('This checkbox will disable Cookiebot in the Wordpress Admin area.','cookiebot') ?></b>
799 </p>
800 </td>
801 </tr>
802 <tr valign="top">
803 <th scope="row"><?php _e('Enable Cookiebot on front end while logged in','cookiebot'); ?></th>
804 <td>
805 <?php
806 $disabled = false;
807 if($is_ms && get_site_option('cookiebot-output-logged-in',false)) {
808 echo '<input type="checkbox" checked disabled />';
809 $disabled = true;
810 }
811 else {
812 ?>
813 <input type="checkbox" name="cookiebot-output-logged-in" value="1" <?php checked(1,get_option('cookiebot-output-logged-in',false), true); ?> />
814 <?php
815 }
816 ?>
817 <p class="description">
818 <?php if($disabled) { echo '<b>'._('Network setting applied. Please contact website administrator to change this setting.').'</b><br />'; } ?>
819 <b><?php _e('This checkbox will enable Cookiebot on front end while you\'re logged in','cookiebot') ?></b>
820 </p>
821 </td>
822 </tr>
823 </table>
824 </div>
825 <?php if($this->is_wp_consent_api_active()) { ?>
826 <h3 id="consent_level_api_settings" class="cookiebot_fieldset_header"><?php _e('Consent Level API Settings', 'cookiebot'); ?></h3>
827 <div id="consent_level_api_settings" style="display:none;">
828 <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>
829
830 <?php
831 $mDefault = $this->get_default_wp_consent_api_mapping();
832
833 $m = $this->get_wp_consent_api_mapping();
834
835 $consentTypes = ['preferences', 'statistics', 'marketing'];
836 $states = array_reduce($consentTypes, function ($t, $v) {
837 $newt = [];
838 if (empty($t)) {
839 $newt = [
840 [$v => true],
841 [$v => false],
842 ];
843 } else {
844 foreach ($t as $item) {
845 $newt[] = array_merge($item, [$v => true]);
846 $newt[] = array_merge($item, [$v => false]);
847 }
848 }
849
850 return $newt;
851 }, []);
852
853 ?>
854
855
856 <table class="widefat striped consent_mapping_table">
857 <thead>
858 <tr>
859 <th><?php _e('Cookiebot categories','cookiebot'); ?></th>
860 <th class="consent_mapping"><?php _e('WP Consent Level categories','cookiebot'); ?></th>
861 </tr>
862 </thead>
863 <?php
864 foreach($states as $state) {
865
866 $key = [];
867 $key[] = 'n=1';
868 $key[] = 'p='.($state['preferences'] ? '1' : '0');
869 $key[] = 's='.($state['statistics'] ? '1' : '0');
870 $key[] = 'm='.($state['marketing'] ? '1' : '0');
871 $key = implode(';',$key);
872 ?>
873 <tr valign="top">
874 <td>
875 <div class="cb_consent">
876 <span class="forceconsent">Necessary</span>
877 <span class="<?php echo ($state['preferences'] ? 'consent' : 'noconsent'); ?>"><?php _e('Preferences','cookiebot'); ?></span>
878 <span class="<?php echo ($state['statistics'] ? 'consent' : 'noconsent'); ?>"><?php _e('Statistics','cookiebot'); ?></span>
879 <span class="<?php echo ($state['marketing'] ? 'consent' : 'noconsent'); ?>"><?php _e('Marketing','cookiebot'); ?></span>
880 </div>
881 </td>
882 <td>
883 <div class="consent_mapping">
884 <label><input type="checkbox" name="cookiebot-consent-mapping[<?php echo $key; ?>][functional]" data-default-value="1" value="1" checked disabled> Functional </label>
885 <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'; } ?>> <?php _e('Preferences','cookiebot'); ?> </label>
886 <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'; } ?>> <?php _e('Statistics','cookiebot'); ?> </label>
887 <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'; } ?>> <?php _e('Statistics Anonymous','cookiebot'); ?></label>
888 <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'; } ?>> <?php _e('Marketing','cookiebot'); ?></label>
889 </div>
890 </td>
891 </tr>
892 <?php
893 }
894 ?>
895 <tfoot>
896 <tr>
897 <td colspan="2" style="text-align:right;"><button class="button" onclick="return resetConsentMapping();"><?php _e('Reset to default mapping','cookiebot'); ?></button></td>
898 </tr>
899 </tfoot>
900 </table>
901 <script>
902 function resetConsentMapping() {
903 if(confirm('Are you sure you want to reset to default consent mapping?')) {
904 jQuery('.consent_mapping_table input[type=checkbox]').each(function () {
905 if(!this.disabled) {
906 this.checked = (jQuery(this).data('default-value') == '1') ? true : false;
907 }
908 });
909 }
910 return false;
911 }
912 </script>
913 </div>
914 <?php } ?>
915 <?php submit_button(); ?>
916 </form>
917 </div>
918 <?php
919 }
920
921 /**
922 * Cookiebot_WP Cookiebot network setting page
923 *
924 * @version 2.2.0
925 * @since 2.2.0
926 */
927 function network_settings_page() {
928 ?>
929 <div class="wrap">
930 <h1><?php _e('Cookiebot Network Settings','cookiebot'); ?></h1>
931 <a href="https://www.cookiebot.com">
932 <img src="<?php echo plugins_url( 'cookiebot-logo.png', __FILE__ ); ?>" style="float:right;margin-left:1em;">
933 </a>
934 <p>
935 <?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'); ?>
936 </p>
937 <p>
938 <b><big style="color:red;"><?php _e('The settings below is network wide settings. See notes below each field.','cookiebot'); ?></big></b>
939 </p>
940 <form method="post" action="edit.php?action=cookiebot_network_settings">
941 <?php wp_nonce_field( 'cookiebot-network-settings' ); ?>
942 <table class="form-table">
943 <tr valign="top">
944 <th scope="row"><?php _e('Network Cookiebot ID','cookiebot'); ?></th>
945 <td>
946 <input type="text" name="cookiebot-cbid" value="<?php echo esc_attr( get_site_option('cookiebot-cbid','') ); ?>" style="width:300px" />
947 <p class="description">
948 <b><?php _e('If added this will be the default Cookiebot ID for all subsites. Subsites are able to override the Cookiebot ID.','cookiebot'); ?></b>
949 <br />
950 <?php _e('Need an ID?','cookiebot'); ?>
951 <a href="https://www.cookiebot.com/goto/signup" target="_blank"><?php _e('Sign up for free on cookiebot.com','cookiebot'); ?></a>
952 </p>
953 </td>
954 </tr>
955 <tr valign="top">
956 <th scope="row">
957 <?php _e('Cookie-blocking mode','cookiebot'); ?>
958 </th>
959 <td>
960 <?php
961 $cbm = get_site_option('cookiebot-cookie-blocking-mode','manual');
962 ?>
963 <label>
964 <input type="radio" name="cookiebot-cookie-blocking-mode" value="auto" <?php checked('auto', $cbm, true); ?> />
965 <?php _e('Automatic','cookiebot'); ?>
966 </label>
967 &nbsp; &nbsp;
968 <label>
969 <input type="radio" name="cookiebot-cookie-blocking-mode" value="manual" <?php checked('manual',$cbm, true); ?> />
970 <?php _e('Manual','cookiebot'); ?>
971 </label>
972 <p class="description">
973 <?php _e('Should Cookiebot automatic block cookies by tagging known tags.','cookiebot') ?>
974 </p>
975 </td>
976 </tr>
977 <script>
978 jQuery(document).ready(function($) {
979 var cookieBlockingMode = '<?php echo $cbm; ?>';
980 $( 'input[type=radio][name=cookiebot-cookie-blocking-mode]' ).on( 'change', function() {
981 if(this.value == 'auto' && cookieBlockingMode != this.value ) {
982 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 );
983 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true );
984 }
985 if( this.value == 'manual' && cookieBlockingMode != this.value ) {
986 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 1 );
987 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', false );
988 }
989 cookieBlockingMode = this.value;
990 });
991 if( cookieBlockingMode == 'auto' ) {
992 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 );
993 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true );
994 }
995 });
996 </script>
997 <tr valign="top" id="cookiebot-setting-async">
998 <th scope="row">
999 <?php _e('Add async or defer attribute','cookiebot'); ?>
1000 <br /><?php _e('Consent banner script tag'); ?>
1001 </th>
1002 <td>
1003 <?php
1004 $cv = get_site_option('cookiebot-script-tag-uc-attribute','custom');
1005 ?>
1006 <label>
1007 <input type="radio" name="cookiebot-script-tag-uc-attribute" value="" <?php checked('', $cv, true); ?> />
1008 <i><?php _e('None','cookiebot'); ?></i>
1009 </label>
1010 &nbsp; &nbsp;
1011 <label>
1012 <input type="radio" name="cookiebot-script-tag-uc-attribute" value="async" <?php checked('async',$cv, true); ?> />
1013 async
1014 </label>
1015 &nbsp; &nbsp;
1016 <label>
1017 <input type="radio" name="cookiebot-script-tag-uc-attribute" value="defer" <?php checked('defer',$cv, true); ?> />
1018 defer
1019 </label>
1020 &nbsp; &nbsp;
1021 <label>
1022 <input type="radio" name="cookiebot-script-tag-uc-attribute" value="custom" <?php checked('custom',$cv, true); ?> />
1023 <i><?php _e('Choose per subsite','cookiebot'); ?></i>
1024 </label>
1025 <p class="description">
1026 <b><?php _e('Setting will apply for all subsites. Subsites will not be able to override.','cookiebot'); ?></b><br />
1027 <?php _e('Add async or defer attribute to Cookiebot script tag. Default: Choose per subsite','cookiebot') ?>
1028 </p>
1029 </td>
1030 </tr>
1031 <tr valign="top">
1032 <th scope="row">
1033 <?php _e('Add async or defer attribute','cookiebot'); ?>
1034 <br /><?php _e('Cookie declaration script tag','cookiebot'); ?>
1035 </th>
1036 <td>
1037 <?php
1038 $cv = get_site_option('cookiebot-script-tag-cd-attribute','custom');
1039 ?>
1040 <label>
1041 <input type="radio" name="cookiebot-script-tag-cd-attribute" value="" <?php checked('', $cv, true); ?> />
1042 <i><?php _e('None','cookiebot'); ?></i>
1043 </label>
1044 &nbsp; &nbsp;
1045 <label>
1046 <input type="radio" name="cookiebot-script-tag-cd-attribute" value="async" <?php checked('async',$cv, true); ?> />
1047 async
1048 </label>
1049 &nbsp; &nbsp;
1050 <label>
1051 <input type="radio" name="cookiebot-script-tag-cd-attribute" value="defer" <?php checked('defer',$cv, true); ?> />
1052 defer
1053 </label>
1054 &nbsp; &nbsp;
1055 <label>
1056 <input type="radio" name="cookiebot-script-tag-cd-attribute" value="custom" <?php checked('custom',$cv, true); ?> />
1057 <i><?php _e('Choose per subsite','cookiebot'); ?></i>
1058 </label>
1059 <p class="description">
1060 <b><?php _e('Setting will apply for all subsites. Subsites will not be able to override.','cookiebot'); ?></b><br />
1061 <?php _e('Add async or defer attribute to Cookiebot script tag. Default: Choose per subsite','cookiebot') ?>
1062 </p>
1063 </td>
1064 </tr>
1065 <tr valign="top">
1066 <th scope="row"><?php _e('Auto-update Cookiebot','cookiebot'); ?></th>
1067 <td>
1068 <input type="checkbox" name="cookiebot-autoupdate" value="1" <?php checked(1,get_site_option('cookiebot-autoupdate',false), true); ?> />
1069 <p class="description">
1070 <?php _e('Automatic update your Cookiebot plugin when new releases becomes available.','cookiebot') ?>
1071 </p>
1072 </td>
1073 </tr>
1074 <tr valign="top" id="cookiebot-setting-hide-popup">
1075 <th scope="row"><?php _e('Hide Cookie Popup','cookiebot'); ?></th>
1076 <td>
1077 <input type="checkbox" name="cookiebot-nooutput" value="1" <?php checked(1,get_site_option('cookiebot-nooutput',false), true); ?> />
1078 <p class="description">
1079 <b><?php _e('Remove the cookie consent banner from all subsites. This cannot be changed by subsites. The <i>[cookie_declaration]</i> shortcode will still be available.','cookiebot') ?></b><br />
1080 <?php _e('If you are using Google Tag Manager (or equal), you need to add the Cookiebot script in your Tag Manager.','cookiebot') ?><br />
1081 <?php _e('<a href="https://support.cookiebot.com/hc/en-us/articles/360003793854-Google-Tag-Manager-deployment" target="_blank">See a detailed guide here</a>','cookiebot') ?>
1082 </p>
1083 </td>
1084 </tr>
1085 <tr valign="top">
1086 <th scope="row"><?php _e('Hide Cookie Popup in WP Admin','cookiebot'); ?></th>
1087 <td>
1088 <input type="checkbox" name="cookiebot-nooutput-admin" value="1" <?php checked(1,get_site_option('cookiebot-nooutput-admin',false), true); ?> />
1089 <p class="description">
1090 <b><?php _e('Remove the cookie consent banner the Wordpress Admin area for all subsites. This cannot be changed by subsites.','cookiebot') ?></b>
1091 </p>
1092 </td>
1093 </tr>
1094 </table>
1095 <?php submit_button(); ?>
1096 </form>
1097 </div>
1098 <?php
1099 }
1100
1101
1102 /**
1103 * Cookiebot_WP Cookiebot save network settings
1104 *
1105 * @version 2.2.0
1106 * @since 2.2.0
1107 */
1108 function network_settings_save() {
1109 check_admin_referer( 'cookiebot-network-settings' );
1110
1111 update_site_option('cookiebot-cbid', $_POST['cookiebot-cbid'] );
1112 update_site_option('cookiebot-script-tag-uc-attribute', $_POST['cookiebot-script-tag-uc-attribute'] );
1113 update_site_option('cookiebot-script-tag-cd-attribute', $_POST['cookiebot-script-tag-cd-attribute'] );
1114 update_site_option('cookiebot-autoupdate', $_POST['cookiebot-autoupdate'] );
1115 update_site_option('cookiebot-nooutput', $_POST['cookiebot-nooutput'] );
1116 update_site_option('cookiebot-nooutput-admin', $_POST['cookiebot-nooutput-admin'] );
1117 update_site_option('cookiebot-cookie-blocking-mode', $_POST['cookiebot-cookie-blocking-mode'] );
1118
1119
1120 wp_redirect( add_query_arg( array(
1121 'page' => 'cookiebot_network',
1122 'updated' => true ), network_admin_url('admin.php')
1123 ));
1124 exit;
1125 }
1126
1127 /**
1128 * Cookiebot_WP Cookiebot support page
1129 *
1130 * @version 2.2.0
1131 * @since 2.0.0
1132 */
1133 function support_page() {
1134 ?>
1135 <div class="wrap">
1136 <h1><?php _e('Support','cookiebot'); ?></h1>
1137 <h2><?php _e('How to find my Cookiebot ID','cookiebot'); ?></h2>
1138 <p>
1139 <ol>
1140 <li><?php _e('Log in to your <a href="https://www.cookiebot.com/goto/account" target="_blank">Cookiebot account</a>.','cookiebot'); ?></li>
1141 <li><?php _e('Go to <b>Manage</b> > <b>Settings</b> and add setup your Cookiebot','cookiebot'); ?></li>
1142 <li><?php _e('Go to the <b>"Your scripts"</b> tab','cookiebot'); ?></li>
1143 <li><?php _e('Copy the value inside the data-cid parameter - eg.: abcdef12-3456-7890-abcd-ef1234567890','cookiebot'); ?></li>
1144 <li><?php _e('Add <b>[cookie_declaration]</b> shortcode to a page to show the declation','cookiebot'); ?></li>
1145 <li><?php _e('Remember to change your scripts as descripted below','cookiebot'); ?></li>
1146 </ol>
1147 </p>
1148 <h2><?php _e('Add the Cookie Declaration to your website'); ?></h2>
1149 <p>
1150 <?php _e('Use the shortcode <b>[cookie_declaration]</b> to add the cookie declaration a page or post. The cookie declaration will always show the latest version from Cookiebot.','cookiebot'); ?>
1151 <br />
1152 <?php _e('If you need to force language of the cookie declaration, you can add the <i>lang</i> attribute. Eg. <b>[cookie_declaration lang="de"]</b>.','cookiebot'); ?>
1153 </p>
1154 <p>
1155 <a href="https://www.youtube.com/watch?v=OCXz2bt4H_w" target="_blank" class="button"><?php _e('Watch video demonstration','cookiebot'); ?></a>
1156 </p>
1157 <h2><?php _e('Update your script tags','cookiebot'); ?></h2>
1158 <p>
1159 <?php _e('To enable prior consent, apply the attribute "data-cookieconsent" to cookie-setting script tags on your website. Set the comma-separated value to one or more of the cookie categories "preferences", "statistics" and "marketing" in accordance with the types of cookies being set by each script. Finally change the attribute "type" from "text/javascript" to "text/plain". Example on modifying an existing Google Analytics Universal script tag.','cookiebot'); ?>
1160 </p>
1161 <code>
1162 <?php
1163 echo htmlentities("<script type=\"text/plain\" data-cookieconsent=\"statistics\">").'<br />';
1164 echo htmlentities("(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');").'<br />';
1165 echo htmlentities("ga('create', 'UA-00000000-0', 'auto');").'<br />';
1166 echo htmlentities("ga('send', 'pageview');").'<br />';
1167 echo htmlentities("</script>").'<br />';
1168 ?>
1169 </code>
1170 <p>
1171 <a href="https://www.youtube.com/watch?v=MeHycvV2QCQ" target="_blank" class="button"><?php _e('Watch video demonstration','cookiebot'); ?></a>
1172 </p>
1173
1174 <h2><?php _e('Helper function to update your scripts','cookiebot'); ?></h2>
1175 <p>
1176 <?php _e('You are able to update your scripts yourself. However, Cookiebot also offers a small helper function that makes the work easier.','cookiebot'); ?>
1177 <br />
1178 <?php _e('Update your script tags this way:','cookiebot'); ?>
1179 </p>
1180 <?php
1181 printf(
1182 __('%s to %s'),
1183 '<code>'.htmlentities('<script type="text/javascript">').'</code>',
1184 '<code>'.htmlentities('<script<?php echo cookiebot_assist(\'marketing\') ?>>').'</code>'
1185 );
1186 ?>
1187 </div>
1188 <?php
1189 }
1190
1191 /**
1192 * Cookiebot_WP Google Tag Manager page
1193 *
1194 * @version 3.8.1
1195 * @since 3.8.1
1196 */
1197
1198 function GTM_page(){
1199 ?>
1200 <div class="wrap">
1201 <h1><?php _e('Google Tag Manager', 'cookiebot')?></h1>
1202
1203 <form method="post" action="options.php" style="display: grid; grid-template-columns: 35% 65%; grid-row-gap: 20px; width: 700px; align-items: center;">
1204 <?php settings_fields( 'cookiebot-gtm' ); ?>
1205 <?php do_settings_sections( 'cookiebot-gtm' ); ?>
1206
1207 <p><?php _e('Enable GTM', 'cookiebot')?></p>
1208 <div class="GTM_check">
1209 <input type="checkbox" name="cookiebot-gtm" id="cookiebot-gtm" value="1" <?php checked(1,get_option('cookiebot-gtm'), true); ?> style="float: left; margin: 2px 4px 0 0">
1210 <p style="margin: 0; font-style: italic;"><?php _e('For more details about Cookiebot and Google Tag Manager click', 'cookiebot') ?><a target="_blank" href="https://www.cookiebot.com/en/google-tag-manager-and-gdpr-compliance-with-cookiebot/" style="margin: 0; font-style: italic;">&nbsp;<?php _e('here', 'cookiebot')?></a></p>
1211 </div>
1212
1213 <p><?php _e('GTM ID', 'cookiebot')?></p>
1214 <input type="text" name="cookiebot-gtm-id" id="cookiebot-gtm-id" value="<?php echo get_option('cookiebot-gtm-id'); ?>" style="height: 30px;">
1215
1216 <p><?php _e('DataLayer name', 'cookiebot')?></p>
1217 <div>
1218 <input type="text" name="cookiebot-data-layer" id="data_layer" placeholder="dataLayer" value="<?php echo get_option('cookiebot-data-layer'); ?>" style="height: 30px;">
1219 <p style="margin: 0;"><?php _e('Optional, only change if necessary', 'cookiebot')?></p>
1220 </div>
1221
1222 <p><?php _e('Google Consent Mode', 'cookiebot')?></p>
1223 <div class="GTM_check">
1224 <input type="checkbox" name="cookiebot-gcm" id="gcm" value="1" <?php checked(1,get_option('cookiebot-gcm'), true); ?> style="float: left; margin: 2px 4px 0 0">
1225 <p style="margin: 0; font-style: italic;"><?php _e('For more details about Cookiebot and Google Consent Mode click', 'cookiebot') ?><a target="_blank" href="https://support.cookiebot.com/hc/en-us/articles/360016047000-Cookiebot-and-Google-Consent-Mode" style="margin: 0; font-style: italic;">&nbsp;<?php _e('here', 'cookiebot')?></a></p>
1226 </div>
1227 <input type="submit" value="Save" name="gtm_save" style="background-color: rgb(0, 124, 186); color: white; padding: 5px 10px; border: none; border-radius: 5px; justify-self: start;">
1228 </form>
1229 </div>
1230 <?php
1231 }
1232
1233 /**
1234 * Cookiebot_WP Cookiebot IAB page
1235 *
1236 * @version 2.0.0
1237 * @since 2.0.0
1238 */
1239 function iab_page() {
1240 ?>
1241 <div class="wrap">
1242 <h1><?php _e('IAB','cookiebot'); ?></h1>
1243
1244 <p>For more details about Cookiebot's IAB integration, see <a href="https://support.cookiebot.com/hc/en-us/articles/360007652694-Cookiebot-and-the-IAB-Consent-Framework" target="_blank">article about cookiebot and the IAB consent framework</a></p>
1245
1246 <form method="post" action="options.php">
1247 <?php settings_fields( 'cookiebot-iab' ); ?>
1248 <?php do_settings_sections( 'cookiebot-iab' ); ?>
1249
1250 <label>Enable IAB integration</label>
1251 <input type="checkbox" name="cookiebot-iab" value="1" <?php checked(1,get_option('cookiebot-iab'), true); ?>>
1252
1253 <?php submit_button(); ?>
1254 </form>
1255 </div>
1256 <?php
1257 }
1258
1259 /**
1260 * Cookiebot_WP Cookiebot legislations page
1261 *
1262 * @version 3.6.6
1263 * @since 3.6.6
1264 */
1265 function legislations_page() {
1266 ?>
1267 <div class="wrap">
1268 <h1><?php _e('Legislations','cookiebot'); ?></h1>
1269
1270 <p>For more details about Cookiebot's CCPA Legislation integration, see <a href="https://support.cookiebot.com/hc/en-us/articles/360010932419-Use-multiple-banners-on-the-same-website-support-both-CCPA-GDPR-compliance-" target="_blank">article about cookiebot and the CCPA compliance</a></p>
1271
1272 <form method="post" action="options.php">
1273 <?php settings_fields( 'cookiebot-legislations' ); ?>
1274 <?php do_settings_sections( 'cookiebot-legislations' ); ?>
1275
1276
1277 <table class="form-table">
1278 <tbody>
1279 <tr valign="top">
1280 <th scope="row"><label>Enable CCPA configuration for visitors from California</label></th>
1281 <td>
1282 <input type="checkbox" name="cookiebot-ccpa" value="1" <?php checked(1,get_option('cookiebot-ccpa'), true); ?>>
1283 </td>
1284 </tr>
1285 <tr>
1286 <th valign="top"><label>Domain Group ID</label></th>
1287 <td>
1288 <input type="text" style="width: 300px;" name="cookiebot-ccpa-domain-group-id" value="<?php echo get_option('cookiebot-ccpa-domain-group-id'); ?>">
1289 </td>
1290 </tr>
1291 </tbody>
1292 </table>
1293
1294 <?php submit_button(); ?>
1295 </form>
1296 </div>
1297 <?php
1298 }
1299
1300 /**
1301 * Cookiebot_WP Debug Page
1302 *
1303 * @version 3.9.
1304 * @since 3.6.0
1305 */
1306
1307 function debug_page() {
1308 global $wpdb;
1309
1310 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
1311 $plugins = get_plugins();
1312 $active_plugins = get_option( 'active_plugins' );
1313
1314
1315 //$foo = new cookiebot_addons\lib\Settings_Service;
1316 //$addons = $foo->get_active_addons();
1317
1318 $debugStr = "";
1319 $debugStr.= "##### Debug Information for ".get_site_url()." generated at ".date("c")." #####\n\n";
1320 $debugStr.= "Wordpress Version: ".get_bloginfo('version')."\n";
1321 $debugStr.= "Wordpress Language: ".get_bloginfo('language')."\n";
1322 $debugStr.= "PHP Version: ".phpversion()."\n";
1323 $debugStr.= "MySQL Version: ".$wpdb->db_version()."\n";
1324 $debugStr.= "\n--- Cookiebot Information ---\n";
1325 $debugStr.= "Plugin Version: ".$this->version."\n";
1326 $debugStr.= "Cookiebot ID: ".$this->get_cbid()."\n";
1327 $debugStr.= "Blocking mode: ".get_option('cookiebot-cookie-blocking-mode')."\n";
1328 $debugStr.= "Language: ".get_option('cookiebot-language')."\n";
1329 $debugStr.= "IAB: ".(get_option('cookiebot-iab') == '1' ? 'Enabled' : 'Not enabled')."\n";
1330 $debugStr.= "CCPA banner for visitors from California: ".(get_option('cookiebot-ccpa') == '1' ? 'Enabled' : 'Not enabled')."\n";
1331 $debugStr.= "CCPA domain group id: ". get_option('cookiebot-ccpa-domain-group-id') ."\n";
1332 $debugStr.= "Add async/defer to banner tag: ".(get_option('cookiebot-script-tag-uc-attribute') != '' ? get_option('cookiebot-script-tag-uc-attribute') : 'None')."\n";
1333 $debugStr.= "Add async/defer to declaration tag: ".(get_option('cookiebot-script-tag-cd-attribute') != '' ? get_option('cookiebot-script-tag-cd-attribute') : 'None')."\n";
1334 $debugStr.= "Auto update: ".(get_option('cookiebot-autoupdate') == '1' ? 'Enabled' : 'Not enabled')."\n";
1335 $debugStr.= "Hide Cookie Popup: ".(get_option('cookiebot-nooutput') == '1' ? 'Yes' : 'No')."\n";
1336 $debugStr.= "Disable Cookiebot in WP Admin: ".(get_option('cookiebot-nooutput-admin') == '1' ? 'Yes' : 'No')."\n";
1337 $debugStr.= "Enable Cookiebot on front end while logged in: ".(get_option('cookiebot-output-logged-in') == '1' ? 'Yes' : 'No')."\n";
1338 $debugStr.= "Banner tag: ".$this->add_js(false)."\n";
1339 $debugStr.= "Declaration tag: ".$this->show_declaration()."\n";
1340
1341 if(get_option('cookiebot-gtm') != false ){
1342 $debugStr.= "GTM tag: ".$this->add_GTM(false)."\n";
1343 }
1344
1345 if(get_option('cookiebot-gcm') != false ){
1346 $debugStr.= "GCM tag: ".$this->add_GCM(false)."\n";
1347 }
1348
1349 if($this->is_wp_consent_api_active()) {
1350 $debugStr.= "\n--- WP Consent Level API Mapping ---\n";
1351 $debugStr .= 'F = Functional, N = Necessary, P = Preferences, M = Marketing, S = Statistics, SA = Statistics Anonymous'."\n";
1352 $m = $this->get_wp_consent_api_mapping();
1353 foreach($m as $k=>$v) {
1354 $cb = array();
1355
1356 $debugStr .= strtoupper( str_replace(';', ', ', $k ) ) . ' => ';
1357
1358 $debugStr .= 'F=1, ';
1359 $debugStr .= 'P=' . $v['preferences'] . ', ';
1360 $debugStr .= 'M=' . $v['marketing'] . ', ';
1361 $debugStr .= 'S=' . $v['statistics'] . ', ';
1362 $debugStr .= 'SA=' . $v['statistics-anonymous'] . "\n";
1363
1364 }
1365
1366 }
1367
1368 if(class_exists('cookiebot_addons\Cookiebot_Addons')) {
1369 $ca = new cookiebot_addons\Cookiebot_Addons();
1370 $settingservice = $ca->container->get( 'Settings_Service_Interface' );
1371 $addons = $settingservice->get_active_addons();
1372 $debugStr.= "\n--- Activated Cookiebot Addons ---\n";
1373 foreach($addons as $addon) {
1374 $debugStr.= $addon->get_addon_name()." (".implode( ", ", $addon->get_cookie_types() ).")\n";
1375 }
1376 }
1377
1378 $debugStr.= "\n--- Activated Plugins ---\n";
1379 foreach($active_plugins as $p) {
1380 if($p != 'cookiebot/cookiebot.php') {
1381 $debugStr.= $plugins[$p]['Name'] . " (Version: ".$plugins[$p]['Version'].")\n";
1382 }
1383 }
1384
1385 $debugStr.= "\n##### Debug Information END #####";
1386
1387 ?>
1388 <div class="wrap">
1389 <h1><?php _e('Debug information','cookiebot'); ?></h1>
1390 <p><?php _e('The information below is for debugging purpose. If you have any issues with your Cookiebot integration, the information below is usefull for a supporter to help you the best way.'); ?></p>
1391 <p><button class="button button-primary" onclick="copyDebugInfo();"><?php _e('Copy debug information to clipboard'); ?></button></p>
1392 <textarea cols="100" rows="40" style="width:800px;max-width:100%;" id="cookiebot-debug-info" readonly><?php echo $debugStr; ?></textarea>
1393 <script>
1394 function copyDebugInfo() {
1395 var t = document.getElementById("cookiebot-debug-info");
1396 t.select();
1397 t.setSelectionRange(0, 99999);
1398 document.execCommand("copy");
1399 }
1400 </script>
1401 </div>
1402 <?php
1403 }
1404
1405 /**
1406 * Cookiebot_WP Add Cookiebot JS to <head>
1407 *
1408 * @version 3.9.0
1409 * @since 1.0.0
1410 */
1411 function add_js($printTag=true) {
1412 $cbid = $this->get_cbid();
1413 if(!empty($cbid) && !defined('COOKIEBOT_DISABLE_ON_PAGE')) {
1414 if(is_multisite() && get_site_option('cookiebot-nooutput',false)) {
1415 return; //Is multisite - and disabled output is checked as network setting
1416 }
1417
1418 if(get_option('cookiebot-nooutput',false)) {
1419 return; //Do not show JS - output disabled
1420 }
1421
1422 if($this->get_cookie_blocking_mode() == 'auto' && $this->can_current_user_edit_theme() && $printTag !== false && get_site_option('cookiebot-output-logged-in') == false) {
1423 return;
1424 }
1425
1426 $lang = $this->get_language();
1427 if(!empty($lang)) {
1428 $lang = ' data-culture="'.strtoupper($lang).'"'; //Use data-culture to define language
1429 }
1430
1431 if(!is_multisite() || get_site_option('cookiebot-script-tag-uc-attribute','custom') == 'custom') {
1432 $tagAttr = get_option('cookiebot-script-tag-uc-attribute','async');
1433 }
1434 else {
1435 $tagAttr = get_site_option('cookiebot-script-tag-uc-attribute');
1436 }
1437
1438 if($this->get_cookie_blocking_mode() == 'auto') {
1439 $tagAttr = 'data-blockingmode="auto"';
1440 }
1441
1442 if (get_option('cookiebot-gtm') != false) {
1443 if (empty(get_option('cookiebot-data-layer'))) {
1444 $data_layer = 'data-layer-name="dataLayer"';
1445 } else {
1446 $data_layer = 'data-layer-name="' . get_option('cookiebot-data-layer') . '"';
1447 }
1448 } else {
1449 $data_layer = '';
1450 }
1451
1452 $iab = ( get_option('cookiebot-iab') != false ) ? 'data-framework="IAB"' : '';
1453
1454 $ccpa = ( get_option('cookiebot-ccpa') != false ) ? 'data-georegions="{\'region\':\'US-06\',\'cbid\':\''.get_option('cookiebot-ccpa-domain-group-id').'\'}"' : '';
1455
1456 $tag = '<script id="Cookiebot" src="https://consent.cookiebot.com/uc.js" '.$iab.' '.$ccpa.' '.$data_layer.' data-cbid="'.$cbid.'"'.$lang.' type="text/javascript" '.$tagAttr.'></script>';
1457 if($printTag===false) {
1458 return $tag;
1459 }
1460 echo $tag;
1461 }
1462 }
1463
1464 /**
1465 * Cookiebot_WP Add Google Tag Manager JS to <head>
1466 *
1467 * @version 3.8.1
1468 * @since 3.8.1
1469 */
1470
1471 function add_GTM($printTag=true) {
1472
1473 if(get_option('cookiebot-gtm') != false ){
1474
1475 if(empty(get_option('cookiebot-data-layer'))){
1476 $data_layer = 'dataLayer';
1477 }else{
1478 $data_layer = get_option('cookiebot-data-layer');
1479 }
1480
1481 $GTM = "<script>";
1482 if( get_option('cookiebot-iab') ) {
1483 $GTM .= 'window ["gtag_enable_tcf_support"] = true;';
1484 }
1485
1486 $GTM .= "(function (w, d, s, l, i) {
1487 w[l] = w[l] || []; w[l].push({'gtm.start':new Date().getTime(), event: 'gtm.js'});
1488 var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : '';
1489 j.async = true; j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
1490 f.parentNode.insertBefore(j, f);})
1491 (window, document, 'script', '" . $data_layer . "', '" . get_option('cookiebot-gtm-id') . "');";
1492
1493
1494 $GTM .= "</script>";
1495
1496 if($printTag===false) {
1497 return $GTM;
1498 }
1499
1500 echo $GTM;
1501 }
1502 }
1503
1504 /**
1505 * Cookiebot_WP Add Google Consent Mode JS to <head>
1506 *
1507 * @version 3.8.1
1508 * @since 3.8.1
1509 */
1510
1511 function add_GCM($printTag=true) {
1512
1513 if(get_option('cookiebot-gcm') != false ){
1514
1515 if(empty(get_option('cookiebot-data-layer'))){
1516 $data_layer = 'dataLayer';
1517 }else{
1518 $data_layer = get_option('cookiebot-data-layer');
1519 }
1520
1521 $GCM = '<script data-cookieconsent="ignore">
1522 (function(w,d,l){w[l]=w[l]||[];function gtag(){w[l].push(arguments)};
1523 gtag("consent","default",{ad_storage:d,analytics_storage:d,wait_for_update:500,});
1524 gtag("set", "ads_data_redaction", true);})(window,"denied","' . $data_layer . '");';
1525
1526 $GCM .= '</script>';
1527
1528 if($printTag===false) {
1529 return $GCM;
1530 }
1531
1532 echo $GCM;
1533 }
1534 }
1535
1536 /**
1537 * Returns true if an user is logged in and has an edit_themes capability
1538 *
1539 * @return bool
1540 *
1541 * @since 3.3.1
1542 * @version 3.4.1
1543 */
1544 function can_current_user_edit_theme() {
1545 if( is_user_logged_in() ) {
1546 if( current_user_can('edit_themes') ) {
1547 return true;
1548 }
1549
1550 if( current_user_can( 'edit_pages' ) ) {
1551 return true;
1552 }
1553
1554 if( current_user_can( 'edit_posts' ) ) {
1555 return true;
1556 }
1557 }
1558
1559 return false;
1560 }
1561
1562 /**
1563 * Cookiebot_WP Output declation shortcode [cookie_declaration]
1564 * Support attribute lang="LANGUAGE_CODE". Eg. lang="en".
1565 *
1566 * @version 2.2.0
1567 * @since 1.0.0
1568 */
1569 function show_declaration($atts=array()) {
1570 $cbid = $this->get_cbid();
1571 $lang = '';
1572 if(!empty($cbid)) {
1573
1574 $atts = shortcode_atts(array(
1575 'lang' => $this->get_language(),
1576 ), $atts, 'cookie_declaration'
1577 );
1578
1579 if(!empty($atts['lang'])) {
1580 $lang = ' data-culture="'.strtoupper($atts['lang']).'"'; //Use data-culture to define language
1581 }
1582
1583 if(!is_multisite() || get_site_option('cookiebot-script-tag-cd-attribute','custom') == 'custom') {
1584 $tagAttr = get_option('cookiebot-script-tag-cd-attribute','async');
1585 }
1586 else {
1587 $tagAttr = get_site_option('cookiebot-script-tag-cd-attribute');
1588 }
1589
1590 return '<script id="CookieDeclaration" src="https://consent.cookiebot.com/'.$cbid.'/cd.js"'.$lang.' type="text/javascript" '.$tagAttr.'></script>';
1591 }
1592 else {
1593 return __('Please add your Cookiebot ID to show Cookie Declarations','cookiebot');
1594 }
1595 }
1596
1597 /**
1598 * Cookiebot_WP Get cookiebot cbid
1599 *
1600 * @version 2.2.0
1601 * @since 1.0.0
1602 */
1603 public static function get_cbid() {
1604 $cbid = get_option('cookiebot-cbid');
1605 if(is_multisite() && ($network_cbid = get_site_option('cookiebot-cbid'))) {
1606 if(empty($cbid)) {
1607 return $network_cbid;
1608 }
1609 }
1610 return $cbid;
1611 }
1612
1613 /**
1614 * Cookiebot_WP Get cookie blocking mode (auto | manual)
1615 *
1616 * @version 2.2.0
1617 * @since 1.0.0
1618 */
1619 public static function get_cookie_blocking_mode() {
1620 $cbm = get_option('cookiebot-cookie-blocking-mode');
1621 if(is_multisite() && ($network_cbm = get_site_option('cookiebot-cookie-blocking-mode'))) {
1622 if(empty($cbm)) {
1623 return $network_cbm;
1624 }
1625 }
1626 if(empty($cbm)) { $cbm = 'manual'; }
1627 return $cbm;
1628 }
1629
1630
1631 /**
1632 * Cookiebot_WP Check if Cookiebot is active in admin
1633 *
1634 * @version 3.1.0
1635 * @since 3.1.0
1636 */
1637 public static function cookiebot_disabled_in_admin() {
1638 if(is_multisite() && get_site_option('cookiebot-nooutput-admin',false)) {
1639 return true;
1640 }
1641 elseif(get_option('cookiebot-nooutput-admin',false)) {
1642 return true;
1643 }
1644 return false;
1645 }
1646
1647 /**
1648 * Cookiebot_WP Get the language code for Cookiebot
1649 *
1650 * @version 1.4.0
1651 * @since 1.4.0
1652 */
1653 function get_language($onlyFromSetting=false) {
1654 // Get language set in setting page - if empty use WP language info
1655 $lang = get_option('cookiebot-language');
1656 if(!empty($lang)) {
1657 if($lang != '_wp') {
1658 return $lang;
1659 }
1660 }
1661
1662 if($onlyFromSetting) {
1663 return $lang; //We want only to get if already set
1664 }
1665
1666 //Language not set - use WP language
1667 if($lang == '_wp') {
1668 $lang = get_bloginfo('language'); //Gets language in en-US format
1669 if(!empty($lang)) {
1670 list($lang) = explode('-',$lang); //Changes format from eg. en-US to en.
1671 }
1672 }
1673 return $lang;
1674 }
1675
1676 /**
1677 * Cookiebot_WP Adding Cookiebot domain(s) to exclude list for WP Rocket minification.
1678 *
1679 * @version 1.6.1
1680 * @since 1.6.1
1681 */
1682 function wp_rocket_exclude_external_js($external_js_hosts) {
1683 $external_js_hosts[] = 'consent.cookiebot.com'; // Add cookiebot domains
1684 $external_js_hosts[] = 'consentcdn.cookiebot.com';
1685 return $external_js_hosts;
1686 }
1687
1688 /**
1689 * Cookiebot_WP Adding Cookiebot domain(s) to exclude list for SGO minification.
1690 *
1691 * @version 3.6.5
1692 * @since 3.6.5
1693 */
1694 function sgo_exclude_external_js( $exclude_list ) {
1695 //Uses same format as WP Rocket - for now we just use WP Rocket function
1696 return wp_rocket_exclude_external_js( $exclude_list );
1697 }
1698
1699
1700 /**
1701 * Cookiebot_WP Check if WP Cookie Consent API is active
1702 *
1703 * @version 3.5.0
1704 * @since 3.5.0
1705 */
1706 public function is_wp_consent_api_active() {
1707 if ( class_exists( 'WP_CONSENT_API' ) ) {
1708 return true;
1709 }
1710 return false;
1711 }
1712
1713 /**
1714 * Cookiebot_WP Default consent level mappings
1715 *
1716 * @version 3.5.0
1717 * @since 3.5.0
1718 */
1719 public function get_default_wp_consent_api_mapping() {
1720 return array(
1721 'n=1;p=1;s=1;m=1' =>
1722 array('preferences'=>1,'statistics'=>1,'statistics-anonymous'=>0,'marketing'=>1),
1723 'n=1;p=1;s=1;m=0' =>
1724 array('preferences'=>1,'statistics'=>1,'statistics-anonymous'=>1,'marketing'=>0),
1725 'n=1;p=1;s=0;m=1' =>
1726 array('preferences'=>1,'statistics'=>0,'statistics-anonymous'=>0,'marketing'=>1),
1727 'n=1;p=1;s=0;m=0' =>
1728 array('preferences'=>1,'statistics'=>0,'statistics-anonymous'=>0,'marketing'=>0),
1729 'n=1;p=0;s=1;m=1' =>
1730 array('preferences'=>0,'statistics'=>1,'statistics-anonymous'=>0,'marketing'=>1),
1731 'n=1;p=0;s=1;m=0' =>
1732 array('preferences'=>0,'statistics'=>1,'statistics-anonymous'=>0,'marketing'=>0),
1733 'n=1;p=0;s=0;m=1' =>
1734 array('preferences'=>0,'statistics'=>0,'statistics-anonymous'=>0,'marketing'=>1),
1735 'n=1;p=0;s=0;m=0' =>
1736 array('preferences'=>0,'statistics'=>0,'statistics-anonymous'=>0,'marketing'=>0),
1737 );
1738
1739 }
1740
1741 /**
1742 * Cookiebot_WP Get the mapping between Consent Level API and Cookiebot
1743 * Returns array where key is the consent level api category and value
1744 * is the mapped Cookiebot category.
1745 *
1746 * @version 3.5.0
1747 * @since 3.5.0
1748 */
1749 public function get_wp_consent_api_mapping() {
1750 $mDefault = $this->get_default_wp_consent_api_mapping();
1751 $mapping = get_option( 'cookiebot-consent-mapping', $mDefault);
1752
1753 $mapping = ( '' === $mapping ) ? $mDefault : $mapping;
1754
1755 foreach($mDefault as $k=>$v) {
1756 if(!isset($mapping[$k])) {
1757 $mapping[$k] = $v;
1758 }
1759 else {
1760 foreach($v as $vck=>$vcv) {
1761 if(!isset($mapping[$k][$vck])) {
1762 $mapping[$k][$vck] = $vcv;
1763 }
1764 }
1765 }
1766 }
1767 return $mapping;
1768 }
1769
1770 /**
1771 * Cookiebot_WP Enqueue JS for integration with WP Consent Level API
1772 *
1773 * @version 3.5.0
1774 * @since 3.5.0
1775 */
1776 function cookiebot_enqueue_consent_api_scripts() {
1777 wp_register_script( 'cookiebot-wp-consent-level-api-integration', plugins_url( 'cookiebot/js/cookiebot-wp-consent-level-api-integration.js', 'cookiebot' ) );
1778 wp_enqueue_script( 'cookiebot-wp-consent-level-api-integration' );
1779 wp_localize_script( 'cookiebot-wp-consent-level-api-integration', 'cookiebot_category_mapping', $this->get_wp_consent_api_mapping() );
1780 }
1781
1782
1783 /**
1784 * Display admin notice for recommending cookiebot
1785 *
1786 * @version 2.0.5
1787 * @since 2.0.5
1788 */
1789 function cookiebot_admin_notices() {
1790 if( ! $this->cookiebot_valid_admin_recommendation() ) {
1791 return false;
1792 }
1793 $two_week_review_ignore = add_query_arg( array( 'cookiebot_admin_notice' => 'hide' ) );
1794 $two_week_review_temp = add_query_arg( array( 'cookiebot_admin_notice' => 'two_week' ) );
1795
1796 $notices = array(
1797 'title' => __('Leave A Review?', 'cookiebot'),
1798 'msg' => __('We hope you enjoy using WordPress Cookiebot! Would you consider leaving us a review on WordPress.org?', 'cookiebot'),
1799 'link' => '<li><span class="dashicons dashicons-external"></span><a href="https://wordpress.org/support/plugin/cookiebot/reviews?filter=5&rate=5#new-post" target="_blank">' . __('Sure! I\'d love to!', 'cookiebot') . '</a></li>
1800 <li><span class="dashicons dashicons-smiley"></span><a href="' . $two_week_review_ignore . '"> ' . __('I\'ve already left a review', 'cookiebot') . '</a></li>
1801 <li><span class="dashicons dashicons-calendar-alt"></span><a href="' . $two_week_review_temp . '">' . __('Maybe Later', 'cookiebot') . '</a></li>
1802 <li><span class="dashicons dashicons-dismiss"></span><a href="' . $two_week_review_ignore . '">' . __('Never show again', 'cookiebot') . '</a></li>',
1803 'later_link' => $two_week_review_temp,
1804 'int' => 14
1805 );
1806
1807 echo '<div class="update-nag cookiebot-admin-notice">
1808 <div class="cookiebot-notice-logo"></div>
1809 <p class="cookiebot-notice-title">' . $notices['title'] . '</p>
1810 <p class="cookiebot-notice-body">' . $notices['msg'] . '</p>
1811 <ul class="cookiebot-notice-body wd-blue">' . $notices['link'] . '</ul>
1812 <a href="' . $notices['later_link'] . '" class="dashicons dashicons-dismiss"></a>
1813 </div>';
1814
1815 wp_enqueue_style( 'cookiebot-admin-notices', plugins_url( 'css/notice.css', __FILE__ ), array(), '2.0.4' );
1816 }
1817
1818
1819 /**
1820 * Validate if the last user action is valid for plugin recommendation
1821 *
1822 * @return bool
1823 *
1824 * @version 2.0.5
1825 * @since 2.0.5
1826 */
1827 function cookiebot_valid_admin_recommendation() {
1828 //Default - the recommendation is allowed to be visible
1829 $return = true;
1830
1831 $option = get_option('cookiebot_notice_recommend');
1832
1833 if( $option != false ) {
1834 //Never show again is clicked
1835 if( $option == 'hide' ) {
1836 $return = false;
1837 }
1838 elseif( is_numeric($option) && strtotime('now') < $option ) {
1839 //Show me after 2 weeks is clicked and the time is not valid yet
1840 $return = false;
1841 }
1842 }
1843 return $return;
1844 }
1845
1846 /**
1847 * Save the user action on cookiebot recommendation link
1848 *
1849 * @version 2.0.5
1850 * @since 2.0.5
1851 */
1852 function save_notice_link() {
1853 if( isset( $_GET['cookiebot_admin_notice'] ) ) {
1854 if( $_GET['cookiebot_admin_notice'] == 'hide' ) {
1855 update_option('cookiebot_notice_recommend', 'hide' );
1856 }
1857 else {
1858 update_option('cookiebot_notice_recommend', strtotime('+2 weeks') );
1859 }
1860 }
1861 }
1862
1863
1864
1865
1866 /**
1867 * Cookiebot_WP Fix plugin conflicts related to Cookiebot
1868 *
1869 * @version 3.2.0
1870 * @since 3.3.0
1871 */
1872 function cookiebot_fix_plugin_conflicts() {
1873 //Fix for Divi Page Builder
1874 //Disabled - using another method now (can_current_user_edit_theme())
1875 //add_action( 'wp', array( $this, '_cookiebot_plugin_conflict_divi' ), 100 );
1876
1877 //Fix for Elementor and WPBakery Page Builder Builder
1878 //Disabled - using another method now (can_current_user_edit_theme())
1879 //add_filter( 'script_loader_tag', array( $this, '_cookiebot_plugin_conflict_scripttags' ), 10, 2 );
1880 }
1881
1882 /**
1883 * Cookiebot_WP Fix Divi builder conflict when blocking mode is in auto.
1884 *
1885 * @version 3.2.0
1886 * @since 3.2.0
1887 */
1888 function _cookiebot_plugin_conflict_divi() {
1889 if ( defined( 'ET_FB_ENABLED' ) ) {
1890 if ( ET_FB_ENABLED &&
1891 $this->cookiebot_disabled_in_admin() &&
1892 $this->get_cookie_blocking_mode() == 'auto' ) {
1893
1894 define('COOKIEBOT_DISABLE_ON_PAGE',true); //Disable Cookiebot on the current page
1895
1896 }
1897 }
1898 }
1899
1900 /**
1901 * Cookiebot_WP Fix plugin conflicts with page builders - whitelist JS files in automode
1902 *
1903 * @version 3.2.0
1904 * @since 3.3.0
1905 */
1906 function _cookiebot_plugin_conflict_scripttags( $tag, $handle ) {
1907
1908 //Check if Elementor Page Builder active
1909 if( defined( 'ELEMENTOR_VERSION' ) ) {
1910 if( in_array( $handle, [
1911 'jquery-core',
1912 'elementor-frontend-modules',
1913 'elementor-frontend',
1914 'wp-tinymce' ,
1915 'underscore',
1916 'backbone',
1917 'backbone-marionette',
1918 'backbone-radio',
1919 'elementor-common-modules',
1920 'elementor-dialog',
1921 'elementor-common',
1922 ] ) ) {
1923 $tag = str_replace( '<script ', '<script data-cookieconsent="ignore" ', $tag );
1924 }
1925 }
1926
1927 //Check if WPBakery Page Builder active
1928 if ( defined( 'WPB_VC_VERSION' ) ) {
1929 if( in_array( $handle, [
1930 'jquery-core',
1931 'jquery-ui-core',
1932 'jquery-ui-sortable',
1933 'jquery-ui-mouse',
1934 'jquery-ui-widget',
1935 'vc_editors-templates-preview-js',
1936 'vc-frontend-editor-min-js',
1937 'vc_inline_iframe_js',
1938 'wpb_composer_front_js',
1939 ] ) ) {
1940 $tag = str_replace( '<script ', '<script data-cookieconsent="ignore" ', $tag );
1941 }
1942 }
1943
1944 return $tag;
1945 }
1946
1947 }
1948 endif;
1949
1950
1951 /**
1952 * Helper function to manipulate script tags
1953 *
1954 * @version 1.6
1955 * @since 1.0
1956 * @return string
1957 */
1958 function cookiebot_assist($type='statistics') {
1959 //change to array
1960 if(!is_array($type)) { $type = array($type); }
1961
1962 foreach($type as $tk=>$tv) {
1963 if(!in_array($tv,array('marketing','statistics','preferences'))) {
1964 unset($type[$tk]);
1965 }
1966 }
1967 if(sizeof($type) > 0) {
1968 return ' type="text/plain" data-cookieconsent="'.implode(',',$type).'"';
1969 }
1970 return '';
1971 }
1972
1973
1974 /**
1975 * Helper function to check if cookiebot is active.
1976 * Useful for other plugins adding support for Cookiebot.
1977 *
1978 * @version 2.2.2
1979 * @since 1.2
1980 * @return string
1981 */
1982 function cookiebot_active() {
1983 $cbid = Cookiebot_WP::get_cbid();
1984 if(!empty($cbid)) {
1985 return true;
1986 }
1987 return false;
1988 }
1989
1990
1991 if(!function_exists('cookiebot')) {
1992 /**
1993 * Returns the main instance of Cookiebot_WO to prevent the need to use globals.
1994 *
1995 * @version 1.0.0
1996 * @since 1.0.0
1997 * @return Cookiebot_WP
1998 */
1999 function cookiebot() {
2000 return Cookiebot_WP::instance();
2001 }
2002 }
2003
2004 cookiebot();
2005