WordPress Hooks Explorer

Listing all hooks extracted WordPress Core


Details about block_type_metadata

Back to home

Files

Filename Hook Type Line Number PHP Doc
wp-includes/blocks.php apply_filters 354 /**
* Filters the metadata provided for registering a block type.
*
* @since 5.7.0
*
* @param array $metadata Metadata for registering a block type.
*/
wp-includes/blocks/comments.php apply_filters 216 /**
* Ensures backwards compatibility for any users running the Gutenberg plugin
* who have used Post Comments before it was merged into Comments Query Loop.
*
* The same approach was followed when core/query-loop was renamed to
* core/post-template.
*
* @see https://github.com/WordPress/gutenberg/pull/41807
* @see https://github.com/WordPress/gutenberg/pull/32514
*/
function register_legacy_post_comments_block() {
$registry = WP_Block_Type_Registry::get_instance();

/*
* Remove the old `post-comments` block if it was already registered, as it
* is about to be replaced by the type defined below.
*/
if ( $registry->is_registered( 'core/post-comments' ) ) {
unregister_block_type( 'core/post-comments' );
}

// Recreate the legacy block metadata.
$metadata = array(
'name' => 'core/post-comments',
'category' => 'theme',
'attributes' => array(
'textAlign' => array(
'type' => 'string',
),
),
'uses_context' => array(
'postId',
'postType',
),
'supports' => array(
'html' => false,
'align' => array( 'wide', 'full' ),
'typography' => array(
'fontSize' => true,
'lineHeight' => true,
'__experimentalFontStyle' => true,
'__experimentalFontWeight' => true,
'__experimentalLetterSpacing' => true,
'__experimentalTextTransform' => true,
'__experimentalDefaultControls' => array(
'fontSize' => true,
),
),
'color' => array(
'gradients' => true,
'link' => true,
'__experimentalDefaultControls' => array(
'background' => true,
'text' => true,
),
),
'inserter' => false,
),
'style' => array(
'wp-block-post-comments',
'wp-block-buttons',
'wp-block-button',
),
'editorStyle' => 'wp-block-post-comments-editor',
'render_callback' => 'render_block_core_comments',
'skip_inner_blocks' => true,
);

/*
* Filters the metadata object, the same way it's done inside
* `register_block_type_from_metadata()`. This applies some default filters,
* like `_wp_multiple_block_styles`, which is required in this case because
* the block has multiple styles.
*/

Hook Parameters

Parameter Type Name Description
array $metadata Metadata for registering a block type.