WC_Legacy_API::handle_rest_api_requests()
Deprecated from version 2.6.0. It is no longer supported and can be removed in future releases. It is recommended to replace this function with the same one.
Handle REST API requests.
Method of the class: WC_Legacy_API{}
No Hooks.
Return
null
. Nothing.
Usage
$WC_Legacy_API = new WC_Legacy_API(); $WC_Legacy_API->handle_rest_api_requests();
Changelog
Since 2.2 | Introduced. |
Deprecated since | 2.6.0 |
WC_Legacy_API::handle_rest_api_requests() WC Legacy API::handle rest api requests code WC 7.7.0
public function handle_rest_api_requests() { global $wp; if ( ! empty( $_GET['wc-api-version'] ) ) { $wp->query_vars['wc-api-version'] = $_GET['wc-api-version']; } if ( ! empty( $_GET['wc-api-route'] ) ) { $wp->query_vars['wc-api-route'] = $_GET['wc-api-route']; } // REST API request. if ( ! empty( $wp->query_vars['wc-api-version'] ) && ! empty( $wp->query_vars['wc-api-route'] ) ) { wc_maybe_define_constant( 'WC_API_REQUEST', true ); wc_maybe_define_constant( 'WC_API_REQUEST_VERSION', absint( $wp->query_vars['wc-api-version'] ) ); // Legacy v1 API request. if ( 1 === WC_API_REQUEST_VERSION ) { $this->handle_v1_rest_api_request(); } elseif ( 2 === WC_API_REQUEST_VERSION ) { $this->handle_v2_rest_api_request(); } else { $this->includes(); $this->server = new WC_API_Server( $wp->query_vars['wc-api-route'] ); // load API resource classes. $this->register_resources( $this->server ); // Fire off the request. $this->server->serve_request(); } exit; } }