Automattic\WooCommerce\Blocks\BlockTypes

ProductSearch::enqueue_data()protectedWC 1.0

Extra data passed through from server to client for block.

Method of the class: ProductSearch{}

No Hooks.

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->enqueue_data( $attributes );
$attributes(array)
Any attributes that currently are available from the block. Note, this will be empty in the editor context when the block is not in the post content on editor load.
Default: []

ProductSearch::enqueue_data() code WC 8.9.0

protected function enqueue_data( array $attributes = [] ) {
	parent::enqueue_data( $attributes );

	$gutenberg_version = '';

	if ( is_plugin_active( 'gutenberg/gutenberg.php' ) ) {
		if ( defined( 'GUTENBERG_VERSION' ) ) {
			$gutenberg_version = GUTENBERG_VERSION;
		}

		if ( ! $gutenberg_version ) {
			$gutenberg_data    = get_file_data(
				WP_PLUGIN_DIR . '/gutenberg/gutenberg.php',
				array( 'Version' => 'Version' )
			);
			$gutenberg_version = $gutenberg_data['Version'];
		}
	}

	$this->asset_data_registry->add(
		'isBlockVariationAvailable',
		version_compare( get_bloginfo( 'version' ), '6.1', '>=' ) || version_compare( $gutenberg_version, '13.4', '>=' )
	);
}