PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 4.1.0
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v4.1.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
152 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 private function get_ignored_scripts() {
48 $ignored_scripts = get_option( 'cookiebot-ignore-scripts' );
49
50 $ignored_scripts = array_map(
51 function( $ignore_tag ) {
52 return trim( $ignore_tag );
53 },
54 explode( PHP_EOL, $ignored_scripts )
55 );
56
57 $ignored_scripts = apply_filters( 'cybot_cookiebot_ignore_scripts', $ignored_scripts );
58
59 return implode( ', ', $ignored_scripts );
60 }
61
62 /**
63 * @throws InvalidArgumentException
64 */
65 private function prepare_debug_data() {
66 global $wpdb;
67
68 $cookiebot_javascript_helper = new Cookiebot_Javascript_Helper();
69 $consent_api_helper = new Consent_API_Helper();
70
71 if ( ! function_exists( 'get_plugins' ) ) {
72 include_once ABSPATH . 'wp-admin/includes/plugin.php';
73 }
74
75 $plugins = get_plugins();
76 $active_plugins = get_option( 'active_plugins' );
77
78 $debug_output = '';
79 // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
80 $debug_output .= '##### Debug Information for ' . get_site_url() . ' generated at ' . date( 'c' ) . " #####\n\n";
81 $debug_output .= 'WordPress Version: ' . get_bloginfo( 'version' ) . "\n";
82 $debug_output .= 'WordPress Language: ' . get_bloginfo( 'language' ) . "\n";
83 $debug_output .= 'PHP Version: ' . phpversion() . "\n";
84 $debug_output .= 'MySQL Version: ' . $wpdb->db_version() . "\n";
85 $debug_output .= "\n--- Cookiebot Information ---\n";
86 $debug_output .= 'Plugin Version: ' . Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION . "\n";
87 $debug_output .= 'Cookiebot ID: ' . Cookiebot_WP::get_cbid() . "\n";
88 $debug_output .= 'Blocking mode: ' . get_option( 'cookiebot-cookie-blocking-mode' ) . "\n";
89 $debug_output .= 'Language: ' . get_option( 'cookiebot-language' ) . "\n";
90 $debug_output .= 'IAB: ' . ( get_option( 'cookiebot-iab' ) === '1' ? 'Enabled' : 'Not enabled' ) . "\n";
91 $debug_output .= 'CCPA banner for visitors from California: ' . ( get_option( 'cookiebot-ccpa' ) === '1' ? 'Enabled' : 'Not enabled' ) . "\n";
92 $debug_output .= 'CCPA domain group id: ' . get_option( 'cookiebot-ccpa-domain-group-id' ) . "\n";
93 $debug_output .= 'Add async/defer to banner tag: ' . ( get_option( 'cookiebot-script-tag-uc-attribute' ) !== '' ? get_option( 'cookiebot-script-tag-uc-attribute' ) : 'None' ) . "\n";
94 $debug_output .= 'Add async/defer to declaration tag: ' . ( get_option( 'cookiebot-script-tag-cd-attribute' ) !== '' ? get_option( 'cookiebot-script-tag-cd-attribute' ) : 'None' ) . "\n";
95 $debug_output .= 'Auto update: ' . ( get_option( 'cookiebot-autoupdate' ) === '1' ? 'Enabled' : 'Not enabled' ) . "\n";
96 $debug_output .= 'Hide Cookie Popup: ' . ( get_option( 'cookiebot-nooutput' ) === '1' ? 'Yes' : 'No' ) . "\n";
97 $debug_output .= 'Disable Cookiebot in WP Admin: ' . ( get_option( 'cookiebot-nooutput-admin' ) === '1' ? 'Yes' : 'No' ) . "\n";
98 $debug_output .= 'Enable Cookiebot on front end while logged in: ' . ( get_option( 'cookiebot-output-logged-in' ) === '1' ? 'Yes' : 'No' ) . "\n";
99 $debug_output .= 'List of ignored javascript files: ' . $this->get_ignored_scripts() . "\n";
100 $debug_output .= 'Banner tag: ' . $cookiebot_javascript_helper->include_cookiebot_js( true ) . "\n";
101 $debug_output .= 'Declaration tag: ' . Cookiebot_Declaration_Shortcode::show_declaration() . "\n";
102
103 if ( get_option( 'cookiebot-gtm' ) !== false ) {
104 $debug_output .= 'GTM tag: ' . $cookiebot_javascript_helper->include_google_tag_manager_js( true ) . "\n";
105 }
106
107 if ( get_option( 'cookiebot-gcm' ) !== false ) {
108 $debug_output .= 'GCM tag: ' . $cookiebot_javascript_helper->include_google_consent_mode_js( true ) . "\n";
109 }
110
111 if ( $consent_api_helper->is_wp_consent_api_active() ) {
112 $debug_output .= "\n--- WP Consent Level API Mapping ---\n";
113 $debug_output .= 'F = Functional, N = Necessary, P = Preferences, M = Marketing, S = Statistics, SA = Statistics Anonymous' . "\n";
114 $m = $consent_api_helper->get_wp_consent_api_mapping();
115 foreach ( $m as $k => $v ) {
116 $debug_output .= strtoupper( str_replace( ';', ', ', $k ) ) . ' => ';
117 $debug_output .= 'F=1, ';
118 $debug_output .= 'P=' . $v['preferences'] . ', ';
119 $debug_output .= 'M=' . $v['marketing'] . ', ';
120 $debug_output .= 'S=' . $v['statistics'] . ', ';
121 $debug_output .= 'SA=' . $v['statistics-anonymous'] . "\n";
122 }
123 }
124
125 try {
126 $cookiebot_addons = new Cookiebot_Addons();
127 /** @var Settings_Service_Interface $settings_service */
128 $settings_service = $cookiebot_addons->container->get( 'Settings_Service_Interface' );
129 $addons = $settings_service->get_active_addons();
130 $debug_output .= "\n--- Activated Cookiebot Addons ---\n";
131 /** @var Base_Cookiebot_Addon $addon */
132 foreach ( $addons as $addon ) {
133 $debug_output .= $addon::ADDON_NAME . ' (' . implode( ', ', $addon->get_cookie_types() ) . ")\n";
134 }
135 } catch ( Exception $exception ) {
136 $debug_output .= PHP_EOL . '--- Cookiebot Addons could not be activated ---' . PHP_EOL;
137 $debug_output .= $exception->getMessage() . PHP_EOL;
138 }
139
140 $debug_output .= "\n--- Activated Plugins ---\n";
141 foreach ( $active_plugins as $p ) {
142 if ( $p !== 'cookiebot/cookiebot.php' ) {
143 $debug_output .= $plugins[ $p ]['Name'] . ' (Version: ' . $plugins[ $p ]['Version'] . ")\n";
144 }
145 }
146
147 $debug_output .= "\n##### Debug Information END #####";
148
149 return $debug_output;
150 }
151 }
152