Created
April 26, 2023 07:01
-
-
Save qant/52fa02625763778eb447023be79ee9aa to your computer and use it in GitHub Desktop.
modify printify response for wordpress http request 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 | |
/** | |
* @see Printify_Shipping_API::get_shipping_rates() | |
* @see \WP_Http::request() | |
*/ | |
function modify_printify_response( $response, $parsed_args, $url ) { | |
// Check is it a request to Printify. | |
if( 0 !== strpos( $url, 'https://api-prod.printify.com' ) ) { | |
return $response; | |
} | |
$body = json_decode( $response['body'] ); | |
// TODO Manipulate the repsonse. | |
$response['body'] = wp_json_encode( $body ); | |
return $response; | |
} | |
add_filter( 'http_response', 'modify_printify_response', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment