Updates or creates a new attribute on the currently matched tag with the passed value.
Description
For boolean attributes special handling is provided: <ul> <li>When true is passed as the value, then only the attribute name is added to the tag.</li> <li>When false is passed, the attribute gets removed if it existed before.</li> </ul> For string attributes, the value is escaped using the esc_attr function.
Parameters
$namestring
The attribute name to target.
$valuestring|bool
The new attribute value.
Return
bool
Whether an attribute value was set.
Uses · 2
WP_HTML_Processor::is_virtual()Indicates if the currently-matched token is virtual, created by a stack operation while processing HTML, rather than a token found in the HTML text itself.
Signature, return type and hooks compared across 5 parsed releases.
About this page
Parsed data
Generated from the wordpress-develop 6.8.8 tag, from src/wp-includes/html-api/class-wp-html-processor.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.