Dashboard_Page.php
1 year ago
Debug_Page.php
2 years ago
Gcm_Page.php
2 years ago
Gtm_Page.php
3 years ago
Iab_Page.php
1 year ago
Legislations_Page.php
4 years ago
Multiple_Page.php
3 years ago
Settings_Page.php
1 year ago
Settings_Page_Interface.php
3 years ago
Support_Page.php
3 years ago
Settings_Page.php
95 lines
| 1 | <?php |
| 2 | |
| 3 | namespace cybot\cookiebot\settings\pages; |
| 4 | |
| 5 | use cybot\cookiebot\lib\Cookiebot_WP; |
| 6 | use cybot\cookiebot\lib\Consent_API_Helper; |
| 7 | use cybot\cookiebot\lib\Supported_Languages; |
| 8 | use InvalidArgumentException; |
| 9 | use function cybot\cookiebot\lib\include_view; |
| 10 | use function cybot\cookiebot\lib\asset_url; |
| 11 | use function cybot\cookiebot\lib\cookiebot_get_language_from_setting; |
| 12 | |
| 13 | class Settings_Page implements Settings_Page_Interface { |
| 14 | |
| 15 | const ICON = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA0MCA0MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgY2xpcC1wYXRoPSJ1cmwoI2NsaXAwXzY0ODFfMzE4MTUpIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01Ljg2MTYgNS44MDUyVjE5LjgxMTRDNS44NjE2IDI3LjUzNjMgMTIuMjAzOSAzMy44MTc2IDIwLjAwMzkgMzMuODE3NkMyNy44MDM4IDMzLjgxNzYgMzQuMTQ2MiAyNy41MzYzIDM0LjE0NjIgMTkuODExNFY1LjgwNTJINS44NjE2Wk0yMCAzOS42MjI4QzguOTc2MzggMzkuNjIwNyAwIDMwLjczNzEgMCAxOS44MTE0VjBINDBWMTkuODExNEM0MCAzMC43Mjk0IDMxLjAzMTQgMzkuNjIwNyAyMCAzOS42MjI4Wk0yMi42ODk0IDI2Ljk0ODZMMjIuNjg4OCAyNi45NDk5SDE1LjkyTDE1LjkzMTIgMjYuOTI2Nkw5Ljk4OTIxIDE2LjU4MjFIMTYuNzY1N0wxOS4wMTA2IDIwLjQ5MDJMMjMuNzEyMiAxMC42NjMxSDMwLjQ4ODhMMjIuNzAzNSAyNi45MTkyTDIyLjcyMDQgMjYuOTQ4NkgyMi42ODk0WiIgZmlsbD0iYmxhY2siLz4KPC9nPgo8ZGVmcz4KPGNsaXBQYXRoIGlkPSJjbGlwMF82NDgxXzMxODE1Ij4KPHJlY3Qgd2lkdGg9IjQwIiBoZWlnaHQ9IjQwIiBmaWxsPSJ3aGl0ZSIvPgo8L2NsaXBQYXRoPgo8L2RlZnM+Cjwvc3ZnPgo='; |
| 16 | |
| 17 | const ADMIN_SLUG = 'cookiebot_settings'; |
| 18 | |
| 19 | public function menu() { |
| 20 | add_submenu_page( |
| 21 | 'cookiebot', |
| 22 | __( 'Cookiebot Settings', 'cookiebot' ), |
| 23 | __( 'Settings', 'cookiebot' ), |
| 24 | 'manage_options', |
| 25 | self::ADMIN_SLUG, |
| 26 | array( |
| 27 | $this, |
| 28 | 'display', |
| 29 | ), |
| 30 | 2 |
| 31 | ); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * @throws InvalidArgumentException |
| 36 | */ |
| 37 | public function display() { |
| 38 | $consent_api_helper = new Consent_API_Helper(); |
| 39 | |
| 40 | $args = array( |
| 41 | 'cbid' => Cookiebot_WP::get_cbid(), |
| 42 | 'is_ms' => false, |
| 43 | 'cookiebot_gdpr_url' => 'https://www.cookiebot.com/' . Cookiebot_WP::get_manager_language() . '/gdpr/?utm_source=wordpress&utm_medium=referral&utm_campaign=banner', |
| 44 | 'cookiebot_logo' => CYBOT_COOKIEBOT_PLUGIN_URL . 'cookiebot-logo.png', |
| 45 | 'supported_languages' => Supported_Languages::get(), |
| 46 | 'current_lang' => cookiebot_get_language_from_setting( true ), |
| 47 | 'is_wp_consent_api_active' => $consent_api_helper->is_wp_consent_api_active(), |
| 48 | 'm_default' => $consent_api_helper->get_default_wp_consent_api_mapping(), |
| 49 | 'm' => $consent_api_helper->get_wp_consent_api_mapping(), |
| 50 | 'cookie_blocking_mode' => Cookiebot_WP::get_cookie_blocking_mode(), |
| 51 | 'network_auto' => Cookiebot_WP::check_network_auto_blocking_mode(), |
| 52 | 'add_language_gif_url' => asset_url( 'img/guide_add_language.gif' ), |
| 53 | ); |
| 54 | |
| 55 | /* Check if multisite */ |
| 56 | if ( is_multisite() ) { |
| 57 | // Receive settings from multisite - this might change the way we render the form |
| 58 | $args['network_cbid'] = get_site_option( 'cookiebot-cbid', '' ); |
| 59 | $args['network_scrip_tag_uc_attr'] = get_site_option( 'cookiebot-script-tag-uc-attribute', 'custom' ); |
| 60 | $args['network_scrip_tag_cd_attr'] = get_site_option( 'cookiebot-script-tag-cd-attribute', 'custom' ); |
| 61 | $args['is_ms'] = true; |
| 62 | } |
| 63 | |
| 64 | wp_enqueue_style( |
| 65 | 'cookiebot-consent-mapping-table', |
| 66 | asset_url( 'css/backend/consent_mapping_table.css' ), |
| 67 | null, |
| 68 | Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION |
| 69 | ); |
| 70 | |
| 71 | wp_enqueue_style( |
| 72 | 'cookiebot-settings-page-css', |
| 73 | asset_url( 'css/backend/settings-page.css' ), |
| 74 | null, |
| 75 | Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION |
| 76 | ); |
| 77 | |
| 78 | wp_enqueue_script( |
| 79 | 'cookiebot-settings-page-js', |
| 80 | asset_url( 'js/backend/settings-page.js' ), |
| 81 | null, |
| 82 | Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION, |
| 83 | true |
| 84 | ); |
| 85 | |
| 86 | wp_localize_script( |
| 87 | 'cookiebot-settings-page-js', |
| 88 | 'cookiebot_settings', |
| 89 | array( 'cookieBlockingMode' => $args['cookie_blocking_mode'] ) |
| 90 | ); |
| 91 | |
| 92 | include_view( 'admin/settings/settings-page.php', $args ); |
| 93 | } |
| 94 | } |
| 95 |