PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 3.0.0
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v3.0.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
1267 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.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.0';
25
26 /**
27 * @var Cookiebot_WP The single instance of the class
28 * @since 1.0.0
29 */
30 protected static $_instance = null;
31
32 /**
33 * Main Cookiebot_WP Instance
34 *
35 * Ensures only one instance of Cookiebot_WP is loaded or can be loaded.
36 *
37 * @version 1.0.0
38 * @since 1.0.0
39 * @static
40 * @return Cookiebot_WP - Main instance
41 */
42 public static function instance() {
43 if(is_null(self::$_instance)) {
44 self::$_instance = new self();
45 }
46 return self::$_instance;
47 }
48
49 /**
50 * Cookiebot_WP Constructor.
51 *
52 * @version 2.1.4
53 * @since 1.0.0
54 * @access public
55 */
56 function __construct() {
57 add_action('plugins_loaded', array($this, 'cookiebot_init'), 5);
58 register_activation_hook( __FILE__ , array($this, 'activation'));
59 register_deactivation_hook( __FILE__, 'cookiebot_addons_plugin_deactivated' );
60 }
61
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"><?php _e('Cookiebot Language','cookiebot'); ?></th>
437 <td>
438 <div>
439 <select name="cookiebot-language" id="cookiebot-language">
440 <?php
441 $currentLang = $this->get_language(true);
442 ?>
443 <option value=""><?php _e('Default (Autodetect)','cookiebot'); ?></option>
444 <option value="_wp"<?php echo ($currentLang == '_wp') ? ' selected' : ''; ?>><?php _e('Use Wordpress Language','cookiebot'); ?></option>
445 <?php
446 $supportedLanguages = $this->get_supported_languages();
447 foreach($supportedLanguages as $langCode=>$langName) {
448 echo '<option value="'.$langCode.'"'.(($currentLang==$langCode) ? ' selected' : '').'>'.$langName.'</option>';
449 }
450 ?>
451 </select>
452 </div>
453 <div class="notice inline notice-warning notice-alt cookiebot-notice" style="padding:12px;font-size:13px;display:inline-block;">
454 <div style="<?php echo ($currentLang=='') ? 'display:none;' : '' ?>" id="info_lang_specified">
455 <?php _e('You need to add the language in the Cookiebot administration tool.'); ?>
456 </div>
457 <div style="<?php echo ($currentLang=='') ? '' : 'display:none;' ?>" id="info_lang_autodetect">
458 <?php _e('You need to add all languages that you want auto-detected in the Cookiebot administration tool.'); ?> <br/>
459 <?php _e('The auto-detect checkbox needs to be enabled in the Cookiebot administration tool.'); ?><br/>
460 <?php _e('If the auto-detected language is not supported, Cookiebot will use the default language.'); ?>
461 </div>
462 <br />
463
464 <a href="#" id="show_add_language_guide"><?php _e('Show guide to add languages'); ?></a>
465 &nbsp;
466 <a href="https://support.cookiebot.com/hc/en-us/articles/360003793394-How-do-I-set-the-language-of-the-consent-banner-dialog-" target="_blank">
467 <?php _e('Read more here'); ?>
468 </a>
469
470 <div id="add_language_guide" style="display:none;">
471 <img src="<?php echo plugin_dir_url( __FILE__ ); ?>/assets/guide_add_language.gif" alt="Add language in Cookiebot administration tool" />
472 <br />
473 <a href="#" id="hide_add_language_guide"><?php _e('Hide guide'); ?></a>
474 </div>
475 </div>
476 <script>
477 jQuery(document).ready(function($) {
478 $('#show_add_language_guide').on('click',function(e) {
479 e.preventDefault();
480 $('#add_language_guide').slideDown();
481 $(this).hide();
482 });
483 $('#hide_add_language_guide').on('click',function(e) {
484 e.preventDefault();
485 $('#add_language_guide').slideUp();
486 $('#show_add_language_guide').show();
487 });
488
489 $('#cookiebot-language').on('change', function() {
490 if(this.value == '') {
491 $('#info_lang_autodetect').show();
492 $('#info_lang_specified').hide();
493 }
494 else {
495 $('#info_lang_autodetect').hide();
496 $('#info_lang_specified').show();
497 }
498 });
499 });
500 </script>
501
502 </td>
503 </tr>
504 <tr valign="top">
505 <th scope="row">
506 <?php _e('Cookie-blocking mode','cookiebot'); ?>
507 </th>
508 <td>
509 <?php
510 $cbm = get_option('cookiebot-cookie-blocking-mode','manual');
511 if($is_ms && $network_cookie_blocking_mode != 'custom') {
512 $cbm = $network_cookie_blocking_mode;
513 }
514 ?>
515 <label>
516 <input type="radio" name="cookiebot-cookie-blocking-mode" value="auto" <?php checked('auto', $cbm, true); ?> />
517 <?php _e('Automatic','cookiebot'); ?>
518 </label>
519 &nbsp; &nbsp;
520 <label>
521 <input type="radio" name="cookiebot-cookie-blocking-mode" value="manual" <?php checked('manual',$cbm, true); ?> />
522 <?php _e('Manual','cookiebot'); ?>
523 </label>
524 <p class="description">
525 <?php _e('Should Cookiebot automatic block cookies by tagging known tags.','cookiebot') ?>
526 </p>
527 </td>
528 </tr>
529 <script>
530 jQuery(document).ready(function($) {
531 var cookieBlockingMode = '<?php echo $cbm; ?>';
532 $( 'input[type=radio][name=cookiebot-cookie-blocking-mode]' ).on( 'change', function() {
533 if(this.value == 'auto' && cookieBlockingMode != this.value ) {
534 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 );
535 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true );
536 }
537 if( this.value == 'manual' && cookieBlockingMode != this.value ) {
538 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 1 );
539 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', false );
540 }
541 cookieBlockingMode = this.value;
542 });
543 if( cookieBlockingMode == 'auto' ) {
544 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 );
545 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true );
546 }
547 });
548 </script>
549
550 <tr valign="top" id="cookiebot-setting-async">
551 <th scope="row">
552 <?php _e('Add async or defer attribute','cookiebot'); ?>
553 <br /><?php _e('Consent banner script tag'); ?>
554 </th>
555 <td>
556 <?php
557 $cv = get_option('cookiebot-script-tag-uc-attribute','async');
558 $disabled = false;
559 if($is_ms && $network_scrip_tag_uc_attr != 'custom') {
560 $disabled = true;
561 $cv = $network_scrip_tag_uc_attr;
562 }
563 ?>
564 <label>
565 <input type="radio" name="cookiebot-script-tag-uc-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="" <?php checked('', $cv, true); ?> />
566 <i>None</i>
567 </label>
568 &nbsp; &nbsp;
569 <label>
570 <input type="radio" name="cookiebot-script-tag-uc-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="async" <?php checked('async',$cv, true); ?> />
571 async
572 </label>
573 &nbsp; &nbsp;
574 <label>
575 <input type="radio" name="cookiebot-script-tag-uc-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="defer" <?php checked('defer',$cv, true); ?> />
576 defer
577 </label>
578 <p class="description">
579 <?php if($disabled) { echo '<b>'._('Network setting applied. Please contact website administrator to change this setting.').'</b><br />'; } ?>
580 <?php _e('Add async or defer attribute to Cookiebot script tag. Default: async','cookiebot') ?>
581 </p>
582 </td>
583 </tr>
584 <tr valign="top">
585 <th scope="row">
586 <?php _e('Add async or defer attribute','cookiebot'); ?>
587 <br /><?php _e('Cookie declaration script tag'); ?>
588 </th>
589 <td>
590 <?php
591 $cv = get_option('cookiebot-script-tag-cd-attribute','async');
592 $disabled = false;
593 if($is_ms && $network_scrip_tag_cd_attr != 'custom') {
594 $disabled = true;
595 $cv = $network_scrip_tag_cd_attr;
596 }
597 ?>
598 <label>
599 <input type="radio" name="cookiebot-script-tag-cd-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="" <?php checked('', $cv, true); ?> />
600 <i>None</i>
601 </label>
602 &nbsp; &nbsp;
603 <label>
604 <input type="radio" name="cookiebot-script-tag-cd-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="async" <?php checked('async',$cv, true); ?> />
605 async
606 </label>
607 &nbsp; &nbsp;
608 <label>
609 <input type="radio" name="cookiebot-script-tag-cd-attribute"<?php echo ($disabled) ? ' disabled' : ''; ?> value="defer" <?php checked('defer',$cv, true); ?> />
610 defer
611 </label>
612 <p class="description">
613 <?php if($disabled) { echo '<b>'._('Network setting applied. Please contact website administrator to change this setting.').'</b><br />'; } ?>
614 <?php _e('Add async or defer attribute to Cookiebot script tag. Default: async','cookiebot') ?>
615 </p>
616 </td>
617 </tr>
618 <?php
619 if(!is_multisite()) {
620 ?>
621 <tr valign="top">
622 <th scope="row"><?php _e('Auto-update Cookiebot','cookiebot'); ?></th>
623 <td>
624 <input type="checkbox" name="cookiebot-autoupdate" value="1" <?php checked(1,get_option('cookiebot-autoupdate',false), true); ?> />
625 <p class="description">
626 <?php _e('Automatic update your Cookiebot plugin when new releases becomes available.','cookiebot') ?>
627 </p>
628 </td>
629 </tr>
630 <?php
631 }
632 ?>
633 <tr valign="top" id="cookiebot-setting-hide-popup">
634 <th scope="row"><?php _e('Hide Cookie Popup','cookiebot'); ?></th>
635 <td>
636 <?php
637 $disabled = false;
638 if($is_ms && get_site_option('cookiebot-nooutput',false)) {
639 $disabled = true;
640 echo '<input type="checkbox" checked disabled />';
641 }
642 else {
643 ?>
644 <input type="checkbox" name="cookiebot-nooutput" value="1" <?php checked(1,get_option('cookiebot-nooutput',false), true); ?> />
645 <?php
646 }
647 ?>
648 <p class="description">
649 <?php if($disabled) { echo '<b>'._('Network setting applied. Please contact website administrator to change this setting.').'</b><br />'; } ?>
650 <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 />
651 <?php _e('If you are using Google Tag Manager (or equal), you need to add the Cookiebot script in your Tag Manager.','cookiebot') ?><br />
652 <?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') ?>
653 </p>
654 </td>
655 </tr>
656 <tr valign="top">
657 <th scope="row"><?php _e('Hide Cookie Popup in WP Admin','cookiebot'); ?></th>
658 <td>
659 <?php
660 $disabled = false;
661 if($is_ms && get_site_option('cookiebot-nooutput-admin',false)) {
662 echo '<input type="checkbox" checked disabled />';
663 $disabled = true;
664 }
665 else {
666 ?>
667 <input type="checkbox" name="cookiebot-nooutput-admin" value="1" <?php checked(1,get_option('cookiebot-nooutput-admin',false), true); ?> />
668 <?php
669 }
670 ?>
671 <p class="description">
672 <?php if($disabled) { echo '<b>'._('Network setting applied. Please contact website administrator to change this setting.').'</b><br />'; } ?>
673 <b><?php _e('This checkbox will remove the cookie consent banner the Wordpress Admin area.','cookiebot') ?></b>
674 </p>
675 </td>
676 </tr>
677 </table>
678 <?php submit_button(); ?>
679 </form>
680 </div>
681 <?php
682 }
683
684 /**
685 * Cookiebot_WP Cookiebot network setting page
686 *
687 * @version 2.2.0
688 * @since 2.2.0
689 */
690 function network_settings_page() {
691 ?>
692 <div class="wrap">
693 <h1><?php _e('Cookiebot Network Settings','cookiebot'); ?></h1>
694 <a href="https://www.cookiebot.com">
695 <img src="<?php echo plugins_url( 'cookiebot-logo.png', __FILE__ ); ?>" style="float:right;margin-left:1em;">
696 </a>
697 <p>
698 <?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'); ?>
699 </p>
700 <p>
701 <b><big style="color:red;"><?php _e('The settings below is network wide settings. See notes below each field.'); ?></big></b>
702 </p>
703 <form method="post" action="edit.php?action=cookiebot_network_settings">
704 <?php wp_nonce_field( 'cookiebot-network-settings' ); ?>
705 <table class="form-table">
706 <tr valign="top">
707 <th scope="row"><?php _e('Network Cookiebot ID','cookiebot'); ?></th>
708 <td>
709 <input type="text" name="cookiebot-cbid" value="<?php echo esc_attr( get_site_option('cookiebot-cbid','') ); ?>" style="width:300px" />
710 <p class="description">
711 <b><?php _e('If added this will be the default Cookiebot ID for all subsites. Subsites are able to override the Cookiebot ID.'); ?></b>
712 <br />
713 <?php _e('Need an ID?','cookiebot'); ?>
714 <a href="https://www.cookiebot.com/en/signup" target="_blank"><?php _e('Sign up for free on cookiebot.com','cookiebot'); ?></a>
715 </p>
716 </td>
717 </tr>
718 <tr valign="top">
719 <th scope="row">
720 <?php _e('Cookie-blocking mode','cookiebot'); ?>
721 </th>
722 <td>
723 <?php
724 $cbm = get_site_option('cookiebot-cookie-blocking-mode','manual');
725 ?>
726 <label>
727 <input type="radio" name="cookiebot-cookie-blocking-mode" value="auto" <?php checked('auto', $cbm, true); ?> />
728 <?php _e('Automatic','cookiebot'); ?>
729 </label>
730 &nbsp; &nbsp;
731 <label>
732 <input type="radio" name="cookiebot-cookie-blocking-mode" value="manual" <?php checked('manual',$cbm, true); ?> />
733 <?php _e('Manual','cookiebot'); ?>
734 </label>
735 <p class="description">
736 <?php _e('Should Cookiebot automatic block cookies by tagging known tags.','cookiebot') ?>
737 </p>
738 </td>
739 </tr>
740 <script>
741 jQuery(document).ready(function($) {
742 var cookieBlockingMode = '<?php echo $cbm; ?>';
743 $( 'input[type=radio][name=cookiebot-cookie-blocking-mode]' ).on( 'change', function() {
744 if(this.value == 'auto' && cookieBlockingMode != this.value ) {
745 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 );
746 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true );
747 }
748 if( this.value == 'manual' && cookieBlockingMode != this.value ) {
749 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 1 );
750 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', false );
751 }
752 cookieBlockingMode = this.value;
753 });
754 if( cookieBlockingMode == 'auto' ) {
755 $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 );
756 $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true );
757 }
758 });
759 </script>
760 <tr valign="top" id="cookiebot-setting-async">
761 <th scope="row">
762 <?php _e('Add async or defer attribute','cookiebot'); ?>
763 <br /><?php _e('Consent banner script tag'); ?>
764 </th>
765 <td>
766 <?php
767 $cv = get_site_option('cookiebot-script-tag-uc-attribute','custom');
768 ?>
769 <label>
770 <input type="radio" name="cookiebot-script-tag-uc-attribute" value="" <?php checked('', $cv, true); ?> />
771 <i>None</i>
772 </label>
773 &nbsp; &nbsp;
774 <label>
775 <input type="radio" name="cookiebot-script-tag-uc-attribute" value="async" <?php checked('async',$cv, true); ?> />
776 async
777 </label>
778 &nbsp; &nbsp;
779 <label>
780 <input type="radio" name="cookiebot-script-tag-uc-attribute" value="defer" <?php checked('defer',$cv, true); ?> />
781 defer
782 </label>
783 &nbsp; &nbsp;
784 <label>
785 <input type="radio" name="cookiebot-script-tag-uc-attribute" value="custom" <?php checked('custom',$cv, true); ?> />
786 <i>Choose per subsite</i>
787 </label>
788 <p class="description">
789 <b><?php _e('Setting will apply for all subsites. Subsites will not be able to override.'); ?></b><br />
790 <?php _e('Add async or defer attribute to Cookiebot script tag. Default: Choose per subsite','cookiebot') ?>
791 </p>
792 </td>
793 </tr>
794 <tr valign="top">
795 <th scope="row">
796 <?php _e('Add async or defer attribute','cookiebot'); ?>
797 <br /><?php _e('Cookie declaration script tag'); ?>
798 </th>
799 <td>
800 <?php
801 $cv = get_site_option('cookiebot-script-tag-cd-attribute','custom');
802 ?>
803 <label>
804 <input type="radio" name="cookiebot-script-tag-cd-attribute" value="" <?php checked('', $cv, true); ?> />
805 <i>None</i>
806 </label>
807 &nbsp; &nbsp;
808 <label>
809 <input type="radio" name="cookiebot-script-tag-cd-attribute" value="async" <?php checked('async',$cv, true); ?> />
810 async
811 </label>
812 &nbsp; &nbsp;
813 <label>
814 <input type="radio" name="cookiebot-script-tag-cd-attribute" value="defer" <?php checked('defer',$cv, true); ?> />
815 defer
816 </label>
817 &nbsp; &nbsp;
818 <label>
819 <input type="radio" name="cookiebot-script-tag-cd-attribute" value="custom" <?php checked('custom',$cv, true); ?> />
820 <i>Choose per subsite</i>
821 </label>
822 <p class="description">
823 <b><?php _e('Setting will apply for all subsites. Subsites will not be able to override.'); ?></b><br />
824 <?php _e('Add async or defer attribute to Cookiebot script tag. Default: Choose per subsite','cookiebot') ?>
825 </p>
826 </td>
827 </tr>
828 <tr valign="top">
829 <th scope="row"><?php _e('Auto-update Cookiebot','cookiebot'); ?></th>
830 <td>
831 <input type="checkbox" name="cookiebot-autoupdate" value="1" <?php checked(1,get_site_option('cookiebot-autoupdate',false), true); ?> />
832 <p class="description">
833 <?php _e('Automatic update your Cookiebot plugin when new releases becomes available.','cookiebot') ?>
834 </p>
835 </td>
836 </tr>
837 <tr valign="top" id="cookiebot-setting-hide-popup">
838 <th scope="row"><?php _e('Hide Cookie Popup','cookiebot'); ?></th>
839 <td>
840 <input type="checkbox" name="cookiebot-nooutput" value="1" <?php checked(1,get_site_option('cookiebot-nooutput',false), true); ?> />
841 <p class="description">
842 <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 />
843 <?php _e('If you are using Google Tag Manager (or equal), you need to add the Cookiebot script in your Tag Manager.','cookiebot') ?><br />
844 <?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') ?>
845 </p>
846 </td>
847 </tr>
848 <tr valign="top">
849 <th scope="row"><?php _e('Hide Cookie Popup in WP Admin','cookiebot'); ?></th>
850 <td>
851 <input type="checkbox" name="cookiebot-nooutput-admin" value="1" <?php checked(1,get_site_option('cookiebot-nooutput-admin',false), true); ?> />
852 <p class="description">
853 <b><?php _e('Remove the cookie consent banner the Wordpress Admin area for all subsites. This cannot be changed by subsites.','cookiebot') ?></b>
854 </p>
855 </td>
856 </tr>
857 </table>
858 <?php submit_button(); ?>
859 </form>
860 </div>
861 <?php
862 }
863
864
865 /**
866 * Cookiebot_WP Cookiebot save network settings
867 *
868 * @version 2.2.0
869 * @since 2.2.0
870 */
871 function network_settings_save() {
872 check_admin_referer( 'cookiebot-network-settings' );
873
874 update_site_option('cookiebot-cbid', $_POST['cookiebot-cbid'] );
875 update_site_option('cookiebot-script-tag-uc-attribute', $_POST['cookiebot-script-tag-uc-attribute'] );
876 update_site_option('cookiebot-script-tag-cd-attribute', $_POST['cookiebot-script-tag-cd-attribute'] );
877 update_site_option('cookiebot-autoupdate', $_POST['cookiebot-autoupdate'] );
878 update_site_option('cookiebot-nooutput', $_POST['cookiebot-nooutput'] );
879 update_site_option('cookiebot-nooutput-admin', $_POST['cookiebot-nooutput-admin'] );
880 update_site_option('cookiebot-cookie-blocking-mode', $_POST['cookiebot-cookie-blocking-mode'] );
881
882
883 wp_redirect( add_query_arg( array(
884 'page' => 'cookiebot_network',
885 'updated' => true ), network_admin_url('admin.php')
886 ));
887 exit;
888 }
889
890 /**
891 * Cookiebot_WP Cookiebot support page
892 *
893 * @version 2.2.0
894 * @since 2.0.0
895 */
896 function support_page() {
897 ?>
898 <div class="wrap">
899 <h1><?php _e('Support','cookiebot'); ?></h1>
900 <h2><?php _e('How to find my Cookiebot ID','cookiebot'); ?></h2>
901 <p>
902 <ol>
903 <li><?php _e('Log in to your <a href="https://www.cookiebot.com/en/account" target="_blank">Cookiebot account</a>.','cookiebot'); ?></li>
904 <li><?php _e('Go to <b>Manage</b> > <b>Settings</b> and add setup your Cookiebot','cookiebot'); ?></li>
905 <li><?php _e('Go to the <b>"Your scripts"</b> tab','cookiebot'); ?></li>
906 <li><?php _e('Copy the value inside the data-cid parameter - eg.: abcdef12-3456-7890-abcd-ef1234567890','cookiebot'); ?></li>
907 <li><?php _e('Add <b>[cookie_declaration]</b> shortcode to a page to show the declation','cookiebot'); ?></li>
908 <li><?php _e('Remember to change your scripts as descripted below','cookiebot'); ?></li>
909 </ol>
910 </p>
911 <h2><?php _e('Add the Cookie Declaration to your website'); ?></h2>
912 <p>
913 <?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'); ?>
914 <br />
915 <?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'); ?>
916 </p>
917 <p>
918 <a href="https://www.youtube.com/watch?v=OCXz2bt4H_w" target="_blank" class="button"><?php _e('Watch video demonstration','cookiebot'); ?></a>
919 </p>
920 <h2><?php _e('Update your script tags','cookiebot'); ?></h2>
921 <p>
922 <?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'); ?>
923 </p>
924 <code>
925 <?php
926 echo htmlentities("<script type=\"text/plain\" data-cookieconsent=\"statistics\">").'<br />';
927 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 />';
928 echo htmlentities("ga('create', 'UA-00000000-0', 'auto');").'<br />';
929 echo htmlentities("ga('send', 'pageview');").'<br />';
930 echo htmlentities("</script>").'<br />';
931 ?>
932 </code>
933 <p>
934 <a href="https://www.youtube.com/watch?v=MeHycvV2QCQ" target="_blank" class="button"><?php _e('Watch video demonstration','cookiebot'); ?></a>
935 </p>
936
937 <h2><?php _e('Helper function to update your scripts','cookiebot'); ?></h2>
938 <p>
939 <?php _e('You are able to update your scripts yourself. However, Cookiebot also offers a small helper function that makes the work easier.','cookiebot'); ?>
940 <br />
941 <?php _e('Update your script tags this way:','cookiebot'); ?>
942 </p>
943 <?php
944 printf(
945 __('%s to %s'),
946 '<code>'.htmlentities('<script type="text/javascript">').'</code>',
947 '<code>'.htmlentities('<script<?php echo cookiebot_assist(\'marketing\') ?>>').'</code>'
948 );
949 ?>
950 </div>
951 <?php
952 }
953
954 /**
955 * Cookiebot_WP Cookiebot IAB page
956 *
957 * @version 2.0.0
958 * @since 2.0.0
959 */
960 function iab_page() {
961 ?>
962 <div class="wrap">
963 <h1><?php _e('IAB','cookiebot'); ?></h1>
964
965 <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>
966
967 <form method="post" action="options.php">
968 <?php settings_fields( 'cookiebot-iab' ); ?>
969 <?php do_settings_sections( 'cookiebot-iab' ); ?>
970
971 <label>Enable IAB integration</label>
972 <input type="checkbox" name="cookiebot-iab" value="1" <?php checked(1,get_option('cookiebot-iab'), true); ?>>
973
974 <?php submit_button(); ?>
975 </form>
976 </div>
977 <?php
978 }
979
980 /**
981 * Cookiebot_WP Add Cookiebot JS to <head>
982 *
983 * @version 2.2.0
984 * @since 1.0.0
985 */
986 function add_js() {
987 $cbid = $this->get_cbid();
988 if(!empty($cbid)) {
989 if(is_multisite() && get_site_option('cookiebot-nooutput',false)) {
990 return; //Is multisite - and disabled output is checked as network setting
991 }
992 if(get_option('cookiebot-nooutput',false)) {
993 return; //Do not show JS - output disabled
994 }
995
996
997 $lang = $this->get_language();
998 if(!empty($lang)) {
999 $lang = ' data-culture="'.strtoupper($lang).'"'; //Use data-culture to define language
1000 }
1001
1002 if(!is_multisite() || get_site_option('cookiebot-script-tag-uc-attribute','custom') == 'custom') {
1003 $tagAttr = get_option('cookiebot-script-tag-uc-attribute','async');
1004 }
1005 else {
1006 $tagAttr = get_site_option('cookiebot-script-tag-uc-attribute');
1007 }
1008
1009 if($this->get_cookie_blocking_mode() == 'auto') {
1010 $tagAttr = 'data-blockingmode="auto"';
1011 }
1012
1013 $iab = ( get_option('cookiebot-iab') != false ) ? 'data-framework="IAB"' : '';
1014 ?>
1015 <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>
1016 <?php
1017 }
1018 }
1019
1020 /**
1021 * Cookiebot_WP Output declation shortcode [cookie_declaration]
1022 * Support attribute lang="LANGUAGE_CODE". Eg. lang="en".
1023 *
1024 * @version 2.2.0
1025 * @since 1.0.0
1026 */
1027 function show_declaration($atts) {
1028 $cbid = $this->get_cbid();
1029 $lang = '';
1030 if(!empty($cbid)) {
1031
1032 $atts = shortcode_atts(array(
1033 'lang' => $this->get_language(),
1034 ), $atts, 'cookie_declaration'
1035 );
1036
1037 if(!empty($atts['lang'])) {
1038 $lang = ' data-culture="'.strtoupper($atts['lang']).'"'; //Use data-culture to define language
1039 }
1040
1041 if(!is_multisite() || get_site_option('cookiebot-script-tag-cd-attribute','custom') == 'custom') {
1042 $tagAttr = get_option('cookiebot-script-tag-cd-attribute','async');
1043 }
1044 else {
1045 $tagAttr = get_site_option('cookiebot-script-tag-cd-attribute');
1046 }
1047
1048 return '<script id="CookieDeclaration" src="https://consent.cookiebot.com/'.$cbid.'/cd.js"'.$lang.' type="text/javascript" '.$tagAttr.'></script>';
1049 }
1050 else {
1051 return __('Please add your Cookiebot ID to show Cookie Declarations','cookiebot');
1052 }
1053 }
1054
1055 /**
1056 * Cookiebot_WP Get cookiebot cbid
1057 *
1058 * @version 2.2.0
1059 * @since 1.0.0
1060 */
1061 public static function get_cbid() {
1062 $cbid = get_option('cookiebot-cbid');
1063 if(is_multisite() && ($network_cbid = get_site_option('cookiebot-cbid'))) {
1064 if(empty($cbid)) {
1065 return $network_cbid;
1066 }
1067 }
1068 return $cbid;
1069 }
1070
1071 /**
1072 * Cookiebot_WP Get cookie blocking mode (auto | manual)
1073 *
1074 * @version 2.2.0
1075 * @since 1.0.0
1076 */
1077 public static function get_cookie_blocking_mode() {
1078 $cbm = get_option('cookiebot-cookie-blocking-mode');
1079 if(is_multisite() && ($network_cbm = get_site_option('cookiebot-cookie-blocking-mode'))) {
1080 if(empty($cbm)) {
1081 return $network_cbm;
1082 }
1083 }
1084 if(empty($cbm)) { $cbm = 'manual'; }
1085 return $cbm;
1086 }
1087
1088 /**
1089 * Cookiebot_WP Get the language code for Cookiebot
1090 *
1091 * @version 1.4.0
1092 * @since 1.4.0
1093 */
1094 function get_language($onlyFromSetting=false) {
1095 // Get language set in setting page - if empty use WP language info
1096 $lang = get_option('cookiebot-language');
1097 if(!empty($lang)) {
1098 if($lang != '_wp') {
1099 return $lang;
1100 }
1101 }
1102
1103 if($onlyFromSetting) {
1104 return $lang; //We want only to get if already set
1105 }
1106
1107 //Language not set - use WP language
1108 if($lang == '_wp') {
1109 $lang = get_bloginfo('language'); //Gets language in en-US format
1110 if(!empty($lang)) {
1111 list($lang) = explode('-',$lang); //Changes format from eg. en-US to en.
1112 }
1113 }
1114 return $lang;
1115 }
1116
1117 /**
1118 * Cookiebot_WP Adding Cookiebot domain(s) to exclude list for WP Rocket minification.
1119 *
1120 * @version 1.6.1
1121 * @since 1.6.1
1122 */
1123 function wp_rocket_exclude_external_js($external_js_hosts) {
1124 $external_js_hosts[] = 'consent.cookiebot.com'; // Add cookiebot domains
1125 $external_js_hosts[] = 'consentcdn.cookiebot.com';
1126 return $external_js_hosts;
1127 }
1128
1129 /**
1130 * Display admin notice for recommending cookiebot
1131 *
1132 * @version 2.0.5
1133 * @since 2.0.5
1134 */
1135 function cookiebot_admin_notices() {
1136 if( ! $this->cookiebot_valid_admin_recommendation() ) {
1137 return false;
1138 }
1139 $two_week_review_ignore = add_query_arg( array( 'cookiebot_admin_notice' => 'hide' ) );
1140 $two_week_review_temp = add_query_arg( array( 'cookiebot_admin_notice' => 'two_week' ) );
1141
1142 $notices = array(
1143 'title' => __('Leave A Review?', 'cookiebot'),
1144 'msg' => __('We hope you enjoy using WordPress Cookiebot! Would you consider leaving us a review on WordPress.org?', 'cookiebot'),
1145 '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>
1146 <li><span class="dashicons dashicons-smiley"></span><a href="' . $two_week_review_ignore . '"> ' . __('I\'ve already left a review', 'cookiebot') . '</a></li>
1147 <li><span class="dashicons dashicons-calendar-alt"></span><a href="' . $two_week_review_temp . '">' . __('Maybe Later', 'cookiebot') . '</a></li>
1148 <li><span class="dashicons dashicons-dismiss"></span><a href="' . $two_week_review_ignore . '">' . __('Never show again', 'cookiebot') . '</a></li>',
1149 'later_link' => $two_week_review_temp,
1150 'int' => 14
1151 );
1152
1153 echo '<div class="update-nag cookiebot-admin-notice">
1154 <div class="cookiebot-notice-logo"></div>
1155 <p class="cookiebot-notice-title">' . $notices['title'] . '</p>
1156 <p class="cookiebot-notice-body">' . $notices['msg'] . '</p>
1157 <ul class="cookiebot-notice-body wd-blue">' . $notices['link'] . '</ul>
1158 <a href="' . $notices['later_link'] . '" class="dashicons dashicons-dismiss"></a>
1159 </div>';
1160
1161 wp_enqueue_style( 'cookiebot-admin-notices', plugins_url( 'css/notice.css', __FILE__ ), array(), '2.0.4' );
1162 }
1163
1164
1165 /**
1166 * Validate if the last user action is valid for plugin recommendation
1167 *
1168 * @return bool
1169 *
1170 * @version 2.0.5
1171 * @since 2.0.5
1172 */
1173 function cookiebot_valid_admin_recommendation() {
1174 //Default - the recommendation is allowed to be visible
1175 $return = true;
1176
1177 $option = get_option('cookiebot_notice_recommend');
1178
1179 if( $option != false ) {
1180 //Never show again is clicked
1181 if( $option == 'hide' ) {
1182 $return = false;
1183 }
1184 elseif( is_numeric($option) && strtotime('now') < $option ) {
1185 //Show me after 2 weeks is clicked and the time is not valid yet
1186 $return = false;
1187 }
1188 }
1189 return $return;
1190 }
1191
1192 /**
1193 * Save the user action on cookiebot recommendation link
1194 *
1195 * @version 2.0.5
1196 * @since 2.0.5
1197 */
1198 function save_notice_link() {
1199 if( isset( $_GET['cookiebot_admin_notice'] ) ) {
1200 if( $_GET['cookiebot_admin_notice'] == 'hide' ) {
1201 update_option('cookiebot_notice_recommend', 'hide' );
1202 }
1203 else {
1204 update_option('cookiebot_notice_recommend', strtotime('+2 weeks') );
1205 }
1206 }
1207 }
1208
1209 }
1210 endif;
1211
1212
1213 /**
1214 * Helper function to manipulate script tags
1215 *
1216 * @version 1.6
1217 * @since 1.0
1218 * @return string
1219 */
1220 function cookiebot_assist($type='statistics') {
1221 //change to array
1222 if(!is_array($type)) { $type = array($type); }
1223
1224 foreach($type as $tk=>$tv) {
1225 if(!in_array($tv,array('marketing','statistics','preferences'))) {
1226 unset($type[$tk]);
1227 }
1228 }
1229 if(sizeof($type) > 0) {
1230 return ' type="text/plain" data-cookieconsent="'.implode(',',$type).'"';
1231 }
1232 return '';
1233 }
1234
1235
1236 /**
1237 * Helper function to check if cookiebot is active.
1238 * Useful for other plugins adding support for Cookiebot.
1239 *
1240 * @version 2.2.2
1241 * @since 1.2
1242 * @return string
1243 */
1244 function cookiebot_active() {
1245 $cbid = Cookiebot_WP::get_cbid();
1246 if(!empty($cbid)) {
1247 return true;
1248 }
1249 return false;
1250 }
1251
1252
1253 if(!function_exists('cookiebot')) {
1254 /**
1255 * Returns the main instance of Cookiebot_WO to prevent the need to use globals.
1256 *
1257 * @version 1.0.0
1258 * @since 1.0.0
1259 * @return Cookiebot_WP
1260 */
1261 function cookiebot() {
1262 return Cookiebot_WP::instance();
1263 }
1264 }
1265
1266 cookiebot();
1267