do_blocks

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

WordPress Version: 5.3

/**
 * Parses dynamic blocks out of `post_content` and re-renders them.
 *
 * @since 5.0.0
 *
 * @param string $content Post content.
 * @return string Updated post content.
 */
function do_blocks($content)
{
    $blocks = parse_blocks($content);
    $output = '';
    foreach ($blocks as $block) {
        $output .= render_block($block);
    }
    // If there are blocks in this content, we shouldn't run wpautop() on it later.
    $priority = has_filter('the_content', 'wpautop');
    if (false !== $priority && doing_filter('the_content') && has_blocks($content)) {
        remove_filter('the_content', 'wpautop', $priority);
        add_filter('the_content', '_restore_wpautop_hook', $priority + 1);
    }
    return $output;
}

WordPress Version: 5.2

/**
 * Parses dynamic blocks out of `post_content` and re-renders them.
 *
 * @since 5.0.0
 * @global WP_Post $post The post to edit.
 *
 * @param  string $content Post content.
 * @return string Updated post content.
 */
function do_blocks($content)
{
    $blocks = parse_blocks($content);
    $output = '';
    foreach ($blocks as $block) {
        $output .= render_block($block);
    }
    // If there are blocks in this content, we shouldn't run wpautop() on it later.
    $priority = has_filter('the_content', 'wpautop');
    if (false !== $priority && doing_filter('the_content') && has_blocks($content)) {
        remove_filter('the_content', 'wpautop', $priority);
        add_filter('the_content', '_restore_wpautop_hook', $priority + 1);
    }
    return $output;
}

WordPress Version: 5.0

/**
 * Parses dynamic blocks out of `post_content` and re-renders them.
 *
 * @since 5.0.0
 * @global WP_Post $post The post to edit.
 *
 * @param  string $content Post content.
 * @return string Updated post content.
 */
function do_blocks($content)
{
    // If there are blocks in this content, we shouldn't run wpautop() on it later.
    $priority = has_filter('the_content', 'wpautop');
    if (false !== $priority && doing_filter('the_content') && has_blocks($content)) {
        remove_filter('the_content', 'wpautop', $priority);
        add_filter('the_content', '_restore_wpautop_hook', $priority + 1);
    }
    $blocks = parse_blocks($content);
    $output = '';
    foreach ($blocks as $block) {
        $output .= render_block($block);
    }
    return $output;
}