woocommerce/woocommerce-rest-api.php

49 lines
1.2 KiB
PHP
Raw Normal View History

<?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
* License: GPLv3
*
* @package WooCommerce/RestApi
*/
defined( 'ABSPATH' ) || exit;
2019-05-10 22:33:31 +00:00
if ( version_compare( PHP_VERSION, '5.6.0', '<' ) ) {
return;
}
/**
* API feature plugin version.
*
* @internal This version needs incrementing when releasing new versions of the API.
*/
$version = '1.1.0';
/**
* This callback loads this version of the API.
*/
2019-05-22 12:46:06 +00:00
$init_callback = function() use ( $version ) {
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();
};
/**
* 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;
}
wc()->api->register( $version, $init_callback );
};
add_action( 'woocommerce_loaded', $register_callback );