Our plugins contain a number of actions and filters that help extend or modify the functionality of our plugins. Code snippets would need to be added to your themes functions.php file
wpgetapi_default_request_args_parameters
This filter will modify the default arguments for the API calls such as timeout, sslverify, redirection and others. The full list of arguments can be found here – https://developer.wordpress.org/reference/classes/wp_http/request/
The filter can be used like below.
function wpgetapi_modify_arguments( $args ) {
$args['timeout'] = 30;
$args['sslverify'] = true;
return $args;
}
add_filter( 'wpgetapi_default_request_args_parameters', 'wpgetapi_modify_arguments', 10, 1 );
wpgetapi_final_url
This filter will modify the final URL that the API is calling.
function wpgetapi_modify_url( $url, $wpgetapi ) {
$url = $url . '?add=something';
return $url;
}
add_filter( 'wpgetapi_final_url', 'wpgetapi_modify_url', 10, 2 );
wpgetapi_before_retrieve_body
This filter can modify the response from the API as soon as we receive it.
function wpgetapi_modify_response( $response, $response_code, $wpgetapi ) {
$response = 'blah blah blah';
return $response;
}
add_filter( 'wpgetapi_before_retrieve_body', 'wpgetapi_modify_response', 10, 3 );