Automattic\WooCommerce\Blocks
BlockTypesController::register_block_metadata()
Register block metadata collections for WooCommerce blocks.
This method handles the registration of block metadata by using WordPress's block metadata collection registration system. It includes a temporary workaround for WordPress 6.7's strict path validation that might fail for sites using symlinked plugins.
If the registration fails due to path validation, blocks will fall back to regular registration without affecting functionality.
Method of the class: BlockTypesController{}
No Hooks.
Return
null
. Nothing (null).
Usage
$BlockTypesController = new BlockTypesController(); $BlockTypesController->register_block_metadata();
BlockTypesController::register_block_metadata() BlockTypesController::register block metadata code WC 9.8.1
public function register_block_metadata() { $meta_file_path = WC_ABSPATH . 'assets/client/blocks/blocks-json.php'; if ( function_exists( 'wp_register_block_metadata_collection' ) && file_exists( $meta_file_path ) ) { add_filter( 'doing_it_wrong_trigger_error', array( __CLASS__, 'bypass_block_metadata_doing_it_wrong' ), 10, 4 ); wp_register_block_metadata_collection( WC_ABSPATH . 'assets/client/blocks/', $meta_file_path ); remove_filter( 'doing_it_wrong_trigger_error', array( __CLASS__, 'bypass_block_metadata_doing_it_wrong' ), 10 ); } }