WP Accessibility - Version 1.9.1

Version Description

  • Bug fix: Duplicate skiplink styles: if custom styles used, default settings could be appended to them as a duplicate.
  • Filters: Add filters to configure deprecated skiplinks if necessary.
  • Show default CSS when enabled for reference.
Download this release

Release Info

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

Code changes from version 1.9.0 to 1.9.1

css/wpa-styles.css CHANGED
@@ -4,6 +4,10 @@
4
  grid-template-columns: 70% 1fr;
5
  }
6
 
 
 
 
 
7
  .wpa-settings-wrapper .inside h3 {
8
  font-size: 1.1em;
9
  margin: 0;
4
  grid-template-columns: 70% 1fr;
5
  }
6
 
7
+ .wpa-settings-wrapper .button-secondary .dashicons {
8
+ vertical-align: text-bottom;
9
+ }
10
+
11
  .wpa-settings-wrapper .inside h3 {
12
  font-size: 1.1em;
13
  margin: 0;
js/color-picker.js CHANGED
@@ -1,3 +1,35 @@
1
  jQuery(document).ready(function ($) {
2
  $('.wpa-color-input').wpColorPicker();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  });
1
  jQuery(document).ready(function ($) {
2
  $('.wpa-color-input').wpColorPicker();
3
+
4
+ var default_css = document.getElementById( 'wpa_default_css' );
5
+ if ( null !== default_css ) {
6
+
7
+ default_css.style.display = 'none';
8
+
9
+ var button = document.createElement( 'button' );
10
+ button.type = 'button';
11
+ button.innerHTML = 'Show Default CSS <span class="dashicons dashicons-arrow-right" aria-hidden="true"></span>';
12
+ button.className = 'toggle-css button-secondary';
13
+ button.setAttribute( 'aria-controls', 'wpa_default_css' );
14
+ button.setAttribute( 'aria-expanded', false );
15
+ default_css.insertAdjacentElement( 'beforebegin', button );
16
+
17
+ var wpa_button = document.querySelector( 'button.toggle-css' );
18
+ wpa_button.addEventListener( 'click', function() {
19
+ var target = this.getAttribute( 'aria-controls' );
20
+ var css = document.getElementById( target );
21
+ var visible = ( css.style['display'] == 'none' ) ? false : true;
22
+ if ( ! visible ) {
23
+ css.style.display = 'block';
24
+ this.setAttribute( 'aria-expanded', true );
25
+ this.querySelector( '.dashicons' ).classList.add( 'dashicons-arrow-down' );
26
+ this.querySelector( '.dashicons' ).classList.remove( 'dashicons-arrow-right' );
27
+ } else {
28
+ css.style.display = 'none';
29
+ this.setAttribute( 'aria-expanded', false );
30
+ this.querySelector( '.dashicons' ).classList.remove( 'dashicons-arrow-down' );
31
+ this.querySelector( '.dashicons' ).classList.add( 'dashicons-arrow-right' );
32
+ }
33
+ });
34
+ }
35
  });
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: title, accessibility, accessible, navigation, wcag, a11y, section508, focu
5
  Requires at least: 3.4.2
6
  Requires PHP: 5.6
7
  Tested up to: 6.0
8
- Stable tag: 1.9.0
9
  Text Domain: wp-accessibility
10
  License: GPLv2 or later
11
 
@@ -76,6 +76,12 @@ 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.0 =
80
 
81
  * Update: Significant reorganization of settings.
5
  Requires at least: 3.4.2
6
  Requires PHP: 5.6
7
  Tested up to: 6.0
8
+ Stable tag: 1.9.1
9
  Text Domain: wp-accessibility
10
  License: GPLv2 or later
11
 
76
 
77
  [Suggest a change!](https://github.com/joedolson/wp-accessibility/issues/)
78
 
79
+ = 1.9.1 =
80
+
81
+ * Bug fix: Duplicate skiplink styles: if custom styles used, default settings could be appended to them as a duplicate.
82
+ * Filters: Add filters to configure deprecated skiplinks if necessary.
83
+ * Show default CSS when enabled for reference.
84
+
85
  = 1.9.0 =
86
 
87
  * Update: Significant reorganization of settings.
wp-accessibility-settings.php CHANGED
@@ -23,7 +23,7 @@ function wpa_admin_styles() {
23
  wp_enqueue_style( 'wpa-styles', plugins_url( 'css/wpa-styles.css', __FILE__ ), array( 'farbtastic' ), $version );
24
  wp_enqueue_style( 'wp-color-picker' );
25
  // Switch to wp_add_inline_script when no longer supporting WP 4.4.x.
26
- wp_enqueue_script( 'wpa-color-picker', plugins_url( 'js/color-picker.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
27
  }
28
  }
29
 
@@ -204,19 +204,37 @@ function wpa_admin_settings() {
204
  <input type="text" id="asl_navigation" name="asl_navigation" placeholder="#" size="30" aria-describedby="asl_navigation_description" value="<?php echo esc_attr( get_option( 'asl_navigation' ) ); ?>"/> <span id="asl_navigation_description"><?php _e( 'ID attribute starting with <code>#</code>', 'wp-accessibility' ); ?></span>
205
  </li>
206
  <?php
207
- if ( '' !== get_option( 'asl_sitemap', '' ) ) {
 
 
 
 
 
 
 
 
 
208
  ?>
209
  <li>
210
  <label for="asl_sitemap"><?php _e( 'Site Map link target (URL for your site map)', 'wp-accessibility' ); ?></label><br />
211
- <input type="text" id="asl_sitemap" name="asl_sitemap" size="44" value="<?php echo esc_attr( get_option( 'asl_sitemap' ) ); ?>"/>
212
  </li>
213
  <?php
214
  }
215
- if ( '' !== get_option( 'asl_extra_target', '' ) ) {
 
 
 
 
 
 
 
 
 
216
  ?>
217
  <li>
218
  <label for="asl_extra_target"><?php _e( 'Add your own link (link or container ID)', 'wp-accessibility' ); ?></label><br />
219
- <input type="text" id="asl_extra_target" name="asl_extra_target" size="44" value="<?php echo esc_attr( get_option( 'asl_extra_target' ) ); ?>"/>
220
  </li>
221
  <li>
222
  <label for="asl_extra_text"><?php _e( 'Link text for your link', 'wp-accessibility' ); ?></label><br />
@@ -239,6 +257,9 @@ function wpa_admin_settings() {
239
  <textarea name='asl_styles' id='asl_styles' cols='60' rows='4'><?php echo esc_textarea( stripcslashes( $styles ) ); ?></textarea>
240
  </li>
241
  <?php
 
 
 
242
  }
243
  ?>
244
  </ul>
23
  wp_enqueue_style( 'wpa-styles', plugins_url( 'css/wpa-styles.css', __FILE__ ), array( 'farbtastic' ), $version );
24
  wp_enqueue_style( 'wp-color-picker' );
25
  // Switch to wp_add_inline_script when no longer supporting WP 4.4.x.
26
+ wp_enqueue_script( 'wpa-color-picker', plugins_url( 'js/color-picker.js', __FILE__ ), array( 'wp-color-picker' ), $version, true );
27
  }
28
  }
29
 
204
  <input type="text" id="asl_navigation" name="asl_navigation" placeholder="#" size="30" aria-describedby="asl_navigation_description" value="<?php echo esc_attr( get_option( 'asl_navigation' ) ); ?>"/> <span id="asl_navigation_description"><?php _e( 'ID attribute starting with <code>#</code>', 'wp-accessibility' ); ?></span>
205
  </li>
206
  <?php
207
+ /**
208
+ * Customize the default value for sitemap skiplink. Turns on sitemap skiplink options in WP Accessibility versions > 1.9.0.
209
+ *
210
+ * @hook asl_sitemap
211
+ * @param {string} Value to use as a default for the sitemap.
212
+ *
213
+ * @return {string}
214
+ */
215
+ $default_sitemap = apply_filters( 'asl_sitemap', '' );
216
+ if ( '' !== get_option( 'asl_sitemap', $default_sitemap ) ) {
217
  ?>
218
  <li>
219
  <label for="asl_sitemap"><?php _e( 'Site Map link target (URL for your site map)', 'wp-accessibility' ); ?></label><br />
220
+ <input type="text" id="asl_sitemap" name="asl_sitemap" size="44" value="<?php echo esc_attr( get_option( 'asl_sitemap', $default_sitemap ) ); ?>"/>
221
  </li>
222
  <?php
223
  }
224
+ /**
225
+ * Customize the default value for extra skiplink. Turns on extra skiplink options in WP Accessibility versions > 1.9.0.
226
+ *
227
+ * @hook asl_extra_target
228
+ * @param {string} Value to use as a default for the extra skiplink target.
229
+ *
230
+ * @return {string}
231
+ */
232
+ $default_extra = apply_filters( 'asl_extra_target', '' );
233
+ if ( '' !== get_option( 'asl_extra_target', $default_extra ) ) {
234
  ?>
235
  <li>
236
  <label for="asl_extra_target"><?php _e( 'Add your own link (link or container ID)', 'wp-accessibility' ); ?></label><br />
237
+ <input type="text" id="asl_extra_target" name="asl_extra_target" size="44" value="<?php echo esc_attr( get_option( 'asl_extra_target', $default_extra ) ); ?>"/>
238
  </li>
239
  <li>
240
  <label for="asl_extra_text"><?php _e( 'Link text for your link', 'wp-accessibility' ); ?></label><br />
257
  <textarea name='asl_styles' id='asl_styles' cols='60' rows='4'><?php echo esc_textarea( stripcslashes( $styles ) ); ?></textarea>
258
  </li>
259
  <?php
260
+ } else {
261
+ $styles = wpa_skiplink_css( true );
262
+ echo '<pre id="wpa_default_css">' . esc_html( stripcslashes( $styles ) ) . '</pre>';
263
  }
264
  ?>
265
  </ul>
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.0
21
  */
22
 
23
  /*
@@ -70,7 +70,7 @@ function wpa_admin_menu() {
70
  * Install on activation.
71
  */
72
  function wpa_install() {
73
- $wpa_version = '1.9.0';
74
  if ( 'true' !== get_option( 'wpa_installed' ) ) {
75
  add_option( 'rta_from_tag_clouds', 'on' );
76
  add_option( 'asl_styles_focus', '' );
@@ -228,26 +228,38 @@ function wpa_admin_stylesheet() {
228
  /**
229
  * Generate skiplink CSS.
230
  *
 
 
231
  * @return string
232
  */
233
- function wpa_skiplink_css() {
234
  $use_defaults = get_option( 'asl_default_styles', '' );
235
  $styles = '';
236
  $focus = '';
237
  $passive = '';
238
- if ( 'true' !== $use_defaults ) {
 
 
 
 
 
 
 
239
  if ( '' !== get_option( 'asl_styles' ) ) {
240
  $styles = wp_filter_nohtml_kses( get_option( 'asl_styles' ) );
 
 
 
 
 
 
241
  } else {
242
  $focus = wp_filter_nohtml_kses( get_option( 'asl_styles_focus' ) );
243
  $passive = wp_filter_nohtml_kses( get_option( 'asl_styles_passive' ) );
244
  }
245
- }
246
- if ( is_admin() && '' !== $styles ) {
247
- return $styles;
248
- }
249
- // these styles are derived from the WordPress skip link defaults.
250
- $default_focus = 'background-color: #f1f1f1;
251
  box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
252
  clip: auto;
253
  color: #0073aa;
@@ -263,13 +275,9 @@ function wpa_skiplink_css() {
263
  text-transform: none;
264
  width: auto;
265
  z-index: 100000;';
266
- if ( ! $focus ) {
267
- $focus = $default_focus;
268
- } else {
269
- $focus = $default_focus . $focus;
270
- }
271
- // Passive default styles derived from WordPress default focus styles.
272
- $default_passive = 'background-color: #fff;
273
  box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.2);
274
  clip: auto;
275
  color: #333;
@@ -285,13 +293,20 @@ function wpa_skiplink_css() {
285
  text-transform: none;
286
  width: auto;
287
  z-index: 100000;';
 
 
 
 
 
 
 
 
 
 
288
 
289
  $vis = '';
290
  $invis = '';
291
-
292
- $visibility = ( 'on' === get_option( 'asl_visible' ) ) ? 'wpa-visible' : 'wpa-hide';
293
- $is_rtl = ( is_rtl() ) ? '-rtl' : '-ltr';
294
- $class = '.' . $visibility . $is_rtl;
295
  // If links are visible, "hover" is a focus style, otherwise, it's a passive style.
296
  if ( 'on' === get_option( 'asl_visible' ) ) {
297
  $vis = $class . '#skiplinks a:hover,';
@@ -349,23 +364,40 @@ function wpa_jquery_asl() {
349
  $output = '';
350
  if ( 'on' === get_option( 'asl_enable' ) ) {
351
  $html = '';
352
- // Build skiplinks.
353
- $extra = (string) get_option( 'asl_extra_target' );
354
- $extra = ( wpa_is_url( $extra ) ) ? esc_url( $extra ) : str_replace( '#', '', esc_attr( $extra ) );
 
 
 
 
 
 
 
 
355
  if ( '' !== $extra && ! wpa_is_url( $extra ) ) {
356
  $extra = "#$extra";
357
  }
358
  $extra_text = (string) stripslashes( get_option( 'asl_extra_text' ) );
359
  $content = str_replace( '#', '', esc_attr( get_option( 'asl_content' ) ) );
360
  $nav = str_replace( '#', '', esc_attr( get_option( 'asl_navigation' ) ) );
361
- $sitemap = esc_url( get_option( 'asl_sitemap' ) );
362
- $html .= ( '' !== $content ) ? "<a href=\"#$content\" class='no-scroll'>" . __( 'Skip to Content', 'wp-accessibility' ) . '</a> ' : '';
363
- $html .= ( '' !== $nav ) ? "<a href=\"#$nav\" class='no-scroll'>" . __( 'Skip to navigation', 'wp-accessibility' ) . '</a> ' : '';
364
- $html .= ( '' !== $sitemap ) ? "<a href=\"$sitemap\" class='no-scroll'>" . __( 'Site map', 'wp-accessibility' ) . '</a> ' : '';
365
- $html .= ( '' !== $extra && '' !== $extra_text ) ? "<a href=\"$extra\" class='no-scroll'>$extra_text</a> " : '';
366
- $is_rtl = ( is_rtl() ) ? '-rtl' : '-ltr';
367
- $skiplinks = __( 'Skip links', 'wp-accessibility' );
368
- $output = ( '' !== $html ) ? "<div class=\"$visibility$is_rtl\" id=\"skiplinks\" role=\"navigation\" aria-label=\"" . esc_attr( $skiplinks ) . "\">$html</div>" : '';
 
 
 
 
 
 
 
 
 
369
  }
370
 
371
  wp_enqueue_script( 'wp-accessibility', plugins_url( 'js/wp-accessibility.js', __FILE__ ), array( 'jquery' ), '1.0.3', true );
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.1
21
  */
22
 
23
  /*
70
  * Install on activation.
71
  */
72
  function wpa_install() {
73
+ $wpa_version = '1.9.1';
74
  if ( 'true' !== get_option( 'wpa_installed' ) ) {
75
  add_option( 'rta_from_tag_clouds', 'on' );
76
  add_option( 'asl_styles_focus', '' );
228
  /**
229
  * Generate skiplink CSS.
230
  *
231
+ * @param bool $defaults 'true' to return defaults regardless of settings.
232
+ *
233
  * @return string
234
  */
235
+ function wpa_skiplink_css( $defaults = false ) {
236
  $use_defaults = get_option( 'asl_default_styles', '' );
237
  $styles = '';
238
  $focus = '';
239
  $passive = '';
240
+ $visibility = ( 'on' === get_option( 'asl_visible' ) ) ? 'wpa-visible' : 'wpa-hide';
241
+ $is_rtl = ( is_rtl() ) ? '-rtl' : '-ltr';
242
+ $off_vis = ( 'on' === get_option( 'asl_visible' ) ) ? 'wpa-hide' : 'wpa-visible';
243
+ $off_rtl = ( is_rtl() ) ? '-ltr' : '-rtl';
244
+ // If not using default styles.
245
+ if ( 'true' !== $use_defaults && ! $defaults ) {
246
+ $default_focus = '';
247
+ $default_passive = '';
248
  if ( '' !== get_option( 'asl_styles' ) ) {
249
  $styles = wp_filter_nohtml_kses( get_option( 'asl_styles' ) );
250
+ // Ensure custom styles match settings.
251
+ $styles = str_replace( array( $off_vis, $off_rtl ), array( $visibility, $is_rtl ), $styles );
252
+ // If custom styles contain #skiplinks, we can just return this; it's probably a fully realized selector.
253
+ if ( false !== stripos( $styles, '#skiplinks' ) ) {
254
+ return $styles;
255
+ }
256
  } else {
257
  $focus = wp_filter_nohtml_kses( get_option( 'asl_styles_focus' ) );
258
  $passive = wp_filter_nohtml_kses( get_option( 'asl_styles_passive' ) );
259
  }
260
+ } else {
261
+ // these styles are derived from the WordPress skip link defaults.
262
+ $default_focus = 'background-color: #f1f1f1;
 
 
 
263
  box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
264
  clip: auto;
265
  color: #0073aa;
275
  text-transform: none;
276
  width: auto;
277
  z-index: 100000;';
278
+
279
+ // Passive default styles derived from WordPress default focus styles.
280
+ $default_passive = 'background-color: #fff;
 
 
 
 
281
  box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.2);
282
  clip: auto;
283
  color: #333;
293
  text-transform: none;
294
  width: auto;
295
  z-index: 100000;';
296
+ }
297
+ if ( is_admin() && '' !== $styles ) {
298
+ return $styles;
299
+ }
300
+
301
+ if ( ! $focus ) {
302
+ $focus = $default_focus;
303
+ } else {
304
+ $focus = $default_focus . $focus;
305
+ }
306
 
307
  $vis = '';
308
  $invis = '';
309
+ $class = '.' . $visibility . $is_rtl;
 
 
 
310
  // If links are visible, "hover" is a focus style, otherwise, it's a passive style.
311
  if ( 'on' === get_option( 'asl_visible' ) ) {
312
  $vis = $class . '#skiplinks a:hover,';
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.
369
+ *
370
+ * @hook asl_extra_target
371
+ * @param {string} Value to use as a default for the extra skiplink.
372
+ *
373
+ * @return {string}
374
+ */
375
+ $default_extra = apply_filters( 'asl_extra_target', '' );
376
+ $extra = get_option( 'asl_extra_target', $default_extra );
377
+ $extra = ( wpa_is_url( $extra ) ) ? esc_url( $extra ) : str_replace( '#', '', esc_attr( $extra ) );
378
  if ( '' !== $extra && ! wpa_is_url( $extra ) ) {
379
  $extra = "#$extra";
380
  }
381
  $extra_text = (string) stripslashes( get_option( 'asl_extra_text' ) );
382
  $content = str_replace( '#', '', esc_attr( get_option( 'asl_content' ) ) );
383
  $nav = str_replace( '#', '', esc_attr( get_option( 'asl_navigation' ) ) );
384
+ /**
385
+ * Customize the default value for sitemap skiplink. Turns on sitemap skiplink options in WP Accessibility versions > 1.9.0.
386
+ *
387
+ * @hook asl_sitemap
388
+ * @param {string} Value to use as a default for the sitemap.
389
+ *
390
+ * @return {string}
391
+ */
392
+ $default_sitemap = apply_filters( 'asl_sitemap', '' );
393
+ $sitemap = esc_url( get_option( 'asl_sitemap', $default_sitemap ) );
394
+ $html .= ( '' !== $content ) ? "<a href=\"#$content\" class='no-scroll'>" . __( 'Skip to Content', 'wp-accessibility' ) . '</a> ' : '';
395
+ $html .= ( '' !== $nav ) ? "<a href=\"#$nav\" class='no-scroll'>" . __( 'Skip to navigation', 'wp-accessibility' ) . '</a> ' : '';
396
+ $html .= ( '' !== $sitemap ) ? "<a href=\"$sitemap\" class='no-scroll'>" . __( 'Site map', 'wp-accessibility' ) . '</a> ' : '';
397
+ $html .= ( '' !== $extra && '' !== $extra_text ) ? "<a href=\"$extra\" class='no-scroll'>$extra_text</a> " : '';
398
+ $is_rtl = ( is_rtl() ) ? '-rtl' : '-ltr';
399
+ $skiplinks = __( 'Skip links', 'wp-accessibility' );
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 );