Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: rest_pre_dispatch

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
941            * will be used to serve the request instead.
942            *
943            * @since 4.4.0
944            *
945            * @param mixed           $result  Response to replace the requested version with. Can be anything
946            *                                 a normal endpoint can return, or null to not hijack the request.
947            * @param WP_REST_Server  $server  Server instance.
948            * @param WP_REST_Request $request Request used to generate the response.
949            */
950           $result = apply_filters( 'rest_pre_dispatch', null, $this, $request );
951
952           if ( ! empty( $result ) ) {
953                return $result;
954           }
955
956           $error   = null;
957           $matched = $this->match_request_to_handler( $request );
958
959           if ( is_wp_error( $matched ) ) {
 
Line Code
1569           }
1570
1571           foreach ( $requests as $i => $single_request ) {
1572                $clean_request = clone $single_request;
1573                $clean_request->set_url_params( array() );
1574                $clean_request->set_attributes( array() );
1575                $clean_request->set_default_params( array() );
1576
1577                /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */
1578                $result = apply_filters( 'rest_pre_dispatch', null, $this, $clean_request );
1579
1580                if ( empty( $result ) ) {
1581                     $match = $matches[ $i ];
1582                     $error = null;
1583
1584                     if ( is_wp_error( $validation[ $i ] ) ) {
1585                          $error = $validation[ $i ];
1586                     }
1587