Add feature gate for the block templates controller refactor (https://github.com/woocommerce/woocommerce-blocks/pull/11178)
* add feature gating for the block templates controller refactor * improve check
This commit is contained in:
parent
a6ddae9dc3
commit
645bd8d339
|
@ -42,8 +42,11 @@ class BlockTemplatesController {
|
|||
public function __construct( Package $package ) {
|
||||
$this->package = $package;
|
||||
|
||||
$feature_gating = $package->feature();
|
||||
$is_block_templates_controller_refactor_enabled = $feature_gating->is_block_templates_controller_refactor_enabled();
|
||||
|
||||
// This feature is gated for WooCommerce versions 6.0.0 and above.
|
||||
if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '6.0.0', '>=' ) ) {
|
||||
if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '6.0.0', '>=' ) && ! $is_block_templates_controller_refactor_enabled ) {
|
||||
$this->init();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,4 +164,15 @@ class FeatureGating {
|
|||
return self::EXPERIMENTAL_FLAG;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the block templates controller refactor should be used to display blocks.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_block_templates_controller_refactor_enabled() {
|
||||
$conf = parse_ini_file( __DIR__ . '/../../../blocks.ini' );
|
||||
return $this->is_development_environment() && isset( $conf['use_block_templates_controller_refactor'] ) && true === (bool) $conf['use_block_templates_controller_refactor'];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue