G
G
Grisha Nikolsky2015-10-31 09:47:44
WordPress
Grisha Nikolsky, 2015-10-31 09:47:44

How can you understand this piece of code?

Hello, how can I understand this piece of code?

$attributes['redirect'] = '';
    if ( isset( $_REQUEST['redirect_to'] ) ) {
        $attributes['redirect'] = wp_validate_redirect( $_REQUEST['redirect_to'], $attributes['redirect'] );
    }

Provided that $attributes are shortcode attributes.
It seems like I read about wp_validate_redirect on the Internet, but all the information was only in English and I did not achieve a clear understanding. Therefore, please explain this code, including the above function and the IF condition.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
WP Panda, 2015-10-31
@VoxelGod

Well, I already explained.
Checks if the redirect_to parameter is present in the response , if it is, it checks if it is in the list of allowed ones and returns it, if not, then returns the value set in $attributes['redirect']
More answered your question on the site. wp-panda.com/build-a-custom-wordpress-user-flow-pa...

P
Puma Thailand, 2015-10-31
@opium

If just checks if the variable exists
And about the function, just go and look at its code, everything is open there

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question