WP_HTML_Decoder::decode_attribute( string $text ): string

In this article

Returns a string containing the decoded value of a given HTML attribute.

Description

Text found inside an HTML attribute has different parsing rules than for text found inside other markup, or DATA segments. Use this function to read the decoded value of an HTML string inside a quoted attribute.

Example:

'“😄”' === WP_HTML_Decode::decode_attribute( '“😄&#x94' );

Parameters

$textstringrequired
Text containing raw and non-decoded attribute value to decode.

Return

string Decoded UTF-8 value of given attribute value.

Source

public static function decode_attribute( $text ): string {
	return static::decode( 'attribute', $text );
}

Changelog

VersionDescription
6.6.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.