Add checkout-header template to the correct area (https://github.com/woocommerce/woocommerce-blocks/pull/11528)

This commit is contained in:
Mike Jolley 2023-11-01 16:34:10 +00:00 committed by GitHub
parent 49a5a11290
commit 7cd966f0fd
1 changed files with 12 additions and 3 deletions

View File

@ -183,7 +183,8 @@ class BlockTemplateUtils {
/**
* Build a unified template object based on a theme file.
* Important: This method is an almost identical duplicate from wp-includes/block-template-utils.php as it was not intended for public use. It has been modified to build templates from plugins rather than themes.
*
* @internal Important: This method is an almost identical duplicate from wp-includes/block-template-utils.php as it was not intended for public use. It has been modified to build templates from plugins rather than themes.
*
* @param array|object $template_file Theme file.
* @param string $template_type wp_template or wp_template_part.
@ -223,8 +224,16 @@ class BlockTemplateUtils {
$template->area = 'uncategorized';
// Force the Mini-Cart template part to be in the Mini-Cart template part area.
if ( 'wp_template_part' === $template_type && 'mini-cart' === $template_file->slug ) {
$template->area = 'mini-cart';
// @todo When this class is refactored, move title, description, and area definition to the template classes (CheckoutHeaderTemplate, MiniCartTemplate, etc).
if ( 'wp_template_part' === $template_type ) {
switch ( $template_file->slug ) {
case 'mini-cart':
$template->area = 'mini-cart';
break;
case 'checkout-header':
$template->area = 'header';
break;
}
}
return $template;
}