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