WP_Block::get_block_bindings_processor
Method of the class: WP_Block{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = WP_Block::get_block_bindings_processor( $block_content );
- $block_content(string) (required)
- .
WP_Block::get_block_bindings_processor() WP Block::get block bindings processor code WP 6.9.1
private static function get_block_bindings_processor( string $block_content ) {
$internal_processor_class = new class('', WP_HTML_Processor::CONSTRUCTOR_UNLOCK_CODE) extends WP_HTML_Processor {
/**
* Replace the rich text content between a tag opener and matching closer.
*
* When stopped on a tag opener, replace the content enclosed by it and its
* matching closer with the provided rich text.
*
* @param string $rich_text The rich text to replace the original content with.
* @return bool True on success.
*/
public function replace_rich_text( $rich_text ) {
if ( $this->is_tag_closer() || ! $this->expects_closer() ) {
return false;
}
$depth = $this->get_current_depth();
$tag_name = $this->get_tag();
$this->set_bookmark( '_wp_block_bindings' );
// The bookmark names are prefixed with `_` so the key below has an extra `_`.
$tag_opener = $this->bookmarks['__wp_block_bindings'];
$start = $tag_opener->start + $tag_opener->length;
// Find matching tag closer.
while ( $this->next_token() && $this->get_current_depth() >= $depth ) {
}
if ( ! $this->is_tag_closer() || $tag_name !== $this->get_tag() ) {
return false;
}
$this->set_bookmark( '_wp_block_bindings' );
$tag_closer = $this->bookmarks['__wp_block_bindings'];
$end = $tag_closer->start;
$this->lexical_updates[] = new WP_HTML_Text_Replacement(
$start,
$end - $start,
$rich_text
);
return true;
}
};
return $internal_processor_class::create_fragment( $block_content );
}