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