From cf14034f9a7ba0ffe332332c2770a07aa5954f11 Mon Sep 17 00:00:00 2001 From: Kelly Dwan Date: Fri, 19 Apr 2019 12:51:24 -0400 Subject: [PATCH] Cherry-pick branch/2.0.x: Fix conflict with hooks + 3.6, pre 3.6.2 --- plugins/woocommerce-blocks/readme.txt | 7 ++++++- .../woocommerce-gutenberg-products-block.php | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/woocommerce-blocks/readme.txt b/plugins/woocommerce-blocks/readme.txt index 16b154ae5fd..1376640f270 100644 --- a/plugins/woocommerce-blocks/readme.txt +++ b/plugins/woocommerce-blocks/readme.txt @@ -4,7 +4,7 @@ Tags: gutenberg, woocommerce, woo commerce, products Requires at least: 5.0 Tested up to: 5.2 Requires PHP: 5.2 -Stable tag: 2.0.0 +Stable tag: 2.0.1 License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.html @@ -83,6 +83,11 @@ Release and roadmap notes available on the [WooCommerce Developers Blog](https:/ == Changelog == += 2.0.1 - 2019-04-22 = + +- Fix: Fix warnings about blocks already being registered. +- Fix: Fix a conflict with WooCommerce 3.6 and WooCommerce Blocks 1.4 (this change only applies to the version of blocks bundled with WooCommerce core). + = 2.0.0 - 2019-04-18 = - **BREAKING:** Requires WordPress 5.0+, WooCommerce 3.6+ diff --git a/plugins/woocommerce-blocks/woocommerce-gutenberg-products-block.php b/plugins/woocommerce-blocks/woocommerce-gutenberg-products-block.php index fcbcb138f36..9ac6ed44472 100644 --- a/plugins/woocommerce-blocks/woocommerce-gutenberg-products-block.php +++ b/plugins/woocommerce-blocks/woocommerce-gutenberg-products-block.php @@ -27,6 +27,11 @@ function wgpb_initialize() { // Remove core hook in favor of our local feature plugin handler. remove_action( 'init', array( 'WC_Block_Library', 'init' ) ); + // 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 ); $files_exist = file_exists( plugin_dir_path( __FILE__ ) . '/build/featured-product.js' ); if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG && ! $files_exist ) {