PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 3.5.0
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v3.5.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 6 years ago assets 7 years ago css 6 years ago documentation 7 years ago js 6 years ago langs 8 years ago widgets 7 years ago CookiebotAPI.md 7 years ago LICENSE.txt 8 years ago README.md 7 years ago cookiebot-logo.png 8 years ago cookiebot.php 6 years ago phpunit.xml 7 years ago readme.txt 6 years ago
cookiebot.php
1607 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.5.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.5.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('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 /**
66 * Cookiebot_WP Installation actions
67 *
68 * @version 2.1.4
69 * @since 2.1.4
70 * @accces public
71 */
72 function activation() {
73 //Delay display of recommendation notice in 3 days if not activated ealier
74 if(get_option('cookiebot_notice_recommend',false) === false) {
75 //Not set yet - this must be first activation - delay in 3 days
76 update_option('cookiebot_notice_recommend', strtotime('+3 days'));
77 }
78 if($this->get_cbid() == '') {
79 if(is_multisite()) {
80 update_site_option('cookiebot-cookie-blocking-mode','auto');
81 update_site_option('cookiebot-nooutput-admin',true);
82 }
83 else {
84 update_option('cookiebot-cookie-blocking-mode','auto');
85 update_option('cookiebot-nooutput-admin',true);
86 }
87 }
88 }
89
90 /**
91 * Cookiebot_WP Init Cookiebot.
92 *
93 * @version 3.2.0
94 * @since 1.6.2
95 * @access public
96 */
97 function cookiebot_init() {
98 /* Load Cookiebot Addons Framework */
99 $dismissAddons = false;
100 if(defined('CAF_DIR')) {
101 $dismissAddons = true;
102 /*add_action('admin_notices', function() {
103 ?>
104 <div class="notice notice-warning">
105 <p>
106 <?php _e( 'You have Cookiebot Addons installed.', 'cookiebot' ); ?><br />
107 <?php _e( 'In this and future releases of Cookiebot all available Addons are bundled directly with the Cookiebot plugin.', 'cookiebot' ); ?><br />
108 <?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' ); ?>
109 </p>
110 </div>
111 <?php
112 });*/
113 }
114 //elseif( $this->get_cookie_blocking_mode() !== 'auto' ) {
115 else {
116 if( (!defined('COOKIEBOT_ADDONS_STANDALONE') || COOKIEBOT_ADDONS_STANDALONE != true || !defined('COOKIE_ADDONS_LOADED')) && $dismissAddons !== true ) {
117 //Make sure we got a PHP version that works
118 if(version_compare(PHP_VERSION, '5.4.0', '>=')) {
119 define('COOKIEBOT_URL', plugin_dir_url( __FILE__ ));
120 include_once( dirname( __FILE__ ) . '/addons/cookiebot-addons-init.php' );
121 }
122 else {
123 define('COOKIEBOT_ADDONS_UNSUPPORTED_PHPVERSION',true);
124 }
125 }
126 else {
127 add_action('admin_notices', function() {
128 ?>
129 <div class="notice notice-warning">
130 <p>
131 <?php _e( 'You are using Cookiebot Addons Standalone.', 'cookiebot' ); ?>
132 </p>
133 </div>
134 <?php
135 });
136 }
137 }
138 if(is_admin()) {
139
140 //Adding menu to WP admin
141 add_action('admin_menu', array($this,'add_menu'),1);
142
143 if(is_multisite()) {
144 add_action('network_admin_menu', array($this,'add_network_menu'),1);
145 add_action('network_admin_edit_cookiebot_network_settings', array($this,'network_settings_save'));
146 }
147
148 //Register settings
149 add_action('admin_init', array($this,'register_cookiebot_settings'));
150
151 //Adding dashboard widgets
152 add_action('wp_dashboard_setup', array($this,'add_dashboard_widgets'));
153
154 add_action('admin_notices', array( $this, 'cookiebot_admin_notices' ) );
155 add_action('admin_init', array($this,'save_notice_link'));
156
157 //Check if we should show cookie consent banner on admin pages
158 if(!$this->cookiebot_disabled_in_admin()) {
159 //adding cookie banner in admin area too
160 add_action('admin_head', array($this,'add_js'),-9999);
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/' );
171
172 //add JS
173 add_action('wp_head', array($this,'add_js'), -9999);
174 add_shortcode('cookie_declaration', array($this,'show_declaration'));
175
176 //Add filter if WP rocket is enabled
177 if(defined('WP_ROCKET_VERSION')) {
178 add_filter('rocket_minify_excluded_external_js', array($this,'wp_rocket_exclude_external_js'));
179 }
180
181 //Automatic update plugin
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') );
189
190 }
191
192 /**
193 * Cookiebot_WP Load text domain
194 *
195 * @version 2.0.0
196 * @since 2.0.0
197 */
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 */
208 function register_widgets() {
209 register_widget( 'Cookiebot_Declaration_Widget' );
210 }
211
212 /**
213 * Cookiebot_WP Add dashboard widgets to admin
214 *
215 * @version 1.0.0
216 * @since 1.0.0
217 */
218
219 function add_dashboard_widgets() {
220 wp_add_dashboard_widget('cookiebot_status', __('Cookiebot Status','cookiebot'), array($this,'dashboard_widget_status'));
221 }
222
223 /**
224 * Cookiebot_WP Output Dashboard Status Widget
225 *
226 * @version 1.0.0
227 * @since 1.0.0
228 */
229 function dashboard_widget_status() {
230 $cbid = $this->get_cbid();
231 if(empty($cbid)) {
232 echo '<p>'.__('You need to enter your Cookiebot ID.','cookiebot').'</p>';
233 echo '<p><a href="options-general.php?page=cookiebot">';
234 echo __('Update your Cookiebot ID','cookiebot');
235 echo '</a></p>';
236 }
237 else {
238 echo '<p>'._e('Your Cookiebot is working!','cookiebot').'</p>';
239 }
240 }
241
242 /**
243 * Cookiebot_WP Add option menu page for Cookiebot
244 *
245 * @version 2.2.0
246 * @since 1.0.0
247 */
248 function add_menu() {
249 //Cookiebot Icon SVG base64 encoded
250 $icon = 'data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgNzIgNTQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iI0ZGRkZGRiIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNNDYuODcyNTkwMyA4Ljc3MzU4MzM0QzQxLjk0MzkwMzkgMy4zODI5NTAxMSAzNC44NDI0OTQ2IDAgMjYuOTQ4MjgxOSAwIDEyLjA2NTE1NjggMCAwIDEyLjAyNDQ3NzQgMCAyNi44NTc0MjE5YzAgMTQuODMyOTQ0NSAxMi4wNjUxNTY4IDI2Ljg1NzQyMTkgMjYuOTQ4MjgxOSAyNi44NTc0MjE5IDcuODk0MjEyNyAwIDE0Ljk5NTYyMi0zLjM4Mjk1MDIgMTkuOTI0MzA4NC04Ljc3MzU4MzQtMi44ODk2OTY3LTEuMzY4ODY2My01LjM5OTMxMS0zLjQwNTQzOS03LjMyODA4MzgtNS45MDk2MzU4LTMuMTIxNDMwNiAzLjIwOTQxMDQtNy40OTI5OTQ0IDUuMjA0MTI5MS0xMi4zMzIwMjU4IDUuMjA0MTI5MS05LjQ4NDM0NDQgMC0xNy4xNzI5MjQ3LTcuNjYyNjU3Mi0xNy4xNzI5MjQ3LTE3LjExNTAyMzhzNy42ODg1ODAzLTE3LjExNTAyMzcgMTcuMTcyOTI0Ny0xNy4xMTUwMjM3YzQuNzIzNDgyMiAwIDkuMDAxNTU1MiAxLjkwMDU5MzkgMTIuMTA2MjkyIDQuOTc2MzA5IDEuOTU2OTIzNy0yLjY0MTEzMSA0LjU1MDAyNjMtNC43ODU1MTgzIDcuNTUzODE3Ni02LjIwODQzMTg2eiIvPjxwYXRoIGQ9Ik01NS4zODAzMjgyIDQyLjY1MDE5OTFDNDYuMzMzNzIyNyA0Mi42NTAxOTkxIDM5IDM1LjM0MTIwMzEgMzkgMjYuMzI1MDk5NiAzOSAxNy4zMDg5OTYgNDYuMzMzNzIyNyAxMCA1NS4zODAzMjgyIDEwYzkuMDQ2NjA1NSAwIDE2LjM4MDMyODIgNy4zMDg5OTYgMTYuMzgwMzI4MiAxNi4zMjUwOTk2IDAgOS4wMTYxMDM1LTcuMzMzNzIyNyAxNi4zMjUwOTk1LTE2LjM4MDMyODIgMTYuMzI1MDk5NXptLjAyMTMwOTItNy43NTU2MzQyYzQuNzM3MDI3NiAwIDguNTc3MTQ3MS0zLjgyNzE3MiA4LjU3NzE0NzEtOC41NDgyMjc5IDAtNC43MjEwNTYtMy44NDAxMTk1LTguNTQ4MjI4LTguNTc3MTQ3MS04LjU0ODIyOC00LjczNzAyNzUgMC04LjU3NzE0NyAzLjgyNzE3Mi04LjU3NzE0NyA4LjU0ODIyOCAwIDQuNzIxMDU1OSAzLjg0MDExOTUgOC41NDgyMjc5IDguNTc3MTQ3IDguNTQ4MjI3OXoiLz48L2c+PC9zdmc+';
251 add_menu_page( 'Cookiebot', __('Cookiebot','cookiebot'), 'manage_options', 'cookiebot', array($this,'settings_page'),$icon);
252
253 add_submenu_page('cookiebot',__('Cookiebot Settings','cookiebot'),__('Settings','cookiebot'), 'manage_options', 'cookiebot',array($this,'settings_page'));
254 add_submenu_page('cookiebot',__('Cookiebot Support','cookiebot'),__('Support','cookiebot'), 'manage_options', 'cookiebot_support',array($this,'support_page'));
255 add_submenu_page('cookiebot',__('IAB','cookiebot'),__('IAB','cookiebot'), 'manage_options', 'cookiebot_iab',array($this,'iab_page'));
256
257 if(defined('COOKIEBOT_ADDONS_UNSUPPORTED_PHPVERSION')) {
258 //Load prior consent page anyway - but from Cookiebot WP Core plugin.
259 add_submenu_page( 'cookiebot', __( 'Prior Consent', 'cookiebot' ), __( 'Prior Consent', 'cookiebot' ), 'manage_options', 'cookiebot-addons', array($this,'setting_page_placeholder' ) );
260 }
261 }
262
263 /**
264 * Cookiebot_WP Add menu for network sites
265 *
266 * @version 2.2.0
267 * @since 2.2.0
268 */
269 function add_network_menu() {
270 $icon = 'data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgNzIgNTQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iI0ZGRkZGRiIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNNDYuODcyNTkwMyA4Ljc3MzU4MzM0QzQxLjk0MzkwMzkgMy4zODI5NTAxMSAzNC44NDI0OTQ2IDAgMjYuOTQ4MjgxOSAwIDEyLjA2NTE1NjggMCAwIDEyLjAyNDQ3NzQgMCAyNi44NTc0MjE5YzAgMTQuODMyOTQ0NSAxMi4wNjUxNTY4IDI2Ljg1NzQyMTkgMjYuOTQ4MjgxOSAyNi44NTc0MjE5IDcuODk0MjEyNyAwIDE0Ljk5NTYyMi0zLjM4Mjk1MDIgMTkuOTI0MzA4NC04Ljc3MzU4MzQtMi44ODk2OTY3LTEuMzY4ODY2My01LjM5OTMxMS0zLjQwNTQzOS03LjMyODA4MzgtNS45MDk2MzU4LTMuMTIxNDMwNiAzLjIwOTQxMDQtNy40OTI5OTQ0IDUuMjA0MTI5MS0xMi4zMzIwMjU4IDUuMjA0MTI5MS05LjQ4NDM0NDQgMC0xNy4xNzI5MjQ3LTcuNjYyNjU3Mi0xNy4xNzI5MjQ3LTE3LjExNTAyMzhzNy42ODg1ODAzLTE3LjExNTAyMzcgMTcuMTcyOTI0Ny0xNy4xMTUwMjM3YzQuNzIzNDgyMiAwIDkuMDAxNTU1MiAxLjkwMDU5MzkgMTIuMTA2MjkyIDQuOTc2MzA5IDEuOTU2OTIzNy0yLjY0MTEzMSA0LjU1MDAyNjMtNC43ODU1MTgzIDcuNTUzODE3Ni02LjIwODQzMTg2eiIvPjxwYXRoIGQ9Ik01NS4zODAzMjgyIDQyLjY1MDE5OTFDNDYuMzMzNzIyNyA0Mi42NTAxOTkxIDM5IDM1LjM0MTIwMzEgMzkgMjYuMzI1MDk5NiAzOSAxNy4zMDg5OTYgNDYuMzMzNzIyNyAxMCA1NS4zODAzMjgyIDEwYzkuMDQ2NjA1NSAwIDE2LjM4MDMyODIgNy4zMDg5OTYgMTYuMzgwMzI4MiAxNi4zMjUwOTk2IDAgOS4wMTYxMDM1LTcuMzMzNzIyNyAxNi4zMjUwOTk1LTE2LjM4MDMyODIgMTYuMzI1MDk5NXptLjAyMTMwOTItNy43NTU2MzQyYzQuNzM3MDI3NiAwIDguNTc3MTQ3MS0zLjgyNzE3MiA4LjU3NzE0NzEtOC41NDgyMjc5IDAtNC43MjEwNTYtMy44NDAxMTk1LTguNTQ4MjI4LTguNTc3MTQ3MS04LjU0ODIyOC00LjczNzAyNzUgMC04LjU3NzE0NyAzLjgyNzE3Mi04LjU3NzE0NyA4LjU0ODIyOCAwIDQuNzIxMDU1OSAzLjg0MDExOTUgOC41NDgyMjc5IDguNTc3MTQ3IDguNTQ4MjI3OXoiLz48L2c+PC9zdmc+';
271 add_menu_page( 'Cookiebot', __('Cookiebot','cookiebot'), 'manage_network_options', 'cookiebot_network', array($this,'network_settings_page'),$icon);
272
273 add_submenu_page('cookiebot_network',__('Cookiebot Settings','cookiebot'),__('Settings','cookiebot'), 'network_settings_page', 'cookiebot_network',array($this,'network_settings_page'));
274 add_submenu_page('cookiebot_network',__('Cookiebot Support','cookiebot'),__('Support','cookiebot'), 'network_settings_page', 'cookiebot_support',array($this,'support_page'));
275
276 }
277
278 /**
279 * Cookiebot_WP Cookiebot prior consent placeholder page
280 *
281 * @version 1.4.0
282 * @since 1.0.0
283 */
284 function setting_page_placeholder() {
285 include __DIR__ . DIRECTORY_SEPARATOR . 'addons' . DIRECTORY_SEPARATOR . 'view/admin/settings/setting-page.php';
286 }
287
288 /**
289 * Cookiebot_WP Register Cookiebot settings
290 *
291 * @version 2.1.5
292 * @since 1.0.0
293 */
294 function register_cookiebot_settings() {
295 register_setting('cookiebot', 'cookiebot-cbid');
296 register_setting('cookiebot', 'cookiebot-language');
297 register_setting('cookiebot', 'cookiebot-nooutput');
298 register_setting('cookiebot', 'cookiebot-nooutput-admin');
299 register_setting('cookiebot', 'cookiebot-autoupdate');
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
307 /**
308 * Cookiebot_WP Automatic update plugin if activated
309 *
310 * @version 2.2.0
311 * @since 1.5.0
312 */
313 function automatic_updates($update, $item) {
314 //Do not update from subsite on a multisite installation
315 if(is_multisite() && ! is_main_site()) {
316 return $update;
317 }
318
319 //Check if we have everything we need
320 $item = (array)$item;
321 if(!isset($item['new_version']) || !isset($item['slug'])) {
322 return $update;
323 }
324
325 //It is not Cookiebot
326 if($item['slug'] !== 'cookiebot') {
327 return $update;
328 }
329
330 // Check if cookiebot autoupdate is disabled
331 if(!get_option('cookiebot-autoupdate',false)) {
332 return $update;
333 }
334
335 // Check if multisite autoupdate is disabled
336 if(is_multisite() && !get_site_option('cookiebot-autoupdate',false)) {
337 return $update;
338 }
339
340 return true;
341 }
342
343
344 /**
345 * Cookiebot_WP Get list of supported languages
346 *
347 * @version 1.4.0
348 * @since 1.4.0
349 */
350 public static function get_supported_languages() {
351 $supportedLanguages = array();
352 $supportedLanguages['nb'] = __('Norwegian Bokmål','cookiebot');
353 $supportedLanguages['tr'] = __('Turkish','cookiebot');
354 $supportedLanguages['de'] = __('German','cookiebot');
355 $supportedLanguages['cs'] = __('Czech','cookiebot');
356 $supportedLanguages['da'] = __('Danish','cookiebot');
357 $supportedLanguages['sq'] = __('Albanian','cookiebot');
358 $supportedLanguages['he'] = __('Hebrew','cookiebot');
359 $supportedLanguages['ko'] = __('Korean','cookiebot');
360 $supportedLanguages['it'] = __('Italian','cookiebot');
361 $supportedLanguages['nl'] = __('Dutch','cookiebot');
362 $supportedLanguages['vi'] = __('Vietnamese','cookiebot');
363 $supportedLanguages['ta'] = __('Tamil','cookiebot');
364 $supportedLanguages['is'] = __('Icelandic','cookiebot');
365 $supportedLanguages['ro'] = __('Romanian','cookiebot');
366 $supportedLanguages['si'] = __('Sinhala','cookiebot');
367 $supportedLanguages['ca'] = __('Catalan','cookiebot');
368 $supportedLanguages['bg'] = __('Bulgarian','cookiebot');
369 $supportedLanguages['uk'] = __('Ukrainian','cookiebot');
370 $supportedLanguages['zh'] = __('Chinese','cookiebot');
371 $supportedLanguages['en'] = __('English','cookiebot');
372 $supportedLanguages['ar'] = __('Arabic','cookiebot');
373 $supportedLanguages['hr'] = __('Croatian','cookiebot');
374 $supportedLanguages['th'] = __('Thai','cookiebot');
375 $supportedLanguages['el'] = __('Greek','cookiebot');
376 $supportedLanguages['lt'] = __('Lithuanian','cookiebot');
377 $supportedLanguages['pl'] = __('Polish','cookiebot');
378 $supportedLanguages['lv'] = __('Latvian','cookiebot');
379 $supportedLanguages['fr'] = __('French','cookiebot');
380 $supportedLanguages['id'] = __('Indonesian','cookiebot');
381 $supportedLanguages['mk'] = __('Macedonian','cookiebot');
382 $supportedLanguages['et'] = __('Estonian','cookiebot');
383 $supportedLanguages['pt'] = __('Portuguese','cookiebot');
384 $supportedLanguages['ga'] = __('Irish','cookiebot');
385 $supportedLanguages['ms'] = __('Malay','cookiebot');
386 $supportedLanguages['sl'] = __('Slovenian','cookiebot');
387 $supportedLanguages['ru'] = __('Russian','cookiebot');
388 $supportedLanguages['ja'] = __('Japanese','cookiebot');
389 $supportedLanguages['hi'] = __('Hindi','cookiebot');
390 $supportedLanguages['sk'] = __('Slovak','cookiebot');
391 $supportedLanguages['es'] = __('Spanish','cookiebot');
392 $supportedLanguages['sv'] = __('Swedish','cookiebot');
393 $supportedLanguages['sr'] = __('Serbian','cookiebot');
394 $supportedLanguages['fi'] = __('Finnish','cookiebot');
395 $supportedLanguages['eu'] = __('Basque','cookiebot');
396 $supportedLanguages['hu'] = __('Hungarian','cookiebot');
397 asort($supportedLanguages,SORT_LOCALE_STRING);
398 return $supportedLanguages;
399 }
400
401 /**
402 * Cookiebot_WP Output settings page
403 *
404 * @version 2.2.0
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
413 $network_cbid = get_site_option('cookiebot-cbid','');
414 $network_scrip_tag_uc_attr = get_site_option('cookiebot-script-tag-uc-attribute','custom');
415 $network_scrip_tag_cd_attr = get_site_option('cookiebot-script-tag-cd-attribute','custom');
416 $network_cookie_blocking_mode = get_site_option('cookiebot-cookie-blocking-mode','manual');
417 }
418 ?>
419 <div class="wrap">
420 <h1><?php _e('Cookiebot Settings','cookiebot'); ?></h1>
421 <a href="https://www.cookiebot.com">
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' ); ?>
429 <?php do_settings_sections( 'cookiebot' ); ?>
430 <table class="form-table">
431 <tr valign="top">
432 <th scope="row"><?php _e('Cookiebot ID','cookiebot'); ?></th>
433 <td>
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>
441 <tr valign="top">
442 <th scope="row">
443 <?php _e('Cookie-blocking mode','cookiebot'); ?>
444 </th>
445 <td>
446 <?php
447 $cbm = get_option('cookiebot-cookie-blocking-mode','manual');
448 if($is_ms && $network_cookie_blocking_mode != 'custom') {
449 $cbm = $network_cookie_blocking_mode;
450 }
451 ?>
452 <label>
453 <input type="radio" name="cookiebot-cookie-blocking-mode" value="auto" <?php checked('auto', $cbm, true); ?> />
454 <?php _e('Automatic','cookiebot'); ?>
455 </label>
456 &nbsp; &nbsp;
457 <label>
458 <input type="radio" name="cookiebot-cookie-blocking-mode" value="manual" <?php checked('manual',$cbm, true); ?> />
459 <?php _e('Manual','cookiebot'); ?>
460 </label>
461 <p class="description">
462 <?php _e('Automatic block cookies (except necessary) untill the user has given their consent.','cookiebot') ?>
463 <a href="https://support.cookiebot.com/hc/en-us/articles/360009063100-Automatic-Cookie-Blocking-How-does-it-work-" target="_blank">
464 <?php _e('Learn more','cookiebot'); ?>
465 </a>
466 </p>
467 <script>
468 jQuery(document).ready(function($) {
469 var cookieBlockingMode = '<?php echo $cbm; ?>';
470 $( 'input[type=radio][name=cookiebot-cookie-blocking-mode]' ).on( 'change', function() {
471 if(this.value == 'auto' && cookieBlockingMode != this.value ) {
472 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 );
473 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true );
474 }
475 if( this.value == 'manual' && cookieBlockingMode != this.value ) {
476 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 1 );
477 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', false );
478 }
479 cookieBlockingMode = this.value;
480 });
481 if( cookieBlockingMode == 'auto' ) {
482 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 );
483 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true );
484 }
485 });
486 </script>
487 </td>
488 </tr>
489 <tr valign="top">
490 <th scope="row"><?php _e('Cookiebot Language','cookiebot'); ?></th>
491 <td>
492 <div>
493 <select name="cookiebot-language" id="cookiebot-language">
494 <?php
495 $currentLang = $this->get_language(true);
496 ?>
497 <option value=""><?php _e('Default (Autodetect)','cookiebot'); ?></option>
498 <option value="_wp"<?php echo ($currentLang == '_wp') ? ' selected' : ''; ?>><?php _e('Use Wordpress Language','cookiebot'); ?></option>
499 <?php
500 $supportedLanguages = $this->get_supported_languages();
501 foreach($supportedLanguages as $langCode=>$langName) {
502 echo '<option value="'.$langCode.'"'.(($currentLang==$langCode) ? ' selected' : '').'>'.$langName.'</option>';
503 }
504 ?>
505 </select>
506 </div>
507 <div class="notice inline notice-warning notice-alt cookiebot-notice" style="padding:12px;font-size:13px;display:inline-block;">
508 <div style="<?php echo ($currentLang=='') ? 'display:none;' : '' ?>" id="info_lang_specified">
509 <?php _e('You need to add the language in the Cookiebot administration tool.'); ?>
510 </div>
511 <div style="<?php echo ($currentLang=='') ? '' : 'display:none;' ?>" id="info_lang_autodetect">
512 <?php _e('You need to add all languages that you want auto-detected in the Cookiebot administration tool.'); ?> <br/>
513 <?php _e('The auto-detect checkbox needs to be enabled in the Cookiebot administration tool.'); ?><br/>
514 <?php _e('If the auto-detected language is not supported, Cookiebot will use the default language.'); ?>
515 </div>
516 <br />
517
518 <a href="#" id="show_add_language_guide"><?php _e('Show guide to add languages'); ?></a>
519 &nbsp;
520 <a href="https://support.cookiebot.com/hc/en-us/articles/360003793394-How-do-I-set-the-language-of-the-consent-banner-dialog-" target="_blank">
521 <?php _e('Read more here'); ?>
522 </a>
523
524 <div id="add_language_guide" style="display:none;">
525 <img src="<?php echo plugin_dir_url( __FILE__ ); ?>/assets/guide_add_language.gif" alt="Add language in Cookiebot administration tool" />
526 <br />
527 <a href="#" id="hide_add_language_guide"><?php _e('Hide guide'); ?></a>
528 </div>
529 </div>
530 <script>
531 jQuery(document).ready(function($) {
532 $('#show_add_language_guide').on('click',function(e) {
533 e.preventDefault();
534 $('#add_language_guide').slideDown();
535 $(this).hide();
536 });
537 $('#hide_add_language_guide').on('click',function(e) {
538 e.preventDefault();
539 $('#add_language_guide').slideUp();
540 $('#show_add_language_guide').show();
541 });
542
543 $('#cookiebot-language').on('change', function() {
544 if(this.value == '') {
545 $('#info_lang_autodetect').show();
546 $('#info_lang_specified').hide();
547 }
548 else {
549 $('#info_lang_autodetect').hide();
550 $('#info_lang_specified').show();
551 }
552 });
553 });
554 </script>
555
556 </td>
557 </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">
587 <?php _e('Add async or defer attribute','cookiebot'); ?>
588 <br /><?php _e('Consent banner script tag'); ?>
589 </th>
590 <td>
591 <?php
592 $cv = get_option('cookiebot-script-tag-uc-attribute','async');
593 $disabled = false;
594 if($is_ms && $network_scrip_tag_uc_attr != 'custom') {
595 $disabled = true;
596 $cv = $network_scrip_tag_uc_attr;
597 }
598 ?>
599 <label>
600 <input type="radio" name="cookiebot-script-tag-uc-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="" <?php checked('', $cv, true); ?> />
601 <i>None</i>
602 </label>
603 &nbsp; &nbsp;
604 <label>
605 <input type="radio" name="cookiebot-script-tag-uc-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="async" <?php checked('async',$cv, true); ?> />
606 async
607 </label>
608 &nbsp; &nbsp;
609 <label>
610 <input type="radio" name="cookiebot-script-tag-uc-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="defer" <?php checked('defer',$cv, true); ?> />
611 defer
612 </label>
613 <p class="description">
614 <?php if($disabled) { echo '<b>'._('Network setting applied. Please contact website administrator to change this setting.').'</b><br />'; } ?>
615 <?php _e('Add async or defer attribute to Cookiebot script tag. Default: async','cookiebot') ?>
616 </p>
617 </td>
618 </tr>
619 <tr valign="top">
620 <th scope="row">
621 <?php _e('Add async or defer attribute','cookiebot'); ?>
622 <br /><?php _e('Cookie declaration script tag'); ?>
623 </th>
624 <td>
625 <?php
626 $cv = get_option('cookiebot-script-tag-cd-attribute','async');
627 $disabled = false;
628 if($is_ms && $network_scrip_tag_cd_attr != 'custom') {
629 $disabled = true;
630 $cv = $network_scrip_tag_cd_attr;
631 }
632 ?>
633 <label>
634 <input type="radio" name="cookiebot-script-tag-cd-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="" <?php checked('', $cv, true); ?> />
635 <i>None</i>
636 </label>
637 &nbsp; &nbsp;
638 <label>
639 <input type="radio" name="cookiebot-script-tag-cd-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="async" <?php checked('async',$cv, true); ?> />
640 async
641 </label>
642 &nbsp; &nbsp;
643 <label>
644 <input type="radio" name="cookiebot-script-tag-cd-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="defer" <?php checked('defer',$cv, true); ?> />
645 defer
646 </label>
647 <p class="description">
648 <?php if($disabled) { echo '<b>'._('Network setting applied. Please contact website administrator to change this setting.').'</b><br />'; } ?>
649 <?php _e('Add async or defer attribute to Cookiebot script tag. Default: async','cookiebot') ?>
650 </p>
651 </td>
652 </tr>
653 <?php
654 if(!is_multisite()) {
655 ?>
656 <tr valign="top">
657 <th scope="row"><?php _e('Auto-update Cookiebot','cookiebot'); ?></th>
658 <td>
659 <input type="checkbox" name="cookiebot-autoupdate" value="1" <?php checked(1,get_option('cookiebot-autoupdate',false), true); ?> />
660 <p class="description">
661 <?php _e('Automatic update your Cookiebot plugin when new releases becomes available.','cookiebot') ?>
662 </p>
663 </td>
664 </tr>
665 <?php
666 }
667 ?>
668 <tr valign="top" id="cookiebot-setting-hide-popup">
669 <th scope="row"><?php _e('Hide Cookie Popup','cookiebot'); ?></th>
670 <td>
671 <?php
672 $disabled = false;
673 if($is_ms && get_site_option('cookiebot-nooutput',false)) {
674 $disabled = true;
675 echo '<input type="checkbox" checked disabled />';
676 }
677 else {
678 ?>
679 <input type="checkbox" name="cookiebot-nooutput" value="1" <?php checked(1,get_option('cookiebot-nooutput',false), true); ?> />
680 <?php
681 }
682 ?>
683 <p class="description">
684 <?php if($disabled) { echo '<b>'._('Network setting applied. Please contact website administrator to change this setting.').'</b><br />'; } ?>
685 <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 />
686 <?php _e('If you are using Google Tag Manager (or equal), you need to add the Cookiebot script in your Tag Manager.','cookiebot') ?><br />
687 <?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') ?>
688 </p>
689 </td>
690 </tr>
691 <tr valign="top">
692 <th scope="row"><?php _e('Disable Cookiebot in WP Admin','cookiebot'); ?></th>
693 <td>
694 <?php
695 $disabled = false;
696 if($is_ms && get_site_option('cookiebot-nooutput-admin',false)) {
697 echo '<input type="checkbox" checked disabled />';
698 $disabled = true;
699 }
700 else {
701 ?>
702 <input type="checkbox" name="cookiebot-nooutput-admin" value="1" <?php checked(1,get_option('cookiebot-nooutput-admin',false), true); ?> />
703 <?php
704 }
705 ?>
706 <p class="description">
707 <?php if($disabled) { echo '<b>'._('Network setting applied. Please contact website administrator to change this setting.').'</b><br />'; } ?>
708 <b><?php _e('This checkbox will disable Cookiebot in the Wordpress Admin area.','cookiebot') ?></b>
709 </p>
710 </td>
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>
807 <?php
808 }
809
810 /**
811 * Cookiebot_WP Cookiebot network setting page
812 *
813 * @version 2.2.0
814 * @since 2.2.0
815 */
816 function network_settings_page() {
817 ?>
818 <div class="wrap">
819 <h1><?php _e('Cookiebot Network Settings','cookiebot'); ?></h1>
820 <a href="https://www.cookiebot.com">
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>
828 </p>
829 <form method="post" action="edit.php?action=cookiebot_network_settings">
830 <?php wp_nonce_field( 'cookiebot-network-settings' ); ?>
831 <table class="form-table">
832 <tr valign="top">
833 <th scope="row"><?php _e('Network Cookiebot ID','cookiebot'); ?></th>
834 <td>
835 <input type="text" name="cookiebot-cbid" value="<?php echo esc_attr( get_site_option('cookiebot-cbid','') ); ?>" style="width:300px" />
836 <p class="description">
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>
844 <tr valign="top">
845 <th scope="row">
846 <?php _e('Cookie-blocking mode','cookiebot'); ?>
847 </th>
848 <td>
849 <?php
850 $cbm = get_site_option('cookiebot-cookie-blocking-mode','manual');
851 ?>
852 <label>
853 <input type="radio" name="cookiebot-cookie-blocking-mode" value="auto" <?php checked('auto', $cbm, true); ?> />
854 <?php _e('Automatic','cookiebot'); ?>
855 </label>
856 &nbsp; &nbsp;
857 <label>
858 <input type="radio" name="cookiebot-cookie-blocking-mode" value="manual" <?php checked('manual',$cbm, true); ?> />
859 <?php _e('Manual','cookiebot'); ?>
860 </label>
861 <p class="description">
862 <?php _e('Should Cookiebot automatic block cookies by tagging known tags.','cookiebot') ?>
863 </p>
864 </td>
865 </tr>
866 <script>
867 jQuery(document).ready(function($) {
868 var cookieBlockingMode = '<?php echo $cbm; ?>';
869 $( 'input[type=radio][name=cookiebot-cookie-blocking-mode]' ).on( 'change', function() {
870 if(this.value == 'auto' && cookieBlockingMode != this.value ) {
871 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 );
872 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true );
873 }
874 if( this.value == 'manual' && cookieBlockingMode != this.value ) {
875 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 1 );
876 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', false );
877 }
878 cookieBlockingMode = this.value;
879 });
880 if( cookieBlockingMode == 'auto' ) {
881 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 );
882 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true );
883 }
884 });
885 </script>
886 <tr valign="top" id="cookiebot-setting-async">
887 <th scope="row">
888 <?php _e('Add async or defer attribute','cookiebot'); ?>
889 <br /><?php _e('Consent banner script tag'); ?>
890 </th>
891 <td>
892 <?php
893 $cv = get_site_option('cookiebot-script-tag-uc-attribute','custom');
894 ?>
895 <label>
896 <input type="radio" name="cookiebot-script-tag-uc-attribute" value="" <?php checked('', $cv, true); ?> />
897 <i>None</i>
898 </label>
899 &nbsp; &nbsp;
900 <label>
901 <input type="radio" name="cookiebot-script-tag-uc-attribute" value="async" <?php checked('async',$cv, true); ?> />
902 async
903 </label>
904 &nbsp; &nbsp;
905 <label>
906 <input type="radio" name="cookiebot-script-tag-uc-attribute" value="defer" <?php checked('defer',$cv, true); ?> />
907 defer
908 </label>
909 &nbsp; &nbsp;
910 <label>
911 <input type="radio" name="cookiebot-script-tag-uc-attribute" value="custom" <?php checked('custom',$cv, true); ?> />
912 <i>Choose per subsite</i>
913 </label>
914 <p class="description">
915 <b><?php _e('Setting will apply for all subsites. Subsites will not be able to override.'); ?></b><br />
916 <?php _e('Add async or defer attribute to Cookiebot script tag. Default: Choose per subsite','cookiebot') ?>
917 </p>
918 </td>
919 </tr>
920 <tr valign="top">
921 <th scope="row">
922 <?php _e('Add async or defer attribute','cookiebot'); ?>
923 <br /><?php _e('Cookie declaration script tag'); ?>
924 </th>
925 <td>
926 <?php
927 $cv = get_site_option('cookiebot-script-tag-cd-attribute','custom');
928 ?>
929 <label>
930 <input type="radio" name="cookiebot-script-tag-cd-attribute" value="" <?php checked('', $cv, true); ?> />
931 <i>None</i>
932 </label>
933 &nbsp; &nbsp;
934 <label>
935 <input type="radio" name="cookiebot-script-tag-cd-attribute" value="async" <?php checked('async',$cv, true); ?> />
936 async
937 </label>
938 &nbsp; &nbsp;
939 <label>
940 <input type="radio" name="cookiebot-script-tag-cd-attribute" value="defer" <?php checked('defer',$cv, true); ?> />
941 defer
942 </label>
943 &nbsp; &nbsp;
944 <label>
945 <input type="radio" name="cookiebot-script-tag-cd-attribute" value="custom" <?php checked('custom',$cv, true); ?> />
946 <i>Choose per subsite</i>
947 </label>
948 <p class="description">
949 <b><?php _e('Setting will apply for all subsites. Subsites will not be able to override.'); ?></b><br />
950 <?php _e('Add async or defer attribute to Cookiebot script tag. Default: Choose per subsite','cookiebot') ?>
951 </p>
952 </td>
953 </tr>
954 <tr valign="top">
955 <th scope="row"><?php _e('Auto-update Cookiebot','cookiebot'); ?></th>
956 <td>
957 <input type="checkbox" name="cookiebot-autoupdate" value="1" <?php checked(1,get_site_option('cookiebot-autoupdate',false), true); ?> />
958 <p class="description">
959 <?php _e('Automatic update your Cookiebot plugin when new releases becomes available.','cookiebot') ?>
960 </p>
961 </td>
962 </tr>
963 <tr valign="top" id="cookiebot-setting-hide-popup">
964 <th scope="row"><?php _e('Hide Cookie Popup','cookiebot'); ?></th>
965 <td>
966 <input type="checkbox" name="cookiebot-nooutput" value="1" <?php checked(1,get_site_option('cookiebot-nooutput',false), true); ?> />
967 <p class="description">
968 <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 />
969 <?php _e('If you are using Google Tag Manager (or equal), you need to add the Cookiebot script in your Tag Manager.','cookiebot') ?><br />
970 <?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') ?>
971 </p>
972 </td>
973 </tr>
974 <tr valign="top">
975 <th scope="row"><?php _e('Hide Cookie Popup in WP Admin','cookiebot'); ?></th>
976 <td>
977 <input type="checkbox" name="cookiebot-nooutput-admin" value="1" <?php checked(1,get_site_option('cookiebot-nooutput-admin',false), true); ?> />
978 <p class="description">
979 <b><?php _e('Remove the cookie consent banner the Wordpress Admin area for all subsites. This cannot be changed by subsites.','cookiebot') ?></b>
980 </p>
981 </td>
982 </tr>
983 </table>
984 <?php submit_button(); ?>
985 </form>
986 </div>
987 <?php
988 }
989
990
991 /**
992 * Cookiebot_WP Cookiebot save network settings
993 *
994 * @version 2.2.0
995 * @since 2.2.0
996 */
997 function network_settings_save() {
998 check_admin_referer( 'cookiebot-network-settings' );
999
1000 update_site_option('cookiebot-cbid', $_POST['cookiebot-cbid'] );
1001 update_site_option('cookiebot-script-tag-uc-attribute', $_POST['cookiebot-script-tag-uc-attribute'] );
1002 update_site_option('cookiebot-script-tag-cd-attribute', $_POST['cookiebot-script-tag-cd-attribute'] );
1003 update_site_option('cookiebot-autoupdate', $_POST['cookiebot-autoupdate'] );
1004 update_site_option('cookiebot-nooutput', $_POST['cookiebot-nooutput'] );
1005 update_site_option('cookiebot-nooutput-admin', $_POST['cookiebot-nooutput-admin'] );
1006 update_site_option('cookiebot-cookie-blocking-mode', $_POST['cookiebot-cookie-blocking-mode'] );
1007
1008
1009 wp_redirect( add_query_arg( array(
1010 'page' => 'cookiebot_network',
1011 'updated' => true ), network_admin_url('admin.php')
1012 ));
1013 exit;
1014 }
1015
1016 /**
1017 * Cookiebot_WP Cookiebot support page
1018 *
1019 * @version 2.2.0
1020 * @since 2.0.0
1021 */
1022 function support_page() {
1023 ?>
1024 <div class="wrap">
1025 <h1><?php _e('Support','cookiebot'); ?></h1>
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>
1033 <li><?php _e('Add <b>[cookie_declaration]</b> shortcode to a page to show the declation','cookiebot'); ?></li>
1034 <li><?php _e('Remember to change your scripts as descripted below','cookiebot'); ?></li>
1035 </ol>
1036 </p>
1037 <h2><?php _e('Add the Cookie Declaration to your website'); ?></h2>
1038 <p>
1039 <?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'); ?>
1040 <br />
1041 <?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'); ?>
1042 </p>
1043 <p>
1044 <a href="https://www.youtube.com/watch?v=OCXz2bt4H_w" target="_blank" class="button"><?php _e('Watch video demonstration','cookiebot'); ?></a>
1045 </p>
1046 <h2><?php _e('Update your script tags','cookiebot'); ?></h2>
1047 <p>
1048 <?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'); ?>
1049 </p>
1050 <code>
1051 <?php
1052 echo htmlentities("<script type=\"text/plain\" data-cookieconsent=\"statistics\">").'<br />';
1053 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 />';
1054 echo htmlentities("ga('create', 'UA-00000000-0', 'auto');").'<br />';
1055 echo htmlentities("ga('send', 'pageview');").'<br />';
1056 echo htmlentities("</script>").'<br />';
1057 ?>
1058 </code>
1059 <p>
1060 <a href="https://www.youtube.com/watch?v=MeHycvV2QCQ" target="_blank" class="button"><?php _e('Watch video demonstration','cookiebot'); ?></a>
1061 </p>
1062
1063 <h2><?php _e('Helper function to update your scripts','cookiebot'); ?></h2>
1064 <p>
1065 <?php _e('You are able to update your scripts yourself. However, Cookiebot also offers a small helper function that makes the work easier.','cookiebot'); ?>
1066 <br />
1067 <?php _e('Update your script tags this way:','cookiebot'); ?>
1068 </p>
1069 <?php
1070 printf(
1071 __('%s to %s'),
1072 '<code>'.htmlentities('<script type="text/javascript">').'</code>',
1073 '<code>'.htmlentities('<script<?php echo cookiebot_assist(\'marketing\') ?>>').'</code>'
1074 );
1075 ?>
1076 </div>
1077 <?php
1078 }
1079
1080 /**
1081 * Cookiebot_WP Cookiebot IAB page
1082 *
1083 * @version 2.0.0
1084 * @since 2.0.0
1085 */
1086 function iab_page() {
1087 ?>
1088 <div class="wrap">
1089 <h1><?php _e('IAB','cookiebot'); ?></h1>
1090
1091 <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>
1092
1093 <form method="post" action="options.php">
1094 <?php settings_fields( 'cookiebot-iab' ); ?>
1095 <?php do_settings_sections( 'cookiebot-iab' ); ?>
1096
1097 <label>Enable IAB integration</label>
1098 <input type="checkbox" name="cookiebot-iab" value="1" <?php checked(1,get_option('cookiebot-iab'), true); ?>>
1099
1100 <?php submit_button(); ?>
1101 </form>
1102 </div>
1103 <?php
1104 }
1105
1106 /**
1107 * Cookiebot_WP Add Cookiebot JS to <head>
1108 *
1109 * @version 2.2.0
1110 * @since 1.0.0
1111 */
1112 function add_js() {
1113 $cbid = $this->get_cbid();
1114 if(!empty($cbid) && !defined('COOKIEBOT_DISABLE_ON_PAGE')) {
1115 if(is_multisite() && get_site_option('cookiebot-nooutput',false)) {
1116 return; //Is multisite - and disabled output is checked as network setting
1117 }
1118 if(get_option('cookiebot-nooutput',false)) {
1119 return; //Do not show JS - output disabled
1120 }
1121
1122 if($this->get_cookie_blocking_mode() == 'auto' && $this->can_current_user_edit_theme() ) {
1123 return;
1124 }
1125
1126 $lang = $this->get_language();
1127 if(!empty($lang)) {
1128 $lang = ' data-culture="'.strtoupper($lang).'"'; //Use data-culture to define language
1129 }
1130
1131 if(!is_multisite() || get_site_option('cookiebot-script-tag-uc-attribute','custom') == 'custom') {
1132 $tagAttr = get_option('cookiebot-script-tag-uc-attribute','async');
1133 }
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 }
1141
1142 $iab = ( get_option('cookiebot-iab') != false ) ? 'data-framework="IAB"' : '';
1143 ?>
1144 <script id="Cookiebot" src="https://consent.cookiebot.com/uc.js" <?php echo $iab; ?> data-cbid="<?php echo $cbid; ?>"<?php echo $lang; ?> type="text/javascript" <?php echo $tagAttr; ?>></script>
1145 <?php
1146 }
1147 }
1148
1149 /**
1150 * Returns true if an user is logged in and has an edit_themes capability
1151 *
1152 * @return bool
1153 *
1154 * @since 3.3.1
1155 * @version 3.4.1
1156 */
1157 function can_current_user_edit_theme() {
1158 if( is_user_logged_in() ) {
1159 if( current_user_can('edit_themes') ) {
1160 return true;
1161 }
1162
1163 if( current_user_can( 'edit_pages' ) ) {
1164 return true;
1165 }
1166
1167 if( current_user_can( 'edit_posts' ) ) {
1168 return true;
1169 }
1170 }
1171
1172 return false;
1173 }
1174
1175 /**
1176 * Cookiebot_WP Output declation shortcode [cookie_declaration]
1177 * Support attribute lang="LANGUAGE_CODE". Eg. lang="en".
1178 *
1179 * @version 2.2.0
1180 * @since 1.0.0
1181 */
1182 function show_declaration($atts) {
1183 $cbid = $this->get_cbid();
1184 $lang = '';
1185 if(!empty($cbid)) {
1186
1187 $atts = shortcode_atts(array(
1188 'lang' => $this->get_language(),
1189 ), $atts, 'cookie_declaration'
1190 );
1191
1192 if(!empty($atts['lang'])) {
1193 $lang = ' data-culture="'.strtoupper($atts['lang']).'"'; //Use data-culture to define language
1194 }
1195
1196 if(!is_multisite() || get_site_option('cookiebot-script-tag-cd-attribute','custom') == 'custom') {
1197 $tagAttr = get_option('cookiebot-script-tag-cd-attribute','async');
1198 }
1199 else {
1200 $tagAttr = get_site_option('cookiebot-script-tag-cd-attribute');
1201 }
1202
1203 return '<script id="CookieDeclaration" src="https://consent.cookiebot.com/'.$cbid.'/cd.js"'.$lang.' type="text/javascript" '.$tagAttr.'></script>';
1204 }
1205 else {
1206 return __('Please add your Cookiebot ID to show Cookie Declarations','cookiebot');
1207 }
1208 }
1209
1210 /**
1211 * Cookiebot_WP Get cookiebot cbid
1212 *
1213 * @version 2.2.0
1214 * @since 1.0.0
1215 */
1216 public static function get_cbid() {
1217 $cbid = get_option('cookiebot-cbid');
1218 if(is_multisite() && ($network_cbid = get_site_option('cookiebot-cbid'))) {
1219 if(empty($cbid)) {
1220 return $network_cbid;
1221 }
1222 }
1223 return $cbid;
1224 }
1225
1226 /**
1227 * Cookiebot_WP Get cookie blocking mode (auto | manual)
1228 *
1229 * @version 2.2.0
1230 * @since 1.0.0
1231 */
1232 public static function get_cookie_blocking_mode() {
1233 $cbm = get_option('cookiebot-cookie-blocking-mode');
1234 if(is_multisite() && ($network_cbm = get_site_option('cookiebot-cookie-blocking-mode'))) {
1235 if(empty($cbm)) {
1236 return $network_cbm;
1237 }
1238 }
1239 if(empty($cbm)) { $cbm = 'manual'; }
1240 return $cbm;
1241 }
1242
1243
1244 /**
1245 * Cookiebot_WP Check if Cookiebot is active in admin
1246 *
1247 * @version 3.1.0
1248 * @since 3.1.0
1249 */
1250 public static function cookiebot_disabled_in_admin() {
1251 if(is_multisite() && get_site_option('cookiebot-nooutput-admin',false)) {
1252 return true;
1253 }
1254 elseif(get_option('cookiebot-nooutput-admin',false)) {
1255 return true;
1256 }
1257 return false;
1258 }
1259
1260 /**
1261 * Cookiebot_WP Get the language code for Cookiebot
1262 *
1263 * @version 1.4.0
1264 * @since 1.4.0
1265 */
1266 function get_language($onlyFromSetting=false) {
1267 // Get language set in setting page - if empty use WP language info
1268 $lang = get_option('cookiebot-language');
1269 if(!empty($lang)) {
1270 if($lang != '_wp') {
1271 return $lang;
1272 }
1273 }
1274
1275 if($onlyFromSetting) {
1276 return $lang; //We want only to get if already set
1277 }
1278
1279 //Language not set - use WP language
1280 if($lang == '_wp') {
1281 $lang = get_bloginfo('language'); //Gets language in en-US format
1282 if(!empty($lang)) {
1283 list($lang) = explode('-',$lang); //Changes format from eg. en-US to en.
1284 }
1285 }
1286 return $lang;
1287 }
1288
1289 /**
1290 * Cookiebot_WP Adding Cookiebot domain(s) to exclude list for WP Rocket minification.
1291 *
1292 * @version 1.6.1
1293 * @since 1.6.1
1294 */
1295 function wp_rocket_exclude_external_js($external_js_hosts) {
1296 $external_js_hosts[] = 'consent.cookiebot.com'; // Add cookiebot domains
1297 $external_js_hosts[] = 'consentcdn.cookiebot.com';
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 *
1388 * @version 2.0.5
1389 * @since 2.0.5
1390 */
1391 function cookiebot_admin_notices() {
1392 if( ! $this->cookiebot_valid_admin_recommendation() ) {
1393 return false;
1394 }
1395 $two_week_review_ignore = add_query_arg( array( 'cookiebot_admin_notice' => 'hide' ) );
1396 $two_week_review_temp = add_query_arg( array( 'cookiebot_admin_notice' => 'two_week' ) );
1397
1398 $notices = array(
1399 'title' => __('Leave A Review?', 'cookiebot'),
1400 'msg' => __('We hope you enjoy using WordPress Cookiebot! Would you consider leaving us a review on WordPress.org?', 'cookiebot'),
1401 '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>
1402 <li><span class="dashicons dashicons-smiley"></span><a href="' . $two_week_review_ignore . '"> ' . __('I\'ve already left a review', 'cookiebot') . '</a></li>
1403 <li><span class="dashicons dashicons-calendar-alt"></span><a href="' . $two_week_review_temp . '">' . __('Maybe Later', 'cookiebot') . '</a></li>
1404 <li><span class="dashicons dashicons-dismiss"></span><a href="' . $two_week_review_ignore . '">' . __('Never show again', 'cookiebot') . '</a></li>',
1405 'later_link' => $two_week_review_temp,
1406 'int' => 14
1407 );
1408
1409 echo '<div class="update-nag cookiebot-admin-notice">
1410 <div class="cookiebot-notice-logo"></div>
1411 <p class="cookiebot-notice-title">' . $notices['title'] . '</p>
1412 <p class="cookiebot-notice-body">' . $notices['msg'] . '</p>
1413 <ul class="cookiebot-notice-body wd-blue">' . $notices['link'] . '</ul>
1414 <a href="' . $notices['later_link'] . '" class="dashicons dashicons-dismiss"></a>
1415 </div>';
1416
1417 wp_enqueue_style( 'cookiebot-admin-notices', plugins_url( 'css/notice.css', __FILE__ ), array(), '2.0.4' );
1418 }
1419
1420
1421 /**
1422 * Validate if the last user action is valid for plugin recommendation
1423 *
1424 * @return bool
1425 *
1426 * @version 2.0.5
1427 * @since 2.0.5
1428 */
1429 function cookiebot_valid_admin_recommendation() {
1430 //Default - the recommendation is allowed to be visible
1431 $return = true;
1432
1433 $option = get_option('cookiebot_notice_recommend');
1434
1435 if( $option != false ) {
1436 //Never show again is clicked
1437 if( $option == 'hide' ) {
1438 $return = false;
1439 }
1440 elseif( is_numeric($option) && strtotime('now') < $option ) {
1441 //Show me after 2 weeks is clicked and the time is not valid yet
1442 $return = false;
1443 }
1444 }
1445 return $return;
1446 }
1447
1448 /**
1449 * Save the user action on cookiebot recommendation link
1450 *
1451 * @version 2.0.5
1452 * @since 2.0.5
1453 */
1454 function save_notice_link() {
1455 if( isset( $_GET['cookiebot_admin_notice'] ) ) {
1456 if( $_GET['cookiebot_admin_notice'] == 'hide' ) {
1457 update_option('cookiebot_notice_recommend', 'hide' );
1458 }
1459 else {
1460 update_option('cookiebot_notice_recommend', strtotime('+2 weeks') );
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
1473 */
1474 function cookiebot_fix_plugin_conflicts() {
1475 //Fix for Divi Page Builder
1476 //Disabled - using another method now (can_current_user_edit_theme())
1477 //add_action( 'wp', array( $this, '_cookiebot_plugin_conflict_divi' ), 100 );
1478
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
1489 */
1490 function _cookiebot_plugin_conflict_divi() {
1491 if ( defined( 'ET_FB_ENABLED' ) ) {
1492 if ( ET_FB_ENABLED &&
1493 $this->cookiebot_disabled_in_admin() &&
1494 $this->get_cookie_blocking_mode() == 'auto' ) {
1495
1496 define('COOKIEBOT_DISABLE_ON_PAGE',true); //Disable Cookiebot on the current page
1497
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',
1519 'backbone-marionette',
1520 'backbone-radio',
1521 'elementor-common-modules',
1522 'elementor-dialog',
1523 'elementor-common',
1524 ] ) ) {
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, [
1532 'jquery-core',
1533 'jquery-ui-core',
1534 'jquery-ui-sortable',
1535 'jquery-ui-mouse',
1536 'jquery-ui-widget',
1537 'vc_editors-templates-preview-js',
1538 'vc-frontend-editor-min-js',
1539 'vc_inline_iframe_js',
1540 'wpb_composer_front_js',
1541 ] ) ) {
1542 $tag = str_replace( '<script ', '<script data-cookieconsent="ignore" ', $tag );
1543 }
1544 }
1545
1546 return $tag;
1547 }
1548
1549 }
1550 endif;
1551
1552
1553 /**
1554 * Helper function to manipulate script tags
1555 *
1556 * @version 1.6
1557 * @since 1.0
1558 * @return string
1559 */
1560 function cookiebot_assist($type='statistics') {
1561 //change to array
1562 if(!is_array($type)) { $type = array($type); }
1563
1564 foreach($type as $tk=>$tv) {
1565 if(!in_array($tv,array('marketing','statistics','preferences'))) {
1566 unset($type[$tk]);
1567 }
1568 }
1569 if(sizeof($type) > 0) {
1570 return ' type="text/plain" data-cookieconsent="'.implode(',',$type).'"';
1571 }
1572 return '';
1573 }
1574
1575
1576 /**
1577 * Helper function to check if cookiebot is active.
1578 * Useful for other plugins adding support for Cookiebot.
1579 *
1580 * @version 2.2.2
1581 * @since 1.2
1582 * @return string
1583 */
1584 function cookiebot_active() {
1585 $cbid = Cookiebot_WP::get_cbid();
1586 if(!empty($cbid)) {
1587 return true;
1588 }
1589 return false;
1590 }
1591
1592
1593 if(!function_exists('cookiebot')) {
1594 /**
1595 * Returns the main instance of Cookiebot_WO to prevent the need to use globals.
1596 *
1597 * @version 1.0.0
1598 * @since 1.0.0
1599 * @return Cookiebot_WP
1600 */
1601 function cookiebot() {
1602 return Cookiebot_WP::instance();
1603 }
1604 }
1605
1606 cookiebot();
1607