do_blocks( string $content ): string

Parses dynamic blocks out of post_content and re-renders them.


Parameters

$content string Required
Post content.

Top ↑

Return

string Updated post content.


Top ↑

Source

File: wp-includes/blocks.php. View all references

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;
}


Top ↑

Changelog

Changelog
Version Description
5.0.0 Introduced.

Top ↑

User Contributed Notes

You must log in before being able to contribute a note or feedback.