page_title = __( 'Cookies Configuration', 'wpconsent-cookies-banner-privacy-suite' ); $this->menu_title = __( 'Settings', 'wpconsent-cookies-banner-privacy-suite' ); parent::__construct(); } /** * Page specific Hooks. * * @return void */ public function page_hooks() { add_action( 'admin_init', array( $this, 'handle_submit' ) ); add_filter( 'wpconsent_admin_js_data', array( $this, 'add_connect_strings' ) ); $this->views = array( 'settings' => __( 'Settings', 'wpconsent-cookies-banner-privacy-suite' ), 'cookies' => __( 'Cookies', 'wpconsent-cookies-banner-privacy-suite' ), 'languages' => __( 'Languages', 'wpconsent-cookies-banner-privacy-suite' ), 'advanced' => __( 'Advanced', 'wpconsent-cookies-banner-privacy-suite' ), 'iabtcf' => __( 'IAB TCF', 'wpconsent-cookies-banner-privacy-suite' ), ); } /** * Add the strings for the connect page to the JS object. * * @param array $data The localized data we already have. * * @return array */ public function add_connect_strings( $data ) { $data['oops'] = esc_html__( 'Oops!', 'wpconsent-cookies-banner-privacy-suite' ); $data['ok'] = esc_html__( 'OK', 'wpconsent-cookies-banner-privacy-suite' ); $data['almost_done'] = esc_html__( 'Almost Done', 'wpconsent-cookies-banner-privacy-suite' ); $data['plugin_activate_btn'] = esc_html__( 'Activate', 'wpconsent-cookies-banner-privacy-suite' ); $data['server_error'] = esc_html__( 'Unfortunately there was a server connection error.', 'wpconsent-cookies-banner-privacy-suite' ); $data['icons'] = array( 'checkmark' => wpconsent_get_icon( 'checkmark', 88, 88, '0 0 130.2 130.2' ), ); $data['records_of_consent'] = array( 'title' => esc_html__( 'Records of Consent is a PRO feature', 'wpconsent-cookies-banner-privacy-suite' ), 'text' => esc_html__( 'Upgrade to PRO today and start keeping logs for all visitors that give consent. 100% self-hosted on your WordPress site.', 'wpconsent-cookies-banner-privacy-suite' ), 'url' => wpconsent_utm_url( 'https://wpconsent.com/lite', 'settings', 'consent-logs' ), ); $data['scanner'] = array( 'title' => esc_html__( 'Automatic Scanning is a PRO feature', 'wpconsent-cookies-banner-privacy-suite' ), 'text' => esc_html__( 'Upgrade to PRO today and schedule automatic website scanning to stay up to date with your website\'s consent needs.', 'wpconsent-cookies-banner-privacy-suite' ), 'url' => wpconsent_utm_url( 'https://wpconsent.com/lite', 'settings', 'consent-logs' ), ); return $data; } /** * The page output based on the view. * * @return void */ public function output_content() { if ( method_exists( $this, 'output_view_' . $this->view ) ) { call_user_func( array( $this, 'output_view_' . $this->view ) ); } } /** * For this page we output a menu. * * @return void */ public function output_header_bottom() { ?> view ) { $enable_shared_consent = isset( $_POST['enable_shared_consent'] ) ? 1 : 0; // Calculate cookie domain if shared consent is enabled. $cookie_domain = ''; $hostname = ''; if ( $enable_shared_consent ) { $hostname = wp_parse_url( home_url(), PHP_URL_HOST ); if ( $hostname ) { $cookie_domain = wpconsent_get_registrable_domain( $hostname ); } } /** * Filter the calculated cookie domain before saving. * * Allows developers to modify the cookie domain for edge cases or custom requirements. * * @param string $cookie_domain The calculated registrable domain (e.g., 'example.com'). * @param string $hostname The original hostname from home_url(). * @param int $enable_shared_consent Whether shared consent is enabled (1 or 0). * * @since 1.1.0 * */ $cookie_domain = apply_filters( 'wpconsent_cookie_domain', $cookie_domain, $hostname, $enable_shared_consent ); $settings = array( 'clarity_consent_mode' => isset( $_POST['clarity_consent_mode'] ) ? 1 : 0, 'uninstall_data' => isset( $_POST['uninstall_data'] ) ? 1 : 0, 'enable_shared_consent' => $enable_shared_consent, 'cookie_domain' => $cookie_domain, 'respect_gpc' => isset( $_POST['respect_gpc'] ) ? 1 : 0, 'usage_tracking' => isset( $_POST['usage_tracking'] ) ? 1 : 0, ); } else { // Update main settings (for settings view). $settings = array( 'enable_consent_banner' => isset( $_POST['enable_consent_banner'] ) ? 1 : 0, 'cookie_policy_page' => isset( $_POST['cookie_policy_page'] ) ? intval( $_POST['cookie_policy_page'] ) : 0, 'enable_script_blocking' => ( isset( $_POST['enable_script_blocking'] ) && isset( $_POST['enable_consent_banner'] ) ) ? 1 : 0, 'google_consent_mode' => ( isset( $_POST['google_consent_mode'] ) && isset( $_POST['google_consent_mode'] ) ) ? 1 : 0, 'enable_consent_floating' => isset( $_POST['enable_consent_floating'] ) ? 1 : 0, 'default_allow' => isset( $_POST['default_allow'] ) ? 1 : 0, 'manual_toggle_services' => isset( $_POST['manual_toggle_services'] ) ? 1 : 0, 'consent_duration' => isset( $_POST['consent_duration'] ) ? intval( $_POST['consent_duration'] ) : 30, 'enable_content_blocking' => isset( $_POST['enable_content_blocking'] ) ? 1 : 0, 'content_blocking_services' => isset( $_POST['content_blocking_services'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['content_blocking_services'] ) ) : array(), 'content_blocking_placeholder_text' => isset( $_POST['content_blocking_placeholder_text'] ) ? sanitize_text_field( wp_unslash( $_POST['content_blocking_placeholder_text'] ) ) : 'Click here to accept {category} cookies and load this content', ); } wpconsent()->settings->bulk_update_options( $settings ); wp_safe_redirect( $this->get_page_action_url() ); exit; } /** * Output the settings view. * * @return void */ public function output_view_settings() { ?>
metabox( esc_html__( 'License', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_license_key_content() ); $this->metabox( __( 'Cookies Configuration', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_settings_metabox() ); wp_nonce_field( 'wpconsent_save_settings', 'wpconsent_save_settings_nonce' ); ?>

🙂

', '' ) ?>


metabox_row( esc_html__( 'License Key', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_license_key_field(), 'wpconsent-setting-license-key' ); return ob_get_clean(); } /** * Get the TCF notice for the Consent Settings section. * * Returns an empty string by default. Pro classes override this when IAB TCF is enabled. * * @return string */ protected function get_tcf_consent_settings_notice() { return ''; } /** * Get the settings metabox. * * @return string */ public function get_settings_metabox() { ob_start(); echo $this->get_tcf_consent_settings_notice(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped $this->metabox_row( esc_html__( 'Consent Banner', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_checkbox_toggle( wpconsent()->settings->get_option( 'enable_consent_banner' ), 'enable_consent_banner', esc_html__( 'Enable displaying the consent banner on your website.', 'wpconsent-cookies-banner-privacy-suite' ) ), 'enable_consent_banner', '', '', '', false, '', $this->is_tcf_field_locked( 'enable_consent_banner' ) ); $this->metabox_row( esc_html__( 'Script Blocking', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_checkbox_toggle( wpconsent()->settings->get_option( 'enable_script_blocking' ), 'enable_script_blocking', sprintf( // translators: %1$s is an opening link tag, %2$s is a closing link tag. esc_html__( 'Prevent known scripts from adding cookies before consent is given. %1$sLearn More%2$s', 'wpconsent-cookies-banner-privacy-suite' ), '', '' ) ) . $this->help_icon( __( 'Script blocking is not available without displaying the banner', 'wpconsent-cookies-banner-privacy-suite' ), false ), 'enable_script_blocking', '', '', '', false, '', $this->is_tcf_field_locked( 'enable_script_blocking' ) ); $this->metabox_row( esc_html__( 'Google Consent Mode', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_checkbox_toggle( wpconsent()->settings->get_option( 'google_consent_mode', true ), 'google_consent_mode', sprintf( // translators: %1$s is an opening link tag, %2$s is a closing link tag. esc_html__( 'Use services like Google Analytics and Google ads without cookies until consent is given. %1$sLearn More%2$s', 'wpconsent-cookies-banner-privacy-suite' ), '', '' ) ) . $this->help_icon( __( 'Google Consent Mode will not be loaded if the banner is disabled.', 'wpconsent-cookies-banner-privacy-suite' ), false ), 'google_consent_mode', '', '', '', false, '', $this->is_tcf_field_locked( 'google_consent_mode' ) ); $this->metabox_row( esc_html__( 'Settings Button', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_checkbox_toggle( wpconsent()->settings->get_option( 'enable_consent_floating' ), 'enable_consent_floating', esc_html__( 'Show a floating button to manage consent after the banner is dismissed.', 'wpconsent-cookies-banner-privacy-suite' ) ), 'enable_consent_floating', '', '', '', false, '', $this->is_tcf_field_locked( 'enable_consent_floating' ) ); $this->metabox_row( esc_html__( 'Default Allow', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_checkbox_toggle( wpconsent()->settings->get_option( 'default_allow' ), 'default_allow', sprintf( // translators: %1$s is an opening link tag, %2$s is a closing link tag. esc_html__( 'Enable this to only block scripts/cookies if the user rejects them. %1$sLearn More%2$s', 'wpconsent-cookies-banner-privacy-suite' ), '', '' ) ), 'default_allow', '', '', '', false, '', $this->is_tcf_field_locked( 'default_allow' ) ); $this->metabox_row( esc_html__( 'Toggle Services', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_checkbox_toggle( wpconsent()->settings->get_option( 'manual_toggle_services' ), 'manual_toggle_services', esc_html__( 'Allow site visitors to toggle individual services from the preferences panel.', 'wpconsent-cookies-banner-privacy-suite' ) ), 'manual_toggle_services', '', '', '', false, '', $this->is_tcf_field_locked( 'manual_toggle_services' ) ); $this->metabox_row_separator(); $this->metabox_row( esc_html__( 'Cookie Categories', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_cookie_categories_input() ); $this->metabox_row_separator(); $this->metabox_row( esc_html__( 'Cookie Policy', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_cookie_policy_input(), '', '', '', '', false, 'cookie-policy-input' ); $this->metabox_row_separator(); $this->metabox_row( esc_html__( 'Content Blocking', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_checkbox_toggle( wpconsent()->settings->get_option( 'enable_content_blocking' ), 'enable_content_blocking', esc_html__( 'Block 3rd party services that use iframes from being loaded before consent is given.', 'wpconsent-cookies-banner-privacy-suite' ) ), 'enable_content_blocking' ); $this->metabox_row( esc_html__( 'Content to Block', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_content_blocking_input(), '', '#enable_content_blocking', '1', esc_html__( 'Choose which content providers to automatically block.', 'wpconsent-cookies-banner-privacy-suite' ), false, 'content_blocking' ); $this->metabox_row( esc_html__( 'Placeholder Button', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_input_text( 'content_blocking_placeholder_text', wpconsent()->settings->get_option( 'content_blocking_placeholder_text', wpconsent()->strings->get_string( 'content_blocking_placeholder_text' ) ) ), 'content_blocking_placeholder_text', '#enable_content_blocking', '1', sprintf( // Translators: %s is the {category} tag wrapped in a code tag. esc_html__( 'Customize the text shown on the placeholder button. Use %s to insert the cookie category name.', 'wpconsent-cookies-banner-privacy-suite' ), '{category}' ) ); $this->metabox_row_separator(); $this->metabox_row( esc_html__( 'Consent Duration', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_input_number( 'consent_duration', wpconsent()->settings->get_option( 'consent_duration', 30 ) ), 'consent_duration', '', '', esc_html__( 'The duration of the consent given by the user (in days).', 'wpconsent-cookies-banner-privacy-suite' ) ); $this->metabox_row_separator(); $this->records_of_consent_input(); return ob_get_clean(); } /** * Get the input for enabling records of consent. * * @return void */ public function records_of_consent_input() { $this->metabox_row( esc_html__( 'Consent Logs', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_checkbox_toggle( false, 'wpconsent-records-of-consent-lite', esc_html__( 'Enable keeping records of consent for all visitors that give consent.', 'wpconsent-cookies-banner-privacy-suite' ) ), 'wpconsent-records-of-consent-lite', '', '', '', true ); } /** * Manage cookie categories. * * @return string */ public function get_cookie_categories_input() { ob_start(); $categories = wpconsent()->cookies->get_categories(); ?>
cookies->get_categories(); ?>
cookies->get_cookies_by_category( $category['id'] ); ?>

cookies->get_services_by_category( $category['id'] ); foreach ( $services as $service ) { ?>
get_service_library_button( $category ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
metabox( __( 'Cookies Configuration', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_cookies_input() ); } /** * Output the footer. * * @return void */ public function output_footer() { parent::output_footer(); $footer_method = 'output_footer_' . $this->view; if ( method_exists( $this, $footer_method ) ) { call_user_func( array( $this, $footer_method ) ); } } /** * Output the footer for the settings view. * * @return void */ public function output_footer_settings() { ?>

metabox_row( esc_html__( 'Category Name', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_input_text( 'category_name' ) ); $this->metabox_row( esc_html__( 'Description', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_input_textarea( 'category_description' ) ); ?>

cookies->get_categories(); $select_options = array(); foreach ( $categories as $category ) { $select_options[ $category['id'] ] = $category['name']; } $this->metabox_row( esc_html__( 'Category', 'wpconsent-cookies-banner-privacy-suite' ), $this->select( 'service_category', $select_options ) ); $this->metabox_row( esc_html__( 'Service Name', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_input_text( 'service_name' ) ); $this->metabox_row( esc_html__( 'Description', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_input_textarea( 'service_description' ) ); $this->metabox_row( esc_html__( 'Privacy Policy URL', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_input_text( 'service_url' ) ); ?>
esc_html__( 'No service', 'wpconsent-cookies-banner-privacy-suite' ), ); } /** * Get the cookie policy input. * * @return string */ public function get_cookie_policy_input() { ob_start(); $selected_page_id = wpconsent()->settings->get_option( 'cookie_policy_page' ); $selected_page = $selected_page_id ? get_post( $selected_page_id ) : null; $pages_args = array( 'number' => 20, 'orderby' => 'title', 'order' => 'ASC', ); if ( ! empty( $selected_page_id ) ) { $pages_args['exclude'] = array( $selected_page_id ); } // Let's pre-load 20 pages. $pages = get_pages( $pages_args ); ?>
[wpconsent_cookie_policy]' ); ?>
metabox( esc_html__( 'Language Settings', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_language_settings_content() ); wp_nonce_field( 'wpconsent_save_language_settings', 'wpconsent_save_language_settings_nonce' ); ?>
' . esc_html__( 'Upgrade to WPConsent PRO today and easily manage content in multiple languages. Automatic AI-powered translations get you set up with a new language in minutes.', 'wpconsent-cookies-banner-privacy-suite' ) . '

', array( 'text' => esc_html__( 'Upgrade to PRO and Unlock Languages', 'wpconsent-cookies-banner-privacy-suite' ), 'url' => esc_url( wpconsent_utm_url( 'https://wpconsent.com/lite/', 'languages-page', 'main' ) ), ), array( 'text' => esc_html__( 'Learn more about all the features', 'wpconsent-cookies-banner-privacy-suite' ), 'url' => esc_url( wpconsent_utm_url( 'https://wpconsent.com/lite/', 'languages-page', 'features' ) ), ) ); ?>

'en_US', 'english_name' => 'English (United States)', 'native_name' => 'English (United States)', ); // Get WordPress default language. $default_language = get_locale(); $enabled_languages = array( $default_language ); // Sort languages into selected and unselected. $selected_languages = array(); $unselected_languages = array(); foreach ( $available_languages as $locale => $language ) { if ( in_array( $locale, $enabled_languages, true ) ) { $selected_languages[ $locale ] = $language; } else { $unselected_languages[ $locale ] = $language; } } // Sort both arrays alphabetically by English name. uasort( $selected_languages, function ( $a, $b ) { return strcmp( $a['english_name'], $b['english_name'] ); } ); uasort( $unselected_languages, function ( $a, $b ) { return strcmp( $a['english_name'], $b['english_name'] ); } ); ?>

$language ) : $is_default = $locale === $default_language; $this->output_language_item( $locale, $language, $is_default, true ); endforeach; ?>
$language ) : $is_default = $locale === $default_language; $this->output_language_item( $locale, $language, $is_default, false ); endforeach; ?>
metabox_row( esc_html__( 'Language Picker', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_checkbox_toggle( true, 'show_language_picker', esc_html__( 'Show a language picker in the consent banner', 'wpconsent-cookies-banner-privacy-suite' ) ), 'show_language_picker', '', '', esc_html__( 'This will show a globe icon in the header of the consent banner, allowing users to switch between languages just for the banner/preferences panel even if you do not use a translation plugin. If you are using a translation plugin the banner should automatically display the content in the selected language, if available.', 'wpconsent-cookies-banner-privacy-suite' ) ); return ob_get_clean(); } /** * The input to choose which content to be blocked. * * @return string */ public function get_content_blocking_input() { $content_blocking_services = wpconsent()->script_blocker->get_content_blocking_providers(); $currently_blocking = wpconsent()->settings->get_option( 'content_blocking_services', array() ); ob_start(); ?>
$service ) { $is_enabled = empty( $currently_blocking ) || in_array( $service_id, $currently_blocking, true ); $this->metabox_row( esc_html( $service ), $this->get_checkbox_toggle( $is_enabled, 'content_blocking_services[]', '', $service_id ), 'content_blocking_services_' . $service_id ); } ?>
metabox( __( 'Custom Iframe/Scripts', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_custom_scripts_content() ); ?>
' . esc_html__( 'Upgrade to WPConsent PRO today and easily manage custom scripts and iframes. Take full control and block any scripts and iframes from loading until users give consent.', 'wpconsent-cookies-banner-privacy-suite' ) . '

', array( 'text' => esc_html__( 'Upgrade to PRO and Unlock Custom Scripts', 'wpconsent-cookies-banner-privacy-suite' ), 'url' => esc_url( wpconsent_utm_url( 'https://wpconsent.com/lite/', 'advanced-page', 'main' ) ), ), array( 'text' => esc_html__( 'Learn more about all the features', 'wpconsent-cookies-banner-privacy-suite' ), 'url' => esc_url( wpconsent_utm_url( 'https://wpconsent.com/lite/', 'advanced-page', 'features' ) ), ) ); ?>
metabox( __( 'Hide Banner Rules', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_display_rules_content_lite() ); ?>
' . esc_html__( 'Control where and to whom the cookie banner is displayed. Hide the banner for specific user roles or on certain pages to improve user experience.', 'wpconsent-cookies-banner-privacy-suite' ) . '

', array( 'text' => esc_html__( 'Upgrade to PRO and Unlock Hide Banner Rules', 'wpconsent-cookies-banner-privacy-suite' ), 'url' => esc_url( wpconsent_utm_url( 'https://wpconsent.com/lite/', 'advanced-page', 'hide-banner-rules' ) ), ), array( 'text' => esc_html__( 'Learn more about all the features', 'wpconsent-cookies-banner-privacy-suite' ), 'url' => esc_url( wpconsent_utm_url( 'https://wpconsent.com/lite/', 'advanced-page', 'features' ) ), ) ); ?>
metabox( __( 'Advanced Settings', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_advanced_settings_content() ); ?>

'custom_1', 'service' => 'Some Service', 'type' => 'script', 'tag' => '1234', 'blocked_elements' => 'script[src*="yourservice.com"]', 'category' => 'statistics', ), array( 'id' => 'custom_2', 'service' => 'Other Pixel', 'type' => 'script', 'tag' => 'abc', 'blocked_elements' => 'script[src*="otherservice.com"]', 'category' => 'statistics', ), ); // Fetch categories from the database. $all_categories = wpconsent()->cookies->get_categories(); $categories = array(); if ( isset( $all_categories['statistics'] ) ) { $categories[ $all_categories['statistics']['id'] ] = array( 'name' => esc_html( $all_categories['statistics']['name'] ) . ' ' . esc_html__( 'Scripts', 'wpconsent-cookies-banner-privacy-suite' ), 'description' => esc_html__( 'Add scripts for analytics and statistics tracking.', 'wpconsent-cookies-banner-privacy-suite' ), ); } if ( isset( $all_categories['marketing'] ) ) { $categories[ $all_categories['marketing']['id'] ] = array( 'name' => esc_html( $all_categories['marketing']['name'] ) . ' ' . esc_html__( 'Scripts', 'wpconsent-cookies-banner-privacy-suite' ), 'description' => esc_html__( 'Add scripts for marketing and advertising purposes.', 'wpconsent-cookies-banner-privacy-suite' ), ); } foreach ( $categories as $category_id => $category ) { ?>

metabox_row( esc_html__( 'Clarity Consent Mode', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_checkbox_toggle( wpconsent()->settings->get_option( 'clarity_consent_mode', true ), 'clarity_consent_mode', sprintf( // translators: %1$s is an opening link tag, %2$s is a closing link tag. esc_html__( 'Use Microsoft Clarity without cookies until consent is given. %1$sLearn More%2$s', 'wpconsent-cookies-banner-privacy-suite' ), '', '' ) ) . $this->help_icon( __( 'Clarity Consent Mode will not be loaded if the banner is disabled.', 'wpconsent-cookies-banner-privacy-suite' ), false ), 'clarity_consent_mode' ); $this->metabox_row( esc_html__( 'Shared Consent', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_checkbox_toggle( wpconsent()->settings->get_option( 'enable_shared_consent' ), 'enable_shared_consent', esc_html__( 'Share cookie preferences across all subdomains. MUST be enabled on all subdomain sites using WPConsent.', 'wpconsent-cookies-banner-privacy-suite' ) ) . $this->help_icon( __( 'Preferences set on example.com will automatically apply to blog.example.com, shop.example.com, and any other subdomain. All subdomain sites must have this setting enabled.', 'wpconsent-cookies-banner-privacy-suite' ), false ), 'enable_shared_consent' ); $this->metabox_row( esc_html__( 'Respect Global Privacy Controls', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_checkbox_toggle( wpconsent()->settings->get_option( 'respect_gpc', false ), 'respect_gpc', esc_html__( 'Automatically respect Global Privacy Control (GPC) signals from user browsers.', 'wpconsent-cookies-banner-privacy-suite' ) ) . $this->help_icon( __( 'When enabled, users with GPC enabled in their browser will automatically have non-essential cookies declined and will not see the consent banner. This helps comply with privacy regulations by respecting user-set privacy preferences.', 'wpconsent-cookies-banner-privacy-suite' ), false ), 'respect_gpc' ); $this->usage_tracking_input(); $this->metabox_row( esc_html__( 'Reset to Defaults', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_reset_banner_content_button(), '', '', '', '', false, 'reset-banner-content' ); $this->metabox_row( esc_html__( 'Remove all data', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_checkbox_toggle( wpconsent()->settings->get_option( 'uninstall_data', false ), 'uninstall_data', esc_html__( 'Remove all data when uninstalling the plugin.', 'wpconsent-cookies-banner-privacy-suite' ) ) . $this->help_icon( __( 'All cookie data and configuration will be unrecoverable.', 'wpconsent-cookies-banner-privacy-suite' ), false ), 'uninstall_data' ); return ob_get_clean(); } /** * Get the reset banner content button. * * @return string */ public function get_reset_banner_content_button() { ob_start(); ?>
metabox_row( esc_html__( 'Allow Usage Tracking', 'wpconsent-cookies-banner-privacy-suite' ), $this->get_checkbox_toggle( wpconsent()->settings->get_option( 'usage_tracking' ), 'usage_tracking', esc_html__( 'By allowing us to track usage data, we can better help you, as we will know which WordPress configurations, themes, and plugins we should test.', 'wpconsent-cookies-banner-privacy-suite' ) ), 'usage_tracking' ); } /** * Output the IAB TCF view. * * @return void */ public function output_view_iabtcf() { // Get dummy data for preview. $dummy_data = $this->get_iab_tcf_dummy_data(); ?>
output_iab_tcf_preview( $dummy_data ); ?>
' . esc_html__( 'Upgrade to WPConsent PRO today to enable IAB Transparency & Consent Framework v2.2 support. Manage vendor consents, publisher restrictions, and ensure compliance with the TCF specification.', 'wpconsent-cookies-banner-privacy-suite' ) . '

', array( 'text' => esc_html__( 'Upgrade to PRO and Unlock IAB TCF', 'wpconsent-cookies-banner-privacy-suite' ), 'url' => esc_url( wpconsent_utm_url( 'https://wpconsent.com/lite/', 'iab-tcf-page', 'main' ) ), ), array( 'text' => esc_html__( 'Learn more about all the features', 'wpconsent-cookies-banner-privacy-suite' ), 'url' => esc_url( wpconsent_utm_url( 'https://wpconsent.com/lite/', 'iab-tcf-page', 'features' ) ), ) ); ?>
array( 1 => array( 'name' => 'Store and/or access information on a device' ), 2 => array( 'name' => 'Select basic ads' ), 3 => array( 'name' => 'Create a personalised ads profile' ), 4 => array( 'name' => 'Select personalised ads' ), 5 => array( 'name' => 'Create a personalised content profile' ), 6 => array( 'name' => 'Select personalised content' ), 7 => array( 'name' => 'Measure ad performance' ), 8 => array( 'name' => 'Measure content performance' ), 9 => array( 'name' => 'Apply market research to generate audience insights' ), 10 => array( 'name' => 'Develop and improve products' ), ), 'special_purposes' => array( 1 => array( 'name' => 'Ensure security, prevent fraud, and debug' ), 2 => array( 'name' => 'Technically deliver ads or content' ), ), ); } /** * Output IAB TCF preview with dummy data for lite version. * * @param array $dummy_data Dummy data for preview. * * @return void */ protected function output_iab_tcf_preview( $dummy_data ) { $purposes = $dummy_data['purposes']; ?>
'; $toggle_html .= ''; $toggle_html .= ''; $toggle_html .= ''; $this->metabox_row( __( 'Enable TCF on Frontend', 'wpconsent-cookies-banner-privacy-suite' ), $toggle_html, 'iab_tcf_frontend_enabled', '', '', __( 'Enable this setting to load the IAB TCF (Transparency and Consent Framework) on the frontend of your website.', 'wpconsent-cookies-banner-privacy-suite' ) ); $frontend_content = ob_get_clean(); $this->metabox( __( 'TCF Activation', 'wpconsent-cookies-banner-privacy-suite' ), $frontend_content ); ?> output_global_vendor_restrictions_preview( $purposes ); ?> output_publisher_declarations_preview( $purposes ); ?>
'; $li_select .= ''; $li_select .= ''; $li_select .= ''; $li_select .= ''; $this->metabox_row( __( 'Legitimate Interest', 'wpconsent-cookies-banner-privacy-suite' ), $li_select, 'global_disallow_li', '', '', __( 'Control whether vendors can use legitimate interest as a legal basis for data processing.', 'wpconsent-cookies-banner-privacy-suite' ) ); ?> metabox( __( 'Global Vendor Restrictions', 'wpconsent-cookies-banner-privacy-suite' ), $content, __( 'Apply restrictions to all vendors at once. These settings allow you to enforce stricter data policies across all selected vendors.', 'wpconsent-cookies-banner-privacy-suite' ) ); } /** * Output publisher data processing declarations section for preview. * * @param array $purposes The purposes array. * * @return void */ protected function output_publisher_declarations_preview( $purposes ) { // Default all purposes to enabled for preview. $purposes_consent = array_keys( $purposes ); // Default legitimate interest purposes to enabled (only 2, 7, 9, 10 are allowed per TCF policy). $li_allowed_purposes = array( 2, 7, 9, 10 ); $purposes_li = $li_allowed_purposes; // Buffer the metabox content. ob_start(); ?>

metabox( __( 'Publisher Data Processing Declarations', 'wpconsent-cookies-banner-privacy-suite' ), $content, __( 'Declare which TCF purposes your website uses for its own data processing. These declarations are encoded in the TC String and communicated to vendors.', 'wpconsent-cookies-banner-privacy-suite' ) ); } /** * Output vendor controls (search, filters, sorting) for preview. * * @param int $total_vendors Total number of vendors. * * @return void */ protected function output_vendor_controls_preview( $total_vendors ) { ?>
'; $li_select .= ''; $li_select .= ''; $li_select .= ''; $li_select .= ''; $this->metabox_row( __( 'Legitimate Interest', 'wpconsent-cookies-banner-privacy-suite' ), $li_select, 'global_disallow_li', '', '', __( 'Control whether vendors can use legitimate interest as a legal basis for data processing.', 'wpconsent-cookies-banner-privacy-suite' ) ); // Purpose checkboxes (conditional). $show_if_style = ( ! empty( $disallow_li_purposes ) && ! in_array( 'all', $disallow_li_purposes, true ) ) ? '' : 'display: none;'; ?>
$purpose ) : ?>
metabox( __( 'Global Vendor Restrictions', 'wpconsent-cookies-banner-privacy-suite' ), $content, __( 'Apply restrictions to all vendors at once. These settings allow you to enforce stricter data policies across all selected vendors.', 'wpconsent-cookies-banner-privacy-suite' ) ); } /** * Output publisher data processing declarations section. * * @param array $purposes The purposes array. * * @return void */ protected function output_publisher_declarations( $purposes ) { // Get saved publisher declarations. $declarations = wpconsent()->settings->get_option( 'iab_tcf_publisher_declarations', array() ); // Check if this is the first time (no saved declarations). If so, enable all by default. $is_first_time = empty( $declarations ); if ( $is_first_time ) { // Default all purposes to enabled. $purposes_consent = array_keys( $purposes ); // Default legitimate interest purposes to enabled (only 2, 7, 9, 10 are allowed per TCF policy). $li_allowed_purposes = array( 2, 7, 9, 10 ); $purposes_li = array_intersect( $li_allowed_purposes, array_keys( $purposes ) ); } else { // Load saved values. $purposes_consent = isset( $declarations['purposes_consent'] ) ? $declarations['purposes_consent'] : array(); $purposes_li = isset( $declarations['purposes_li_transparency'] ) ? $declarations['purposes_li_transparency'] : array(); } // Buffer the metabox content. ob_start(); ?>

metabox( __( 'Publisher Data Processing Declarations', 'wpconsent-cookies-banner-privacy-suite' ), $content, __( 'Declare which TCF purposes your website uses for its own data processing. These declarations are encoded in the TC String and communicated to vendors.', 'wpconsent-cookies-banner-privacy-suite' ) ); } }