Automattic\WooCommerce\Blocks\BlockTypes

AbstractBlock::get_chunks_paths()protectedWC 1.0

Generate an array of chunks paths for loading translation.

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

Хуков нет.

Возвращает

Строку[]. $chunks list of chunks to load.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_chunks_paths( $chunks_folder );
$chunks_folder(строка) (обязательный)
The folder to iterate over.

Код AbstractBlock::get_chunks_paths() WC 9.7.1

protected function get_chunks_paths( $chunks_folder ) {
	$build_path = \Automattic\WooCommerce\Blocks\Package::get_path() . 'assets/client/blocks/';
	$blocks     = [];
	if ( ! is_dir( $build_path . $chunks_folder ) ) {
		return [];
	}
	foreach ( new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $build_path . $chunks_folder, \FilesystemIterator::UNIX_PATHS ) ) as $block_name ) {
		$blocks[] = str_replace( $build_path, '', $block_name );
	}

	$chunks = preg_filter( '/.js/', '', $blocks );
	return $chunks;
}