PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 4.3.12
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v4.3.12
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 3 years ago script_loader_tag 2 years ago traits 3 years ago Consent_API_Helper.php 2 years ago Cookie_Consent.php 3 years ago Cookie_Consent_Interface.php 4 years ago Cookiebot_Activated.php 2 years ago Cookiebot_Admin_Links.php 1 year ago Cookiebot_Automatic_Updates.php 3 years ago Cookiebot_Deactivated.php 4 years ago Cookiebot_Javascript_Helper.php 1 year ago Cookiebot_Review.php 1 year ago Cookiebot_WP.php 1 year ago Dependency_Container.php 3 years ago Settings_Page_Tab.php 3 years ago Settings_Service.php 3 years ago Settings_Service_Interface.php 3 years ago Supported_Languages.php 4 years ago Supported_Regions.php 2 years ago WP_Rocket_Helper.php 3 years ago Widgets.php 3 years ago global-deprecations.php 3 years ago helper.php 2 years ago
Cookiebot_Review.php
126 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 * Handler url.
11 *
12 * @var string
13 */
14 protected $api_url = 'https://www.cookiebot.com/wp-json/cmp/v1/survey/';
15
16 public function register_hooks() {
17 add_action( 'admin_enqueue_scripts', array( $this, 'cookiebot_admin_script' ), 9999 );
18 add_filter( 'plugin_action_links_cookiebot/cookiebot.php', array( $this, 'plugin_action_links' ) );
19 add_filter( 'network_admin_plugin_action_links', array( $this, 'plugin_action_links' ) );
20 add_action( 'wp_ajax_cb_submit_survey', array( $this, 'send_uninstall_survey' ) );
21 }
22
23 /**
24 * Edit action links
25 *
26 * @param array $links action links.
27 * @return array
28 */
29 public function plugin_action_links( $links ) {
30 if ( array_key_exists( 'deactivate', $links ) ) {
31 $links['deactivate'] = str_replace( '<a', '<a class="cb-deactivate-action"', $links['deactivate'] );
32 }
33
34 return $links;
35 }
36
37 /**
38 * Cookiebot Add ajax url
39 */
40 public function cookiebot_admin_script( $hook ) {
41 wp_enqueue_script(
42 'cookiebot_admin_js',
43 asset_url( 'js/backend/cookiebot-admin-script.js' ),
44 null,
45 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION,
46 true
47 );
48
49 wp_enqueue_style(
50 'cookiebot-admin-global-css',
51 asset_url( 'css/backend/global/cookiebot_admin.css' ),
52 null,
53 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION
54 );
55
56 wp_localize_script(
57 'cookiebot_admin_js',
58 'cb_ajax',
59 array(
60 'ajax_url' => admin_url( 'admin-ajax.php' ),
61 'survey_nonce' => wp_create_nonce( 'cookiebot_survey_nonce' ),
62 )
63 );
64
65 $args = array(
66 'cookiebot_logo' => asset_url( 'img/icons/shield_icon.svg' ),
67 );
68
69 if ( 'plugins.php' === $hook ) {
70 include_view( 'admin/templates/extra/review-form.php', $args );
71 }
72 }
73
74 /**
75 * Send uninstall reason to server
76 *
77 * @return void
78 */
79 public function send_uninstall_survey() {
80 global $wpdb;
81 if ( ! check_ajax_referer( 'cookiebot_survey_nonce', 'survey_nonce', false ) ) {
82 wp_send_json_error( esc_html__( 'Sorry you are not allowed to do this.', 'cookiebot' ), 401 );
83 }
84 if ( ! isset( $_POST['reason_id'] ) ) {
85 wp_send_json_error( esc_html__( 'Please select one option', 'cookiebot' ), 400 );
86 }
87 $data = array(
88 'survey_check' => sanitize_text_field( wp_unslash( $_POST['survey_check'] ) ),
89 'reason_slug' => sanitize_text_field( wp_unslash( $_POST['reason_id'] ) ),
90 'reason_detail' => ! empty( $_POST['reason_text'] ) ? sanitize_text_field( wp_unslash( $_POST['reason_text'] ) ) : null,
91 'comments' => ! empty( $_POST['reason_info'] ) ? sanitize_text_field( wp_unslash( $_POST['reason_info'] ) ) : null,
92 'date' => gmdate( 'M d, Y h:i:s A' ),
93 'server' => ! empty( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : null,
94 'php_version' => phpversion(),
95 'mysql_version' => $wpdb->db_version(),
96 'wp_version' => get_bloginfo( 'version' ),
97 'locale' => get_locale(),
98 'plugin_version' => Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION,
99 'is_multisite' => is_multisite(),
100 );
101
102 if ( ! empty( $_POST['reason_debug'] ) && rest_sanitize_boolean( $_POST['reason_debug'] ) === true ) {
103 $debug_info = new Debug_Page();
104 $data['debug_info'] = wp_json_encode( $debug_info->prepare_debug_data() );
105 }
106
107 wp_remote_post(
108 $this->api_url,
109 array(
110 'headers' => array(
111 'Content-Type' => 'application/json; charset=utf-8',
112 ),
113 'method' => 'POST',
114 'timeout' => 45,
115 'redirection' => 5,
116 'httpversion' => '1.0',
117 'blocking' => false,
118 'body' => wp_json_encode( $data ),
119 'cookies' => array(),
120 )
121 );
122
123 wp_send_json_success( null, 200 );
124 }
125 }
126