base, array( 'post', 'page' ), true ) ) return; global $post; if ( ! $post ) return; preg_match_all( '/]+>/i', $post->post_content, $images ); $missing = 0; foreach ( $images[0] as $img ) { if ( ! preg_match( '/alt=["\'][^"\']+["\']/i', $img ) ) { $missing++; } } if ( $missing > 0 ) { printf( '

%s

', sprintf( /* translators: %d: number of images missing alt text */ esc_html__( 'WP Accessibility Suite: %d image(s) in this post appear to be missing alt text.', 'a11ykit-accessibility' ), esc_attr($missing) ) ); } } // ── Admin: heading structure check via meta box ──────────────────────────────── add_action( 'add_meta_boxes', 'wpas_heading_meta_box' ); function wpas_heading_meta_box() { if ( ! wpas_is_enabled( 'heading_structure_check' ) ) return; add_meta_box( 'wpas-heading-check', __( 'Accessibility: Heading Structure', 'a11ykit-accessibility' ), 'wpas_heading_meta_box_cb', array( 'post', 'page' ), 'side', 'default' ); } function wpas_heading_meta_box_cb( $post ) { preg_match_all( '/]*>(.*?)<\/h\1>/is', $post->post_content, $headings ); if ( empty( $headings[1] ) ) { echo '

' . esc_html__( 'No headings found in this content.', 'a11ykit-accessibility' ) . '

'; return; } $issues = array(); $prev = 0; foreach ( $headings[1] as $i => $level ) { $level = (int) $level; if ( $prev && $level > $prev + 1 ) { $issues[] = sprintf( // esc_html__( 'Heading level jumped from H%d to H%d (skipped levels).', 'a11ykit-accessibility' ), /* translators: 1: previous heading level, 2: current heading level */ esc_html__( 'Heading level jumped from H%1$d to H%2$d (skipped levels).', 'a11ykit-accessibility' ), $prev, $level ); } $prev = $level; } if ( empty( $issues ) ) { echo '

✓ ' . esc_html__( 'Heading structure looks good!', 'a11ykit-accessibility' ) . '

'; } else { echo ''; } echo '

' . esc_html__( 'Headings found:', 'a11ykit-accessibility' ) . '

'; }