Skip to content

Commit b558a5a

Browse files
committed
Remove static var
1 parent 4a4b31a commit b558a5a

File tree

1 file changed

+35
-38
lines changed

1 file changed

+35
-38
lines changed

src/wp-includes/class-wp-block.php

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -463,50 +463,47 @@ private function replace_html( string $block_content, string $attribute_name, $s
463463
}
464464

465465
private static function get_block_bindings_processor( string $block_content ) {
466-
static $internal_processor_class = null;
467-
if ( null === $internal_processor_class ) {
468-
$internal_processor_class = new class('', WP_HTML_Processor::CONSTRUCTOR_UNLOCK_CODE) extends WP_HTML_Processor {
469-
/**
470-
* Replace the rich text content between a tag opener and matching closer.
471-
*
472-
* When stopped on a tag opener, replace the content enclosed by it and its
473-
* matching closer with the provided rich text.
474-
*
475-
* @param string $rich_text The rich text to replace the original content with.
476-
* @return bool True on success.
477-
*/
478-
public function replace_rich_text( $rich_text ) {
479-
if ( $this->is_tag_closer() ) {
480-
return false;
481-
}
466+
$internal_processor_class = new class('', WP_HTML_Processor::CONSTRUCTOR_UNLOCK_CODE) extends WP_HTML_Processor {
467+
/**
468+
* Replace the rich text content between a tag opener and matching closer.
469+
*
470+
* When stopped on a tag opener, replace the content enclosed by it and its
471+
* matching closer with the provided rich text.
472+
*
473+
* @param string $rich_text The rich text to replace the original content with.
474+
* @return bool True on success.
475+
*/
476+
public function replace_rich_text( $rich_text ) {
477+
if ( $this->is_tag_closer() ) {
478+
return false;
479+
}
482480

483-
$depth = $this->get_current_depth();
481+
$depth = $this->get_current_depth();
484482

485-
$this->set_bookmark( '_wp_block_bindings_tag_opener' );
486-
// The bookmark names are prefixed with `_` so the key below has an extra `_`.
487-
$tag_opener = $this->bookmarks['__wp_block_bindings_tag_opener'];
488-
$start = $tag_opener->start + $tag_opener->length;
489-
$this->release_bookmark( '_wp_block_bindings_tag_opener' );
483+
$this->set_bookmark( '_wp_block_bindings_tag_opener' );
484+
// The bookmark names are prefixed with `_` so the key below has an extra `_`.
485+
$tag_opener = $this->bookmarks['__wp_block_bindings_tag_opener'];
486+
$start = $tag_opener->start + $tag_opener->length;
487+
$this->release_bookmark( '_wp_block_bindings_tag_opener' );
490488

491-
// Find matching tag closer.
492-
while ( $this->next_token() && $this->get_current_depth() >= $depth ) {
493-
}
489+
// Find matching tag closer.
490+
while ( $this->next_token() && $this->get_current_depth() >= $depth ) {
491+
}
494492

495-
$this->set_bookmark( '_wp_block_bindings_tag_closer' );
496-
$tag_closer = $this->bookmarks['__wp_block_bindings_tag_closer'];
497-
$end = $tag_closer->start;
498-
$this->release_bookmark( '_wp_block_bindings_tag_closer' );
493+
$this->set_bookmark( '_wp_block_bindings_tag_closer' );
494+
$tag_closer = $this->bookmarks['__wp_block_bindings_tag_closer'];
495+
$end = $tag_closer->start;
496+
$this->release_bookmark( '_wp_block_bindings_tag_closer' );
499497

500-
$this->lexical_updates[] = new WP_HTML_Text_Replacement(
501-
$start,
502-
$end - $start,
503-
$rich_text
504-
);
498+
$this->lexical_updates[] = new WP_HTML_Text_Replacement(
499+
$start,
500+
$end - $start,
501+
$rich_text
502+
);
505503

506-
return true;
507-
}
508-
};
509-
}
504+
return true;
505+
}
506+
};
510507

511508
return $internal_processor_class::create_fragment( $block_content );
512509
}

0 commit comments

Comments
 (0)