PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 4.5.3
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v4.5.3
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
257 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 if ( ! $is_authenticated && ! empty( $cbid ) && ! empty( $user_data ) && ! empty( $was_onboarded ) ) {
106 wp_enqueue_style(
107 'cookiebot-dashboard-css',
108 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/css/backend/dashboard.css',
109 array(),
110 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION
111 );
112
113 wp_enqueue_script(
114 'cookiebot-account-static-js',
115 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/js/backend/account-static.js',
116 array( 'jquery' ),
117 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION,
118 true
119 );
120
121 wp_localize_script(
122 'cookiebot-account-static-js',
123 'cookiebot_account',
124 array(
125 'ajax_url' => admin_url( 'admin-ajax.php' ),
126 'nonce' => wp_create_nonce( 'cookiebot-account' ),
127 'cbid' => $cbid,
128 'has_user_data' => ! empty( $user_data ),
129 'has_cbid' => ! empty( $cbid ),
130 'was_onboarded' => $was_onboarded,
131 'debug' => defined( 'WP_DEBUG' ) && WP_DEBUG,
132 'auth_expired_flow' => true,
133 )
134 );
135
136 require_once CYBOT_COOKIEBOT_PLUGIN_DIR . 'src/view/admin/common/dashboard-page-session-expired.php';
137 return;
138 }
139
140 // Check if the trial has expired
141 if ( Cookiebot_WP::is_trial_expired() && ! Cookiebot_WP::has_upgraded() ) {
142 wp_enqueue_style(
143 'cookiebot-dashboard-css',
144 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/css/backend/dashboard.css',
145 array(),
146 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION
147 );
148
149 wp_enqueue_script(
150 'cookiebot-account-js',
151 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/js/backend/account.js',
152 array( 'jquery' ),
153 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION,
154 true
155 );
156
157 wp_localize_script(
158 'cookiebot-account-js',
159 'cookiebot_account',
160 array(
161 'ajax_url' => admin_url( 'admin-ajax.php' ),
162 'nonce' => wp_create_nonce( 'cookiebot-account' ),
163 'cbid' => $cbid,
164 'has_user_data' => ! empty( $user_data ),
165 'has_cbid' => ! empty( $cbid ),
166 'was_onboarded' => $was_onboarded,
167 'debug' => defined( 'WP_DEBUG' ) && WP_DEBUG,
168 )
169 );
170
171 require_once CYBOT_COOKIEBOT_PLUGIN_DIR . 'src/view/admin/common/dashboard-trial-expired.php';
172 return;
173 }
174
175 // Modified condition to check for onboarding status
176 if ( ! empty( $cbid ) && ( empty( $user_data ) && ! $was_onboarded ) ) {
177 wp_enqueue_style(
178 'cookiebot-dashboard-backup-css',
179 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/css/backend/dashboard-old.css',
180 array(),
181 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION
182 );
183
184 wp_enqueue_script(
185 'cookiebot-account-js',
186 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/js/backend/account.js',
187 array( 'jquery' ),
188 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION,
189 true
190 );
191
192 wp_localize_script(
193 'cookiebot-account-js',
194 'cookiebot_account',
195 array(
196 'ajax_url' => admin_url( 'admin-ajax.php' ),
197 'nonce' => wp_create_nonce( 'cookiebot-account' ),
198 'cbid' => $cbid,
199 'has_user_data' => ! empty( $user_data ),
200 'has_cbid' => ! empty( $cbid ),
201 'was_onboarded' => $was_onboarded,
202 'debug' => defined( 'WP_DEBUG' ) && WP_DEBUG,
203 )
204 );
205
206 require_once CYBOT_COOKIEBOT_PLUGIN_DIR . 'src/view/admin/common/dashboard-page-old.php';
207 return;
208 }
209
210 wp_enqueue_style(
211 'cookiebot-dashboard-css',
212 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/css/backend/dashboard.css',
213 array(),
214 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION
215 );
216
217 wp_enqueue_script(
218 'cookiebot-dashboard-js',
219 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/js/backend/dashboard.js',
220 array( 'jquery' ),
221 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION,
222 true
223 );
224
225 wp_enqueue_script(
226 'cookiebot-account-js',
227 CYBOT_COOKIEBOT_PLUGIN_URL . 'assets/js/backend/account.js',
228 array( 'jquery' ),
229 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION,
230 true
231 );
232
233 wp_localize_script(
234 'cookiebot-account-js',
235 'cookiebot_account',
236 array(
237 'ajax_url' => admin_url( 'admin-ajax.php' ),
238 'nonce' => wp_create_nonce( 'cookiebot-account' ),
239 'cbid' => $cbid,
240 'has_user_data' => ! empty( $user_data ),
241 'has_cbid' => ! empty( $cbid ),
242 'was_onboarded' => $was_onboarded,
243 'is_authenticated' => ! empty( Cookiebot_WP::get_auth_token() ),
244 'messages' => array(
245 'success_create' => __( 'Account created successfully!', 'cookiebot' ),
246 'error_create' => __( 'Failed to create account.', 'cookiebot' ),
247 'success_verify' => __( 'CBID verified successfully!', 'cookiebot' ),
248 'error_verify' => __( 'Invalid CBID.', 'cookiebot' ),
249 ),
250 'debug' => defined( 'WP_DEBUG' ) && WP_DEBUG,
251 )
252 );
253
254 require_once CYBOT_COOKIEBOT_PLUGIN_DIR . 'src/view/admin/common/dashboard-page.php';
255 }
256 }
257