Merge pull request #23958 from woocommerce/update/legacy-api-location

Move legacy API to `/legacy/` directory
This commit is contained in:
Mike Jolley 2019-06-26 11:48:43 +01:00 committed by GitHub
commit cdfb684823
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 39 additions and 42 deletions

View File

@ -24,8 +24,6 @@ class WC_API extends WC_Legacy_API {
* @since 2.0 * @since 2.0
*/ */
public function __construct() { public function __construct() {
parent::__construct();
$this->wc_api_init(); $this->wc_api_init();
$this->rest_api_init(); $this->rest_api_init();
} }

View File

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

View File

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