====================================================
|
|
class WP_REST_Server { |
828 | 828 | } |
829 | 829 | } |
830 | 830 | |
| 831 | $did_run_before_callbacks = false; |
| 832 | if ( ! is_wp_error( $response ) ) { |
| 833 | /** |
| 834 | * Call a filter before executing any callbacks. Allows |
| 835 | * plugins to perform additional validation after a request |
| 836 | * is initialized but before it is executed. |
| 837 | * |
| 838 | * @since 4.4.2 |
| 839 | * |
| 840 | * @param WP_HTTP_Response $response Result to send to the client. Usually a WP_REST_Response. |
| 841 | * @param WP_REST_Server $handler ResponseHandler instance (usually WP_REST_Server). |
| 842 | * @param WP_REST_Request $request Request used to generate the response. |
| 843 | */ |
| 844 | $response = apply_filters( 'rest_request_before_callbacks', $response, $handler, $request ); |
| 845 | $did_run_before_callbacks = true; |
| 846 | } |
| 847 | |
831 | 848 | if ( ! is_wp_error( $response ) ) { |
832 | 849 | // Check permission specified on the route. |
833 | 850 | if ( ! empty( $handler['permission_callback'] ) ) { |
… |
… |
class WP_REST_Server { |
862 | 879 | } |
863 | 880 | } |
864 | 881 | |
| 882 | if ( $did_run_before_callbacks ) { |
| 883 | /** |
| 884 | * Call a filter immediately after executing the request |
| 885 | * callback(s). Allows plugins to perform any needed |
| 886 | * cleanup, for example, to undo changes made by |
| 887 | * `rest_request_before_callbacks`. |
| 888 | * |
| 889 | * @since 4.4.2 |
| 890 | * |
| 891 | * @param WP_HTTP_Response $response Result to send to the client. Usually a WP_REST_Response. |
| 892 | * @param WP_REST_Server $handler ResponseHandler instance (usually WP_REST_Server). |
| 893 | * @param WP_REST_Request $request Request used to generate the response. |
| 894 | */ |
| 895 | $response = apply_filters( 'rest_request_after_callbacks', $response, $handler, $request ); |
| 896 | } |
| 897 | |
865 | 898 | if ( is_wp_error( $response ) ) { |
866 | 899 | $response = $this->error_to_response( $response ); |
867 | 900 | } else { |