WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )apply_filters( "hook_name", "what_to_filter" ).Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 2 times in this file.
| Line | Code |
|---|---|
| 988 | * will be used to serve the request instead. |
| 989 | * |
| 990 | * @since 4.4.0 |
| 991 | * |
| 992 | * @param mixed $result Response to replace the requested version with. Can be anything |
| 993 | * a normal endpoint can return, or null to not hijack the request. |
| 994 | * @param WP_REST_Server $server Server instance. |
| 995 | * @param WP_REST_Request $request Request used to generate the response. |
| 996 | */ |
| 997 | $result = apply_filters( 'rest_pre_dispatch', null, $this, $request ); |
| 998 | |
| 999 | if ( ! empty( $result ) ) { |
| 1000 | |
| 1001 | // Normalize to either WP_Error or WP_REST_Response... |
| 1002 | $result = rest_ensure_response( $result ); |
| 1003 | |
| 1004 | // ...then convert WP_Error across. |
| 1005 | if ( is_wp_error( $result ) ) { |
| 1006 | $result = $this->error_to_response( $result ); |
| Line | Code |
| 1714 | } |
| 1715 | |
| 1716 | foreach ( $requests as $i => $single_request ) { |
| 1717 | $clean_request = clone $single_request; |
| 1718 | $clean_request->set_url_params( array() ); |
| 1719 | $clean_request->set_attributes( array() ); |
| 1720 | $clean_request->set_default_params( array() ); |
| 1721 | |
| 1722 | /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */ |
| 1723 | $result = apply_filters( 'rest_pre_dispatch', null, $this, $clean_request ); |
| 1724 | |
| 1725 | if ( empty( $result ) ) { |
| 1726 | $match = $matches[ $i ]; |
| 1727 | $error = null; |
| 1728 | |
| 1729 | if ( is_wp_error( $validation[ $i ] ) ) { |
| 1730 | $error = $validation[ $i ]; |
| 1731 | } |
| 1732 | |