返回介绍

wp_validate_redirect()

发布于 2017-09-11 13:10:22 字数 2358 浏览 915 评论 0 收藏 0

wp_validate_redirect( string $location,  string $default = '' )

Validates a URL for use in a redirect.


description

Checks whether the $location is using an allowed host, if it has an absolute path. A plugin can therefore set or remove allowed host(s) to or from the list.

If the host is not allowed, then the redirect is to $default supplied


参数

$location

(string) (Required) The redirect to validate

$default

(string) (Optional) The value to return if $location is not allowed

Default value: ''


返回值

(string) redirect-sanitized URL


源代码

File: wp-includes/pluggable.php

function wp_validate_redirect($location, $default = '') {
	$location = trim( $location, " \t\n\r\0\x08\x0B" );
	// browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//'
	if ( substr($location, 0, 2) == '//' )
		$location = 'http:' . $location;

	// In php 5 parse_url may fail if the URL query part contains http://, bug

更新日志

Versiondescription
2.8.1Introduced.

相关函数

Uses

  • wp-includes/pluggable.php: allowed_redirect_hosts
  • wp-includes/link-template.php: home_url()
  • wp-includes/plugin.php: apply_filters()

Used By

  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::set_return_url()
  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::set_preview_url()
  • wp-includes/pluggable.php: wp_safe_redirect()
  • wp-includes/functions.php: wp_get_referer()
  • wp-includes/functions.php: wp_get_original_referer()
  • wp-includes/http.php: allowed_http_request_hosts()
  • Show 1 more used by Hide more used by

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文