wp_get_referer() – Retrieve referer from ‘_wp_http_referer’ or HTTP referer.

You appear to be a bot. Output may be restricted

Description

Retrieve referer from '_wp_http_referer' or HTTP referer.

If it's the same as the current request URL, will return false.

Usage

$string|false = wp_get_referer();

Parameters

Returns

string|false Referer URL on success, false on failure.

Source

File name: wordpress/wp-includes/functions.php
Lines:

1 to 13 of 13
function wp_get_referer() {
  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 ) {
    return wp_validate_redirect( $ref, false );
  }

  return false;
}
 

 View on GitHub View on Trac