From 86120777495e7bff598bf465cbb1e2ac65c85acc Mon Sep 17 00:00:00 2001 From: Moutushi Date: Fri, 22 May 2020 14:00:39 -0400 Subject: [PATCH] Added prompt for browser blocked cookie --- public/class-gdpr-public.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/public/class-gdpr-public.php b/public/class-gdpr-public.php index 440af095..83913ce2 100755 --- a/public/class-gdpr-public.php +++ b/public/class-gdpr-public.php @@ -237,7 +237,7 @@ public function update_privacy_preferences() { $consents = isset( $_POST['user_consents'] ) ? array_map( 'sanitize_text_field', (array) wp_unslash( $_POST['user_consents'] ) ) : array(); // phpcs:ignore $cookies = isset( $_POST['approved_cookies'] ) ? array_map( 'sanitize_text_field', (array) wp_unslash( $_POST['approved_cookies'] ) ) : array(); // phpcs:ignore $all_cookies = isset( $_POST['all_cookies'] ) ? array_map( 'sanitize_text_field', (array) json_decode( wp_unslash( $_POST['all_cookies'] ) ) ) : array(); // phpcs:ignore - + $approved_cookies = array(); if ( ! empty( $cookies ) ) { foreach ( $cookies as $cookie_array ) { @@ -288,8 +288,17 @@ public function update_privacy_preferences() { } } } - - wp_send_json_success(); + if ( empty ( $_COOKIE ) ) { + wp_send_json_error( + array( + 'title' => esc_html__( 'Warning!', 'gdpr' ), + 'content' => esc_html__( 'Your browser is set to block cookies therefore we cannot record your acceptance. Please adjust your browser’s settings and try again.', 'gdpr' ), + ) + ); + } else { + wp_send_json_success(); + } + } /**