Automattic\WooCommerce\Blocks\Assets

Api::get_block_metadata_path()publicWC 1.0

Get the path to a block's metadata

Method of the class: Api{}

No Hooks.

Return

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() code WC 9.8.1

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;
}