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
946            * will be used to serve the request instead.
947            *
948            * @since 4.4.0
949            *
950            * @param mixed           $result  Response to replace the requested version with. Can be anything
951            *                                 a normal endpoint can return, or null to not hijack the request.
952            * @param WP_REST_Server  $server  Server instance.
953            * @param WP_REST_Request $request Request used to generate the response.
954            */
955           $result = apply_filters( 'rest_pre_dispatch', null, $this, $request );
956
957           if ( ! empty( $result ) ) {
958                return $result;
959           }
960
961           $error   = null;
962           $matched = $this->match_request_to_handler( $request );
963
964           if ( is_wp_error( $matched ) ) {
 
Line Code
1644           }
1645
1646           foreach ( $requests as $i => $single_request ) {
1647                $clean_request = clone $single_request;
1648                $clean_request->set_url_params( array() );
1649                $clean_request->set_attributes( array() );
1650                $clean_request->set_default_params( array() );
1651
1652                /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */
1653                $result = apply_filters( 'rest_pre_dispatch', null, $this, $clean_request );
1654
1655                if ( empty( $result ) ) {
1656                     $match = $matches[ $i ];
1657                     $error = null;
1658
1659                     if ( is_wp_error( $validation[ $i ] ) ) {
1660                          $error = $validation[ $i ];
1661                     }
1662