WP_HTML_Processor::set_attribute()
Updates or creates a new attribute on the currently matched tag with the passed value.
For boolean attributes special handling is provided:
- 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.
For string attributes, the value is escaped using the esc_attr function.
Method of the class: WP_HTML_Processor{}
No Hooks.
Return
true|false
. Whether an attribute value was set.
Usage
$WP_HTML_Processor = new WP_HTML_Processor(); $WP_HTML_Processor->set_attribute( $name, $value );
- $name(string) (required)
- The attribute name to target.
- $value(string|true|false) (required)
- The new attribute value.
Changelog
Since 6.6.0 | Introduced. |
Since 6.6.0 | Subclassed for the HTML Processor. |
WP_HTML_Processor::set_attribute() WP HTML Processor::set attribute code WP 6.6.2
public function set_attribute( $name, $value ) { return $this->is_virtual() ? false : parent::set_attribute( $name, $value ); }