wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



wp_is_rest_endpoint › WordPress Function

Od6.5.0
Przestarzałyn/a
wp_is_rest_endpoint ( Brak parametrów )
Powrót:
  • (bool) True if a REST endpoint request is currently being handled, false otherwise.
Zdefiniowane na:
Codex:

Checks whether a REST API endpoint request is currently being handled.

This may be a standalone REST API request, or an internal request dispatched from within a regular page load.


Źródło

function wp_is_rest_endpoint() {
	/* @var WP_REST_Server $wp_rest_server */
	global $wp_rest_server;

	// Check whether this is a standalone REST request.
	$is_rest_endpoint = wp_is_serving_rest_request();
	if ( ! $is_rest_endpoint ) {
		// Otherwise, check whether an internal REST request is currently being handled.
		$is_rest_endpoint = isset( $wp_rest_server )
			&& $wp_rest_server->is_dispatching();
	}

	/**
	 * Filters whether a REST endpoint request is currently being handled.
	 *
	 * This may be a standalone REST API request, or an internal request dispatched from within a regular page load.
	 *
	 * @since 6.5.0
	 *
	 * @param bool $is_request_endpoint Whether a REST endpoint request is currently being handled.
	 */
	return (bool) apply_filters( 'wp_is_rest_endpoint', $is_rest_endpoint );
}