PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 4.5.5
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v4.5.5
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 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
280 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 $auth_token = Cookiebot_WP::get_auth_token();
65 $user_data = Cookiebot_WP::get_user_data();
66 $scan_status = Cookiebot_WP::get_scan_status();
67 $banner_enabled = Cookiebot_WP::get_banner_enabled();
68 $auto_blocking_mode = Cookiebot_WP::get_auto_blocking_mode();
69 $gcm_enabled = Cookiebot_WP::get_gcm_enabled();
70 $subscription = Cookiebot_WP::get_subscription_type();
71 $legal_framework = Cookiebot_WP::get_legal_framwework();
72 $is_authenticated = ! empty( Cookiebot_WP::get_auth_token() );
73
74 // Get user data and check if they were onboarded via signup
75 $was_onboarded = Cookiebot_WP::was_onboarded_via_signup();
76 $user_email = isset( $user_data['email'] ) ? $user_data['email'] : '';
77
78 // Prepare variables for the template
79 $template_args = array(
80 'cbid' => $cbid,
81 'user_data' => $user_data,
82 'scan_status' => $scan_status,
83 'cb_wp' => CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/img/cb-wp.png',
84 'europe_icon' => CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/img/europe.png',
85 'usa_icon' => CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/img/usa.png',
86 'check_icon' => CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/img/icons/check.svg',
87 'link_icon' => CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/img/icons/link.svg',
88 'banner_enabled' => $banner_enabled,
89 'auto_blocking_mode' => $auto_blocking_mode,
90 'gcm_enabled' => $gcm_enabled,
91 'preview_link' => Cookiebot_WP::get_preview_link(),
92 'subscription' => $subscription,
93 'legal_framework' => $legal_framework,
94 'customize_banner_link' => 'https://admin.usercentrics.eu/#/v3/appearance/layout?settingsId=' . $cbid,
95 'cookiebot_admin_link' => 'https://admin.cookiebot.com',
96 'uc_admin_link' => 'https://admin.usercentrics.eu',
97 'configure_banner_link' => 'https://support.usercentrics.com/hc/en-us/articles/18225055002908-WordPress-Plugin-FAQ',
98 'has_user_data' => ! empty( $user_data ),
99 'has_cbid' => ! empty( $cbid ),
100 'is_authenticated' => ! empty( Cookiebot_WP::get_auth_token() ),
101 'was_onboarded' => $was_onboarded,
102 'user_email' => $user_email,
103 );
104
105 wp_enqueue_script(
106 'cookiebot-amplitude-js',
107 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/js/backend/amplitude.js',
108 array( 'jquery' ),
109 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION,
110 true
111 );
112
113 wp_localize_script(
114 'cookiebot-amplitude-js',
115 'cookiebot_amplitude',
116 array()
117 );
118
119 if ( ! $is_authenticated && ! empty( $cbid ) && ! empty( $user_data ) && ! empty( $was_onboarded ) ) {
120 wp_enqueue_style(
121 'cookiebot-dashboard-css',
122 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/css/backend/dashboard.css',
123 array(),
124 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION
125 );
126
127 wp_enqueue_script(
128 'cookiebot-account-static-js',
129 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/js/backend/account-static.js',
130 array( 'jquery' ),
131 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION,
132 true
133 );
134
135 wp_localize_script(
136 'cookiebot-account-static-js',
137 'cookiebot_account',
138 array(
139 'ajax_url' => admin_url( 'admin-ajax.php' ),
140 'nonce' => wp_create_nonce( 'cookiebot-account' ),
141 'cbid' => $cbid,
142 'has_user_data' => ! empty( $user_data ),
143 'has_cbid' => ! empty( $cbid ),
144 'was_onboarded' => $was_onboarded,
145 'debug' => defined( 'WP_DEBUG' ) && WP_DEBUG,
146 'auth_expired_flow' => true,
147 )
148 );
149
150 require_once CYBOT_COOKIEBOT_PLUGIN_DIR . 'src/view/admin/common/dashboard-page-session-expired.php';
151 return;
152 }
153
154 // Check if the trial has expired
155 if ( Cookiebot_WP::is_trial_expired() && ! Cookiebot_WP::has_upgraded() ) {
156 wp_enqueue_style(
157 'cookiebot-dashboard-css',
158 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/css/backend/dashboard.css',
159 array(),
160 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION
161 );
162
163 wp_enqueue_script(
164 'cookiebot-account-js',
165 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/js/backend/account.js',
166 array( 'jquery' ),
167 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION,
168 true
169 );
170
171 wp_localize_script(
172 'cookiebot-account-js',
173 'cookiebot_account',
174 array(
175 'ajax_url' => admin_url( 'admin-ajax.php' ),
176 'nonce' => wp_create_nonce( 'cookiebot-account' ),
177 'cbid' => $cbid,
178 'has_user_data' => ! empty( $user_data ),
179 'has_cbid' => ! empty( $cbid ),
180 'was_onboarded' => $was_onboarded,
181 'debug' => defined( 'WP_DEBUG' ) && WP_DEBUG,
182 )
183 );
184
185 require_once CYBOT_COOKIEBOT_PLUGIN_DIR . 'src/view/admin/common/dashboard-trial-expired.php';
186 return;
187 }
188
189 // Modified condition to check for onboarding status
190 if ( ! empty( $cbid ) && ( empty( $user_data ) && ! $was_onboarded ) ) {
191 wp_enqueue_style(
192 'cookiebot-dashboard-backup-css',
193 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/css/backend/dashboard-old.css',
194 array(),
195 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION
196 );
197
198 wp_enqueue_script(
199 'cookiebot-account-js',
200 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/js/backend/account.js',
201 array( 'jquery' ),
202 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION,
203 true
204 );
205
206 wp_localize_script(
207 'cookiebot-account-js',
208 'cookiebot_account',
209 array(
210 'ajax_url' => admin_url( 'admin-ajax.php' ),
211 'nonce' => wp_create_nonce( 'cookiebot-account' ),
212 'cbid' => $cbid,
213 'has_user_data' => ! empty( $user_data ),
214 'has_cbid' => ! empty( $cbid ),
215 'was_onboarded' => $was_onboarded,
216 'debug' => defined( 'WP_DEBUG' ) && WP_DEBUG,
217 )
218 );
219
220 require_once CYBOT_COOKIEBOT_PLUGIN_DIR . 'src/view/admin/common/dashboard-page-old.php';
221 return;
222 }
223
224 wp_enqueue_style(
225 'cookiebot-dashboard-css',
226 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/css/backend/dashboard.css',
227 array(),
228 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION
229 );
230
231 wp_enqueue_script(
232 'cookiebot-dashboard-js',
233 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/js/backend/dashboard.js',
234 array( 'jquery' ),
235 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION,
236 true
237 );
238
239 wp_localize_script(
240 'cookiebot-dashboard-js',
241 'cookiebot_dashboard',
242 array(
243 'cbid' => $cbid,
244 'user_data' => $user_data,
245 )
246 );
247
248 wp_enqueue_script(
249 'cookiebot-account-js',
250 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/js/backend/account.js',
251 array( 'jquery' ),
252 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION,
253 true
254 );
255
256 wp_localize_script(
257 'cookiebot-account-js',
258 'cookiebot_account',
259 array(
260 'ajax_url' => admin_url( 'admin-ajax.php' ),
261 'nonce' => wp_create_nonce( 'cookiebot-account' ),
262 'cbid' => $cbid,
263 'has_user_data' => ! empty( $user_data ),
264 'has_cbid' => ! empty( $cbid ),
265 'was_onboarded' => $was_onboarded,
266 'is_authenticated' => ! empty( Cookiebot_WP::get_auth_token() ),
267 'messages' => array(
268 'success_create' => __( 'Account created successfully!', 'cookiebot' ),
269 'error_create' => __( 'Failed to create account.', 'cookiebot' ),
270 'success_verify' => __( 'CBID verified successfully!', 'cookiebot' ),
271 'error_verify' => __( 'Invalid CBID.', 'cookiebot' ),
272 ),
273 'debug' => defined( 'WP_DEBUG' ) && WP_DEBUG,
274 )
275 );
276
277 require_once CYBOT_COOKIEBOT_PLUGIN_DIR . 'src/view/admin/common/dashboard-page.php';
278 }
279 }
280