Retrieves referer from ‘_wp_http_referer’ or HTTP referer.
Description
If it’s the same as the current request URL, will return false.
Source
* If it's the same as the current request URL, will return false.
*
* @since 2.0.4
*
* @return string|false Referer URL on success, false on failure.
*/
function wp_get_referer() {
// Return early if called before wp_validate_redirect() is defined.
if ( ! function_exists( 'wp_validate_redirect' ) ) {
return false;
}
$ref = wp_get_raw_referer();
if ( $ref && wp_unslash( $_SERVER['REQUEST_URI'] ) !== $ref
&& home_url() . wp_unslash( $_SERVER['REQUEST_URI'] ) !== $ref
Changelog
Version | Description |
---|---|
2.0.4 | Introduced. |
Example