I’ve been searching for some WP specific way to detect any referrer. Have an idea?
I know how to do that in PHP but I just want to know if there’s some WP function to do that?
EDIT: here is what I ‘m trying to test =>
$referer = wp_get_referer();
if ( strpos($referer ,'http://wordpress.org') !== false ) echo 'you come from wordpress.org';
The best way to check the referrer will depends of what are you trying to do. You can use wp_get_referer() or wp_get_original_referer(), but if you want to check the referer for security reasons you should definitely use other functions like check_admin_referer(), check_ajax_referer(), wp_referer_field() or other of the WordPress Nonces related functions.
You can get it using wp_get_referer() and wp_get_original_referer() functions.
use
wp_get_referer();
to Retrieve referer from ‘_wp_http_referer’, HTTP referer, or current page respectively. for more info read codex