wp_is_xml_request

函数
wp_is_xml_request ( No parameters )
返回值
  • (bool) True if `Accepts` or `Content-Type` headers contain `text/xml` or one of the related MIME types. False otherwise.
定义位置
相关方法
wp_is_json_requestwp_is_jsonp_requestwp_safe_remote_requestwp_remote_requestwp_send_user_request
引入
5.2.0
弃用
-

wp_is_xml_request: 这个函数用来检查当前的请求是否是一个XML请求。如果该请求是一个XML请求,则返回true,否则返回false。

检查当前请求是否是一个XML请求,或者是否在期待一个XML响应。

function wp_is_xml_request() {
	$accepted = array(
		'text/xml',
		'application/rss+xml',
		'application/atom+xml',
		'application/rdf+xml',
		'text/xml+oembed',
		'application/xml+oembed',
	);

	if ( isset( $_SERVER['HTTP_ACCEPT'] ) ) {
		foreach ( $accepted as $type ) {
			if ( false !== strpos( $_SERVER['HTTP_ACCEPT'], $type ) ) {
				return true;
			}
		}
	}

	if ( isset( $_SERVER['CONTENT_TYPE'] ) && in_array( $_SERVER['CONTENT_TYPE'], $accepted, true ) ) {
		return true;
	}

	return false;
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2026-01-29 05:09:31

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: