WC_API_Server::is_xml_request()
Check if the current request accepts an XML response by checking the endpoint suffix (.xml) or the HTTP ACCEPT header
Method of the class: WC_API_Server{}
No Hooks.
Return
true|false
.
Usage
// private - for code of main (parent) class only $result = $this->is_xml_request();
Changelog
Since 2.1 | Introduced. |
WC_API_Server::is_xml_request() WC API Server::is xml request code WC 7.7.0
private function is_xml_request() { // check path if ( false !== stripos( $this->path, '.xml' ) ) { return true; } // check headers, 'application/xml' or 'text/xml' are acceptable, see RFC 2376 if ( isset( $this->headers['ACCEPT'] ) && ( 'application/xml' == $this->headers['ACCEPT'] || 'text/xml' == $this->headers['ACCEPT'] ) ) { return true; } return false; }