This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the archive-product template to render product attributes pages (#…
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Automattic\WooCommerce\Blocks\Templates; | ||
|
||
/** | ||
* ProductAttributeTemplate class. | ||
* | ||
* @internal | ||
*/ | ||
class ProductAttributeTemplate { | ||
const SLUG = 'archive-product'; | ||
|
||
/** | ||
* Constructor. | ||
*/ | ||
public function __construct() { | ||
$this->init(); | ||
} | ||
|
||
/** | ||
* Initialization method. | ||
*/ | ||
protected function init() { | ||
add_filter( 'taxonomy_template_hierarchy', array( $this, 'update_taxonomy_template_hierarchy' ), 10, 3 ); | ||
} | ||
|
||
/** | ||
* Render the Archive Product Template for product attributes. | ||
* | ||
* @param array $templates Templates that match the product attributes taxonomy. | ||
*/ | ||
public function update_taxonomy_template_hierarchy( $templates ) { | ||
if ( taxonomy_is_product_attribute( get_query_var( 'taxonomy' ) ) && wc_current_theme_is_fse_theme() ) { | ||
array_unshift( $templates, self::SLUG ); | ||
} | ||
|
||
return $templates; | ||
} | ||
} |