http_response
Filters the HTTP API response immediately before the response is returned.
Description
Parameters (3)
- 0. $response (array)
- HTTP response.
- 1. $r (array)
- HTTP request arguments.
- 2. $url (string)
- The request URL.
Usage
- To run the hook, copy the example below.
- $response = apply_filters( 'http_response', $response, $r, $url );
- if ( !empty( $response ) ) {
- // everything has led up to this point...
- }
- The following example is for adding a hook callback.
- // define the http_response callback
- function filter_http_response( $response, $r, $url ) {
- // make filter magic happen here...
- return $response;
- };
- // add the filter
- add_filter( 'http_response', 'filter_http_response', 10, 3 );
- To remove a hook callback, use the example below.
- // remove the filter
- remove_filter( 'http_response', 'filter_http_response', 10, 3 );
Defined (2)
The filter is defined in the following location(s).
- /wp-includes/class-http.php
- return apply_filters( 'http_response', $response, $r, $url );
- return apply_filters( 'http_response', $response, $args, $url );