From f9976b90ad9f86fb22941fc33f0d1913601f8f2b Mon Sep 17 00:00:00 2001 From: pattonwebz Date: Fri, 28 Jun 2024 22:15:15 +0100 Subject: [PATCH] Image inputs with alt text shouldn't flag for missing_form_label --- includes/rules/missing_form_label.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/includes/rules/missing_form_label.php b/includes/rules/missing_form_label.php index 473d0a03..0a8224d2 100644 --- a/includes/rules/missing_form_label.php +++ b/includes/rules/missing_form_label.php @@ -22,6 +22,12 @@ function edac_rule_missing_form_label( $content, $post ) { // phpcs:ignore -- $p if ( in_array( $field->getAttribute( 'type' ), [ 'submit', 'hidden', 'button', 'reset' ], true ) ) { continue; } + + // Not an error if it's an image input with an alt. + if ( 'image' === $field->getAttribute( 'type' ) && ! empty( $field->getAttribute( 'alt' ) ) ) { + continue; + } + if ( ! ac_input_has_label( $field, $dom ) ) { $errors[] = $field->outertext; }