Skip to content

Commit

Permalink
Merge pull request #696 from equalizedigital/william/610/dont-flag-mi…
Browse files Browse the repository at this point in the history
…ssing-form-label-on-image-input-with-alt

Enahcement: Image inputs with alt text shouldn't flag for missing_form_label
  • Loading branch information
pattonwebz authored Jul 8, 2024
2 parents 9b49a4a + f9976b9 commit 3dfdeac
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions includes/rules/missing_form_label.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 3dfdeac

Please sign in to comment.