PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 3.3.0
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v3.3.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 6 years ago css 6 years ago documentation 6 years ago langs 8 years ago widgets 6 years ago CookiebotAPI.md 6 years ago LICENSE.txt 8 years ago README.md 6 years ago cookiebot-logo.png 8 years ago cookiebot.php 6 years ago phpunit.xml 6 years ago readme.txt 6 years ago
cookiebot.php
1395 lines
1 <?php
2 /*
3 Plugin Name: Cookiebot | GDPR Compliant Cookie Consent and Notice
4 Plugin URI: https://cookiebot.com/
5 Description: Cookiebot is a fully GDPR & ePrivacy compliant cookie consent solution supporting prior consent, cookie declaration, and documentation of consents. Easy to install, implement and configure.
6 Author: Cybot A/S
7 Version: 3.3.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.3.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
165 // Set up localisation
166 load_plugin_textdomain('cookiebot', false, dirname( plugin_basename( __FILE__ ) ) . '/langs/' );
167
168 //add JS
169 add_action('wp_head', array($this,'add_js'), -9999);
170 add_shortcode('cookie_declaration', array($this,'show_declaration'));
171
172 //Add filter if WP rocket is enabled
173 if(defined('WP_ROCKET_VERSION')) {
174 add_filter('rocket_minify_excluded_external_js', array($this,'wp_rocket_exclude_external_js'));
175 }
176
177 //Automatic update plugin
178 if(is_admin() || (defined('DOING_CRON') && DOING_CRON)) {
179 add_filter('auto_update_plugin', array($this,'automatic_updates'), 10, 2);
180 }
181
182 //Loading widgets
183 include_once( dirname( __FILE__ ) . '/widgets/cookiebot-declaration-widget.php' );
184 add_action( 'widgets_init', array($this,'register_widgets') );
185
186 }
187
188 /**
189 * Cookiebot_WP Load text domain
190 *
191 * @version 2.0.0
192 * @since 2.0.0
193 */
194 function load_textdomain() {
195 load_plugin_textdomain( 'cookiebot', false, basename( dirname( __FILE__ ) ) . '/langs' );
196 }
197
198 /**
199 * Cookiebot_WP Register widgets
200 *
201 * @version 2.5.0
202 * @since 2.5.0
203 */
204 function register_widgets() {
205 register_widget( 'Cookiebot_Declaration_Widget' );
206 }
207
208 /**
209 * Cookiebot_WP Add dashboard widgets to admin
210 *
211 * @version 1.0.0
212 * @since 1.0.0
213 */
214
215 function add_dashboard_widgets() {
216 wp_add_dashboard_widget('cookiebot_status', __('Cookiebot Status','cookiebot'), array($this,'dashboard_widget_status'));
217 }
218
219 /**
220 * Cookiebot_WP Output Dashboard Status Widget
221 *
222 * @version 1.0.0
223 * @since 1.0.0
224 */
225 function dashboard_widget_status() {
226 $cbid = $this->get_cbid();
227 if(empty($cbid)) {
228 echo '<p>'.__('You need to enter your Cookiebot ID.','cookiebot').'</p>';
229 echo '<p><a href="options-general.php?page=cookiebot">';
230 echo __('Update your Cookiebot ID','cookiebot');
231 echo '</a></p>';
232 }
233 else {
234 echo '<p>'._e('Your Cookiebot is working!','cookiebot').'</p>';
235 }
236 }
237
238 /**
239 * Cookiebot_WP Add option menu page for Cookiebot
240 *
241 * @version 2.2.0
242 * @since 1.0.0
243 */
244 function add_menu() {
245 //Cookiebot Icon SVG base64 encoded
246 $icon = 'data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgNzIgNTQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iI0ZGRkZGRiIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNNDYuODcyNTkwMyA4Ljc3MzU4MzM0QzQxLjk0MzkwMzkgMy4zODI5NTAxMSAzNC44NDI0OTQ2IDAgMjYuOTQ4MjgxOSAwIDEyLjA2NTE1NjggMCAwIDEyLjAyNDQ3NzQgMCAyNi44NTc0MjE5YzAgMTQuODMyOTQ0NSAxMi4wNjUxNTY4IDI2Ljg1NzQyMTkgMjYuOTQ4MjgxOSAyNi44NTc0MjE5IDcuODk0MjEyNyAwIDE0Ljk5NTYyMi0zLjM4Mjk1MDIgMTkuOTI0MzA4NC04Ljc3MzU4MzQtMi44ODk2OTY3LTEuMzY4ODY2My01LjM5OTMxMS0zLjQwNTQzOS03LjMyODA4MzgtNS45MDk2MzU4LTMuMTIxNDMwNiAzLjIwOTQxMDQtNy40OTI5OTQ0IDUuMjA0MTI5MS0xMi4zMzIwMjU4IDUuMjA0MTI5MS05LjQ4NDM0NDQgMC0xNy4xNzI5MjQ3LTcuNjYyNjU3Mi0xNy4xNzI5MjQ3LTE3LjExNTAyMzhzNy42ODg1ODAzLTE3LjExNTAyMzcgMTcuMTcyOTI0Ny0xNy4xMTUwMjM3YzQuNzIzNDgyMiAwIDkuMDAxNTU1MiAxLjkwMDU5MzkgMTIuMTA2MjkyIDQuOTc2MzA5IDEuOTU2OTIzNy0yLjY0MTEzMSA0LjU1MDAyNjMtNC43ODU1MTgzIDcuNTUzODE3Ni02LjIwODQzMTg2eiIvPjxwYXRoIGQ9Ik01NS4zODAzMjgyIDQyLjY1MDE5OTFDNDYuMzMzNzIyNyA0Mi42NTAxOTkxIDM5IDM1LjM0MTIwMzEgMzkgMjYuMzI1MDk5NiAzOSAxNy4zMDg5OTYgNDYuMzMzNzIyNyAxMCA1NS4zODAzMjgyIDEwYzkuMDQ2NjA1NSAwIDE2LjM4MDMyODIgNy4zMDg5OTYgMTYuMzgwMzI4MiAxNi4zMjUwOTk2IDAgOS4wMTYxMDM1LTcuMzMzNzIyNyAxNi4zMjUwOTk1LTE2LjM4MDMyODIgMTYuMzI1MDk5NXptLjAyMTMwOTItNy43NTU2MzQyYzQuNzM3MDI3NiAwIDguNTc3MTQ3MS0zLjgyNzE3MiA4LjU3NzE0NzEtOC41NDgyMjc5IDAtNC43MjEwNTYtMy44NDAxMTk1LTguNTQ4MjI4LTguNTc3MTQ3MS04LjU0ODIyOC00LjczNzAyNzUgMC04LjU3NzE0NyAzLjgyNzE3Mi04LjU3NzE0NyA4LjU0ODIyOCAwIDQuNzIxMDU1OSAzLjg0MDExOTUgOC41NDgyMjc5IDguNTc3MTQ3IDguNTQ4MjI3OXoiLz48L2c+PC9zdmc+';
247 add_menu_page( 'Cookiebot', __('Cookiebot','cookiebot'), 'manage_options', 'cookiebot', array($this,'settings_page'),$icon);
248
249 add_submenu_page('cookiebot',__('Cookiebot Settings','cookiebot'),__('Settings','cookiebot'), 'manage_options', 'cookiebot',array($this,'settings_page'));
250 add_submenu_page('cookiebot',__('Cookiebot Support','cookiebot'),__('Support','cookiebot'), 'manage_options', 'cookiebot_support',array($this,'support_page'));
251 add_submenu_page('cookiebot',__('IAB','cookiebot'),__('IAB','cookiebot'), 'manage_options', 'cookiebot_iab',array($this,'iab_page'));
252
253 if(defined('COOKIEBOT_ADDONS_UNSUPPORTED_PHPVERSION')) {
254 //Load prior consent page anyway - but from Cookiebot WP Core plugin.
255 add_submenu_page( 'cookiebot', __( 'Prior Consent', 'cookiebot' ), __( 'Prior Consent', 'cookiebot' ), 'manage_options', 'cookiebot-addons', array($this,'setting_page_placeholder' ) );
256 }
257 }
258
259 /**
260 * Cookiebot_WP Add menu for network sites
261 *
262 * @version 2.2.0
263 * @since 2.2.0
264 */
265 function add_network_menu() {
266 $icon = 'data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgNzIgNTQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iI0ZGRkZGRiIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNNDYuODcyNTkwMyA4Ljc3MzU4MzM0QzQxLjk0MzkwMzkgMy4zODI5NTAxMSAzNC44NDI0OTQ2IDAgMjYuOTQ4MjgxOSAwIDEyLjA2NTE1NjggMCAwIDEyLjAyNDQ3NzQgMCAyNi44NTc0MjE5YzAgMTQuODMyOTQ0NSAxMi4wNjUxNTY4IDI2Ljg1NzQyMTkgMjYuOTQ4MjgxOSAyNi44NTc0MjE5IDcuODk0MjEyNyAwIDE0Ljk5NTYyMi0zLjM4Mjk1MDIgMTkuOTI0MzA4NC04Ljc3MzU4MzQtMi44ODk2OTY3LTEuMzY4ODY2My01LjM5OTMxMS0zLjQwNTQzOS03LjMyODA4MzgtNS45MDk2MzU4LTMuMTIxNDMwNiAzLjIwOTQxMDQtNy40OTI5OTQ0IDUuMjA0MTI5MS0xMi4zMzIwMjU4IDUuMjA0MTI5MS05LjQ4NDM0NDQgMC0xNy4xNzI5MjQ3LTcuNjYyNjU3Mi0xNy4xNzI5MjQ3LTE3LjExNTAyMzhzNy42ODg1ODAzLTE3LjExNTAyMzcgMTcuMTcyOTI0Ny0xNy4xMTUwMjM3YzQuNzIzNDgyMiAwIDkuMDAxNTU1MiAxLjkwMDU5MzkgMTIuMTA2MjkyIDQuOTc2MzA5IDEuOTU2OTIzNy0yLjY0MTEzMSA0LjU1MDAyNjMtNC43ODU1MTgzIDcuNTUzODE3Ni02LjIwODQzMTg2eiIvPjxwYXRoIGQ9Ik01NS4zODAzMjgyIDQyLjY1MDE5OTFDNDYuMzMzNzIyNyA0Mi42NTAxOTkxIDM5IDM1LjM0MTIwMzEgMzkgMjYuMzI1MDk5NiAzOSAxNy4zMDg5OTYgNDYuMzMzNzIyNyAxMCA1NS4zODAzMjgyIDEwYzkuMDQ2NjA1NSAwIDE2LjM4MDMyODIgNy4zMDg5OTYgMTYuMzgwMzI4MiAxNi4zMjUwOTk2IDAgOS4wMTYxMDM1LTcuMzMzNzIyNyAxNi4zMjUwOTk1LTE2LjM4MDMyODIgMTYuMzI1MDk5NXptLjAyMTMwOTItNy43NTU2MzQyYzQuNzM3MDI3NiAwIDguNTc3MTQ3MS0zLjgyNzE3MiA4LjU3NzE0NzEtOC41NDgyMjc5IDAtNC43MjEwNTYtMy44NDAxMTk1LTguNTQ4MjI4LTguNTc3MTQ3MS04LjU0ODIyOC00LjczNzAyNzUgMC04LjU3NzE0NyAzLjgyNzE3Mi04LjU3NzE0NyA4LjU0ODIyOCAwIDQuNzIxMDU1OSAzLjg0MDExOTUgOC41NDgyMjc5IDguNTc3MTQ3IDguNTQ4MjI3OXoiLz48L2c+PC9zdmc+';
267 add_menu_page( 'Cookiebot', __('Cookiebot','cookiebot'), 'manage_network_options', 'cookiebot_network', array($this,'network_settings_page'),$icon);
268
269 add_submenu_page('cookiebot_network',__('Cookiebot Settings','cookiebot'),__('Settings','cookiebot'), 'network_settings_page', 'cookiebot_network',array($this,'network_settings_page'));
270 add_submenu_page('cookiebot_network',__('Cookiebot Support','cookiebot'),__('Support','cookiebot'), 'network_settings_page', 'cookiebot_support',array($this,'support_page'));
271
272 }
273
274 /**
275 * Cookiebot_WP Cookiebot prior consent placeholder page
276 *
277 * @version 1.4.0
278 * @since 1.0.0
279 */
280 function setting_page_placeholder() {
281 include __DIR__ . DIRECTORY_SEPARATOR . 'addons' . DIRECTORY_SEPARATOR . 'view/admin/settings/setting-page.php';
282 }
283
284 /**
285 * Cookiebot_WP Register Cookiebot settings
286 *
287 * @version 2.1.5
288 * @since 1.0.0
289 */
290 function register_cookiebot_settings() {
291 register_setting('cookiebot', 'cookiebot-cbid');
292 register_setting('cookiebot', 'cookiebot-language');
293 register_setting('cookiebot', 'cookiebot-nooutput');
294 register_setting('cookiebot', 'cookiebot-nooutput-admin');
295 register_setting('cookiebot', 'cookiebot-autoupdate');
296 register_setting('cookiebot', 'cookiebot-script-tag-uc-attribute');
297 register_setting('cookiebot', 'cookiebot-script-tag-cd-attribute');
298 register_setting('cookiebot', 'cookiebot-cookie-blocking-mode');
299 register_setting('cookiebot-iab', 'cookiebot-iab');
300 }
301
302 /**
303 * Cookiebot_WP Automatic update plugin if activated
304 *
305 * @version 2.2.0
306 * @since 1.5.0
307 */
308 function automatic_updates($update, $item) {
309 //Do not update from subsite on a multisite installation
310 if(is_multisite() && ! is_main_site()) {
311 return $update;
312 }
313
314 //Check if we have everything we need
315 $item = (array)$item;
316 if(!isset($item['new_version']) || !isset($item['slug'])) {
317 return $update;
318 }
319
320 //It is not Cookiebot
321 if($item['slug'] !== 'cookiebot') {
322 return $update;
323 }
324
325 // Check if cookiebot autoupdate is disabled
326 if(!get_option('cookiebot-autoupdate',false)) {
327 return $update;
328 }
329
330 // Check if multisite autoupdate is disabled
331 if(is_multisite() && !get_site_option('cookiebot-autoupdate',false)) {
332 return $update;
333 }
334
335 return true;
336 }
337
338
339 /**
340 * Cookiebot_WP Get list of supported languages
341 *
342 * @version 1.4.0
343 * @since 1.4.0
344 */
345 public static function get_supported_languages() {
346 $supportedLanguages = array();
347 $supportedLanguages['nb'] = __('Norwegian Bokmål','cookiebot');
348 $supportedLanguages['tr'] = __('Turkish','cookiebot');
349 $supportedLanguages['de'] = __('German','cookiebot');
350 $supportedLanguages['cs'] = __('Czech','cookiebot');
351 $supportedLanguages['da'] = __('Danish','cookiebot');
352 $supportedLanguages['sq'] = __('Albanian','cookiebot');
353 $supportedLanguages['he'] = __('Hebrew','cookiebot');
354 $supportedLanguages['ko'] = __('Korean','cookiebot');
355 $supportedLanguages['it'] = __('Italian','cookiebot');
356 $supportedLanguages['nl'] = __('Dutch','cookiebot');
357 $supportedLanguages['vi'] = __('Vietnamese','cookiebot');
358 $supportedLanguages['ta'] = __('Tamil','cookiebot');
359 $supportedLanguages['is'] = __('Icelandic','cookiebot');
360 $supportedLanguages['ro'] = __('Romanian','cookiebot');
361 $supportedLanguages['si'] = __('Sinhala','cookiebot');
362 $supportedLanguages['ca'] = __('Catalan','cookiebot');
363 $supportedLanguages['bg'] = __('Bulgarian','cookiebot');
364 $supportedLanguages['uk'] = __('Ukrainian','cookiebot');
365 $supportedLanguages['zh'] = __('Chinese','cookiebot');
366 $supportedLanguages['en'] = __('English','cookiebot');
367 $supportedLanguages['ar'] = __('Arabic','cookiebot');
368 $supportedLanguages['hr'] = __('Croatian','cookiebot');
369 $supportedLanguages['th'] = __('Thai','cookiebot');
370 $supportedLanguages['el'] = __('Greek','cookiebot');
371 $supportedLanguages['lt'] = __('Lithuanian','cookiebot');
372 $supportedLanguages['pl'] = __('Polish','cookiebot');
373 $supportedLanguages['lv'] = __('Latvian','cookiebot');
374 $supportedLanguages['fr'] = __('French','cookiebot');
375 $supportedLanguages['id'] = __('Indonesian','cookiebot');
376 $supportedLanguages['mk'] = __('Macedonian','cookiebot');
377 $supportedLanguages['et'] = __('Estonian','cookiebot');
378 $supportedLanguages['pt'] = __('Portuguese','cookiebot');
379 $supportedLanguages['ga'] = __('Irish','cookiebot');
380 $supportedLanguages['ms'] = __('Malay','cookiebot');
381 $supportedLanguages['sl'] = __('Slovenian','cookiebot');
382 $supportedLanguages['ru'] = __('Russian','cookiebot');
383 $supportedLanguages['ja'] = __('Japanese','cookiebot');
384 $supportedLanguages['hi'] = __('Hindi','cookiebot');
385 $supportedLanguages['sk'] = __('Slovak','cookiebot');
386 $supportedLanguages['es'] = __('Spanish','cookiebot');
387 $supportedLanguages['sv'] = __('Swedish','cookiebot');
388 $supportedLanguages['sr'] = __('Serbian','cookiebot');
389 $supportedLanguages['fi'] = __('Finnish','cookiebot');
390 $supportedLanguages['eu'] = __('Basque','cookiebot');
391 asort($supportedLanguages,SORT_LOCALE_STRING);
392 return $supportedLanguages;
393 }
394
395 /**
396 * Cookiebot_WP Output settings page
397 *
398 * @version 2.2.0
399 * @since 1.0.0
400 */
401 function settings_page() {
402 /* Check if multisite */
403 if($is_ms = is_multisite()) {
404 //Receive settings from multisite - this might change the way we render the form
405 $network_cbid = get_site_option('cookiebot-cbid','');
406 $network_scrip_tag_uc_attr = get_site_option('cookiebot-script-tag-uc-attribute','custom');
407 $network_scrip_tag_cd_attr = get_site_option('cookiebot-script-tag-cd-attribute','custom');
408 $network_cookie_blocking_mode = get_site_option('cookiebot-cookie-blocking-mode','manual');
409 }
410 ?>
411 <div class="wrap">
412 <h1><?php _e('Cookiebot Settings','cookiebot'); ?></h1>
413 <a href="https://www.cookiebot.com">
414 <img src="<?php echo plugins_url( 'cookiebot-logo.png', __FILE__ ); ?>" style="float:right;margin-left:1em;">
415 </a>
416 <p>
417 <?php _e('Cookiebot enables your website to comply with current legislation in the EU on the use of cookies for user tracking and profiling. The EU ePrivacy Directive requires prior, informed consent of your site users, while the <a href="https://www.cookiebot.com/en/gdpr" target="_blank">General Data Protection Regulation (GDPR)</a> requires you to document each consent. At the same time you must be able to account for what user data you share with embedded third-party services on your website and where in the world the user data is sent.','cookiebot'); ?>
418 </p>
419 <form method="post" action="options.php">
420 <?php settings_fields( 'cookiebot' ); ?>
421 <?php do_settings_sections( 'cookiebot' ); ?>
422 <table class="form-table">
423 <tr valign="top">
424 <th scope="row"><?php _e('Cookiebot ID','cookiebot'); ?></th>
425 <td>
426 <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" />
427 <p class="description">
428 <?php _e('Need an ID?','cookiebot'); ?>
429 <a href="https://www.cookiebot.com/en/signup" target="_blank"><?php _e('Sign up for free on cookiebot.com','cookiebot'); ?></a>
430 </p>
431 </td>
432 </tr>
433 <tr valign="top">
434 <th scope="row">
435 <?php _e('Cookie-blocking mode','cookiebot'); ?>
436 </th>
437 <td>
438 <?php
439 $cbm = get_option('cookiebot-cookie-blocking-mode','manual');
440 if($is_ms && $network_cookie_blocking_mode != 'custom') {
441 $cbm = $network_cookie_blocking_mode;
442 }
443 ?>
444 <label>
445 <input type="radio" name="cookiebot-cookie-blocking-mode" value="auto" <?php checked('auto', $cbm, true); ?> />
446 <?php _e('Automatic','cookiebot'); ?>
447 </label>
448 &nbsp; &nbsp;
449 <label>
450 <input type="radio" name="cookiebot-cookie-blocking-mode" value="manual" <?php checked('manual',$cbm, true); ?> />
451 <?php _e('Manual','cookiebot'); ?>
452 </label>
453 <p class="description">
454 <?php _e('Automatic block cookies (except necessary) untill the user has given their consent.','cookiebot') ?>
455 <a href="https://support.cookiebot.com/hc/en-us/articles/360009063100-Automatic-Cookie-Blocking-How-does-it-work-" target="_blank">
456 <?php _e('Learn more','cookiebot'); ?>
457 </a>
458 </p>
459 <script>
460 jQuery(document).ready(function($) {
461 var cookieBlockingMode = '<?php echo $cbm; ?>';
462 $( 'input[type=radio][name=cookiebot-cookie-blocking-mode]' ).on( 'change', function() {
463 if(this.value == 'auto' && cookieBlockingMode != this.value ) {
464 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 );
465 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true );
466 }
467 if( this.value == 'manual' && cookieBlockingMode != this.value ) {
468 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 1 );
469 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', false );
470 }
471 cookieBlockingMode = this.value;
472 });
473 if( cookieBlockingMode == 'auto' ) {
474 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 );
475 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true );
476 }
477 });
478 </script>
479 </td>
480 </tr>
481 <tr valign="top">
482 <th scope="row"><?php _e('Cookiebot Language','cookiebot'); ?></th>
483 <td>
484 <div>
485 <select name="cookiebot-language" id="cookiebot-language">
486 <?php
487 $currentLang = $this->get_language(true);
488 ?>
489 <option value=""><?php _e('Default (Autodetect)','cookiebot'); ?></option>
490 <option value="_wp"<?php echo ($currentLang == '_wp') ? ' selected' : ''; ?>><?php _e('Use Wordpress Language','cookiebot'); ?></option>
491 <?php
492 $supportedLanguages = $this->get_supported_languages();
493 foreach($supportedLanguages as $langCode=>$langName) {
494 echo '<option value="'.$langCode.'"'.(($currentLang==$langCode) ? ' selected' : '').'>'.$langName.'</option>';
495 }
496 ?>
497 </select>
498 </div>
499 <div class="notice inline notice-warning notice-alt cookiebot-notice" style="padding:12px;font-size:13px;display:inline-block;">
500 <div style="<?php echo ($currentLang=='') ? 'display:none;' : '' ?>" id="info_lang_specified">
501 <?php _e('You need to add the language in the Cookiebot administration tool.'); ?>
502 </div>
503 <div style="<?php echo ($currentLang=='') ? '' : 'display:none;' ?>" id="info_lang_autodetect">
504 <?php _e('You need to add all languages that you want auto-detected in the Cookiebot administration tool.'); ?> <br/>
505 <?php _e('The auto-detect checkbox needs to be enabled in the Cookiebot administration tool.'); ?><br/>
506 <?php _e('If the auto-detected language is not supported, Cookiebot will use the default language.'); ?>
507 </div>
508 <br />
509
510 <a href="#" id="show_add_language_guide"><?php _e('Show guide to add languages'); ?></a>
511 &nbsp;
512 <a href="https://support.cookiebot.com/hc/en-us/articles/360003793394-How-do-I-set-the-language-of-the-consent-banner-dialog-" target="_blank">
513 <?php _e('Read more here'); ?>
514 </a>
515
516 <div id="add_language_guide" style="display:none;">
517 <img src="<?php echo plugin_dir_url( __FILE__ ); ?>/assets/guide_add_language.gif" alt="Add language in Cookiebot administration tool" />
518 <br />
519 <a href="#" id="hide_add_language_guide"><?php _e('Hide guide'); ?></a>
520 </div>
521 </div>
522 <script>
523 jQuery(document).ready(function($) {
524 $('#show_add_language_guide').on('click',function(e) {
525 e.preventDefault();
526 $('#add_language_guide').slideDown();
527 $(this).hide();
528 });
529 $('#hide_add_language_guide').on('click',function(e) {
530 e.preventDefault();
531 $('#add_language_guide').slideUp();
532 $('#show_add_language_guide').show();
533 });
534
535 $('#cookiebot-language').on('change', function() {
536 if(this.value == '') {
537 $('#info_lang_autodetect').show();
538 $('#info_lang_specified').hide();
539 }
540 else {
541 $('#info_lang_autodetect').hide();
542 $('#info_lang_specified').show();
543 }
544 });
545 });
546 </script>
547
548 </td>
549 </tr>
550 </table>
551 <script>
552 jQuery(document).ready(function($) {
553 $('#advanced_settings_link').on('click',function(e) {
554 e.preventDefault();
555 $('#advanced_settings').slideToggle();
556 $('#advanced_settings_link').toggleClass('active');
557 });
558 });
559 </script>
560 <style type="text/css">
561 #advanced_settings_link {
562 cursor:pointer;
563 }
564 #advanced_settings_link::after {
565 content: "\f140";
566 font: normal 24px/1 dashicons;
567 position: relative;
568 top: 5px;
569 }
570 #advanced_settings_link.active::after {
571 content: "\f142";
572 }
573 </style>
574 <h3 id="advanced_settings_link"><?php _e('Advanced settings', 'cookiebot'); ?></h3>
575 <div id="advanced_settings" style="display:none;">
576 <table class="form-table">
577 <tr valign="top" id="cookiebot-setting-async">
578 <th scope="row">
579 <?php _e('Add async or defer attribute','cookiebot'); ?>
580 <br /><?php _e('Consent banner script tag'); ?>
581 </th>
582 <td>
583 <?php
584 $cv = get_option('cookiebot-script-tag-uc-attribute','async');
585 $disabled = false;
586 if($is_ms && $network_scrip_tag_uc_attr != 'custom') {
587 $disabled = true;
588 $cv = $network_scrip_tag_uc_attr;
589 }
590 ?>
591 <label>
592 <input type="radio" name="cookiebot-script-tag-uc-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="" <?php checked('', $cv, true); ?> />
593 <i>None</i>
594 </label>
595 &nbsp; &nbsp;
596 <label>
597 <input type="radio" name="cookiebot-script-tag-uc-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="async" <?php checked('async',$cv, true); ?> />
598 async
599 </label>
600 &nbsp; &nbsp;
601 <label>
602 <input type="radio" name="cookiebot-script-tag-uc-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="defer" <?php checked('defer',$cv, true); ?> />
603 defer
604 </label>
605 <p class="description">
606 <?php if($disabled) { echo '<b>'._('Network setting applied. Please contact website administrator to change this setting.').'</b><br />'; } ?>
607 <?php _e('Add async or defer attribute to Cookiebot script tag. Default: async','cookiebot') ?>
608 </p>
609 </td>
610 </tr>
611 <tr valign="top">
612 <th scope="row">
613 <?php _e('Add async or defer attribute','cookiebot'); ?>
614 <br /><?php _e('Cookie declaration script tag'); ?>
615 </th>
616 <td>
617 <?php
618 $cv = get_option('cookiebot-script-tag-cd-attribute','async');
619 $disabled = false;
620 if($is_ms && $network_scrip_tag_cd_attr != 'custom') {
621 $disabled = true;
622 $cv = $network_scrip_tag_cd_attr;
623 }
624 ?>
625 <label>
626 <input type="radio" name="cookiebot-script-tag-cd-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="" <?php checked('', $cv, true); ?> />
627 <i>None</i>
628 </label>
629 &nbsp; &nbsp;
630 <label>
631 <input type="radio" name="cookiebot-script-tag-cd-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="async" <?php checked('async',$cv, true); ?> />
632 async
633 </label>
634 &nbsp; &nbsp;
635 <label>
636 <input type="radio" name="cookiebot-script-tag-cd-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="defer" <?php checked('defer',$cv, true); ?> />
637 defer
638 </label>
639 <p class="description">
640 <?php if($disabled) { echo '<b>'._('Network setting applied. Please contact website administrator to change this setting.').'</b><br />'; } ?>
641 <?php _e('Add async or defer attribute to Cookiebot script tag. Default: async','cookiebot') ?>
642 </p>
643 </td>
644 </tr>
645 <?php
646 if(!is_multisite()) {
647 ?>
648 <tr valign="top">
649 <th scope="row"><?php _e('Auto-update Cookiebot','cookiebot'); ?></th>
650 <td>
651 <input type="checkbox" name="cookiebot-autoupdate" value="1" <?php checked(1,get_option('cookiebot-autoupdate',false), true); ?> />
652 <p class="description">
653 <?php _e('Automatic update your Cookiebot plugin when new releases becomes available.','cookiebot') ?>
654 </p>
655 </td>
656 </tr>
657 <?php
658 }
659 ?>
660 <tr valign="top" id="cookiebot-setting-hide-popup">
661 <th scope="row"><?php _e('Hide Cookie Popup','cookiebot'); ?></th>
662 <td>
663 <?php
664 $disabled = false;
665 if($is_ms && get_site_option('cookiebot-nooutput',false)) {
666 $disabled = true;
667 echo '<input type="checkbox" checked disabled />';
668 }
669 else {
670 ?>
671 <input type="checkbox" name="cookiebot-nooutput" value="1" <?php checked(1,get_option('cookiebot-nooutput',false), true); ?> />
672 <?php
673 }
674 ?>
675 <p class="description">
676 <?php if($disabled) { echo '<b>'._('Network setting applied. Please contact website administrator to change this setting.').'</b><br />'; } ?>
677 <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 />
678 <?php _e('If you are using Google Tag Manager (or equal), you need to add the Cookiebot script in your Tag Manager.','cookiebot') ?><br />
679 <?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') ?>
680 </p>
681 </td>
682 </tr>
683 <tr valign="top">
684 <th scope="row"><?php _e('Disable Cookiebot in WP Admin','cookiebot'); ?></th>
685 <td>
686 <?php
687 $disabled = false;
688 if($is_ms && get_site_option('cookiebot-nooutput-admin',false)) {
689 echo '<input type="checkbox" checked disabled />';
690 $disabled = true;
691 }
692 else {
693 ?>
694 <input type="checkbox" name="cookiebot-nooutput-admin" value="1" <?php checked(1,get_option('cookiebot-nooutput-admin',false), true); ?> />
695 <?php
696 }
697 ?>
698 <p class="description">
699 <?php if($disabled) { echo '<b>'._('Network setting applied. Please contact website administrator to change this setting.').'</b><br />'; } ?>
700 <b><?php _e('This checkbox will disable Cookiebot in the Wordpress Admin area.','cookiebot') ?></b>
701 </p>
702 </td>
703 </tr>
704 </table>
705 </div>
706 <?php submit_button(); ?>
707 </form>
708 </div>
709 <?php
710 }
711
712 /**
713 * Cookiebot_WP Cookiebot network setting page
714 *
715 * @version 2.2.0
716 * @since 2.2.0
717 */
718 function network_settings_page() {
719 ?>
720 <div class="wrap">
721 <h1><?php _e('Cookiebot Network Settings','cookiebot'); ?></h1>
722 <a href="https://www.cookiebot.com">
723 <img src="<?php echo plugins_url( 'cookiebot-logo.png', __FILE__ ); ?>" style="float:right;margin-left:1em;">
724 </a>
725 <p>
726 <?php _e('Cookiebot enables your website to comply with current legislation in the EU on the use of cookies for user tracking and profiling. The EU ePrivacy Directive requires prior, informed consent of your site users, while the <a href="https://www.cookiebot.com/en/gdpr" target="_blank">General Data Protection Regulation (GDPR)</a> requires you to document each consent. At the same time you must be able to account for what user data you share with embedded third-party services on your website and where in the world the user data is sent.','cookiebot'); ?>
727 </p>
728 <p>
729 <b><big style="color:red;"><?php _e('The settings below is network wide settings. See notes below each field.'); ?></big></b>
730 </p>
731 <form method="post" action="edit.php?action=cookiebot_network_settings">
732 <?php wp_nonce_field( 'cookiebot-network-settings' ); ?>
733 <table class="form-table">
734 <tr valign="top">
735 <th scope="row"><?php _e('Network Cookiebot ID','cookiebot'); ?></th>
736 <td>
737 <input type="text" name="cookiebot-cbid" value="<?php echo esc_attr( get_site_option('cookiebot-cbid','') ); ?>" style="width:300px" />
738 <p class="description">
739 <b><?php _e('If added this will be the default Cookiebot ID for all subsites. Subsites are able to override the Cookiebot ID.'); ?></b>
740 <br />
741 <?php _e('Need an ID?','cookiebot'); ?>
742 <a href="https://www.cookiebot.com/en/signup" target="_blank"><?php _e('Sign up for free on cookiebot.com','cookiebot'); ?></a>
743 </p>
744 </td>
745 </tr>
746 <tr valign="top">
747 <th scope="row">
748 <?php _e('Cookie-blocking mode','cookiebot'); ?>
749 </th>
750 <td>
751 <?php
752 $cbm = get_site_option('cookiebot-cookie-blocking-mode','manual');
753 ?>
754 <label>
755 <input type="radio" name="cookiebot-cookie-blocking-mode" value="auto" <?php checked('auto', $cbm, true); ?> />
756 <?php _e('Automatic','cookiebot'); ?>
757 </label>
758 &nbsp; &nbsp;
759 <label>
760 <input type="radio" name="cookiebot-cookie-blocking-mode" value="manual" <?php checked('manual',$cbm, true); ?> />
761 <?php _e('Manual','cookiebot'); ?>
762 </label>
763 <p class="description">
764 <?php _e('Should Cookiebot automatic block cookies by tagging known tags.','cookiebot') ?>
765 </p>
766 </td>
767 </tr>
768 <script>
769 jQuery(document).ready(function($) {
770 var cookieBlockingMode = '<?php echo $cbm; ?>';
771 $( 'input[type=radio][name=cookiebot-cookie-blocking-mode]' ).on( 'change', function() {
772 if(this.value == 'auto' && cookieBlockingMode != this.value ) {
773 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 );
774 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true );
775 }
776 if( this.value == 'manual' && cookieBlockingMode != this.value ) {
777 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 1 );
778 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', false );
779 }
780 cookieBlockingMode = this.value;
781 });
782 if( cookieBlockingMode == 'auto' ) {
783 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 );
784 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true );
785 }
786 });
787 </script>
788 <tr valign="top" id="cookiebot-setting-async">
789 <th scope="row">
790 <?php _e('Add async or defer attribute','cookiebot'); ?>
791 <br /><?php _e('Consent banner script tag'); ?>
792 </th>
793 <td>
794 <?php
795 $cv = get_site_option('cookiebot-script-tag-uc-attribute','custom');
796 ?>
797 <label>
798 <input type="radio" name="cookiebot-script-tag-uc-attribute" value="" <?php checked('', $cv, true); ?> />
799 <i>None</i>
800 </label>
801 &nbsp; &nbsp;
802 <label>
803 <input type="radio" name="cookiebot-script-tag-uc-attribute" value="async" <?php checked('async',$cv, true); ?> />
804 async
805 </label>
806 &nbsp; &nbsp;
807 <label>
808 <input type="radio" name="cookiebot-script-tag-uc-attribute" value="defer" <?php checked('defer',$cv, true); ?> />
809 defer
810 </label>
811 &nbsp; &nbsp;
812 <label>
813 <input type="radio" name="cookiebot-script-tag-uc-attribute" value="custom" <?php checked('custom',$cv, true); ?> />
814 <i>Choose per subsite</i>
815 </label>
816 <p class="description">
817 <b><?php _e('Setting will apply for all subsites. Subsites will not be able to override.'); ?></b><br />
818 <?php _e('Add async or defer attribute to Cookiebot script tag. Default: Choose per subsite','cookiebot') ?>
819 </p>
820 </td>
821 </tr>
822 <tr valign="top">
823 <th scope="row">
824 <?php _e('Add async or defer attribute','cookiebot'); ?>
825 <br /><?php _e('Cookie declaration script tag'); ?>
826 </th>
827 <td>
828 <?php
829 $cv = get_site_option('cookiebot-script-tag-cd-attribute','custom');
830 ?>
831 <label>
832 <input type="radio" name="cookiebot-script-tag-cd-attribute" value="" <?php checked('', $cv, true); ?> />
833 <i>None</i>
834 </label>
835 &nbsp; &nbsp;
836 <label>
837 <input type="radio" name="cookiebot-script-tag-cd-attribute" value="async" <?php checked('async',$cv, true); ?> />
838 async
839 </label>
840 &nbsp; &nbsp;
841 <label>
842 <input type="radio" name="cookiebot-script-tag-cd-attribute" value="defer" <?php checked('defer',$cv, true); ?> />
843 defer
844 </label>
845 &nbsp; &nbsp;
846 <label>
847 <input type="radio" name="cookiebot-script-tag-cd-attribute" value="custom" <?php checked('custom',$cv, true); ?> />
848 <i>Choose per subsite</i>
849 </label>
850 <p class="description">
851 <b><?php _e('Setting will apply for all subsites. Subsites will not be able to override.'); ?></b><br />
852 <?php _e('Add async or defer attribute to Cookiebot script tag. Default: Choose per subsite','cookiebot') ?>
853 </p>
854 </td>
855 </tr>
856 <tr valign="top">
857 <th scope="row"><?php _e('Auto-update Cookiebot','cookiebot'); ?></th>
858 <td>
859 <input type="checkbox" name="cookiebot-autoupdate" value="1" <?php checked(1,get_site_option('cookiebot-autoupdate',false), true); ?> />
860 <p class="description">
861 <?php _e('Automatic update your Cookiebot plugin when new releases becomes available.','cookiebot') ?>
862 </p>
863 </td>
864 </tr>
865 <tr valign="top" id="cookiebot-setting-hide-popup">
866 <th scope="row"><?php _e('Hide Cookie Popup','cookiebot'); ?></th>
867 <td>
868 <input type="checkbox" name="cookiebot-nooutput" value="1" <?php checked(1,get_site_option('cookiebot-nooutput',false), true); ?> />
869 <p class="description">
870 <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 />
871 <?php _e('If you are using Google Tag Manager (or equal), you need to add the Cookiebot script in your Tag Manager.','cookiebot') ?><br />
872 <?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') ?>
873 </p>
874 </td>
875 </tr>
876 <tr valign="top">
877 <th scope="row"><?php _e('Hide Cookie Popup in WP Admin','cookiebot'); ?></th>
878 <td>
879 <input type="checkbox" name="cookiebot-nooutput-admin" value="1" <?php checked(1,get_site_option('cookiebot-nooutput-admin',false), true); ?> />
880 <p class="description">
881 <b><?php _e('Remove the cookie consent banner the Wordpress Admin area for all subsites. This cannot be changed by subsites.','cookiebot') ?></b>
882 </p>
883 </td>
884 </tr>
885 </table>
886 <?php submit_button(); ?>
887 </form>
888 </div>
889 <?php
890 }
891
892
893 /**
894 * Cookiebot_WP Cookiebot save network settings
895 *
896 * @version 2.2.0
897 * @since 2.2.0
898 */
899 function network_settings_save() {
900 check_admin_referer( 'cookiebot-network-settings' );
901
902 update_site_option('cookiebot-cbid', $_POST['cookiebot-cbid'] );
903 update_site_option('cookiebot-script-tag-uc-attribute', $_POST['cookiebot-script-tag-uc-attribute'] );
904 update_site_option('cookiebot-script-tag-cd-attribute', $_POST['cookiebot-script-tag-cd-attribute'] );
905 update_site_option('cookiebot-autoupdate', $_POST['cookiebot-autoupdate'] );
906 update_site_option('cookiebot-nooutput', $_POST['cookiebot-nooutput'] );
907 update_site_option('cookiebot-nooutput-admin', $_POST['cookiebot-nooutput-admin'] );
908 update_site_option('cookiebot-cookie-blocking-mode', $_POST['cookiebot-cookie-blocking-mode'] );
909
910
911 wp_redirect( add_query_arg( array(
912 'page' => 'cookiebot_network',
913 'updated' => true ), network_admin_url('admin.php')
914 ));
915 exit;
916 }
917
918 /**
919 * Cookiebot_WP Cookiebot support page
920 *
921 * @version 2.2.0
922 * @since 2.0.0
923 */
924 function support_page() {
925 ?>
926 <div class="wrap">
927 <h1><?php _e('Support','cookiebot'); ?></h1>
928 <h2><?php _e('How to find my Cookiebot ID','cookiebot'); ?></h2>
929 <p>
930 <ol>
931 <li><?php _e('Log in to your <a href="https://www.cookiebot.com/en/account" target="_blank">Cookiebot account</a>.','cookiebot'); ?></li>
932 <li><?php _e('Go to <b>Manage</b> > <b>Settings</b> and add setup your Cookiebot','cookiebot'); ?></li>
933 <li><?php _e('Go to the <b>"Your scripts"</b> tab','cookiebot'); ?></li>
934 <li><?php _e('Copy the value inside the data-cid parameter - eg.: abcdef12-3456-7890-abcd-ef1234567890','cookiebot'); ?></li>
935 <li><?php _e('Add <b>[cookie_declaration]</b> shortcode to a page to show the declation','cookiebot'); ?></li>
936 <li><?php _e('Remember to change your scripts as descripted below','cookiebot'); ?></li>
937 </ol>
938 </p>
939 <h2><?php _e('Add the Cookie Declaration to your website'); ?></h2>
940 <p>
941 <?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'); ?>
942 <br />
943 <?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'); ?>
944 </p>
945 <p>
946 <a href="https://www.youtube.com/watch?v=OCXz2bt4H_w" target="_blank" class="button"><?php _e('Watch video demonstration','cookiebot'); ?></a>
947 </p>
948 <h2><?php _e('Update your script tags','cookiebot'); ?></h2>
949 <p>
950 <?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'); ?>
951 </p>
952 <code>
953 <?php
954 echo htmlentities("<script type=\"text/plain\" data-cookieconsent=\"statistics\">").'<br />';
955 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 />';
956 echo htmlentities("ga('create', 'UA-00000000-0', 'auto');").'<br />';
957 echo htmlentities("ga('send', 'pageview');").'<br />';
958 echo htmlentities("</script>").'<br />';
959 ?>
960 </code>
961 <p>
962 <a href="https://www.youtube.com/watch?v=MeHycvV2QCQ" target="_blank" class="button"><?php _e('Watch video demonstration','cookiebot'); ?></a>
963 </p>
964
965 <h2><?php _e('Helper function to update your scripts','cookiebot'); ?></h2>
966 <p>
967 <?php _e('You are able to update your scripts yourself. However, Cookiebot also offers a small helper function that makes the work easier.','cookiebot'); ?>
968 <br />
969 <?php _e('Update your script tags this way:','cookiebot'); ?>
970 </p>
971 <?php
972 printf(
973 __('%s to %s'),
974 '<code>'.htmlentities('<script type="text/javascript">').'</code>',
975 '<code>'.htmlentities('<script<?php echo cookiebot_assist(\'marketing\') ?>>').'</code>'
976 );
977 ?>
978 </div>
979 <?php
980 }
981
982 /**
983 * Cookiebot_WP Cookiebot IAB page
984 *
985 * @version 2.0.0
986 * @since 2.0.0
987 */
988 function iab_page() {
989 ?>
990 <div class="wrap">
991 <h1><?php _e('IAB','cookiebot'); ?></h1>
992
993 <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>
994
995 <form method="post" action="options.php">
996 <?php settings_fields( 'cookiebot-iab' ); ?>
997 <?php do_settings_sections( 'cookiebot-iab' ); ?>
998
999 <label>Enable IAB integration</label>
1000 <input type="checkbox" name="cookiebot-iab" value="1" <?php checked(1,get_option('cookiebot-iab'), true); ?>>
1001
1002 <?php submit_button(); ?>
1003 </form>
1004 </div>
1005 <?php
1006 }
1007
1008 /**
1009 * Cookiebot_WP Add Cookiebot JS to <head>
1010 *
1011 * @version 2.2.0
1012 * @since 1.0.0
1013 */
1014 function add_js() {
1015 $cbid = $this->get_cbid();
1016 if(!empty($cbid) && !defined('COOKIEBOT_DISABLE_ON_PAGE')) {
1017 if(is_multisite() && get_site_option('cookiebot-nooutput',false)) {
1018 return; //Is multisite - and disabled output is checked as network setting
1019 }
1020 if(get_option('cookiebot-nooutput',false)) {
1021 return; //Do not show JS - output disabled
1022 }
1023
1024
1025 $lang = $this->get_language();
1026 if(!empty($lang)) {
1027 $lang = ' data-culture="'.strtoupper($lang).'"'; //Use data-culture to define language
1028 }
1029
1030 if(!is_multisite() || get_site_option('cookiebot-script-tag-uc-attribute','custom') == 'custom') {
1031 $tagAttr = get_option('cookiebot-script-tag-uc-attribute','async');
1032 }
1033 else {
1034 $tagAttr = get_site_option('cookiebot-script-tag-uc-attribute');
1035 }
1036
1037 if($this->get_cookie_blocking_mode() == 'auto') {
1038 $tagAttr = 'data-blockingmode="auto"';
1039 }
1040
1041 $iab = ( get_option('cookiebot-iab') != false ) ? 'data-framework="IAB"' : '';
1042 ?>
1043 <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>
1044 <?php
1045 }
1046 }
1047
1048 /**
1049 * Cookiebot_WP Output declation shortcode [cookie_declaration]
1050 * Support attribute lang="LANGUAGE_CODE". Eg. lang="en".
1051 *
1052 * @version 2.2.0
1053 * @since 1.0.0
1054 */
1055 function show_declaration($atts) {
1056 $cbid = $this->get_cbid();
1057 $lang = '';
1058 if(!empty($cbid)) {
1059
1060 $atts = shortcode_atts(array(
1061 'lang' => $this->get_language(),
1062 ), $atts, 'cookie_declaration'
1063 );
1064
1065 if(!empty($atts['lang'])) {
1066 $lang = ' data-culture="'.strtoupper($atts['lang']).'"'; //Use data-culture to define language
1067 }
1068
1069 if(!is_multisite() || get_site_option('cookiebot-script-tag-cd-attribute','custom') == 'custom') {
1070 $tagAttr = get_option('cookiebot-script-tag-cd-attribute','async');
1071 }
1072 else {
1073 $tagAttr = get_site_option('cookiebot-script-tag-cd-attribute');
1074 }
1075
1076 return '<script id="CookieDeclaration" src="https://consent.cookiebot.com/'.$cbid.'/cd.js"'.$lang.' type="text/javascript" '.$tagAttr.'></script>';
1077 }
1078 else {
1079 return __('Please add your Cookiebot ID to show Cookie Declarations','cookiebot');
1080 }
1081 }
1082
1083 /**
1084 * Cookiebot_WP Get cookiebot cbid
1085 *
1086 * @version 2.2.0
1087 * @since 1.0.0
1088 */
1089 public static function get_cbid() {
1090 $cbid = get_option('cookiebot-cbid');
1091 if(is_multisite() && ($network_cbid = get_site_option('cookiebot-cbid'))) {
1092 if(empty($cbid)) {
1093 return $network_cbid;
1094 }
1095 }
1096 return $cbid;
1097 }
1098
1099 /**
1100 * Cookiebot_WP Get cookie blocking mode (auto | manual)
1101 *
1102 * @version 2.2.0
1103 * @since 1.0.0
1104 */
1105 public static function get_cookie_blocking_mode() {
1106 $cbm = get_option('cookiebot-cookie-blocking-mode');
1107 if(is_multisite() && ($network_cbm = get_site_option('cookiebot-cookie-blocking-mode'))) {
1108 if(empty($cbm)) {
1109 return $network_cbm;
1110 }
1111 }
1112 if(empty($cbm)) { $cbm = 'manual'; }
1113 return $cbm;
1114 }
1115
1116
1117 /**
1118 * Cookiebot_WP Check if Cookiebot is active in admin
1119 *
1120 * @version 3.1.0
1121 * @since 3.1.0
1122 */
1123 public static function cookiebot_disabled_in_admin() {
1124 if(is_multisite() && get_site_option('cookiebot-nooutput-admin',false)) {
1125 return true;
1126 }
1127 elseif(get_option('cookiebot-nooutput-admin',false)) {
1128 return true;
1129 }
1130 return false;
1131 }
1132
1133 /**
1134 * Cookiebot_WP Get the language code for Cookiebot
1135 *
1136 * @version 1.4.0
1137 * @since 1.4.0
1138 */
1139 function get_language($onlyFromSetting=false) {
1140 // Get language set in setting page - if empty use WP language info
1141 $lang = get_option('cookiebot-language');
1142 if(!empty($lang)) {
1143 if($lang != '_wp') {
1144 return $lang;
1145 }
1146 }
1147
1148 if($onlyFromSetting) {
1149 return $lang; //We want only to get if already set
1150 }
1151
1152 //Language not set - use WP language
1153 if($lang == '_wp') {
1154 $lang = get_bloginfo('language'); //Gets language in en-US format
1155 if(!empty($lang)) {
1156 list($lang) = explode('-',$lang); //Changes format from eg. en-US to en.
1157 }
1158 }
1159 return $lang;
1160 }
1161
1162 /**
1163 * Cookiebot_WP Adding Cookiebot domain(s) to exclude list for WP Rocket minification.
1164 *
1165 * @version 1.6.1
1166 * @since 1.6.1
1167 */
1168 function wp_rocket_exclude_external_js($external_js_hosts) {
1169 $external_js_hosts[] = 'consent.cookiebot.com'; // Add cookiebot domains
1170 $external_js_hosts[] = 'consentcdn.cookiebot.com';
1171 return $external_js_hosts;
1172 }
1173
1174 /**
1175 * Display admin notice for recommending cookiebot
1176 *
1177 * @version 2.0.5
1178 * @since 2.0.5
1179 */
1180 function cookiebot_admin_notices() {
1181 if( ! $this->cookiebot_valid_admin_recommendation() ) {
1182 return false;
1183 }
1184 $two_week_review_ignore = add_query_arg( array( 'cookiebot_admin_notice' => 'hide' ) );
1185 $two_week_review_temp = add_query_arg( array( 'cookiebot_admin_notice' => 'two_week' ) );
1186
1187 $notices = array(
1188 'title' => __('Leave A Review?', 'cookiebot'),
1189 'msg' => __('We hope you enjoy using WordPress Cookiebot! Would you consider leaving us a review on WordPress.org?', 'cookiebot'),
1190 '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>
1191 <li><span class="dashicons dashicons-smiley"></span><a href="' . $two_week_review_ignore . '"> ' . __('I\'ve already left a review', 'cookiebot') . '</a></li>
1192 <li><span class="dashicons dashicons-calendar-alt"></span><a href="' . $two_week_review_temp . '">' . __('Maybe Later', 'cookiebot') . '</a></li>
1193 <li><span class="dashicons dashicons-dismiss"></span><a href="' . $two_week_review_ignore . '">' . __('Never show again', 'cookiebot') . '</a></li>',
1194 'later_link' => $two_week_review_temp,
1195 'int' => 14
1196 );
1197
1198 echo '<div class="update-nag cookiebot-admin-notice">
1199 <div class="cookiebot-notice-logo"></div>
1200 <p class="cookiebot-notice-title">' . $notices['title'] . '</p>
1201 <p class="cookiebot-notice-body">' . $notices['msg'] . '</p>
1202 <ul class="cookiebot-notice-body wd-blue">' . $notices['link'] . '</ul>
1203 <a href="' . $notices['later_link'] . '" class="dashicons dashicons-dismiss"></a>
1204 </div>';
1205
1206 wp_enqueue_style( 'cookiebot-admin-notices', plugins_url( 'css/notice.css', __FILE__ ), array(), '2.0.4' );
1207 }
1208
1209
1210 /**
1211 * Validate if the last user action is valid for plugin recommendation
1212 *
1213 * @return bool
1214 *
1215 * @version 2.0.5
1216 * @since 2.0.5
1217 */
1218 function cookiebot_valid_admin_recommendation() {
1219 //Default - the recommendation is allowed to be visible
1220 $return = true;
1221
1222 $option = get_option('cookiebot_notice_recommend');
1223
1224 if( $option != false ) {
1225 //Never show again is clicked
1226 if( $option == 'hide' ) {
1227 $return = false;
1228 }
1229 elseif( is_numeric($option) && strtotime('now') < $option ) {
1230 //Show me after 2 weeks is clicked and the time is not valid yet
1231 $return = false;
1232 }
1233 }
1234 return $return;
1235 }
1236
1237 /**
1238 * Save the user action on cookiebot recommendation link
1239 *
1240 * @version 2.0.5
1241 * @since 2.0.5
1242 */
1243 function save_notice_link() {
1244 if( isset( $_GET['cookiebot_admin_notice'] ) ) {
1245 if( $_GET['cookiebot_admin_notice'] == 'hide' ) {
1246 update_option('cookiebot_notice_recommend', 'hide' );
1247 }
1248 else {
1249 update_option('cookiebot_notice_recommend', strtotime('+2 weeks') );
1250 }
1251 }
1252 }
1253
1254
1255
1256
1257 /**
1258 * Cookiebot_WP Fix plugin conflicts related to Cookiebot
1259 *
1260 * @version 3.2.0
1261 * @since 3.3.0
1262 */
1263 function cookiebot_fix_plugin_conflicts() {
1264 //Fix for Divi Page Builder
1265 add_action( 'wp', array( $this, '_cookiebot_plugin_conflict_divi' ), 100 );
1266
1267 //Fix for Elementor and WPBakery Page Builder Builder
1268 add_filter( 'script_loader_tag', array( $this, '_cookiebot_plugin_conflict_scripttags' ), 10, 2 );
1269
1270 }
1271
1272 /**
1273 * Cookiebot_WP Fix Divi builder conflict when blocking mode is in auto.
1274 *
1275 * @version 3.2.0
1276 * @since 3.2.0
1277 */
1278 function _cookiebot_plugin_conflict_divi() {
1279 if ( defined( 'ET_FB_ENABLED' ) ) {
1280 if ( ET_FB_ENABLED &&
1281 $this->cookiebot_disabled_in_admin() &&
1282 $this->get_cookie_blocking_mode() == 'auto' ) {
1283
1284 define('COOKIEBOT_DISABLE_ON_PAGE',true); //Disable Cookiebot on the current page
1285
1286 }
1287 }
1288 }
1289
1290 /**
1291 * Cookiebot_WP Fix plugin conflicts with page builders - whitelist JS files in automode
1292 *
1293 * @version 3.2.0
1294 * @since 3.3.0
1295 */
1296 function _cookiebot_plugin_conflict_scripttags( $tag, $handle ) {
1297
1298 //Check if Elementor Page Builder active
1299 if( defined( 'ELEMENTOR_VERSION' ) ) {
1300 if( in_array( $handle, [
1301 'jquery-core',
1302 'elementor-frontend-modules',
1303 'elementor-frontend',
1304 'wp-tinymce' ,
1305 'underscore',
1306 'backbone',
1307 'backbone-marionette',
1308 'backbone-radio',
1309 'elementor-common-modules',
1310 'elementor-dialog',
1311 'elementor-common',
1312 ] ) ) {
1313 $tag = str_replace( '<script ', '<script data-cookieconsent="ignore" ', $tag );
1314 }
1315 }
1316
1317 //Check if WPBakery Page Builder active
1318 if ( defined( 'WPB_VC_VERSION' ) ) {
1319 if( in_array( $handle, [
1320 'jquery-core',
1321 'jquery-ui-core',
1322 'jquery-ui-sortable',
1323 'jquery-ui-mouse',
1324 'jquery-ui-widget',
1325 'vc_editors-templates-preview-js',
1326 'vc-frontend-editor-min-js',
1327 'vc_inline_iframe_js',
1328 'wpb_composer_front_js',
1329 ] ) ) {
1330 $tag = str_replace( '<script ', '<script data-cookieconsent="ignore" ', $tag );
1331 }
1332 }
1333
1334 return $tag;
1335 }
1336
1337 }
1338 endif;
1339
1340
1341 /**
1342 * Helper function to manipulate script tags
1343 *
1344 * @version 1.6
1345 * @since 1.0
1346 * @return string
1347 */
1348 function cookiebot_assist($type='statistics') {
1349 //change to array
1350 if(!is_array($type)) { $type = array($type); }
1351
1352 foreach($type as $tk=>$tv) {
1353 if(!in_array($tv,array('marketing','statistics','preferences'))) {
1354 unset($type[$tk]);
1355 }
1356 }
1357 if(sizeof($type) > 0) {
1358 return ' type="text/plain" data-cookieconsent="'.implode(',',$type).'"';
1359 }
1360 return '';
1361 }
1362
1363
1364 /**
1365 * Helper function to check if cookiebot is active.
1366 * Useful for other plugins adding support for Cookiebot.
1367 *
1368 * @version 2.2.2
1369 * @since 1.2
1370 * @return string
1371 */
1372 function cookiebot_active() {
1373 $cbid = Cookiebot_WP::get_cbid();
1374 if(!empty($cbid)) {
1375 return true;
1376 }
1377 return false;
1378 }
1379
1380
1381 if(!function_exists('cookiebot')) {
1382 /**
1383 * Returns the main instance of Cookiebot_WO to prevent the need to use globals.
1384 *
1385 * @version 1.0.0
1386 * @since 1.0.0
1387 * @return Cookiebot_WP
1388 */
1389 function cookiebot() {
1390 return Cookiebot_WP::instance();
1391 }
1392 }
1393
1394 cookiebot();
1395