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