Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add WP_Block_Bindings_Processor class
  • Loading branch information
ockham committed Aug 18, 2025
commit 15d619b6fc6ec0209ea4c048fa766b11293288ba
34 changes: 34 additions & 0 deletions src/wp-includes/class-wp-block-bindings-processor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

class WP_Block_Bindings_Processor extends WP_HTML_Processor {
private $output = '';
private $end_of_flushed = 0;

public function build() {
return $this->output . substr( $this->html, $this->end_of_flushed );
}

public function replace_rich_text( $rich_text ) {
if ( $this->is_tag_closer() ) {
return false;
}

$tag_name = $this->get_tag();
$depth = $this->get_current_depth();

$this->set_bookmark( '_wp_block_bindings_tag_opener' );
// The bookmark names are prefixed with `_` so the key below has an extra `_`.
$bm = $this->bookmarks['__wp_block_bindings_tag_opener'];
$this->output .= substr( $this->html, $this->end_of_flushed, $bm->start + $bm->length );
$this->output .= $rich_text;
$this->release_bookmark( '_wp_block_bindings_tag_opener' );

while ( $this->next_token() && $this->get_current_depth() >= $depth ) {
}

$this->set_bookmark( '_wp_block_bindings_tag_closer' );
$bm = $this->bookmarks['__wp_block_bindings_tag_closer'];
$this->end_of_flushed = $bm->start;
$this->release_bookmark( '_wp_block_bindings_tag_closer' );
}
}
1 change: 1 addition & 0 deletions src/wp-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@
require ABSPATH . WPINC . '/sitemaps/providers/class-wp-sitemaps-posts.php';
require ABSPATH . WPINC . '/sitemaps/providers/class-wp-sitemaps-taxonomies.php';
require ABSPATH . WPINC . '/sitemaps/providers/class-wp-sitemaps-users.php';
require ABSPATH . WPINC . '/class-wp-block-bindings-processor.php';
require ABSPATH . WPINC . '/class-wp-block-bindings-source.php';
require ABSPATH . WPINC . '/class-wp-block-bindings-registry.php';
require ABSPATH . WPINC . '/class-wp-block-editor-context.php';
Expand Down