wp_is_xml_request

The timeline below displays how wordpress function wp_is_xml_request has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Checks whether current request is an XML request, or is expecting an XML response.
 *
 * @since 5.2.0
 *
 * @return bool True if `Accepts` or `Content-Type` headers contain `text/xml`
 *              or one of the related MIME types. False otherwise.
 */
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 (str_contains($_SERVER['HTTP_ACCEPT'], $type)) {
                return true;
            }
        }
    }
    if (isset($_SERVER['CONTENT_TYPE']) && in_array($_SERVER['CONTENT_TYPE'], $accepted, true)) {
        return true;
    }
    return false;
}

WordPress Version: 5.4

/**
 * Checks whether current request is an XML request, or is expecting an XML response.
 *
 * @since 5.2.0
 *
 * @return bool True if `Accepts` or `Content-Type` headers contain `text/xml`
 *              or one of the related MIME types. False otherwise.
 */
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;
}

WordPress Version: 5.2

/**
 * Checks whether current request is an XML request, or is expecting an XML response.
 *
 * @since 5.2.0
 *
 * @return bool True if Accepts or Content-Type headers contain xml, false otherwise.
 */
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;
}