Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
WP_HTML_Tag_Processor::parse_query( array|string|null $query )
Parses tag query input into internal search criteria.
Parameters
-
$query
array|string|null Optional -
Which tag name to find, having which class, etc. Default is to find any tag.
tag_name
string|nullWhich tag to find, ornull
for "any tag."match_offset
int|nullFind the Nth tag matching all search criteria.
1 for "first" tag, 3 for "third," etc.
Defaults to first tag.class_name
string|nullTag must contain this class name to match.tag_closers
string"visit" or "skip": whether to stop on tag closers, e.g. </div>.
Source
File: wp-includes/html-api/class-wp-html-tag-processor.php
.
View all references
private function parse_query( $query ) {
if ( null !== $query && $query === $this->last_query ) {
return;
}
$this->last_query = $query;
$this->sought_tag_name = null;
$this->sought_class_name = null;
$this->sought_match_offset = 1;
$this->stop_on_tag_closers = false;
// A single string value means "find the tag of this name".
if ( is_string( $query ) ) {
$this->sought_tag_name = $query;
return;
}
// An empty query parameter applies no restrictions on the search.
if ( null === $query ) {
return;
}
// If not using the string interface, an associative array is required.
if ( ! is_array( $query ) ) {
_doing_it_wrong(
__METHOD__,
__( 'The query argument must be an array or a tag name.' ),
'6.2.0'
);
return;
}
if ( isset( $query['tag_name'] ) && is_string( $query['tag_name'] ) ) {
$this->sought_tag_name = $query['tag_name'];
}
if ( isset( $query['class_name'] ) && is_string( $query['class_name'] ) ) {
$this->sought_class_name = $query['class_name'];
}
if ( isset( $query['match_offset'] ) && is_int( $query['match_offset'] ) && 0 < $query['match_offset'] ) {
$this->sought_match_offset = $query['match_offset'];
}
if ( isset( $query['tag_closers'] ) ) {
$this->stop_on_tag_closers = 'visit' === $query['tag_closers'];
}
}
Changelog
Version | Description |
---|---|
6.2.0 | Introduced. |