Skip to content

Commit 4e13d3e

Browse files
Restrict method to figcaption
Co-authored-by: Luis Herranz <luisherranz@gmail.com>
1 parent 9c9641c commit 4e13d3e

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,18 +337,18 @@ private function replace_html( string $block_content, string $attribute_name, $s
337337
// Create private anonymous class until the HTML API provides `set_inner_html` method.
338338
$bindings_processor = new class( $block_content, WP_HTML_Processor::CONSTRUCTOR_UNLOCK_CODE ) extends WP_HTML_Processor {
339339
/**
340-
* Replace the inner text of an HTML with the passed content.
340+
* Replace the inner content of a figcaption element with the passed content.
341341
*
342342
* THIS IS A TEMPORARY SOLUTION IN CORE NOT TO BE EMULATED.
343343
* IT IS A TEMPORARY SOLUTION THAT JUST WORKS FOR THIS SPECIFIC
344344
* USE CASE UNTIL THE HTML PROCESSOR PROVIDES ITS OWN METHOD.
345345
*
346346
* @since 6.6.0
347347
*
348-
* @param string $new_content New text to insert in the HTML element.
349-
* @return bool Whether the inner text was properly replaced.
348+
* @param string $new_content New content to insert in the figcaption element.
349+
* @return bool Whether the inner content was properly replaced.
350350
*/
351-
public function set_inner_text( $new_content ) {
351+
public function set_content_between_figcaption_balanced_tags( $new_content ) {
352352
/*
353353
* THIS IS A STOP-GAP MEASURE NOT TO BE EMULATED.
354354
*
@@ -357,6 +357,7 @@ public function set_inner_text( $new_content ) {
357357
*/
358358
if (
359359
WP_HTML_Processor::STATE_MATCHED_TAG !== $this->parser_state ||
360+
'figcaption' !== $this->get_tag() ||
360361
$this->is_tag_closer()
361362
) {
362363
return false;

0 commit comments

Comments
 (0)