do_blocks()

最后更新于:2021-11-26 03:24:19

do_blocks( string$content)

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

参数

$content

(string) (Required) Post content.

响应

(string) Updated post content.

源文件

文件: gc-includes/blocks.php

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 gcautop() on it later.
	$priority = has_filter( 'the_content', 'gcautop' );
	if ( false !== $priority && doing_filter( 'the_content' ) && has_blocks( $content ) ) {
		remove_filter( 'the_content', 'gcautop', $priority );
		add_filter( 'the_content', '_restore_gcautop_hook', $priority + 1 );
	}

	return $output;
}