cookiebot_fix_plugin_conflicts();
}
/**
* Cookiebot_WP Installation actions
*
* @version 2.1.4
* @since 2.1.4
* @accces public
*/
function activation() {
//Delay display of recommendation notice in 3 days if not activated ealier
if ( get_option( 'cookiebot_notice_recommend', false ) === false ) {
//Not set yet - this must be first activation - delay in 3 days
update_option( 'cookiebot_notice_recommend', strtotime( '+3 days' ) );
}
if ( $this->get_cbid() == '' ) {
if ( is_multisite() ) {
update_site_option( 'cookiebot-cookie-blocking-mode', 'auto' );
update_site_option( 'cookiebot-nooutput-admin', true );
} else {
update_option( 'cookiebot-cookie-blocking-mode', 'auto' );
update_option( 'cookiebot-nooutput-admin', true );
}
}
/**
* Run through the addons and enable the default ones
*/
if ( ( ! defined( 'COOKIEBOT_ADDONS_STANDALONE' ) || COOKIEBOT_ADDONS_STANDALONE != true || ! defined( 'COOKIE_ADDONS_LOADED' ) ) ) {
//Make sure we got a PHP version that works
if ( version_compare( PHP_VERSION, '5.4.0', '>=' ) ) {
define( 'COOKIEBOT_URL', plugin_dir_url( __FILE__ ) );
// activation hook doesn't have the addons loaded - so load it extra when the plugin is activated
include_once dirname( __FILE__ ) . '/addons/cookiebot-addons-init.php';
// run activated hook on the addons
cookiebot_addons_plugin_activated();
}
}
}
/**
* Cookiebot_WP Init Cookiebot.
*
* @version 3.8.1
* @since 1.6.2
* @access public
*/
function cookiebot_init() {
/* Load Cookiebot Addons Framework */
$dismissAddons = false;
if ( defined( 'CAF_DIR' ) ) {
$dismissAddons = true;
/*add_action('admin_notices', function() {
?>
get_cookie_blocking_mode() !== 'auto' ) {
else {
if ( ( ! defined( 'COOKIEBOT_ADDONS_STANDALONE' ) || COOKIEBOT_ADDONS_STANDALONE != true || ! defined( 'COOKIE_ADDONS_LOADED' ) ) && $dismissAddons !== true ) {
//Make sure we got a PHP version that works
if ( version_compare( PHP_VERSION, '5.4.0', '>=' ) ) {
define( 'COOKIEBOT_URL', plugin_dir_url( __FILE__ ) );
include_once dirname( __FILE__ ) . '/addons/cookiebot-addons-init.php';
} else {
define( 'COOKIEBOT_ADDONS_UNSUPPORTED_PHPVERSION', true );
}
} else {
add_action(
'admin_notices',
function() {
?>
cookiebot_disabled_in_admin() ) {
//adding cookie banner in admin area too
add_action( 'admin_head', array( $this, 'add_js' ), -9999 );
}
}
//Include integration to WP Consent Level API if available
if ( $this->is_wp_consent_api_active() ) {
add_action( 'wp_enqueue_scripts', array( $this, 'cookiebot_enqueue_consent_api_scripts' ) );
}
// Set up localisation
load_plugin_textdomain( 'cookiebot', false, dirname( plugin_basename( __FILE__ ) ) . '/langs/' );
//add JS
add_action( 'wp_head', array( $this, 'add_js' ), -9997 );
add_action( 'wp_head', array( $this, 'add_GTM' ), -9998 );
add_action( 'wp_head', array( $this, 'add_GCM' ), -9999 );
add_shortcode( 'cookie_declaration', array( $this, 'show_declaration' ) );
//Add filter if WP rocket is enabled
if ( defined( 'WP_ROCKET_VERSION' ) ) {
add_filter( 'rocket_minify_excluded_external_js', array( $this, 'wp_rocket_exclude_external_js' ) );
}
//Add filter
add_filter( 'sgo_javascript_combine_excluded_external_paths', array( $this, 'sgo_exclude_external_js' ) );
//Automatic update plugin
if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
add_filter( 'auto_update_plugin', array( $this, 'automatic_updates' ), 10, 2 );
}
//Loading widgets
include_once dirname( __FILE__ ) . '/widgets/cookiebot-declaration-widget.php';
add_action( 'widgets_init', array( $this, 'register_widgets' ) );
//Add Gutenberg block
add_action( 'init', array( $this, 'gutenberg_block_setup' ) );
add_action( 'enqueue_block_editor_assets', array( $this, 'gutenberg_block_admin_assets' ) );
}
/**
* Cookiebot_WP Setup Gutenberg block
*
* @version 3.7.0
* @since 3.7.0
*/
function gutenberg_block_setup() {
if ( ! function_exists( 'register_block_type' ) ) {
return; //gutenberg not active
}
register_block_type(
'cookiebot/cookie-declaration',
array(
'render_callback' => array( $this, 'block_cookie_declaration' ),
)
);
}
/**
* Cookiebot_WP Add block JS
*
* @version 3.7.1
* @since 3.7.1
*/
function gutenberg_block_admin_assets() {
//Add Gutenberg Widget
wp_enqueue_script(
'cookiebot-declaration',
plugin_dir_url( __FILE__ ) . 'js/block.js',
array( 'wp-blocks', 'wp-i18n', 'wp-element' ), // Required scripts for the block
$this->version
);
}
/**
* Cookiebot_WP Render Cookiebot Declaration as Gutenberg block
*
* @version 3.7.0
* @since 3.7.0
*/
function block_cookie_declaration() {
return $this->show_declaration();
}
/**
* Cookiebot_WP Load text domain
*
* @version 2.0.0
* @since 2.0.0
*/
function load_textdomain() {
load_plugin_textdomain( 'cookiebot', false, basename( dirname( __FILE__ ) ) . '/langs' );
}
/**
* Cookiebot_WP Register widgets
*
* @version 2.5.0
* @since 2.5.0
*/
function register_widgets() {
register_widget( 'Cookiebot_Declaration_Widget' );
}
/**
* Cookiebot_WP Add dashboard widgets to admin
*
* @version 1.0.0
* @since 1.0.0
*/
function add_dashboard_widgets() {
wp_add_dashboard_widget( 'cookiebot_status', esc_html__( 'Cookiebot Status', 'cookiebot' ), array( $this, 'dashboard_widget_status' ) );
}
/**
* Cookiebot_WP Output Dashboard Status Widget
*
* @version 1.0.0
* @since 1.0.0
*/
function dashboard_widget_status() {
$cbid = $this->get_cbid();
if ( empty( $cbid ) ) {
echo '' . esc_html__( 'You need to enter your Cookiebot ID.', 'cookiebot' ) . '
';
echo '';
echo esc_html__( 'Update your Cookiebot ID', 'cookiebot' );
echo '
';
} else {
echo '' . esc_html_e( 'Your Cookiebot is working!', 'cookiebot' ) . '
';
}
}
/**
* Cookiebot_WP Add option menu page for Cookiebot
*
* @version 2.2.0
* @since 1.0.0
*/
function add_menu() {
//Cookiebot Icon SVG base64 encoded
$icon = 'data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgNzIgNTQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iI0ZGRkZGRiIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNNDYuODcyNTkwMyA4Ljc3MzU4MzM0QzQxLjk0MzkwMzkgMy4zODI5NTAxMSAzNC44NDI0OTQ2IDAgMjYuOTQ4MjgxOSAwIDEyLjA2NTE1NjggMCAwIDEyLjAyNDQ3NzQgMCAyNi44NTc0MjE5YzAgMTQuODMyOTQ0NSAxMi4wNjUxNTY4IDI2Ljg1NzQyMTkgMjYuOTQ4MjgxOSAyNi44NTc0MjE5IDcuODk0MjEyNyAwIDE0Ljk5NTYyMi0zLjM4Mjk1MDIgMTkuOTI0MzA4NC04Ljc3MzU4MzQtMi44ODk2OTY3LTEuMzY4ODY2My01LjM5OTMxMS0zLjQwNTQzOS03LjMyODA4MzgtNS45MDk2MzU4LTMuMTIxNDMwNiAzLjIwOTQxMDQtNy40OTI5OTQ0IDUuMjA0MTI5MS0xMi4zMzIwMjU4IDUuMjA0MTI5MS05LjQ4NDM0NDQgMC0xNy4xNzI5MjQ3LTcuNjYyNjU3Mi0xNy4xNzI5MjQ3LTE3LjExNTAyMzhzNy42ODg1ODAzLTE3LjExNTAyMzcgMTcuMTcyOTI0Ny0xNy4xMTUwMjM3YzQuNzIzNDgyMiAwIDkuMDAxNTU1MiAxLjkwMDU5MzkgMTIuMTA2MjkyIDQuOTc2MzA5IDEuOTU2OTIzNy0yLjY0MTEzMSA0LjU1MDAyNjMtNC43ODU1MTgzIDcuNTUzODE3Ni02LjIwODQzMTg2eiIvPjxwYXRoIGQ9Ik01NS4zODAzMjgyIDQyLjY1MDE5OTFDNDYuMzMzNzIyNyA0Mi42NTAxOTkxIDM5IDM1LjM0MTIwMzEgMzkgMjYuMzI1MDk5NiAzOSAxNy4zMDg5OTYgNDYuMzMzNzIyNyAxMCA1NS4zODAzMjgyIDEwYzkuMDQ2NjA1NSAwIDE2LjM4MDMyODIgNy4zMDg5OTYgMTYuMzgwMzI4MiAxNi4zMjUwOTk2IDAgOS4wMTYxMDM1LTcuMzMzNzIyNyAxNi4zMjUwOTk1LTE2LjM4MDMyODIgMTYuMzI1MDk5NXptLjAyMTMwOTItNy43NTU2MzQyYzQuNzM3MDI3NiAwIDguNTc3MTQ3MS0zLjgyNzE3MiA4LjU3NzE0NzEtOC41NDgyMjc5IDAtNC43MjEwNTYtMy44NDAxMTk1LTguNTQ4MjI4LTguNTc3MTQ3MS04LjU0ODIyOC00LjczNzAyNzUgMC04LjU3NzE0NyAzLjgyNzE3Mi04LjU3NzE0NyA4LjU0ODIyOCAwIDQuNzIxMDU1OSAzLjg0MDExOTUgOC41NDgyMjc5IDguNTc3MTQ3IDguNTQ4MjI3OXoiLz48L2c+PC9zdmc+';
add_menu_page( 'Cookiebot', __( 'Cookiebot', 'cookiebot' ), 'manage_options', 'cookiebot', array( $this, 'settings_page' ), $icon );
add_submenu_page( 'cookiebot', __( 'Cookiebot Settings', 'cookiebot' ), __( 'Settings', 'cookiebot' ), 'manage_options', 'cookiebot', array( $this, 'settings_page' ), 10 );
add_submenu_page( 'cookiebot', __( 'Cookiebot Support', 'cookiebot' ), __( 'Support', 'cookiebot' ), 'manage_options', 'cookiebot_support', array( $this, 'support_page' ), 20 );
add_submenu_page( 'cookiebot', __( 'Google Tag Manager', 'cookiebot' ), __( 'Google Tag Manager', 'cookiebot' ), 'manage_options', 'cookiebot_GTM', array( $this, 'GTM_page' ) );
add_submenu_page( 'cookiebot', __( 'IAB', 'cookiebot' ), __( 'IAB', 'cookiebot' ), 'manage_options', 'cookiebot_iab', array( $this, 'iab_page' ), 30 );
if ( defined( 'COOKIEBOT_ADDONS_UNSUPPORTED_PHPVERSION' ) ) {
//Load prior consent page anyway - but from Cookiebot WP Core plugin.
add_submenu_page( 'cookiebot', __( 'Prior Consent', 'cookiebot' ), __( 'Prior Consent', 'cookiebot' ), 'manage_options', 'cookiebot-addons', array( $this, 'setting_page_placeholder' ), 40 );
}
}
function add_menu_legislations() {
add_submenu_page( 'cookiebot', __( 'Legislations', 'cookiebot' ), __( 'Legislations', 'cookiebot' ), 'manage_options', 'cookiebot-legislations', array( $this, 'legislations_page' ), 50 );
}
/**
* Cookiebot_WP Add debug menu - we need to add this seperate to ensure it is placed last (after menu items from Addons).
*
* @version 3.6.0
* @since 3.6.0
*/
function add_menu_debug() {
add_submenu_page( 'cookiebot', __( 'Debug info', 'cookiebot' ), __( 'Debug info', 'cookiebot' ), 'manage_options', 'cookiebot_debug', array( $this, 'debug_page' ) );
}
/**
* Cookiebot_WP Add menu for network sites
*
* @version 2.2.0
* @since 2.2.0
*/
function add_network_menu() {
$icon = 'data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgNzIgNTQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iI0ZGRkZGRiIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNNDYuODcyNTkwMyA4Ljc3MzU4MzM0QzQxLjk0MzkwMzkgMy4zODI5NTAxMSAzNC44NDI0OTQ2IDAgMjYuOTQ4MjgxOSAwIDEyLjA2NTE1NjggMCAwIDEyLjAyNDQ3NzQgMCAyNi44NTc0MjE5YzAgMTQuODMyOTQ0NSAxMi4wNjUxNTY4IDI2Ljg1NzQyMTkgMjYuOTQ4MjgxOSAyNi44NTc0MjE5IDcuODk0MjEyNyAwIDE0Ljk5NTYyMi0zLjM4Mjk1MDIgMTkuOTI0MzA4NC04Ljc3MzU4MzQtMi44ODk2OTY3LTEuMzY4ODY2My01LjM5OTMxMS0zLjQwNTQzOS03LjMyODA4MzgtNS45MDk2MzU4LTMuMTIxNDMwNiAzLjIwOTQxMDQtNy40OTI5OTQ0IDUuMjA0MTI5MS0xMi4zMzIwMjU4IDUuMjA0MTI5MS05LjQ4NDM0NDQgMC0xNy4xNzI5MjQ3LTcuNjYyNjU3Mi0xNy4xNzI5MjQ3LTE3LjExNTAyMzhzNy42ODg1ODAzLTE3LjExNTAyMzcgMTcuMTcyOTI0Ny0xNy4xMTUwMjM3YzQuNzIzNDgyMiAwIDkuMDAxNTU1MiAxLjkwMDU5MzkgMTIuMTA2MjkyIDQuOTc2MzA5IDEuOTU2OTIzNy0yLjY0MTEzMSA0LjU1MDAyNjMtNC43ODU1MTgzIDcuNTUzODE3Ni02LjIwODQzMTg2eiIvPjxwYXRoIGQ9Ik01NS4zODAzMjgyIDQyLjY1MDE5OTFDNDYuMzMzNzIyNyA0Mi42NTAxOTkxIDM5IDM1LjM0MTIwMzEgMzkgMjYuMzI1MDk5NiAzOSAxNy4zMDg5OTYgNDYuMzMzNzIyNyAxMCA1NS4zODAzMjgyIDEwYzkuMDQ2NjA1NSAwIDE2LjM4MDMyODIgNy4zMDg5OTYgMTYuMzgwMzI4MiAxNi4zMjUwOTk2IDAgOS4wMTYxMDM1LTcuMzMzNzIyNyAxNi4zMjUwOTk1LTE2LjM4MDMyODIgMTYuMzI1MDk5NXptLjAyMTMwOTItNy43NTU2MzQyYzQuNzM3MDI3NiAwIDguNTc3MTQ3MS0zLjgyNzE3MiA4LjU3NzE0NzEtOC41NDgyMjc5IDAtNC43MjEwNTYtMy44NDAxMTk1LTguNTQ4MjI4LTguNTc3MTQ3MS04LjU0ODIyOC00LjczNzAyNzUgMC04LjU3NzE0NyAzLjgyNzE3Mi04LjU3NzE0NyA4LjU0ODIyOCAwIDQuNzIxMDU1OSAzLjg0MDExOTUgOC41NDgyMjc5IDguNTc3MTQ3IDguNTQ4MjI3OXoiLz48L2c+PC9zdmc+';
add_menu_page( 'Cookiebot', __( 'Cookiebot', 'cookiebot' ), 'manage_network_options', 'cookiebot_network', array( $this, 'network_settings_page' ), $icon );
add_submenu_page( 'cookiebot_network', __( 'Cookiebot Settings', 'cookiebot' ), __( 'Settings', 'cookiebot' ), 'network_settings_page', 'cookiebot_network', array( $this, 'network_settings_page' ) );
add_submenu_page( 'cookiebot_network', __( 'Cookiebot Support', 'cookiebot' ), __( 'Support', 'cookiebot' ), 'network_settings_page', 'cookiebot_support', array( $this, 'support_page' ) );
}
/**
* Cookiebot_WP Cookiebot prior consent placeholder page
*
* @version 1.4.0
* @since 1.0.0
*/
function setting_page_placeholder() {
include __DIR__ . DIRECTORY_SEPARATOR . 'addons' . DIRECTORY_SEPARATOR . 'view/admin/settings/setting-page.php';
}
/**
* Cookiebot_WP Register Cookiebot settings
*
* @version 3.9.0
* @since 1.0.0
*/
function register_cookiebot_settings() {
register_setting( 'cookiebot', 'cookiebot-cbid' );
register_setting( 'cookiebot', 'cookiebot-language' );
register_setting( 'cookiebot', 'cookiebot-nooutput' );
register_setting( 'cookiebot', 'cookiebot-nooutput-admin' );
register_setting( 'cookiebot', 'cookiebot-output-logged-in' );
register_setting( 'cookiebot', 'cookiebot-autoupdate' );
register_setting( 'cookiebot', 'cookiebot-script-tag-uc-attribute' );
register_setting( 'cookiebot', 'cookiebot-script-tag-cd-attribute' );
register_setting( 'cookiebot', 'cookiebot-cookie-blocking-mode' );
register_setting( 'cookiebot', 'cookiebot-consent-mapping' );
register_setting( 'cookiebot-iab', 'cookiebot-iab' );
register_setting( 'cookiebot-legislations', 'cookiebot-ccpa' );
register_setting( 'cookiebot-legislations', 'cookiebot-ccpa-domain-group-id' );
register_setting( 'cookiebot-gtm', 'cookiebot-gtm' );
register_setting( 'cookiebot-gtm', 'cookiebot-gtm-id' );
register_setting( 'cookiebot-gtm', 'cookiebot-data-layer' );
register_setting( 'cookiebot-gtm', 'cookiebot-gcm' );
}
/**
* Cookiebot_WP Automatic update plugin if activated
*
* @version 2.2.0
* @since 1.5.0
*/
function automatic_updates( $update, $item ) {
//Do not update from subsite on a multisite installation
if ( is_multisite() && ! is_main_site() ) {
return $update;
}
//Check if we have everything we need
$item = (array) $item;
if ( ! isset( $item['new_version'] ) || ! isset( $item['slug'] ) ) {
return $update;
}
//It is not Cookiebot
if ( $item['slug'] !== 'cookiebot' ) {
return $update;
}
// Check if cookiebot autoupdate is disabled
if ( ! get_option( 'cookiebot-autoupdate', false ) ) {
return $update;
}
// Check if multisite autoupdate is disabled
if ( is_multisite() && ! get_site_option( 'cookiebot-autoupdate', false ) ) {
return $update;
}
return true;
}
/**
* Cookiebot_WP Get list of supported languages
*
* @version 1.4.0
* @since 1.4.0
*/
public static function get_supported_languages() {
$supportedLanguages = array();
$supportedLanguages['nb'] = __( 'Norwegian Bokmål', 'cookiebot' );
$supportedLanguages['tr'] = __( 'Turkish', 'cookiebot' );
$supportedLanguages['de'] = __( 'German', 'cookiebot' );
$supportedLanguages['cs'] = __( 'Czech', 'cookiebot' );
$supportedLanguages['da'] = __( 'Danish', 'cookiebot' );
$supportedLanguages['sq'] = __( 'Albanian', 'cookiebot' );
$supportedLanguages['he'] = __( 'Hebrew', 'cookiebot' );
$supportedLanguages['ko'] = __( 'Korean', 'cookiebot' );
$supportedLanguages['it'] = __( 'Italian', 'cookiebot' );
$supportedLanguages['nl'] = __( 'Dutch', 'cookiebot' );
$supportedLanguages['vi'] = __( 'Vietnamese', 'cookiebot' );
$supportedLanguages['ta'] = __( 'Tamil', 'cookiebot' );
$supportedLanguages['is'] = __( 'Icelandic', 'cookiebot' );
$supportedLanguages['ro'] = __( 'Romanian', 'cookiebot' );
$supportedLanguages['si'] = __( 'Sinhala', 'cookiebot' );
$supportedLanguages['ca'] = __( 'Catalan', 'cookiebot' );
$supportedLanguages['bg'] = __( 'Bulgarian', 'cookiebot' );
$supportedLanguages['uk'] = __( 'Ukrainian', 'cookiebot' );
$supportedLanguages['zh'] = __( 'Chinese', 'cookiebot' );
$supportedLanguages['en'] = __( 'English', 'cookiebot' );
$supportedLanguages['ar'] = __( 'Arabic', 'cookiebot' );
$supportedLanguages['hr'] = __( 'Croatian', 'cookiebot' );
$supportedLanguages['th'] = __( 'Thai', 'cookiebot' );
$supportedLanguages['el'] = __( 'Greek', 'cookiebot' );
$supportedLanguages['lt'] = __( 'Lithuanian', 'cookiebot' );
$supportedLanguages['pl'] = __( 'Polish', 'cookiebot' );
$supportedLanguages['lv'] = __( 'Latvian', 'cookiebot' );
$supportedLanguages['fr'] = __( 'French', 'cookiebot' );
$supportedLanguages['id'] = __( 'Indonesian', 'cookiebot' );
$supportedLanguages['mk'] = __( 'Macedonian', 'cookiebot' );
$supportedLanguages['et'] = __( 'Estonian', 'cookiebot' );
$supportedLanguages['pt'] = __( 'Portuguese', 'cookiebot' );
$supportedLanguages['ga'] = __( 'Irish', 'cookiebot' );
$supportedLanguages['ms'] = __( 'Malay', 'cookiebot' );
$supportedLanguages['sl'] = __( 'Slovenian', 'cookiebot' );
$supportedLanguages['ru'] = __( 'Russian', 'cookiebot' );
$supportedLanguages['ja'] = __( 'Japanese', 'cookiebot' );
$supportedLanguages['hi'] = __( 'Hindi', 'cookiebot' );
$supportedLanguages['sk'] = __( 'Slovak', 'cookiebot' );
$supportedLanguages['es'] = __( 'Spanish', 'cookiebot' );
$supportedLanguages['sv'] = __( 'Swedish', 'cookiebot' );
$supportedLanguages['sr'] = __( 'Serbian', 'cookiebot' );
$supportedLanguages['fi'] = __( 'Finnish', 'cookiebot' );
$supportedLanguages['eu'] = __( 'Basque', 'cookiebot' );
$supportedLanguages['hu'] = __( 'Hungarian', 'cookiebot' );
asort( $supportedLanguages, SORT_LOCALE_STRING );
return $supportedLanguages;
}
/**
* Cookiebot_WP Output settings page
*
* @version 3.9.0
* @since 1.0.0
*/
function settings_page() {
wp_enqueue_style( 'cookiebot-consent-mapping-table', plugins_url( 'css/consent_mapping_table.css', __FILE__ ), array(), '3.5.0' );
/* Check if multisite */
if ( $is_ms = is_multisite() ) {
//Receive settings from multisite - this might change the way we render the form
$network_cbid = get_site_option( 'cookiebot-cbid', '' );
$network_scrip_tag_uc_attr = get_site_option( 'cookiebot-script-tag-uc-attribute', 'custom' );
$network_scrip_tag_cd_attr = get_site_option( 'cookiebot-script-tag-cd-attribute', 'custom' );
$network_cookie_blocking_mode = get_site_option( 'cookiebot-cookie-blocking-mode', 'manual' );
}
?>
%s',
esc_url( $cookiebot_gdpr_url ),
esc_html__( 'General Data Protection Regulation (GDPR)', 'cookiebot' )
),
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' )
);
?>
%s',
esc_url( $cookiebot_gdpr_url ),
esc_html__( 'General Data Protection Regulation (GDPR)', 'cookiebot' )
),
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' )
);
?>
'cookiebot_network',
'updated' => true,
),
network_admin_url( 'admin.php' )
)
);
exit;
}
/**
* Cookiebot_WP Cookiebot support page
*
* @version 2.2.0
* @since 2.0.0
*/
function support_page() {
?>
- Cookiebot account.', 'cookiebot' ); ?>
- Manage > Settings and add setup your Cookiebot', 'cookiebot' ); ?>
- "Your scripts" tab', 'cookiebot' ); ?>
- [cookie_declaration] shortcode to a page to show the declation', 'cookiebot' ); ?>
[cookie_declaration] to add the cookie declaration a page or post. The cookie declaration will always show the latest version from Cookiebot.', 'cookiebot' ); ?>
lang attribute. Eg. [cookie_declaration lang="de"].', 'cookiebot' ); ?>
' ) . '
';
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');" ) . '
';
echo htmlentities( "ga('create', 'UA-00000000-0', 'auto');" ) . '
';
echo htmlentities( "ga('send', 'pageview');" ) . '
';
echo htmlentities( '' ) . '
';
?>
' . htmlentities( '
*
* @version 3.9.0
* @since 1.0.0
*/
function add_js( $printTag = true ) {
$cbid = $this->get_cbid();
if ( ! empty( $cbid ) && ! defined( 'COOKIEBOT_DISABLE_ON_PAGE' ) ) {
if ( is_multisite() && get_site_option( 'cookiebot-nooutput', false ) ) {
return; //Is multisite - and disabled output is checked as network setting
}
if ( get_option( 'cookiebot-nooutput', false ) ) {
return; //Do not show JS - output disabled
}
if ( $this->get_cookie_blocking_mode() == 'auto' && $this->can_current_user_edit_theme() && $printTag !== false && get_site_option( 'cookiebot-output-logged-in' ) == false ) {
return;
}
$lang = $this->get_language();
if ( ! empty( $lang ) ) {
$lang = ' data-culture="' . strtoupper( $lang ) . '"'; //Use data-culture to define language
}
if ( ! is_multisite() || get_site_option( 'cookiebot-script-tag-uc-attribute', 'custom' ) == 'custom' ) {
$tagAttr = get_option( 'cookiebot-script-tag-uc-attribute', 'async' );
} else {
$tagAttr = get_site_option( 'cookiebot-script-tag-uc-attribute' );
}
if ( $this->get_cookie_blocking_mode() == 'auto' ) {
$tagAttr = 'data-blockingmode="auto"';
}
if ( get_option( 'cookiebot-gtm' ) != false ) {
if ( empty( get_option( 'cookiebot-data-layer' ) ) ) {
$data_layer = 'data-layer-name="dataLayer"';
} else {
$data_layer = 'data-layer-name="' . get_option( 'cookiebot-data-layer' ) . '"';
}
} else {
$data_layer = '';
}
$iab = ( get_option( 'cookiebot-iab' ) != false ) ? 'data-framework="IAB"' : '';
$ccpa = ( get_option( 'cookiebot-ccpa' ) != false ) ? 'data-georegions="{\'region\':\'US-06\',\'cbid\':\'' . get_option( 'cookiebot-ccpa-domain-group-id' ) . '\'}"' : '';
$tag = '';
if ( $printTag === false ) {
return $tag;
}
echo $tag;
}
}
/**
* Cookiebot_WP Add Google Tag Manager JS to
*
* @version 3.8.1
* @since 3.8.1
*/
function add_GTM( $printTag = true ) {
if ( get_option( 'cookiebot-gtm' ) != false ) {
if ( empty( get_option( 'cookiebot-data-layer' ) ) ) {
$data_layer = 'dataLayer';
} else {
$data_layer = get_option( 'cookiebot-data-layer' );
}
$GTM = '';
if ( $printTag === false ) {
return $GTM;
}
echo $GTM;
}
}
/**
* Cookiebot_WP Add Google Consent Mode JS to
*
* @version 3.8.1
* @since 3.8.1
*/
function add_GCM( $printTag = true ) {
if ( get_option( 'cookiebot-gcm' ) != false ) {
if ( empty( get_option( 'cookiebot-data-layer' ) ) ) {
$data_layer = 'dataLayer';
} else {
$data_layer = get_option( 'cookiebot-data-layer' );
}
$GCM = '';
if ( $printTag === false ) {
return $GCM;
}
echo $GCM;
}
}
/**
* Returns true if an user is logged in and has an edit_themes capability
*
* @return bool
*
* @since 3.3.1
* @version 3.4.1
*/
function can_current_user_edit_theme() {
if ( is_user_logged_in() ) {
if ( current_user_can( 'edit_themes' ) ) {
return true;
}
if ( current_user_can( 'edit_pages' ) ) {
return true;
}
if ( current_user_can( 'edit_posts' ) ) {
return true;
}
}
return false;
}
/**
* Cookiebot_WP Output declation shortcode [cookie_declaration]
* Support attribute lang="LANGUAGE_CODE". Eg. lang="en".
*
* @version 2.2.0
* @since 1.0.0
*/
function show_declaration( $atts = array() ) {
$cbid = $this->get_cbid();
$lang = '';
if ( ! empty( $cbid ) ) {
$atts = shortcode_atts(
array(
'lang' => $this->get_language(),
),
$atts,
'cookie_declaration'
);
if ( ! empty( $atts['lang'] ) ) {
$lang = ' data-culture="' . strtoupper( $atts['lang'] ) . '"'; //Use data-culture to define language
}
if ( ! is_multisite() || get_site_option( 'cookiebot-script-tag-cd-attribute', 'custom' ) == 'custom' ) {
$tagAttr = get_option( 'cookiebot-script-tag-cd-attribute', 'async' );
} else {
$tagAttr = get_site_option( 'cookiebot-script-tag-cd-attribute' );
}
return '';
} else {
return esc_html__( 'Please add your Cookiebot ID to show Cookie Declarations', 'cookiebot' );
}
}
/**
* Cookiebot_WP Get cookiebot cbid
*
* @version 2.2.0
* @since 1.0.0
*/
public static function get_cbid() {
$cbid = get_option( 'cookiebot-cbid' );
if ( is_multisite() && ( $network_cbid = get_site_option( 'cookiebot-cbid' ) ) ) {
if ( empty( $cbid ) ) {
return $network_cbid;
}
}
return $cbid;
}
/**
* Cookiebot_WP Get cookie blocking mode (auto | manual)
*
* @version 2.2.0
* @since 1.0.0
*/
public static function get_cookie_blocking_mode() {
$cbm = get_option( 'cookiebot-cookie-blocking-mode' );
if ( is_multisite() && ( $network_cbm = get_site_option( 'cookiebot-cookie-blocking-mode' ) ) ) {
if ( empty( $cbm ) ) {
return $network_cbm;
}
}
if ( empty( $cbm ) ) {
$cbm = 'manual'; }
return $cbm;
}
/**
* Cookiebot_WP Check if Cookiebot is active in admin
*
* @version 3.1.0
* @since 3.1.0
*/
public static function cookiebot_disabled_in_admin() {
if ( is_multisite() && get_site_option( 'cookiebot-nooutput-admin', false ) ) {
return true;
} elseif ( get_option( 'cookiebot-nooutput-admin', false ) ) {
return true;
}
return false;
}
/**
* Cookiebot_WP Get the language code for Cookiebot
*
* @version 1.4.0
* @since 1.4.0
*/
function get_language( $onlyFromSetting = false ) {
// Get language set in setting page - if empty use WP language info
$lang = get_option( 'cookiebot-language' );
if ( ! empty( $lang ) ) {
if ( $lang != '_wp' ) {
return $lang;
}
}
if ( $onlyFromSetting ) {
return $lang; //We want only to get if already set
}
//Language not set - use WP language
if ( $lang == '_wp' ) {
$lang = get_bloginfo( 'language' ); //Gets language in en-US format
if ( ! empty( $lang ) ) {
list($lang) = explode( '-', $lang ); //Changes format from eg. en-US to en.
}
}
return $lang;
}
/**
* Cookiebot_WP Adding Cookiebot domain(s) to exclude list for WP Rocket minification.
*
* @version 1.6.1
* @since 1.6.1
*/
function wp_rocket_exclude_external_js( $external_js_hosts ) {
$external_js_hosts[] = 'consent.cookiebot.com'; // Add cookiebot domains
$external_js_hosts[] = 'consentcdn.cookiebot.com';
return $external_js_hosts;
}
/**
* Cookiebot_WP Adding Cookiebot domain(s) to exclude list for SGO minification.
*
* @version 3.6.5
* @since 3.6.5
*/
function sgo_exclude_external_js( $exclude_list ) {
//Uses same format as WP Rocket - for now we just use WP Rocket function
return wp_rocket_exclude_external_js( $exclude_list );
}
/**
* Cookiebot_WP Check if WP Cookie Consent API is active
*
* @version 3.5.0
* @since 3.5.0
*/
public function is_wp_consent_api_active() {
if ( class_exists( 'WP_CONSENT_API' ) ) {
return true;
}
return false;
}
/**
* Cookiebot_WP Default consent level mappings
*
* @version 3.5.0
* @since 3.5.0
*/
public function get_default_wp_consent_api_mapping() {
return array(
'n=1;p=1;s=1;m=1' =>
array(
'preferences' => 1,
'statistics' => 1,
'statistics-anonymous' => 0,
'marketing' => 1,
),
'n=1;p=1;s=1;m=0' =>
array(
'preferences' => 1,
'statistics' => 1,
'statistics-anonymous' => 1,
'marketing' => 0,
),
'n=1;p=1;s=0;m=1' =>
array(
'preferences' => 1,
'statistics' => 0,
'statistics-anonymous' => 0,
'marketing' => 1,
),
'n=1;p=1;s=0;m=0' =>
array(
'preferences' => 1,
'statistics' => 0,
'statistics-anonymous' => 0,
'marketing' => 0,
),
'n=1;p=0;s=1;m=1' =>
array(
'preferences' => 0,
'statistics' => 1,
'statistics-anonymous' => 0,
'marketing' => 1,
),
'n=1;p=0;s=1;m=0' =>
array(
'preferences' => 0,
'statistics' => 1,
'statistics-anonymous' => 0,
'marketing' => 0,
),
'n=1;p=0;s=0;m=1' =>
array(
'preferences' => 0,
'statistics' => 0,
'statistics-anonymous' => 0,
'marketing' => 1,
),
'n=1;p=0;s=0;m=0' =>
array(
'preferences' => 0,
'statistics' => 0,
'statistics-anonymous' => 0,
'marketing' => 0,
),
);
}
/**
* Cookiebot_WP Get the mapping between Consent Level API and Cookiebot
* Returns array where key is the consent level api category and value
* is the mapped Cookiebot category.
*
* @version 3.5.0
* @since 3.5.0
*/
public function get_wp_consent_api_mapping() {
$mDefault = $this->get_default_wp_consent_api_mapping();
$mapping = get_option( 'cookiebot-consent-mapping', $mDefault );
$mapping = ( '' === $mapping ) ? $mDefault : $mapping;
foreach ( $mDefault as $k => $v ) {
if ( ! isset( $mapping[ $k ] ) ) {
$mapping[ $k ] = $v;
} else {
foreach ( $v as $vck => $vcv ) {
if ( ! isset( $mapping[ $k ][ $vck ] ) ) {
$mapping[ $k ][ $vck ] = $vcv;
}
}
}
}
return $mapping;
}
/**
* Cookiebot_WP Enqueue JS for integration with WP Consent Level API
*
* @version 3.5.0
* @since 3.5.0
*/
function cookiebot_enqueue_consent_api_scripts() {
wp_register_script( 'cookiebot-wp-consent-level-api-integration', plugins_url( 'cookiebot/js/cookiebot-wp-consent-level-api-integration.js', 'cookiebot' ) );
wp_enqueue_script( 'cookiebot-wp-consent-level-api-integration' );
wp_localize_script( 'cookiebot-wp-consent-level-api-integration', 'cookiebot_category_mapping', $this->get_wp_consent_api_mapping() );
}
/**
* Display admin notice for recommending cookiebot
*
* @version 2.0.5
* @since 2.0.5
*/
function cookiebot_admin_notices() {
if ( ! $this->cookiebot_valid_admin_recommendation() ) {
return false;
}
$two_week_review_ignore = add_query_arg( array( 'cookiebot_admin_notice' => 'hide' ) );
$two_week_review_temp = add_query_arg( array( 'cookiebot_admin_notice' => 'two_week' ) );
$notices = array(
'title' => esc_html__( 'Leave A Review?', 'cookiebot' ),
'msg' => esc_html__( 'We hope you enjoy using WordPress Cookiebot! Would you consider leaving us a review on WordPress.org?', 'cookiebot' ),
'link' => '' . esc_html__( 'Sure! I\'d love to!', 'cookiebot' ) . '
' . esc_html__( 'I\'ve already left a review', 'cookiebot' ) . '
' . esc_html__( 'Maybe Later', 'cookiebot' ) . '
' . esc_html__( 'Never show again', 'cookiebot' ) . '',
'later_link' => $two_week_review_temp,
'int' => 14,
);
echo '
' . $notices['title'] . '
' . $notices['msg'] . '
';
wp_enqueue_style( 'cookiebot-admin-notices', plugins_url( 'css/notice.css', __FILE__ ), array(), '2.0.4' );
}
/**
* Validate if the last user action is valid for plugin recommendation
*
* @return bool
*
* @version 2.0.5
* @since 2.0.5
*/
function cookiebot_valid_admin_recommendation() {
//Default - the recommendation is allowed to be visible
$return = true;
$option = get_option( 'cookiebot_notice_recommend' );
if ( $option != false ) {
//Never show again is clicked
if ( $option == 'hide' ) {
$return = false;
} elseif ( is_numeric( $option ) && strtotime( 'now' ) < $option ) {
//Show me after 2 weeks is clicked and the time is not valid yet
$return = false;
}
}
return $return;
}
/**
* Save the user action on cookiebot recommendation link
*
* @version 2.0.5
* @since 2.0.5
*/
function save_notice_link() {
if ( isset( $_GET['cookiebot_admin_notice'] ) ) {
if ( $_GET['cookiebot_admin_notice'] == 'hide' ) {
update_option( 'cookiebot_notice_recommend', 'hide' );
} else {
update_option( 'cookiebot_notice_recommend', strtotime( '+2 weeks' ) );
}
}
}
/**
* Cookiebot_WP Fix plugin conflicts related to Cookiebot
*
* @version 3.2.0
* @since 3.3.0
*/
function cookiebot_fix_plugin_conflicts() {
//Fix for Divi Page Builder
//Disabled - using another method now (can_current_user_edit_theme())
//add_action( 'wp', array( $this, '_cookiebot_plugin_conflict_divi' ), 100 );
//Fix for Elementor and WPBakery Page Builder Builder
//Disabled - using another method now (can_current_user_edit_theme())
//add_filter( 'script_loader_tag', array( $this, '_cookiebot_plugin_conflict_scripttags' ), 10, 2 );
}
/**
* Cookiebot_WP Fix Divi builder conflict when blocking mode is in auto.
*
* @version 3.2.0
* @since 3.2.0
*/
function _cookiebot_plugin_conflict_divi() {
if ( defined( 'ET_FB_ENABLED' ) ) {
if ( ET_FB_ENABLED &&
$this->cookiebot_disabled_in_admin() &&
$this->get_cookie_blocking_mode() == 'auto' ) {
define( 'COOKIEBOT_DISABLE_ON_PAGE', true ); //Disable Cookiebot on the current page
}
}
}
/**
* Cookiebot_WP Fix plugin conflicts with page builders - whitelist JS files in automode
*
* @version 3.2.0
* @since 3.3.0
*/
function _cookiebot_plugin_conflict_scripttags( $tag, $handle ) {
//Check if Elementor Page Builder active
if ( defined( 'ELEMENTOR_VERSION' ) ) {
if ( in_array(
$handle,
array(
'jquery-core',
'elementor-frontend-modules',
'elementor-frontend',
'wp-tinymce',
'underscore',
'backbone',
'backbone-marionette',
'backbone-radio',
'elementor-common-modules',
'elementor-dialog',
'elementor-common',
)
) ) {
$tag = str_replace( '