is_allowed_http_origin

函式
is_allowed_http_origin ( $origin = null )
引數
  • (string|null) $origin Origin URL. If not provided, the value of get_http_origin() is used.
    Required:
    Default: null
返回值
  • (string) Origin URL if allowed, empty string if not.
定義位置
相關方法
get_allowed_http_originsget_http_originms_allowed_http_request_hostsadd_allowed_optionsallowed_tags
引入
3.4.0
棄用
-

is_allowed_http_origin: 這個函式用來檢查一個給定的HTTP來源是否被允許訪問網站。它把HTTP來源作為一個引數,如果該來源被允許,則返回真,否則返回假。

判斷HTTP來源是否為授權來源。

function is_allowed_http_origin( $origin = null ) {
	$origin_arg = $origin;

	if ( null === $origin ) {
		$origin = get_http_origin();
	}

	if ( $origin && ! in_array( $origin, get_allowed_http_origins(), true ) ) {
		$origin = '';
	}

	/**
	 * Change the allowed HTTP origin result.
	 *
	 * @since 3.4.0
	 *
	 * @param string $origin     Origin URL if allowed, empty string if not.
	 * @param string $origin_arg Original origin string passed into is_allowed_http_origin function.
	 */
	return apply_filters( 'allowed_http_origin', $origin, $origin_arg );
}

常見問題

FAQs
檢視更多 >