array( 'post', 'page' ),
'post_status' => 'publish',
'posts_per_page' => (int) $limit,
'orderby' => 'modified',
'order' => 'DESC',
) );
$findings = array();
foreach ( $posts as $p ) {
$findings[] = $this->analyse_post( $p );
}
return $findings;
}
/**
* Analyse a single post's content for accessibility issues.
*/
public function analyse_post( $post ) {
$content = $post->post_content;
$issues = array();
// Missing alt
$img_count = preg_match_all( '/]*\salt=)/i', $content );
if ( $missing_alt > 0 ) {
$issues[] = array(
'severity' => 'critical',
'rule' => 'WCAG 1.1.1',
'count' => (int) $missing_alt,
'label' => sprintf( __( '%d image(s) missing alt text', 'sitefix' ), $missing_alt ),
);
}
// No H1
if ( $img_count > 0 && ! preg_match( '/