Files
old-new-wiaas/backend/app/plugins/wiaas/includes/class-wiaas-api.php

51 lines
929 B
PHP
Raw Normal View History

<?php
/**
* Wiaas API
*
* Handles wiaas API endpoint requests
*/
defined( 'ABSPATH' ) || exit;
2018-08-06 17:36:57 +02:00
/**
* API class
*/
class Wiaas_API {
2018-08-06 17:36:57 +02:00
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
*/
2018-08-06 17:36:57 +02:00
private static function _rest_api_includes() {
2018-08-06 17:36:57 +02:00
#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';
}
2018-08-06 17:36:57 +02:00
public static function register_rest_routes() {
$controllers = array(
'Wiass_REST_Delivery_Process_API',
'Wiaas_Cart_API'
2018-08-06 17:36:57 +02:00
);
foreach ( $controllers as $controller ) {
call_user_func(array($controller, 'register_routes'));
}
}
}
Wiaas_API::init();