Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent 'BlockTemplatesController::add_archive_product_to_eligible_for_fallback_templates' to leak into classic themes #46461

Open
Aljullu opened this issue Apr 11, 2024 · 0 comments
Labels
focus: template Issue related to WooCommerce templates. team: Kirigami & Origami

Comments

@Aljullu
Copy link
Contributor

Aljullu commented Apr 11, 2024

There is a method in BlockTemplatesController called add_archive_product_to_eligible_for_fallback_templates which seems to be leaking into classic themes. From my investigation, it doesn't have any impact in functionality, but we should make it so it only runs in block themes to avoid running unnecessary code and to prevent unexpected bugs.

The method can be found here:

/**
* Adds the `archive-product` template to the `taxonomy-product_cat`, `taxonomy-product_tag`, `taxonomy-attribute`
* templates to be able to fall back to it.
*
* @param array $template_hierarchy A list of template candidates, in descending order of priority.
*/
public function add_archive_product_to_eligible_for_fallback_templates( $template_hierarchy ) {
$template_slugs = array_map(
'_strip_template_file_suffix',
$template_hierarchy
);
$templates_eligible_for_fallback = array_filter(
$template_slugs,
function ( $template_slug ) {
return BlockTemplateUtils::template_is_eligible_for_product_archive_fallback( $template_slug );
}
);
if ( count( $templates_eligible_for_fallback ) > 0 ) {
$template_hierarchy[] = ProductCatalogTemplate::SLUG;
}
return $template_hierarchy;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: template Issue related to WooCommerce templates. team: Kirigami & Origami
Projects
Development

No branches or pull requests

1 participant