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' ); } } } /** * When the search is for products and a block theme is active, render the Product Search Template. * * @param array $templates Templates that match the search hierarchy. */ public function update_search_template_hierarchy( $templates ) { if ( ( is_search() && is_post_type_archive( 'product' ) ) && wp_is_block_theme() ) { array_unshift( $templates, self::SLUG ); } return $templates; } }