wp-includes/class-wp-block-processor.php:631Advance to the next block delimiter which opens a block, indicating if one was found.
* is provided as the block type, freeform content is matched.
<⃨h⃨2⃨>⃨M⃨y⃨ ⃨s⃨y⃨n⃨o⃨p⃨s⃨i⃨s⃨<⃨/⃨h⃨2⃨>⃨\⃨n⃨<!-- wp:my/table-of-contents /-->
// Inner HTML is never freeform content, and will not be matched even with the wildcard.
<!-- /wp:list-item --></ul><!-- /wp:list --><⃨!⃨-⃨-⃨ ⃨w⃨p⃨:⃨p⃨a⃨r⃨a⃨g⃨r⃨a⃨p⃨h⃨ ⃨-⃨>⃨<p> Example: // Find all textual ranges of image block opening delimiters.
$images = array();
$processor = new WP_Block_Processor( $html );
while ( $processor->next_block( 'core/image' ) ) {
$images[] = $processor->get_span();
} In some cases it may be useful to conditionally visit the implicit freeform blocks, such as when determining if a post contains freeform content that isn’t purely whitespace. Example: $seen_block_types = [];
$block_type = '*';
$processor = new WP_Block_Processor( $html );
while ( $processor->next_block( $block_type ) {
// Stop wasting time visiting freeform blocks after one has been found.
if (
'*' === $block_type &&
null === $processor->get_block_type() &&
$processor->is_non_whitespace_html()
) {
$block_type = null;
$seen_block_types['core/freeform'] = true;
continue;
}
$seen_block_types[ $processor->get_block_type() ] = true;
}$block_typestring|nulloptionalnullbool public function next_block( ?string $block_type = null ): bool { while ( $this->next_delimiter( $block_type ) ) { if ( self::CLOSER !== $this->get_delimiter_type() ) { return true; } } return false; }Introduced in 6.9.0. Unchanged from 6.9.7 through 7.1.0.
Signature, return type and hooks compared across 3 parsed releases.
src/wp-includes/class-wp-block-processor.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.