PluginProbe
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 4.7.3
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v4.7.3
4.7.3 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 All 93 releases
← All changes | cookiebot.php +18 -2119 3.10.04.7.3 View file →
@@ -1,12 +1,13 @@
1 1 <?php
2 +
2 3 /*
3 -Plugin Name: Cookiebot | GDPR/CCPA Compliant Cookie Consent and Control
4 -Plugin URI: https://cookiebot.com/
5 -Description: Cookiebot is a cloud-driven solution that automatically controls cookies and trackers, enabling full GDPR/ePrivacy and CCPA compliance for websites.
6 -Author: Cybot A/S
7 -Version: 3.10.0
8 -Author URI: http://cookiebot.com
4 +Plugin Name: Cookiebot by Usercentrics - Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode
5 +Plugin URI: https://www.cookiebot.com/
6 +Description: Install your cookie banner in minutes. Automatically scan and block cookies to comply with the GDPR, CCPA, Google Consent Mode v2. Free plan option.
7 +Author: Usercentrics A/S
8 +Version: 4.7.3
9 +Author URI: https://www.cookiebot.com/
9 10 Text Domain: cookiebot
10 11 Domain Path: /langs
11 12 */
12 13
@@ -13,2120 +14,18 @@
13 14 if ( ! defined( 'ABSPATH' ) ) {
14 15 exit; // Exit if accessed directly
15 16 }
16 17
17 -if ( ! class_exists( 'Cookiebot_WP' ) ) :
18 +define( 'CYBOT_COOKIEBOT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
19 +define( 'CYBOT_COOKIEBOT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
18 20
19 - final class Cookiebot_WP {
20 - /**
21 - * Plugin version.
22 - *
23 - * @var string
24 - * @since 1.0.0
25 - */
26 - public $version = '3.10.0';
21 +require_once __DIR__ . '/vendor/autoload.php';
22 +require_once __DIR__ . '/src/lib/helper.php';
23 +require_once __DIR__ . '/src/lib/global-deprecations.php';
27 24
28 - /**
29 - * @var Cookiebot_WP The single instance of the class
30 - * @since 1.0.0
31 - */
32 - protected static $_instance = null;
33 -
34 - /**
35 - * Main Cookiebot_WP Instance
36 - *
37 - * Ensures only one instance of Cookiebot_WP is loaded or can be loaded.
38 - *
39 - * @version 1.0.0
40 - * @since 1.0.0
41 - * @static
42 - * @return Cookiebot_WP - Main instance
43 - */
44 - public static function instance() {
45 - if ( is_null( self::$_instance ) ) {
46 - self::$_instance = new self();
47 - }
48 - return self::$_instance;
49 - }
50 -
51 - /**
52 - * Cookiebot_WP Constructor.
53 - *
54 - * @version 2.1.4
55 - * @since 1.0.0
56 - * @access public
57 - */
58 - function __construct() {
59 - add_action( 'after_setup_theme', array( $this, 'cookiebot_init' ), 5 );
60 - register_activation_hook( __FILE__, array( $this, 'activation' ) );
61 - register_deactivation_hook( __FILE__, 'cookiebot_addons_plugin_deactivated' );
62 -
63 - $this->cookiebot_fix_plugin_conflicts();
64 - }
65 -
66 - /**
67 - * Cookiebot_WP Installation actions
68 - *
69 - * @version 2.1.4
70 - * @since 2.1.4
71 - * @accces public
72 - */
73 - function activation() {
74 - //Delay display of recommendation notice in 3 days if not activated ealier
75 - if ( get_option( 'cookiebot_notice_recommend', false ) === false ) {
76 - //Not set yet - this must be first activation - delay in 3 days
77 - update_option( 'cookiebot_notice_recommend', strtotime( '+3 days' ) );
78 - }
79 - if ( $this->get_cbid() == '' ) {
80 - if ( is_multisite() ) {
81 - update_site_option( 'cookiebot-cookie-blocking-mode', 'auto' );
82 - update_site_option( 'cookiebot-nooutput-admin', true );
83 - } else {
84 - update_option( 'cookiebot-cookie-blocking-mode', 'auto' );
85 - update_option( 'cookiebot-nooutput-admin', true );
86 - }
87 - }
88 -
89 - /**
90 - * Run through the addons and enable the default ones
91 - */
92 - if ( ( ! defined( 'COOKIEBOT_ADDONS_STANDALONE' ) || COOKIEBOT_ADDONS_STANDALONE != true || ! defined( 'COOKIE_ADDONS_LOADED' ) ) ) {
93 - //Make sure we got a PHP version that works
94 - if ( version_compare( PHP_VERSION, '5.4.0', '>=' ) ) {
95 - define( 'COOKIEBOT_URL', plugin_dir_url( __FILE__ ) );
96 - // activation hook doesn't have the addons loaded - so load it extra when the plugin is activated
97 - include_once dirname( __FILE__ ) . '/addons/cookiebot-addons-init.php';
98 - // run activated hook on the addons
99 - cookiebot_addons_plugin_activated();
100 - }
101 - }
102 - }
103 -
104 - /**
105 - * Cookiebot_WP Init Cookiebot.
106 - *
107 - * @version 3.8.1
108 - * @since 1.6.2
109 - * @access public
110 - */
111 - function cookiebot_init() {
112 - /* Load Cookiebot Addons Framework */
113 - $dismissAddons = false;
114 - if ( defined( 'CAF_DIR' ) ) {
115 - $dismissAddons = true;
116 - /*add_action('admin_notices', function() {
117 - ?>
118 - <div class="notice notice-warning">
119 - <p>
120 - <?php esc_html_e( 'You have Cookiebot Addons installed.', 'cookiebot' ); ?><br />
121 - <?php esc_html_e( 'In this and future releases of Cookiebot all available Addons are bundled directly with the Cookiebot plugin.', 'cookiebot' ); ?><br />
122 - <?php esc_html_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' ); ?>
123 - </p>
124 - </div>
125 - <?php
126 - });*/
127 - }
128 - //elseif( $this->get_cookie_blocking_mode() !== 'auto' ) {
129 - else {
130 - if ( ( ! defined( 'COOKIEBOT_ADDONS_STANDALONE' ) || COOKIEBOT_ADDONS_STANDALONE != true || ! defined( 'COOKIE_ADDONS_LOADED' ) ) && $dismissAddons !== true ) {
131 - //Make sure we got a PHP version that works
132 - if ( version_compare( PHP_VERSION, '5.4.0', '>=' ) ) {
133 - define( 'COOKIEBOT_URL', plugin_dir_url( __FILE__ ) );
134 - include_once dirname( __FILE__ ) . '/addons/cookiebot-addons-init.php';
135 - } else {
136 - define( 'COOKIEBOT_ADDONS_UNSUPPORTED_PHPVERSION', true );
137 - }
138 - } else {
139 - add_action(
140 - 'admin_notices',
141 - function() {
142 - ?>
143 - <div class="notice notice-warning">
144 - <p>
145 - <?php esc_html_e( 'You are using Cookiebot Addons Standalone.', 'cookiebot' ); ?>
146 - </p>
147 - </div>
148 - <?php
149 - }
150 - );
151 - }
152 - }
153 - if ( is_admin() ) {
154 -
155 - //Adding menu to WP admin
156 - add_action( 'admin_menu', array( $this, 'add_menu' ), 1 );
157 - add_action( 'admin_menu', array( $this, 'add_menu_legislations' ), 40 );
158 - add_action( 'admin_menu', array( $this, 'add_menu_debug' ), 50 );
159 -
160 - if ( is_multisite() ) {
161 - add_action( 'network_admin_menu', array( $this, 'add_network_menu' ), 1 );
162 - add_action( 'network_admin_edit_cookiebot_network_settings', array( $this, 'network_settings_save' ) );
163 - }
164 -
165 - //Register settings
166 - add_action( 'admin_init', array( $this, 'register_cookiebot_settings' ) );
167 -
168 - //Adding dashboard widgets
169 - add_action( 'wp_dashboard_setup', array( $this, 'add_dashboard_widgets' ) );
170 -
171 - add_action( 'admin_notices', array( $this, 'cookiebot_admin_notices' ) );
172 - add_action( 'admin_init', array( $this, 'save_notice_link' ) );
173 -
174 - //Check if we should show cookie consent banner on admin pages
175 - if ( ! $this->cookiebot_disabled_in_admin() ) {
176 - //adding cookie banner in admin area too
177 - add_action( 'admin_head', array( $this, 'add_js' ), -9999 );
178 - }
179 - }
180 -
181 - //Include integration to WP Consent Level API if available
182 - if ( $this->is_wp_consent_api_active() ) {
183 - add_action( 'wp_enqueue_scripts', array( $this, 'cookiebot_enqueue_consent_api_scripts' ) );
184 - }
185 -
186 - // Set up localisation
187 - load_plugin_textdomain( 'cookiebot', false, dirname( plugin_basename( __FILE__ ) ) . '/langs/' );
188 -
189 - //add JS
190 - add_action( 'wp_head', array( $this, 'add_js' ), -9997 );
191 - add_action( 'wp_head', array( $this, 'add_GTM' ), -9998 );
192 - add_action( 'wp_head', array( $this, 'add_GCM' ), -9999 );
193 - add_shortcode( 'cookie_declaration', array( $this, 'show_declaration' ) );
194 -
195 - //Add filter if WP rocket is enabled
196 - if ( defined( 'WP_ROCKET_VERSION' ) ) {
197 - add_filter( 'rocket_minify_excluded_external_js', array( $this, 'wp_rocket_exclude_external_js' ) );
198 - }
199 -
200 - //Add filter
201 - add_filter( 'sgo_javascript_combine_excluded_external_paths', array( $this, 'sgo_exclude_external_js' ) );
202 -
203 - //Automatic update plugin
204 - if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
205 - add_filter( 'auto_update_plugin', array( $this, 'automatic_updates' ), 10, 2 );
206 - }
207 -
208 - //Loading widgets
209 - include_once dirname( __FILE__ ) . '/widgets/cookiebot-declaration-widget.php';
210 - add_action( 'widgets_init', array( $this, 'register_widgets' ) );
211 -
212 - //Add Gutenberg block
213 - add_action( 'init', array( $this, 'gutenberg_block_setup' ) );
214 - add_action( 'enqueue_block_editor_assets', array( $this, 'gutenberg_block_admin_assets' ) );
215 - }
216 -
217 -
218 - /**
219 - * Cookiebot_WP Setup Gutenberg block
220 - *
221 - * @version 3.7.0
222 - * @since 3.7.0
223 - */
224 - function gutenberg_block_setup() {
225 - if ( ! function_exists( 'register_block_type' ) ) {
226 - return; //gutenberg not active
227 - }
228 -
229 - register_block_type(
230 - 'cookiebot/cookie-declaration',
231 - array(
232 - 'render_callback' => array( $this, 'block_cookie_declaration' ),
233 - )
234 - );
235 - }
236 -
237 - /**
238 - * Cookiebot_WP Add block JS
239 - *
240 - * @version 3.7.1
241 - * @since 3.7.1
242 - */
243 - function gutenberg_block_admin_assets() {
244 - //Add Gutenberg Widget
245 - wp_enqueue_script(
246 - 'cookiebot-declaration',
247 - plugin_dir_url( __FILE__ ) . 'js/block.js',
248 - array( 'wp-blocks', 'wp-i18n', 'wp-element' ), // Required scripts for the block
249 - $this->version
250 - );
251 - }
252 -
253 - /**
254 - * Cookiebot_WP Render Cookiebot Declaration as Gutenberg block
255 - *
256 - * @version 3.7.0
257 - * @since 3.7.0
258 - */
259 - function block_cookie_declaration() {
260 - return $this->show_declaration();
261 - }
262 -
263 - /**
264 - * Cookiebot_WP Load text domain
265 - *
266 - * @version 2.0.0
267 - * @since 2.0.0
268 - */
269 - function load_textdomain() {
270 - load_plugin_textdomain( 'cookiebot', false, basename( dirname( __FILE__ ) ) . '/langs' );
271 - }
272 -
273 - /**
274 - * Cookiebot_WP Register widgets
275 - *
276 - * @version 2.5.0
277 - * @since 2.5.0
278 - */
279 - function register_widgets() {
280 - register_widget( 'Cookiebot_Declaration_Widget' );
281 - }
282 -
283 - /**
284 - * Cookiebot_WP Add dashboard widgets to admin
285 - *
286 - * @version 1.0.0
287 - * @since 1.0.0
288 - */
289 -
290 - function add_dashboard_widgets() {
291 - wp_add_dashboard_widget( 'cookiebot_status', esc_html__( 'Cookiebot Status', 'cookiebot' ), array( $this, 'dashboard_widget_status' ) );
292 - }
293 -
294 - /**
295 - * Cookiebot_WP Output Dashboard Status Widget
296 - *
297 - * @version 1.0.0
298 - * @since 1.0.0
299 - */
300 - function dashboard_widget_status() {
301 - $cbid = $this->get_cbid();
302 - if ( empty( $cbid ) ) {
303 - echo '<p>' . esc_html__( 'You need to enter your Cookiebot ID.', 'cookiebot' ) . '</p>';
304 - echo '<p><a href="options-general.php?page=cookiebot">';
305 - echo esc_html__( 'Update your Cookiebot ID', 'cookiebot' );
306 - echo '</a></p>';
307 - } else {
308 - echo '<p>' . esc_html_e( 'Your Cookiebot is working!', 'cookiebot' ) . '</p>';
309 - }
310 - }
311 -
312 - /**
313 - * Cookiebot_WP Add option menu page for Cookiebot
314 - *
315 - * @version 2.2.0
316 - * @since 1.0.0
317 - */
318 - function add_menu() {
319 - //Cookiebot Icon SVG base64 encoded
320 - $icon = 'data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgNzIgNTQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iI0ZGRkZGRiIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNNDYuODcyNTkwMyA4Ljc3MzU4MzM0QzQxLjk0MzkwMzkgMy4zODI5NTAxMSAzNC44NDI0OTQ2IDAgMjYuOTQ4MjgxOSAwIDEyLjA2NTE1NjggMCAwIDEyLjAyNDQ3NzQgMCAyNi44NTc0MjE5YzAgMTQuODMyOTQ0NSAxMi4wNjUxNTY4IDI2Ljg1NzQyMTkgMjYuOTQ4MjgxOSAyNi44NTc0MjE5IDcuODk0MjEyNyAwIDE0Ljk5NTYyMi0zLjM4Mjk1MDIgMTkuOTI0MzA4NC04Ljc3MzU4MzQtMi44ODk2OTY3LTEuMzY4ODY2My01LjM5OTMxMS0zLjQwNTQzOS03LjMyODA4MzgtNS45MDk2MzU4LTMuMTIxNDMwNiAzLjIwOTQxMDQtNy40OTI5OTQ0IDUuMjA0MTI5MS0xMi4zMzIwMjU4IDUuMjA0MTI5MS05LjQ4NDM0NDQgMC0xNy4xNzI5MjQ3LTcuNjYyNjU3Mi0xNy4xNzI5MjQ3LTE3LjExNTAyMzhzNy42ODg1ODAzLTE3LjExNTAyMzcgMTcuMTcyOTI0Ny0xNy4xMTUwMjM3YzQuNzIzNDgyMiAwIDkuMDAxNTU1MiAxLjkwMDU5MzkgMTIuMTA2MjkyIDQuOTc2MzA5IDEuOTU2OTIzNy0yLjY0MTEzMSA0LjU1MDAyNjMtNC43ODU1MTgzIDcuNTUzODE3Ni02LjIwODQzMTg2eiIvPjxwYXRoIGQ9Ik01NS4zODAzMjgyIDQyLjY1MDE5OTFDNDYuMzMzNzIyNyA0Mi42NTAxOTkxIDM5IDM1LjM0MTIwMzEgMzkgMjYuMzI1MDk5NiAzOSAxNy4zMDg5OTYgNDYuMzMzNzIyNyAxMCA1NS4zODAzMjgyIDEwYzkuMDQ2NjA1NSAwIDE2LjM4MDMyODIgNy4zMDg5OTYgMTYuMzgwMzI4MiAxNi4zMjUwOTk2IDAgOS4wMTYxMDM1LTcuMzMzNzIyNyAxNi4zMjUwOTk1LTE2LjM4MDMyODIgMTYuMzI1MDk5NXptLjAyMTMwOTItNy43NTU2MzQyYzQuNzM3MDI3NiAwIDguNTc3MTQ3MS0zLjgyNzE3MiA4LjU3NzE0NzEtOC41NDgyMjc5IDAtNC43MjEwNTYtMy44NDAxMTk1LTguNTQ4MjI4LTguNTc3MTQ3MS04LjU0ODIyOC00LjczNzAyNzUgMC04LjU3NzE0NyAzLjgyNzE3Mi04LjU3NzE0NyA4LjU0ODIyOCAwIDQuNzIxMDU1OSAzLjg0MDExOTUgOC41NDgyMjc5IDguNTc3MTQ3IDguNTQ4MjI3OXoiLz48L2c+PC9zdmc+';
321 - add_menu_page( 'Cookiebot', __( 'Cookiebot', 'cookiebot' ), 'manage_options', 'cookiebot', array( $this, 'settings_page' ), $icon );
322 -
323 - add_submenu_page( 'cookiebot', __( 'Cookiebot Settings', 'cookiebot' ), __( 'Settings', 'cookiebot' ), 'manage_options', 'cookiebot', array( $this, 'settings_page' ), 10 );
324 - add_submenu_page( 'cookiebot', __( 'Cookiebot Support', 'cookiebot' ), __( 'Support', 'cookiebot' ), 'manage_options', 'cookiebot_support', array( $this, 'support_page' ), 20 );
325 - add_submenu_page( 'cookiebot', __( 'Google Tag Manager', 'cookiebot' ), __( 'Google Tag Manager', 'cookiebot' ), 'manage_options', 'cookiebot_GTM', array( $this, 'GTM_page' ) );
326 - add_submenu_page( 'cookiebot', __( 'IAB', 'cookiebot' ), __( 'IAB', 'cookiebot' ), 'manage_options', 'cookiebot_iab', array( $this, 'iab_page' ), 30 );
327 -
328 - if ( defined( 'COOKIEBOT_ADDONS_UNSUPPORTED_PHPVERSION' ) ) {
329 - //Load prior consent page anyway - but from Cookiebot WP Core plugin.
330 - add_submenu_page( 'cookiebot', __( 'Prior Consent', 'cookiebot' ), __( 'Prior Consent', 'cookiebot' ), 'manage_options', 'cookiebot-addons', array( $this, 'setting_page_placeholder' ), 40 );
331 - }
332 - }
333 -
334 - function add_menu_legislations() {
335 - add_submenu_page( 'cookiebot', __( 'Legislations', 'cookiebot' ), __( 'Legislations', 'cookiebot' ), 'manage_options', 'cookiebot-legislations', array( $this, 'legislations_page' ), 50 );
336 - }
337 -
338 - /**
339 - * Cookiebot_WP Add debug menu - we need to add this seperate to ensure it is placed last (after menu items from Addons).
340 - *
341 - * @version 3.6.0
342 - * @since 3.6.0
343 - */
344 - function add_menu_debug() {
345 - add_submenu_page( 'cookiebot', __( 'Debug info', 'cookiebot' ), __( 'Debug info', 'cookiebot' ), 'manage_options', 'cookiebot_debug', array( $this, 'debug_page' ) );
346 - }
347 -
348 - /**
349 - * Cookiebot_WP Add menu for network sites
350 - *
351 - * @version 2.2.0
352 - * @since 2.2.0
353 - */
354 - function add_network_menu() {
355 - $icon = 'data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgNzIgNTQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iI0ZGRkZGRiIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNNDYuODcyNTkwMyA4Ljc3MzU4MzM0QzQxLjk0MzkwMzkgMy4zODI5NTAxMSAzNC44NDI0OTQ2IDAgMjYuOTQ4MjgxOSAwIDEyLjA2NTE1NjggMCAwIDEyLjAyNDQ3NzQgMCAyNi44NTc0MjE5YzAgMTQuODMyOTQ0NSAxMi4wNjUxNTY4IDI2Ljg1NzQyMTkgMjYuOTQ4MjgxOSAyNi44NTc0MjE5IDcuODk0MjEyNyAwIDE0Ljk5NTYyMi0zLjM4Mjk1MDIgMTkuOTI0MzA4NC04Ljc3MzU4MzQtMi44ODk2OTY3LTEuMzY4ODY2My01LjM5OTMxMS0zLjQwNTQzOS03LjMyODA4MzgtNS45MDk2MzU4LTMuMTIxNDMwNiAzLjIwOTQxMDQtNy40OTI5OTQ0IDUuMjA0MTI5MS0xMi4zMzIwMjU4IDUuMjA0MTI5MS05LjQ4NDM0NDQgMC0xNy4xNzI5MjQ3LTcuNjYyNjU3Mi0xNy4xNzI5MjQ3LTE3LjExNTAyMzhzNy42ODg1ODAzLTE3LjExNTAyMzcgMTcuMTcyOTI0Ny0xNy4xMTUwMjM3YzQuNzIzNDgyMiAwIDkuMDAxNTU1MiAxLjkwMDU5MzkgMTIuMTA2MjkyIDQuOTc2MzA5IDEuOTU2OTIzNy0yLjY0MTEzMSA0LjU1MDAyNjMtNC43ODU1MTgzIDcuNTUzODE3Ni02LjIwODQzMTg2eiIvPjxwYXRoIGQ9Ik01NS4zODAzMjgyIDQyLjY1MDE5OTFDNDYuMzMzNzIyNyA0Mi42NTAxOTkxIDM5IDM1LjM0MTIwMzEgMzkgMjYuMzI1MDk5NiAzOSAxNy4zMDg5OTYgNDYuMzMzNzIyNyAxMCA1NS4zODAzMjgyIDEwYzkuMDQ2NjA1NSAwIDE2LjM4MDMyODIgNy4zMDg5OTYgMTYuMzgwMzI4MiAxNi4zMjUwOTk2IDAgOS4wMTYxMDM1LTcuMzMzNzIyNyAxNi4zMjUwOTk1LTE2LjM4MDMyODIgMTYuMzI1MDk5NXptLjAyMTMwOTItNy43NTU2MzQyYzQuNzM3MDI3NiAwIDguNTc3MTQ3MS0zLjgyNzE3MiA4LjU3NzE0NzEtOC41NDgyMjc5IDAtNC43MjEwNTYtMy44NDAxMTk1LTguNTQ4MjI4LTguNTc3MTQ3MS04LjU0ODIyOC00LjczNzAyNzUgMC04LjU3NzE0NyAzLjgyNzE3Mi04LjU3NzE0NyA4LjU0ODIyOCAwIDQuNzIxMDU1OSAzLjg0MDExOTUgOC41NDgyMjc5IDguNTc3MTQ3IDguNTQ4MjI3OXoiLz48L2c+PC9zdmc+';
356 - add_menu_page( 'Cookiebot', __( 'Cookiebot', 'cookiebot' ), 'manage_network_options', 'cookiebot_network', array( $this, 'network_settings_page' ), $icon );
357 -
358 - add_submenu_page( 'cookiebot_network', __( 'Cookiebot Settings', 'cookiebot' ), __( 'Settings', 'cookiebot' ), 'network_settings_page', 'cookiebot_network', array( $this, 'network_settings_page' ) );
359 - add_submenu_page( 'cookiebot_network', __( 'Cookiebot Support', 'cookiebot' ), __( 'Support', 'cookiebot' ), 'network_settings_page', 'cookiebot_support', array( $this, 'support_page' ) );
360 -
361 - }
362 -
363 - /**
364 - * Cookiebot_WP Cookiebot prior consent placeholder page
365 - *
366 - * @version 1.4.0
367 - * @since 1.0.0
368 - */
369 - function setting_page_placeholder() {
370 - include __DIR__ . DIRECTORY_SEPARATOR . 'addons' . DIRECTORY_SEPARATOR . 'view/admin/settings/setting-page.php';
371 - }
372 -
373 - /**
374 - * Cookiebot_WP Register Cookiebot settings
375 - *
376 - * @version 3.9.0
377 - * @since 1.0.0
378 - */
379 - function register_cookiebot_settings() {
380 - register_setting( 'cookiebot', 'cookiebot-cbid' );
381 - register_setting( 'cookiebot', 'cookiebot-language' );
382 - register_setting( 'cookiebot', 'cookiebot-nooutput' );
383 - register_setting( 'cookiebot', 'cookiebot-nooutput-admin' );
384 - register_setting( 'cookiebot', 'cookiebot-output-logged-in' );
385 - register_setting( 'cookiebot', 'cookiebot-autoupdate' );
386 - register_setting( 'cookiebot', 'cookiebot-script-tag-uc-attribute' );
387 - register_setting( 'cookiebot', 'cookiebot-script-tag-cd-attribute' );
388 - register_setting( 'cookiebot', 'cookiebot-cookie-blocking-mode' );
389 - register_setting( 'cookiebot', 'cookiebot-consent-mapping' );
390 - register_setting( 'cookiebot-iab', 'cookiebot-iab' );
391 - register_setting( 'cookiebot-legislations', 'cookiebot-ccpa' );
392 - register_setting( 'cookiebot-legislations', 'cookiebot-ccpa-domain-group-id' );
393 - register_setting( 'cookiebot-gtm', 'cookiebot-gtm' );
394 - register_setting( 'cookiebot-gtm', 'cookiebot-gtm-id' );
395 - register_setting( 'cookiebot-gtm', 'cookiebot-data-layer' );
396 - register_setting( 'cookiebot-gtm', 'cookiebot-gcm' );
397 - }
398 -
399 - /**
400 - * Cookiebot_WP Automatic update plugin if activated
401 - *
402 - * @version 2.2.0
403 - * @since 1.5.0
404 - */
405 - function automatic_updates( $update, $item ) {
406 - //Do not update from subsite on a multisite installation
407 - if ( is_multisite() && ! is_main_site() ) {
408 - return $update;
409 - }
410 -
411 - //Check if we have everything we need
412 - $item = (array) $item;
413 - if ( ! isset( $item['new_version'] ) || ! isset( $item['slug'] ) ) {
414 - return $update;
415 - }
416 -
417 - //It is not Cookiebot
418 - if ( $item['slug'] !== 'cookiebot' ) {
419 - return $update;
420 - }
421 -
422 - // Check if cookiebot autoupdate is disabled
423 - if ( ! get_option( 'cookiebot-autoupdate', false ) ) {
424 - return $update;
425 - }
426 -
427 - // Check if multisite autoupdate is disabled
428 - if ( is_multisite() && ! get_site_option( 'cookiebot-autoupdate', false ) ) {
429 - return $update;
430 - }
431 -
432 - return true;
433 - }
434 -
435 -
436 - /**
437 - * Cookiebot_WP Get list of supported languages
438 - *
439 - * @version 1.4.0
440 - * @since 1.4.0
441 - */
442 - public static function get_supported_languages() {
443 - $supportedLanguages = array();
444 - $supportedLanguages['nb'] = __( 'Norwegian Bokmål', 'cookiebot' );
445 - $supportedLanguages['tr'] = __( 'Turkish', 'cookiebot' );
446 - $supportedLanguages['de'] = __( 'German', 'cookiebot' );
447 - $supportedLanguages['cs'] = __( 'Czech', 'cookiebot' );
448 - $supportedLanguages['da'] = __( 'Danish', 'cookiebot' );
449 - $supportedLanguages['sq'] = __( 'Albanian', 'cookiebot' );
450 - $supportedLanguages['he'] = __( 'Hebrew', 'cookiebot' );
451 - $supportedLanguages['ko'] = __( 'Korean', 'cookiebot' );
452 - $supportedLanguages['it'] = __( 'Italian', 'cookiebot' );
453 - $supportedLanguages['nl'] = __( 'Dutch', 'cookiebot' );
454 - $supportedLanguages['vi'] = __( 'Vietnamese', 'cookiebot' );
455 - $supportedLanguages['ta'] = __( 'Tamil', 'cookiebot' );
456 - $supportedLanguages['is'] = __( 'Icelandic', 'cookiebot' );
457 - $supportedLanguages['ro'] = __( 'Romanian', 'cookiebot' );
458 - $supportedLanguages['si'] = __( 'Sinhala', 'cookiebot' );
459 - $supportedLanguages['ca'] = __( 'Catalan', 'cookiebot' );
460 - $supportedLanguages['bg'] = __( 'Bulgarian', 'cookiebot' );
461 - $supportedLanguages['uk'] = __( 'Ukrainian', 'cookiebot' );
462 - $supportedLanguages['zh'] = __( 'Chinese', 'cookiebot' );
463 - $supportedLanguages['en'] = __( 'English', 'cookiebot' );
464 - $supportedLanguages['ar'] = __( 'Arabic', 'cookiebot' );
465 - $supportedLanguages['hr'] = __( 'Croatian', 'cookiebot' );
466 - $supportedLanguages['th'] = __( 'Thai', 'cookiebot' );
467 - $supportedLanguages['el'] = __( 'Greek', 'cookiebot' );
468 - $supportedLanguages['lt'] = __( 'Lithuanian', 'cookiebot' );
469 - $supportedLanguages['pl'] = __( 'Polish', 'cookiebot' );
470 - $supportedLanguages['lv'] = __( 'Latvian', 'cookiebot' );
471 - $supportedLanguages['fr'] = __( 'French', 'cookiebot' );
472 - $supportedLanguages['id'] = __( 'Indonesian', 'cookiebot' );
473 - $supportedLanguages['mk'] = __( 'Macedonian', 'cookiebot' );
474 - $supportedLanguages['et'] = __( 'Estonian', 'cookiebot' );
475 - $supportedLanguages['pt'] = __( 'Portuguese', 'cookiebot' );
476 - $supportedLanguages['ga'] = __( 'Irish', 'cookiebot' );
477 - $supportedLanguages['ms'] = __( 'Malay', 'cookiebot' );
478 - $supportedLanguages['sl'] = __( 'Slovenian', 'cookiebot' );
479 - $supportedLanguages['ru'] = __( 'Russian', 'cookiebot' );
480 - $supportedLanguages['ja'] = __( 'Japanese', 'cookiebot' );
481 - $supportedLanguages['hi'] = __( 'Hindi', 'cookiebot' );
482 - $supportedLanguages['sk'] = __( 'Slovak', 'cookiebot' );
483 - $supportedLanguages['es'] = __( 'Spanish', 'cookiebot' );
484 - $supportedLanguages['sv'] = __( 'Swedish', 'cookiebot' );
485 - $supportedLanguages['sr'] = __( 'Serbian', 'cookiebot' );
486 - $supportedLanguages['fi'] = __( 'Finnish', 'cookiebot' );
487 - $supportedLanguages['eu'] = __( 'Basque', 'cookiebot' );
488 - $supportedLanguages['hu'] = __( 'Hungarian', 'cookiebot' );
489 - asort( $supportedLanguages, SORT_LOCALE_STRING );
490 - return $supportedLanguages;
491 - }
492 -
493 - /**
494 - * Cookiebot_WP Output settings page
495 - *
496 - * @version 3.9.0
497 - * @since 1.0.0
498 - */
499 - function settings_page() {
500 - wp_enqueue_style( 'cookiebot-consent-mapping-table', plugins_url( 'css/consent_mapping_table.css', __FILE__ ), array(), '3.5.0' );
501 -
502 - /* Check if multisite */
503 - if ( $is_ms = is_multisite() ) {
504 - //Receive settings from multisite - this might change the way we render the form
505 - $network_cbid = get_site_option( 'cookiebot-cbid', '' );
506 - $network_scrip_tag_uc_attr = get_site_option( 'cookiebot-script-tag-uc-attribute', 'custom' );
507 - $network_scrip_tag_cd_attr = get_site_option( 'cookiebot-script-tag-cd-attribute', 'custom' );
508 - $network_cookie_blocking_mode = get_site_option( 'cookiebot-cookie-blocking-mode', 'manual' );
509 - }
510 - ?>
511 - <div class="wrap">
512 - <h1><?php esc_html_e( 'Cookiebot Settings', 'cookiebot' ); ?></h1>
513 - <a href="https://www.cookiebot.com">
514 - <img src="<?php echo plugins_url( 'cookiebot-logo.png', __FILE__ ); ?>" style="float:right;margin-left:1em;">
515 - </a>
516 - <p>
517 - <?php
518 - $cookiebot_gdpr_url = 'https://www.cookiebot.com/goto/gdpr';
519 - printf(
520 - esc_html__( '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 %1$s %2$s.', 'cookiebot' ),
521 - sprintf(
522 - '<a href="%s" target="_blank">%s</a>',
523 - esc_url( $cookiebot_gdpr_url ),
524 - esc_html__( 'General Data Protection Regulation (GDPR)', 'cookiebot' )
525 - ),
526 - esc_html__( ' 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' )
527 - );
528 - ?>
529 - </p>
530 - <form method="post" action="options.php">
531 - <?php settings_fields( 'cookiebot' ); ?>
532 - <?php do_settings_sections( 'cookiebot' ); ?>
533 - <table class="form-table">
534 - <tr valign="top">
535 - <th scope="row"><?php esc_html_e( 'Cookiebot ID', 'cookiebot' ); ?></th>
536 - <td>
537 - <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" />
538 - <p class="description">
539 - <?php esc_html_e( 'Need an ID?', 'cookiebot' ); ?>
540 - <a href="https://www.cookiebot.com/goto/signup" target="_blank"><?php esc_html_e( 'Sign up for free on cookiebot.com', 'cookiebot' ); ?></a>
541 - </p>
542 - </td>
543 - </tr>
544 - <tr valign="top">
545 - <th scope="row">
546 - <?php esc_html_e( 'Cookie-blocking mode', 'cookiebot' ); ?>
547 - </th>
548 - <td>
549 - <?php
550 - $cbm = get_option( 'cookiebot-cookie-blocking-mode', 'manual' );
551 - if ( $is_ms && $network_cookie_blocking_mode != 'custom' ) {
552 - $cbm = $network_cookie_blocking_mode;
553 - }
554 - ?>
555 - <label>
556 - <input type="radio" name="cookiebot-cookie-blocking-mode" value="auto" <?php checked( 'auto', $cbm, true ); ?> />
557 - <?php esc_html_e( 'Automatic', 'cookiebot' ); ?>
558 - </label>
559 - &nbsp; &nbsp;
560 - <label>
561 - <input type="radio" name="cookiebot-cookie-blocking-mode" value="manual" <?php checked( 'manual', $cbm, true ); ?> />
562 - <?php esc_html_e( 'Manual', 'cookiebot' ); ?>
563 - </label>
564 - <p class="description">
565 - <?php esc_html_e( 'Automatic block cookies (except necessary) until the user has given their consent.', 'cookiebot' ); ?>
566 - <a href="https://support.cookiebot.com/hc/en-us/articles/360009063100-Automatic-Cookie-Blocking-How-does-it-work-" target="_blank">
567 - <?php esc_html_e( 'Learn more', 'cookiebot' ); ?>
568 - </a>
569 - </p>
570 - <script>
571 - jQuery(document).ready(function($) {
572 - var cookieBlockingMode = '<?php echo $cbm; ?>';
573 - $( 'input[type=radio][name=cookiebot-cookie-blocking-mode]' ).on( 'change', function() {
574 - if(this.value == 'auto' && cookieBlockingMode != this.value ) {
575 - $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 );
576 - $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true );
577 - }
578 - if( this.value == 'manual' && cookieBlockingMode != this.value ) {
579 - $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 1 );
580 - $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', false );
581 - }
582 - cookieBlockingMode = this.value;
583 - });
584 - if( cookieBlockingMode == 'auto' ) {
585 - $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 );
586 - $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true );
587 - }
588 - });
589 - </script>
590 - </td>
591 - </tr>
592 - <tr valign="top">
593 - <th scope="row"><?php esc_html_e( 'Cookiebot Language', 'cookiebot' ); ?></th>
594 - <td>
595 - <div>
596 - <select name="cookiebot-language" id="cookiebot-language">
597 - <?php
598 - $currentLang = $this->get_language( true );
599 - ?>
600 - <option value=""><?php esc_html_e( 'Default (Autodetect)', 'cookiebot' ); ?></option>
601 - <option value="_wp"<?php echo ( $currentLang == '_wp' ) ? ' selected' : ''; ?>><?php esc_html_e( 'Use WordPress Language', 'cookiebot' ); ?></option>
602 - <?php
603 - $supportedLanguages = $this->get_supported_languages();
604 - foreach ( $supportedLanguages as $langCode => $langName ) {
605 - echo '<option value="' . $langCode . '"' . ( ( $currentLang == $langCode ) ? ' selected' : '' ) . '>' . $langName . '</option>';
606 - }
607 - ?>
608 - </select>
609 - </div>
610 - <div class="notice inline notice-warning notice-alt cookiebot-notice" style="padding:12px;font-size:13px;display:inline-block;">
611 - <div style="<?php echo ( $currentLang == '' ) ? 'display:none;' : ''; ?>" id="info_lang_specified">
612 - <?php esc_html_e( 'You need to add the language in the Cookiebot administration tool.', 'cookiebot' ); ?>
613 - </div>
614 - <div style="<?php echo ( $currentLang == '' ) ? '' : 'display:none;'; ?>" id="info_lang_autodetect">
615 - <?php esc_html_e( 'You need to add all languages that you want auto-detected in the Cookiebot administration tool.', 'cookiebot' ); ?> <br/>
616 - <?php esc_html_e( 'The auto-detect checkbox needs to be enabled in the Cookiebot administration tool.', 'cookiebot' ); ?><br/>
617 - <?php esc_html_e( 'If the auto-detected language is not supported, Cookiebot will use the default language.', 'cookiebot' ); ?>
618 - </div>
619 - <br />
620 -
621 - <a href="#" id="show_add_language_guide"><?php esc_html_e( 'Show guide to add languages', 'cookiebot' ); ?></a>
622 - &nbsp;
623 - <a href="https://support.cookiebot.com/hc/en-us/articles/360003793394-How-do-I-set-the-language-of-the-consent-banner-dialog-" target="_blank">
624 - <?php esc_html_e( 'Read more here', 'cookiebot' ); ?>
625 - </a>
626 -
627 - <div id="add_language_guide" style="display:none;">
628 - <img src="<?php echo plugin_dir_url( __FILE__ ); ?>/assets/guide_add_language.gif" alt="Add language in Cookiebot administration tool" />
629 - <br />
630 - <a href="#" id="hide_add_language_guide"><?php esc_html_e( 'Hide guide', 'cookiebot' ); ?></a>
631 - </div>
632 - </div>
633 - <script>
634 - jQuery(document).ready(function($) {
635 - $('#show_add_language_guide').on('click',function(e) {
636 - e.preventDefault();
637 - $('#add_language_guide').slideDown();
638 - $(this).hide();
639 - });
640 - $('#hide_add_language_guide').on('click',function(e) {
641 - e.preventDefault();
642 - $('#add_language_guide').slideUp();
643 - $('#show_add_language_guide').show();
644 - });
645 -
646 - $('#cookiebot-language').on('change', function() {
647 - if(this.value == '') {
648 - $('#info_lang_autodetect').show();
649 - $('#info_lang_specified').hide();
650 - }
651 - else {
652 - $('#info_lang_autodetect').hide();
653 - $('#info_lang_specified').show();
654 - }
655 - });
656 - });
657 - </script>
658 -
659 - </td>
660 - </tr>
661 - </table>
662 - <script>
663 - jQuery(document).ready(function($) {
664 - $('.cookiebot_fieldset_header').on('click',function(e) {
665 - e.preventDefault();
666 - $(this).next().slideToggle();
667 - $(this).toggleClass('active');
668 - });
669 - });
670 - </script>
671 - <style type="text/css">
672 - .cookiebot_fieldset_header {
673 - cursor:pointer;
674 - }
675 - .cookiebot_fieldset_header::after {
676 - content: "\f140";
677 - font: normal 24px/1 dashicons;
678 - position: relative;
679 - top: 5px;
680 - }
681 - .cookiebot_fieldset_header.active::after {
682 - content: "\f142";
683 - }
684 - </style>
685 - <h3 id="advanced_settings_link" class="cookiebot_fieldset_header"><?php esc_html_e( 'Advanced settings', 'cookiebot' ); ?></h3>
686 - <div id="advanced_settings" style="display:none;">
687 - <table class="form-table">
688 - <tr valign="top" id="cookiebot-setting-async">
689 - <th scope="row">
690 - <?php esc_html_e( 'Add async or defer attribute', 'cookiebot' ); ?>
691 - <br /><?php esc_html_e( 'Consent banner script tag', 'cookiebot' ); ?>
692 - </th>
693 - <td>
694 - <?php
695 - $cv = get_option( 'cookiebot-script-tag-uc-attribute', 'async' );
696 - $disabled = false;
697 - if ( $is_ms && $network_scrip_tag_uc_attr != 'custom' ) {
698 - $disabled = true;
699 - $cv = $network_scrip_tag_uc_attr;
700 - }
701 - ?>
702 - <label>
703 - <input type="radio" name="cookiebot-script-tag-uc-attribute"<?php echo ( $disabled ) ? ' disabled' : ''; ?> value="" <?php checked( '', $cv, true ); ?> />
704 - <i><?php esc_html_e( 'None', 'cookiebot' ); ?></i>
705 - </label>
706 - &nbsp; &nbsp;
707 - <label>
708 - <input type="radio" name="cookiebot-script-tag-uc-attribute"<?php echo ( $disabled ) ? ' disabled' : ''; ?> value="async" <?php checked( 'async', $cv, true ); ?> />
709 - async
710 - </label>
711 - &nbsp; &nbsp;
712 - <label>
713 - <input type="radio" name="cookiebot-script-tag-uc-attribute"<?php echo ( $disabled ) ? ' disabled' : ''; ?> value="defer" <?php checked( 'defer', $cv, true ); ?> />
714 - defer
715 - </label>
716 - <p class="description">
717 - <?php
718 - if ( $disabled ) {
719 - echo '<b>' . esc_html__( 'Network setting applied. Please contact website administrator to change this setting.', 'cookiebot' ) . '</b><br />'; }
720 - ?>
721 - <?php esc_html_e( 'Add async or defer attribute to Cookiebot script tag. Default: async', 'cookiebot' ); ?>
722 - </p>
723 - </td>
724 - </tr>
725 - <tr valign="top">
726 - <th scope="row">
727 - <?php esc_html_e( 'Add async or defer attribute', 'cookiebot' ); ?>
728 - <br /><?php esc_html_e( 'Cookie declaration script tag', 'cookiebot' ); ?>
729 - </th>
730 - <td>
731 - <?php
732 - $cv = get_option( 'cookiebot-script-tag-cd-attribute', 'async' );
733 - $disabled = false;
734 - if ( $is_ms && $network_scrip_tag_cd_attr != 'custom' ) {
735 - $disabled = true;
736 - $cv = $network_scrip_tag_cd_attr;
737 - }
738 - ?>
739 - <label>
740 - <input type="radio" name="cookiebot-script-tag-cd-attribute"<?php echo ( $disabled ) ? ' disabled' : ''; ?> value="" <?php checked( '', $cv, true ); ?> />
741 - <i><?php esc_html_e( 'None', 'cookiebot' ); ?></i>
742 - </label>
743 - &nbsp; &nbsp;
744 - <label>
745 - <input type="radio" name="cookiebot-script-tag-cd-attribute"<?php echo ( $disabled ) ? ' disabled' : ''; ?> value="async" <?php checked( 'async', $cv, true ); ?> />
746 - async
747 - </label>
748 - &nbsp; &nbsp;
749 - <label>
750 - <input type="radio" name="cookiebot-script-tag-cd-attribute"<?php echo ( $disabled ) ? ' disabled' : ''; ?> value="defer" <?php checked( 'defer', $cv, true ); ?> />
751 - defer
752 - </label>
753 - <p class="description">
754 - <?php
755 - if ( $disabled ) {
756 - echo '<b>' . esc_html__( 'Network setting applied. Please contact website administrator to change this setting.', 'cookiebot' ) . '</b><br />'; }
757 - ?>
758 - <?php esc_html_e( 'Add async or defer attribute to Cookiebot script tag. Default: async', 'cookiebot' ); ?>
759 - </p>
760 - </td>
761 - </tr>
762 - <?php
763 - if ( ! is_multisite() ) {
764 - ?>
765 - <tr valign="top">
766 - <th scope="row"><?php esc_html_e( 'Auto-update Cookiebot', 'cookiebot' ); ?></th>
767 - <td>
768 - <input type="checkbox" name="cookiebot-autoupdate" value="1" <?php checked( 1, get_option( 'cookiebot-autoupdate', false ), true ); ?> />
769 - <p class="description">
770 - <?php esc_html_e( 'Automatic update your Cookiebot plugin when new releases becomes available.', 'cookiebot' ); ?>
771 - </p>
772 - </td>
773 - </tr>
774 - <?php
775 - }
776 - ?>
777 - <tr valign="top" id="cookiebot-setting-hide-popup">
778 - <th scope="row"><?php esc_html_e( 'Hide Cookie Popup', 'cookiebot' ); ?></th>
779 - <td>
780 - <?php
781 - $disabled = false;
782 - if ( $is_ms && get_site_option( 'cookiebot-nooutput', false ) ) {
783 - $disabled = true;
784 - echo '<input type="checkbox" checked disabled />';
785 - } else {
786 - ?>
787 - <input type="checkbox" name="cookiebot-nooutput" value="1" <?php checked( 1, get_option( 'cookiebot-nooutput', false ), true ); ?> />
788 - <?php
789 - }
790 - ?>
791 - <p class="description">
792 - <?php
793 - if ( $disabled ) {
794 - echo '<b>' . esc_html__( 'Network setting applied. Please contact website administrator to change this setting.', 'cookiebot' ) . '</b><br />'; }
795 - ?>
796 - <b><?php esc_html_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 />
797 - <?php esc_html_e( 'If you are using Google Tag Manager (or equal), you need to add the Cookiebot script in your Tag Manager.', 'cookiebot' ); ?><br />
798 - <a href="https://support.cookiebot.com/hc/en-us/articles/360003793854-Google-Tag-Manager-deployment" target="_blank">
799 - <?php esc_html_e( 'See a detailed guide here', 'cookiebot' ); ?>
800 - </a>
801 - </p>
802 - </td>
803 - </tr>
804 - <tr valign="top">
805 - <th scope="row"><?php esc_html_e( 'Disable Cookiebot in WP Admin', 'cookiebot' ); ?></th>
806 - <td>
807 - <?php
808 - $disabled = false;
809 - if ( $is_ms && get_site_option( 'cookiebot-nooutput-admin', false ) ) {
810 - echo '<input type="checkbox" checked disabled />';
811 - $disabled = true;
812 - } else {
813 - ?>
814 - <input type="checkbox" name="cookiebot-nooutput-admin" value="1" <?php checked( 1, get_option( 'cookiebot-nooutput-admin', false ), true ); ?> />
815 - <?php
816 - }
817 - ?>
818 - <p class="description">
819 - <?php
820 - if ( $disabled ) {
821 - echo '<b>' . __( 'Network setting applied. Please contact website administrator to change this setting.' ) . '</b><br />'; }
822 - ?>
823 - <b><?php esc_html_e( 'This checkbox will disable Cookiebot in the WordPress Admin area.', 'cookiebot' ); ?></b>
824 - </p>
825 - </td>
826 - </tr>
827 - <tr valign="top">
828 - <th scope="row"><?php esc_html_e( 'Enable Cookiebot on front end while logged in', 'cookiebot' ); ?></th>
829 - <td>
830 - <?php
831 - $disabled = false;
832 - if ( $is_ms && get_site_option( 'cookiebot-output-logged-in', false ) ) {
833 - echo '<input type="checkbox" checked disabled />';
834 - $disabled = true;
835 - } else {
836 - ?>
837 - <input type="checkbox" name="cookiebot-output-logged-in" value="1" <?php checked( 1, get_option( 'cookiebot-output-logged-in', false ), true ); ?> />
838 - <?php
839 - }
840 - ?>
841 - <p class="description">
842 - <?php
843 - if ( $disabled ) {
844 - echo '<b>' . esc_html__( 'Network setting applied. Please contact website administrator to change this setting.' ) . '</b><br />'; }
845 - ?>
846 - <b><?php esc_html_e( 'This checkbox will enable Cookiebot on front end while you\'re logged in', 'cookiebot' ); ?></b>
847 - </p>
848 - </td>
849 - </tr>
850 - </table>
851 - </div>
852 - <?php if ( $this->is_wp_consent_api_active() ) { ?>
853 - <h3 id="consent_level_api_settings" class="cookiebot_fieldset_header"><?php esc_html_e( 'Consent Level API Settings', 'cookiebot' ); ?></h3>
854 - <div id="consent_level_api_settings" style="display:none;">
855 - <p><?php esc_html_e( 'WP Consent Level API and Cookiebot categorise cookies a bit different. The default settings should fit mosts needs - but if you need to change the mapping you are able to do it below.', 'cookiebot' ); ?></p>
856 -
857 - <?php
858 - $mDefault = $this->get_default_wp_consent_api_mapping();
859 -
860 - $m = $this->get_wp_consent_api_mapping();
861 -
862 - $consentTypes = array( 'preferences', 'statistics', 'marketing' );
863 - $states = array_reduce(
864 - $consentTypes,
865 - function ( $t, $v ) {
866 - $newt = array();
867 - if ( empty( $t ) ) {
868 - $newt = array(
869 - array( $v => true ),
870 - array( $v => false ),
871 - );
872 - } else {
873 - foreach ( $t as $item ) {
874 - $newt[] = array_merge( $item, array( $v => true ) );
875 - $newt[] = array_merge( $item, array( $v => false ) );
876 - }
877 - }
878 -
879 - return $newt;
880 - },
881 - array()
882 - );
883 -
884 - ?>
885 -
886 -
887 - <table class="widefat striped consent_mapping_table">
888 - <thead>
889 - <tr>
890 - <th><?php esc_html_e( 'Cookiebot categories', 'cookiebot' ); ?></th>
891 - <th class="consent_mapping"><?php esc_html_e( 'WP Consent Level categories', 'cookiebot' ); ?></th>
892 - </tr>
893 - </thead>
894 - <?php
895 - foreach ( $states as $state ) {
896 -
897 - $key = array();
898 - $key[] = 'n=1';
899 - $key[] = 'p=' . ( $state['preferences'] ? '1' : '0' );
900 - $key[] = 's=' . ( $state['statistics'] ? '1' : '0' );
901 - $key[] = 'm=' . ( $state['marketing'] ? '1' : '0' );
902 - $key = implode( ';', $key );
903 - ?>
904 - <tr valign="top">
905 - <td>
906 - <div class="cb_consent">
907 - <span class="forceconsent">
908 - <?php esc_html_e( 'Necessary', 'cookiebot' ); ?>
909 - </span>
910 - <span class="<?php echo( $state['preferences'] ? 'consent' : 'noconsent' ); ?>">
911 - <?php esc_html_e( 'Preferences', 'cookiebot' ); ?>
912 - </span>
913 - <span class="<?php echo( $state['statistics'] ? 'consent' : 'noconsent' ); ?>">
914 - <?php esc_html_e( 'Statistics', 'cookiebot' ); ?>
915 - </span>
916 - <span class="<?php echo( $state['marketing'] ? 'consent' : 'noconsent' ); ?>">
917 - <?php esc_html_e( 'Marketing', 'cookiebot' ); ?>
918 - </span>
919 - </div>
920 - </td>
921 - <td>
922 - <div class="consent_mapping">
923 - <label><input type="checkbox" name="cookiebot-consent-mapping[<?php echo $key; ?>][functional]" data-default-value="1" value="1" checked disabled
924 - > <?php esc_html_e( 'Functional', 'cookiebot' ); ?> </label>
925 - <label><input type="checkbox" name="cookiebot-consent-mapping[<?php echo $key; ?>][preferences]" data-default-value="<?php echo $mDefault[ $key ]['preferences']; ?>" value="1"
926 - <?php
927 - if ( $m[ $key ]['preferences'] ) {
928 - echo 'checked'; }
929 - ?>
930 - > <?php esc_html_e( 'Preferences', 'cookiebot' ); ?> </label>
931 - <label><input type="checkbox" name="cookiebot-consent-mapping[<?php echo $key; ?>][statistics]" data-default-value="<?php echo $mDefault[ $key ]['statistics']; ?>" value="1"
932 - <?php
933 - if ( $m[ $key ]['statistics'] ) {
934 - echo 'checked'; }
935 - ?>
936 - > <?php esc_html_e( 'Statistics', 'cookiebot' ); ?> </label>
937 - <label><input type="checkbox" name="cookiebot-consent-mapping[<?php echo $key; ?>][statistics-anonymous]" data-default-value="<?php echo $mDefault[ $key ]['statistics-anonymous']; ?>" value="1"
938 - <?php
939 - if ( $m[ $key ]['statistics-anonymous'] ) {
940 - echo 'checked'; }
941 - ?>
942 - > <?php esc_html_e( 'Statistics Anonymous', 'cookiebot' ); ?></label>
943 - <label><input type="checkbox" name="cookiebot-consent-mapping[<?php echo $key; ?>][marketing]" data-default-value="<?php echo $mDefault[ $key ]['marketing']; ?>" value="1"
944 - <?php
945 - if ( $m[ $key ]['marketing'] ) {
946 - echo 'checked'; }
947 - ?>
948 - > <?php esc_html_e( 'Marketing', 'cookiebot' ); ?></label>
949 - </div>
950 - </td>
951 - </tr>
952 - <?php
953 - }
954 - ?>
955 - <tfoot>
956 - <tr>
957 - <td colspan="2" style="text-align:right;"><button class="button" onclick="return resetConsentMapping();"><?php esc_html_e( 'Reset to default mapping', 'cookiebot' ); ?></button></td>
958 - </tr>
959 - </tfoot>
960 - </table>
961 - <script>
962 - function resetConsentMapping() {
963 - if(confirm('Are you sure you want to reset to default consent mapping?')) {
964 - jQuery('.consent_mapping_table input[type=checkbox]').each(function () {
965 - if(!this.disabled) {
966 - this.checked = (jQuery(this).data('default-value') == '1') ? true : false;
967 - }
968 - });
969 - }
970 - return false;
971 - }
972 - </script>
973 - </div>
974 - <?php } ?>
975 - <?php submit_button(); ?>
976 - </form>
977 - </div>
978 - <?php
979 - }
980 -
981 - /**
982 - * Cookiebot_WP Cookiebot network setting page
983 - *
984 - * @version 2.2.0
985 - * @since 2.2.0
986 - */
987 - function network_settings_page() {
988 - ?>
989 - <div class="wrap">
990 - <h1><?php esc_html_e( 'Cookiebot Network Settings', 'cookiebot' ); ?></h1>
991 - <a href="https://www.cookiebot.com">
992 - <img src="<?php echo plugins_url( 'cookiebot-logo.png', __FILE__ ); ?>" style="float:right;margin-left:1em;">
993 - </a>
994 - <p>
995 - <?php
996 - $cookiebot_gdpr_url = 'https://www.cookiebot.com/goto/gdpr';
997 - printf(
998 - esc_html__( '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 %1$s %2$s.', 'cookiebot' ),
999 - sprintf(
1000 - '<a href="%s" target="_blank">%s</a>',
1001 - esc_url( $cookiebot_gdpr_url ),
1002 - esc_html__( 'General Data Protection Regulation (GDPR)', 'cookiebot' )
1003 - ),
1004 - esc_html__( ' 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' )
1005 - );
1006 - ?>
1007 - </p>
1008 - <p>
1009 - <b><big style="color:red;"><?php esc_html_e( 'The settings below is network wide settings. See notes below each field.', 'cookiebot' ); ?></big></b>
1010 - </p>
1011 - <form method="post" action="edit.php?action=cookiebot_network_settings">
1012 - <?php wp_nonce_field( 'cookiebot-network-settings' ); ?>
1013 - <table class="form-table">
1014 - <tr valign="top">
1015 - <th scope="row"><?php esc_html_e( 'Network Cookiebot ID', 'cookiebot' ); ?></th>
1016 - <td>
1017 - <input type="text" name="cookiebot-cbid" value="<?php echo esc_attr( get_site_option( 'cookiebot-cbid', '' ) ); ?>" style="width:300px" />
1018 - <p class="description">
1019 - <b><?php esc_html_e( 'If added this will be the default Cookiebot ID for all subsites. Subsites are able to override the Cookiebot ID.', 'cookiebot' ); ?></b>
1020 - <br />
1021 - <?php esc_html_e( 'Need an ID?', 'cookiebot' ); ?>
1022 - <a href="https://www.cookiebot.com/goto/signup" target="_blank"><?php esc_html_e( 'Sign up for free on cookiebot.com', 'cookiebot' ); ?></a>
1023 - </p>
1024 - </td>
1025 - </tr>
1026 - <tr valign="top">
1027 - <th scope="row">
1028 - <?php esc_html_e( 'Cookie-blocking mode', 'cookiebot' ); ?>
1029 - </th>
1030 - <td>
1031 - <?php
1032 - $cbm = get_site_option( 'cookiebot-cookie-blocking-mode', 'manual' );
1033 - ?>
1034 - <label>
1035 - <input type="radio" name="cookiebot-cookie-blocking-mode" value="auto" <?php checked( 'auto', $cbm, true ); ?> />
1036 - <?php esc_html_e( 'Automatic', 'cookiebot' ); ?>
1037 - </label>
1038 - &nbsp; &nbsp;
1039 - <label>
1040 - <input type="radio" name="cookiebot-cookie-blocking-mode" value="manual" <?php checked( 'manual', $cbm, true ); ?> />
1041 - <?php esc_html_e( 'Manual', 'cookiebot' ); ?>
1042 - </label>
1043 - <p class="description">
1044 - <?php esc_html_e( 'Should Cookiebot automatic block cookies by tagging known tags.', 'cookiebot' ); ?>
1045 - </p>
1046 - </td>
1047 - </tr>
1048 - <script>
1049 - jQuery(document).ready(function($) {
1050 - var cookieBlockingMode = '<?php echo $cbm; ?>';
1051 - $( 'input[type=radio][name=cookiebot-cookie-blocking-mode]' ).on( 'change', function() {
1052 - if(this.value == 'auto' && cookieBlockingMode != this.value ) {
1053 - $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 );
1054 - $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true );
1055 - }
1056 - if( this.value == 'manual' && cookieBlockingMode != this.value ) {
1057 - $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 1 );
1058 - $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', false );
1059 - }
1060 - cookieBlockingMode = this.value;
1061 - });
1062 - if( cookieBlockingMode == 'auto' ) {
1063 - $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 );
1064 - $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true );
1065 - }
1066 - });
1067 - </script>
1068 - <tr valign="top" id="cookiebot-setting-async">
1069 - <th scope="row">
1070 - <?php esc_html_e( 'Add async or defer attribute', 'cookiebot' ); ?>
1071 - <br /><?php esc_html_e( 'Consent banner script tag', 'cookiebot' ); ?>
1072 - </th>
1073 - <td>
1074 - <?php
1075 - $cv = get_site_option( 'cookiebot-script-tag-uc-attribute', 'custom' );
1076 - ?>
1077 - <label>
1078 - <input type="radio" name="cookiebot-script-tag-uc-attribute" value="" <?php checked( '', $cv, true ); ?> />
1079 - <i><?php esc_html_e( 'None', 'cookiebot' ); ?></i>
1080 - </label>
1081 - &nbsp; &nbsp;
1082 - <label>
1083 - <input type="radio" name="cookiebot-script-tag-uc-attribute" value="async" <?php checked( 'async', $cv, true ); ?> />
1084 - async
1085 - </label>
1086 - &nbsp; &nbsp;
1087 - <label>
1088 - <input type="radio" name="cookiebot-script-tag-uc-attribute" value="defer" <?php checked( 'defer', $cv, true ); ?> />
1089 - defer
1090 - </label>
1091 - &nbsp; &nbsp;
1092 - <label>
1093 - <input type="radio" name="cookiebot-script-tag-uc-attribute" value="custom" <?php checked( 'custom', $cv, true ); ?> />
1094 - <i><?php esc_html_e( 'Choose per subsite', 'cookiebot' ); ?></i>
1095 - </label>
1096 - <p class="description">
1097 - <b><?php esc_html_e( 'Setting will apply for all subsites. Subsites will not be able to override.', 'cookiebot' ); ?></b><br />
1098 - <?php esc_html_e( 'Add async or defer attribute to Cookiebot script tag. Default: Choose per subsite', 'cookiebot' ); ?>
1099 - </p>
1100 - </td>
1101 - </tr>
1102 - <tr valign="top">
1103 - <th scope="row">
1104 - <?php esc_html_e( 'Add async or defer attribute', 'cookiebot' ); ?>
1105 - <br /><?php esc_html_e( 'Cookie declaration script tag', 'cookiebot' ); ?>
1106 - </th>
1107 - <td>
1108 - <?php
1109 - $cv = get_site_option( 'cookiebot-script-tag-cd-attribute', 'custom' );
1110 - ?>
1111 - <label>
1112 - <input type="radio" name="cookiebot-script-tag-cd-attribute" value="" <?php checked( '', $cv, true ); ?> />
1113 - <i><?php esc_html_e( 'None', 'cookiebot' ); ?></i>
1114 - </label>
1115 - &nbsp; &nbsp;
1116 - <label>
1117 - <input type="radio" name="cookiebot-script-tag-cd-attribute" value="async" <?php checked( 'async', $cv, true ); ?> />
1118 - async
1119 - </label>
1120 - &nbsp; &nbsp;
1121 - <label>
1122 - <input type="radio" name="cookiebot-script-tag-cd-attribute" value="defer" <?php checked( 'defer', $cv, true ); ?> />
1123 - defer
1124 - </label>
1125 - &nbsp; &nbsp;
1126 - <label>
1127 - <input type="radio" name="cookiebot-script-tag-cd-attribute" value="custom" <?php checked( 'custom', $cv, true ); ?> />
1128 - <i><?php esc_html_e( 'Choose per subsite', 'cookiebot' ); ?></i>
1129 - </label>
1130 - <p class="description">
1131 - <b><?php esc_html_e( 'Setting will apply for all subsites. Subsites will not be able to override.', 'cookiebot' ); ?></b><br />
1132 - <?php esc_html_e( 'Add async or defer attribute to Cookiebot script tag. Default: Choose per subsite', 'cookiebot' ); ?>
1133 - </p>
1134 - </td>
1135 - </tr>
1136 - <tr valign="top">
1137 - <th scope="row"><?php esc_html_e( 'Auto-update Cookiebot', 'cookiebot' ); ?></th>
1138 - <td>
1139 - <input type="checkbox" name="cookiebot-autoupdate" value="1" <?php checked( 1, get_site_option( 'cookiebot-autoupdate', false ), true ); ?> />
1140 - <p class="description">
1141 - <?php esc_html_e( 'Automatic update your Cookiebot plugin when new releases becomes available.', 'cookiebot' ); ?>
1142 - </p>
1143 - </td>
1144 - </tr>
1145 - <tr valign="top" id="cookiebot-setting-hide-popup">
1146 - <th scope="row"><?php esc_html_e( 'Hide Cookie Popup', 'cookiebot' ); ?></th>
1147 - <td>
1148 - <input type="checkbox" name="cookiebot-nooutput" value="1" <?php checked( 1, get_site_option( 'cookiebot-nooutput', false ), true ); ?> />
1149 - <p class="description">
1150 - <b><?php esc_html_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 />
1151 - <?php esc_html_e( 'If you are using Google Tag Manager (or equal), you need to add the Cookiebot script in your Tag Manager.', 'cookiebot' ); ?><br />
1152 - <?php esc_html_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' ); ?>
1153 - </p>
1154 - </td>
1155 - </tr>
1156 - <tr valign="top">
1157 - <th scope="row"><?php esc_html_e( 'Hide Cookie Popup in WP Admin', 'cookiebot' ); ?></th>
1158 - <td>
1159 - <input type="checkbox" name="cookiebot-nooutput-admin" value="1" <?php checked( 1, get_site_option( 'cookiebot-nooutput-admin', false ), true ); ?> />
1160 - <p class="description">
1161 - <b><?php esc_html_e( 'Remove the cookie consent banner the WordPress Admin area for all subsites. This cannot be changed by subsites.', 'cookiebot' ); ?></b>
1162 - </p>
1163 - </td>
1164 - </tr>
1165 - </table>
1166 - <?php submit_button(); ?>
1167 - </form>
1168 - </div>
1169 - <?php
1170 - }
1171 -
1172 -
1173 - /**
1174 - * Cookiebot_WP Cookiebot save network settings
1175 - *
1176 - * @version 2.2.0
1177 - * @since 2.2.0
1178 - */
1179 - function network_settings_save() {
1180 - check_admin_referer( 'cookiebot-network-settings' );
1181 -
1182 - update_site_option( 'cookiebot-cbid', $_POST['cookiebot-cbid'] );
1183 - update_site_option( 'cookiebot-script-tag-uc-attribute', $_POST['cookiebot-script-tag-uc-attribute'] );
1184 - update_site_option( 'cookiebot-script-tag-cd-attribute', $_POST['cookiebot-script-tag-cd-attribute'] );
1185 - update_site_option( 'cookiebot-autoupdate', $_POST['cookiebot-autoupdate'] );
1186 - update_site_option( 'cookiebot-nooutput', $_POST['cookiebot-nooutput'] );
1187 - update_site_option( 'cookiebot-nooutput-admin', $_POST['cookiebot-nooutput-admin'] );
1188 - update_site_option( 'cookiebot-cookie-blocking-mode', $_POST['cookiebot-cookie-blocking-mode'] );
1189 -
1190 - wp_redirect(
1191 - add_query_arg(
1192 - array(
1193 - 'page' => 'cookiebot_network',
1194 - 'updated' => true,
1195 - ),
1196 - network_admin_url( 'admin.php' )
1197 - )
1198 - );
1199 - exit;
1200 - }
1201 -
1202 - /**
1203 - * Cookiebot_WP Cookiebot support page
1204 - *
1205 - * @version 2.2.0
1206 - * @since 2.0.0
1207 - */
1208 - function support_page() {
1209 - ?>
1210 - <div class="wrap">
1211 - <h1><?php esc_html_e( 'Support', 'cookiebot' ); ?></h1>
1212 - <h2><?php esc_html_e( 'How to find my Cookiebot ID', 'cookiebot' ); ?></h2>
1213 - <p>
1214 - <ol>
1215 - <li><?php esc_html_e( 'Log in to your <a href="https://www.cookiebot.com/goto/account" target="_blank">Cookiebot account</a>.', 'cookiebot' ); ?></li>
1216 - <li><?php esc_html_e( 'Go to <b>Manage</b> > <b>Settings</b> and add setup your Cookiebot', 'cookiebot' ); ?></li>
1217 - <li><?php esc_html_e( 'Go to the <b>"Your scripts"</b> tab', 'cookiebot' ); ?></li>
1218 - <li><?php esc_html_e( 'Copy the value inside the data-cid parameter - eg.: abcdef12-3456-7890-abcd-ef1234567890', 'cookiebot' ); ?></li>
1219 - <li><?php esc_html_e( 'Add <b>[cookie_declaration]</b> shortcode to a page to show the declation', 'cookiebot' ); ?></li>
1220 - <li><?php esc_html_e( 'Remember to change your scripts as descripted below', 'cookiebot' ); ?></li>
1221 - </ol>
1222 - </p>
1223 - <h2><?php esc_html_e( 'Add the Cookie Declaration to your website', 'cookiebot' ); ?></h2>
1224 - <p>
1225 - <?php esc_html_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' ); ?>
1226 - <br />
1227 - <?php esc_html_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' ); ?>
1228 - </p>
1229 - <p>
1230 - <a href="https://www.youtube.com/watch?v=OCXz2bt4H_w" target="_blank" class="button"><?php esc_html_e( 'Watch video demonstration', 'cookiebot' ); ?></a>
1231 - </p>
1232 - <h2><?php esc_html_e( 'Update your script tags', 'cookiebot' ); ?></h2>
1233 - <p>
1234 - <?php esc_html_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' ); ?>
1235 - </p>
1236 - <code>
1237 - <?php
1238 - echo htmlentities( '<script type="text/plain" data-cookieconsent="statistics">' ) . '<br />';
1239 - 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 />';
1240 - echo htmlentities( "ga('create', 'UA-00000000-0', 'auto');" ) . '<br />';
1241 - echo htmlentities( "ga('send', 'pageview');" ) . '<br />';
1242 - echo htmlentities( '</script>' ) . '<br />';
1243 - ?>
1244 - </code>
1245 - <p>
1246 - <a href="https://www.youtube.com/watch?v=MeHycvV2QCQ" target="_blank" class="button"><?php esc_html_e( 'Watch video demonstration', 'cookiebot' ); ?></a>
1247 - </p>
1248 -
1249 - <h2><?php esc_html_e( 'Helper function to update your scripts', 'cookiebot' ); ?></h2>
1250 - <p>
1251 - <?php esc_html_e( 'You are able to update your scripts yourself. However, Cookiebot also offers a small helper function that makes the work easier.', 'cookiebot' ); ?>
1252 - <br />
1253 - <?php esc_html_e( 'Update your script tags this way:', 'cookiebot' ); ?>
1254 - </p>
1255 - <?php
1256 - printf(
1257 - esc_html__( '%1$s to %2$s', 'cookiebot' ),
1258 - '<code>' . htmlentities( '<script type="text/javascript">' ) . '</code>',
1259 - '<code>' . htmlentities( '<script<?php echo cookiebot_assist(\'marketing\') ?>>' ) . '</code>'
1260 - );
1261 - ?>
1262 - </div>
1263 - <?php
1264 - }
1265 -
1266 - /**
1267 - * Cookiebot_WP Google Tag Manager page
1268 - *
1269 - * @version 3.8.1
1270 - * @since 3.8.1
1271 - */
1272 -
1273 - function GTM_page() {
1274 - ?>
1275 - <div class="wrap">
1276 - <h1><?php esc_html_e( 'Google Tag Manager', 'cookiebot' ); ?></h1>
1277 -
1278 - <form method="post" action="options.php" style="display: grid; grid-template-columns: 35% 65%; grid-row-gap: 20px; width: 700px; align-items: center;">
1279 - <?php settings_fields( 'cookiebot-gtm' ); ?>
1280 - <?php do_settings_sections( 'cookiebot-gtm' ); ?>
1281 -
1282 - <p><?php esc_html_e( 'Enable GTM', 'cookiebot' ); ?></p>
1283 - <div class="GTM_check">
1284 - <input type="checkbox" name="cookiebot-gtm" id="cookiebot-gtm" value="1" <?php checked( 1, get_option( 'cookiebot-gtm' ), true ); ?> style="float: left; margin: 2px 4px 0 0">
1285 - <p style="margin: 0; font-style: italic;"><?php esc_html_e( 'For more details about Cookiebot and Google Tag Manager click', 'cookiebot' ); ?><a target="_blank" href="https://www.cookiebot.com/en/google-tag-manager-and-gdpr-compliance-with-cookiebot/" style="margin: 0; font-style: italic;">&nbsp;<?php esc_html_e( 'here', 'cookiebot' ); ?></a></p>
1286 - </div>
1287 -
1288 - <p><?php esc_html_e( 'GTM ID', 'cookiebot' ); ?></p>
1289 - <input type="text" name="cookiebot-gtm-id" id="cookiebot-gtm-id" value="<?php echo get_option( 'cookiebot-gtm-id' ); ?>" style="height: 30px;">
1290 -
1291 - <p><?php esc_html_e( 'DataLayer name', 'cookiebot' ); ?></p>
1292 - <div>
1293 - <input type="text" name="cookiebot-data-layer" id="data_layer" placeholder="dataLayer" value="<?php echo get_option( 'cookiebot-data-layer' ); ?>" style="height: 30px;">
1294 - <p style="margin: 0;"><?php esc_html_e( 'Optional, only change if necessary', 'cookiebot' ); ?></p>
1295 - </div>
1296 -
1297 - <p><?php esc_html_e( 'Google Consent Mode', 'cookiebot' ); ?></p>
1298 - <div class="GTM_check">
1299 - <input type="checkbox" name="cookiebot-gcm" id="gcm" value="1" <?php checked( 1, get_option( 'cookiebot-gcm' ), true ); ?> style="float: left; margin: 2px 4px 0 0">
1300 - <p style="margin: 0; font-style: italic;"><?php esc_html_e( 'For more details about Cookiebot and Google Consent Mode click', 'cookiebot' ); ?><a target="_blank" href="https://support.cookiebot.com/hc/en-us/articles/360016047000-Cookiebot-and-Google-Consent-Mode" style="margin: 0; font-style: italic;">&nbsp;<?php esc_html_e( 'here', 'cookiebot' ); ?></a></p>
1301 - </div>
1302 - <input type="submit" value="Save" name="gtm_save" style="background-color: rgb(0, 124, 186); color: white; padding: 5px 10px; border: none; border-radius: 5px; justify-self: start;">
1303 - </form>
1304 - </div>
1305 - <?php
1306 - }
1307 -
1308 - /**
1309 - * Cookiebot_WP Cookiebot IAB page
1310 - *
1311 - * @version 2.0.0
1312 - * @since 2.0.0
1313 - */
1314 - function iab_page() {
1315 - ?>
1316 - <div class="wrap">
1317 - <h1><?php esc_html_e( 'IAB', 'cookiebot' ); ?></h1>
1318 -
1319 - <p>
1320 - <?php echo sprintf(
1321 - esc_html__( 'For more details about Cookiebot\'s IAB integration, see %sarticle about cookiebot and the IAB consent framework%s', 'cookiebot' ),
1322 - '<a href="https://support.cookiebot.com/hc/en-us/articles/360007652694-Cookiebot-and-the-IAB-Consent-Framework" target="_blank">',
1323 - '</a>'
1324 - ); ?>
1325 - </p>
1326 -
1327 - <form method="post" action="options.php">
1328 - <?php settings_fields( 'cookiebot-iab' ); ?>
1329 - <?php do_settings_sections( 'cookiebot-iab' ); ?>
1330 -
1331 - <label><?php esc_html_e( 'Enable IAB integration', 'cookiebot' ); ?></label>
1332 - <input type="checkbox" name="cookiebot-iab" value="1" <?php checked( 1, get_option( 'cookiebot-iab' ), true ); ?>>
1333 -
1334 - <?php submit_button(); ?>
1335 - </form>
1336 - </div>
1337 - <?php
1338 - }
1339 -
1340 - /**
1341 - * Cookiebot_WP Cookiebot legislations page
1342 - *
1343 - * @version 3.6.6
1344 - * @since 3.6.6
1345 - */
1346 - function legislations_page() {
1347 - ?>
1348 - <div class="wrap">
1349 - <h1><?php esc_html_e( 'Legislations', 'cookiebot' ); ?></h1>
1350 -
1351 - <p>
1352 - <?php echo sprintf(
1353 - esc_html__( 'For more details about Cookiebot\'s CCPA Legislation integration, see %sarticle about cookiebot and the CCPA compliance%s', 'cookiebot' ),
1354 - '<a href="https://support.cookiebot.com/hc/en-us/articles/360010932419-Use-multiple-banners-on-the-same-website-support-both-CCPA-GDPR-compliance-" target="_blank">',
1355 - '</a>'
1356 - ); ?>
1357 - </p>
1358 -
1359 - <form method="post" action="options.php">
1360 - <?php settings_fields( 'cookiebot-legislations' ); ?>
1361 - <?php do_settings_sections( 'cookiebot-legislations' ); ?>
1362 -
1363 -
1364 - <table class="form-table">
1365 - <tbody>
1366 - <tr valign="top">
1367 - <th scope="row"><label><?php esc_html_e( 'Enable CCPA configuration for visitors from California', 'cookiebot' ); ?></label></th>
1368 - <td>
1369 - <input type="checkbox" name="cookiebot-ccpa" value="1" <?php checked( 1, get_option( 'cookiebot-ccpa' ), true ); ?>>
1370 - </td>
1371 - </tr>
1372 - <tr>
1373 - <th valign="top"><label><?php esc_html_e('Domain Group ID', 'cookiebot'); ?></label></th>
1374 - <td>
1375 - <input type="text" style="width: 300px;" name="cookiebot-ccpa-domain-group-id" value="<?php echo get_option( 'cookiebot-ccpa-domain-group-id' ); ?>">
1376 - </td>
1377 - </tr>
1378 - </tbody>
1379 - </table>
1380 -
1381 - <?php submit_button(); ?>
1382 - </form>
1383 - </div>
1384 - <?php
1385 - }
1386 -
1387 - /**
1388 - * Cookiebot_WP Debug Page
1389 - *
1390 - * @version 3.9.
1391 - * @since 3.6.0
1392 - */
1393 -
1394 - function debug_page() {
1395 - global $wpdb;
1396 -
1397 - include_once ABSPATH . 'wp-admin/includes/plugin.php';
1398 - $plugins = get_plugins();
1399 - $active_plugins = get_option( 'active_plugins' );
1400 -
1401 - //$foo = new cookiebot_addons\lib\Settings_Service;
1402 - //$addons = $foo->get_active_addons();
1403 -
1404 - $debugStr = '';
1405 - $debugStr .= '##### Debug Information for ' . get_site_url() . ' generated at ' . date( 'c' ) . " #####\n\n";
1406 - $debugStr .= 'WordPress Version: ' . get_bloginfo( 'version' ) . "\n";
1407 - $debugStr .= 'WordPress Language: ' . get_bloginfo( 'language' ) . "\n";
1408 - $debugStr .= 'PHP Version: ' . phpversion() . "\n";
1409 - $debugStr .= 'MySQL Version: ' . $wpdb->db_version() . "\n";
1410 - $debugStr .= "\n--- Cookiebot Information ---\n";
1411 - $debugStr .= 'Plugin Version: ' . $this->version . "\n";
1412 - $debugStr .= 'Cookiebot ID: ' . $this->get_cbid() . "\n";
1413 - $debugStr .= 'Blocking mode: ' . get_option( 'cookiebot-cookie-blocking-mode' ) . "\n";
1414 - $debugStr .= 'Language: ' . get_option( 'cookiebot-language' ) . "\n";
1415 - $debugStr .= 'IAB: ' . ( get_option( 'cookiebot-iab' ) == '1' ? 'Enabled' : 'Not enabled' ) . "\n";
1416 - $debugStr .= 'CCPA banner for visitors from California: ' . ( get_option( 'cookiebot-ccpa' ) == '1' ? 'Enabled' : 'Not enabled' ) . "\n";
1417 - $debugStr .= 'CCPA domain group id: ' . get_option( 'cookiebot-ccpa-domain-group-id' ) . "\n";
1418 - $debugStr .= 'Add async/defer to banner tag: ' . ( get_option( 'cookiebot-script-tag-uc-attribute' ) != '' ? get_option( 'cookiebot-script-tag-uc-attribute' ) : 'None' ) . "\n";
1419 - $debugStr .= 'Add async/defer to declaration tag: ' . ( get_option( 'cookiebot-script-tag-cd-attribute' ) != '' ? get_option( 'cookiebot-script-tag-cd-attribute' ) : 'None' ) . "\n";
1420 - $debugStr .= 'Auto update: ' . ( get_option( 'cookiebot-autoupdate' ) == '1' ? 'Enabled' : 'Not enabled' ) . "\n";
1421 - $debugStr .= 'Hide Cookie Popup: ' . ( get_option( 'cookiebot-nooutput' ) == '1' ? 'Yes' : 'No' ) . "\n";
1422 - $debugStr .= 'Disable Cookiebot in WP Admin: ' . ( get_option( 'cookiebot-nooutput-admin' ) == '1' ? 'Yes' : 'No' ) . "\n";
1423 - $debugStr .= 'Enable Cookiebot on front end while logged in: ' . ( get_option( 'cookiebot-output-logged-in' ) == '1' ? 'Yes' : 'No' ) . "\n";
1424 - $debugStr .= 'Banner tag: ' . $this->add_js( false ) . "\n";
1425 - $debugStr .= 'Declaration tag: ' . $this->show_declaration() . "\n";
1426 -
1427 - if ( get_option( 'cookiebot-gtm' ) != false ) {
1428 - $debugStr .= 'GTM tag: ' . $this->add_GTM( false ) . "\n";
1429 - }
1430 -
1431 - if ( get_option( 'cookiebot-gcm' ) != false ) {
1432 - $debugStr .= 'GCM tag: ' . $this->add_GCM( false ) . "\n";
1433 - }
1434 -
1435 - if ( $this->is_wp_consent_api_active() ) {
1436 - $debugStr .= "\n--- WP Consent Level API Mapping ---\n";
1437 - $debugStr .= 'F = Functional, N = Necessary, P = Preferences, M = Marketing, S = Statistics, SA = Statistics Anonymous' . "\n";
1438 - $m = $this->get_wp_consent_api_mapping();
1439 - foreach ( $m as $k => $v ) {
1440 - $cb = array();
1441 -
1442 - $debugStr .= strtoupper( str_replace( ';', ', ', $k ) ) . ' => ';
1443 -
1444 - $debugStr .= 'F=1, ';
1445 - $debugStr .= 'P=' . $v['preferences'] . ', ';
1446 - $debugStr .= 'M=' . $v['marketing'] . ', ';
1447 - $debugStr .= 'S=' . $v['statistics'] . ', ';
1448 - $debugStr .= 'SA=' . $v['statistics-anonymous'] . "\n";
1449 -
1450 - }
1451 - }
1452 -
1453 - if ( class_exists( 'cookiebot_addons\Cookiebot_Addons' ) ) {
1454 - $ca = new cookiebot_addons\Cookiebot_Addons();
1455 - $settingservice = $ca->container->get( 'Settings_Service_Interface' );
1456 - $addons = $settingservice->get_active_addons();
1457 - $debugStr .= "\n--- Activated Cookiebot Addons ---\n";
1458 - foreach ( $addons as $addon ) {
1459 - $debugStr .= $addon->get_addon_name() . ' (' . implode( ', ', $addon->get_cookie_types() ) . ")\n";
1460 - }
1461 - }
1462 -
1463 - $debugStr .= "\n--- Activated Plugins ---\n";
1464 - foreach ( $active_plugins as $p ) {
1465 - if ( $p != 'cookiebot/cookiebot.php' ) {
1466 - $debugStr .= $plugins[ $p ]['Name'] . ' (Version: ' . $plugins[ $p ]['Version'] . ")\n";
1467 - }
1468 - }
1469 -
1470 - $debugStr .= "\n##### Debug Information END #####";
1471 -
1472 - ?>
1473 - <div class="wrap">
1474 - <h1><?php esc_html_e( 'Debug information', 'cookiebot' ); ?></h1>
1475 - <p><?php esc_html_e( 'The information below is for debugging purpose. If you have any issues with your Cookiebot integration, the information below is usefull for a supporter to help you the best way.', 'cookiebot' ); ?></p>
1476 - <p><button class="button button-primary" onclick="copyDebugInfo();"><?php esc_html_e( 'Copy debug information to clipboard', 'cookiebot' ); ?></button></p>
1477 - <textarea cols="100" rows="40" style="width:800px;max-width:100%;" id="cookiebot-debug-info" readonly><?php echo $debugStr; ?></textarea>
1478 - <script>
1479 - function copyDebugInfo() {
1480 - var t = document.getElementById("cookiebot-debug-info");
1481 - t.select();
1482 - t.setSelectionRange(0, 99999);
1483 - document.execCommand("copy");
1484 - }
1485 - </script>
1486 - </div>
1487 - <?php
1488 - }
1489 -
1490 - /**
1491 - * Cookiebot_WP Add Cookiebot JS to <head>
1492 - *
1493 - * @version 3.9.0
1494 - * @since 1.0.0
1495 - */
1496 - function add_js( $printTag = true ) {
1497 - $cbid = $this->get_cbid();
1498 - if ( ! empty( $cbid ) && ! defined( 'COOKIEBOT_DISABLE_ON_PAGE' ) ) {
1499 - if ( is_multisite() && get_site_option( 'cookiebot-nooutput', false ) ) {
1500 - return; //Is multisite - and disabled output is checked as network setting
1501 - }
1502 -
1503 - if ( get_option( 'cookiebot-nooutput', false ) ) {
1504 - return; //Do not show JS - output disabled
1505 - }
1506 -
1507 - if ( $this->get_cookie_blocking_mode() == 'auto' && $this->can_current_user_edit_theme() && $printTag !== false && get_site_option( 'cookiebot-output-logged-in' ) == false ) {
1508 - return;
1509 - }
1510 -
1511 - $lang = $this->get_language();
1512 - if ( ! empty( $lang ) ) {
1513 - $lang = ' data-culture="' . strtoupper( $lang ) . '"'; //Use data-culture to define language
1514 - }
1515 -
1516 - if ( ! is_multisite() || get_site_option( 'cookiebot-script-tag-uc-attribute', 'custom' ) == 'custom' ) {
1517 - $tagAttr = get_option( 'cookiebot-script-tag-uc-attribute', 'async' );
1518 - } else {
1519 - $tagAttr = get_site_option( 'cookiebot-script-tag-uc-attribute' );
1520 - }
1521 -
1522 - if ( $this->get_cookie_blocking_mode() == 'auto' ) {
1523 - $tagAttr = 'data-blockingmode="auto"';
1524 - }
1525 -
1526 - if ( get_option( 'cookiebot-gtm' ) != false ) {
1527 - if ( empty( get_option( 'cookiebot-data-layer' ) ) ) {
1528 - $data_layer = 'data-layer-name="dataLayer"';
1529 - } else {
1530 - $data_layer = 'data-layer-name="' . get_option( 'cookiebot-data-layer' ) . '"';
1531 - }
1532 - } else {
1533 - $data_layer = '';
1534 - }
1535 -
1536 - $iab = ( get_option( 'cookiebot-iab' ) != false ) ? 'data-framework="IAB"' : '';
1537 -
1538 - $ccpa = ( get_option( 'cookiebot-ccpa' ) != false ) ? 'data-georegions="{\'region\':\'US-06\',\'cbid\':\'' . get_option( 'cookiebot-ccpa-domain-group-id' ) . '\'}"' : '';
1539 -
1540 - $tag = '<script id="Cookiebot" src="https://consent.cookiebot.com/uc.js" ' . $iab . ' ' . $ccpa . ' ' . $data_layer . ' data-cbid="' . $cbid . '"' . $lang . ' type="text/javascript" ' . $tagAttr . '></script>';
1541 - if ( $printTag === false ) {
1542 - return $tag;
1543 - }
1544 - echo $tag;
1545 - }
1546 - }
1547 -
1548 - /**
1549 - * Cookiebot_WP Add Google Tag Manager JS to <head>
1550 - *
1551 - * @version 3.8.1
1552 - * @since 3.8.1
1553 - */
1554 -
1555 - function add_GTM( $printTag = true ) {
1556 -
1557 - if ( get_option( 'cookiebot-gtm' ) != false ) {
1558 -
1559 - if ( empty( get_option( 'cookiebot-data-layer' ) ) ) {
1560 - $data_layer = 'dataLayer';
1561 - } else {
1562 - $data_layer = get_option( 'cookiebot-data-layer' );
1563 - }
1564 -
1565 - $GTM = '<script>';
1566 - if ( get_option( 'cookiebot-iab' ) ) {
1567 - $GTM .= 'window ["gtag_enable_tcf_support"] = true;';
1568 - }
1569 -
1570 - $GTM .= "(function (w, d, s, l, i) {
1571 - w[l] = w[l] || []; w[l].push({'gtm.start':new Date().getTime(), event: 'gtm.js'});
1572 - var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : '';
1573 - j.async = true; j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
1574 - f.parentNode.insertBefore(j, f);})
1575 - (window, document, 'script', '" . $data_layer . "', '" . get_option( 'cookiebot-gtm-id' ) . "');";
1576 -
1577 - $GTM .= '</script>';
1578 -
1579 - if ( $printTag === false ) {
1580 - return $GTM;
1581 - }
1582 -
1583 - echo $GTM;
1584 - }
1585 - }
1586 -
1587 - /**
1588 - * Cookiebot_WP Add Google Consent Mode JS to <head>
1589 - *
1590 - * @version 3.8.1
1591 - * @since 3.8.1
1592 - */
1593 -
1594 - function add_GCM( $printTag = true ) {
1595 -
1596 - if ( get_option( 'cookiebot-gcm' ) != false ) {
1597 -
1598 - if ( empty( get_option( 'cookiebot-data-layer' ) ) ) {
1599 - $data_layer = 'dataLayer';
1600 - } else {
1601 - $data_layer = get_option( 'cookiebot-data-layer' );
1602 - }
1603 -
1604 - $GCM = '<script data-cookieconsent="ignore">
1605 - (function(w,d,l){w[l]=w[l]||[];function gtag(){w[l].push(arguments)};
1606 - gtag("consent","default",{ad_storage:d,analytics_storage:d,wait_for_update:500,});
1607 - gtag("set", "ads_data_redaction", true);})(window,"denied","' . $data_layer . '");';
1608 -
1609 - $GCM .= '</script>';
1610 -
1611 - if ( $printTag === false ) {
1612 - return $GCM;
1613 - }
1614 -
1615 - echo $GCM;
1616 - }
1617 - }
1618 -
1619 - /**
1620 - * Returns true if an user is logged in and has an edit_themes capability
1621 - *
1622 - * @return bool
1623 - *
1624 - * @since 3.3.1
1625 - * @version 3.4.1
1626 - */
1627 - function can_current_user_edit_theme() {
1628 - if ( is_user_logged_in() ) {
1629 - if ( current_user_can( 'edit_themes' ) ) {
1630 - return true;
1631 - }
1632 -
1633 - if ( current_user_can( 'edit_pages' ) ) {
1634 - return true;
1635 - }
1636 -
1637 - if ( current_user_can( 'edit_posts' ) ) {
1638 - return true;
1639 - }
1640 - }
1641 -
1642 - return false;
1643 - }
1644 -
1645 - /**
1646 - * Cookiebot_WP Output declation shortcode [cookie_declaration]
1647 - * Support attribute lang="LANGUAGE_CODE". Eg. lang="en".
1648 - *
1649 - * @version 2.2.0
1650 - * @since 1.0.0
1651 - */
1652 - function show_declaration( $atts = array() ) {
1653 - $cbid = $this->get_cbid();
1654 - $lang = '';
1655 - if ( ! empty( $cbid ) ) {
1656 -
1657 - $atts = shortcode_atts(
1658 - array(
1659 - 'lang' => $this->get_language(),
1660 - ),
1661 - $atts,
1662 - 'cookie_declaration'
1663 - );
1664 -
1665 - if ( ! empty( $atts['lang'] ) ) {
1666 - $lang = ' data-culture="' . strtoupper( $atts['lang'] ) . '"'; //Use data-culture to define language
1667 - }
1668 -
1669 - if ( ! is_multisite() || get_site_option( 'cookiebot-script-tag-cd-attribute', 'custom' ) == 'custom' ) {
1670 - $tagAttr = get_option( 'cookiebot-script-tag-cd-attribute', 'async' );
1671 - } else {
1672 - $tagAttr = get_site_option( 'cookiebot-script-tag-cd-attribute' );
1673 - }
1674 -
1675 - return '<script id="CookieDeclaration" src="https://consent.cookiebot.com/' . $cbid . '/cd.js"' . $lang . ' type="text/javascript" ' . $tagAttr . '></script>';
1676 - } else {
1677 - return esc_html__( 'Please add your Cookiebot ID to show Cookie Declarations', 'cookiebot' );
1678 - }
1679 - }
1680 -
1681 - /**
1682 - * Cookiebot_WP Get cookiebot cbid
1683 - *
1684 - * @version 2.2.0
1685 - * @since 1.0.0
1686 - */
1687 - public static function get_cbid() {
1688 - $cbid = get_option( 'cookiebot-cbid' );
1689 - if ( is_multisite() && ( $network_cbid = get_site_option( 'cookiebot-cbid' ) ) ) {
1690 - if ( empty( $cbid ) ) {
1691 - return $network_cbid;
1692 - }
1693 - }
1694 - return $cbid;
1695 - }
1696 -
1697 - /**
1698 - * Cookiebot_WP Get cookie blocking mode (auto | manual)
1699 - *
1700 - * @version 2.2.0
1701 - * @since 1.0.0
1702 - */
1703 - public static function get_cookie_blocking_mode() {
1704 - $cbm = get_option( 'cookiebot-cookie-blocking-mode' );
1705 - if ( is_multisite() && ( $network_cbm = get_site_option( 'cookiebot-cookie-blocking-mode' ) ) ) {
1706 - if ( empty( $cbm ) ) {
1707 - return $network_cbm;
1708 - }
1709 - }
1710 - if ( empty( $cbm ) ) {
1711 - $cbm = 'manual'; }
1712 - return $cbm;
1713 - }
1714 -
1715 -
1716 - /**
1717 - * Cookiebot_WP Check if Cookiebot is active in admin
1718 - *
1719 - * @version 3.1.0
1720 - * @since 3.1.0
1721 - */
1722 - public static function cookiebot_disabled_in_admin() {
1723 - if ( is_multisite() && get_site_option( 'cookiebot-nooutput-admin', false ) ) {
1724 - return true;
1725 - } elseif ( get_option( 'cookiebot-nooutput-admin', false ) ) {
1726 - return true;
1727 - }
1728 - return false;
1729 - }
1730 -
1731 - /**
1732 - * Cookiebot_WP Get the language code for Cookiebot
1733 - *
1734 - * @version 1.4.0
1735 - * @since 1.4.0
1736 - */
1737 - function get_language( $onlyFromSetting = false ) {
1738 - // Get language set in setting page - if empty use WP language info
1739 - $lang = get_option( 'cookiebot-language' );
1740 - if ( ! empty( $lang ) ) {
1741 - if ( $lang != '_wp' ) {
1742 - return $lang;
1743 - }
1744 - }
1745 -
1746 - if ( $onlyFromSetting ) {
1747 - return $lang; //We want only to get if already set
1748 - }
1749 -
1750 - //Language not set - use WP language
1751 - if ( $lang == '_wp' ) {
1752 - $lang = get_bloginfo( 'language' ); //Gets language in en-US format
1753 - if ( ! empty( $lang ) ) {
1754 - list($lang) = explode( '-', $lang ); //Changes format from eg. en-US to en.
1755 - }
1756 - }
1757 - return $lang;
1758 - }
1759 -
1760 - /**
1761 - * Cookiebot_WP Adding Cookiebot domain(s) to exclude list for WP Rocket minification.
1762 - *
1763 - * @version 1.6.1
1764 - * @since 1.6.1
1765 - */
1766 - function wp_rocket_exclude_external_js( $external_js_hosts ) {
1767 - $external_js_hosts[] = 'consent.cookiebot.com'; // Add cookiebot domains
1768 - $external_js_hosts[] = 'consentcdn.cookiebot.com';
1769 - return $external_js_hosts;
1770 - }
1771 -
1772 - /**
1773 - * Cookiebot_WP Adding Cookiebot domain(s) to exclude list for SGO minification.
1774 - *
1775 - * @version 3.6.5
1776 - * @since 3.6.5
1777 - */
1778 - function sgo_exclude_external_js( $exclude_list ) {
1779 - //Uses same format as WP Rocket - for now we just use WP Rocket function
1780 - return wp_rocket_exclude_external_js( $exclude_list );
1781 - }
1782 -
1783 -
1784 - /**
1785 - * Cookiebot_WP Check if WP Cookie Consent API is active
1786 - *
1787 - * @version 3.5.0
1788 - * @since 3.5.0
1789 - */
1790 - public function is_wp_consent_api_active() {
1791 - if ( class_exists( 'WP_CONSENT_API' ) ) {
1792 - return true;
1793 - }
1794 - return false;
1795 - }
1796 -
1797 - /**
1798 - * Cookiebot_WP Default consent level mappings
1799 - *
1800 - * @version 3.5.0
1801 - * @since 3.5.0
1802 - */
1803 - public function get_default_wp_consent_api_mapping() {
1804 - return array(
1805 - 'n=1;p=1;s=1;m=1' =>
1806 - array(
1807 - 'preferences' => 1,
1808 - 'statistics' => 1,
1809 - 'statistics-anonymous' => 0,
1810 - 'marketing' => 1,
1811 - ),
1812 - 'n=1;p=1;s=1;m=0' =>
1813 - array(
1814 - 'preferences' => 1,
1815 - 'statistics' => 1,
1816 - 'statistics-anonymous' => 1,
1817 - 'marketing' => 0,
1818 - ),
1819 - 'n=1;p=1;s=0;m=1' =>
1820 - array(
1821 - 'preferences' => 1,
1822 - 'statistics' => 0,
1823 - 'statistics-anonymous' => 0,
1824 - 'marketing' => 1,
1825 - ),
1826 - 'n=1;p=1;s=0;m=0' =>
1827 - array(
1828 - 'preferences' => 1,
1829 - 'statistics' => 0,
1830 - 'statistics-anonymous' => 0,
1831 - 'marketing' => 0,
1832 - ),
1833 - 'n=1;p=0;s=1;m=1' =>
1834 - array(
1835 - 'preferences' => 0,
1836 - 'statistics' => 1,
1837 - 'statistics-anonymous' => 0,
1838 - 'marketing' => 1,
1839 - ),
1840 - 'n=1;p=0;s=1;m=0' =>
1841 - array(
1842 - 'preferences' => 0,
1843 - 'statistics' => 1,
1844 - 'statistics-anonymous' => 0,
1845 - 'marketing' => 0,
1846 - ),
1847 - 'n=1;p=0;s=0;m=1' =>
1848 - array(
1849 - 'preferences' => 0,
1850 - 'statistics' => 0,
1851 - 'statistics-anonymous' => 0,
1852 - 'marketing' => 1,
1853 - ),
1854 - 'n=1;p=0;s=0;m=0' =>
1855 - array(
1856 - 'preferences' => 0,
1857 - 'statistics' => 0,
1858 - 'statistics-anonymous' => 0,
1859 - 'marketing' => 0,
1860 - ),
1861 - );
1862 -
1863 - }
1864 -
1865 - /**
1866 - * Cookiebot_WP Get the mapping between Consent Level API and Cookiebot
1867 - * Returns array where key is the consent level api category and value
1868 - * is the mapped Cookiebot category.
1869 - *
1870 - * @version 3.5.0
1871 - * @since 3.5.0
1872 - */
1873 - public function get_wp_consent_api_mapping() {
1874 - $mDefault = $this->get_default_wp_consent_api_mapping();
1875 - $mapping = get_option( 'cookiebot-consent-mapping', $mDefault );
1876 -
1877 - $mapping = ( '' === $mapping ) ? $mDefault : $mapping;
1878 -
1879 - foreach ( $mDefault as $k => $v ) {
1880 - if ( ! isset( $mapping[ $k ] ) ) {
1881 - $mapping[ $k ] = $v;
1882 - } else {
1883 - foreach ( $v as $vck => $vcv ) {
1884 - if ( ! isset( $mapping[ $k ][ $vck ] ) ) {
1885 - $mapping[ $k ][ $vck ] = $vcv;
1886 - }
1887 - }
1888 - }
1889 - }
1890 - return $mapping;
1891 - }
1892 -
1893 - /**
1894 - * Cookiebot_WP Enqueue JS for integration with WP Consent Level API
1895 - *
1896 - * @version 3.5.0
1897 - * @since 3.5.0
1898 - */
1899 - function cookiebot_enqueue_consent_api_scripts() {
1900 - wp_register_script( 'cookiebot-wp-consent-level-api-integration', plugins_url( 'cookiebot/js/cookiebot-wp-consent-level-api-integration.js', 'cookiebot' ) );
1901 - wp_enqueue_script( 'cookiebot-wp-consent-level-api-integration' );
1902 - wp_localize_script( 'cookiebot-wp-consent-level-api-integration', 'cookiebot_category_mapping', $this->get_wp_consent_api_mapping() );
1903 - }
1904 -
1905 -
1906 - /**
1907 - * Display admin notice for recommending cookiebot
1908 - *
1909 - * @version 2.0.5
1910 - * @since 2.0.5
1911 - */
1912 - function cookiebot_admin_notices() {
1913 - if ( ! $this->cookiebot_valid_admin_recommendation() ) {
1914 - return false;
1915 - }
1916 - $two_week_review_ignore = add_query_arg( array( 'cookiebot_admin_notice' => 'hide' ) );
1917 - $two_week_review_temp = add_query_arg( array( 'cookiebot_admin_notice' => 'two_week' ) );
1918 -
1919 - $notices = array(
1920 - 'title' => esc_html__( 'Leave A Review?', 'cookiebot' ),
1921 - 'msg' => esc_html__( 'We hope you enjoy using WordPress Cookiebot! Would you consider leaving us a review on WordPress.org?', 'cookiebot' ),
1922 - '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">' . esc_html__( 'Sure! I\'d love to!', 'cookiebot' ) . '</a></li>
1923 - <li><span class="dashicons dashicons-smiley"></span><a href="' . $two_week_review_ignore . '"> ' . esc_html__( 'I\'ve already left a review', 'cookiebot' ) . '</a></li>
1924 - <li><span class="dashicons dashicons-calendar-alt"></span><a href="' . $two_week_review_temp . '">' . esc_html__( 'Maybe Later', 'cookiebot' ) . '</a></li>
1925 - <li><span class="dashicons dashicons-dismiss"></span><a href="' . $two_week_review_ignore . '">' . esc_html__( 'Never show again', 'cookiebot' ) . '</a></li>',
1926 - 'later_link' => $two_week_review_temp,
1927 - 'int' => 14,
1928 - );
1929 -
1930 - echo '<div class="update-nag cookiebot-admin-notice">
1931 - <div class="cookiebot-notice-logo"></div>
1932 - <p class="cookiebot-notice-title">' . $notices['title'] . '</p>
1933 - <p class="cookiebot-notice-body">' . $notices['msg'] . '</p>
1934 - <ul class="cookiebot-notice-body wd-blue">' . $notices['link'] . '</ul>
1935 - <a href="' . $notices['later_link'] . '" class="dashicons dashicons-dismiss"></a>
1936 - </div>';
1937 -
1938 - wp_enqueue_style( 'cookiebot-admin-notices', plugins_url( 'css/notice.css', __FILE__ ), array(), '2.0.4' );
1939 - }
1940 -
1941 -
1942 - /**
1943 - * Validate if the last user action is valid for plugin recommendation
1944 - *
1945 - * @return bool
1946 - *
1947 - * @version 2.0.5
1948 - * @since 2.0.5
1949 - */
1950 - function cookiebot_valid_admin_recommendation() {
1951 - //Default - the recommendation is allowed to be visible
1952 - $return = true;
1953 -
1954 - $option = get_option( 'cookiebot_notice_recommend' );
1955 -
1956 - if ( $option != false ) {
1957 - //Never show again is clicked
1958 - if ( $option == 'hide' ) {
1959 - $return = false;
1960 - } elseif ( is_numeric( $option ) && strtotime( 'now' ) < $option ) {
1961 - //Show me after 2 weeks is clicked and the time is not valid yet
1962 - $return = false;
1963 - }
1964 - }
1965 - return $return;
1966 - }
1967 -
1968 - /**
1969 - * Save the user action on cookiebot recommendation link
1970 - *
1971 - * @version 2.0.5
1972 - * @since 2.0.5
1973 - */
1974 - function save_notice_link() {
1975 - if ( isset( $_GET['cookiebot_admin_notice'] ) ) {
1976 - if ( $_GET['cookiebot_admin_notice'] == 'hide' ) {
1977 - update_option( 'cookiebot_notice_recommend', 'hide' );
1978 - } else {
1979 - update_option( 'cookiebot_notice_recommend', strtotime( '+2 weeks' ) );
1980 - }
1981 - }
1982 - }
1983 -
1984 -
1985 -
1986 -
1987 - /**
1988 - * Cookiebot_WP Fix plugin conflicts related to Cookiebot
1989 - *
1990 - * @version 3.2.0
1991 - * @since 3.3.0
1992 - */
1993 - function cookiebot_fix_plugin_conflicts() {
1994 - //Fix for Divi Page Builder
1995 - //Disabled - using another method now (can_current_user_edit_theme())
1996 - //add_action( 'wp', array( $this, '_cookiebot_plugin_conflict_divi' ), 100 );
1997 -
1998 - //Fix for Elementor and WPBakery Page Builder Builder
1999 - //Disabled - using another method now (can_current_user_edit_theme())
2000 - //add_filter( 'script_loader_tag', array( $this, '_cookiebot_plugin_conflict_scripttags' ), 10, 2 );
2001 - }
2002 -
2003 - /**
2004 - * Cookiebot_WP Fix Divi builder conflict when blocking mode is in auto.
2005 - *
2006 - * @version 3.2.0
2007 - * @since 3.2.0
2008 - */
2009 - function _cookiebot_plugin_conflict_divi() {
2010 - if ( defined( 'ET_FB_ENABLED' ) ) {
2011 - if ( ET_FB_ENABLED &&
2012 - $this->cookiebot_disabled_in_admin() &&
2013 - $this->get_cookie_blocking_mode() == 'auto' ) {
2014 -
2015 - define( 'COOKIEBOT_DISABLE_ON_PAGE', true ); //Disable Cookiebot on the current page
2016 -
2017 - }
2018 - }
2019 - }
2020 -
2021 - /**
2022 - * Cookiebot_WP Fix plugin conflicts with page builders - whitelist JS files in automode
2023 - *
2024 - * @version 3.2.0
2025 - * @since 3.3.0
2026 - */
2027 - function _cookiebot_plugin_conflict_scripttags( $tag, $handle ) {
2028 -
2029 - //Check if Elementor Page Builder active
2030 - if ( defined( 'ELEMENTOR_VERSION' ) ) {
2031 - if ( in_array(
2032 - $handle,
2033 - array(
2034 - 'jquery-core',
2035 - 'elementor-frontend-modules',
2036 - 'elementor-frontend',
2037 - 'wp-tinymce',
2038 - 'underscore',
2039 - 'backbone',
2040 - 'backbone-marionette',
2041 - 'backbone-radio',
2042 - 'elementor-common-modules',
2043 - 'elementor-dialog',
2044 - 'elementor-common',
2045 - )
2046 - ) ) {
2047 - $tag = str_replace( '<script ', '<script data-cookieconsent="ignore" ', $tag );
2048 - }
2049 - }
2050 -
2051 - //Check if WPBakery Page Builder active
2052 - if ( defined( 'WPB_VC_VERSION' ) ) {
2053 - if ( in_array(
2054 - $handle,
2055 - array(
2056 - 'jquery-core',
2057 - 'jquery-ui-core',
2058 - 'jquery-ui-sortable',
2059 - 'jquery-ui-mouse',
2060 - 'jquery-ui-widget',
2061 - 'vc_editors-templates-preview-js',
2062 - 'vc-frontend-editor-min-js',
2063 - 'vc_inline_iframe_js',
2064 - 'wpb_composer_front_js',
2065 - )
2066 - ) ) {
2067 - $tag = str_replace( '<script ', '<script data-cookieconsent="ignore" ', $tag );
2068 - }
2069 - }
2070 -
2071 - return $tag;
2072 - }
2073 -
2074 - }
2075 -endif;
2076 -
2077 -
2078 -/**
2079 - * Helper function to manipulate script tags
2080 - *
2081 - * @version 1.6
2082 - * @since 1.0
2083 - * @return string
2084 - */
2085 -function cookiebot_assist( $type = 'statistics' ) {
2086 - //change to array
2087 - if ( ! is_array( $type ) ) {
2088 - $type = array( $type ); }
2089 -
2090 - foreach ( $type as $tk => $tv ) {
2091 - if ( ! in_array( $tv, array( 'marketing', 'statistics', 'preferences' ) ) ) {
2092 - unset( $type[ $tk ] );
2093 - }
2094 - }
2095 - if ( sizeof( $type ) > 0 ) {
2096 - return ' type="text/plain" data-cookieconsent="' . implode( ',', $type ) . '"';
2097 - }
2098 - return '';
25 +try {
26 + \cybot\cookiebot\lib\cookiebot();
27 +} catch ( RuntimeException $exception ) {
28 + require_once ABSPATH . 'wp-admin/includes/plugin.php';
29 + deactivate_plugins( plugin_basename( __FILE__ ) );
30 + wp_die( esc_html( $exception->getMessage() ) );
2099 31 }
2100 -
2101 -
2102 -/**
2103 - * Helper function to check if cookiebot is active.
2104 - * Useful for other plugins adding support for Cookiebot.
2105 - *
2106 - * @version 2.2.2
2107 - * @since 1.2
2108 - * @return string
2109 - */
2110 -function cookiebot_active() {
2111 - $cbid = Cookiebot_WP::get_cbid();
2112 - if ( ! empty( $cbid ) ) {
2113 - return true;
2114 - }
2115 - return false;
2116 -}
2117 -
2118 -
2119 -if ( ! function_exists( 'cookiebot' ) ) {
2120 - /**
2121 - * Returns the main instance of Cookiebot_WO to prevent the need to use globals.
2122 - *
2123 - * @version 1.0.0
2124 - * @since 1.0.0
2125 - * @return Cookiebot_WP
2126 - */
2127 - function cookiebot() {
2128 - return Cookiebot_WP::instance();
2129 - }
2130 -}
2131 -
2132 -cookiebot();