Automattic\WooCommerce\Blocks\BlockTypes
AbstractBlock::get_chunks_paths
Generate an array of chunks paths for loading translation.
Method of the class: AbstractBlock{}
No Hooks.
Returns
String[]. $chunks list of chunks to load.
Usage
// protected - for code of main (parent) or child class $result = $this->get_chunks_paths( $chunks_folder );
- $chunks_folder(string) (required)
- The folder to iterate over.
AbstractBlock::get_chunks_paths() AbstractBlock::get chunks paths code WC 10.3.6
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;
}