WordPress at Your Fingertips
function is not described

WC_API_Server::is_json_request() private WC 2.1

Check if the current request accepts a JSON response by checking the endpoint suffix (.json) or the HTTP ACCEPT header

{} It's a method of the class: WC_API_Server{}

No Hooks.

Return

true|false.

Usage

// private - for code of main (parent) class only
$result = $this->is_json_request();

Changelog

Since 2.1 Introduced.

Code of WC_API_Server::is_json_request() WC 5.7.1

private function is_json_request() {

	// check path
	if ( false !== stripos( $this->path, '.json' ) ) {
		return true;
	}

	// check ACCEPT header, only 'application/json' is acceptable, see RFC 4627
	if ( isset( $this->headers['ACCEPT'] ) && 'application/json' == $this->headers['ACCEPT'] ) {
		return true;
	}

	return false;
}