2018-02-13 19:03:53 +00:00
< ? php
/**
2018-12-04 20:54:14 +00:00
* Plugin Name : WooCommerce Blocks
2018-02-13 19:03:53 +00:00
* Plugin URI : https :// github . com / woocommerce / woocommerce - gutenberg - products - block
2018-12-04 20:54:14 +00:00
* Description : WooCommerce blocks for the Gutenberg editor .
2019-08-29 09:46:11 +00:00
* Version : 2.5 . 0 - dev
2018-02-13 19:03:53 +00:00
* Author : Automattic
* Author URI : https :// woocommerce . com
2018-12-04 14:51:21 +00:00
* Text Domain : woo - gutenberg - products - block
2019-11-11 17:06:03 +00:00
* Requires at least : 5.0
* Requires PHP : 5.6
2019-04-08 23:24:02 +00:00
* WC requires at least : 3.6
2019-11-11 17:06:03 +00:00
* WC tested up to : 3.8
2018-12-11 17:14:02 +00:00
*
* @ package WooCommerce\Blocks
2019-07-01 12:52:44 +00:00
* @ internal This file is only used when running the REST API as a feature plugin .
2018-02-13 19:03:53 +00:00
*/
2019-07-01 12:52:44 +00:00
defined ( 'ABSPATH' ) || exit ;
2018-02-13 19:03:53 +00:00
2019-07-01 12:52:44 +00:00
if ( version_compare ( PHP_VERSION , '5.6.0' , '<' ) ) {
return ;
2018-02-13 19:03:53 +00:00
}
2018-11-13 19:12:32 +00:00
/**
2019-07-01 12:52:44 +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 .
2018-11-13 19:12:32 +00:00
*/
2019-07-01 12:52:44 +00:00
$autoloader = __DIR__ . '/vendor/autoload_packages.php' ;
if ( is_readable ( $autoloader ) ) {
require $autoloader ;
} else {
if ( defined ( 'WP_DEBUG' ) && WP_DEBUG ) {
error_log ( // phpcs:ignore
sprintf (
/* translators: 1: composer command. 2: plugin directory */
esc_html__ ( 'Your installation of the WooCommerce Blocks feature plugin is incomplete. Please run %1$s within the %2$s directory.' , 'woo-gutenberg-products-block' ),
'`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 */
esc_html__ ( 'Your installation of the WooCommerce Blocks feature plugin is incomplete. Please run %1$s within the %2$s directory.' , 'woo-gutenberg-products-block' ),
'<code>composer install</code>' ,
'<code>' . esc_html ( str_replace ( ABSPATH , '' , __DIR__ ) ) . '</code>'
);
?>
</ p >
</ div >
< ? php
}
2018-12-14 14:57:11 +00:00
);
2019-07-01 12:52:44 +00:00
return ;
2018-11-13 19:12:32 +00:00
}
2019-07-01 12:52:44 +00:00
2019-09-23 18:07:13 +00:00
/**
* Loads the dependency injection container for woocommerce blocks .
*
* @ param boolean $reset Used to reset the container to a fresh instance .
* Note : this means all dependencies will be reconstructed .
*/
function wc_blocks_container ( $reset = false ) {
static $container ;
if (
! $container instanceof Automattic\WooCommerce\Blocks\Registry\Container
|| $reset
) {
$container = new Automattic\WooCommerce\Blocks\Registry\Container ();
// register Package.
$container -> register (
Automattic\WooCommerce\Blocks\Domain\Package :: class ,
function ( $container ) {
2019-11-12 16:26:35 +00:00
// leave for automated version bumping.
$version = '2.5.0-dev' ;
2019-09-23 18:07:13 +00:00
return new Automattic\WooCommerce\Blocks\Domain\Package (
2019-11-12 16:26:35 +00:00
$version ,
2019-09-23 18:07:13 +00:00
__FILE__
);
}
);
// register Bootstrap.
$container -> register (
Automattic\WooCommerce\Blocks\Domain\Bootstrap :: class ,
function ( $container ) {
return new Automattic\WooCommerce\Blocks\Domain\Bootstrap (
$container
);
}
);
}
return $container ;
}
add_action ( 'plugins_loaded' , 'wc_blocks_bootstrap' );
/**
* Boostrap WooCommerce Blocks App
*/
function wc_blocks_bootstrap () {
// initialize bootstrap.
wc_blocks_container () -> get (
Automattic\WooCommerce\Blocks\Domain\Bootstrap :: class
);
}