PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / trunk
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode vtrunk
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 4 months ago traits 4 months ago Account_Service.php 4 months ago Consent_API_Helper.php 1 year ago Cookie_Consent.php 4 months ago Cookie_Consent_Interface.php 1 year ago Cookiebot_Activated.php 4 months ago Cookiebot_Admin_Links.php 1 year ago Cookiebot_Automatic_Updates.php 1 year ago Cookiebot_Deactivated.php 5 months ago Cookiebot_Frame.php 1 year ago Cookiebot_Javascript_Helper.php 7 months ago Cookiebot_Review.php 4 months ago Cookiebot_WP.php 2 weeks ago Dependency_Container.php 4 months 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 4 months ago
Cookiebot_Review.php
185 lines
1 <?php
2
3 namespace cybot\cookiebot\lib;
4
5 use WP_REST_SERVER;
6 use cybot\cookiebot\settings\pages\Support_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 // Options 1 and 2 are out of order intentionally just to confirm if the users are choosing the first one shown by default.
66 wp_localize_script(
67 'cookiebot_admin_js',
68 'cb_survey',
69 array(
70 'survey_nonce' => wp_create_nonce( 'cookiebot_survey_nonce' ),
71 'logo' => asset_url( 'img/icons/shield_icon.svg' ),
72 'popup_header_title' => __( 'Leaving Cookiebot by Usercentrics?', 'cookiebot' ),
73 'first_msg' => __( 'We\'re sad to see you go. Let us know how we can improve Cookiebot by Usercentrics', 'cookiebot' ),
74 'options' => array(
75 array(
76 'text' => __( 'Cookies weren\'t being blocked correctly', 'cookiebot' ),
77 'value' => '2',
78 ),
79 array(
80 'text' => __( 'My site stopped working / it conflicted with other plugins', 'cookiebot' ),
81 'value' => '1',
82 ),
83 array(
84 'text' => __( 'I couldn\'t find or activate the Free plan', 'cookiebot' ),
85 'value' => '3',
86 ),
87 array(
88 'text' => __( 'The Premium plans are too expensive', 'cookiebot' ),
89 'value' => '4',
90 ),
91 array(
92 'text' => __( 'Missing features / didn\'t meet my expectations', 'cookiebot' ),
93 'value' => '5',
94 ),
95 array(
96 'text' => __( 'I found another plugin that fits my needs better', 'cookiebot' ),
97 'value' => '6',
98 ),
99 array(
100 'text' => __( 'I\'m only deactivating it temporarily', 'cookiebot' ),
101 'value' => '7',
102 ),
103 array(
104 'text' => __( 'Other', 'cookiebot' ),
105 'value' => '8',
106 'extra' => __( 'Please specify here', 'cookiebot' ),
107 ),
108 ),
109 'consent' => array(
110 'optional' => __( '(Optional)', 'cookiebot' ),
111 'first' => __(
112 ' By checking this box, you agree to submit troubleshooting information and allow us to contact you regarding the problem if necessary.',
113 'cookiebot'
114 ),
115 'second' => __(
116 '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 ',
117 'cookiebot'
118 ),
119 ),
120 'alert' => __( 'Please select one option', 'cookiebot' ),
121 'actions' => array(
122 'skip' => __( 'Skip and Deactivate', 'cookiebot' ),
123 'submit' => __( 'Submit and Deactivate', 'cookiebot' ),
124 ),
125 )
126 );
127
128 if ( 'plugins.php' === $hook ) {
129 include_view( 'admin/common/templates/extra/review-form.php' );
130 }
131 }
132
133 /**
134 * Send uninstall reason to server
135 *
136 * @return void
137 */
138 public function send_uninstall_survey() {
139 global $wpdb;
140 if ( ! check_ajax_referer( 'cookiebot_survey_nonce', 'survey_nonce', false ) || ! current_user_can( 'manage_options' ) ) {
141 wp_send_json_error( esc_html__( 'Sorry you are not allowed to do this.', 'cookiebot' ), 401 );
142 }
143 if ( ! isset( $_POST['reason_id'] ) ) {
144 wp_send_json_error( esc_html__( 'Please select one option', 'cookiebot' ), 400 );
145 }
146 $data = array(
147 'survey_check' => isset( $_POST['survey_check'] ) ? sanitize_text_field( wp_unslash( $_POST['survey_check'] ) ) : '',
148 'reason_slug' => sanitize_text_field( wp_unslash( $_POST['reason_id'] ) ),
149 'reason_detail' => ! empty( $_POST['reason_text'] ) ? sanitize_text_field( wp_unslash( $_POST['reason_text'] ) ) : null,
150 'comments' => ! empty( $_POST['reason_info'] ) ? sanitize_text_field( wp_unslash( $_POST['reason_info'] ) ) : null,
151 'date' => gmdate( 'M d, Y h:i:s A' ),
152 'server' => ! empty( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : null,
153 'php_version' => phpversion(),
154 'mysql_version' => $wpdb->db_version(),
155 'wp_version' => get_bloginfo( 'version' ),
156 'locale' => get_locale(),
157 'plugin_version' => Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION,
158 'is_multisite' => is_multisite(),
159 );
160
161 if ( ! empty( $_POST['reason_debug'] ) && rest_sanitize_boolean( $_POST['reason_debug'] ) === true ) {
162 $support = new Support_Page();
163 $data['debug_info'] = wp_json_encode( $support->prepare_debug_data() );
164 }
165
166 wp_remote_post(
167 $this->api_url,
168 array(
169 'headers' => array(
170 'Content-Type' => 'application/json; charset=utf-8',
171 ),
172 'method' => 'POST',
173 'timeout' => 45,
174 'redirection' => 5,
175 'httpversion' => '1.0',
176 'blocking' => false,
177 'body' => wp_json_encode( $data ),
178 'cookies' => array(),
179 )
180 );
181
182 wp_send_json_success( null, 200 );
183 }
184 }
185