q( '//a[@href]' ) as $a ) { if ( 'true' === $a->getAttribute( 'aria-hidden' ) || Html::is_hidden( $a ) ) { continue; } $href = trim( $a->getAttribute( 'href' ) ); $name = Html::accessible_name( $a, $c->xp ); if ( '' === trim( $name ) ) { if ( $c->q( './/img', $a ) ) { continue; // Reported as a linked image with no name. } if ( '-1' === $a->getAttribute( 'tabindex' ) ) { continue; } $c->add( 'link-empty', $a ); continue; } $norm = strtolower( trim( preg_replace( '/[^\p{L}\p{N}\s]+/u', '', $name ) ) ); $norm = preg_replace( '/\s+/', ' ', $norm ); if ( isset( $vague[ $norm ] ) ) { $c->add( 'link-vague', $a, array( 'text' => $name ) ); } elseif ( '' !== $norm && 0 !== strpos( $href, '#' ) && 0 !== stripos( $href, 'javascript:' ) && 0 !== stripos( $href, 'mailto:' ) && 0 !== stripos( $href, 'tel:' ) ) { $groups[ $norm ][ Html::resolve( $href, $c->url ) ][] = $a; } if ( '_blank' === strtolower( $a->getAttribute( 'target' ) ) ) { $hint = strtolower( $name . ' ' . $a->getAttribute( 'title' ) . ' ' . $a->getAttribute( 'aria-label' ) ); if ( ! preg_match( '/new (tab|window)|opens in|external/', $hint ) ) { $c->add( 'link-new-window', $a ); } } $path = (string) wp_parse_url( $href, PHP_URL_PATH ); $ext = strtolower( pathinfo( $path, PATHINFO_EXTENSION ) ); if ( '' !== $ext && in_array( $ext, $phrases['fileExtensions'], true ) && false === stripos( $name, $ext ) && ! preg_match( '/download|document|file/i', $name ) ) { $c->add( 'link-file-no-type', $a, array( 'extension' => $ext ) ); } } foreach ( $groups as $text => $dests ) { if ( count( $dests ) < 2 ) { continue; } $n = 0; foreach ( $dests as $dest => $links ) { $c->add( 'link-same-text-different-dest', $links[0], array( 'text' => $text, 'destinations' => count( $dests ), ) ); if ( ++$n >= 4 ) { break; } } } foreach ( $c->q( "//button | //*[@role='button'] | //input[@type='button' or @type='submit' or @type='reset']" ) as $b ) { if ( 'true' === $b->getAttribute( 'aria-hidden' ) || Html::is_hidden( $b ) ) { continue; } if ( '' === trim( Html::accessible_name( $b, $c->xp ) ) ) { $c->add( 'button-empty', $b ); } } } }