Returns the value of a requested attribute from a matched tag opener if that attribute exists.
Example:
$p = WP_HTML_Processor::create_fragment( '<div enabled class="test" data-test-id="14">Test</div>' );
$p->next_token() === true;
$p->get_attribute( 'data-test-id' ) === '14';
$p->get_attribute( 'enabled' ) === true;
$p->get_attribute( 'aria-label' ) === null;
$p->next_tag() === false;
$p->get_attribute( 'class' ) === null;$namestringrequired
null if not available. Boolean attributes return true./*
* > A start tag whose tag name is "noscript", if the scripting flag is disabled
*/
| Version | Description |
|---|---|
| 6.6.0 | Introduced. |
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_html_processor/get_attribute