Automattic\WooCommerce\Blocks\BlockTypes

AbstractBlock::register_chunk_translations()protectedWC 1.0

Injects Chunk Translations into the page so translations work for lazy loaded components.

The chunk names are defined when creating lazy loaded components using webpackChunkName.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->register_chunk_translations( $chunks );
$chunks(string[]) (обязательный)
Array of chunk names.

Код AbstractBlock::register_chunk_translations() WC 8.7.0

protected function register_chunk_translations( $chunks ) {
	foreach ( $chunks as $chunk ) {
		$handle = 'wc-blocks-' . $chunk . '-chunk';
		$this->asset_api->register_script( $handle, $this->asset_api->get_block_asset_build_path( $chunk ), [], true );
		wp_add_inline_script(
			$this->get_block_type_script( 'handle' ),
			wp_scripts()->print_translations( $handle, false ),
			'before'
		);
		wp_deregister_script( $handle );
	}
}