diff --git a/plugins/auto-sizes/optimization-detective.php b/plugins/auto-sizes/optimization-detective.php index e753fd2f38..3b10027dac 100644 --- a/plugins/auto-sizes/optimization-detective.php +++ b/plugins/auto-sizes/optimization-detective.php @@ -16,7 +16,7 @@ * @since 1.1.0 * * @param OD_Tag_Visitor_Context $context Tag visitor context. - * @return false Whether the tag should be recorded in URL metrics. + * @return false Whether the tag should be tracked in URL metrics. */ function auto_sizes_visit_tag( OD_Tag_Visitor_Context $context ): bool { if ( 'IMG' !== $context->processor->get_tag() ) { diff --git a/plugins/embed-optimizer/class-embed-optimizer-tag-visitor.php b/plugins/embed-optimizer/class-embed-optimizer-tag-visitor.php index 4791b845cf..e902f1a6bb 100644 --- a/plugins/embed-optimizer/class-embed-optimizer-tag-visitor.php +++ b/plugins/embed-optimizer/class-embed-optimizer-tag-visitor.php @@ -32,7 +32,7 @@ final class Embed_Optimizer_Tag_Visitor { * @since 0.2.0 * * @param OD_Tag_Visitor_Context $context Tag visitor context. - * @return bool Whether the visit or visited the tag. + * @return bool Whether the tag should be tracked in URL metrics. */ public function __invoke( OD_Tag_Visitor_Context $context ): bool { $processor = $context->processor; diff --git a/plugins/image-prioritizer/class-image-prioritizer-background-image-styled-tag-visitor.php b/plugins/image-prioritizer/class-image-prioritizer-background-image-styled-tag-visitor.php index 8e6a01f522..ae6836b284 100644 --- a/plugins/image-prioritizer/class-image-prioritizer-background-image-styled-tag-visitor.php +++ b/plugins/image-prioritizer/class-image-prioritizer-background-image-styled-tag-visitor.php @@ -23,7 +23,7 @@ final class Image_Prioritizer_Background_Image_Styled_Tag_Visitor extends Image_ * Visits a tag. * * @param OD_Tag_Visitor_Context $context Tag visitor context. - * @return bool Whether the visitor visited the tag. + * @return bool Whether the tag should be tracked in URL metrics. */ public function __invoke( OD_Tag_Visitor_Context $context ): bool { $processor = $context->processor; diff --git a/plugins/image-prioritizer/class-image-prioritizer-img-tag-visitor.php b/plugins/image-prioritizer/class-image-prioritizer-img-tag-visitor.php index 4395cdaf83..287e955f31 100644 --- a/plugins/image-prioritizer/class-image-prioritizer-img-tag-visitor.php +++ b/plugins/image-prioritizer/class-image-prioritizer-img-tag-visitor.php @@ -24,7 +24,7 @@ final class Image_Prioritizer_Img_Tag_Visitor extends Image_Prioritizer_Tag_Visi * * @param OD_Tag_Visitor_Context $context Tag visitor context. * - * @return bool Whether the visitor visited the tag. + * @return bool Whether the tag should be tracked in URL metrics. */ public function __invoke( OD_Tag_Visitor_Context $context ): bool { $processor = $context->processor; diff --git a/plugins/image-prioritizer/class-image-prioritizer-tag-visitor.php b/plugins/image-prioritizer/class-image-prioritizer-tag-visitor.php index b768725a6b..e0f4d564e7 100644 --- a/plugins/image-prioritizer/class-image-prioritizer-tag-visitor.php +++ b/plugins/image-prioritizer/class-image-prioritizer-tag-visitor.php @@ -23,7 +23,7 @@ abstract class Image_Prioritizer_Tag_Visitor { * Visits a tag. * * @param OD_Tag_Visitor_Context $context Tag visitor context. - * @return bool Whether the visitor visited the tag. + * @return bool Whether the tag should be tracked in URL metrics. */ abstract public function __invoke( OD_Tag_Visitor_Context $context ): bool; diff --git a/plugins/optimization-detective/optimization.php b/plugins/optimization-detective/optimization.php index 8e4d997506..bd52395b21 100644 --- a/plugins/optimization-detective/optimization.php +++ b/plugins/optimization-detective/optimization.php @@ -215,12 +215,12 @@ function od_optimize_template_output_buffer( string $buffer ): string { $current_tag_bookmark = 'optimization_detective_current_tag'; $visitors = iterator_to_array( $tag_visitor_registry ); do { - $did_visit = false; + $tracked_in_url_metrics = false; $processor->set_bookmark( $current_tag_bookmark ); // TODO: Should we break if this returns false? foreach ( $visitors as $visitor ) { - $cursor_move_count = $processor->get_cursor_move_count(); - $did_visit = $visitor( $tag_visitor_context ) || $did_visit; + $cursor_move_count = $processor->get_cursor_move_count(); + $tracked_in_url_metrics = $visitor( $tag_visitor_context ) || $tracked_in_url_metrics; // If the visitor traversed HTML tags, we need to go back to this tag so that in the next iteration any // relevant tag visitors may apply, in addition to properly setting the data-od-xpath on this tag below. @@ -230,7 +230,7 @@ function od_optimize_template_output_buffer( string $buffer ): string { } $processor->release_bookmark( $current_tag_bookmark ); - if ( $did_visit && $needs_detection ) { + if ( $tracked_in_url_metrics && $needs_detection ) { $processor->set_meta_attribute( 'xpath', $processor->get_xpath() ); } } while ( $processor->next_open_tag() );