From 4bbc8b839df14809e62fea48a8f2d5353fb77ac0 Mon Sep 17 00:00:00 2001 From: Mtxz Date: Wed, 18 Jul 2018 01:25:40 +0200 Subject: [PATCH] better way to force woocommerce.blade.php as default woocommerce template + readme --- README.md | 3 ++- your-sage-theme/app/filters.php | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fd0ab1e..2582946 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,8 @@ Check dev branches for latest updates. - [discourse.roots.io](https://discourse.roots.io/t/woocommerce-blade-sage-9/8449/17) - [discourse.roots.io](https://discourse.roots.io/t/any-working-example-of-sage-9-latest-sage-9-0-0-beta-4-with-woocommerce-3-1-1/10099/17) - [github](https://github.com/MarekVrofski/Sage-Woocommerce) (much thanks again to [@MarekVrofski](https://github.com/MarekVrofski/) for his improvements) - + - [github sage PR](https://github.com/roots/sage/pull/1923) + ## Changelog - 17/07/2018 - test still in progress - Sage 9.0.1 diff --git a/your-sage-theme/app/filters.php b/your-sage-theme/app/filters.php index 157f30b..d847148 100644 --- a/your-sage-theme/app/filters.php +++ b/your-sage-theme/app/filters.php @@ -14,13 +14,13 @@ * - wp-content/plugins/woocommerce/includes/class-wc-template-loader.php l68 template_loader() calls -> * - wp-content/plugins/woocommerce/includes/class-wc-template-loader.php l129 get_template_loader_files() that uses 'woocommerce_template_loader_files' filter * - but in template_loader() the call to locate_template() fails to find our woo.blade.php... only a /resources/woocommerce.php because of STYLESHEETPATH & TEMPLATEPATH templating variables (wp-includes/default-constants.php l344) + * - our override filter_templates() method will return a correct path for woocommerce.blade.php * * Added a comment here: https://github.com/roots/sage/issues/1429 */ -add_filter( 'woocommerce_template_loader_files', function ( $default_file ) { - $default_file[] = 'views/woocommerce.blade.php'; - return $default_file; -}, PHP_INT_MAX ); +add_filter( 'woocommerce_template_loader_files', function ( $templates, $default_file ) { + return filter_templates(array_merge($templates, array_filter([$default_file, 'woocommerce']))); +}, PHP_INT_MAX, 2 ); /** * Render page using Blade (and get data from controller from sage/template/{$class}/data filter)