解析post_content中的动态块并重新呈现它们。
原型
do_blocks( string $content )
参数
$content
(string)
(Required)
发布内容。
返回值
(string)
更新了帖子内容。
源文件
路径:wp-includes/blocks.php
<?php
...
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;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/do_blocks/