Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions public/class-gdpr-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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();
}

Comment on lines +291 to +301
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to move the entire cookie logic to a JS-based approach so caching plugins do not interfere with anything.

}

/**
Expand Down