parse_blocks( string $content ): array[]

Parses blocks out of a content string.

Description

Given an HTML document, this function fully-parses block content, producing a tree of blocks and their contents, as well as top-level non-block content, which will appear as a block with no blockName.

This function can be memory heavy for certain documents, particularly those with deeply-nested blocks or blocks with extensive attribute values. Further, this function must parse an entire document in one atomic operation.

If the entire parsed document is not necessary, consider using WP_Block_Processor instead, as it provides a streaming and low-overhead interface for finding blocks.

Parameters

$contentstringrequired
Post content.

Return

array[] Array of block structures.