-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathIncorrectHeadingOrderRule.php
More file actions
65 lines (62 loc) · 2.86 KB
/
Copy pathIncorrectHeadingOrderRule.php
File metadata and controls
65 lines (62 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* IncorrectHeadingOrder Rule.
*
* @package EqualizeDigital\AccessibilityChecker
*/
namespace EqualizeDigital\AccessibilityChecker\Rules\Rule;
use EqualizeDigital\AccessibilityChecker\Rules\RuleInterface;
use EqualizeDigital\AccessibilityChecker\Rules\AffectedDisabilities;
/**
* IncorrectHeadingOrder Rule class.
*/
class IncorrectHeadingOrderRule implements RuleInterface {
/**
* Get the rule definition.
*
* @return array The rule definition array.
*/
public static function get_rule(): array {
return [
'title' => esc_html__( 'Incorrect Heading Order', 'accessibility-checker' ),
'info_url' => 'https://a11ychecker.com/help1940',
'slug' => 'incorrect_heading_order',
'rule_type' => 'error',
'summary' => esc_html__( 'This page uses headings out of order, skipping one or more heading levels.', 'accessibility-checker' ),
'summary_plural' => sprintf(
// translators: %1$s is <code><h1></code>, %2$s is <code><h3></code>, %3$s is <code><h2></code.
esc_html__( 'These pages use headings out of order, skipping one or more heading levels, such as going from %1$s to %2$s without an %3$s between.', 'accessibility-checker' ),
'<code><h1></code>',
'<code><h3></code>',
'<code><h2></code>'
),
'why_it_matters' => esc_html__( 'Headings help all users—especially those using screen readers or keyboard navigation—understand the structure of the page. Skipping heading levels can create confusion and make it harder to follow the content hierarchy or navigate efficiently.', 'accessibility-checker' ),
'how_to_fix' => sprintf(
// translators: %1$s is <code><h1></code>, %2$s is <code><h3></code>, %3$s is <code><h2></code.
esc_html__( 'Revise your headings to follow a logical order without skipping levels. For example, if a %1$s is followed by a %2$s, change the %2$s to a %3$s or add an intervening %3$s section to preserve proper structure. If needed, use CSS or block/page builder settings to style headings rather than setting the incorrect level.', 'accessibility-checker' ),
'<code><h1></code>',
'<code><h3></code>',
'<code><h2></code>'
),
'references' => [
[
'text' => __( 'W3C Page Structure Tutorial: Headings', 'accessibility-checker' ),
'url' => 'https://www.w3.org/WAI/tutorials/page-structure/headings/',
],
],
'ruleset' => 'js',
'wcag' => '1.3.1',
'severity' => 2, // High.
'affected_disabilities' => [
AffectedDisabilities::BLIND,
AffectedDisabilities::LOW_VISION,
AffectedDisabilities::DEAFBLIND,
AffectedDisabilities::COGNITIVE,
AffectedDisabilities::MOBILITY,
],
'combines' => [
'heading-order',
],
];
}
}