PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 4.4.1
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v4.4.1
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 / lib / Cookiebot_Review.php
cookiebot / src / lib Last commit date
buffer 1 year ago script_loader_tag 1 year ago traits 1 year ago Consent_API_Helper.php 1 year ago Cookie_Consent.php 1 year ago Cookie_Consent_Interface.php 1 year ago Cookiebot_Activated.php 1 year ago Cookiebot_Admin_Links.php 1 year ago Cookiebot_Automatic_Updates.php 1 year ago Cookiebot_Deactivated.php 1 year ago Cookiebot_Frame.php 1 year ago Cookiebot_Javascript_Helper.php 1 year ago Cookiebot_Review.php 1 year ago Cookiebot_WP.php 1 year ago Dependency_Container.php 1 year ago Settings_Page_Tab.php 1 year ago Settings_Service.php 1 year ago Settings_Service_Interface.php 1 year ago Supported_Languages.php 1 year ago Supported_Regions.php 1 year ago WP_Rocket_Helper.php 1 year ago Widgets.php 1 year ago global-deprecations.php 1 year ago helper.php 1 year ago
Cookiebot_Review.php
180 lines
1 <?php
2
3 namespace cybot\cookiebot\lib;
4
5 use WP_REST_SERVER;
6 use cybot\cookiebot\settings\pages\Debug_Page;
7
8 class Cookiebot_Review {
9
10 /**
11 * Handler url.
12 *
13 * @var string
14 */
15 protected $api_url = 'https://www.cookiebot.com/wp-json/cmp/v1/survey/';
16
17 public function register_hooks() {
18 add_action( 'admin_enqueue_scripts', array( $this, 'cookiebot_admin_script' ), 9999 );
19 add_filter( 'plugin_action_links_cookiebot/cookiebot.php', array( $this, 'plugin_action_links' ) );
20 add_filter( 'network_admin_plugin_action_links', array( $this, 'plugin_action_links' ) );
21 add_action( 'wp_ajax_cb_submit_survey', array( $this, 'send_uninstall_survey' ) );
22 }
23
24 /**
25 * Edit action links
26 *
27 * @param array $links action links.
28 * @return array
29 */
30 public function plugin_action_links( $links ) {
31 if ( array_key_exists( 'deactivate', $links ) ) {
32 $links['deactivate'] = str_replace( '<a', '<a class="cb-deactivate-action"', $links['deactivate'] );
33 }
34
35 return $links;
36 }
37
38 /**
39 * Cookiebot Add ajax url
40 */
41 public function cookiebot_admin_script( $hook ) {
42 wp_enqueue_script(
43 'cookiebot_admin_js',
44 asset_url( 'js/backend/cookiebot-admin-script.js' ),
45 null,
46 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION,
47 true
48 );
49
50 wp_enqueue_style(
51 'cookiebot-admin-global-css',
52 asset_url( 'css/backend/global/cookiebot_admin.css' ),
53 null,
54 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION
55 );
56
57 wp_localize_script(
58 'cookiebot_admin_js',
59 'cb_ajax',
60 array(
61 'ajax_url' => admin_url( 'admin-ajax.php' ),
62 )
63 );
64
65 wp_localize_script(
66 'cookiebot_admin_js',
67 'cb_survey',
68 array(
69 'survey_nonce' => wp_create_nonce( 'cookiebot_survey_nonce' ),
70 'logo' => asset_url( 'img/icons/shield_icon.svg' ),
71 'popup_header_title' => __( 'Cookiebot CMP Deactivation', 'cookiebot' ),
72 'first_msg' => __( 'We are sad to lose you. Take a moment to help us improve?', 'cookiebot' ),
73 'options' => array(
74 array(
75 'text' => __( 'The installation is too complicated', 'cookiebot' ),
76 'value' => '1',
77 ),
78 array(
79 'text' => __( 'I found a plugin that better serves my needs', 'cookiebot' ),
80 'value' => '2',
81 ),
82 array(
83 'text' => __( 'Missing features / did not meet my expectations', 'cookiebot' ),
84 'value' => '3',
85 ),
86 array(
87 'text' => __( 'I need more customization options', 'cookiebot' ),
88 'value' => '4',
89 ),
90 array(
91 'text' => __( 'The premium plan is too expensive', 'cookiebot' ),
92 'value' => '5',
93 ),
94 array(
95 'text' => __( 'I’m only deactivating the plugin temporarily', 'cookiebot' ),
96 'value' => '6',
97 ),
98 array(
99 'text' => __( 'Other', 'cookiebot' ),
100 'value' => '7',
101 'extra' => __( 'Please specify here', 'cookiebot' ),
102 ),
103 ),
104 'consent' => array(
105 'optional' => __( '(Optional)', 'cookiebot' ),
106 'first' => __(
107 ' By checking this box, you agree to submit troubleshooting information and allow us to contact you regarding the problem if necessary.',
108 'cookiebot'
109 ),
110 'second' => __(
111 'The information will be kept for no longer than 90 days. You may revoke this consent at any time, e.g. by sending an email to ',
112 'cookiebot'
113 ),
114 ),
115 'alert' => __( 'Please select one option', 'cookiebot' ),
116 'actions' => array(
117 'skip' => __( 'Skip and Deactivate', 'cookiebot' ),
118 'submit' => __( 'Submit and Deactivate', 'cookiebot' ),
119 ),
120 )
121 );
122
123 if ( 'plugins.php' === $hook ) {
124 include_view( 'admin/common/templates/extra/review-form.php' );
125 }
126 }
127
128 /**
129 * Send uninstall reason to server
130 *
131 * @return void
132 */
133 public function send_uninstall_survey() {
134 global $wpdb;
135 if ( ! check_ajax_referer( 'cookiebot_survey_nonce', 'survey_nonce', false ) ) {
136 wp_send_json_error( esc_html__( 'Sorry you are not allowed to do this.', 'cookiebot' ), 401 );
137 }
138 if ( ! isset( $_POST['reason_id'] ) ) {
139 wp_send_json_error( esc_html__( 'Please select one option', 'cookiebot' ), 400 );
140 }
141 $data = array(
142 'survey_check' => sanitize_text_field( wp_unslash( $_POST['survey_check'] ) ),
143 'reason_slug' => sanitize_text_field( wp_unslash( $_POST['reason_id'] ) ),
144 'reason_detail' => ! empty( $_POST['reason_text'] ) ? sanitize_text_field( wp_unslash( $_POST['reason_text'] ) ) : null,
145 'comments' => ! empty( $_POST['reason_info'] ) ? sanitize_text_field( wp_unslash( $_POST['reason_info'] ) ) : null,
146 'date' => gmdate( 'M d, Y h:i:s A' ),
147 'server' => ! empty( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : null,
148 'php_version' => phpversion(),
149 'mysql_version' => $wpdb->db_version(),
150 'wp_version' => get_bloginfo( 'version' ),
151 'locale' => get_locale(),
152 'plugin_version' => Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION,
153 'is_multisite' => is_multisite(),
154 );
155
156 if ( ! empty( $_POST['reason_debug'] ) && rest_sanitize_boolean( $_POST['reason_debug'] ) === true ) {
157 $debug_info = new Debug_Page();
158 $data['debug_info'] = wp_json_encode( $debug_info->prepare_debug_data() );
159 }
160
161 wp_remote_post(
162 $this->api_url,
163 array(
164 'headers' => array(
165 'Content-Type' => 'application/json; charset=utf-8',
166 ),
167 'method' => 'POST',
168 'timeout' => 45,
169 'redirection' => 5,
170 'httpversion' => '1.0',
171 'blocking' => false,
172 'body' => wp_json_encode( $data ),
173 'cookies' => array(),
174 )
175 );
176
177 wp_send_json_success( null, 200 );
178 }
179 }
180