diff --git a/src/BlockTemplatesController.php b/src/BlockTemplatesController.php index 6cf131b9bc7..49f6878d13f 100644 --- a/src/BlockTemplatesController.php +++ b/src/BlockTemplatesController.php @@ -295,7 +295,7 @@ public function get_block_file_template( $template, $id, $template_type ) { * @return array */ public function add_block_templates( $query_result, $query, $template_type ) { - if ( ! BlockTemplateUtils::supports_block_templates() ) { + if ( ! BlockTemplateUtils::supports_block_templates( $template_type ) ) { return $query_result; } diff --git a/src/BlockTypes/MiniCart.php b/src/BlockTypes/MiniCart.php index 60b33ae98de..11bd7530df3 100644 --- a/src/BlockTypes/MiniCart.php +++ b/src/BlockTypes/MiniCart.php @@ -155,7 +155,7 @@ protected function enqueue_data( array $attributes = [] ) { if ( current_user_can( 'edit_theme_options' ) && - wc_current_theme_is_fse_theme() + ( wc_current_theme_is_fse_theme() || current_theme_supports( 'block-template-parts' ) ) ) { $theme_slug = BlockTemplateUtils::theme_has_template_part( 'mini-cart' ) ? wp_get_theme()->get_stylesheet() : BlockTemplateUtils::PLUGIN_SLUG; diff --git a/src/Utils/BlockTemplateUtils.php b/src/Utils/BlockTemplateUtils.php index 0a65a3cbcc1..d6e63110c3b 100644 --- a/src/Utils/BlockTemplateUtils.php +++ b/src/Utils/BlockTemplateUtils.php @@ -440,25 +440,25 @@ public static function theme_has_template_part( $template_name ) { /** * Checks to see if they are using a compatible version of WP, or if not they have a compatible version of the Gutenberg plugin installed. * + * @param string $template_type Optional. Template type: `wp_template` or `wp_template_part`. + * Default `wp_template`. * @return boolean */ - public static function supports_block_templates() { - if ( - ! wc_current_theme_is_fse_theme() && - ( ! function_exists( 'gutenberg_supports_block_templates' ) || ! gutenberg_supports_block_templates() ) - ) { - return false; + public static function supports_block_templates( $template_type = 'wp_template' ) { + if ( 'wp_template_part' === $template_type && ( wc_current_theme_is_fse_theme() || current_theme_supports( 'block-template-parts' ) ) ) { + return true; + } elseif ( 'wp_template' === $template_type && wc_current_theme_is_fse_theme() ) { + return true; } - - return true; + return false; } /** * Retrieves a single unified template object using its id. * * @param string $id Template unique identifier (example: theme_slug//template_slug). - * @param string $template_type Optional. Template type: `'wp_template'` or '`wp_template_part'`. - * Default `'wp_template'`. + * @param string $template_type Optional. Template type: `wp_template` or 'wp_template_part`. + * Default `wp_template`. * * @return WP_Block_Template|null Template. */ diff --git a/woocommerce-gutenberg-products-block.php b/woocommerce-gutenberg-products-block.php index cf0f68ab4ca..60f54a154c7 100644 --- a/woocommerce-gutenberg-products-block.php +++ b/woocommerce-gutenberg-products-block.php @@ -7,7 +7,7 @@ * Author: Automattic * Author URI: https://woocommerce.com * Text Domain: woo-gutenberg-products-block - * Requires at least: 6.2 + * Requires at least: 6.1 * Requires PHP: 7.3 * WC requires at least: 7.7 * WC tested up to: 7.8 @@ -18,7 +18,7 @@ defined( 'ABSPATH' ) || exit; -$minimum_wp_version = '6.2'; +$minimum_wp_version = '6.1'; if ( ! defined( 'WC_BLOCKS_IS_FEATURE_PLUGIN' ) ) { define( 'WC_BLOCKS_IS_FEATURE_PLUGIN', true );