Automattic\WooCommerce\Blocks\Assets
Api::get_block_metadata_path
Get the path to a block's metadata
Method of the class: Api{}
No Hooks.
Returns
String|true|false. False if metadata file is not found for the block.
Usage
$Api = new Api(); $Api->get_block_metadata_path( $block_name, $path );
- $block_name(string) (required)
- The block to get metadata for.
- $path(string)
- The path to the metadata file inside the
'assets/client/blocks'folder.
Default:''
Api::get_block_metadata_path() Api::get block metadata path code WC 10.9.4
public function get_block_metadata_path( $block_name, $path = '' ) {
$path_to_metadata_from_plugin_root = $this->package->get_path( 'assets/client/blocks/' . $path . $block_name . '/block.json' );
if ( ! file_exists( $path_to_metadata_from_plugin_root ) ) {
return false;
}
return $path_to_metadata_from_plugin_root;
}