I know when I want to save data in database, I must sanitize data but what about following case which is a simple comparison. Should I sanitize?

if ( ! isset( $_GET['page'] ) ) {

if ( 'google' === $_GET['page'] ) {
    wp_redirect( 'https://google.com' );

if ( 'facebook' === $_GET['page'] ) {
    wp_redirect( 'https://facebook.com' );

1 Answer 1


No, it's not necessary to sanitise in this case.

If you were redirecting to the value directly, or outputting it in some way, you would definitely need to, but since you're just comparing its value against a white list (essentially) no sanitising or escaping is necessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.