mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-20 19:56:49 +01:00
HTML API: Respect class_name query arg in HTML_Processor::next_tag()
Previously the HTML Process was ignoring the `class_name` argument in the `next_tag()` query if it existed. This was wrong and would lead to calling code finding the wrong tag if provided. This patch adds the class detection code back into `next_tag()` to fix the bug. Developed in https://github.com/WordPress/wordpress-develop/pull/6618 Discussed in https://core.trac.wordpress.org/ticket/58517 See #58517. Follow-up to [56274]. Props: dmsnell, jonsurrell. Built from https://develop.svn.wordpress.org/trunk@58190 git-svn-id: http://core.svn.wordpress.org/trunk@57653 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3c2e6808c3
commit
c3b76697cd
|
|
@ -386,12 +386,20 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
|
|||
return false;
|
||||
}
|
||||
|
||||
$needs_class = ( isset( $query['class_name'] ) && is_string( $query['class_name'] ) )
|
||||
? $query['class_name']
|
||||
: null;
|
||||
|
||||
if ( ! ( array_key_exists( 'breadcrumbs', $query ) && is_array( $query['breadcrumbs'] ) ) ) {
|
||||
while ( $this->step() ) {
|
||||
if ( '#tag' !== $this->get_token_type() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( isset( $needs_class ) && ! $this->has_class( $needs_class ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! $this->is_tag_closer() ) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -417,6 +425,10 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
|
|||
continue;
|
||||
}
|
||||
|
||||
if ( isset( $needs_class ) && ! $this->has_class( $needs_class ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $this->matches_breadcrumbs( $breadcrumbs ) && 0 === --$match_offset ) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.6-alpha-58189';
|
||||
$wp_version = '6.6-alpha-58190';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user