On this page
do_blocks( string $content ): string
Parses dynamic blocks out of post_content and re-renders them.
Parameters
$contentstring Required-
Post content.
Return
string Updated post content.
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;
}
Related
Uses
| Uses | Description |
|---|---|
| parse_blocks() wp-includes/blocks.php | Parses blocks out of a content string. |
| render_block() wp-includes/blocks.php | Renders a single block into a HTML string. |
| has_blocks() wp-includes/blocks.php | Determines whether a post or content string has blocks. |
| has_filter() wp-includes/plugin.php | Checks if any filter has been registered for a hook. |
| doing_filter() wp-includes/plugin.php | Returns whether or not a filter hook is currently being processed. |
| remove_filter() wp-includes/plugin.php | Removes a callback function from a filter hook. |
| add_filter() wp-includes/plugin.php | Adds a callback function to a filter hook. |
Used By
| Used By | Description |
|---|---|
| block_template_part() wp-includes/block-template-utils.php | Prints a block template part. |
| get_the_block_template_html() wp-includes/block-template.php | Returns the markup for the current template. |
Changelog
| Version | Description |
|---|---|
| 5.0.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/do_blocks