diff --git a/src/RestApi.php b/src/RestApi.php index 1720f68c210..ecc20286b55 100644 --- a/src/RestApi.php +++ b/src/RestApi.php @@ -24,6 +24,13 @@ class RestApi { */ protected $endpoints = []; + /** + * REST API package version. + * + * @var string + */ + protected $version; + /** * Hook into WordPress ready to init the REST API as needed. */ @@ -31,6 +38,24 @@ class RestApi { add_action( 'rest_api_init', array( $this, 'register_rest_routes' ), 10 ); } + /** + * Return REST API package version. + * + * @return string + */ + public function get_version() { + return $this->version; + } + + /** + * Set REST API package version. + * + * @param string $version Version to set. + */ + public function set_version( $version ) { + $this->version = $version; + } + /** * Register REST API routes. */ diff --git a/woocommerce-rest-api.php b/woocommerce-rest-api.php index 884b25e634b..ef0ae00a5d3 100644 --- a/woocommerce-rest-api.php +++ b/woocommerce-rest-api.php @@ -28,9 +28,11 @@ $version = '1.1.0'; /** * This callback loads this version of the API. */ -$init_callback = function() { +$init_callback = function() use ( $version ) { require __DIR__ . '/vendor/autoload.php'; - \WooCommerce\RestApi::instance()->init(); + $rest_api = \WooCommerce\RestApi::instance(); + $rest_api->set_version( $version ); + $rest_api->init(); }; /**