init(); $templates = get_block_templates( array( 'slug__in' => array( self::SLUG ) ) ); if ( isset( $templates[0] ) && BlockTemplateUtils::template_has_legacy_template_block( $templates[0] ) ) { add_filter( 'woocommerce_disable_compatibility_layer', '__return_true' ); } add_filter( 'woocommerce_has_block_template', '__return_true', 10, 0 ); } } /** * Remove the template panel from the Sidebar of the Shop page because * the Site Editor handles it. * * @see https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues/6278 * * @param bool $is_support Whether the active theme supports block templates. * * @return bool */ public function remove_block_template_support_for_shop_page( $is_support ) { global $pagenow, $post; if ( is_admin() && 'post.php' === $pagenow && function_exists( 'wc_get_page_id' ) && is_a( $post, 'WP_Post' ) && wc_get_page_id( 'shop' ) === $post->ID ) { return false; } return $is_support; } }