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
2020-01-15 23:29:39 +00:00
* Version : 1.0 . 6
2019-05-10 22:33:31 +00:00
* Requires PHP : 5.6
2019-05-10 16:56:07 +00:00
* License : GPLv3
*
2019-06-21 09:40:39 +00:00
* @ package Automattic / WooCommerce / RestApi
2019-06-21 13:57:26 +00:00
* @ internal This file is only used when running the REST API as a feature plugin .
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-06-21 09:17:22 +00:00
/**
* Autoload packages .
*
* The package autoloader includes version information which prevents classes in this feature plugin
* conflicting with WooCommerce core .
*
* We want to fail gracefully if `composer install` has not been executed yet , so we are checking for the autoloader .
* If the autoloader is not present , let ' s log the failure and display a nice admin notice .
*/
2019-06-20 15:51:47 +00:00
$autoloader = __DIR__ . '/vendor/autoload_packages.php' ;
if ( is_readable ( $autoloader ) ) {
require $autoloader ;
2019-06-21 09:17:22 +00:00
} else {
if ( defined ( 'WP_DEBUG' ) && WP_DEBUG ) {
error_log ( // phpcs:ignore
sprintf (
/* translators: 1: composer command. 2: plugin directory */
2019-06-24 12:01:21 +00:00
esc_html__ ( 'Your installation of the WooCommerce REST API feature plugin is incomplete. Please run %1$s within the %2$s directory.' , 'woocommerce-rest-api' ),
2019-06-21 09:17:22 +00:00
'`composer install`' ,
'`' . esc_html ( str_replace ( ABSPATH , '' , __DIR__ ) ) . '`'
)
);
}
/**
* Outputs an admin notice if composer install has not been ran .
*/
add_action (
'admin_notices' ,
function () {
?>
< div class = " notice notice-error " >
< p >
< ? php
printf (
/* translators: 1: composer command. 2: plugin directory */
2019-06-24 12:01:21 +00:00
esc_html__ ( 'Your installation of the WooCommerce REST API feature plugin is incomplete. Please run %1$s within the %2$s directory.' , 'woocommerce-rest-api' ),
2019-06-21 09:17:22 +00:00
'<code>composer install</code>' ,
'<code>' . esc_html ( str_replace ( ABSPATH , '' , __DIR__ ) ) . '</code>'
);
?>
</ p >
</ div >
< ? php
}
);
return ;
2019-06-20 15:51:47 +00:00
}