Automattic\WooCommerce\Blocks\BlockTypes

AbstractBlock::enqueue_data()protectedWC 1.0

Data passed through from server to client for block.

{} Это метод класса: AbstractBlock{}

Хуков нет.

Возвращает

null. Ничего.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->enqueue_data( $attributes );
$attributes(массив)
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.
По умолчанию: []

Код AbstractBlock::enqueue_data() WC 6.8.0

protected function enqueue_data( array $attributes = [] ) {
	$registered_script_data = $this->integration_registry->get_all_registered_script_data();

	foreach ( $registered_script_data as $asset_data_key => $asset_data_value ) {
		if ( ! $this->asset_data_registry->exists( $asset_data_key ) ) {
			$this->asset_data_registry->add( $asset_data_key, $asset_data_value );
		}
	}

	if ( ! $this->asset_data_registry->exists( 'wcBlocksConfig' ) ) {
		$this->asset_data_registry->add(
			'wcBlocksConfig',
			[
				'buildPhase'    => Package::feature()->get_flag(),
				'pluginUrl'     => plugins_url( '/', dirname( __DIR__ ) ),
				'productCount'  => array_sum( (array) wp_count_posts( 'product' ) ),
				'restApiRoutes' => [
					'/wc/store/v1' => array_keys( $this->get_routes_from_namespace( 'wc/store/v1' ) ),
				],
				'defaultAvatar' => get_avatar_url( 0, [ 'force_default' => true ] ),

				/*
				 * translators: If your word count is based on single characters (e.g. East Asian characters),
				 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
				 * Do not translate into your own language.
				 */
				'wordCountType' => _x( 'words', 'Word count type. Do not translate!', 'woocommerce' ),
			]
		);
	}
}