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-04-10 23:13:09 +00:00
* Version : 2.1 . 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-04-08 23:24:02 +00:00
* WC requires at least : 3.6
2019-02-22 18:16:46 +00:00
* WC tested up to : 3.6
2018-12-11 17:14:02 +00:00
*
* @ package WooCommerce\Blocks
2018-02-13 19:03:53 +00:00
*/
defined ( 'ABSPATH' ) || die ();
2019-04-10 23:13:09 +00:00
define ( 'WGPB_VERSION' , '2.1.0-dev' );
2019-03-04 17:30:06 +00:00
define ( 'WGPB_PLUGIN_FILE' , __FILE__ );
define ( 'WGPB_ABSPATH' , dirname ( WGPB_PLUGIN_FILE ) . '/' );
2018-11-13 19:12:32 +00:00
2018-02-15 17:42:24 +00:00
/**
* Load up the assets if Gutenberg is active .
*/
2018-02-13 19:03:53 +00:00
function wgpb_initialize () {
2019-03-04 17:30:06 +00:00
require_once plugin_dir_path ( __FILE__ ) . 'assets/php/class-wgpb-block-library.php' ;
2018-02-13 19:03:53 +00:00
2019-04-19 16:30:59 +00:00
// Remove core hook in favor of our local feature plugin handler.
remove_action ( 'init' , array ( 'WC_Block_Library' , 'init' ) );
2019-04-19 16:51:24 +00:00
// Remove core hooks from pre-3.6 (in 3.6.2 all functions were moved to one hook on init).
remove_action ( 'init' , array ( 'WC_Block_Library' , 'register_blocks' ) );
remove_action ( 'init' , array ( 'WC_Block_Library' , 'register_assets' ) );
remove_filter ( 'block_categories' , array ( 'WC_Block_Library' , 'add_block_category' ) );
remove_action ( 'admin_print_footer_scripts' , array ( 'WC_Block_Library' , 'print_script_settings' ), 1 );
2018-11-19 16:33:17 +00:00
2019-03-04 17:30:06 +00:00
$files_exist = file_exists ( plugin_dir_path ( __FILE__ ) . '/build/featured-product.js' );
if ( defined ( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG && ! $files_exist ) {
2018-11-13 19:12:32 +00:00
add_action ( 'admin_notices' , 'wgpb_plugins_notice' );
2018-02-13 19:03:53 +00:00
}
}
add_action ( 'woocommerce_loaded' , 'wgpb_initialize' );
2018-11-13 19:12:32 +00:00
/**
* Display a warning about building files .
*/
function wgpb_plugins_notice () {
echo '<div class="error"><p>' ;
2018-12-14 14:57:11 +00:00
printf (
/* Translators: %1$s is the install command, %2$s is the build command, %3$s is the watch command. */
esc_html__ ( 'WooCommerce Blocks development mode requires files to be built. From the plugin directory, run %1$s to install dependencies, %2$s to build the files or %3$s to build the files and watch for changes.' , 'woo-gutenberg-products-block' ),
'<code>npm install</code>' ,
'<code>npm run build</code>' ,
'<code>npm start</code>'
);
2018-11-13 19:12:32 +00:00
echo '</p></div>' ;
}