Automattic\WooCommerce\Blocks\Templates

AbstractTemplateCompatibility::init()publicWC 1.0

Initialization method.

Method of the class: AbstractTemplateCompatibility{}

Return

null. Nothing (null).

Usage

$AbstractTemplateCompatibility = new AbstractTemplateCompatibility();
$AbstractTemplateCompatibility->init();

AbstractTemplateCompatibility::init() code WC 8.9.0

public function init() {
	if ( ! wc_current_theme_is_fse_theme() ) {
		return;
	}

	$this->set_hook_data();

	add_filter(
		'render_block_data',
		function( $parsed_block, $source_block, $parent_block ) {
			/**
			* Filter to disable the compatibility layer for the blockified templates.
			*
			* This hook allows to disable the compatibility layer for the blockified templates.
			*
			* @since TBD
			* @param boolean.
			*/
			$is_disabled_compatility_layer = apply_filters( 'woocommerce_disable_compatibility_layer', false );

			if ( $is_disabled_compatility_layer ) {
				return $parsed_block;
			}

			return $this->update_render_block_data( $parsed_block, $source_block, $parent_block );

		},
		10,
		3
	);

	add_filter(
		'render_block',
		function ( $block_content, $block ) {
			/**
			* Filter to disable the compatibility layer for the blockified templates.
			*
			* This hook allows to disable the compatibility layer for the blockified.
			*
			* @since TBD
			* @param boolean.
			*/
			$is_disabled_compatility_layer = apply_filters( 'woocommerce_disable_compatibility_layer', false );

			if ( $is_disabled_compatility_layer ) {
				return $block_content;
			}

			return $this->inject_hooks( $block_content, $block );
		},
		10,
		2
	);
}