WP Accessibility - Version 2.0.0

Version Description

  • New feature: Show alt attributes toggle on content images.
  • New feature: Ensure users can adjust scale even if maximum-scale set to 1.0.
  • New feature: Alt enforcement indicators now present in block editor.
  • New feature: Flag missing captions or subtitles in uploaded videos in editor.
  • Updated feature: Remove title attributes now more intelligent.
  • Updated feature: Modernized alt attribute enforcement tools.
  • Change: Combine remediation scripting in wp-accessibility.js.
  • Change: Disable accessibility-ready duplicating features if theme changed to accessibility-ready.
  • Bug fix: aria-expanded missing in some cases for longdesc disclosures.
  • Bug fix: Main JS file did not have a version number.
  • Bug fix: Run feature JS after running remediation JS.
  • Bug fix: Fix DOM ordering with image disclosure buttons.
  • Retired language directory call. Translation files haven't been updated since version Oct 2014.
Download this release

Release Info

Developer joedolson
Plugin Icon 128x128 WP Accessibility
Version 2.0.0
Comparing to
See all releases

Code changes from version 1.9.2 to 2.0.0

css/editor-style.css CHANGED
@@ -1,4 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
1
  .wpa-image-missing-alt {
2
- border: 2px solid red;
3
- box-shadow: 0 0 2px 2px #ffa;
4
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wp-block-image {
2
+ position: relative;
3
+ }
4
+
5
+ .wp-video-shortcode:not(.wp-video-shortcode:has(track[kind="captions"],track[kind="subtitles"])),
6
+ .wp-block-video:not(.wp-block-video:has(track[kind="captions"],track[kind="subtitles"])) {
7
+ border: 4px solid #b32d2e;
8
+ }
9
+
10
+ img[alt*="This image has an empty alt"],
11
+ .wp-block-image img[alt=""],
12
  .wpa-image-missing-alt {
13
+ outline: 4px solid #b32d2e;
14
+ outline-offset: 2px;
15
+ }
16
+
17
+ .wp-block-image:has(img[alt*="This image has an empty alt"]):after,
18
+ .wp-block-image:has(img[alt=""]):after,
19
+ .wpa-image-missing-alt:after {
20
+ content: 'alt text missing';
21
+ position: absolute;
22
+ left: 10px;
23
+ top: 10px;
24
+ background: rgba( 0,0,0,.65 );
25
+ color: #fff;
26
+ padding: 3px 5px;
27
+ border-radius: 5px;
28
+ border: 1px solid #b32d2e;
29
+ font-size: .875rem;
30
+ font-weight: 700;
31
+ }
32
+
33
+ .wp-video-shortcode:not(.wp-video-shortcode:has(track[kind="captions"],track[kind="subtitles"])):after,
34
+ .wp-block-video:not(.wp-block-video:has(track[kind="captions"],track[kind="subtitles"])):after {
35
+ content: 'no captions or subtitles';
36
+ position: absolute;
37
+ left: 10px;
38
+ top: 10px;
39
+ background: rgba( 0,0,0,.65 );
40
+ color: #fff;
41
+ padding: 3px 5px;
42
+ border-radius: 5px;
43
+ border: 1px solid #b32d2e;
44
+ font-size: .875rem;
45
+ font-weight: 700;
46
+ }
css/wpa-style.css CHANGED
@@ -31,20 +31,24 @@
31
  z-index: 100000; /* Above WP toolbar. */
32
  }
33
 
 
34
  .wpa-ld {
35
  display: inline-block;
36
  position: relative;
37
  }
38
 
39
  /* basic support for themes that don't define alignleft and alignright for non-image elements. */
 
40
  div.alignleft.wpa-ld {
41
  float: left;
42
  }
43
 
 
44
  div.alignright.wpa-ld {
45
  float: right;
46
  }
47
 
 
48
  div.aligncenter.wpa-ld {
49
  display: block;
50
  margin: 0 auto;
@@ -56,7 +60,8 @@ div.aligncenter.wpa-ld {
56
  outline-offset: 1px;
57
  }
58
 
59
- .wpa-ld a, .wpa-ld button {
 
60
  bottom: 2px;
61
  left: 2px;
62
  position: absolute;
@@ -64,28 +69,38 @@ div.aligncenter.wpa-ld {
64
  min-width: 24px;
65
  }
66
 
67
- .top-left .wpa-ld a, .top-left .wpa-ld button {
 
68
  top: 2px;
69
  bottom: auto;
70
  }
71
 
72
- .top-right .wpa-ld a, .top-right .wpa-ld button {
 
73
  top: 2px;
74
  right: 2px;
75
  left: auto;
76
  bottom: auto;
77
  }
78
 
79
- .bottom-right .wpa-ld a, .bottom-right .wpa-ld button {
 
80
  right: 2px;
81
  left: auto;
82
  }
83
 
84
- .wpa-ld img {
85
- display: block;
 
 
 
 
 
 
86
  }
87
 
88
- .wpa-ld button, .wpa-ld button:active, .wpa-ld button:focus, .wpa-ld button:hover {
 
89
  border: 1px solid #777;
90
  border-radius: 2px;
91
  z-index: 10;
@@ -101,21 +116,48 @@ div.aligncenter.wpa-ld {
101
  -webkit-box-sizing: border-box;
102
  box-sizing: border-box;
103
  background: rgba(255, 255, 255, .95);
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  padding: 1.5em;
 
 
 
105
  text-align: left;
 
 
 
 
 
 
 
 
106
  }
107
 
 
108
  .rtl .wpa-ld .longdesc {
109
  text-align: right;
110
  }
111
 
112
- .wpa-ld button, .wpa-ld button:active, .wpa-ld button:focus, .wpa-ld button:hover, .wpa-ld a {
113
- font-size: 1em;
114
- font-weight: 400;
115
  background: rgba(255, 255, 255, .8) !important;
116
  padding: 0;
 
 
117
  color: #000 !important;
118
- padding: 3px 6px;
119
  border-radius: 3px;
120
  }
121
 
@@ -123,11 +165,14 @@ div.aligncenter.wpa-ld {
123
  line-height: inherit;
124
  }
125
 
 
126
  .wpa-ld button:focus, .wpa-ld button:hover {
127
  background: rgba(0, 0, 0, .8) !important;
128
  color: #fff !important;
129
  border: 1px solid #000 !important;
130
  cursor: pointer;
 
 
131
  }
132
 
133
  .template-longdesc {
@@ -165,4 +210,14 @@ label.wpa-screen-reader-text {
165
  .wpa-content-summary div p:last-of-type {
166
  margin-bottom: 0;
167
  padding-bottom: 0;
 
 
 
 
 
 
 
 
 
 
168
  }
31
  z-index: 100000; /* Above WP toolbar. */
32
  }
33
 
34
+ .wpa-alt,
35
  .wpa-ld {
36
  display: inline-block;
37
  position: relative;
38
  }
39
 
40
  /* basic support for themes that don't define alignleft and alignright for non-image elements. */
41
+ div.alignleft.wpa-alt,
42
  div.alignleft.wpa-ld {
43
  float: left;
44
  }
45
 
46
+ div.alignright.wpa-alt,
47
  div.alignright.wpa-ld {
48
  float: right;
49
  }
50
 
51
+ div.aligncenter.wpa-alt,
52
  div.aligncenter.wpa-ld {
53
  display: block;
54
  margin: 0 auto;
60
  outline-offset: 1px;
61
  }
62
 
63
+ .wpa-alt button.wpa-toggle,
64
+ .wpa-ld a.wpa-toggle, .wpa-ld button.wpa-toggle {
65
  bottom: 2px;
66
  left: 2px;
67
  position: absolute;
69
  min-width: 24px;
70
  }
71
 
72
+ .top-left .wpa-alt a.wpa-toggle, .top-left .wpa-alt button.wpa-toggle,
73
+ .top-left .wpa-ld a.wpa-toggle, .top-left .wpa-ld button.wpa-toggle {
74
  top: 2px;
75
  bottom: auto;
76
  }
77
 
78
+ .top-right .wpa-alt a.wpa-toggle, .top-right .wpa-alt button.wpa-toggle,
79
+ .top-right .wpa-ld a.wpa-toggle, .top-right .wpa-ld button.wpa-toggle {
80
  top: 2px;
81
  right: 2px;
82
  left: auto;
83
  bottom: auto;
84
  }
85
 
86
+ .bottom-right .wpa-alt a.wpa-toggle, .bottom-right .wpa-alt button.wpa-toggle,
87
+ .bottom-right .wpa-ld a.wpa-toggle, .bottom-right .wpa-ld button.wpa-toggle {
88
  right: 2px;
89
  left: auto;
90
  }
91
 
92
+ .wpa-alt .wpa-ld button {
93
+ left: 2.5em;
94
+ }
95
+
96
+ .top-right .wpa-alt .wpa-ld button,
97
+ .bottom-right .wpa-alt .wpa-ld button {
98
+ left: auto;
99
+ right: 2.5em;
100
  }
101
 
102
+ .wpa-alt button.wpa-toggle, .wpa-alt button.wpa-toggle:active, .wpa-alt button.wpa-toggle:focus, .wpa-alt button.wpa-toggle:hover,
103
+ .wpa-ld button.wpa-toggle, .wpa-ld button.wpa-toggle:active, .wpa-ld button.wpa-toggle:focus, .wpa-ld button.wpa-toggle:hover {
104
  border: 1px solid #777;
105
  border-radius: 2px;
106
  z-index: 10;
116
  -webkit-box-sizing: border-box;
117
  box-sizing: border-box;
118
  background: rgba(255, 255, 255, .95);
119
+ padding: 2em 1em;
120
+ text-align: left;
121
+ }
122
+
123
+ .wpa-alt .wpa-alt-text {
124
+ position: absolute;
125
+ width: calc( 100% - 2em );
126
+ height: 6em;
127
+ bottom: 0;
128
+ -moz-box-sizing: border-box;
129
+ -webkit-box-sizing: border-box;
130
+ box-sizing: border-box;
131
+ background: rgba(255, 255, 255, .95);
132
  padding: 1.5em;
133
+ margin: 1em;
134
+ border-radius: 15px;
135
+ box-shadow: 0 0 6px #333;
136
  text-align: left;
137
+ z-index: 10;
138
+ }
139
+
140
+ .top-right .wpa-alt .wpa-alt-text,
141
+ .top-left .wpa-alt .wpa-alt-text {
142
+ bottom: auto;
143
+ top: 0;
144
+ margin-top: 2.5em;
145
  }
146
 
147
+ .rtl .wpa-alt .wpa-alt-text,
148
  .rtl .wpa-ld .longdesc {
149
  text-align: right;
150
  }
151
 
152
+ .wpa-alt button.wpa-toggle, .wpa-alt button.wpa-toggle:active, .wpa-alt button.wpa-toggle:focus, .wpa-alt button.wpa-toggle:hover, .wpa-alt a.wpa-toggle,
153
+ .wpa-ld button.wpa-toggle, .wpa-ld button.wpa-toggle:active, .wpa-ld button.wpa-toggle:focus, .wpa-ld button.wpa-toggle:hover, .wpa-ld a.wpa-toggle {
154
+ font-size: 1rem;
155
  background: rgba(255, 255, 255, .8) !important;
156
  padding: 0;
157
+ font-weight: 700;
158
+ font-family: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace;
159
  color: #000 !important;
160
+ padding: 2px 4px;
161
  border-radius: 3px;
162
  }
163
 
165
  line-height: inherit;
166
  }
167
 
168
+ .wpa-alt button:focus, .wpa-alt button:hover,
169
  .wpa-ld button:focus, .wpa-ld button:hover {
170
  background: rgba(0, 0, 0, .8) !important;
171
  color: #fff !important;
172
  border: 1px solid #000 !important;
173
  cursor: pointer;
174
+ outline: 2px solid #a00 !important;
175
+ outline-offset: 1px;
176
  }
177
 
178
  .template-longdesc {
210
  .wpa-content-summary div p:last-of-type {
211
  margin-bottom: 0;
212
  padding-bottom: 0;
213
+ }
214
+
215
+ .wpa-excerpt .wp-block-read-more,
216
+ .wpa-excerpt .wp-block-post-excerpt__more-text {
217
+ display: none !important;
218
+ }
219
+
220
+ .wpa-excerpt .wp-block-post-excerpt .continue {
221
+ margin-top: 1rem;
222
+ display: block;
223
  }
css/wpa-styles.css CHANGED
@@ -91,9 +91,9 @@
91
  .wpa-donate a {
92
  font-size: 1.2rem;
93
  padding: .5rem .1rem .6rem;
94
- background: #233c7f;
95
- color: #fff;
96
- border: 2px solid #79b3e1;
97
  display: block;
98
  text-align: center;
99
  text-decoration: none;
91
  .wpa-donate a {
92
  font-size: 1.2rem;
93
  padding: .5rem .1rem .6rem;
94
+ background: #79b3e1;
95
+ color: #031c5f;
96
+ border: 2px solid #233c7f;
97
  display: block;
98
  text-align: center;
99
  text-decoration: none;
js/alt.button.js ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function ($) {
2
+ 'use strict';
3
+ var selector = ( wpalt.selector ) ? wpalt.selector : '.hentry img[alt!=""], .comment-content img[alt!=""]';
4
+ var collection = $( selector );
5
+ collection.each(function () {
6
+ var img = $( this );
7
+ var inLink = ( 1 == img.closest( 'a' ).length ) ? true : false;
8
+ var inButton = ( 1 == img.closest( 'button' ).length ) ? true : false;
9
+ var width = img.innerWidth();
10
+ var height = img.innerHeight();
11
+ if ( width || height ) {
12
+ width = ( ! width ) ? 56 : width; // Enough width for button to be visible.
13
+ height = ( ! height ) ? 56 : height; // Enough height for button & first line to be visible.
14
+ var area = height * width;
15
+ if ( area < ( 150 * 300 ) ) {
16
+ // Small images won't get displayed alt text containers.
17
+ return;
18
+ }
19
+ }
20
+ var alt = img.attr('alt');
21
+ // The default selector will also pick up images with missing alt attribute, so eliminate those els.
22
+ if ( ! alt ) {
23
+ return;
24
+ }
25
+ var classes = img.attr('class');
26
+ img.attr('class', '');
27
+ if ( inLink || inButton ) {
28
+ var wrapper = ( inLink ) ? img.closest( 'a' ) : img.closest( 'button' );
29
+ wrapper.wrap( '<div class="wpa-alt" />' );
30
+ } else {
31
+ img.wrap('<div class="wpa-alt" />')
32
+ }
33
+ img.closest('.wpa-alt').addClass( classes );
34
+ img.closest('.wpa-alt').append('<button aria-expanded="false" class="wpa-toggle">alt</button>');
35
+ img.closest('.wpa-alt').append('<div class="wpa-alt-text"></div>');
36
+ var container = img.closest('.wpa-alt').children('.wpa-alt-text');
37
+ container.hide();
38
+ container.html( alt );
39
+ img.closest('.wpa-alt').children('button').on( 'click', function(e) {
40
+ e.preventDefault();
41
+ var visible = container.is( ':visible' );
42
+ if ( visible ) {
43
+ $( this ).attr( 'aria-expanded', 'false' );
44
+ container.hide();
45
+ } else {
46
+ $( this ).attr( 'aria-expanded', 'true' );
47
+ container.show(150);
48
+ }
49
+ });
50
+ });
51
+ }(jQuery));
js/current-menu-item.js DELETED
@@ -1,5 +0,0 @@
1
- (function ($) {
2
- $(function() {
3
- $( '.current-menu-item a, .current_page_item a' ).attr( 'aria-current', 'page' );
4
- });
5
- }(jQuery));
 
 
 
 
 
js/longdesc.button.js CHANGED
@@ -19,8 +19,8 @@
19
  img.attr('class', '');
20
  img.wrap('<div class="wpa-ld" />')
21
  img.parent('.wpa-ld').addClass(classes);
22
- img.parent('.wpa-ld').append('<div class="longdesc" aria-live="assertive"></div>');
23
- img.parent('.wpa-ld').append('<button>' + wparest.text + '</button>');
24
  var container = img.parent('.wpa-ld').children('.longdesc');
25
  container.hide();
26
  container.load( longdesc + ' #desc_' + image_id );
@@ -28,8 +28,10 @@
28
  e.preventDefault();
29
  var visible = container.is( ':visible' );
30
  if ( visible ) {
 
31
  container.hide();
32
  } else {
 
33
  container.show(150);
34
  }
35
  });
@@ -40,17 +42,23 @@
40
  wpa_load_image( img );
41
  });
42
 
43
- function wpa_draw_longdesc( img, image_id, longdesc ) {
44
  var classes = img.attr('class');
45
  img.attr('class', '').attr('longdesc', longdesc );
46
  img.attr('id','longdesc-return-' + image_id );
47
  img.wrap('<div class="wpa-ld" />')
48
  img.parent('.wpa-ld').addClass(classes);
49
- img.parent('.wpa-ld').append('<button aria-expanded="false">' + wparest.text + '</button>');
50
- img.parent('.wpa-ld').append('<div class="longdesc" aria-live="assertive"></div>');
51
  var container = img.parent('.wpa-ld').children('.longdesc');
52
  container.hide();
53
- container.load( longdesc + ' #desc_' + image_id );
 
 
 
 
 
 
54
  img.parent('.wpa-ld').children('button').on( 'click', function(e) {
55
  e.preventDefault();
56
  var visible = container.is( ':visible' );
@@ -65,7 +73,11 @@
65
  }
66
 
67
  function wpa_load_image( img ) {
68
- var id = img.attr( 'class' ).replace( 'wp-image-', '' );
 
 
 
 
69
  var api = wparest.url + '/' + id;
70
 
71
  $.get( api )
@@ -79,7 +91,7 @@
79
  var url = new URL( response.link );
80
  url.searchParams.set( 'longdesc', id );
81
  url.toString();
82
- wpa_draw_longdesc( img, id, url );
83
  }
84
  })
85
  .fail( function() {
19
  img.attr('class', '');
20
  img.wrap('<div class="wpa-ld" />')
21
  img.parent('.wpa-ld').addClass(classes);
22
+ img.parent('.wpa-ld').append('<button aria-expanded="false" class="wpa-toggle">' + wparest.text + '</button>');
23
+ img.parent('.wpa-ld').append('<div class="longdesc"></div>');
24
  var container = img.parent('.wpa-ld').children('.longdesc');
25
  container.hide();
26
  container.load( longdesc + ' #desc_' + image_id );
28
  e.preventDefault();
29
  var visible = container.is( ':visible' );
30
  if ( visible ) {
31
+ $( this ).attr( 'aria-expanded', 'false' );
32
  container.hide();
33
  } else {
34
+ $( this ).attr( 'aria-expanded', 'true' );
35
  container.show(150);
36
  }
37
  });
42
  wpa_load_image( img );
43
  });
44
 
45
+ function wpa_draw_longdesc( img, image_id, longdesc, rawdesc ) {
46
  var classes = img.attr('class');
47
  img.attr('class', '').attr('longdesc', longdesc );
48
  img.attr('id','longdesc-return-' + image_id );
49
  img.wrap('<div class="wpa-ld" />')
50
  img.parent('.wpa-ld').addClass(classes);
51
+ img.parent('.wpa-ld').append('<button aria-expanded="false" class="wpa-toggle">' + wparest.text + '</button>');
52
+ img.parent('.wpa-ld').append('<div class="longdesc"></div>');
53
  var container = img.parent('.wpa-ld').children('.longdesc');
54
  container.hide();
55
+ container.load( longdesc + ' #desc_' + image_id, {limit:25},
56
+ function( responseText, textStatus, xhr ) {
57
+ if ( 'error' === textStatus ) {
58
+ container.html( rawdesc );
59
+ }
60
+ }
61
+ );
62
  img.parent('.wpa-ld').children('button').on( 'click', function(e) {
63
  e.preventDefault();
64
  var visible = container.is( ':visible' );
73
  }
74
 
75
  function wpa_load_image( img ) {
76
+ var classes = img.attr( 'class' );
77
+ if ( '' === classes ) {
78
+ classes = img.parent( '.wpa-alt' ).attr( 'class' ).replace( 'wpa-alt ', '' );
79
+ }
80
+ var id = classes.replace( 'wp-image-', '' );
81
  var api = wparest.url + '/' + id;
82
 
83
  $.get( api )
91
  var url = new URL( response.link );
92
  url.searchParams.set( 'longdesc', id );
93
  url.toString();
94
+ wpa_draw_longdesc( img, id, url, rawdesc );
95
  }
96
  })
97
  .fail( function() {
js/wp-accessibility.js CHANGED
@@ -1,52 +1,287 @@
1
  (function( $ ) { 'use strict';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  if ( wpa.skiplinks.enabled ) {
4
  $('body').prepend( wpa.skiplinks.output );
 
 
 
5
  }
6
 
7
- var html = document.querySelector( 'html' );
8
- var lang = html.getAttribute( 'lang' );
9
- if ( ! lang ) {
10
- $('html').attr( 'lang', wpa.lang );
 
 
 
11
  }
12
- var dir = html.getAttribute( 'dir' );
13
- if ( ! dir ) {
14
- $('html').attr( 'dir', wpa.dir );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  }
16
 
17
- var viewport = document.querySelector( 'meta[name="viewport"]' );
18
- if ( viewport ) {
19
- var conditions = viewport.getAttribute( 'content' );
20
- if ( conditions.search(/user-scalable=no/g) ) {
21
- conditions = conditions.replace( 'user-scalable=no', 'user-scalable=yes' );
22
- viewport.setAttribute( 'content', conditions );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  }
24
  }
25
 
26
  if ( wpa.target ) {
27
- $('a:not(.wpa-allow-target)').removeAttr( 'target' );
 
 
 
 
 
 
 
 
 
 
 
28
  }
29
 
30
  if ( wpa.tabindex ) {
31
  // Remove tabindex from elements that should be natively focusable.
32
- var focusable = $('input,a,select,textarea,button').not('a:not([href])');
33
- focusable.removeAttr('tabindex');
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  // Add tabindex to elements that appear active but are not natively focusable.
36
  var fakeButtons = $('div[role="button"]').not('div[tabindex]' );
37
  var buttonLinks = $('a[role="button"]').not('a[tabindex],a[href]');
38
  fakeButtons.attr( 'tabindex', '0' ).addClass('wpa-focusable');
 
 
 
39
  buttonLinks.attr( 'tabindex', '0' ).addClass('wpa-focusable');
 
 
 
40
  }
41
 
42
  if ( wpa.underline.enabled ) {
43
- $( wpa.underline.target ).not( 'nav ' + wpa.underline.target ).css( 'text-decoration','underline' );
44
- $( wpa.underline.target ).on( 'focusin mouseenter', function() {
45
- $(this).css( 'text-decoration','none' );
 
 
 
 
 
 
46
  });
47
- $( wpa.underline.target ).on( 'focusout mouseleave', function() {
48
- $(this).css( 'text-decoration','underline' );
 
49
  });
50
- }
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  }(jQuery));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  (function( $ ) { 'use strict';
2
+ var html = document.querySelector( 'html' );
3
+ if ( wpa.lang ) {
4
+ var lang = html.getAttribute( 'lang' );
5
+ if ( ! lang ) {
6
+ $('html').attr( 'lang', wpa.lang );
7
+ if ( wpa.errors ) {
8
+ console.log( 'HTML language set by WP Accessibility' );
9
+ }
10
+ }
11
+ }
12
+
13
+ if ( wpa.dir ) {
14
+ var dir = html.getAttribute( 'dir' );
15
+ if ( ! dir ) {
16
+ $('html').attr( 'dir', wpa.dir );
17
+ if ( wpa.errors ) {
18
+ console.log( 'HTML language direction set by WP Accessibility' );
19
+ }
20
+ }
21
+ }
22
+
23
+ var viewport = document.querySelector( 'meta[name="viewport"]' );
24
+ if ( viewport ) {
25
+ var conditionsBefore = viewport.getAttribute( 'content' );
26
+ var conditionsAfter = viewport.getAttribute( 'content' );
27
+ if ( conditionsBefore.search(/user-scalable=no/g) ) {
28
+ conditionsAfter = conditionsBefore.replace( 'user-scalable=no', 'user-scalable=yes' );
29
+ viewport.setAttribute( 'content', conditionsAfter );
30
+ if ( wpa.errors && conditionsAfter != conditionsBefore ) {
31
+ console.log( 'Viewport made scalable by WP Accessibility' );
32
+ }
33
+ }
34
+ if ( conditionsBefore.search(/maximum-scale=1/g) ) {
35
+ conditionsAfter = conditionsBefore.replace( 'maximum-scale=1', 'maximum-scale=5' );
36
+ conditionsAfter = conditionsAfter.replace( 'maximum-scale=0', 'maximum-scale=5' );
37
+ viewport.setAttribute( 'content', conditionsAfter );
38
+ if ( wpa.errors && conditionsAfter != conditionsBefore ) {
39
+ console.log( 'Viewport maximum scale set by WP Accessibility' );
40
+ }
41
+ }
42
+ }
43
 
44
  if ( wpa.skiplinks.enabled ) {
45
  $('body').prepend( wpa.skiplinks.output );
46
+ if ( wpa.errors ) {
47
+ console.log( 'Skip links added by WP Accessibility' );
48
+ }
49
  }
50
 
51
+ if ( wpa.current ) {
52
+ $(function() {
53
+ $( '.current-menu-item a, .current_page_item a' ).attr( 'aria-current', 'page' );
54
+ });
55
+ if ( wpa.errors ) {
56
+ console.log( 'ARIA current added by WP Accessibility' );
57
+ }
58
  }
59
+
60
+ if ( wpa.labels ) {
61
+ var wpa_names = [ 's', 'author', 'email', 'url', 'comment' ];
62
+ $.each( wpa_names, function( index, value ) {
63
+ if ( value == 'comment' ) {
64
+ var field = $( 'textarea[name=' + value + ']' );
65
+ } else {
66
+ var field = $( 'input[name=' + value + ']' ).not( '#adminbar-search' );
67
+ }
68
+ if ( 0 !== field.length ) {
69
+ var field_id = field.attr( 'id' );
70
+ var implicit = $( field ).parent( 'label' );
71
+ var aria = $( field ).attr( 'aria-label' );
72
+ var ariaId = $( field ).attr( 'aria-labelledby' );
73
+ var ariaTarget = {};
74
+ if ( ariaId ) {
75
+ ariaTarget = $( '#' + ariaId );
76
+ }
77
+ var hasAria = ( '' == aria || 'undefined' == typeof( aria ) ) ? false : true;
78
+ var hasAriaId = ( '' == ariaId || 'undefined' == typeof( ariaId ) ) ? false : true;
79
+ // Add label if aria label empty, aria labelledby empty, or aria reference ID does not exist.
80
+ if ( ( ! hasAria && ! hasAriaId ) || ( ! hasAria && ( hasAriaId && 0 === ariaTarget.length ) ) ) {
81
+ if ( field_id ) {
82
+ var label = $( 'label[for=' + field_id + ']' );
83
+ if ( !label.length && !implicit.length ) {
84
+ field.before( "<label for='" + field_id + "' class='wpa-screen-reader-text'>" + wpa.wpalabels[value] + "</label>" );
85
+ if ( wpa.errors ) {
86
+ console.log( 'Explicit label on ' + wpa.wpalabels[value] + 'added by WP Accessibility' );
87
+ }
88
+ }
89
+ } else {
90
+ if ( !implicit.length ) {
91
+ field.attr( 'id', 'wpa_label_' + value ).before( "<label for='wpa_label_" + value + "' class='wpa-screen-reader-text'>" + wpa.wpalabels[value] + "</label>" );
92
+ if ( wpa.errors ) {
93
+ console.log( 'Implicit label on ' + wpa.wpalabels[value] + 'added by WP Accessibility' );
94
+ }
95
+ }
96
+ }
97
+ }
98
+ }
99
+ });
100
  }
101
 
102
+
103
+ if ( wpa.titles ) {
104
+ var images = 0;
105
+ var controls = 0;
106
+ var fields = 0;
107
+ const els = document.querySelectorAll( 'img, a, input, textarea, select, button' );
108
+ els.forEach((el) => {
109
+ var title = el.getAttribute( 'title' );
110
+ if ( title && '' !== title ) {
111
+ switch ( el.tagName ) {
112
+ case 'IMG':
113
+ // If image has alt, remove title. If not, set title as alt.
114
+ var alt = el.getAttribute( 'alt' );
115
+ if ( ! alt || '' === alt ) {
116
+ el.setAttribute( 'alt', title );
117
+ el.removeAttribute( 'title' );
118
+ } else {
119
+ el.removeAttribute( 'title' );
120
+ }
121
+ images++;
122
+ break;
123
+ case 'A':
124
+ case 'BUTTON':
125
+ // If link or button has contained text or an img with alt, remove title. Otherwise, set title as aria-label unless element already has aria-label.
126
+ var linkText = wpaElementText(el);
127
+ if ( ! linkText || '' === linkText ) {
128
+ var ariaLabel = el.getAttribute( 'aria-label' );
129
+ if ( ! ariaLabel || '' === ariaLabel ) {
130
+ el.setAttribute( 'aria-label', title );
131
+ el.removeAttribute( 'title' );
132
+ }
133
+ } else {
134
+ el.removeAttribute( 'title' );
135
+ }
136
+ controls++;
137
+ break;
138
+ case 'INPUT':
139
+ case 'SELECT':
140
+ case 'TEXTAREA':
141
+ // If input field has an aria-label, aria-labelledby, associated label, or wrapping label, remove title. Else, add title as aria-label.
142
+ var ariaLabel = el.getAttribute( 'aria-label' );
143
+ var ariaLabelled = el.getAttribute( 'aria-labelledby' );
144
+ var ariaLabeller = ( ariaLabelled ) ? document.getElementById( ariaLabelled ) : false;
145
+ var labelId = el.getAttribute( 'id' );
146
+ var label = ( labelId ) ? document.querySelector( 'label[for="' + labelId + '"]' ) : false;
147
+ var parentLabel = el.closest( 'label' );
148
+ var hasAriaLabel = ( ariaLabel && '' !== ariaLabel ) ? true : false;
149
+ var hasRealLabel = ( label && '' !== wpaElementText( label ) ) ? true : false;
150
+ var hasImplicitLabel = ( parentLabel && '' !== wpaElementText( parentLabel ) ) ? true : false;
151
+ var hasAriaLabelled = ( ariaLabeller && '' !== wpaElementText( arialabeller ) ) ? true : false;
152
+ if ( hasAriaLabel || hasRealLabel || hasImplicitLabel || hasAriaLabelled ) {
153
+ // This has a label.
154
+ el.removeAttribute( 'title' );
155
+ } else {
156
+ el.setAttribute( 'aria-label', title );
157
+ el.removeAttribute( 'title' );
158
+ }
159
+ fields++;
160
+ break;
161
+ }
162
+ }
163
+ });
164
+ if ( wpa.errors ) {
165
+ if ( images > 0 ) {
166
+ console.log( images + ' title attributes removed from images by WP Accessibility' );
167
+ }
168
+ if ( controls > 0 ) {
169
+ console.log( controls + ' title attributes removed from links and buttons by WP Accessibility' );
170
+ }
171
+ if ( fields > 0 ) {
172
+ console.log( fields + ' title attributes removed from input fields by WP Accessibility' );
173
+ }
174
  }
175
  }
176
 
177
  if ( wpa.target ) {
178
+ var targeted = $('a:not(.wpa-allow-target)');
179
+ var targetRemoved = 0;
180
+ targeted.each( function() {
181
+ var target = $( this ).attr( 'target' );
182
+ if ( target ) {
183
+ $( this ).removeAttr( 'target' );
184
+ targetRemoved++;
185
+ }
186
+ });
187
+ if ( targetRemoved > 0 && wpa.errors ) {
188
+ console.log( targetRemoved + ' target attributes removed from links by WP Accessibility' );
189
+ }
190
  }
191
 
192
  if ( wpa.tabindex ) {
193
  // Remove tabindex from elements that should be natively focusable.
194
+ var focusable = $('input,a,select,textarea,button').not('a:not([href])');
195
+ var tabRemoved = 0;
196
+ focusable.each( function() {
197
+ var tabindex = $( this ).attr( 'tabindex' );
198
+ if ( tabindex ) {
199
+ $( this ).removeAttr('tabindex');
200
+ tabRemoved++;
201
+ }
202
+ });
203
+
204
+ if ( tabRemoved > 0 && wpa.errors ) {
205
+ console.log( tabRemoved + ' tabindex attributes removed from links, buttons and inputs by WP Accessibility' );
206
+ }
207
 
208
  // Add tabindex to elements that appear active but are not natively focusable.
209
  var fakeButtons = $('div[role="button"]').not('div[tabindex]' );
210
  var buttonLinks = $('a[role="button"]').not('a[tabindex],a[href]');
211
  fakeButtons.attr( 'tabindex', '0' ).addClass('wpa-focusable');
212
+ if ( fakeButtons.length > 0 && wpa.errors ) {
213
+ console.log( fakeButtons.length + ' tabindex attributes added to divs with the button role by WP Accessibility' );
214
+ }
215
  buttonLinks.attr( 'tabindex', '0' ).addClass('wpa-focusable');
216
+ if ( buttonLinks.length > 0 && wpa.errors ) {
217
+ console.log( buttonLinks.length + ' tabindex attributes added to anchor elements with the button role and no href value by WP Accessibility' );
218
+ }
219
  }
220
 
221
  if ( wpa.underline.enabled ) {
222
+ // Underline any link not inside a `nav` region. Using JS for this avoids problems with cascade precedence.
223
+ var originalOutline = $( wpa.underline.target ).css( 'outline-width' );
224
+ var originalOffset = $( wpa.underline.target ).css( 'outline-offset' );
225
+ var textColor = $( wpa.underline.target ).css( 'color' );
226
+ var originalColor = $( wpa.underline.target ).css( 'outline-color' );
227
+ $( wpa.underline.target ).not( 'nav ' + wpa.underline.target ).css( 'text-decoration', 'underline' );
228
+
229
+ $( wpa.underline.target ).on( 'mouseenter', function() {
230
+ $( this ).css( 'text-decoration', 'none' );
231
  });
232
+ $( wpa.underline.target ).on( 'mouseleave', function() {
233
+ // Reset visible appearance on exit.
234
+ $( this ).css( 'text-decoration', 'underline' );
235
  });
 
236
 
237
+ $( wpa.underline.target ).on( 'focusin', function() {
238
+ var newOutline = '2px';
239
+ if ( originalOutline == '2px' ) {
240
+ newOutline = '4px';
241
+ }
242
+ // Ensure there's a visible change of appearance on hover or focus.
243
+ $(this).css( 'outline-width', newOutline );
244
+ $(this).css( 'outline-color', textColor );
245
+ $(this).css( 'outline-offset', '2px' );
246
+ });
247
+ $( wpa.underline.target ).on( 'focusout', function() {
248
+ // Reset visible appearance on exit.
249
+ $(this).css( 'outline-width', originalOutline );
250
+ $(this).css( 'outline-color', originalColor );
251
+ $(this).css( 'outline-offset', originalOffset );
252
+ });
253
+ }
254
  }(jQuery));
255
+
256
+ /**
257
+ * Check whether an element contains text, including inspecting contained content for image alt attributes or aria-label attributes.
258
+ *
259
+ *
260
+ * @arg el DOM element to check.
261
+ *
262
+ * Based on work by Roger Johansson https://www.456bereastreet.com/archive/201105/get_element_text_including_alt_text_for_images_with_javascript/
263
+ */
264
+ function wpaElementText(el) {
265
+ var text = '';
266
+ // Text node (3) or CDATA node (4) - return its text
267
+ if ( (el.nodeType === 3) || (el.nodeType === 4) ) {
268
+ text = el.nodeValue;
269
+ // If node is an element (1) and an img, input[type=image], or area element, return its alt text
270
+ } else if ( (el.nodeType === 1) && (
271
+ (el.tagName.toLowerCase() == 'img') ||
272
+ (el.tagName.toLowerCase() == 'area') ||
273
+ ((el.tagName.toLowerCase() == 'input') && el.getAttribute('type') && (el.getAttribute('type').toLowerCase() == 'image'))
274
+ ) ) {
275
+ text = el.getAttribute('alt') || '';
276
+ // Traverse children unless this is a script or style element
277
+ } else if ( (el.nodeType === 1) && !el.tagName.match(/^(script|style)$/i) ) {
278
+ var children = el.childNodes;
279
+ for (var i = 0, l = children.length; i < l; i++) {
280
+ // If an element has an aria-label, that will override any other contained text.
281
+ var ariaLabel = el.getAttribute( 'aria-label' );
282
+ text += ( ariaLabel ) ? ariaLabel : wpaElementText( children[i] ) + ' ';
283
+ }
284
+ }
285
+
286
+ return text;
287
+ };
js/wpa-toolbar.js CHANGED
@@ -3,20 +3,20 @@
3
  var insert_a11y_toolbar = '';
4
 
5
  insert_a11y_toolbar += '<ul class="a11y-toolbar-list">';
6
- if ( wpa.enable_contrast == 'true' ) {
7
- insert_a11y_toolbar += '<li class="a11y-toolbar-list-item"><button type="button" class="a11y-toggle a11y-toggle-contrast toggle-contrast" id="is_normal_contrast" aria-pressed="false"><span class=\"offscreen\">' + wpa.contrast + '</span><span class="aticon aticon-adjust" aria-hidden="true"></span></button></li>';
8
  }
9
- if ( wpa.enable_grayscale == 'true' ) {
10
- insert_a11y_toolbar += '<li class="a11y-toolbar-list-item"><button type="button" class="a11y-toggle a11y-toggle-grayscale toggle-grayscale" id="is_normal_color" aria-pressed="false"><span class="offscreen">' + wpa.grayscale + '</span><span class="aticon aticon-tint" aria-hidden="true"></span></button></li>';
11
  }
12
- if ( wpa.enable_fontsize == 'true' ) {
13
- insert_a11y_toolbar += '<li class="a11y-toolbar-list-item"><button type="button" class="a11y-toggle a11y-toggle-fontsize toggle-fontsize" id="is_normal_fontsize" aria-pressed="false"><span class="offscreen">' + wpa.fontsize + '</span><span class="aticon aticon-font" aria-hidden="true"></span></button></li>';
14
  }
15
  insert_a11y_toolbar += '</ul>';
16
- a11y_toolbar.classList.add( wpa.responsive, 'a11y-toolbar', wpa.is_rtl, wpa.is_right );
17
  a11y_toolbar.innerHTML = insert_a11y_toolbar;
18
 
19
- var insertionPoint = document.querySelector( wpa.location );
20
  if ( null !== insertionPoint ) {
21
  insertionPoint.insertAdjacentElement( 'afterbegin', a11y_toolbar );
22
  } else {
3
  var insert_a11y_toolbar = '';
4
 
5
  insert_a11y_toolbar += '<ul class="a11y-toolbar-list">';
6
+ if ( wpatb.enable_contrast == 'true' ) {
7
+ insert_a11y_toolbar += '<li class="a11y-toolbar-list-item"><button type="button" class="a11y-toggle a11y-toggle-contrast toggle-contrast" id="is_normal_contrast" aria-pressed="false"><span class=\"offscreen\">' + wpatb.contrast + '</span><span class="aticon aticon-adjust" aria-hidden="true"></span></button></li>';
8
  }
9
+ if ( wpatb.enable_grayscale == 'true' ) {
10
+ insert_a11y_toolbar += '<li class="a11y-toolbar-list-item"><button type="button" class="a11y-toggle a11y-toggle-grayscale toggle-grayscale" id="is_normal_color" aria-pressed="false"><span class="offscreen">' + wpatb.grayscale + '</span><span class="aticon aticon-tint" aria-hidden="true"></span></button></li>';
11
  }
12
+ if ( wpatb.enable_fontsize == 'true' ) {
13
+ insert_a11y_toolbar += '<li class="a11y-toolbar-list-item"><button type="button" class="a11y-toggle a11y-toggle-fontsize toggle-fontsize" id="is_normal_fontsize" aria-pressed="false"><span class="offscreen">' + wpatb.fontsize + '</span><span class="aticon aticon-font" aria-hidden="true"></span></button></li>';
14
  }
15
  insert_a11y_toolbar += '</ul>';
16
+ a11y_toolbar.classList.add( wpatb.responsive, 'a11y-toolbar', wpatb.is_rtl, wpatb.is_right );
17
  a11y_toolbar.innerHTML = insert_a11y_toolbar;
18
 
19
+ var insertionPoint = document.querySelector( wpatb.location );
20
  if ( null !== insertionPoint ) {
21
  insertionPoint.insertAdjacentElement( 'afterbegin', a11y_toolbar );
22
  } else {
js/wpa.labels.js DELETED
@@ -1,38 +0,0 @@
1
- (function( $ ) { 'use strict';
2
- var wpa_names = [ 's', 'author', 'email', 'url', 'comment' ];
3
- $.each( wpa_names, function( index, value ) {
4
- if ( value == 'comment' ) {
5
- var field = $( 'textarea[name=' + value + ']' );
6
- } else {
7
- var field = $( 'input[name=' + value + ']' ).not( '#adminbar-search' );
8
- }
9
- if ( 0 !== field.length ) {
10
- var form_id = field.attr( 'id' );
11
- var implicit = $( field ).parent( 'label' );
12
- var aria = $( field ).attr( 'aria-label' );
13
- var ariaId = $( field ).attr( 'aria-labelledby' );
14
- var ariaTarget = {};
15
- if ( ariaId ) {
16
- ariaTarget = $( '#' + ariaId );
17
- }
18
- var hasAria = ( '' == aria || 'undefined' == typeof( aria ) ) ? false : true;
19
- var hasAriaId = ( '' == ariaId || 'undefined' == typeof( ariaId ) ) ? false : true;
20
- // Add label if aria label empty, aria labelledby empty, or aria reference ID does not exist.
21
- if ( ( ! hasAria && ! hasAriaId ) || ( ! hasAria && ( hasAriaId && 0 === ariaTarget.length ) ) ) {
22
- if ( hasAriaId && 0 === ariaTarget.length ) {
23
- console.log( 'aria-labelledby target ID does not exist: ', ariaId );
24
- }
25
- if ( form_id ) {
26
- var label = $( 'label[for=' + form_id + ']' );
27
- if ( !label.length && !implicit.length ) {
28
- field.before( "<label for='" + form_id + "' class='wpa-screen-reader-text'>" + wpalabels[value] + "</label>" );
29
- }
30
- } else {
31
- if ( !implicit.length ) {
32
- field.attr( 'id', 'wpa_label_' + value ).before( "<label for='wpa_label_" + value + "' class='wpa-screen-reader-text'>" + wpalabels[value] + "</label>" );
33
- }
34
- }
35
- }
36
- }
37
- });
38
- }(jQuery));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -4,8 +4,8 @@ Donate link: http://www.joedolson.com/donate/
4
  Tags: title, accessibility, accessible, navigation, wcag, a11y, section508, focus, alt text, labels, aria
5
  Requires at least: 3.4.2
6
  Requires PHP: 5.6
7
- Tested up to: 6.0
8
- Stable tag: 1.9.2
9
  Text Domain: wp-accessibility
10
  License: GPLv2 or later
11
 
@@ -55,7 +55,7 @@ These are tools provided to help you identify issues you may need to fix.
55
  * Enable diagnostic CSS to show CSS-detectable problems in visual editor or on front-end of site.
56
  * Search your media library on content in alt text fields.
57
 
58
- Learn more! <a href="http://make.wordpress.org/accessibility/wp-accessibility-plugin/">Read about the accessibility issues corrected</a> by WP Accessibility!
59
 
60
  The plug-in is intended to help with deficiencies commonly found in themes and to solve some issues in WordPress core. It can't correct every problem (by a long shot), but provides tools to fix some issues, supplement the accessibility of your site, or identify problems.
61
 
@@ -76,6 +76,22 @@ The plug-in is intended to help with deficiencies commonly found in themes and t
76
 
77
  [Suggest a change!](https://github.com/joedolson/wp-accessibility/issues/)
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  = 1.9.2 =
80
 
81
  * Bug fix: Alignment classes should only apply when wpa-ld class present.
4
  Tags: title, accessibility, accessible, navigation, wcag, a11y, section508, focus, alt text, labels, aria
5
  Requires at least: 3.4.2
6
  Requires PHP: 5.6
7
+ Tested up to: 6.1
8
+ Stable tag: 2.0.0
9
  Text Domain: wp-accessibility
10
  License: GPLv2 or later
11
 
55
  * Enable diagnostic CSS to show CSS-detectable problems in visual editor or on front-end of site.
56
  * Search your media library on content in alt text fields.
57
 
58
+ Learn more! <a href="https://docs.joedolson.com/wp-accessibility/">Read about the accessibility issues corrected</a> by WP Accessibility!
59
 
60
  The plug-in is intended to help with deficiencies commonly found in themes and to solve some issues in WordPress core. It can't correct every problem (by a long shot), but provides tools to fix some issues, supplement the accessibility of your site, or identify problems.
61
 
76
 
77
  [Suggest a change!](https://github.com/joedolson/wp-accessibility/issues/)
78
 
79
+ = 2.0.0 =
80
+
81
+ * New feature: Show alt attributes toggle on content images.
82
+ * New feature: Ensure users can adjust scale even if maximum-scale set to 1.0.
83
+ * New feature: Alt enforcement indicators now present in block editor.
84
+ * New feature: Flag missing captions or subtitles in uploaded videos in editor.
85
+ * Updated feature: [Remove title attributes](https://docs.joedolson.com/wp-accessibility/2022/10/29/remove-title-attributes/) now more intelligent.
86
+ * Updated feature: Modernized alt attribute enforcement tools.
87
+ * Change: Combine remediation scripting in wp-accessibility.js.
88
+ * Change: Disable accessibility-ready duplicating features if theme changed to accessibility-ready.
89
+ * Bug fix: aria-expanded missing in some cases for longdesc disclosures.
90
+ * Bug fix: Main JS file did not have a version number.
91
+ * Bug fix: Run feature JS after running remediation JS.
92
+ * Bug fix: Fix DOM ordering with image disclosure buttons.
93
+ * Retired language directory call. Translation files haven't been updated since version Oct 2014.
94
+
95
  = 1.9.2 =
96
 
97
  * Bug fix: Alignment classes should only apply when wpa-ld class present.
uninstall.php CHANGED
@@ -40,6 +40,7 @@ if ( ! defined( 'ABSPATH' ) && ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
40
  delete_option( 'wpa_toolbar' );
41
  delete_option( 'wpa_diagnostics' );
42
  delete_option( 'wpa_longdesc' );
 
43
  delete_option( 'wpa_underline' );
44
  delete_option( 'wpa_insert_roles' );
45
  delete_option( 'wpa_focus' );
40
  delete_option( 'wpa_toolbar' );
41
  delete_option( 'wpa_diagnostics' );
42
  delete_option( 'wpa_longdesc' );
43
+ delete_option( 'wpa_show_alt' );
44
  delete_option( 'wpa_underline' );
45
  delete_option( 'wpa_insert_roles' );
46
  delete_option( 'wpa_focus' );
wp-accessibility-alt.php CHANGED
@@ -224,7 +224,7 @@ function wpa_alt_attribute( $html, $id, $caption, $title, $align, $url, $size, $
224
  if ( true === $noalt ) {
225
  $html = str_replace( 'alt="' . $alt . '"', 'alt=""', $html );
226
  }
227
- if ( ( '' === $alt || $alt === $title ) && true !== $noalt ) {
228
  if ( $alt === $title ) {
229
  $warning = __( 'The alt text for this image is the same as the title. In most cases, that means that the alt attribute has been automatically provided from the image file name.', 'wp-accessibility' );
230
  $image = 'alt-same.png';
@@ -234,8 +234,9 @@ function wpa_alt_attribute( $html, $id, $caption, $title, $align, $url, $size, $
234
  }
235
  }
236
  if ( $warning ) {
237
- return $html . "<img class='wpa-image-missing-alt size-" . esc_attr( $size ) . ' ' . esc_attr( $align ) . "' src='" . plugins_url( "imgs/$image", __FILE__ ) . "' alt='" . esc_attr( $warning ) . "' />";
238
  }
 
239
  return $html;
240
  }
241
 
@@ -244,5 +245,14 @@ add_action( 'init', 'wpa_add_editor_styles' );
244
  * Enqueue custom editor styles for WP Accessibility. Used in display of img replacements.
245
  */
246
  function wpa_add_editor_styles() {
247
- add_editor_style( plugins_url( 'css/editor-style.css', __FILE__ ) );
 
 
 
 
 
 
 
 
 
248
  }
224
  if ( true === $noalt ) {
225
  $html = str_replace( 'alt="' . $alt . '"', 'alt=""', $html );
226
  }
227
+ if ( ( '' === $alt || $alt === $title || wpa_suspicious_alt( $alt ) ) && true !== $noalt ) {
228
  if ( $alt === $title ) {
229
  $warning = __( 'The alt text for this image is the same as the title. In most cases, that means that the alt attribute has been automatically provided from the image file name.', 'wp-accessibility' );
230
  $image = 'alt-same.png';
234
  }
235
  }
236
  if ( $warning ) {
237
+ return '<div class="wp-block-image">' . $html . '</div>';
238
  }
239
+
240
  return $html;
241
  }
242
 
245
  * Enqueue custom editor styles for WP Accessibility. Used in display of img replacements.
246
  */
247
  function wpa_add_editor_styles() {
248
+ $wpa_version = ( SCRIPT_DEBUG ) ? rand( 10000, 100000 ) : wpa_check_version();
249
+ add_editor_style( plugins_url( 'css/editor-style.css', __FILE__ ), false, $wpa_version );
250
+ }
251
+
252
+ add_action( 'enqueue_block_editor_assets', 'wpa_block_editor_assets' );
253
+ /**
254
+ * Enqueue custom block editor styles for WP Accessibility. Used in display of img replacements.
255
+ */
256
+ function wpa_block_editor_assets() {
257
+ wp_enqueue_style( 'wpa-block-styles', plugins_url( 'css/editor-style.css', __FILE__ ), false, wpa_check_version() );
258
  }
wp-accessibility-settings.php CHANGED
@@ -74,9 +74,11 @@ function wpa_update_settings() {
74
  }
75
 
76
  if ( isset( $_POST['action'] ) && 'features' === $_POST['action'] ) {
 
77
  $wpa_longdesc = ( isset( $_POST['wpa_longdesc'] ) ) ? sanitize_text_field( $_POST['wpa_longdesc'] ) : 'false';
78
  $wpa_longdesc_featured = ( isset( $_POST['wpa_longdesc_featured'] ) ) ? sanitize_text_field( $_POST['wpa_longdesc_featured'] ) : 'false';
79
  $wpa_post_types = ( isset( $_POST['wpa_post_types'] ) ) ? map_deep( $_POST['wpa_post_types'], 'sanitize_text_field' ) : array();
 
80
  update_option( 'wpa_longdesc', $wpa_longdesc );
81
  update_option( 'wpa_longdesc_featured', $wpa_longdesc_featured );
82
  update_option( 'wpa_post_types', $wpa_post_types );
@@ -109,7 +111,6 @@ function wpa_update_settings() {
109
  $wpa_focus = ( isset( $_POST['wpa_focus'] ) ) ? 'on' : '';
110
  $wpa_focus_color = ( isset( $_POST['wpa_focus_color'] ) ) ? str_replace( '#', '', $_POST['wpa_focus_color'] ) : '';
111
  $wpa_continue = ( isset( $_POST['wpa_continue'] ) ) ? sanitize_text_field( $_POST['wpa_continue'] ) : __( 'Continue Reading', 'wp-accessibility' );
112
- $wpa_insert_roles = ( isset( $_POST['wpa_insert_roles'] ) ) ? 'on' : '';
113
  $wpa_complementary_container = ( isset( $_POST['wpa_complementary_container'] ) ) ? str_replace( '#', '', sanitize_text_field( $_POST['wpa_complementary_container'] ) ) : '';
114
  update_option( 'wpa_lang', $wpa_lang );
115
  update_option( 'wpa_target', $wpa_target );
@@ -122,7 +123,6 @@ function wpa_update_settings() {
122
  update_option( 'wpa_focus', $wpa_focus );
123
  update_option( 'wpa_focus_color', $wpa_focus_color );
124
  update_option( 'wpa_continue', $wpa_continue );
125
- update_option( 'wpa_insert_roles', $wpa_insert_roles );
126
  $message = __( 'Miscellaneous Accessibility Settings Updated', 'wp-accessibility' );
127
 
128
  return "<div class='updated'><p>" . $message . '</p></div>';
@@ -376,7 +376,7 @@ function wpa_admin_settings() {
376
  <?php
377
  } else {
378
  ?>
379
- <li><?php _e( '<strong>Four disabled features:</strong> Site language, continue reading text, landmark roles and standard form labels are defined in your <code>accessibility-ready</code> theme.', 'wp-accessibility' ); ?></li>
380
  <?php
381
  }
382
  ?>
@@ -398,7 +398,7 @@ function wpa_admin_settings() {
398
  </li>
399
  <li>
400
  <input type="checkbox" id="wpa_image_titles" name="wpa_image_titles" <?php checked( get_option( 'wpa_image_titles' ), 'on' ); ?>/>
401
- <label for="wpa_image_titles"><?php _e( 'Remove title attributes inserted into post content and featured images.', 'wp-accessibility' ); ?></label>
402
  </li>
403
  <li>
404
  <input type="checkbox" id="wpa_focus" name="wpa_focus" <?php checked( get_option( 'wpa_focus' ), 'on' ); ?>/>
@@ -437,6 +437,10 @@ function wpa_admin_settings() {
437
  <input type="checkbox" id="wpa_longdesc_featured" name="wpa_longdesc_featured" <?php checked( get_option( 'wpa_longdesc_featured' ), 'on' ); ?>/>
438
  <label for="wpa_longdesc_featured"><?php _e( 'Support <code>longdesc</code> on featured images', 'wp-accessibility' ); ?></label>
439
  </li>
 
 
 
 
440
  <li>
441
  <fieldset>
442
  <legend><?php _e( 'Enable Content Summaries', 'wp-accessibility' ); ?></legend>
@@ -626,7 +630,7 @@ function wpa_admin_sidebar() {
626
  }
627
  }(document, "script", "twitter-wjs");</script>
628
  </p>
629
- <p><?php _e( "If you've found WP Accessibility useful, then please <a href='https://wordpress.org/plugins/wp-accessibility/'>rate it five stars</a>, <a href='https://www.joedolson.com/donate/'>make a donation</a>, or <a href='https://translate.wordpress.org/projects/wp-plugins/wp-accessibility'>help with translation</a>.", 'wp-accessibility' ); ?></p>
630
 
631
  <div>
632
  <p class="wpa-donate">
@@ -641,7 +645,7 @@ function wpa_admin_sidebar() {
641
 
642
  <div class="inside">
643
  <ul>
644
- <li><a href="http://make.wordpress.org/accessibility/wp-accessibility-plugin/">Plugin Documentation</a></li>
645
  <li><a href="http://make.wordpress.org/accessibility/">Make WordPress: Accessibility</a></li>
646
  <li><a href="https://make.wordpress.org/themes/handbook/review/accessibility/">WordPress Theme Accessibility Guidelines</a></li>
647
  <li><a href="https://www.joedolson.com/tools/color-contrast.php">Color Contrast Testing</a></li>
@@ -688,17 +692,6 @@ function wpa_admin_sidebar() {
688
  </div>
689
  <?php } ?>
690
 
691
- <div class="postbox">
692
- <h2 class='hndle'><?php _e( 'Contributing References', 'wp-accessibility' ); ?></h2>
693
- <div class="inside">
694
- <ul>
695
- <li><a href="http://www.accessibleculture.org/articles/2010/08/continue-reading-links-in-wordpress/">Continue Reading Links in WordPress</a></li>
696
- <li><a href="http://www.mothereffingtoolconfuser.com">Mother Effing Tool Confuser</a></li>
697
- <li><a href="https://wordpress.org/extend/plugins/remove-title-attributes/">Remove Title Attributes</a></li>
698
- <li><a href="https://wordpress.org/extend/plugins/img-title-removal/">IMG Title Removal</a></li>
699
- </ul>
700
- </div>
701
- </div>
702
  <div class="postbox" id="privacy">
703
  <h2 class='hndle'><?php _e( 'Privacy', 'wp-accessibility' ); ?></h2>
704
 
74
  }
75
 
76
  if ( isset( $_POST['action'] ) && 'features' === $_POST['action'] ) {
77
+ $wpa_show_alt = ( isset( $_POST['wpa_show_alt'] ) ) ? 'on' : 'off';
78
  $wpa_longdesc = ( isset( $_POST['wpa_longdesc'] ) ) ? sanitize_text_field( $_POST['wpa_longdesc'] ) : 'false';
79
  $wpa_longdesc_featured = ( isset( $_POST['wpa_longdesc_featured'] ) ) ? sanitize_text_field( $_POST['wpa_longdesc_featured'] ) : 'false';
80
  $wpa_post_types = ( isset( $_POST['wpa_post_types'] ) ) ? map_deep( $_POST['wpa_post_types'], 'sanitize_text_field' ) : array();
81
+ update_option( 'wpa_show_alt', $wpa_show_alt );
82
  update_option( 'wpa_longdesc', $wpa_longdesc );
83
  update_option( 'wpa_longdesc_featured', $wpa_longdesc_featured );
84
  update_option( 'wpa_post_types', $wpa_post_types );
111
  $wpa_focus = ( isset( $_POST['wpa_focus'] ) ) ? 'on' : '';
112
  $wpa_focus_color = ( isset( $_POST['wpa_focus_color'] ) ) ? str_replace( '#', '', $_POST['wpa_focus_color'] ) : '';
113
  $wpa_continue = ( isset( $_POST['wpa_continue'] ) ) ? sanitize_text_field( $_POST['wpa_continue'] ) : __( 'Continue Reading', 'wp-accessibility' );
 
114
  $wpa_complementary_container = ( isset( $_POST['wpa_complementary_container'] ) ) ? str_replace( '#', '', sanitize_text_field( $_POST['wpa_complementary_container'] ) ) : '';
115
  update_option( 'wpa_lang', $wpa_lang );
116
  update_option( 'wpa_target', $wpa_target );
123
  update_option( 'wpa_focus', $wpa_focus );
124
  update_option( 'wpa_focus_color', $wpa_focus_color );
125
  update_option( 'wpa_continue', $wpa_continue );
 
126
  $message = __( 'Miscellaneous Accessibility Settings Updated', 'wp-accessibility' );
127
 
128
  return "<div class='updated'><p>" . $message . '</p></div>';
376
  <?php
377
  } else {
378
  ?>
379
+ <li><?php _e( '<strong>Three disabled features:</strong> Site language, continue reading text and standard form labels are defined in your <code>accessibility-ready</code> theme.', 'wp-accessibility' ); ?></li>
380
  <?php
381
  }
382
  ?>
398
  </li>
399
  <li>
400
  <input type="checkbox" id="wpa_image_titles" name="wpa_image_titles" <?php checked( get_option( 'wpa_image_titles' ), 'on' ); ?>/>
401
+ <label for="wpa_image_titles"><?php _e( 'Remove title attributes from elements with preferred accessible names.', 'wp-accessibility' ); ?></label>
402
  </li>
403
  <li>
404
  <input type="checkbox" id="wpa_focus" name="wpa_focus" <?php checked( get_option( 'wpa_focus' ), 'on' ); ?>/>
437
  <input type="checkbox" id="wpa_longdesc_featured" name="wpa_longdesc_featured" <?php checked( get_option( 'wpa_longdesc_featured' ), 'on' ); ?>/>
438
  <label for="wpa_longdesc_featured"><?php _e( 'Support <code>longdesc</code> on featured images', 'wp-accessibility' ); ?></label>
439
  </li>
440
+ <li>
441
+ <input type="checkbox" id="wpa_show_alt" name="wpa_show_alt" <?php checked( get_option( 'wpa_show_alt' ), 'on' ); ?>/>
442
+ <label for="wpa_show_alt"><?php _e( 'Add toggle to view image <code>alt</code> text in comments and post content.', 'wp-accessibility' ); ?></label>
443
+ </li>
444
  <li>
445
  <fieldset>
446
  <legend><?php _e( 'Enable Content Summaries', 'wp-accessibility' ); ?></legend>
630
  }
631
  }(document, "script", "twitter-wjs");</script>
632
  </p>
633
+ <p><?php _e( "If you've found WP Accessibility useful, then please <a href='https://wordpress.org/plugins/wp-accessibility/'>rate it five stars</a>, <a href='https://github.com/sponsors/joedolson'>sponsor me on GitHub</a>, or <a href='https://translate.wordpress.org/projects/wp-plugins/wp-accessibility'>help with translation</a>.", 'wp-accessibility' ); ?></p>
634
 
635
  <div>
636
  <p class="wpa-donate">
645
 
646
  <div class="inside">
647
  <ul>
648
+ <li><a href="https://docs.joedolson.com/wp-accessibility/">Plugin Documentation</a></li>
649
  <li><a href="http://make.wordpress.org/accessibility/">Make WordPress: Accessibility</a></li>
650
  <li><a href="https://make.wordpress.org/themes/handbook/review/accessibility/">WordPress Theme Accessibility Guidelines</a></li>
651
  <li><a href="https://www.joedolson.com/tools/color-contrast.php">Color Contrast Testing</a></li>
692
  </div>
693
  <?php } ?>
694
 
 
 
 
 
 
 
 
 
 
 
 
695
  <div class="postbox" id="privacy">
696
  <h2 class='hndle'><?php _e( 'Privacy', 'wp-accessibility' ); ?></h2>
697
 
wp-accessibility-toolbar.php CHANGED
@@ -27,8 +27,9 @@ add_action( 'wp_enqueue_scripts', 'wpa_register_scripts' );
27
  * Register jQuery scripts.
28
  */
29
  function wpa_register_scripts() {
30
- wp_register_script( 'wpa-toolbar', plugins_url( 'wp-accessibility/js/wpa-toolbar.js' ), array(), '1.1', true );
31
- wp_register_script( 'ui-a11y', plugins_url( 'wp-accessibility/toolbar/js/a11y.js' ), array( 'jquery' ), '1.0', true );
 
32
  }
33
 
34
  add_action( 'wp_enqueue_scripts', 'wpa_toolbar_enqueue_scripts' );
@@ -36,12 +37,12 @@ add_action( 'wp_enqueue_scripts', 'wpa_toolbar_enqueue_scripts' );
36
  * Enqueue Toolbar scripts dependent on options.
37
  */
38
  function wpa_toolbar_enqueue_scripts() {
39
- $wpa_version = wpa_check_version();
40
  wp_enqueue_script( 'jquery' );
41
  if ( 'on' === get_option( 'wpa_toolbar' ) ) {
42
  // Enqueue Toolbar JS if enabled.
43
  wp_enqueue_script( 'wpa-toolbar' );
44
- wp_localize_script( 'wpa-toolbar', 'wpa', wpa_toolbar_js() );
45
  }
46
  wp_enqueue_script( 'ui-a11y' );
47
 
27
  * Register jQuery scripts.
28
  */
29
  function wpa_register_scripts() {
30
+ $wpa_version = ( SCRIPT_DEBUG ) ? rand( 10000, 100000 ) : wpa_check_version();
31
+ wp_register_script( 'wpa-toolbar', plugins_url( 'wp-accessibility/js/wpa-toolbar.js' ), array(), $wpa_version, true );
32
+ wp_register_script( 'ui-a11y', plugins_url( 'wp-accessibility/toolbar/js/a11y.js' ), array( 'jquery' ), $wpa_version, true );
33
  }
34
 
35
  add_action( 'wp_enqueue_scripts', 'wpa_toolbar_enqueue_scripts' );
37
  * Enqueue Toolbar scripts dependent on options.
38
  */
39
  function wpa_toolbar_enqueue_scripts() {
40
+ $wpa_version = ( SCRIPT_DEBUG ) ? rand( 10000, 100000 ) : wpa_check_version();
41
  wp_enqueue_script( 'jquery' );
42
  if ( 'on' === get_option( 'wpa_toolbar' ) ) {
43
  // Enqueue Toolbar JS if enabled.
44
  wp_enqueue_script( 'wpa-toolbar' );
45
+ wp_localize_script( 'wpa-toolbar', 'wpatb', wpa_toolbar_js() );
46
  }
47
  wp_enqueue_script( 'ui-a11y' );
48
 
wp-accessibility.php CHANGED
@@ -17,7 +17,7 @@
17
  * Domain Path: /lang
18
  * License: GPL-2.0+
19
  * License URI: http://www.gnu.org/license/gpl-2.0.txt
20
- * Version: 1.9.2
21
  */
22
 
23
  /*
@@ -54,7 +54,7 @@ add_action( 'plugins_loaded', 'wpa_load_textdomain' );
54
  * Load internationalization.
55
  */
56
  function wpa_load_textdomain() {
57
- load_plugin_textdomain( 'wp-accessibility', false, dirname( plugin_basename( __FILE__ ) ) . '/lang' );
58
  }
59
 
60
  add_action( 'admin_menu', 'wpa_admin_menu' );
@@ -70,7 +70,7 @@ function wpa_admin_menu() {
70
  * Install on activation.
71
  */
72
  function wpa_install() {
73
- $wpa_version = '1.9.2';
74
  if ( 'true' !== get_option( 'wpa_installed' ) ) {
75
  add_option( 'rta_from_tag_clouds', 'on' );
76
  add_option( 'asl_styles_focus', '' );
@@ -133,32 +133,12 @@ function wpa_plugin_action( $links, $file ) {
133
  return $links;
134
  }
135
 
136
- add_action( 'wp_enqueue_scripts', 'wpacc_enqueue_scripts' );
137
  /**
138
- * Enqueue accessibility scripts dependent on options.
139
  */
140
  function wpacc_enqueue_scripts() {
141
- $version = wpa_check_version();
142
- if ( 'on' === get_option( 'wpa_labels' ) ) {
143
- wp_enqueue_script( 'wpa-labels', plugins_url( 'js/wpa.labels.js', __FILE__ ), array( 'jquery' ), $version, true );
144
- $labels = array(
145
- 's' => __( 'Search', 'wp-accessibility' ),
146
- 'author' => __( 'Name', 'wp-accessibility' ),
147
- 'email' => __( 'Email', 'wp-accessibility' ),
148
- 'url' => __( 'Website', 'wp-accessibility' ),
149
- 'comment' => __( 'Comment', 'wp-accessibility' ),
150
- );
151
- /**
152
- * Customize labels passed to automatically label core WordPress fields.
153
- *
154
- * @hook wpa_labels
155
- * @param {array} $labels Array of labels for search and comment fields.
156
- *
157
- * @return {array}
158
- */
159
- $labels = apply_filters( 'wpa_labels', $labels );
160
- wp_localize_script( 'wpa-labels', 'wpalabels', $labels );
161
- }
162
  if ( 'link' === get_option( 'wpa_longdesc' ) ) {
163
  wp_enqueue_script( 'longdesc.link', plugins_url( 'js/longdesc.link.js', __FILE__ ), array( 'jquery' ), $version, true );
164
  wp_localize_script(
@@ -169,6 +149,28 @@ function wpacc_enqueue_scripts() {
169
  )
170
  );
171
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  if ( 'jquery' === get_option( 'wpa_longdesc' ) ) {
173
  wp_enqueue_script( 'longdesc.button', plugins_url( 'js/longdesc.button.js', __FILE__ ), array( 'jquery' ), $version, true );
174
  wp_localize_script(
@@ -180,10 +182,6 @@ function wpacc_enqueue_scripts() {
180
  )
181
  );
182
  }
183
- // aria-current was added in 5.3; don't enqueue this script on newer versions.
184
- if ( version_compare( $GLOBALS['wp_version'], '5.3', '<' ) ) {
185
- wp_enqueue_script( 'current.menu', plugins_url( 'js/current-menu-item.js', __FILE__ ), array( 'jquery' ), $version, true );
186
- }
187
  }
188
 
189
  add_action( 'wp_enqueue_scripts', 'wpa_stylesheet' );
@@ -191,7 +189,7 @@ add_action( 'wp_enqueue_scripts', 'wpa_stylesheet' );
191
  * Enqueue stylesheets for WP Accessibility.
192
  */
193
  function wpa_stylesheet() {
194
- $version = wpa_check_version();
195
  wp_register_style( 'wpa-style', plugins_url( 'css/wpa-style.css', __FILE__ ), array(), $version );
196
  if ( 'link' === get_option( 'wpa_longdesc' ) || 'jquery' === get_option( 'wpa_longdesc' ) || 'on' === get_option( 'asl_enable' ) || ! empty( get_option( 'wpa_post_types', array() ) ) ) {
197
  wp_enqueue_style( 'wpa-style' );
@@ -200,7 +198,7 @@ function wpa_stylesheet() {
200
  if ( is_admin_bar_showing() ) {
201
  $top = '37px';
202
  }
203
- $add_css = wpa_css();
204
  $custom_css = ':root { --admin-bar-top : ' . $top . '; }';
205
  wp_add_inline_style( 'wpa-style', wp_filter_nohtml_kses( stripcslashes( $add_css . $custom_css ) ) );
206
  }
@@ -323,6 +321,16 @@ $class#skiplinks a:active, $vis $class#skiplinks a:focus {
323
  $focus
324
  }
325
  ";
 
 
 
 
 
 
 
 
 
 
326
 
327
  return $styles;
328
  }
@@ -341,6 +349,7 @@ function wpa_css() {
341
  :focus { outline: 2px solid$color!important; outline-offset: 2px !important; }
342
  ";
343
  }
 
344
  return $styles;
345
  }
346
 
@@ -360,9 +369,10 @@ add_action( 'wp_enqueue_scripts', 'wpa_jquery_asl', 100 );
360
  * Enqueue JS needed for WP Accessibility options.
361
  */
362
  function wpa_jquery_asl() {
 
363
  $visibility = ( 'on' === get_option( 'asl_visible' ) ) ? 'wpa-visible' : 'wpa-hide';
364
  $output = '';
365
- if ( 'on' === get_option( 'asl_enable' ) ) {
366
  $html = '';
367
  /**
368
  * Customize the default value for extra skiplink. Turns on extra skiplink options in WP Accessibility versions > 1.9.0.
@@ -400,7 +410,26 @@ function wpa_jquery_asl() {
400
  $output = ( '' !== $html ) ? "<div class=\"$visibility$is_rtl\" id=\"skiplinks\" role=\"navigation\" aria-label=\"" . esc_attr( $skiplinks ) . "\">$html</div>" : '';
401
  }
402
 
403
- wp_enqueue_script( 'wp-accessibility', plugins_url( 'js/wp-accessibility.js', __FILE__ ), array( 'jquery' ), '1.0.3', true );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
404
  /**
405
  * Filter target element selector for underlines. Default `a`.
406
  *
@@ -411,6 +440,16 @@ function wpa_jquery_asl() {
411
  * @return string
412
  */
413
  $target = apply_filters( 'wpa_underline_target', 'a' );
 
 
 
 
 
 
 
 
 
 
414
  wp_localize_script(
415
  'wp-accessibility',
416
  'wpa',
@@ -425,8 +464,13 @@ function wpa_jquery_asl() {
425
  'enabled' => ( 'on' === get_option( 'wpa_underline' ) ) ? true : false,
426
  'target' => $target,
427
  ),
428
- 'dir' => ( is_rtl() ) ? 'rtl' : 'ltr',
429
- 'lang' => get_bloginfo( 'language' ),
 
 
 
 
 
430
  )
431
  );
432
  }
@@ -527,30 +571,13 @@ function wpa_search_error( $template ) {
527
  return $template;
528
  }
529
 
530
- if ( 'on' === get_option( 'wpa_image_titles' ) ) {
531
- add_filter( 'the_content', 'wpa_image_titles', 100 );
532
- add_filter( 'post_thumbnail_html', 'wpa_image_titles', 100 );
533
- add_filter( 'wp_get_attachment_image', 'wpa_image_titles', 100 );
534
- }
535
-
536
- /**
537
- * Filter out title attributes on images.
538
- *
539
- * @param string $content A block of content in an image, post thumbnail, or post content.
540
- *
541
- * @return string $content minus title attributes.
542
- */
543
- function wpa_image_titles( $content ) {
544
- $results = array();
545
- preg_match_all( '|[\s]title="[^"]*"|U', $content, $results );
546
- foreach ( $results[0] as $img ) {
547
- $content = str_replace( $img, '', $content );
548
- }
549
-
550
- return $content;
551
- }
552
-
553
- if ( 'on' === get_option( 'wpa_more' ) ) {
554
  add_filter( 'get_the_excerpt', 'wpa_custom_excerpt_more', 100 );
555
  add_filter( 'excerpt_more', 'wpa_excerpt_more', 100 );
556
  add_filter( 'the_content_more_link', 'wpa_content_more', 100 );
@@ -816,7 +843,7 @@ function wpa_get_content_summary( $post_id ) {
816
  */
817
  $heading = apply_filters( 'wpa_summary_heading', __( 'Summary', 'wp-accessibility' ), $post_id );
818
  /**
819
- * Filter the heading leve for content summaries. Default `h2`.
820
  *
821
  * @hook wpa_summary_heading_level
822
  *
17
  * Domain Path: /lang
18
  * License: GPL-2.0+
19
  * License URI: http://www.gnu.org/license/gpl-2.0.txt
20
+ * Version: 2.0.0
21
  */
22
 
23
  /*
54
  * Load internationalization.
55
  */
56
  function wpa_load_textdomain() {
57
+ load_plugin_textdomain( 'wp-accessibility' );
58
  }
59
 
60
  add_action( 'admin_menu', 'wpa_admin_menu' );
70
  * Install on activation.
71
  */
72
  function wpa_install() {
73
+ $wpa_version = '2.0.0';
74
  if ( 'true' !== get_option( 'wpa_installed' ) ) {
75
  add_option( 'rta_from_tag_clouds', 'on' );
76
  add_option( 'asl_styles_focus', '' );
133
  return $links;
134
  }
135
 
136
+ add_action( 'wp_enqueue_scripts', 'wpacc_enqueue_scripts', 101 );
137
  /**
138
+ * Enqueue accessibility feature scripts.
139
  */
140
  function wpacc_enqueue_scripts() {
141
+ $version = ( SCRIPT_DEBUG ) ? rand( 10000, 100000 ) : wpa_check_version();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  if ( 'link' === get_option( 'wpa_longdesc' ) ) {
143
  wp_enqueue_script( 'longdesc.link', plugins_url( 'js/longdesc.link.js', __FILE__ ), array( 'jquery' ), $version, true );
144
  wp_localize_script(
149
  )
150
  );
151
  }
152
+ if ( 'on' === get_option( 'wpa_show_alt' ) ) {
153
+ /**
154
+ * Modify the selector used to attach the alt attribute toggle button on images. Default `.hentry img[alt!=""], .comment-content img[alt!=""]`.
155
+ *
156
+ * @hook wpa_show_alt_selector
157
+ *
158
+ * @since 2.0.0
159
+ *
160
+ * @param {string} $selector Valid jQuery selector string.
161
+ *
162
+ * @return {string}
163
+ */
164
+ $selector = apply_filters( 'wpa_show_alt_selector', '.hentry img[alt!=""], .comment-content img[alt!=""]' );
165
+ wp_enqueue_script( 'alt.button', plugins_url( 'js/alt.button.js', __FILE__ ), array( 'jquery' ), $version, true );
166
+ wp_localize_script(
167
+ 'alt.button',
168
+ 'wpalt',
169
+ array(
170
+ 'selector' => $selector,
171
+ )
172
+ );
173
+ }
174
  if ( 'jquery' === get_option( 'wpa_longdesc' ) ) {
175
  wp_enqueue_script( 'longdesc.button', plugins_url( 'js/longdesc.button.js', __FILE__ ), array( 'jquery' ), $version, true );
176
  wp_localize_script(
182
  )
183
  );
184
  }
 
 
 
 
185
  }
186
 
187
  add_action( 'wp_enqueue_scripts', 'wpa_stylesheet' );
189
  * Enqueue stylesheets for WP Accessibility.
190
  */
191
  function wpa_stylesheet() {
192
+ $version = ( SCRIPT_DEBUG ) ? rand( 10000, 100000 ) : wpa_check_version();
193
  wp_register_style( 'wpa-style', plugins_url( 'css/wpa-style.css', __FILE__ ), array(), $version );
194
  if ( 'link' === get_option( 'wpa_longdesc' ) || 'jquery' === get_option( 'wpa_longdesc' ) || 'on' === get_option( 'asl_enable' ) || ! empty( get_option( 'wpa_post_types', array() ) ) ) {
195
  wp_enqueue_style( 'wpa-style' );
198
  if ( is_admin_bar_showing() ) {
199
  $top = '37px';
200
  }
201
+ $add_css = ( ! wpa_accessible_theme() ) ? wpa_css() : '';
202
  $custom_css = ':root { --admin-bar-top : ' . $top . '; }';
203
  wp_add_inline_style( 'wpa-style', wp_filter_nohtml_kses( stripcslashes( $add_css . $custom_css ) ) );
204
  }
321
  $focus
322
  }
323
  ";
324
+ /**
325
+ * Filter CSS styles output on front-end for skip links.
326
+ *
327
+ * @hook wpa_skiplink_styles
328
+ *
329
+ * @param {string} $styles Styles configured by settings.
330
+ *
331
+ * @return {string}
332
+ */
333
+ $styles = apply_filters( 'wpa_skiplink_styles', $styles );
334
 
335
  return $styles;
336
  }
349
  :focus { outline: 2px solid$color!important; outline-offset: 2px !important; }
350
  ";
351
  }
352
+
353
  return $styles;
354
  }
355
 
369
  * Enqueue JS needed for WP Accessibility options.
370
  */
371
  function wpa_jquery_asl() {
372
+ $version = ( SCRIPT_DEBUG ) ? rand( 10000, 100000 ) : wpa_check_version();
373
  $visibility = ( 'on' === get_option( 'asl_visible' ) ) ? 'wpa-visible' : 'wpa-hide';
374
  $output = '';
375
+ if ( 'on' === get_option( 'asl_enable' ) && ! wpa_accessible_theme() ) {
376
  $html = '';
377
  /**
378
  * Customize the default value for extra skiplink. Turns on extra skiplink options in WP Accessibility versions > 1.9.0.
410
  $output = ( '' !== $html ) ? "<div class=\"$visibility$is_rtl\" id=\"skiplinks\" role=\"navigation\" aria-label=\"" . esc_attr( $skiplinks ) . "\">$html</div>" : '';
411
  }
412
 
413
+ $labels = array(
414
+ 's' => __( 'Search', 'wp-accessibility' ),
415
+ 'author' => __( 'Name', 'wp-accessibility' ),
416
+ 'email' => __( 'Email', 'wp-accessibility' ),
417
+ 'url' => __( 'Website', 'wp-accessibility' ),
418
+ 'comment' => __( 'Comment', 'wp-accessibility' ),
419
+ );
420
+ /**
421
+ * Customize labels passed to automatically label core WordPress fields.
422
+ *
423
+ * @hook wpa_labels
424
+ * @param {array} $labels Array of labels for search and comment fields.
425
+ *
426
+ * @return {array}
427
+ */
428
+ $labels = apply_filters( 'wpa_labels', $labels );
429
+ $dir = ( 'on' === get_option( 'wpa_lang' ) && ! wpa_accessible_theme() ) ? ( ( is_rtl() ) ? 'rtl' : 'ltr' ) : false;
430
+ $lang = ( 'on' === get_option( 'wpa_lang' ) && ! wpa_accessible_theme() ) ? get_bloginfo( 'language' ) : false;
431
+
432
+ wp_enqueue_script( 'wp-accessibility', plugins_url( 'js/wp-accessibility.js', __FILE__ ), array( 'jquery' ), $version, true );
433
  /**
434
  * Filter target element selector for underlines. Default `a`.
435
  *
440
  * @return string
441
  */
442
  $target = apply_filters( 'wpa_underline_target', 'a' );
443
+ /**
444
+ * Filter whether console log messages about remediation actions will be sent.
445
+ *
446
+ * @hook wpa_view_remediation_logs
447
+ *
448
+ * @param {bool} $visible Default `true` if user is logged in and has capabilities to manage options.
449
+ *
450
+ * @return {bool}
451
+ */
452
+ $errors_enabled = apply_filters( 'wpa_view_remediation_logs', current_user_can( 'manage_options' ) );
453
  wp_localize_script(
454
  'wp-accessibility',
455
  'wpa',
464
  'enabled' => ( 'on' === get_option( 'wpa_underline' ) ) ? true : false,
465
  'target' => $target,
466
  ),
467
+ 'dir' => $dir,
468
+ 'lang' => $lang,
469
+ 'titles' => ( 'on' === get_option( 'wpa_image_titles' ) ) ? true : false,
470
+ 'labels' => ( 'on' === get_option( 'wpa_labels' ) && ! wpa_accessible_theme() ) ? true : false,
471
+ 'wpalabels' => $labels,
472
+ 'current' => ( version_compare( $GLOBALS['wp_version'], '5.3', '<' ) ) ? true : false,
473
+ 'errors' => ( $errors_enabled ) ? true : false,
474
  )
475
  );
476
  }
571
  return $template;
572
  }
573
 
574
+ if ( 'on' === get_option( 'wpa_more' ) && ! wpa_accessible_theme() ) {
575
+ add_filter(
576
+ 'body_class',
577
+ function( $classes ) {
578
+ return array_merge( $classes, array( 'wpa-excerpt' ) );
579
+ }
580
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
581
  add_filter( 'get_the_excerpt', 'wpa_custom_excerpt_more', 100 );
582
  add_filter( 'excerpt_more', 'wpa_excerpt_more', 100 );
583
  add_filter( 'the_content_more_link', 'wpa_content_more', 100 );
843
  */
844
  $heading = apply_filters( 'wpa_summary_heading', __( 'Summary', 'wp-accessibility' ), $post_id );
845
  /**
846
+ * Filter the heading level for content summaries. Default `h2`.
847
  *
848
  * @hook wpa_summary_heading_level
849
  *