On this page
parse_blocks( string $content ): array[]
Parses blocks out of a content string.
Parameters
$contentstring Required-
Post content.
Return
array[] Array of parsed block objects.
Source
File: wp-includes/blocks.php. View all references
function parse_blocks( $content ) {
/**
* Filter to allow plugins to replace the server-side block parser.
*
* @since 5.0.0
*
* @param string $parser_class Name of block parser class.
*/
$parser_class = apply_filters( 'block_parser_class', 'WP_Block_Parser' );
$parser = new $parser_class();
return $parser->parse( $content );
}
Hooks
- apply_filters( 'block_parser_class',
string $parser_class ) -
Filter to allow plugins to replace the server-side block parser.
Related
Uses
| Uses | Description |
|---|---|
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| _inject_theme_attribute_in_block_template_content() wp-includes/block-template-utils.php | Parses wp_template content and injects the active theme’s stylesheet as a theme attribute into each wp_template_part |
| _remove_theme_attribute_in_block_template_content() wp-includes/block-template-utils.php | Parses a block template and removes the theme attribute from each template part. |
| WP_Widget_Block::get_dynamic_classname() wp-includes/widgets/class-wp-widget-block.php | Calculates the classname to use in the block widget’s container HTML. |
| filter_block_content() wp-includes/blocks.php | Filters and sanitizes block content to remove non-allowable HTML from parsed block attribute values. |
| do_blocks() wp-includes/blocks.php | Parses dynamic blocks out of |
| excerpt_remove_blocks() wp-includes/blocks.php | Parses blocks out of a content string, and renders those appropriate for the excerpt. |
| get_post_galleries() wp-includes/media.php | Retrieves galleries from the passed post’s content. |
Changelog
| Version | Description |
|---|---|
| 5.0.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/parse_blocks