Automattic\WooCommerce\Blocks

BlockTypesController::bypass_block_metadata_doing_it_wrong()public staticWC 1.0

Temporarily bypasses _doing_it_wrong() notices for block metadata collection registration.

WordPress 6.7 introduced block metadata collections (with strict path validation). Any sites using symlinks for plugins will fail the validation which causes the metadata collection to not be registered. However, the blocks will still fall back to the regular registration and no functionality is affected. While this validation is being discussed in WordPress Core (#62140), this method allows registration to proceed by temporarily disabling the relevant notice.

Method of the class: BlockTypesController{}

No Hooks.

Return

true|false. Whether to trigger the error.

Usage

$result = BlockTypesController::bypass_block_metadata_doing_it_wrong( $trigger, $function, $message, $version );
$trigger(true|false) (required)
Whether to trigger the error.
$function(string) (required)
The function that was called.
$message(string) (required)
A message explaining what was done incorrectly.
$version(string) (required)
The version of WordPress where the message was added.

BlockTypesController::bypass_block_metadata_doing_it_wrong() code WC 9.8.1

public static function bypass_block_metadata_doing_it_wrong( $trigger, $function, $message, $version ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable,Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed,Universal.NamingConventions.NoReservedKeywordParameterNames.functionFound
	if ( 'WP_Block_Metadata_Registry::register_collection' === $function ) {
		return false;
	}
	return $trigger;
}