| Server IP : 14.225.204.176 / Your IP : 216.73.216.6 Web Server : nginx/1.24.0 System : Linux nodejs-ybgk 6.8.0-40-generic #40-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 5 10:34:03 UTC 2024 x86_64 User : root ( 0) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/html/php/fe2tech/wp-content/plugins/woocommerce/src/Utilities/ |
Upload File : |
<?php
namespace Automattic\WooCommerce\Utilities;
/**
* Utility methods related to the REST API.
*/
class RestApiUtil {
/**
* Get data from a WooCommerce API endpoint.
* This method used to be part of the WooCommerce Legacy REST API.
*
* @since 9.0.0
*
* @param string $endpoint Endpoint.
* @param array $params Params to pass with 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 );
}
}