From 3bcedb614bcf815e9874a7387074c6f35247f7ba Mon Sep 17 00:00:00 2001 From: Cooper Dalrymple Date: Tue, 9 Jun 2026 13:39:43 -0500 Subject: [PATCH] Fix floating target `button` tag --- inc/class-widget.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/inc/class-widget.php b/inc/class-widget.php index be8a169..153bddc 100644 --- a/inc/class-widget.php +++ b/inc/class-widget.php @@ -163,21 +163,19 @@ final class Widget { } $tags = new WP_HTML_Tag_Processor($html); - while (true) { + $tags->next_tag(); + $tags->set_bookmark('top'); + foreach ($queries as $query) { + $tags->seek('top'); $found = false; - foreach ($queries as $query) { - if ($tags->next_tag($query)) { - $found = true; - break; + while ($tags->next_tag($query)) { + if (!is_null($args['type_name']) && !empty($args['type_name']) && $tags->get_attribute('type') !== $args['type_name']) continue; + $found = true; + foreach ($attributes as $name => $value) { + $tags->set_attribute($name, $value); } } - if (!$found) break; - - if (!is_null($args['type_name']) && !empty($args['type_name']) && $tags->get_attribute('type') !== $args['type_name']) continue; - - foreach ($attributes as $name => $value) { - $tags->set_attribute($name, $value); - } + if ($found) break; } return $tags->get_updated_html(); }