2019-05-10 16:56:07 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Plugin Name: WooCommerce REST API
|
|
|
|
* Plugin URI: https://github.com/woocommerce/woocommerce-rest-api
|
|
|
|
* Description: The WooCommerce core REST API, installed as a feature plugin for development and testing purposes. Requires WooCommerce 3.7+ and PHP 5.3+.
|
|
|
|
* Author: Automattic
|
|
|
|
* Author URI: https://woocommerce.com
|
2019-05-10 22:33:12 +00:00
|
|
|
* Version: 1.0.0-dev
|
2019-05-10 22:33:31 +00:00
|
|
|
* Requires PHP: 5.6
|
2019-05-10 16:56:07 +00:00
|
|
|
* License: GPLv3
|
|
|
|
*
|
2019-05-22 12:24:03 +00:00
|
|
|
* @package WooCommerce/RestApi
|
2019-05-10 16:56:07 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
|
2019-05-10 22:33:31 +00:00
|
|
|
if ( version_compare( PHP_VERSION, '5.6.0', '<' ) ) {
|
2019-05-10 16:56:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-05-22 12:24:03 +00:00
|
|
|
/**
|
|
|
|
* API feature plugin version.
|
|
|
|
*
|
|
|
|
* @internal This version needs incrementing when releasing new versions of the API.
|
|
|
|
*/
|
|
|
|
$version = '1.1.0';
|
2019-05-10 16:56:07 +00:00
|
|
|
|
2019-05-22 12:24:03 +00:00
|
|
|
/**
|
|
|
|
* This callback loads this version of the API.
|
|
|
|
*/
|
2019-05-22 12:46:06 +00:00
|
|
|
$init_callback = function() use ( $version ) {
|
2019-05-22 12:24:03 +00:00
|
|
|
require __DIR__ . '/vendor/autoload.php';
|
2019-05-22 12:46:06 +00:00
|
|
|
$rest_api = \WooCommerce\RestApi::instance();
|
|
|
|
$rest_api->set_version( $version );
|
|
|
|
$rest_api->init();
|
2019-05-22 12:24:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This callback registers this version of the API with WooCommerce.
|
|
|
|
*/
|
|
|
|
$register_callback = function() use ( $version, $init_callback ) {
|
|
|
|
if ( ! is_callable( array( wc()->api, 'register' ) ) ) {
|
|
|
|
return;
|
2019-05-10 16:56:07 +00:00
|
|
|
}
|
2019-05-22 12:24:03 +00:00
|
|
|
wc()->api->register( $version, $init_callback );
|
|
|
|
};
|
|
|
|
|
|
|
|
add_action( 'woocommerce_loaded', $register_callback );
|