WordPress at a glance

wp_get_referer() WP 1.0

Retrieve referer from '_wp_http_referer' or HTTP referer.

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

✈ 1 time = 0.001678s = very slow | 50000 times = 2.26s = fast | PHP 7.0.32, WP 5.1.1

No Hooks.

Return

String/false. Referer URL on success, false on failure.

Usage

wp_get_referer();

Changelog

Since 2.0.4 Introduced.

Code of wp get referer: wp-includes/functions.php WP 5.4.1

<?php
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;
}

Related Functions

From category: Uncategorized

No comments
        Log In . Register