From 4c2a2bf3dccd3cea3b825690f4aca692a4fbd99c Mon Sep 17 00:00:00 2001 From: Lucio Giannotta Date: Mon, 27 Dec 2021 18:20:42 +0100 Subject: [PATCH] Align Woo Block template locations with the newest convention While we now support both the old and new conventions for the templates paths, our own repo should be aligned with the latest convention. See: #5455 Fixes: #5343 --- src/BlockTemplatesController.php | 17 ++++------ templates/parts/mini-cart.html | 31 +++++++++++++++++++ templates/templates/archive-product.html | 5 +++ templates/templates/single-product.html | 5 +++ templates/templates/taxonomy-product_cat.html | 5 +++ templates/templates/taxonomy-product_tag.html | 5 +++ 6 files changed, 57 insertions(+), 11 deletions(-) create mode 100644 templates/parts/mini-cart.html create mode 100644 templates/templates/archive-product.html create mode 100644 templates/templates/single-product.html create mode 100644 templates/templates/taxonomy-product_cat.html create mode 100644 templates/templates/taxonomy-product_tag.html diff --git a/src/BlockTemplatesController.php b/src/BlockTemplatesController.php index e283547cd68..7b5f813be58 100644 --- a/src/BlockTemplatesController.php +++ b/src/BlockTemplatesController.php @@ -25,18 +25,11 @@ class BlockTemplatesController { private $template_parts_directory; /** - * Directory name of the block template directory. + * Directory which contains all templates * * @var string */ - const TEMPLATES_DIR_NAME = 'block-templates'; - - /** - * Directory name of the block template parts directory. - * - * @var string - */ - const TEMPLATE_PARTS_DIR_NAME = 'block-template-parts'; + const TEMPLATES_ROOT_DIR = 'templates'; /** * Constructor. @@ -44,8 +37,10 @@ class BlockTemplatesController { public function __construct() { // This feature is gated for WooCommerce versions 6.0.0 and above. if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '6.0.0', '>=' ) ) { - $this->templates_directory = plugin_dir_path( __DIR__ ) . 'templates/' . self::TEMPLATES_DIR_NAME; - $this->template_parts_directory = plugin_dir_path( __DIR__ ) . 'templates/' . self::TEMPLATE_PARTS_DIR_NAME; + $root_path = plugin_dir_path( __DIR__ ) . self::TEMPLATES_ROOT_DIR . DIRECTORY_SEPARATOR; + + $this->templates_directory = $root_path . BlockTemplateUtils::TEMPLATES_DIR_NAME; + $this->template_parts_directory = $root_path . BlockTemplateUtils::TEMPLATE_PARTS_DIR_NAME; $this->init(); } } diff --git a/templates/parts/mini-cart.html b/templates/parts/mini-cart.html new file mode 100644 index 00000000000..c2400ba76ed --- /dev/null +++ b/templates/parts/mini-cart.html @@ -0,0 +1,31 @@ + +
+ +
+ + + +
+ + + +
+ +

+ Your cart is currently empty! +

+ + + +
+ + + +
+ +
+ +
+ diff --git a/templates/templates/archive-product.html b/templates/templates/archive-product.html new file mode 100644 index 00000000000..4cf01077d40 --- /dev/null +++ b/templates/templates/archive-product.html @@ -0,0 +1,5 @@ + + +
+ + diff --git a/templates/templates/single-product.html b/templates/templates/single-product.html new file mode 100644 index 00000000000..1e4177d96e3 --- /dev/null +++ b/templates/templates/single-product.html @@ -0,0 +1,5 @@ + + +
+ + diff --git a/templates/templates/taxonomy-product_cat.html b/templates/templates/taxonomy-product_cat.html new file mode 100644 index 00000000000..4a300405a67 --- /dev/null +++ b/templates/templates/taxonomy-product_cat.html @@ -0,0 +1,5 @@ + + +
+ + diff --git a/templates/templates/taxonomy-product_tag.html b/templates/templates/taxonomy-product_tag.html new file mode 100644 index 00000000000..071b616f7d5 --- /dev/null +++ b/templates/templates/taxonomy-product_tag.html @@ -0,0 +1,5 @@ + + +
+ +