Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Align Woo Block template locations with the newest convention
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sunyatasattva committed Dec 27, 2021
1 parent 855ae2e commit 4c2a2bf
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/BlockTemplatesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,22 @@ 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.
*/
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();
}
}
Expand Down
31 changes: 31 additions & 0 deletions templates/parts/mini-cart.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!-- wp:woocommerce/mini-cart-contents -->
<div class="wp-block-woocommerce-mini-cart-contents">
<!-- wp:woocommerce/filled-mini-cart-contents-block -->
<div class="wp-block-woocommerce-filled-mini-cart-contents-block">
<!-- wp:woocommerce/mini-cart-title-block /-->
<!-- wp:woocommerce/mini-cart-products-table-block /-->
<!-- wp:woocommerce/mini-cart-footer-block /-->
</div>
<!-- /wp:woocommerce/filled-mini-cart-contents-block -->

<!-- wp:woocommerce/empty-mini-cart-contents-block -->
<div class="wp-block-woocommerce-empty-mini-cart-contents-block">
<!-- wp:paragraph {"align":"center"} -->
<p class="has-text-align-center">
<strong>Your cart is currently empty!</strong>
</p>
<!-- /wp:paragraph -->

<!-- wp:buttons -->
<div class="wp-block-buttons">
<!-- wp:button {"align":"center","className":"is-style-outline"} -->
<div class="wp-block-button aligncenter is-style-outline">
<a href="/" class="wp-block-button__link">Start shopping</a>
</div>
<!-- /wp:button -->
</div>
<!-- /wp:buttons -->
</div>
<!-- /wp:woocommerce/empty-mini-cart-contents-block -->
</div>
<!-- /wp:woocommerce/mini-cart-contents -->
5 changes: 5 additions & 0 deletions templates/templates/archive-product.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- wp:template-part {"slug":"header"} /-->
<!-- wp:group {"layout":{"inherit":true}} -->
<div class="wp-block-group"><!-- wp:woocommerce/legacy-template {"template":"archive-product"} /--></div>
<!-- /wp:group -->
<!-- wp:template-part {"slug":"footer"} /-->
5 changes: 5 additions & 0 deletions templates/templates/single-product.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- wp:template-part {"slug":"header"} /-->
<!-- wp:group {"layout":{"inherit":true}} -->
<div class="wp-block-group"><!-- wp:woocommerce/legacy-template {"template":"single-product"} /--></div>
<!-- /wp:group -->
<!-- wp:template-part {"slug":"footer"} /-->
5 changes: 5 additions & 0 deletions templates/templates/taxonomy-product_cat.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- wp:template-part {"slug":"header"} /-->
<!-- wp:group {"layout":{"inherit":true}} -->
<div class="wp-block-group"><!-- wp:woocommerce/legacy-template {"template":"taxonomy-product_cat"} /--></div>
<!-- /wp:group -->
<!-- wp:template-part {"slug":"footer"} /-->
5 changes: 5 additions & 0 deletions templates/templates/taxonomy-product_tag.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- wp:template-part {"slug":"header"} /-->
<!-- wp:group {"layout":{"inherit":true}} -->
<div class="wp-block-group"><!-- wp:woocommerce/legacy-template {"template":"taxonomy-product_tag"} /--></div>
<!-- /wp:group -->
<!-- wp:template-part {"slug":"footer"} /-->

0 comments on commit 4c2a2bf

Please sign in to comment.