From bb6f752a812af81ea8dab44731a29edd33df0341 Mon Sep 17 00:00:00 2001 From: Tom Cafferkey Date: Mon, 22 Nov 2021 11:25:53 +0000 Subject: [PATCH] Gate block templates feature for WC 6.0.0 (#5210) --- 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(); + } } /**