PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 4.5.0
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v4.5.0
4.7.2 4.7.1 trunk 2.3.0 2.4.0 2.4.1 2.4.2 2.5.0 3.0.0 3.0.1 3.1.0 3.10.0 3.10.1 3.11.1 3.11.2 3.11.3 3.2.0 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.1 3.6.2 3.6.5 3.6.6 3.7.0 3.7.1 3.8.0 3.9.0 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.2.0 4.2.1 4.2.10 4.2.11 4.2.12 4.2.13 4.2.14 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.3.10 4.3.11 4.3.12 4.3.2 4.3.3 4.3.4 4.3.5 4.3.6 4.3.7 4.3.7.1 4.3.8 4.3.9 4.3.9.1 4.4.0 4.4.1 4.4.2 4.5.0 4.5.1 4.5.10 4.5.11 4.5.2 4.5.3 4.5.4 4.5.5 4.5.6 4.5.7 4.5.8 4.5.9 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.6.7 4.7.0
cookiebot / src / settings / pages / Dashboard_Page.php
cookiebot / src / settings / pages Last commit date
Additional_Page.php 1 year ago Dashboard_Page.php 1 year ago Debug_Page.php 1 year ago Embeddings_Page.php 1 year ago Gcm_Page.php 1 year ago General_Page.php 1 year ago Gtm_Page.php 1 year ago Iab_Page.php 1 year ago Multiple_Page.php 1 year ago Settings_Page.php 1 year ago Settings_Page_Interface.php 1 year ago Support_Page.php 1 year ago
Dashboard_Page.php
181 lines
1 <?php
2
3 namespace cybot\cookiebot\settings\pages;
4
5 use cybot\cookiebot\lib\Cookiebot_Frame;
6 use cybot\cookiebot\lib\Cookiebot_WP;
7 use InvalidArgumentException;
8 use function cybot\cookiebot\lib\include_view;
9
10 // Import WordPress functions from global namespace
11 use function \add_menu_page;
12 use function \add_submenu_page;
13 use function \do_action;
14 use function \wp_enqueue_style;
15 use function \wp_enqueue_script;
16 use function \wp_localize_script;
17 use function \admin_url;
18 use function \wp_create_nonce;
19 use function \__;
20 use function \defined;
21 use function \constant;
22
23 // Add constant for WP_DEBUG
24 if ( ! defined( 'WP_DEBUG' ) ) {
25 define( 'WP_DEBUG', false );
26 }
27
28 class Dashboard_Page implements Settings_Page_Interface {
29
30
31 const ICON = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA0MCA0MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgY2xpcC1wYXRoPSJ1cmwoI2NsaXAwXzY0ODFfMzE4MTUpIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01Ljg2MTYgNS44MDUyVjE5LjgxMTRDNS44NjE2IDI3LjUzNjMgMTIuMjAzOSAzMy44MTc2IDIwLjAwMzkgMzMuODE3NkMyNy44MDM4IDMzLjgxNzYgMzQuMTQ2MiAyNy41MzYzIDM0LjE0NjIgMTkuODExNFY1LjgwNTJINS44NjE2Wk0yMCAzOS42MjI4QzguOTc2MzggMzkuNjIwNyAwIDMwLjczNzEgMCAxOS44MTE0VjBINDBWMTkuODExNEM0MCAzMC43Mjk0IDMxLjAzMTQgMzkuNjIwNyAyMCAzOS42MjI4Wk0yMi42ODk0IDI2Ljk0ODZMMjIuNjg4OCAyNi45NDk5SDE1LjkyTDE1LjkzMTIgMjYuOTI2Nkw5Ljk4OTIxIDE2LjU4MjFIMTYuNzY1N0wxOS4wMTA2IDIwLjQ5MDJMMjMuNzEyMiAxMC42NjMxSDMwLjQ4ODhMMjIuNzAzNSAyNi45MTkyTDIyLjcyMDQgMjYuOTQ4NkgyMi42ODk0WiIgZmlsbD0iYmxhY2siLz4KPC9nPgo8ZGVmcz4KPGNsaXBQYXRoIGlkPSJjbGlwMF82NDgxXzMxODE1Ij4KPHJlY3Qgd2lkdGg9IjQwIiBoZWlnaHQ9IjQwIiBmaWxsPSJ3aGl0ZSIvPgo8L2NsaXBQYXRoPgo8L2RlZnM+Cjwvc3ZnPgo=';
32
33 const ADMIN_SLUG = 'cookiebot';
34
35 public function menu() {
36 add_menu_page(
37 'Cookiebot',
38 __( 'Cookiebot', 'cookiebot' ),
39 'manage_options',
40 self::ADMIN_SLUG,
41 array( $this, 'display' ),
42 self::ICON
43 );
44
45 if ( Cookiebot_Frame::is_cb_frame_type() !== 'empty' ) {
46 add_submenu_page(
47 'cookiebot',
48 __( 'Cookiebot Dashboard', 'cookiebot' ),
49 __( 'Dashboard', 'cookiebot' ),
50 'manage_options',
51 self::ADMIN_SLUG,
52 array( $this, 'display' ),
53 1
54 );
55 }
56 }
57
58 /**
59 * @throws InvalidArgumentException
60 */
61 public function display() {
62 // Get all necessary data upfront
63 $cbid = Cookiebot_WP::get_cbid();
64 $user_data = Cookiebot_WP::get_user_data();
65 $scan_status = Cookiebot_WP::get_scan_status();
66 $banner_enabled = Cookiebot_WP::get_banner_enabled();
67 $gcm_enabled = Cookiebot_WP::get_gcm_enabled();
68 $subscription = Cookiebot_WP::get_subscription_type();
69 $legal_framework = Cookiebot_WP::get_legal_framwework();
70
71 // Get user data and check if they were onboarded via signup
72 $was_onboarded = isset( $user_data['onboarded_via_signup'] ) && $user_data['onboarded_via_signup'] === true;
73 $user_email = isset( $user_data['email'] ) ? $user_data['email'] : '';
74
75 // Prepare variables for the template
76 $template_args = array(
77 'cbid' => $cbid,
78 'user_data' => $user_data,
79 'scan_status' => $scan_status,
80 'cb_wp' => CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/img/cb-wp.png',
81 'europe_icon' => CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/img/europe.png',
82 'usa_icon' => CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/img/usa.png',
83 'check_icon' => CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/img/icons/check.svg',
84 'link_icon' => CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/img/icons/link.svg',
85 'banner_enabled' => $banner_enabled,
86 'gcm_enabled' => $gcm_enabled,
87 'preview_link' => Cookiebot_WP::get_preview_link(),
88 'subscription' => $subscription,
89 'legal_framework' => $legal_framework,
90 'customize_banner_link' => 'https://admin.usercentrics.eu/#/v3/appearance/layout?settingsId=' . $cbid,
91 'cookiebot_admin_link' => 'https://admin.cookiebot.com',
92 'uc_admin_link' => 'https://admin.usercentrics.eu',
93 'configure_banner_link' => 'https://support.usercentrics.com/hc/en-us/articles/18225055002908-WordPress-Plugin-FAQ',
94 'has_user_data' => ! empty( $user_data ),
95 'has_cbid' => ! empty( $cbid ),
96 'is_authenticated' => ! empty( Cookiebot_WP::get_auth_token() ),
97 'was_onboarded' => $was_onboarded,
98 'user_email' => $user_email,
99 );
100
101 // Modified condition to check for onboarding status
102 if ( ! empty( $cbid ) && ( empty( $user_data ) && ! $was_onboarded ) ) {
103 wp_enqueue_style(
104 'cookiebot-dashboard-backup-css',
105 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/css/backend/dashboard-old.css',
106 array(),
107 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION
108 );
109
110 wp_enqueue_script(
111 'cookiebot-account-js',
112 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/js/backend/account.js',
113 array( 'jquery' ),
114 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION,
115 true
116 );
117
118 wp_localize_script(
119 'cookiebot-account-js',
120 'cookiebot_account',
121 array(
122 'ajax_url' => admin_url( 'admin-ajax.php' ),
123 'nonce' => wp_create_nonce( 'cookiebot-account' ),
124 'cbid' => $cbid,
125 'has_user_data' => ! empty( $user_data ),
126 'has_cbid' => ! empty( $cbid ),
127 'debug' => defined( 'WP_DEBUG' ) && WP_DEBUG,
128 )
129 );
130
131 require_once CYBOT_COOKIEBOT_PLUGIN_DIR . 'src/view/admin/common/dashboard-page-old.php';
132 return;
133 }
134
135 wp_enqueue_style(
136 'cookiebot-dashboard-css',
137 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/css/backend/dashboard.css',
138 array(),
139 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION
140 );
141
142 wp_enqueue_script(
143 'cookiebot-dashboard-js',
144 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/js/backend/dashboard.js',
145 array( 'jquery' ),
146 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION,
147 true
148 );
149
150 wp_enqueue_script(
151 'cookiebot-account-js',
152 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/js/backend/account.js',
153 array( 'jquery' ),
154 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION,
155 true
156 );
157
158 wp_localize_script(
159 'cookiebot-account-js',
160 'cookiebot_account',
161 array(
162 'ajax_url' => admin_url( 'admin-ajax.php' ),
163 'nonce' => wp_create_nonce( 'cookiebot-account' ),
164 'cbid' => $cbid,
165 'has_user_data' => ! empty( $user_data ),
166 'has_cbid' => ! empty( $cbid ),
167 'is_authenticated' => ! empty( Cookiebot_WP::get_auth_token() ),
168 'messages' => array(
169 'success_create' => __( 'Account created successfully!', 'cookiebot' ),
170 'error_create' => __( 'Failed to create account.', 'cookiebot' ),
171 'success_verify' => __( 'CBID verified successfully!', 'cookiebot' ),
172 'error_verify' => __( 'Invalid CBID.', 'cookiebot' ),
173 ),
174 'debug' => defined( 'WP_DEBUG' ) && WP_DEBUG,
175 )
176 );
177
178 require_once CYBOT_COOKIEBOT_PLUGIN_DIR . 'src/view/admin/common/dashboard-page.php';
179 }
180 }
181