WP Accessibility - Version 1.6.0

Version Description

Download this release

Release Info

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

Code changes from version 1.5.10 to 1.6.0

js/current-menu-item.js ADDED
@@ -0,0 +1,6 @@
1
+ (function ($) {
2
+ $(function() {
3
+ $( '.current-menu-item' ).attr( 'aria-current', 'true' ).append( "<span class='screen-reader-text'>(current)</span>" );
4
+ $( '.current_page_item' ).attr( 'aria-current', 'true' ).append( "<span class='screen-reader-text'>(current)</span>" );
5
+ });
6
+ }(jQuery));
readme.txt CHANGED
@@ -60,6 +60,14 @@ Translating my plug-ins is always appreciated. Visit <a href="https://translate.
60
61
[Suggest a change!](https://github.com/joedolson/wp-accessibility/)
62
63
= 1.5.10 =
64
65
* Disable Toolbar on Edge due to page not found bug.
60
61
[Suggest a change!](https://github.com/joedolson/wp-accessibility/)
62
63
+ = 1.5.11 =
64
+
65
+ * Bug fix: incorrect CSS style reference on longdesc template
66
+ * Re-enable Toolbar on Edge (slightly different from other browsers, but functional.)
67
+ * Hide grayscale from non-admins.
68
+ * Add note reflecting above
69
+ * Add feature: identify current menu item
70
+
71
= 1.5.10 =
72
73
* Disable Toolbar on Edge due to page not found bug.
templates/longdesc-template.php CHANGED
@@ -11,7 +11,7 @@
11
<meta charset="<?php bloginfo( 'charset' ); ?>">
12
<title><?php the_title(); ?></title>
13
<link rel="stylesheet" type="text/css" href="<?php print get_stylesheet_uri(); ?>">
14
- <link rel="stylesheet" type="text/css" href="<?php print plugins_url( '/wp-accessibility/wpa-style.css' ); ?>">
15
</head>
16
<body>
17
<div id="longdesc" class="template-longdesc">
11
<meta charset="<?php bloginfo( 'charset' ); ?>">
12
<title><?php the_title(); ?></title>
13
<link rel="stylesheet" type="text/css" href="<?php print get_stylesheet_uri(); ?>">
14
+ <link rel="stylesheet" type="text/css" href="<?php print plugins_url( '/wp-accessibility/css/wpa-style.css' ); ?>">
15
</head>
16
<body>
17
<div id="longdesc" class="template-longdesc">
toolbar/css/a11y.css CHANGED
@@ -1,168 +1,168 @@
1
- /*
2
- Accessibility styles
3
- chris@inathought.com
4
- */
5
- @media only screen and (max-width: 800px) {
6
- /* Remove toolbar on small screens */
7
- .a11y-responsive {
8
- display: none;
9
- }
10
- }
11
-
12
- .focusable:focus {
13
- outline: none !important;
14
- }
15
-
16
- .has-focus {
17
- background: yellow;
18
- }
19
-
20
- /* reset styles */
21
- .a11y-toolbar button {
22
- border: 0;
23
- color: inherit;
24
- background-color: transparent;
25
- text-decoration: none;
26
- padding: 0;
27
- line-height: inherit;
28
- margin: 0;
29
- font: inherit;
30
- width: 100%;
31
- height: 100%;
32
- text-align: left;
33
- }
34
-
35
- .a11y-toolbar {
36
- position: fixed;
37
- z-index: 99999;
38
- top: 43%;
39
- left: 0;
40
- }
41
-
42
- .a11y-toolbar ul {
43
- list-style: none;
44
- margin: 0;
45
- padding: 0;
46
- border-top-right-radius: 4px;
47
- border-bottom-right-radius: 4px;
48
- }
49
-
50
- .a11y-toolbar ul li {
51
- margin: 0;
52
- padding: 0;
53
- display: block;
54
- }
55
-
56
- .a11y-toolbar ul li button {
57
- font-size: 1.6em;
58
- padding: .25em;
59
- }
60
-
61
- .a11y-toolbar button {
62
- color: #000 !important;
63
- }
64
-
65
- .a11y-toolbar button.active {
66
- color: #fff !important;
67
- }
68
-
69
- .a11y-toolbar ul li button {
70
- display: block;
71
- background: #e2e2e2;
72
- text-align: center;
73
- border-top: 1px solid #f5f5f5;
74
- border-bottom: 1px solid #d2d2d2;
75
- position: relative;
76
- }
77
-
78
- .a11y-toolbar ul li button:hover {
79
- background: #fff;
80
- }
81
-
82
- .a11y-toolbar ul li button.active {
83
- background: #181818;
84
- border-bottom: 1px solid #525252;
85
- }
86
-
87
- .a11y-toolbar ul li:first-child button {
88
- border-top-right-radius: 4px;
89
- }
90
-
91
- .a11y-toolbar ul li:last-child button {
92
- border-bottom-right-radius: 4px;
93
- }
94
-
95
-
96
- .a11y-toolbar .offscreen, .a11y_stylesheet_path {
97
- position: absolute !important;
98
- clip: rect(1px, 1px, 1px, 1px);
99
- clip-path: polygon(0px 0px, 0px 0px,0px 0px, 0px 0px);
100
- white-space: nowrap;
101
- padding: 0 !important;
102
- border: 0 !important;
103
- height: 1px !important;
104
- width: 1px !important;
105
- overflow: hidden;
106
- -webkit-transition: width .3s, clip .3s, clip-path .3s, background-color .5s;
107
- transition: width .3s, clip .3s, clip-path .3s, background-color .5s;
108
- }
109
-
110
- /* a11y toolbar RTL */
111
- .a11y-toolbar.rtl, .a11y-toolbar.right {
112
- right: 0;
113
- left: auto;
114
- }
115
-
116
- .a11y-toolbar.rtl ul, .a11y-toolbar.right ul {
117
- border-top-left-radius: 4px;
118
- border-bottom-left-radius: 4px;
119
- border-top-right-radius: 0;
120
- border-bottom-right-radius: 0;
121
- }
122
-
123
- .a11y-toolbar.rtl ul li:first-child button, .a11y-toolbar.right ul li:first-child button {
124
- border-top-left-radius: 4px;
125
- border-top-right-radius: 0;
126
- }
127
-
128
- .a11y-toolbar.rtl ul li:last-child button, .a11y-toolbar.right ul li:last-child button {
129
- border-bottom-left-radius: 4px;
130
- border-bottom-right-radius: 0;
131
- }
132
-
133
- .desaturated {
134
- filter: grayscale(100%) !important;
135
- -webkit-filter: grayscale(100%) !important;
136
- -webkit-filter: grayscale(1) !important;
137
- -moz-filter: grayscale(100%) !important;
138
- -ms-filter: grayscale(100%) !important;
139
- -o-filter: grayscale(100%) !important;
140
- filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale") !important;
141
- filter: gray !important;
142
- }
143
-
144
- .a11y-toolbar button:hover .offscreen, .a11y-toolbar button:focus .offscreen {
145
- height: auto !important;
146
- width: 12em !important;
147
- clip: unset !important;
148
- clip-path: unset !important;
149
- color: #333;
150
- background: #ffd;
151
- padding: 2px;
152
- box-shadow: 0 0 1px #000;
153
- border-radius: 2px;
154
- font-size: 13px;
155
- text-transform: none;
156
- font-family: Arial;
157
- top: 25%;
158
- display: block;
159
- }
160
-
161
- .a11y-toolbar.right button:hover .offscreen, .a11y-toolbar.right button:focus .offscreen{
162
- right: 3em;
163
- left: auto;
164
- }
165
-
166
- .a11y-toolbar button:hover .offscreen, .a11y-toolbar button:focus .offscreen{
167
- left: 3em;
168
- }
1
+ /*
2
+ Accessibility styles
3
+ chris@inathought.com
4
+ */
5
+ @media only screen and (max-width: 800px) {
6
+ /* Remove toolbar on small screens */
7
+ .a11y-responsive {
8
+ display: none;
9
+ }
10
+ }
11
+
12
+ .focusable:focus {
13
+ outline: none !important;
14
+ }
15
+
16
+ .has-focus {
17
+ background: yellow;
18
+ }
19
+
20
+ /* reset styles */
21
+ .a11y-toolbar button {
22
+ border: 0;
23
+ color: inherit;
24
+ background-color: transparent;
25
+ text-decoration: none;
26
+ padding: 0;
27
+ line-height: inherit;
28
+ margin: 0;
29
+ font: inherit;
30
+ width: 100%;
31
+ height: 100%;
32
+ text-align: left;
33
+ }
34
+
35
+ .a11y-toolbar {
36
+ position: fixed;
37
+ z-index: 99999;
38
+ top: 43%;
39
+ left: 0;
40
+ }
41
+
42
+ .a11y-toolbar ul {
43
+ list-style: none;
44
+ margin: 0;
45
+ padding: 0;
46
+ border-top-right-radius: 4px;
47
+ border-bottom-right-radius: 4px;
48
+ }
49
+
50
+ .a11y-toolbar ul li {
51
+ margin: 0;
52
+ padding: 0;
53
+ display: block;
54
+ }
55
+
56
+ .a11y-toolbar ul li button {
57
+ font-size: 1.6em;
58
+ padding: .25em;
59
+ }
60
+
61
+ .a11y-toolbar button {
62
+ color: #000 !important;
63
+ }
64
+
65
+ .a11y-toolbar button.active {
66
+ color: #fff !important;
67
+ }
68
+
69
+ .a11y-toolbar ul li button {
70
+ display: block;
71
+ background: #e2e2e2;
72
+ text-align: center;
73
+ border-top: 1px solid #f5f5f5;
74
+ border-bottom: 1px solid #d2d2d2;
75
+ position: relative;
76
+ }
77
+
78
+ .a11y-toolbar ul li button:hover {
79
+ background: #fff;
80
+ }
81
+
82
+ .a11y-toolbar ul li button.active {
83
+ background: #181818;
84
+ border-bottom: 1px solid #525252;
85
+ }
86
+
87
+ .a11y-toolbar ul li:first-child button {
88
+ border-top-right-radius: 4px;
89
+ }
90
+
91
+ .a11y-toolbar ul li:last-child button {
92
+ border-bottom-right-radius: 4px;
93
+ }
94
+
95
+
96
+ .a11y-toolbar .offscreen, .a11y_stylesheet_path {
97
+ position: absolute !important;
98
+ clip: rect(1px, 1px, 1px, 1px);
99
+ clip-path: polygon(0px 0px, 0px 0px,0px 0px, 0px 0px);
100
+ white-space: nowrap;
101
+ padding: 0 !important;
102
+ border: 0 !important;
103
+ height: 1px !important;
104
+ width: 1px !important;
105
+ overflow: hidden;
106
+ -webkit-transition: width .3s, clip .3s, clip-path .3s, background-color .5s;
107
+ transition: width .3s, clip .3s, clip-path .3s, background-color .5s;
108
+ }
109
+
110
+ /* a11y toolbar RTL */
111
+ .a11y-toolbar.rtl, .a11y-toolbar.right {
112
+ right: 0;
113
+ left: auto;
114
+ }
115
+
116
+ .a11y-toolbar.rtl ul, .a11y-toolbar.right ul {
117
+ border-top-left-radius: 4px;
118
+ border-bottom-left-radius: 4px;
119
+ border-top-right-radius: 0;
120
+ border-bottom-right-radius: 0;
121
+ }
122
+
123
+ .a11y-toolbar.rtl ul li:first-child button, .a11y-toolbar.right ul li:first-child button {
124
+ border-top-left-radius: 4px;
125
+ border-top-right-radius: 0;
126
+ }
127
+
128
+ .a11y-toolbar.rtl ul li:last-child button, .a11y-toolbar.right ul li:last-child button {
129
+ border-bottom-left-radius: 4px;
130
+ border-bottom-right-radius: 0;
131
+ }
132
+
133
+ .desaturated {
134
+ filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale") !important;
135
+ filter: grayscale(100%) !important;
136
+ -webkit-filter: grayscale(100%) !important;
137
+ -webkit-filter: grayscale(1) !important;
138
+ -moz-filter: grayscale(100%) !important;
139
+ -ms-filter: grayscale(100%) !important;
140
+ -o-filter: grayscale(100%) !important;
141
+ filter: gray !important;
142
+ }
143
+
144
+ .a11y-toolbar button:hover .offscreen, .a11y-toolbar button:focus .offscreen {
145
+ height: auto !important;
146
+ width: 12em !important;
147
+ clip: unset !important;
148
+ clip-path: unset !important;
149
+ color: #333;
150
+ background: #ffd;
151
+ padding: 2px;
152
+ box-shadow: 0 0 1px #000;
153
+ border-radius: 2px;
154
+ font-size: 13px;
155
+ text-transform: none;
156
+ font-family: Arial;
157
+ top: 25%;
158
+ display: block;
159
+ }
160
+
161
+ .a11y-toolbar.right button:hover .offscreen, .a11y-toolbar.right button:focus .offscreen{
162
+ right: 3em;
163
+ left: auto;
164
+ }
165
+
166
+ .a11y-toolbar button:hover .offscreen, .a11y-toolbar button:focus .offscreen{
167
+ left: 3em;
168
+ }
wp-accessibility-settings.php CHANGED
@@ -53,6 +53,7 @@ function wpa_update_settings() {
53
$wpa_tabindex = ( isset( $_POST['wpa_tabindex'] ) ) ? 'on' : '';
54
$wpa_underline = ( isset( $_POST['wpa_underline'] ) ) ? 'on' : '';
55
$wpa_longdesc = ( isset( $_POST['wpa_longdesc'] ) ) ? esc_attr( $_POST['wpa_longdesc'] ) : 'false';
56
$wpa_longdesc_featured = ( isset( $_POST['wpa_longdesc_featured'] ) ) ? esc_attr( $_POST['wpa_longdesc_featured'] ) : 'false';
57
$wpa_image_titles = ( isset( $_POST['wpa_image_titles'] ) ) ? 'on' : '';
58
$wpa_more = ( isset( $_POST['wpa_more'] ) ) ? 'on' : '';
@@ -70,6 +71,7 @@ function wpa_update_settings() {
70
update_option( 'wpa_tabindex', $wpa_tabindex );
71
update_option( 'wpa_underline', $wpa_underline );
72
update_option( 'wpa_longdesc', $wpa_longdesc );
73
update_option( 'wpa_longdesc_featured', $wpa_longdesc_featured );
74
update_option( 'wpa_image_titles', $wpa_image_titles );
75
update_option( 'wpa_more', $wpa_more );
@@ -221,11 +223,11 @@ function wpa_admin_menu() {
221
} ?>/> <label
222
for="wpa_toolbar_ct"><?php _e( 'Exclude contrast toggle from Accessibility toolbar', 'wp-accessibility' ); ?></label>
223
</li>
224
- <li><input type="checkbox" id="wpa_toolbar_gs"
225
name="wpa_toolbar_gs" <?php if ( get_option( 'wpa_toolbar_gs' ) == "on" ) {
226
echo 'checked="checked" ';
227
} ?>/> <label
228
- for="wpa_toolbar_gs"><?php _e( 'Include grayscale toggle with Accessibility toolbar', 'wp-accessibility' ); ?></label>
229
</li>
230
</ul>
231
</li>
@@ -391,6 +393,12 @@ function wpa_admin_menu() {
391
for="wpa_focus_color"><?php _e( 'Outline color (hexadecimal, optional)', 'wp-accessibility' ); ?></label><input
392
type="text" id="wpa_focus_color" name="wpa_focus_color"
393
value="#<?php esc_attr_e( get_option( 'wpa_focus_color' ) ); ?>"/></li>
394
</ul>
395
<p>
396
<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'wpa-nonce' ); ?>"/>
53
$wpa_tabindex = ( isset( $_POST['wpa_tabindex'] ) ) ? 'on' : '';
54
$wpa_underline = ( isset( $_POST['wpa_underline'] ) ) ? 'on' : '';
55
$wpa_longdesc = ( isset( $_POST['wpa_longdesc'] ) ) ? esc_attr( $_POST['wpa_longdesc'] ) : 'false';
56
+ $wpa_current_menu = ( isset( $_POST['wpa_current_menu'] ) ) ? esc_attr( $_POST['wpa_current_menu'] ) : '';
57
$wpa_longdesc_featured = ( isset( $_POST['wpa_longdesc_featured'] ) ) ? esc_attr( $_POST['wpa_longdesc_featured'] ) : 'false';
58
$wpa_image_titles = ( isset( $_POST['wpa_image_titles'] ) ) ? 'on' : '';
59
$wpa_more = ( isset( $_POST['wpa_more'] ) ) ? 'on' : '';
71
update_option( 'wpa_tabindex', $wpa_tabindex );
72
update_option( 'wpa_underline', $wpa_underline );
73
update_option( 'wpa_longdesc', $wpa_longdesc );
74
+ update_option( 'wpa_current_menu', $wpa_current_menu );
75
update_option( 'wpa_longdesc_featured', $wpa_longdesc_featured );
76
update_option( 'wpa_image_titles', $wpa_image_titles );
77
update_option( 'wpa_more', $wpa_more );
223
} ?>/> <label
224
for="wpa_toolbar_ct"><?php _e( 'Exclude contrast toggle from Accessibility toolbar', 'wp-accessibility' ); ?></label>
225
</li>
226
+ <li><input type="checkbox" aria-describedby="wpa_toolbar_gs_note" id="wpa_toolbar_gs"
227
name="wpa_toolbar_gs" <?php if ( get_option( 'wpa_toolbar_gs' ) == "on" ) {
228
echo 'checked="checked" ';
229
} ?>/> <label
230
+ for="wpa_toolbar_gs"><?php _e( 'Include grayscale toggle with Accessibility toolbar', 'wp-accessibility' ); ?></label><br /><em id="wpa_toolbar_gs_note"><?php _e( 'The grayscale toggle is only intended for testing, and will appear only for logged-in administrators', 'wp-accessibility' ); ?></em>
231
</li>
232
</ul>
233
</li>
393
for="wpa_focus_color"><?php _e( 'Outline color (hexadecimal, optional)', 'wp-accessibility' ); ?></label><input
394
type="text" id="wpa_focus_color" name="wpa_focus_color"
395
value="#<?php esc_attr_e( get_option( 'wpa_focus_color' ) ); ?>"/></li>
396
+ <li><input type="checkbox" id="wpa_current_menu"
397
+ name="wpa_current_menu" <?php if ( get_option( 'wpa_current_menu' ) == "on" ) {
398
+ echo 'checked="checked" ';
399
+ } ?>/> <label
400
+ for="wpa_current_menu"><?php _e( 'Non-visually identify currently active menu item', 'wp-accessibility' ); ?></label>
401
+ </li>
402
</ul>
403
<p>
404
<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'wpa-nonce' ); ?>"/>
wp-accessibility-toolbar.php CHANGED
@@ -1,26 +1,31 @@
1
<?php
2
3
add_shortcode( 'wpa_toolbar', 'wpa_toolbar_html' );
4
- function wpa_toolbar_html() {
5
$contrast = __( 'Toggle High Contrast', 'wp-accessibility' );
6
$grayscale = __( 'Toggle Grayscale', 'wp-accessibility' );
7
$fontsize = __( 'Toggle Font size', 'wp-accessibility' );
8
- $enable_grayscale = ( get_option( 'wpa_toolbar_gs' ) == 'on' ) ? true : false;
9
$enable_contrast = ( get_option( 'wpa_toolbar_ct' ) == 'off' ) ? false : true;
10
$enable_fontsize = ( get_option( 'wpa_toolbar_fs' ) == 'off' ) ? false : true;
11
$responsive = ( get_option( 'wpa_toolbar_mobile' ) == 'on' ) ? 'a11y-responsive ' : '';
12
$toolbar = '
13
<!-- a11y toolbar widget -->
14
- <div class="' . $responsive . 'a11y-toolbar-widget">
15
<ul>';
16
if ( $enable_contrast ) {
17
- $toolbar .= '<li><a href="#" class="a11y-toggle-contrast toggle-contrast" id="is_normal_contrast"><span class="offscreen">'.$contrast.'</span><span class="aticon aticon-adjust"></span></a></li>';
18
}
19
if ( $enable_grayscale ) {
20
- $toolbar .= '<li><a href="#" class="a11y-toggle-grayscale toggle-grayscale" id="is_normal_color"><span class="offscreen">'.$grayscale.'</span><span class="aticon aticon-tint"></span></a></li>';
21
}
22
if ( $enable_fontsize ) {
23
- $toolbar .= '<li><a href="#" class="a11y-toggle-fontsize toggle-fontsize" id="is_normal_fontsize"><span class="offscreen">'.$fontsize.'</span><span class="aticon aticon-font"></span></a></li>';
24
}
25
$toolbar .= '
26
</ul>
@@ -32,45 +37,58 @@ function wpa_toolbar_html() {
32
33
function wpa_toolbar_js() {
34
// Toolbar does not work on Edge. Disable unless I solve the issue.
35
- $user_agent = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? $_SERVER['HTTP_USER_AGENT'] : '';
36
- if ( preg_match( '/Edge/i', $user_agent ) ) {
37
- return;
38
- }
39
-
40
- $contrast = __( 'Toggle High Contrast', 'wp-accessibility' );
41
- $grayscale = __( 'Toggle Grayscale', 'wp-accessibility' );
42
- $fontsize = __( 'Toggle Font size', 'wp-accessibility' );
43
- $enable_grayscale = ( get_option( 'wpa_toolbar_gs' ) == 'on' ) ? true : false;
44
- $enable_fontsize = ( get_option( 'wpa_toolbar_fs' ) == 'off' ) ? false : true;
45
- $enable_contrast = ( get_option( 'wpa_toolbar_ct' ) == 'off' ) ? false : true;
46
$default = ( get_option( 'wpa_toolbar_default' ) != '' ) ? get_option( 'wpa_toolbar_default' ) : 'body';
47
$location = apply_filters( 'wpa_move_toolbar', $default );
48
$is_rtl = ( is_rtl() ) ? ' rtl' : ' ltr';
49
- $is_right = ( get_option( 'wpa_toolbar_right' ) == 'on' ) ? ' right' : '';
50
- $responsive = ( get_option( 'wpa_toolbar_mobile' ) == 'on' ) ? 'a11y-responsive' : '';
51
- echo
52
- "
53
- <script type='text/javascript'>
54
- //<![CDATA[
55
- (function( $ ) { 'use strict';
56
- var insert_a11y_toolbar = '<!-- a11y toolbar -->';
57
- insert_a11y_toolbar += '<div class=\"$responsive a11y-toolbar$is_rtl$is_right\">';
58
- insert_a11y_toolbar += '<ul class=\"a11y-toolbar-list\">';";
59
- if ( get_option( 'wpa_toolbar' ) == 'on' && $enable_contrast ) {
60
- 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>';";
61
- }
62
- if ( get_option( 'wpa_toolbar' ) == 'on' && $enable_grayscale ) {
63
- 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>';";
64
- }
65
- if ( get_option( 'wpa_toolbar' ) == 'on' && $enable_fontsize ) {
66
- 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>';";
67
}
68
- echo "
69
- insert_a11y_toolbar += '</ul>';
70
- insert_a11y_toolbar += '</div>';
71
- insert_a11y_toolbar += '<!-- // a11y toolbar -->';
72
- $( document ).find( '$location' ).prepend( insert_a11y_toolbar );
73
- }(jQuery));
74
- //]]>
75
- </script>";
76
}
1
<?php
2
3
add_shortcode( 'wpa_toolbar', 'wpa_toolbar_html' );
4
+ function wpa_toolbar_html( $type = 'widget' ) {
5
$contrast = __( 'Toggle High Contrast', 'wp-accessibility' );
6
$grayscale = __( 'Toggle Grayscale', 'wp-accessibility' );
7
$fontsize = __( 'Toggle Font size', 'wp-accessibility' );
8
+ $enable_grayscale = ( get_option( 'wpa_toolbar_gs' ) == 'on' && current_user_can( 'manage_options' ) ) ? true : false;
9
$enable_contrast = ( get_option( 'wpa_toolbar_ct' ) == 'off' ) ? false : true;
10
$enable_fontsize = ( get_option( 'wpa_toolbar_fs' ) == 'off' ) ? false : true;
11
$responsive = ( get_option( 'wpa_toolbar_mobile' ) == 'on' ) ? 'a11y-responsive ' : '';
12
+ $is_rtl = ( is_rtl() ) ? ' rtl' : ' ltr';
13
+ $is_right = ( get_option( 'wpa_toolbar_right' ) == 'on' ) ? ' right' : ' left';
14
+ $toolbar_type = ( $type == 'widget' ) ? 'a11y-toolbar-widget' : 'a11y-toolbar';
15
+ $control_type = ( $type == 'button' ) ? 'a href="#" role="button"' : 'button type="button"'; // button control does not work in Edge.
16
+ $closure = ( $type == 'button' ) ? 'a' : 'button'; // button control does not work in Edge
17
$toolbar = '
18
<!-- a11y toolbar widget -->
19
+ <div class="' . $responsive . ' ' . $is_rtl . ' ' . $is_right . ' ' . $toolbar_type . '">
20
<ul>';
21
if ( $enable_contrast ) {
22
+ $toolbar .= '<li><' . $control_type . ' 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></' . $closure . '></li>';
23
}
24
if ( $enable_grayscale ) {
25
+ $toolbar .= '<li><' . $control_type . ' 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></' . $closure . '></li>';
26
}
27
if ( $enable_fontsize ) {
28
+ $toolbar .= '<li><' . $control_type . ' 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></' . $closure . '></li>';
29
}
30
$toolbar .= '
31
</ul>
37
38
function wpa_toolbar_js() {
39
// Toolbar does not work on Edge. Disable unless I solve the issue.
40
$default = ( get_option( 'wpa_toolbar_default' ) != '' ) ? get_option( 'wpa_toolbar_default' ) : 'body';
41
$location = apply_filters( 'wpa_move_toolbar', $default );
42
+ $user_agent = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? $_SERVER['HTTP_USER_AGENT'] : '';
43
$is_rtl = ( is_rtl() ) ? ' rtl' : ' ltr';
44
+ $is_right = ( get_option( 'wpa_toolbar_right' ) == 'on' ) ? ' right' : ' left';
45
+ $responsive = ( get_option( 'wpa_toolbar_mobile' ) == 'on' ) ? 'a11y-responsive ' : 'a11y-non-responsive ';
46
+
47
+ if ( preg_match( '/Edge/i', $user_agent ) ) {
48
+ echo wpa_toolbar_html( 'button' );
49
+ echo "<script type='text/javascript'>
50
+ //<![CDATA[
51
+ (function( $ ) { 'use strict';
52
+ var toolbar = $( '.a11y-toolbar-widget' );
53
+ toolbar.removeClass( 'a11y-toolbar-widget' );
54
+ $( document ).find( '$location' ).prepend( toolbar );
55
+ }(jQuery));
56
+ //]]>
57
+ </script>";
58
+ } else {
59
+
60
+ $contrast = __( 'Toggle High Contrast', 'wp-accessibility' );
61
+ $grayscale = __( 'Toggle Grayscale', 'wp-accessibility' );
62
+ $fontsize = __( 'Toggle Font size', 'wp-accessibility' );
63
+ $enable_grayscale = ( get_option( 'wpa_toolbar_gs' ) == 'on' && current_user_can( 'manage_options' ) ) ? true : false;
64
+ $enable_fontsize = ( get_option( 'wpa_toolbar_fs' ) == 'off' ) ? false : true;
65
+ $enable_contrast = ( get_option( 'wpa_toolbar_ct' ) == 'off' ) ? false : true;
66
+
67
+
68
+ echo
69
+ "
70
+ <script type='text/javascript'>
71
+ //<![CDATA[
72
+ (function( $ ) { 'use strict';
73
+ var insert_a11y_toolbar = '<!-- a11y toolbar -->';
74
+ insert_a11y_toolbar += '<div class=\"" . $responsive . "a11y-toolbar$is_rtl$is_right\">';
75
+ insert_a11y_toolbar += '<ul class=\"a11y-toolbar-list\">';";
76
+ if ( get_option( 'wpa_toolbar' ) == 'on' && $enable_contrast ) {
77
+ 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>';";
78
+ }
79
+ if ( get_option( 'wpa_toolbar' ) == 'on' && $enable_grayscale ) {
80
+ 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>';";
81
+ }
82
+ if ( get_option( 'wpa_toolbar' ) == 'on' && $enable_fontsize ) {
83
+ 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>';";
84
+ }
85
+ echo "
86
+ insert_a11y_toolbar += '</ul>';
87
+ insert_a11y_toolbar += '</div>';
88
+ insert_a11y_toolbar += '<!-- // a11y toolbar -->';
89
+ $( document ).find( '$location' ).prepend( insert_a11y_toolbar );
90
+ }(jQuery));
91
+ //]]>
92
+ </script>";
93
}
94
}
wp-accessibility.php CHANGED
@@ -3,7 +3,7 @@
3
Plugin Name: WP Accessibility
4
Plugin URI: http://www.joedolson.com/wp-accessibility/
5
Description: Helps improve accessibility in your WordPress site, like removing title attributes.
6
- Version: 1.5.10
7
Author: Joe Dolson
8
Text Domain: wp-accessibility
9
Domain Path: /lang
@@ -63,7 +63,7 @@ function wpa_write_js() {
63
64
// ACTIVATION
65
function wpa_install() {
66
- $wpa_version = '1.5.10';
67
if ( get_option( 'wpa_installed' ) != 'true' ) {
68
add_option( 'rta_from_nav_menu', 'on' );
69
add_option( 'rta_from_page_lists', 'on' );
@@ -170,6 +170,9 @@ function wpacc_enqueue_scripts() {
170
if ( get_option( 'wpa_longdesc' ) == 'jquery' ) {
171
wp_enqueue_script( 'longdesc.button', plugins_url( 'js/longdesc.button.js', __FILE__ ), array( 'jquery' ), '1.0', true );
172
}
173
}
174
175
add_action( 'wp_enqueue_scripts', 'wpa_stylesheet' );
@@ -679,7 +682,7 @@ $plugins_string
679
if ( $has_donated == 'Donor' ) {
680
echo "<div class='message updated'><p>" . __( 'Thank you for supporting the continuing development of this plug-in! I\'ll get back to you as soon as I can.', 'wp-accessibility' ) . "</p></div>";
681
} else {
682
- echo "<div class='message updated'><p>" . __( 'I cannot provide support, but will treat your request as a bug report, and will incorporate any permanent solutions I discover into the plug-in.', 'wp-accessibility' ) . "</p></div>";
683
}
684
}
685
}
@@ -903,7 +906,7 @@ function wpa_media_value( $column, $id ) {
903
case 'image/jpeg':
904
case 'image/png':
905
case 'image/gif':
906
- $alt = get_post_meta( $id, '_wp_attachment_image_alt', true );
907
$no_alt = get_post_meta( $id, '_no_alt', true );
908
if ( !$alt && !$no_alt ) {
909
echo '<span class="missing"><span class="dashicons dashicons-no" aria-hidden="true"></span> <a href="'.get_edit_post_link( $id ).'#attachment_alt">'.__( 'Add <code>alt</code> text', 'wp-accessibility' ).'</a></span>';
3
Plugin Name: WP Accessibility
4
Plugin URI: http://www.joedolson.com/wp-accessibility/
5
Description: Helps improve accessibility in your WordPress site, like removing title attributes.
6
+ Version: 1.6.0
7
Author: Joe Dolson
8
Text Domain: wp-accessibility
9
Domain Path: /lang
63
64
// ACTIVATION
65
function wpa_install() {
66
+ $wpa_version = '1.6.0';
67
if ( get_option( 'wpa_installed' ) != 'true' ) {
68
add_option( 'rta_from_nav_menu', 'on' );
69
add_option( 'rta_from_page_lists', 'on' );
170
if ( get_option( 'wpa_longdesc' ) == 'jquery' ) {
171
wp_enqueue_script( 'longdesc.button', plugins_url( 'js/longdesc.button.js', __FILE__ ), array( 'jquery' ), '1.0', true );
172
}
173
+ if ( get_option( 'wpa_current_menu' ) == 'on' ) {
174
+ wp_enqueue_script( 'current.menu', plugins_url( 'js/current-menu-item.js', __FILE__ ), array( 'jquery' ), '1.0', true );
175
+ }
176
}
177
178
add_action( 'wp_enqueue_scripts', 'wpa_stylesheet' );
682
if ( $has_donated == 'Donor' ) {
683
echo "<div class='message updated'><p>" . __( 'Thank you for supporting the continuing development of this plug-in! I\'ll get back to you as soon as I can.', 'wp-accessibility' ) . "</p></div>";
684
} else {
685
+ echo "<div class='message updated'><p>" . __( 'I cannot provide support, but will treat your request as a bug report, and will incorporate any permanent solutions I discover into the plug-in.', 'wp-accessibility' ) . "</p></div>";
686
}
687
}
688
}
906
case 'image/jpeg':
907
case 'image/png':
908
case 'image/gif':
909
+ $alt = get_post_meta( $id, '_wp_attachment_image_alt', true );
910
$no_alt = get_post_meta( $id, '_no_alt', true );
911
if ( !$alt && !$no_alt ) {
912
echo '<span class="missing"><span class="dashicons dashicons-no" aria-hidden="true"></span> <a href="'.get_edit_post_link( $id ).'#attachment_alt">'.__( 'Add <code>alt</code> text', 'wp-accessibility' ).'</a></span>';