get_endpoint_data should be in core

This commit is contained in:
Mike Jolley 2019-06-12 13:17:16 +01:00
parent 732eb4b453
commit e45cd8addf
1 changed files with 0 additions and 21 deletions

View File

@ -49,27 +49,6 @@ class Server {
}
}
/**
* Get data from a WooCommerce API endpoint.
*
* @param string $endpoint Endpoint.
* @param array $params Params to passwith request.
* @return array|WP_Error
*/
public function get_endpoint_data( $endpoint, $params = array() ) {
$request = new \WP_REST_Request( 'GET', $endpoint );
if ( $params ) {
$request->set_query_params( $params );
}
$response = \rest_do_request( $request );
$server = \rest_get_server();
$json = wp_json_encode( $server->response_to_data( $response, false ) );
return json_decode( $json, true );
}
/**
* Get API namespaces - new namespaces should be registered here.
*