From 9e368658f216885a68ed0c726d4bd3de04c64106 Mon Sep 17 00:00:00 2001 From: Tom Cafferkey Date: Mon, 22 Nov 2021 10:41:30 +0000 Subject: [PATCH] Gate block templates feature for WC 6.0.0 --- src/BlockTemplatesController.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/BlockTemplatesController.php b/src/BlockTemplatesController.php index fa448a53dc1..ff18c31c07a 100644 --- a/src/BlockTemplatesController.php +++ b/src/BlockTemplatesController.php @@ -42,9 +42,12 @@ class BlockTemplatesController { * Constructor. */ public function __construct() { - $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; - $this->init(); + // 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; + $this->init(); + } } /**