4040 * Example:
4141 * ```php
4242 * $tags = new WP_HTML_Tag_Processor( $html );
43- * if ( $tags->next_tag( array( 'tag_name' => ' option' ) ) ) {
43+ * if ( $tags->next_tag( ' option' ) ) {
4444 * $tags->set_attribute( 'selected', true );
4545 * }
4646 * ```
5858 * $tags->next_tag();
5959 * ```
6060 *
61- * | Goal | Query |
62- * |-----------------------------------------------------------|----------------------------------------------------------------------------|
63- * | Find any tag. | `$tags->next_tag();` |
61+ * | Goal | Query |
62+ * |-----------------------------------------------------------|--------------------------------------------------------------------------------- |
63+ * | Find any tag. | `$tags->next_tag();` |
6464 * | Find next image tag. | `$tags->next_tag( array( 'tag_name' => 'img' ) );` |
65+ * | Find next image tag (without passing the array). | `$tags->next_tag( 'img' );` |
6566 * | Find next tag containing the `fullwidth` CSS class. | `$tags->next_tag( array( 'class_name' => 'fullwidth' ) );` |
6667 * | Find next image tag containing the `fullwidth` CSS class. | `$tags->next_tag( array( 'tag_name' => 'img', 'class_name' => 'fullwidth' ) );` |
6768 *
@@ -775,7 +776,8 @@ private function skip_rcdata( $tag_name ) {
775776 return false ;
776777 }
777778
778- $ at += 2 ;
779+ $ closer_potentially_starts_at = $ at ;
780+ $ at += 2 ;
779781
780782 /*
781783 * Find a case-insensitive match to the tag name.
@@ -818,7 +820,7 @@ private function skip_rcdata( $tag_name ) {
818820 }
819821
820822 if ( '> ' === $ html [ $ at ] || '/ ' === $ html [ $ at ] ) {
821- ++ $ this ->bytes_already_parsed ;
823+ $ this ->bytes_already_parsed = $ closer_potentially_starts_at ;
822824 return true ;
823825 }
824826 }
@@ -887,7 +889,8 @@ private function skip_script_data() {
887889 }
888890
889891 if ( '/ ' === $ html [ $ at ] ) {
890- $ is_closing = true ;
892+ $ closer_potentially_starts_at = $ at - 1 ;
893+ $ is_closing = true ;
891894 ++$ at ;
892895 } else {
893896 $ is_closing = false ;
@@ -938,7 +941,7 @@ private function skip_script_data() {
938941 }
939942
940943 if ( $ is_closing ) {
941- $ this ->bytes_already_parsed = $ at ;
944+ $ this ->bytes_already_parsed = $ closer_potentially_starts_at ;
942945 if ( $ this ->bytes_already_parsed >= $ doc_length ) {
943946 return false ;
944947 }
@@ -948,7 +951,7 @@ private function skip_script_data() {
948951 }
949952
950953 if ( '> ' === $ html [ $ this ->bytes_already_parsed ] ) {
951- ++ $ this ->bytes_already_parsed ;
954+ $ this ->bytes_already_parsed = $ closer_potentially_starts_at ;
952955 return true ;
953956 }
954957 }
@@ -1608,7 +1611,7 @@ private function get_enqueued_attribute_value( $comparable_name ) {
16081611 * $p->get_attribute( 'enabled' ) === true;
16091612 * $p->get_attribute( 'aria-label' ) === null;
16101613 *
1611- * $p->next_tag( array() ) === false;
1614+ * $p->next_tag() === false;
16121615 * $p->get_attribute( 'class' ) === null;
16131616 * ```
16141617 *
@@ -1689,7 +1692,7 @@ public function get_attribute( $name ) {
16891692 * $p->next_tag( array( 'class_name' => 'test' ) ) === true;
16901693 * $p->get_attribute_names_with_prefix( 'data-' ) === array( 'data-enabled', 'data-test-id' );
16911694 *
1692- * $p->next_tag( array() ) === false;
1695+ * $p->next_tag() === false;
16931696 * $p->get_attribute_names_with_prefix( 'data-' ) === null;
16941697 * ```
16951698 *
@@ -1720,10 +1723,10 @@ function get_attribute_names_with_prefix( $prefix ) {
17201723 * Example:
17211724 * ```php
17221725 * $p = new WP_HTML_Tag_Processor( '<DIV CLASS="test">Test</DIV>' );
1723- * $p->next_tag( array() ) === true;
1726+ * $p->next_tag() === true;
17241727 * $p->get_tag() === 'DIV';
17251728 *
1726- * $p->next_tag( array() ) === false;
1729+ * $p->next_tag() === false;
17271730 * $p->get_tag() === null;
17281731 * ```
17291732 *
0 commit comments