Opens in a new tab
A picture of Jeff Brigman
I CODE TODAY FOR
A BETTER TOMORROW

Glossary Term

parse_blocks()

3 tags 1 category

parse_blocks() — Parses blocks out of a content string. 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.

Inputs: $content (string): Post content.

Returns array[]: Array of block structures. Field (array): …$0 An associative array of a single parsed block object. See WP_Block_Parser_Block. Field $blockName (string|null): Name of block. Field $attrs (array): Attributes from block comment delimiters. Field $innerBlocks (array[]): List of inner blocks. An array of arrays that have the same structure as this one. Field $innerHTML (string): HTML from inside block comment delimiters. Field $innerContent (array): List of string fragments and null markers where inner blocks were found.

Term Connections

Explore related terms connected by shared tags, shared categories, and relationship phrases. This map loads only when it comes into view.

Loading term connections…