wphooks.info - rest_dispatch_request

rest_dispatch_request

(trunk - 5.1-alpha-44286)

The hook occurs in the following file:

wp-includes/rest-api/class-wp-rest-server.php:
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
					 * Allow plugins to override dispatching the request.
					 *
					 * @since 4.4.0
					 * @since 4.5.0 Added `$route` and `$handler` parameters.
					 *
					 * @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( $callback, $request );
					}
				}