apply_filters( 'block_type_metadata', array $metadata )

Filters the metadata provided for registering a block type.


Parameters

$metadata

(array) Metadata for registering a block type.


Top ↑

Source

File: wp-includes/blocks.php

View on Trac



Top ↑

Changelog

Changelog
Version Description
5.7.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by Elvis Morales
    /**
     * 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.