Update paths to legacy API and implement init method.

This commit is contained in:
Mike Jolley 2019-06-19 11:29:49 +01:00
parent 00a8ef5d4d
commit 038bac16f5
2 changed files with 39 additions and 40 deletions

View File

@ -459,6 +459,7 @@ final class WooCommerce {
$this->theme_support_includes();
$this->query = new WC_Query();
$this->api = new WC_API();
$this->api->init();
}
/**

View File

@ -43,11 +43,9 @@ class WC_Legacy_API {
public $authentication;
/**
* Setup class.
*
* @since 2.0
* Init the legacy API.
*/
public function __construct() {
public function init() {
add_action( 'parse_request', array( $this, 'handle_rest_api_requests' ), 0 );
}
@ -128,23 +126,23 @@ class WC_Legacy_API {
public function includes() {
// API server / response handlers.
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-exception.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-server.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/interface-wc-api-handler.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-json-handler.php' );
include_once( dirname( __FILE__ ) . '/api/v3/class-wc-api-exception.php' );
include_once( dirname( __FILE__ ) . '/api/v3/class-wc-api-server.php' );
include_once( dirname( __FILE__ ) . '/api/v3/interface-wc-api-handler.php' );
include_once( dirname( __FILE__ ) . '/api/v3/class-wc-api-json-handler.php' );
// Authentication.
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-authentication.php' );
include_once( dirname( __FILE__ ) . '/api/v3/class-wc-api-authentication.php' );
$this->authentication = new WC_API_Authentication();
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-resource.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-coupons.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-customers.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-orders.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-products.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-reports.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-taxes.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-webhooks.php' );
include_once( dirname( __FILE__ ) . '/api/v3/class-wc-api-resource.php' );
include_once( dirname( __FILE__ ) . '/api/v3/class-wc-api-coupons.php' );
include_once( dirname( __FILE__ ) . '/api/v3/class-wc-api-customers.php' );
include_once( dirname( __FILE__ ) . '/api/v3/class-wc-api-orders.php' );
include_once( dirname( __FILE__ ) . '/api/v3/class-wc-api-products.php' );
include_once( dirname( __FILE__ ) . '/api/v3/class-wc-api-reports.php' );
include_once( dirname( __FILE__ ) . '/api/v3/class-wc-api-taxes.php' );
include_once( dirname( __FILE__ ) . '/api/v3/class-wc-api-webhooks.php' );
// Allow plugins to load other response handlers or resource classes.
do_action( 'woocommerce_api_loaded' );
@ -186,20 +184,20 @@ class WC_Legacy_API {
private function handle_v1_rest_api_request() {
// Include legacy required files for v1 REST API request.
include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-server.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v1/interface-wc-api-handler.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-json-handler.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-xml-handler.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-api-server.php' );
include_once( dirname( __FILE__ ) . '/api/v1/interface-wc-api-handler.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-api-json-handler.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-api-xml-handler.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-authentication.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-api-authentication.php' );
$this->authentication = new WC_API_Authentication();
include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-resource.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-coupons.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-customers.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-orders.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-products.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-reports.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-api-resource.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-api-coupons.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-api-customers.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-api-orders.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-api-products.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-api-reports.php' );
// Allow plugins to load other response handlers or resource classes.
do_action( 'woocommerce_api_loaded' );
@ -232,21 +230,21 @@ class WC_Legacy_API {
* @deprecated 2.6.0
*/
private function handle_v2_rest_api_request() {
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-exception.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-server.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/interface-wc-api-handler.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-json-handler.php' );
include_once( dirname( __FILE__ ) . '/api/v2/class-wc-api-exception.php' );
include_once( dirname( __FILE__ ) . '/api/v2/class-wc-api-server.php' );
include_once( dirname( __FILE__ ) . '/api/v2/interface-wc-api-handler.php' );
include_once( dirname( __FILE__ ) . '/api/v2/class-wc-api-json-handler.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-authentication.php' );
include_once( dirname( __FILE__ ) . '/api/v2/class-wc-api-authentication.php' );
$this->authentication = new WC_API_Authentication();
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-resource.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-coupons.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-customers.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-orders.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-products.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-reports.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-webhooks.php' );
include_once( dirname( __FILE__ ) . '/api/v2/class-wc-api-resource.php' );
include_once( dirname( __FILE__ ) . '/api/v2/class-wc-api-coupons.php' );
include_once( dirname( __FILE__ ) . '/api/v2/class-wc-api-customers.php' );
include_once( dirname( __FILE__ ) . '/api/v2/class-wc-api-orders.php' );
include_once( dirname( __FILE__ ) . '/api/v2/class-wc-api-products.php' );
include_once( dirname( __FILE__ ) . '/api/v2/class-wc-api-reports.php' );
include_once( dirname( __FILE__ ) . '/api/v2/class-wc-api-webhooks.php' );
// allow plugins to load other response handlers or resource classes.
do_action( 'woocommerce_api_loaded' );