Skip to content

Commit 0db1374

Browse files
committed
Improve function description following review suggestion.
1 parent b581113 commit 0db1374

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

src/wp-includes/html-api/class-wp-html-tag-processor.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3880,13 +3880,22 @@ static function ( $tag_match ) {
38803880
/**
38813881
* Updates or creates a new attribute on the currently matched tag with the passed value.
38823882
*
3883-
* For boolean attributes special handling is provided:
3883+
* This function handles all necessary HTML encoding. Provide normal, unescaped string values.
3884+
* The HTML API will encode the strings appropriately so that the borwser interprets them to
3885+
* as then intended value.
3886+
*
3887+
* Example:
3888+
*
3889+
* // Renders “Eggs & Milk” in a browser, encoded as `Eggs & Milk`.
3890+
* $processor->set_attribute( 'title', 'Eggs & Milk' );
3891+
*
3892+
* // Renders “Eggs & Milk” in a browser, encoded as `Eggs & Milk`.
3893+
* $processor->set_attribute( 'title', 'Eggs & Milk' );
3894+
*
3895+
* Special handling is provided for boolean attribute values:
38843896
* - When `true` is passed as the value, then only the attribute name is added to the tag.
38853897
* - When `false` is passed, the attribute gets removed if it existed before.
38863898
*
3887-
* HTML escaping will be performed for string attribute values. The input value should
3888-
* not be unescaped.
3889-
*
38903899
* @since 6.2.0
38913900
* @since 6.2.1 Fix: Only create a single update for multiple calls with case-variant attribute names.
38923901
*
@@ -3960,8 +3969,8 @@ public function set_attribute( $name, $value ): bool {
39603969
} else {
39613970
$comparable_name = strtolower( $name );
39623971

3963-
/*
3964-
* Escape URL attributes.
3972+
/**
3973+
* Escape attribute values appropriately.
39653974
*
39663975
* @see https://html.spec.whatwg.org/#attributes-3
39673976
*/

0 commit comments

Comments
 (0)