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( 'woocommerce_loaded', array( $this, 'init' ) ); 
  12.  
  13. public function init() { 
  14.  
  15. global $wp_version; 
  16.  
  17. if ( version_compare( WC_GZD_Dependencies::instance()->get_plugin_version( 'woocommerce' ), '2.6', '<' ) || version_compare( $wp_version, 4.4, '<' ) ) 
  18. return; 
  19.  
  20. $this->rest_api_includes(); 
  21.  
  22. // Init REST API routes. 
  23. add_action( 'rest_api_init', array( $this, 'register_rest_routes' ), 25 ); 
  24.  
  25.  
  26. public function rest_api_includes() { 
  27. // REST API controllers. 
  28. include_once( 'class-wc-gzd-rest-customers-controller.php' ); 
  29. include_once( 'class-wc-gzd-rest-orders-controller.php' ); 
  30. include_once( 'class-wc-gzd-rest-product-delivery-times-controller.php' ); 
  31. include_once( 'class-wc-gzd-rest-product-price-labels-controller.php' ); 
  32. include_once( 'class-wc-gzd-rest-product-units-controller.php' ); 
  33. include_once( '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_Controller',  
  39. 'WC_GZD_REST_Product_Price_Labels_Controller',  
  40. 'WC_GZD_REST_Product_Units_Controller',  
  41. 'WC_GZD_REST_Customers_Controller',  
  42. 'WC_GZD_REST_Orders_Controller',  
  43. 'WC_GZD_REST_Products_Controller',  
  44. ) ); 
  45.  
  46. foreach ( $controllers as $controller ) { 
  47. WC()->api->$controller = new $controller(); 
  48.  
  49. if ( method_exists( WC()->api->$controller, 'register_routes' ) ) 
  50. WC()->api->$controller->register_routes(); 
  51.  
  52. if ( method_exists( WC()->api->$controller, 'register_fields' ) ) 
  53. WC()->api->$controller->register_fields(); 
  54.  
  55.