Automattic\WooCommerce\Blocks
AssetsController::get_block_asset_resource_hints
Get resource hint for a block by name.
Method of the class: AssetsController{}
No Hooks.
Returns
Array
.
Usage
// private - for code of main (parent) class only $result = $this->get_block_asset_resource_hints( $filename );
- $filename(string)
- Block filename.
Default: ''
AssetsController::get_block_asset_resource_hints() AssetsController::get block asset resource hints code WC 9.9.4
private function get_block_asset_resource_hints( $filename = '' ) { if ( ! $filename ) { return array(); } $cached = $this->get_block_asset_resource_hints_cache(); if ( isset( $cached[ $filename ] ) ) { return $cached[ $filename ]; } $script_data = $this->api->get_script_data( $this->api->get_block_asset_build_path( $filename ) ); $resources = array_merge( array( esc_url( add_query_arg( 'ver', $script_data['version'], $script_data['src'] ) ) ), $this->get_script_dependency_src_array( $script_data['dependencies'] ) ); $data = array_map( function ( $src ) { return array( 'href' => $src, 'as' => 'script', ); }, array_unique( array_filter( $resources ) ) ); $this->set_block_asset_resource_hints_cache( $filename, $data ); return $data; }