Wrap private link exclusion logic in `woocommerce_private_link` option check (#47690)

This commit is contained in:
Chi-Hsuan Huang 2024-05-22 19:15:37 +08:00 committed by GitHub
parent f55e25b009
commit ee6f69a14e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 8 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: update
Wrap LYS private link exclusion logic in an overall check

View File

@ -102,14 +102,17 @@ class ComingSoonRequestHandler {
return false; return false;
} }
// Exclude users with a private link. // Check if the private link option is enabled.
if ( isset( $_GET['woo-share'] ) && get_option( 'woocommerce_share_key' ) === $_GET['woo-share'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( get_option( 'woocommerce_private_link' ) === 'yes' ) {
// Persist the share link with a cookie for 90 days. // Exclude users with a private link.
setcookie( 'woo-share', sanitize_text_field( wp_unslash( $_GET['woo-share'] ) ), time() + 60 * 60 * 24 * 90, '/' ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( isset( $_GET['woo-share'] ) && get_option( 'woocommerce_share_key' ) === $_GET['woo-share'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
return false; // 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
if ( isset( $_COOKIE['woo-share'] ) && get_option( 'woocommerce_share_key' ) === $_COOKIE['woo-share'] ) { return false;
return false; }
if ( isset( $_COOKIE['woo-share'] ) && get_option( 'woocommerce_share_key' ) === $_COOKIE['woo-share'] ) {
return false;
}
} }
return true; return true;
} }