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

Commit

Permalink
Revert "Add template check logic to woocommerce_has_block_template
Browse files Browse the repository at this point in the history
…filter"

This reverts commit 855ae2e.
  • Loading branch information
sunyatasattva committed Dec 28, 2021
1 parent 855ae2e commit e94224f
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions src/BlockTemplatesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ protected function init() {
add_action( 'template_redirect', array( $this, 'render_block_template' ) );
add_filter( 'pre_get_block_file_template', array( $this, 'maybe_return_blocks_template' ), 10, 3 );
add_filter( 'get_block_templates', array( $this, 'add_block_templates' ), 10, 3 );
add_filter( 'woocommerce_has_block_template', array( $this, 'maybe_has_template' ), 10, 2 );
}

/**
Expand Down Expand Up @@ -439,27 +438,4 @@ public function render_block_template() {
}
}

/**
* Checks alternative paths for block templates
*
* This function is supposed to be hooked to the `woocommerce_has_block_template` filter.
* Since Gutenberg 12.1.0, directory names conventions for block templates have changed,
* however, WooCommerce still doesn't support that. Because of that, we patch the support
* by using our own checking functionality here.
*
* @see woocommerce/includes/class-wc-template-loader.php#L110-L126
* @see WooCommerce/woocommerce#31518
*
* @param bool $has_template Whether or not the block template was located.
* @param string $template_name Which template are we looking for.
*
* @return bool Whether a template with that name exists
*/
public function maybe_has_template( $has_template, $template_name ) {
if ( $has_template ) {
return $has_template;
}

return BlockTemplateUtils::theme_has_template( $template_name );
}
}

0 comments on commit e94224f

Please sign in to comment.