apply_filters( ‘block_type_metadata’, array $metadata )

Filters the metadata provided for registering a block type.

Parameters

$metadataarray
Metadata for registering a block type.

Source

$metadata = apply_filters( 'block_type_metadata', $metadata );

Changelog

VersionDescription
5.7.0Introduced.

User Contributed Notes

  1. Skip to note 3 content
    /**
     * Add custom 'visibleOnMobile' attribute to the core/group block.
     *
     * @param array $metadata Metadata for registering a block type.
     * @return array
     */
    function my_filter_block_type_metadata( $metadata ) {
    	if ( 'core/group' === $metadata['name'] ) {
    		$metadata['attributes']['visibleOnMobile'] = array(
    			'type'    => 'boolean',
    			'default' => false,
    		);
    	}
    	return $metadata;
    }
    add_filter( 'block_type_metadata', 'my_filter_block_type_metadata' );

You must log in before being able to contribute a note or feedback.