WP_Block_Parser::parse() public WP 5.0.0
Parses a document and returns a list of block structures
When encountering an invalid parse will return a best-effort parse. In contrast to the specification parser this does not return an error on invalid inputs.
{} It's a method of the class: WP_Block_Parser{}
No Hooks.
Return
WP_Block_Parser_Block[].
Usage
$WP_Block_Parser = new WP_Block_Parser(); $WP_Block_Parser->parse( $document );
- $document(string) (required)
- Input document being parsed.
Changelog
Since 5.0.0 | Introduced. |
Code of WP_Block_Parser::parse() WP Block Parser::parse WP 5.6
function parse( $document ) {
$this->document = $document;
$this->offset = 0;
$this->output = array();
$this->stack = array();
$this->empty_attrs = json_decode( '{}', true );
do {
// twiddle our thumbs.
} while ( $this->proceed() );
return $this->output;
}