wpseek.com
Un motore di ricerca WordPress per sviluppatori e autori di temi



wp_is_serving_rest_request › WordPress Function

Da6.5.0
Deprecaton/a
wp_is_serving_rest_request ( Nessun parametro )
Ritorna:
  • (bool) True if it's a WordPress REST API request, false otherwise.
Definito a:
Codex:

Determines whether WordPress is currently serving a REST API request.

The function relies on the 'REST_REQUEST' global. As such, it only returns true when an actual REST request is being made. It does not return true when a REST endpoint is hit as part of another request, e.g. for preloading a REST response. See {@see} for that purpose. This function should not be called until the {@see 'parse_request'} action, as the constant is only defined then, even for an actual REST request.


Sorgenti

function wp_is_serving_rest_request() {
	return defined( 'REST_REQUEST' ) && REST_REQUEST;
}