version helpers
This commit is contained in:
parent
237d80f3f2
commit
12f667645d
|
@ -24,6 +24,13 @@ class RestApi {
|
||||||
*/
|
*/
|
||||||
protected $endpoints = [];
|
protected $endpoints = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* REST API package version.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook into WordPress ready to init the REST API as needed.
|
* 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 );
|
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.
|
* Register REST API routes.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -28,9 +28,11 @@ $version = '1.1.0';
|
||||||
/**
|
/**
|
||||||
* This callback loads this version of the API.
|
* This callback loads this version of the API.
|
||||||
*/
|
*/
|
||||||
$init_callback = function() {
|
$init_callback = function() use ( $version ) {
|
||||||
require __DIR__ . '/vendor/autoload.php';
|
require __DIR__ . '/vendor/autoload.php';
|
||||||
\WooCommerce\RestApi::instance()->init();
|
$rest_api = \WooCommerce\RestApi::instance();
|
||||||
|
$rest_api->set_version( $version );
|
||||||
|
$rest_api->init();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue