Skip to content

Commit

Permalink
Restrict method to figcaption
Browse files Browse the repository at this point in the history
Co-authored-by: Luis Herranz <[email protected]>
  • Loading branch information
SantosGuillamot and luisherranz authored Jun 20, 2024
1 parent 9c9641c commit 4e13d3e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/wp-includes/class-wp-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,18 +337,18 @@ private function replace_html( string $block_content, string $attribute_name, $s
// Create private anonymous class until the HTML API provides `set_inner_html` method.
$bindings_processor = new class( $block_content, WP_HTML_Processor::CONSTRUCTOR_UNLOCK_CODE ) extends WP_HTML_Processor {
/**
* Replace the inner text of an HTML with the passed content.
* Replace the inner content of a figcaption element with the passed content.
*
* THIS IS A TEMPORARY SOLUTION IN CORE NOT TO BE EMULATED.
* IT IS A TEMPORARY SOLUTION THAT JUST WORKS FOR THIS SPECIFIC
* USE CASE UNTIL THE HTML PROCESSOR PROVIDES ITS OWN METHOD.
*
* @since 6.6.0
*
* @param string $new_content New text to insert in the HTML element.
* @return bool Whether the inner text was properly replaced.
* @param string $new_content New content to insert in the figcaption element.
* @return bool Whether the inner content was properly replaced.
*/
public function set_inner_text( $new_content ) {
public function set_content_between_figcaption_balanced_tags( $new_content ) {
/*
* THIS IS A STOP-GAP MEASURE NOT TO BE EMULATED.
*
Expand All @@ -357,6 +357,7 @@ public function set_inner_text( $new_content ) {
*/
if (
WP_HTML_Processor::STATE_MATCHED_TAG !== $this->parser_state ||
'figcaption' !== $this->get_tag() ||

Check failure on line 360 in src/wp-includes/class-wp-block.php

View workflow job for this annotation

GitHub Actions / PHP coding standards / Run coding standards checks

Tabs must be used to indent lines; spaces are not allowed

Check failure on line 360 in src/wp-includes/class-wp-block.php

View workflow job for this annotation

GitHub Actions / PHP coding standards / Run coding standards checks

Line indented incorrectly; expected at least 7 tabs, found 4
$this->is_tag_closer()
) {
return false;
Expand Down

0 comments on commit 4e13d3e

Please sign in to comment.