Skip to content
Closed
Prev Previous commit
Next Next commit
Improve function description following review suggestion.
  • Loading branch information
sirreal committed Oct 9, 2025
commit 0db137464a0f3a94d9d918bb65339a9a7a97d746
21 changes: 15 additions & 6 deletions src/wp-includes/html-api/class-wp-html-tag-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -3880,13 +3880,22 @@ static function ( $tag_match ) {
/**
* Updates or creates a new attribute on the currently matched tag with the passed value.
*
* For boolean attributes special handling is provided:
* This function handles all necessary HTML encoding. Provide normal, unescaped string values.
* The HTML API will encode the strings appropriately so that the borwser interprets them to
* as then intended value.
*
* Example:
*
* // Renders “Eggs & Milk” in a browser, encoded as `Eggs & Milk`.
* $processor->set_attribute( 'title', 'Eggs & Milk' );
*
* // Renders “Eggs & Milk” in a browser, encoded as `Eggs & Milk`.
* $processor->set_attribute( 'title', 'Eggs & Milk' );
*
* Special handling is provided for boolean attribute values:
* - When `true` is passed as the value, then only the attribute name is added to the tag.
* - When `false` is passed, the attribute gets removed if it existed before.
*
* HTML escaping will be performed for string attribute values. The input value should
* not be unescaped.
*
* @since 6.2.0
* @since 6.2.1 Fix: Only create a single update for multiple calls with case-variant attribute names.
*
Expand Down Expand Up @@ -3960,8 +3969,8 @@ public function set_attribute( $name, $value ): bool {
} else {
$comparable_name = strtolower( $name );

/*
* Escape URL attributes.
/**
* Escape attribute values appropriately.
*
* @see https://html.spec.whatwg.org/#attributes-3
*/
Expand Down
Loading