get_comment_delimited_block_content

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

WordPress Version: 5.6

/**
 * Returns the content of a block, including comment delimiters.
 *
 * @since 5.3.1
 *
 * @param string|null $block_name       Block name. Null if the block name is unknown,
 *                                      e.g. Classic blocks have their name set to null.
 * @param array       $block_attributes Block attributes.
 * @param string      $block_content    Block save content.
 * @return string Comment-delimited block content.
 */
function get_comment_delimited_block_content($block_name, $block_attributes, $block_content)
{
    if (is_null($block_name)) {
        return $block_content;
    }
    $serialized_block_name = strip_core_block_namespace($block_name);
    $serialized_attributes = empty($block_attributes) ? '' : (serialize_block_attributes($block_attributes) . ' ');
    if (empty($block_content)) {
        return sprintf('<!-- wp:%s %s/-->', $serialized_block_name, $serialized_attributes);
    }
    return sprintf('<!-- wp:%s %s-->%s<!-- /wp:%s -->', $serialized_block_name, $serialized_attributes, $block_content, $serialized_block_name);
}

WordPress Version: 5.5

/**
 * Returns the content of a block, including comment delimiters.
 *
 * @since 5.3.1
 *
 * @param string $block_name       Block name.
 * @param array  $block_attributes Block attributes.
 * @param string $block_content    Block save content.
 * @return string Comment-delimited block content.
 */
function get_comment_delimited_block_content($block_name = null, $block_attributes, $block_content)
{
    if (is_null($block_name)) {
        return $block_content;
    }
    $serialized_block_name = strip_core_block_namespace($block_name);
    $serialized_attributes = empty($block_attributes) ? '' : (serialize_block_attributes($block_attributes) . ' ');
    if (empty($block_content)) {
        return sprintf('<!-- wp:%s %s/-->', $serialized_block_name, $serialized_attributes);
    }
    return sprintf('<!-- wp:%s %s-->%s<!-- /wp:%s -->', $serialized_block_name, $serialized_attributes, $block_content, $serialized_block_name);
}

WordPress Version: .10

/**
 * Returns the content of a block, including comment delimiters.
 *
 * @since 5.3.1
 *
 * @param string $block_name Block name.
 * @param array  $attributes Block attributes.
 * @param string $content    Block save content.
 * @return string Comment-delimited block content.
 */
function get_comment_delimited_block_content($block_name = null, $block_attributes, $block_content)
{
    if (is_null($block_name)) {
        return $block_content;
    }
    $serialized_block_name = strip_core_block_namespace($block_name);
    $serialized_attributes = empty($block_attributes) ? '' : (serialize_block_attributes($block_attributes) . ' ');
    if (empty($block_content)) {
        return sprintf('<!-- wp:%s %s/-->', $serialized_block_name, $serialized_attributes);
    }
    return sprintf('<!-- wp:%s %s-->%s<!-- /wp:%s -->', $serialized_block_name, $serialized_attributes, $block_content, $serialized_block_name);
}