72 lines
1.6 KiB
PHP
72 lines
1.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Wiaas API
|
|
*
|
|
* Handles wiaas API endpoint requests
|
|
*/
|
|
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
/**
|
|
* API class
|
|
*/
|
|
class Wiaas_API {
|
|
|
|
public static function init() {
|
|
|
|
if ( ! class_exists( 'WP_REST_Server' ) ) {
|
|
return;
|
|
}
|
|
|
|
self::_rest_api_includes();
|
|
|
|
// Init REST API routes.
|
|
add_action( 'rest_api_init', array( __CLASS__, 'register_rest_routes' ), 10 );
|
|
}
|
|
|
|
/**
|
|
* Include REST API classes
|
|
*/
|
|
private static function _rest_api_includes() {
|
|
|
|
#Delivery process controller
|
|
include_once dirname( __FILE__ ) . '/api/class-wiaas-rest-delivery-process-api.php';
|
|
include_once dirname( __FILE__ ) . '/api/class-wiaas-cart-api.php';
|
|
include_once dirname( __FILE__ ) . '/api/class-wiaas-document-api.php';
|
|
|
|
#User controller
|
|
include_once dirname( __FILE__ ) . '/api/class-wiaas-rest-user-api.php';
|
|
|
|
#Customer controller
|
|
include_once dirname( __FILE__ ) . '/api/class-wiaas-rest-customer.php';
|
|
|
|
include_once dirname( __FILE__ ) . '/api/class-wiaas-order-projects-api.php';
|
|
|
|
include_once dirname( __FILE__ ) . '/api/class-wiaas-wc-package-api-integration.php';
|
|
include_once dirname( __FILE__ ) . '/api/class-wiaas-support-api.php';
|
|
|
|
// API functions
|
|
include_once dirname( __FILE__ ) . '/api/wiaas-api-functions.php';
|
|
|
|
}
|
|
|
|
public static function register_rest_routes() {
|
|
$controllers = array(
|
|
'Wiass_REST_Delivery_Process_API',
|
|
'Wiaas_Cart_API',
|
|
'Wiaas_Document_API',
|
|
'Wiass_REST_User_API',
|
|
'Wiaas_REST_Customer_API',
|
|
'Wiaas_Order_Projects_API',
|
|
'Wiaas_Support_Api',
|
|
);
|
|
|
|
foreach ( $controllers as $controller ) {
|
|
call_user_func(array($controller, 'register_routes'));
|
|
}
|
|
}
|
|
}
|
|
|
|
Wiaas_API::init();
|