Parses tag query input into internal search criteria.
Parameters
$queryarray|string|nulloptional- Which tag name to find, having which class, etc. Default is to find any tag.
tag_namestring|nullWhich tag to find, ornullfor "any tag."match_offsetint|nullFind the Nth tag matching all search criteria.
1 for "first" tag, 3 for "third," etc.
Defaults to first tag.class_namestring|nullTag must contain this class name to match.tag_closersstring"visit" or "skip": whether to stop on tag closers, e.g. </div>.
Source
/**
* WordPress rejects more characters than are strictly forbidden
* in HTML5. This is to prevent additional security risks deeper
* in the WordPress and plugin stack. Specifically the following
* are not allowed to be set as part of an HTML attribute name:
*
* - greater-than “>”
* - ampersand “&”
*
* @see https://html.spec.whatwg.org/#attributes-2
*/
if (
0 === $name_length ||
// Syntax-like characters.
strcspn( $name, '"\'>&</ =' ) !== $name_length ||
// Control characters.
strcspn(
$name,
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F" .
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"
) !== $name_length ||
// Unicode noncharacters.
wp_has_noncharacters( $name )
) {
_doing_it_wrong(
__METHOD__,
__( 'Invalid attribute name.' ),
'6.2.0'
);
return false;
}
/*
* > The values "true" and "false" are not allowed on boolean attributes.
* > To represent a false value, the attribute has to be omitted altogether.
* - HTML5 spec, https://html.spec.whatwg.org/#boolean-attributes
*/
if ( false === $value ) {
return $this->remove_attribute( $name );
}
if ( true === $value ) {
$updated_attribute = $name;
} else {
$comparable_name = strtolower( $name );
Changelog
| Version | Description |
|---|---|
| 6.2.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.