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