apply_filters( 'rest_dispatch_request', mixed $dispatch_result, WP_REST_Request $request, string $route, array $handler )
- Since
- 4.4.0, 4.5.0
Filters the REST API dispatch request result.
Description
Allow plugins to override dispatching the request.
Compatibility
- WordPress
- since 4.5.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Parameters
$dispatch_resultmixed- Dispatch result, will be used if not empty.
$requestWP_REST_Request- Request used to generate the response.
$routestring- Route matched for the request.
$handlerarray- Route handler used for the request.
Where this hook fires · 1
wp-includes/rest-api/class-wp-rest-server.php:1286WP_REST_Server::respond_to_request()
Source code
* * @param mixed $dispatch_result Dispatch result, will be used if not empty. * @param WP_REST_Request $request Request used to generate the response. * @param string $route Route matched for the request. * @param array $handler Route handler used for the request. */ $dispatch_result = apply_filters( 'rest_dispatch_request', null, $request, $route, $handler ); // Allow plugins to halt the request via this filter. if ( null !== $dispatch_result ) { $response = $dispatch_result; } else { $response = call_user_func( $handler['callback'], $request );Changelog
Introduced in 4.4.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
4.5.0
Added
$route and $handler parameters.from the docblock4.4.0
Introduced.from the docblock
About this page
- Parsed data
- Generated from the wordpress-develop 6.7.7 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
- Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.