Un motore di ricerca WordPress per sviluppatori e autori di temi



wp_is_xml_request ›

Da5.2.0
Deprecaton/a
wp_is_xml_request ( Nessun parametro )
Ritorna:
  • (bool) True if Accepts or Content-Type headers contain xml, false otherwise.
Definito a:
Codex:

Checks whether current request is an XML request, or is expecting an XML response.



Sorgenti

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