PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 4.0.0
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v4.0.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 / Debug_Page.php
cookiebot / src / settings / pages Last commit date
Debug_Page.php 4 years ago Gtm_Page.php 4 years ago Iab_Page.php 4 years ago Legislations_Page.php 4 years ago Settings_Page.php 4 years ago Settings_Page_Interface.php 4 years ago Support_Page.php 4 years ago
Debug_Page.php
136 lines
1 <?php
2
3 namespace cybot\cookiebot\settings\pages;
4
5 use cybot\cookiebot\addons\controller\addons\Base_Cookiebot_Addon;
6 use cybot\cookiebot\addons\Cookiebot_Addons;
7 use cybot\cookiebot\lib\Consent_API_Helper;
8 use cybot\cookiebot\lib\Cookiebot_Javascript_Helper;
9 use cybot\cookiebot\lib\Settings_Service_Interface;
10 use cybot\cookiebot\lib\Cookiebot_WP;
11 use cybot\cookiebot\shortcode\Cookiebot_Declaration_Shortcode;
12 use InvalidArgumentException;
13 use RuntimeException;
14 use function cybot\cookiebot\lib\asset_url;
15 use function cybot\cookiebot\lib\include_view;
16 use Exception;
17
18 class Debug_Page implements Settings_Page_Interface {
19
20 public function menu() {
21 add_submenu_page(
22 'cookiebot',
23 __( 'Debug info', 'cookiebot' ),
24 __( 'Debug info', 'cookiebot' ),
25 'manage_options',
26 'cookiebot_debug',
27 array( $this, 'display' )
28 );
29 }
30
31 /**
32 * @throws InvalidArgumentException
33 */
34 public function display() {
35 wp_enqueue_script(
36 'cookiebot-debug-page-js',
37 asset_url( 'js/backend/debug-page.js' ),
38 null,
39 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION,
40 true
41 );
42 $debug_output = $this->prepare_debug_data();
43
44 include_view( 'admin/settings/debug-page.php', array( 'debug_output' => $debug_output ) );
45 }
46
47 /**
48 * @throws InvalidArgumentException
49 */
50 private function prepare_debug_data() {
51 global $wpdb;
52
53 $cookiebot_javascript_helper = new Cookiebot_Javascript_Helper();
54 $consent_api_helper = new Consent_API_Helper();
55
56 if ( ! function_exists( 'get_plugins' ) ) {
57 include_once ABSPATH . 'wp-admin/includes/plugin.php';
58 }
59
60 $plugins = get_plugins();
61 $active_plugins = get_option( 'active_plugins' );
62
63 $debug_output = '';
64 // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
65 $debug_output .= '##### Debug Information for ' . get_site_url() . ' generated at ' . date( 'c' ) . " #####\n\n";
66 $debug_output .= 'WordPress Version: ' . get_bloginfo( 'version' ) . "\n";
67 $debug_output .= 'WordPress Language: ' . get_bloginfo( 'language' ) . "\n";
68 $debug_output .= 'PHP Version: ' . phpversion() . "\n";
69 $debug_output .= 'MySQL Version: ' . $wpdb->db_version() . "\n";
70 $debug_output .= "\n--- Cookiebot Information ---\n";
71 $debug_output .= 'Plugin Version: ' . Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION . "\n";
72 $debug_output .= 'Cookiebot ID: ' . Cookiebot_WP::get_cbid() . "\n";
73 $debug_output .= 'Blocking mode: ' . get_option( 'cookiebot-cookie-blocking-mode' ) . "\n";
74 $debug_output .= 'Language: ' . get_option( 'cookiebot-language' ) . "\n";
75 $debug_output .= 'IAB: ' . ( get_option( 'cookiebot-iab' ) === '1' ? 'Enabled' : 'Not enabled' ) . "\n";
76 $debug_output .= 'CCPA banner for visitors from California: ' . ( get_option( 'cookiebot-ccpa' ) === '1' ? 'Enabled' : 'Not enabled' ) . "\n";
77 $debug_output .= 'CCPA domain group id: ' . get_option( 'cookiebot-ccpa-domain-group-id' ) . "\n";
78 $debug_output .= 'Add async/defer to banner tag: ' . ( get_option( 'cookiebot-script-tag-uc-attribute' ) !== '' ? get_option( 'cookiebot-script-tag-uc-attribute' ) : 'None' ) . "\n";
79 $debug_output .= 'Add async/defer to declaration tag: ' . ( get_option( 'cookiebot-script-tag-cd-attribute' ) !== '' ? get_option( 'cookiebot-script-tag-cd-attribute' ) : 'None' ) . "\n";
80 $debug_output .= 'Auto update: ' . ( get_option( 'cookiebot-autoupdate' ) === '1' ? 'Enabled' : 'Not enabled' ) . "\n";
81 $debug_output .= 'Hide Cookie Popup: ' . ( get_option( 'cookiebot-nooutput' ) === '1' ? 'Yes' : 'No' ) . "\n";
82 $debug_output .= 'Disable Cookiebot in WP Admin: ' . ( get_option( 'cookiebot-nooutput-admin' ) === '1' ? 'Yes' : 'No' ) . "\n";
83 $debug_output .= 'Enable Cookiebot on front end while logged in: ' . ( get_option( 'cookiebot-output-logged-in' ) === '1' ? 'Yes' : 'No' ) . "\n";
84 $debug_output .= 'Banner tag: ' . $cookiebot_javascript_helper->include_cookiebot_js( true ) . "\n";
85 $debug_output .= 'Declaration tag: ' . Cookiebot_Declaration_Shortcode::show_declaration() . "\n";
86
87 if ( get_option( 'cookiebot-gtm' ) !== false ) {
88 $debug_output .= 'GTM tag: ' . $cookiebot_javascript_helper->include_google_tag_manager_js( true ) . "\n";
89 }
90
91 if ( get_option( 'cookiebot-gcm' ) !== false ) {
92 $debug_output .= 'GCM tag: ' . $cookiebot_javascript_helper->include_google_consent_mode_js( true ) . "\n";
93 }
94
95 if ( $consent_api_helper->is_wp_consent_api_active() ) {
96 $debug_output .= "\n--- WP Consent Level API Mapping ---\n";
97 $debug_output .= 'F = Functional, N = Necessary, P = Preferences, M = Marketing, S = Statistics, SA = Statistics Anonymous' . "\n";
98 $m = $consent_api_helper->get_wp_consent_api_mapping();
99 foreach ( $m as $k => $v ) {
100 $debug_output .= strtoupper( str_replace( ';', ', ', $k ) ) . ' => ';
101 $debug_output .= 'F=1, ';
102 $debug_output .= 'P=' . $v['preferences'] . ', ';
103 $debug_output .= 'M=' . $v['marketing'] . ', ';
104 $debug_output .= 'S=' . $v['statistics'] . ', ';
105 $debug_output .= 'SA=' . $v['statistics-anonymous'] . "\n";
106 }
107 }
108
109 try {
110 $cookiebot_addons = new Cookiebot_Addons();
111 /** @var Settings_Service_Interface $settings_service */
112 $settings_service = $cookiebot_addons->container->get( 'Settings_Service_Interface' );
113 $addons = $settings_service->get_active_addons();
114 $debug_output .= "\n--- Activated Cookiebot Addons ---\n";
115 /** @var Base_Cookiebot_Addon $addon */
116 foreach ( $addons as $addon ) {
117 $debug_output .= $addon::ADDON_NAME . ' (' . implode( ', ', $addon->get_cookie_types() ) . ")\n";
118 }
119 } catch ( Exception $exception ) {
120 $debug_output .= PHP_EOL . '--- Cookiebot Addons could not be activated ---' . PHP_EOL;
121 $debug_output .= $exception->getMessage() . PHP_EOL;
122 }
123
124 $debug_output .= "\n--- Activated Plugins ---\n";
125 foreach ( $active_plugins as $p ) {
126 if ( $p !== 'cookiebot/cookiebot.php' ) {
127 $debug_output .= $plugins[ $p ]['Name'] . ' (Version: ' . $plugins[ $p ]['Version'] . ")\n";
128 }
129 }
130
131 $debug_output .= "\n##### Debug Information END #####";
132
133 return $debug_output;
134 }
135 }
136