Returns the value of a requested attribute from a matched tag opener if that attribute exists.
Description
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;
Parameters
$name
stringrequired- Name of attribute whose value is requested.
Source
/*
* > A start tag whose tag name is "noscript", if the scripting flag is disabled
*/
Changelog
Version | Description |
---|---|
6.6.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.