Skip to content
This repository has been archived by the owner on Mar 18, 2022. It is now read-only.

Commit

Permalink
Enable overriding
Browse files Browse the repository at this point in the history
  • Loading branch information
mmirus committed Aug 27, 2018
1 parent f135efb commit 65bc347
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@
add_theme_support('woocommerce');
});

add_filter('template_include', function ($template) {
/**
* @param string $template
* @return string
*/
function wc_template_loader(String $template)
{
return strpos($template, WC_ABSPATH) === -1
? $template
: locate_template(WC()->template_path() . str_replace(WC_ABSPATH . 'templates/', '', $template)) ? : $template;
}, 100, 1);
}
add_filter('template_include', __NAMESPACE__ . '\\wc_template_loader', 100, 1);
add_filter('comments_template', __NAMESPACE__ . '\\wc_template_loader', 100, 1);

add_filter('wc_get_template_part', function ($template) {
$theme_template = locate_template(WC()->template_path() . str_replace(WC_ABSPATH . 'templates/', '', $template));
Expand Down

0 comments on commit 65bc347

Please sign in to comment.