WP Accessibility - Version 1.7.0

Version Description

  • Add: test for specific common types of invalid alt attribute and label as invalid.
  • Change: Remove webkit skiplink polyfill (obsolete)
  • Change: Move toolbar JS to external file.
  • Change: Use wp inline style method for toolbar size.
  • Bug fix: Incorrect variable type matching in toolbar size setting.
  • Security: Minor authenticated XSS vulnerability in custom CSS.
Download this release

Release Info

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

Code changes from version 1.6.10 to 1.7.0

js/skiplinks.webkit.js DELETED
@@ -1,24 +0,0 @@
1
- (function (linkList, i, URI) {
2
- if (!!(URI = document.documentURI)) {
3
- URI = URI.split('#')[0];
4
- document.addEventListener("DOMContentLoaded", function () {
5
- document.removeEventListener("DOMContentLoaded", arguments.callee, false);
6
- linkList = document.links;
7
- for (i in linkList) {
8
- if (!!linkList[i].hash) {
9
- if (linkList[i].hash.match(/^#./)) {
10
- if ((URI + linkList[i].hash) == linkList[i].href) {
11
- linkList[i].addEventListener("click", function (e, f, g) {
12
- f = document.getElementById(this.hash.slice(1));
13
- if (!(g = f.getAttribute('tabIndex'))) f.setAttribute('tabIndex', -1);
14
- f.focus();
15
- if (!g) f.removeAttribute('tabIndex');
16
- }, false);
17
- }
18
- }
19
- }
20
- }
21
- }, false);
22
- }
23
- return true;
24
- })();
js/wpa-toolbar.js ADDED
@@ -0,0 +1,18 @@
1
+ (function( $ ) { 'use strict';
2
+ var insert_a11y_toolbar = '<!-- a11y toolbar -->';
3
+ insert_a11y_toolbar += '<div class="' + wpa.responsive + 'a11y-toolbar' + wpa.is_rtl + wpa.is_right + '">';
4
+ insert_a11y_toolbar += '<ul class="a11y-toolbar-list">';
5
+ if ( wpa.enable_contrast == 'true' ) {
6
+ insert_a11y_toolbar += '<li class="a11y-toolbar-list-item"><button type="button" class="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>';
7
+ }
8
+ if ( wpa.enable_grayscale == 'true' ) {
9
+ insert_a11y_toolbar += '<li class="a11y-toolbar-list-item"><button type="button" class="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>';
10
+ }
11
+ if ( wpa.enable_fontsize == 'true' ) {
12
+ insert_a11y_toolbar += '<li class="a11y-toolbar-list-item"><button type="button" class="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>';
13
+ }
14
+ insert_a11y_toolbar += '</ul>';
15
+ insert_a11y_toolbar += '</div>';
16
+ insert_a11y_toolbar += '<!-- // a11y toolbar -->';
17
+ $( document ).find( wpa.location ).prepend( insert_a11y_toolbar );
18
+ }(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.3
7
- Tested up to: 5.2
8
- Stable tag: 1.6.10
9
Text Domain: wp-accessibility
10
License: GPLv2 or later
11
@@ -26,6 +26,7 @@ All features can be disabled according to your theme's needs. For advanced users
26
* Add a toolbar toggling between high contrast, large print, and desaturated (grayscale) views of your theme.
27
* Add a long description to images. Use the image's "Description" field to add long descriptions.
28
* Enforcement for alt attributes on images.
29
30
= Accessibility Issues fixed by WP Accessibility: =
31
@@ -65,6 +66,15 @@ The plug-in is intended to help with deficiencies commonly found in themes and t
65
[Suggest a change!](https://github.com/joedolson/wp-accessibility/issues/)
66
* Conflict with NextGen gallery to explore
67
68
= 1.6.10 =
69
70
* Based on support for screen-reader-text class and current support for aria-current, shifting to aria only.
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.3
7
+ Tested up to: 5.3
8
+ Stable tag: 1.7.0
9
Text Domain: wp-accessibility
10
License: GPLv2 or later
11
26
* Add a toolbar toggling between high contrast, large print, and desaturated (grayscale) views of your theme.
27
* Add a long description to images. Use the image's "Description" field to add long descriptions.
28
* Enforcement for alt attributes on images.
29
+ * Easily identify images without alt attributes in the Media Library
30
31
= Accessibility Issues fixed by WP Accessibility: =
32
66
[Suggest a change!](https://github.com/joedolson/wp-accessibility/issues/)
67
* Conflict with NextGen gallery to explore
68
69
+ = 1.7.0 =
70
+
71
+ * Add: test for specific common types of invalid alt attribute and label as invalid.
72
+ * Change: Remove webkit skiplink polyfill (obsolete)
73
+ * Change: Move toolbar JS to external file.
74
+ * Change: Use wp inline style method for toolbar size.
75
+ * Bug fix: Incorrect variable type matching in toolbar size setting.
76
+ * Security: Minor authenticated XSS vulnerability in custom CSS.
77
+
78
= 1.6.10 =
79
80
* Based on support for screen-reader-text class and current support for aria-current, shifting to aria only.
wp-accessibility-alt.php CHANGED
@@ -38,7 +38,11 @@ function wpa_media_columns( $columns ) {
38
*/
39
function wpa_media_value( $column, $id ) {
40
if ( 'wpa_data' === $column ) {
41
- $mime = get_post_mime_type( $id );
42
switch ( $mime ) {
43
case 'image/jpeg':
44
case 'image/png':
@@ -50,6 +54,8 @@ function wpa_media_value( $column, $id ) {
50
} else {
51
if ( true === $no_alt ) {
52
echo '<span class="ok"><span class="dashicons dashicons-yes" aria-hidden="true"></span> ' . __( 'Decorative', 'wp-accessibility' ) . '</span>';
53
} else {
54
echo '<span class="ok"><span class="dashicons dashicons-yes" aria-hidden="true"></span> ' . __( 'Has <code>alt</code>', 'wp-accessibility' ) . '</span>';
55
}
38
*/
39
function wpa_media_value( $column, $id ) {
40
if ( 'wpa_data' === $column ) {
41
+ $mime = get_post_mime_type( $id );
42
+ $invalid_values = array(
43
+ '""',
44
+ "''",
45
+ );
46
switch ( $mime ) {
47
case 'image/jpeg':
48
case 'image/png':
54
} else {
55
if ( true === $no_alt ) {
56
echo '<span class="ok"><span class="dashicons dashicons-yes" aria-hidden="true"></span> ' . __( 'Decorative', 'wp-accessibility' ) . '</span>';
57
+ } elseif ( in_array( $alt, $invalid_values, true ) ) {
58
+ echo '<span class="missing"><span class="dashicons dashicons-no" aria-hidden="true"></span> ' . __( 'Invalid', 'wp-accessibility' ) . '</span>';
59
} else {
60
echo '<span class="ok"><span class="dashicons dashicons-yes" aria-hidden="true"></span> ' . __( 'Has <code>alt</code>', 'wp-accessibility' ) . '</span>';
61
}
wp-accessibility-settings.php CHANGED
@@ -300,7 +300,7 @@ function wpa_admin_settings() {
300
<?php
301
for ( $i = 1.2; $i <= 3.8; ) {
302
$val = ( $i * 10 ) + 2;
303
- $current = $val;
304
$selected_size = ( $current === $size ) ? ' selected="selected"' : '';
305
echo "<option value='$val'$selected_size>$val px</option>";
306
$i = $i + .1;
300
<?php
301
for ( $i = 1.2; $i <= 3.8; ) {
302
$val = ( $i * 10 ) + 2;
303
+ $current = absint( $val );
304
$selected_size = ( $current === $size ) ? ' selected="selected"' : '';
305
echo "<option value='$val'$selected_size>$val px</option>";
306
$i = $i + .1;
wp-accessibility-toolbar.php CHANGED
@@ -74,61 +74,33 @@ function wpa_toolbar_html( $type = 'widget', $control = 'button' ) {
74
}
75
76
/**
77
- * Generate Toolbar as JS.
78
*/
79
function wpa_toolbar_js() {
80
// Toolbar does not work on Edge. Disable unless I solve the issue.
81
$default = ( false !== (bool) get_option( 'wpa_toolbar_default' ) ) ? get_option( 'wpa_toolbar_default' ) : 'body';
82
$location = apply_filters( 'wpa_move_toolbar', $default );
83
- $user_agent = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? $_SERVER['HTTP_USER_AGENT'] : '';
84
$is_rtl = ( is_rtl() ) ? ' rtl' : ' ltr';
85
$is_right = ( 'on' === get_option( 'wpa_toolbar_right' ) ) ? ' right' : ' left';
86
$responsive = ( 'on' === get_option( 'wpa_toolbar_mobile' ) ) ? 'a11y-responsive ' : 'a11y-non-responsive ';
87
88
- if ( preg_match( '/Edge/i', $user_agent ) ) {
89
- echo wpa_toolbar_html( 'js', 'a' );
90
- echo "
91
- <script type='text/javascript'>
92
- //<![CDATA[
93
- (function( $ ) { 'use strict';
94
- var toolbar = $( '.a11y-toolbar-widget' );
95
- toolbar.removeClass( 'a11y-toolbar-widget' );
96
- $( document ).find( '$location' ).prepend( toolbar );
97
- }(jQuery));
98
- //]]>
99
- </script>";
100
- } else {
101
- $contrast = __( 'Toggle High Contrast', 'wp-accessibility' );
102
- $grayscale = __( 'Toggle Grayscale', 'wp-accessibility' );
103
- $fontsize = __( 'Toggle Font size', 'wp-accessibility' );
104
- $enable_grayscale = ( 'on' === get_option( 'wpa_toolbar_gs' ) && current_user_can( 'manage_options' ) ) ? true : false;
105
- $enable_fontsize = ( 'off' === get_option( 'wpa_toolbar_fs' ) ) ? false : true;
106
- $enable_contrast = ( 'off' === get_option( 'wpa_toolbar_ct' ) ) ? false : true;
107
108
- echo
109
- "
110
- <script type='text/javascript'>
111
- //<![CDATA[
112
- (function( $ ) { 'use strict';
113
- var insert_a11y_toolbar = '<!-- a11y toolbar -->';
114
- insert_a11y_toolbar += '<div class=\"" . $responsive . "a11y-toolbar$is_rtl$is_right\">';
115
- insert_a11y_toolbar += '<ul class=\"a11y-toolbar-list\">';";
116
- if ( get_option( 'wpa_toolbar' ) === 'on' && $enable_contrast ) {
117
- echo "insert_a11y_toolbar += '<li class=\"a11y-toolbar-list-item\"><button type=\"button\" class=\"a11y-toggle-contrast toggle-contrast\" id=\"is_normal_contrast\" aria-pressed=\"false\"><span class=\"offscreen\">$contrast</span><span class=\"aticon aticon-adjust\" aria-hidden=\"true\"></span></button></li>';";
118
- }
119
- if ( get_option( 'wpa_toolbar' ) === 'on' && $enable_grayscale ) {
120
- echo "insert_a11y_toolbar += '<li class=\"a11y-toolbar-list-item\"><button type=\"button\" class=\"a11y-toggle-grayscale toggle-grayscale\" id=\"is_normal_color\" aria-pressed=\"false\"><span class=\"offscreen\">$grayscale</span><span class=\"aticon aticon-tint\" aria-hidden=\"true\"></span></button></li>';";
121
- }
122
- if ( get_option( 'wpa_toolbar' ) === 'on' && $enable_fontsize ) {
123
- echo "insert_a11y_toolbar += '<li class=\"a11y-toolbar-list-item\"><button type=\"button\" class=\"a11y-toggle-fontsize toggle-fontsize\" id=\"is_normal_fontsize\" aria-pressed=\"false\"><span class=\"offscreen\">$fontsize</span><span class=\"aticon aticon-font\" aria-hidden=\"true\"></span></button></li>';";
124
- }
125
- echo "
126
- insert_a11y_toolbar += '</ul>';
127
- insert_a11y_toolbar += '</div>';
128
- insert_a11y_toolbar += '<!-- // a11y toolbar -->';
129
- $( document ).find( '$location' ).prepend( insert_a11y_toolbar );
130
- }(jQuery));
131
- //]]>
132
- </script>";
133
- }
134
}
74
}
75
76
/**
77
+ * Generate Toolbar variables for localization in JS.
78
*/
79
function wpa_toolbar_js() {
80
// Toolbar does not work on Edge. Disable unless I solve the issue.
81
$default = ( false !== (bool) get_option( 'wpa_toolbar_default' ) ) ? get_option( 'wpa_toolbar_default' ) : 'body';
82
$location = apply_filters( 'wpa_move_toolbar', $default );
83
$is_rtl = ( is_rtl() ) ? ' rtl' : ' ltr';
84
$is_right = ( 'on' === get_option( 'wpa_toolbar_right' ) ) ? ' right' : ' left';
85
$responsive = ( 'on' === get_option( 'wpa_toolbar_mobile' ) ) ? 'a11y-responsive ' : 'a11y-non-responsive ';
86
87
+ $contrast = __( 'Toggle High Contrast', 'wp-accessibility' );
88
+ $grayscale = __( 'Toggle Grayscale', 'wp-accessibility' );
89
+ $fontsize = __( 'Toggle Font size', 'wp-accessibility' );
90
+ $enable_grayscale = ( 'on' === get_option( 'wpa_toolbar_gs' ) && current_user_can( 'manage_options' ) ) ? 'true' : 'false';
91
+ $enable_fontsize = ( 'off' === get_option( 'wpa_toolbar_fs' ) ) ? 'false' : 'true';
92
+ $enable_contrast = ( 'off' === get_option( 'wpa_toolbar_ct' ) ) ? 'false' : 'true';
93
94
+ return array(
95
+ 'location' => $location,
96
+ 'is_rtl' => $is_rtl,
97
+ 'is_right' => $is_right,
98
+ 'responsive' => $responsive,
99
+ 'contrast' => $contrast,
100
+ 'grayscale' => $grayscale,
101
+ 'fontsize' => $fontsize,
102
+ 'enable_grayscale' => $enable_grayscale,
103
+ 'enable_fontsize' => $enable_fontsize,
104
+ 'enable_contrast' => $enable_contrast,
105
+ );
106
}
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.6.10
21
*/
22
23
/*
@@ -68,7 +68,7 @@ function wpa_admin_menu() {
68
* Install on activation.
69
*/
70
function wpa_install() {
71
- $wpa_version = '1.6.10';
72
if ( 'true' !== get_option( 'wpa_installed' ) ) {
73
add_option( 'rta_from_nav_menu', 'on' );
74
add_option( 'rta_from_page_lists', 'on' );
@@ -125,7 +125,7 @@ add_action( 'wp_enqueue_scripts', 'wpa_register_scripts' );
125
* Register jQuery scripts.
126
*/
127
function wpa_register_scripts() {
128
- wp_register_script( 'skiplinks.webkit', plugins_url( 'wp-accessibility/js/skiplinks.webkit.js' ) );
129
wp_register_script( 'ui-a11y.js', plugins_url( 'wp-accessibility/toolbar/js/a11y.js' ), array( 'jquery' ), '1.0', true );
130
}
131
@@ -135,10 +135,12 @@ add_action( 'wp_enqueue_scripts', 'wpacc_enqueue_scripts' );
135
*/
136
function wpacc_enqueue_scripts() {
137
wp_enqueue_script( 'jquery' );
138
- if ( 'on' === get_option( 'asl_enable' ) ) {
139
- wp_enqueue_script( 'skiplinks.webkit' );
140
- }
141
if ( 'on' === get_option( 'wpa_toolbar' ) || 'on' === get_option( 'wpa_widget_toolbar' ) ) {
142
wp_enqueue_script( 'ui-a11y.js' );
143
$plugin_path = plugins_url( 'wp-accessibility/toolbar/css/a11y-contrast.css' );
144
if ( file_exists( get_stylesheet_directory() . '/a11y-contrast.css' ) ) {
@@ -166,9 +168,6 @@ function wpacc_enqueue_scripts() {
166
);
167
wp_localize_script( 'wpa-labels', 'wpalabels', $labels );
168
}
169
- if ( 'on' === get_option( 'wpa_toolbar' ) ) {
170
- add_action( 'wp_footer', 'wpa_toolbar_js' );
171
- }
172
if ( 'link' === get_option( 'wpa_longdesc' ) ) {
173
wp_enqueue_script( 'longdesc.link', plugins_url( 'js/longdesc.link.js', __FILE__ ), array( 'jquery' ), '1.0', true );
174
}
@@ -195,12 +194,7 @@ function wpa_stylesheet() {
195
$toolbar_size = ( false === stripos( $toolbar_size, 'em' ) ) ? $toolbar_size . 'px' : $toolbar_size;
196
// Only enable styles when required by options.
197
if ( get_option( 'wpa_toolbar_size' ) && 'on' === get_option( 'wpa_toolbar' ) ) {
198
- echo "
199
- <style type='text/css'>
200
- .a11y-toolbar ul li button {
201
- font-size: " . $toolbar_size . ' !important;
202
- }
203
- </style>';
204
}
205
if ( 'link' === get_option( 'wpa_longdesc' ) || 'jquery' === get_option( 'wpa_longdesc' ) || 'on' === get_option( 'asl_enable' ) ) {
206
wp_enqueue_style( 'wpa-style' );
@@ -247,7 +241,7 @@ add_action( 'wp_head', 'wpa_css' );
247
function wpa_css() {
248
$styles = '';
249
if ( get_option( 'asl_enable' ) === 'on' ) {
250
- $focus = get_option( 'asl_styles_focus' );
251
// these styles are derived from the WordPress skip link defaults.
252
$top = '7px';
253
if ( is_admin_bar_showing() ) {
@@ -262,7 +256,7 @@ function wpa_css() {
262
// Passive default styles derived from WordPress default focus styles.
263
$default_passive = 'background-color: #fff; box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.2); clip: auto; color: #333; display: block; font-weight: 600; height: auto; line-height: normal; padding: 15px 23px 14px; position: absolute; left: 6px; top: ' . $top . '; text-decoration: none; text-transform: none; width: auto; z-index: 100000;';
264
265
- $passive = get_option( 'asl_styles_passive' );
266
$vis = '';
267
$invis = '';
268
@@ -622,7 +616,7 @@ $plugins_string
622
$sitename = substr( $sitename, 4 );
623
}
624
$from_email = 'wordpress@' . $sitename;
625
- $from = "From: \"$current_user->display_name\" <$from_email>\r\nReply-to: \"$current_user->display_name\" <$current_user->user_email>\r\n";
626
627
if ( ! $has_read_faq ) {
628
echo "<div class='message error'><p>" . __( 'Please read the FAQ and other Help documents before making a support request.', 'wp-accessibility' ) . '</p></div>';
17
* Domain Path: /lang
18
* License: GPL-2.0+
19
* License URI: http://www.gnu.org/license/gpl-2.0.txt
20
+ * Version: 1.7.0
21
*/
22
23
/*
68
* Install on activation.
69
*/
70
function wpa_install() {
71
+ $wpa_version = '1.7.0';
72
if ( 'true' !== get_option( 'wpa_installed' ) ) {
73
add_option( 'rta_from_nav_menu', 'on' );
74
add_option( 'rta_from_page_lists', 'on' );
125
* Register jQuery scripts.
126
*/
127
function wpa_register_scripts() {
128
+ wp_register_script( 'wpa-toolbar', plugins_url( 'wp-accessibility/js/wpa-toolbar.js' ), array( 'jquery' ), '1.0', true );
129
wp_register_script( 'ui-a11y.js', plugins_url( 'wp-accessibility/toolbar/js/a11y.js' ), array( 'jquery' ), '1.0', true );
130
}
131
135
*/
136
function wpacc_enqueue_scripts() {
137
wp_enqueue_script( 'jquery' );
138
if ( 'on' === get_option( 'wpa_toolbar' ) || 'on' === get_option( 'wpa_widget_toolbar' ) ) {
139
+ if ( 'on' === get_option( 'wpa_toolbar' ) ) {
140
+ // Enqueue Toolbar JS if enabled.
141
+ wp_enqueue_script( 'wpa-toolbar' );
142
+ wp_localize_script( 'wpa-toolbar', 'wpa', wpa_toolbar_js() );
143
+ }
144
wp_enqueue_script( 'ui-a11y.js' );
145
$plugin_path = plugins_url( 'wp-accessibility/toolbar/css/a11y-contrast.css' );
146
if ( file_exists( get_stylesheet_directory() . '/a11y-contrast.css' ) ) {
168
);
169
wp_localize_script( 'wpa-labels', 'wpalabels', $labels );
170
}
171
if ( 'link' === get_option( 'wpa_longdesc' ) ) {
172
wp_enqueue_script( 'longdesc.link', plugins_url( 'js/longdesc.link.js', __FILE__ ), array( 'jquery' ), '1.0', true );
173
}
194
$toolbar_size = ( false === stripos( $toolbar_size, 'em' ) ) ? $toolbar_size . 'px' : $toolbar_size;
195
// Only enable styles when required by options.
196
if ( get_option( 'wpa_toolbar_size' ) && 'on' === get_option( 'wpa_toolbar' ) ) {
197
+ wp_add_inline_style( 'ui-a11y.css', '.a11y-toolbar ul li button { font-size: ' . $toolbar_size . ' !important; }' );
198
}
199
if ( 'link' === get_option( 'wpa_longdesc' ) || 'jquery' === get_option( 'wpa_longdesc' ) || 'on' === get_option( 'asl_enable' ) ) {
200
wp_enqueue_style( 'wpa-style' );
241
function wpa_css() {
242
$styles = '';
243
if ( get_option( 'asl_enable' ) === 'on' ) {
244
+ $focus = wp_kses( get_option( 'asl_styles_focus' ), array(), array() );
245
// these styles are derived from the WordPress skip link defaults.
246
$top = '7px';
247
if ( is_admin_bar_showing() ) {
256
// Passive default styles derived from WordPress default focus styles.
257
$default_passive = 'background-color: #fff; box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.2); clip: auto; color: #333; display: block; font-weight: 600; height: auto; line-height: normal; padding: 15px 23px 14px; position: absolute; left: 6px; top: ' . $top . '; text-decoration: none; text-transform: none; width: auto; z-index: 100000;';
258
259
+ $passive = wp_kses( get_option( 'asl_styles_passive' ), array(), array() );
260
$vis = '';
261
$invis = '';
262
616
$sitename = substr( $sitename, 4 );
617
}
618
$from_email = 'wordpress@' . $sitename;
619
+ $from = "From: $current_user->display_name <$from_email>\r\nReply-to: $current_user->display_name <$current_user->user_email>\r\n";
620
621
if ( ! $has_read_faq ) {
622
echo "<div class='message error'><p>" . __( 'Please read the FAQ and other Help documents before making a support request.', 'wp-accessibility' ) . '</p></div>';