WordPress开发者和主题制作者的搜索引擎



wp_get_referer ›

Since2.0.4
已弃用n/a
wp_get_referer ( 没有参数 )
返回:
  • (false|string) False on failure. Referer URL on success.
定义在:
文档:

Retrieve referer from '_wp_http_referer' or HTTP referer.

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



源码

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