register_legacy_post_comments_block

The timeline below displays how wordpress function register_legacy_post_comments_block has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * 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'), '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.
     */
    /** This filter is documented in wp-includes/blocks.php */
    $metadata = apply_filters('block_type_metadata', $metadata);
    register_block_type('core/post-comments', $metadata);
}

WordPress Version: 6.2

/**
 * 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'), '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.
     */
    $metadata = apply_filters('block_type_metadata', $metadata);
    register_block_type('core/post-comments', $metadata);
}

WordPress Version: 6.1

/**
 * 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.
     */
    $metadata = apply_filters('block_type_metadata', $metadata);
    register_block_type('core/post-comments', $metadata);
}