Last active
December 19, 2015 23:49
-
-
Save WerdsWords/6037579 to your computer and use it in GitHub Desktop.
#11: http_response
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Return canned body content for invalid http requests | |
* | |
* @see WP_Http::request() | |
* | |
* @param array $response The http response. | |
* @param array $args An array of arguments. | |
* @param string $url The request URL. | |
* | |
* @return array The filtered http response. | |
*/ | |
function wpdocs_invalid_request_response( $response, $args, $url ) { | |
if ( ! in_array( $response['response']['code'], array( 200, 301, 302 ) ) ) | |
$response['body'] = __( 'No content found', 'yourtextdomain' ); | |
return $response; | |
} | |
add_filter( 'http_response', 'wpdocs_invalid_request_response', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://fotd.werdswords.com/http_response