WC_GZD_REST_API

The WooCommerce Germanized WC GZD REST API class.

Defined (1)

The class is defined in the following location(s).

/includes/api/class-wc-gzd-rest-api.php  
  1. class WC_GZD_REST_API { 
  2.  
  3. protected static $_instance = null; 
  4.  
  5. public static function instance() { 
  6. if ( is_null( self::$_instance ) ) 
  7. self::$_instance = new self(); 
  8. return self::$_instance; 
  9.  
  10. private function __construct() { 
  11. add_action( 'rest_api_init', array( $this, 'init' ), 20 ); 
  12.  
  13. public function init() { 
  14. if ( version_compare( wc_gzd_get_dependencies()->get_plugin_version( 'woocommerce' ), '2.6', '<' ) ) 
  15. return; 
  16.  
  17. $this->rest_api_includes(); 
  18. $this->register_rest_routes(); 
  19.  
  20. public function rest_api_includes() { 
  21.  
  22. // REST API v1 controllers. 
  23. include_once( dirname( __FILE__ ) . '/v1/class-wc-gzd-rest-product-delivery-times-controller.php' ); 
  24. include_once( dirname( __FILE__ ) . '/v1/class-wc-gzd-rest-product-price-labels-controller.php' ); 
  25. include_once( dirname( __FILE__ ) . '/v1/class-wc-gzd-rest-product-units-controller.php' ); 
  26.  
  27. // REST API controllers. 
  28. include_once( dirname( __FILE__ ) . '/class-wc-gzd-rest-customers-controller.php' ); 
  29. include_once( dirname( __FILE__ ) . '/class-wc-gzd-rest-orders-controller.php' ); 
  30. include_once( dirname( __FILE__ ) . '/class-wc-gzd-rest-product-delivery-times-controller.php' ); 
  31. include_once( dirname( __FILE__ ) . '/class-wc-gzd-rest-product-price-labels-controller.php' ); 
  32. include_once( dirname( __FILE__ ) . '/class-wc-gzd-rest-product-units-controller.php' ); 
  33. include_once( dirname( __FILE__ ) . '/class-wc-gzd-rest-products-controller.php' ); 
  34.  
  35. public function register_rest_routes() { 
  36.  
  37. $controllers = apply_filters( 'woocommerce_gzd_rest_controller', array( 
  38. 'WC_GZD_REST_Product_Delivery_Times_V1_Controller',  
  39. 'WC_GZD_REST_Product_Delivery_Times_Controller',  
  40. 'WC_GZD_REST_Product_Price_Labels_V1_Controller',  
  41. 'WC_GZD_REST_Product_Price_Labels_Controller',  
  42. 'WC_GZD_REST_Product_Units_V1_Controller',  
  43. 'WC_GZD_REST_Product_Units_Controller',  
  44. 'WC_GZD_REST_Customers_Controller',  
  45. 'WC_GZD_REST_Orders_Controller',  
  46. 'WC_GZD_REST_Products_Controller',  
  47. ) ); 
  48.  
  49. foreach ( $controllers as $controller ) { 
  50. WC()->api->$controller = new $controller(); 
  51.  
  52. if ( method_exists( WC()->api->$controller, 'register_routes' ) ) 
  53. WC()->api->$controller->register_routes(); 
  54.  
  55. if ( method_exists( WC()->api->$controller, 'register_fields' ) ) 
  56. WC()->api->$controller->register_fields(); 
  57.