Add exclusion for users with private link (#46465)

* Add exclusion for users with private link

* Remove unused private function

* Fix lint issues

* Add changelog

* Update sanitization method

sanitize_key converts to lowercase

* Fix lint issue
This commit is contained in:
Adrian Duffell 2024-04-15 07:57:02 +08:00 committed by GitHub
parent 5e8644d7a5
commit 6486c26d76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: add
Add coming soon exclusion for users with a private link.

View File

@ -54,6 +54,16 @@ class ComingSoonRequestHandler {
return $wp;
}
// Exclude users with a private link.
if ( isset( $_GET['woo-share'] ) && get_option( 'woocommerce_share_key' ) === $_GET['woo-share'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
// Persist the share link with a cookie for 90 days.
setcookie( 'woo-share', sanitize_text_field( wp_unslash( $_GET['woo-share'] ) ), time() + 60 * 60 * 24 * 90 ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended
return $wp;
}
if ( isset( $_COOKIE['woo-share'] ) && get_option( 'woocommerce_share_key' ) === $_COOKIE['woo-share'] ) {
return $wp;
}
// A coming soon page needs to be displayed. Don't cache this response.
nocache_headers();