Skip to content

Commit

Permalink
Move backported Block Renaming metadata registration code to 6.5 dir (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave authored Jan 23, 2024
1 parent b3b844d commit 44237ca
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
21 changes: 0 additions & 21 deletions lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,27 +440,6 @@ function gutenberg_legacy_wp_block_post_meta( $value, $object_id, $meta_key, $si
add_filter( 'default_post_metadata', 'gutenberg_legacy_wp_block_post_meta', 10, 4 );


/**
* Registers the metadata block attribute for all block types.
*
* @param array $args Array of arguments for registering a block type.
* @return array $args
*/
function gutenberg_register_metadata_attribute( $args ) {
// Setup attributes if needed.
if ( ! isset( $args['attributes'] ) || ! is_array( $args['attributes'] ) ) {
$args['attributes'] = array();
}

if ( ! array_key_exists( 'metadata', $args['attributes'] ) ) {
$args['attributes']['metadata'] = array(
'type' => 'object',
);
}

return $args;
}
add_filter( 'register_block_type_args', 'gutenberg_register_metadata_attribute' );

/**
* Strips all HTML from the content of footnotes, and sanitizes the ID.
Expand Down
23 changes: 23 additions & 0 deletions lib/compat/wordpress-6.5/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,26 @@ function gutenberg_register_block_type_args_shim( $args ) {
if ( ! method_exists( 'WP_Block_Type', 'get_variations' ) ) {
add_filter( 'register_block_type_args', 'gutenberg_register_block_type_args_shim' );
}


/**
* Registers the metadata block attribute for all block types.
*
* @param array $args Array of arguments for registering a block type.
* @return array $args
*/
function gutenberg_register_metadata_attribute( $args ) {
// Setup attributes if needed.
if ( ! isset( $args['attributes'] ) || ! is_array( $args['attributes'] ) ) {
$args['attributes'] = array();
}

if ( ! array_key_exists( 'metadata', $args['attributes'] ) ) {
$args['attributes']['metadata'] = array(
'type' => 'object',
);
}

return $args;
}
add_filter( 'register_block_type_args', 'gutenberg_register_metadata_attribute' );

0 comments on commit 44237ca

Please sign in to comment.