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

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

Usage

wp_get_referer();

Changelog

Since 2.0.4 Introduced.

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

<?php
function wp_get_referer() {
	if ( ! function_exists( 'wp_validate_redirect' ) ) {
		return false;
	}

	$ref = wp_get_raw_referer();

	if ( $ref && $ref !== wp_unslash( $_SERVER['REQUEST_URI'] ) && $ref !== home_url() . wp_unslash( $_SERVER['REQUEST_URI'] ) ) {
		return wp_validate_redirect( $ref, false );
	}

	return false;
}

Related Functions

From category: Uncategorized

No comments
    Hello, !     Log In . Register