WP Accessibility - Version 1.3.0

Version Description

  • Add long description support. Requested by John Foliot; based on http://wordpress.org/plugins/long-description-for-image-attachments/
Download this release

Release Info

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

Code changes from version 1.2.9 to 1.3.0

js/longdesc.button.js ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function( $ ) { 'use strict';
2
+ $('img[longdesc]').each(function(){
3
+ var longdesc = $(this).attr('longdesc');
4
+ var text = '<span>Long Description</span>';
5
+ var classes = $(this).attr('class');
6
+ $(this).attr( 'class', '' );
7
+ $(this).wrap('<div class="wpa-ld" />')
8
+ $(this).parent('.wpa-ld').addClass( classes );
9
+ $(this).parent('.wpa-ld').append('<div class="longdesc" aria-live="assertive"></div>'); // better supported
10
+ $(this).parent('.wpa-ld').append('<button>'+text+'</button>');
11
+ $(this).parent('.wpa-ld').children('.longdesc').hide();
12
+ $(this).parent('.wpa-ld').children('.longdesc').load( longdesc + ' #desc');
13
+ $(this).parent('.wpa-ld').children('button').toggle( function() {
14
+ $(this).parent('.wpa-ld').children('.longdesc').show( 150 );
15
+ }, function() {
16
+ $(this).parent('.wpa-ld').children('.longdesc').hide();
17
+ });
18
+ });
19
+ }(jQuery));
20
+
js/longdesc.link.js ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ (function( $ ) { 'use strict';
2
+ $('img[longdesc]').each(function(){
3
+ var longdesc = $(this).attr('longdesc');
4
+ var alt = $(this).attr('alt');
5
+ var classes = $(this).attr('class');
6
+ $(this).wrap('<div class="wpa-ld" />');
7
+ $(this).parent('.wpa-ld').addClass( classes );
8
+ $(this).attr( 'alt', '' ).attr( 'class', '' );
9
+ $(this).parent('.wpa-ld').append('<a href="' + longdesc + '" class="longdesc-link">Description<span> of'+alt+'</span></a>');
10
+ });
11
+ }(jQuery));
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.joedolson.com/donate.php
4
  Tags: title, accessibility, accessible, navigation, wcag, a11y, section508, focus
5
  Requires at least: 3.4.2
6
  Tested up to: 3.8.1
7
- Stable tag: 1.2.8
8
  License: GPLv2 or later
9
 
10
  WP Accessibility provides fixes for common accessibility issues in your WordPress site.
@@ -22,6 +22,7 @@ Accessibility Features added by WP Accessibility:
22
  * Add language and text direction attributes to your HTML attribute
23
  * Add an outline to the keyboard focus state for focusable elements.
24
  * Add a toolbar toggling between high contrast, large print, and desaturated (grayscale) views of your theme.
 
25
 
26
  Accessibility Issues fixed by WP Accessibility:
27
 
@@ -57,6 +58,10 @@ Visit the [WP Accessibility translations site](http://translate.joedolson.com/pr
57
 
58
  == Changelog ==
59
 
 
 
 
 
60
  = 1.2.9 =
61
 
62
  * Bug fix: :focus states for skiplinks broken in 1.2.8.
@@ -171,4 +176,4 @@ Even if WP Accessibility is running correctly, not all accessibility testing too
171
 
172
  == Upgrade Notice ==
173
 
174
- * 1.2.4: Added diagnostic CSS, visible logout link.
4
  Tags: title, accessibility, accessible, navigation, wcag, a11y, section508, focus
5
  Requires at least: 3.4.2
6
  Tested up to: 3.8.1
7
+ Stable tag: 1.2.9
8
  License: GPLv2 or later
9
 
10
  WP Accessibility provides fixes for common accessibility issues in your WordPress site.
22
  * Add language and text direction attributes to your HTML attribute
23
  * Add an outline to the keyboard focus state for focusable elements.
24
  * Add a toolbar toggling between high contrast, large print, and desaturated (grayscale) views of your theme.
25
+ * Add a long description to images. Use the image's "Description" field to add long descriptions.
26
 
27
  Accessibility Issues fixed by WP Accessibility:
28
 
58
 
59
  == Changelog ==
60
 
61
+ = 1.3.0 =
62
+
63
+ * Add long description support. Requested by John Foliot; based on http://wordpress.org/plugins/long-description-for-image-attachments/
64
+
65
  = 1.2.9 =
66
 
67
  * Bug fix: :focus states for skiplinks broken in 1.2.8.
176
 
177
  == Upgrade Notice ==
178
 
179
+ * 1.3.0 Supports longdesc attribute on images. Adds scripted UI for longdesc.
templates/longdesc-template.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * The goal for this template is to provide the simplest possible interface to view the long description.
4
+ * If you replace the template, I recommend against including your peripheral design, such as navigation.
5
+ * The purpose of the long description is to get the description and return to your previous context.
6
+ */
7
+ ?>
8
+ <!DOCTYPE html>
9
+ <html <?php language_attributes(); ?>>
10
+ <head>
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">
18
+ <div id="desc">
19
+ <?php the_content(); ?>
20
+ </div>
21
+ <?php
22
+ if( isset( $_GET['referrer'] ) ) {
23
+ $uri = get_permalink( (int) $_GET['referrer'] );
24
+ if( !empty( $uri ) ) {
25
+ $uri.= '#' . longdesc_return_anchor( get_the_ID() );
26
+ print '<p><a href="' . esc_url( $uri ) . '">' .esc_html__( 'Return to article.', 'longdesc' ) . '</a></p>';
27
+ }
28
+ }
29
+ ?>
30
+ </div>
31
+ </body>
32
+ </html>
uninstall.php CHANGED
@@ -29,4 +29,5 @@ if ( !defined( 'ABSPATH' ) && !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
29
  delete_option( 'wpa_continue' );
30
  delete_option( 'wpa_toolbar' );
31
  delete_option( 'wpa_diagnostics' );
 
32
  }
29
  delete_option( 'wpa_continue' );
30
  delete_option( 'wpa_toolbar' );
31
  delete_option( 'wpa_diagnostics' );
32
+ delete_option( 'wpa_longdesc' );
33
  }
wp-accessibility.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Accessibility
4
  Plugin URI: http://www.joedolson.com/articles/wp-accessibility/
5
  Description: Provides options to improve accessibility in your WordPress site, including removing title attributes.
6
- Version: 1.2.9
7
  Author: Joe Dolson
8
  Author URI: http://www.joedolson.com/
9
 
@@ -36,7 +36,7 @@ function add_wpa_admin_menu() {
36
 
37
  // ACTIVATION
38
  function wpa_install() {
39
- $wpa_version = '1.2.9';
40
  if ( get_option('wpa_installed') != 'true' ) {
41
  add_option('rta_from_nav_menu', 'on');
42
  add_option('rta_from_page_lists', 'on');
@@ -54,7 +54,8 @@ function wpa_install() {
54
  add_option('wpa_continue','Continue Reading');
55
  add_option('wpa_focus','');
56
  add_option( 'wpa_installed', 'true' );
57
- add_option( 'wpa_version', $version );
 
58
  } else {
59
  wpa_check_version();
60
  update_option( 'wpa_version', $version );
@@ -62,7 +63,10 @@ function wpa_install() {
62
  }
63
 
64
  function wpa_check_version() {
65
- return true; // not needed yet
 
 
 
66
  }
67
 
68
  function wpa_plugin_action($links, $file) {
@@ -129,10 +133,7 @@ function wpa_register_scripts() {
129
  wp_register_script( 'scrollTo', plugins_url( 'wp-accessibility/toolbar/js/jquery.scrollto.min.js' ), array( 'jquery' ), '1.4.5', true );
130
  }
131
 
132
- if ( get_option( 'asl_enable') == 'on' ) {
133
- // insert skiplinks into DOM via jQuery
134
- add_action( 'wp_footer', 'wpa_jquery_asl' );
135
- }
136
  if ( get_option( 'wpa_toolbar' ) == 'on' || get_option( 'wpa_widget_toolbar' ) == 'on' ) {
137
  add_action( 'wp_footer', 'wpa_path_a11y' );
138
  }
@@ -165,6 +166,12 @@ function wpa_enqueue_scripts() {
165
  if ( get_option( 'wpa_toolbar' ) == 'on' ) {
166
  add_action( 'wp_footer','wpa_toolbar_js');
167
  }
 
 
 
 
 
 
168
  }
169
 
170
  add_action('widgets_init', create_function('', 'return register_widget("wp_accessibility_toolbar");') );
@@ -266,7 +273,8 @@ function wpa_is_url($url) {
266
  return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url);
267
  }
268
 
269
- function wpa_jquery_asl() {
 
270
  $content = str_replace( '#','',esc_attr( get_option('asl_content') ) );
271
  $visibility = ( get_option( 'asl_visible' ) == 'on' )?'wpa-visible':'wpa-hide';
272
  $nav = str_replace( '#','',esc_attr( get_option('asl_navigation') ) );
@@ -283,15 +291,17 @@ function wpa_jquery_asl() {
283
  $html .= ( $extra != '' && $extra_text != '' )?"<a href=\"$extra\">$extra_text</a> ":'';
284
  $is_rtl = ( is_rtl() ) ? '-rtl' : '-ltr' ;
285
  $output = ($html != '')?"<div class=\"$visibility$is_rtl\" id=\"skiplinks\" role=\"navigation\">$html</div>":'';
286
- $skiplinks_js = ( $output )?"$('body').prepend('$output');":'';
287
  // attach language to html element
288
  $lang = ( get_option( 'wpa_lang' ) == 'on' )?get_bloginfo('language'):false;
289
  $dir = ( get_option( 'wpa_lang' ) == 'on' )?get_bloginfo('text_direction'):false;
290
- $lang_js = "$('html').attr('lang','$lang'); $('html').attr('dir','$dir')";
291
  // force links to open in the same window
292
  $targets = ( get_option( 'wpa_target' ) == 'on' )?"$('a').removeAttr('target');":'';
293
  $tabindex = ( get_option( 'wpa_tabindex') == 'on' )?"$('input,a,select,textarea,button').removeAttr('tabindex');":'';
294
- if ( $output || $lang ) {
 
 
295
  $script = "
296
  <script>
297
  //<![CDATA[
@@ -498,6 +508,7 @@ function wpa_update_settings() {
498
  $wpa_target = ( isset( $_POST['wpa_target'] ) )?'on':'';
499
  $wpa_search = ( isset( $_POST['wpa_search'] ) )?'on':'';
500
  $wpa_tabindex = ( isset ( $_POST['wpa_tabindex'] ) )?'on':'';
 
501
  $wpa_image_titles = ( isset ( $_POST['wpa_image_titles'] ) )?'on':'';
502
  $wpa_more = ( isset ( $_POST['wpa_more'] ) )?'on':'';
503
  $wpa_focus = ( isset ( $_POST['wpa_focus'] ) )?'on':'';
@@ -513,6 +524,7 @@ function wpa_update_settings() {
513
  update_option('wpa_target', $wpa_target );
514
  update_option('wpa_search', $wpa_search );
515
  update_option('wpa_tabindex', $wpa_tabindex );
 
516
  update_option('wpa_image_titles', $wpa_image_titles );
517
  update_option('wpa_more', $wpa_more );
518
  update_option('wpa_focus', $wpa_focus );
@@ -676,6 +688,12 @@ function wpa_admin_menu() { ?>
676
  <li><input type="checkbox" id="wpa_target" name="wpa_target" <?php if ( get_option('wpa_target') == "on") { echo 'checked="checked" '; } ?>/> <label for="wpa_target"><?php _e('Remove target attribute from links','wp-accessibility'); ?></label></li>
677
  <li><input type="checkbox" id="wpa_search" name="wpa_search" <?php if ( get_option('wpa_search') == "on") { echo 'checked="checked" '; } ?>/> <label for="wpa_search"><?php _e('Force search error on empty search submission (theme must have search.php template)','wp-accessibility'); ?></label></li>
678
  <li><input type="checkbox" id="wpa_tabindex" name="wpa_tabindex" <?php if ( get_option('wpa_tabindex') == "on") { echo 'checked="checked" '; } ?>/> <label for="wpa_tabindex"><?php _e('Remove tabindex from focusable elements','wp-accessibility'); ?></label></li>
 
 
 
 
 
 
679
  <li><input type="checkbox" id="wpa_admin_css" name="wpa_admin_css" <?php if ( get_option('wpa_admin_css') == "on") { echo 'checked="checked" '; } ?>/> <label for="wpa_admin_css"><?php _e('Enable WordPress Admin stylesheet','wp-accessibility'); ?></label></li>
680
  <li><input type="checkbox" id="wpa_row_actions" name="wpa_row_actions" <?php if ( get_option('wpa_row_actions') == "on") { echo 'checked="checked" '; } ?>/> <label for="wpa_row_actions"><?php _e('Make row actions always visible','wp-accessibility'); ?></label></li>
681
  <li><input type="checkbox" id="wpa_image_titles" name="wpa_image_titles" <?php if ( get_option('wpa_image_titles') == "on") { echo 'checked="checked" '; } ?>/> <label for="wpa_image_titles"><?php _e('Remove title attribute from images inserted into post content and featured images.','wp-accessibility'); ?></label></li>
@@ -819,6 +837,7 @@ if ( $l_contrast ) {
819
  <li><a href="http://accessites.org/site/2008/11/wordpress-and-accessibility/#comment-2926">WordPress and Accessibility (Comment)</a></li>
820
  <li><a href="http://wordpress.org/extend/plugins/img-title-removal/">IMG Title Removal</a></li>
821
  <li><a href="http://www.usableinteractions.com/2012/11/accessibility-toolbar/">Accessibility Toolbar</a></li>
 
822
  </ul>
823
  </div>
824
  </div>
@@ -826,14 +845,17 @@ if ( $l_contrast ) {
826
 
827
  <div class="ui-sortable meta-box-sortables">
828
  <div class="postbox">
829
- <h3><?php _e('Accessibility Toolbar Notes','wp-accessibility'); ?></h3>
830
  <div class="inside">
831
  <p>
832
- <?php _e('It is almost impossible for the Accessibility Toolbar to guarantee a good result for large text or high contrast modes. You can author your own high-contrast styles by placing a stylesheet called <code>a11y-contrast.css</code> in your Theme\'s stylesheet directory.','wp-accessibility'); ?>
833
  </p>
834
  <p>
835
- <?php _e('You can define custom styles for the large print view by defining them under the body class <code>.fontsize</code> in your theme stylesheet.'); ?>
836
  </p>
 
 
 
837
  </div>
838
  </div>
839
  </div>
@@ -1074,4 +1096,124 @@ $plugins_string
1074
  </div>
1075
  </div>
1076
  </form>";
1077
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  Plugin Name: WP Accessibility
4
  Plugin URI: http://www.joedolson.com/articles/wp-accessibility/
5
  Description: Provides options to improve accessibility in your WordPress site, including removing title attributes.
6
+ Version: 1.3.0
7
  Author: Joe Dolson
8
  Author URI: http://www.joedolson.com/
9
 
36
 
37
  // ACTIVATION
38
  function wpa_install() {
39
+ $wpa_version = '1.3.0';
40
  if ( get_option('wpa_installed') != 'true' ) {
41
  add_option('rta_from_nav_menu', 'on');
42
  add_option('rta_from_page_lists', 'on');
54
  add_option('wpa_continue','Continue Reading');
55
  add_option('wpa_focus','');
56
  add_option( 'wpa_installed', 'true' );
57
+ add_option( 'wpa_version', $version );
58
+ add_option( 'wpa_longdesc', 'jquery' );
59
  } else {
60
  wpa_check_version();
61
  update_option( 'wpa_version', $version );
63
  }
64
 
65
  function wpa_check_version() {
66
+ // upgrade for version 1.3.0
67
+ if ( version_compare( get_option( 'wpa_version' ), '1.3.0', '<' ) ) {
68
+ add_option( 'wpa_longdesc', 'jquery' );
69
+ }
70
  }
71
 
72
  function wpa_plugin_action($links, $file) {
133
  wp_register_script( 'scrollTo', plugins_url( 'wp-accessibility/toolbar/js/jquery.scrollto.min.js' ), array( 'jquery' ), '1.4.5', true );
134
  }
135
 
136
+ add_action( 'wp_footer', 'wpa_jquery_asl' );
 
 
 
137
  if ( get_option( 'wpa_toolbar' ) == 'on' || get_option( 'wpa_widget_toolbar' ) == 'on' ) {
138
  add_action( 'wp_footer', 'wpa_path_a11y' );
139
  }
166
  if ( get_option( 'wpa_toolbar' ) == 'on' ) {
167
  add_action( 'wp_footer','wpa_toolbar_js');
168
  }
169
+ if ( get_option( 'wpa_longdesc' ) == 'link' ) {
170
+ wp_enqueue_script( 'longdesc.link', plugins_url( 'js/longdesc.link.js', __FILE__ ), array( 'jquery' ), '1.0', true );
171
+ }
172
+ if ( get_option( 'wpa_longdesc' ) == 'jquery' ) {
173
+ wp_enqueue_script( 'longdesc.button', plugins_url( 'js/longdesc.button.js', __FILE__ ), array( 'jquery' ), '1.0', true );
174
+ }
175
  }
176
 
177
  add_action('widgets_init', create_function('', 'return register_widget("wp_accessibility_toolbar");') );
273
  return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url);
274
  }
275
 
276
+ function wpa_jquery_asl() {
277
+ $skiplinks_js = $targets = $lang_js = $tabindex = $longdesc = false;
278
  $content = str_replace( '#','',esc_attr( get_option('asl_content') ) );
279
  $visibility = ( get_option( 'asl_visible' ) == 'on' )?'wpa-visible':'wpa-hide';
280
  $nav = str_replace( '#','',esc_attr( get_option('asl_navigation') ) );
291
  $html .= ( $extra != '' && $extra_text != '' )?"<a href=\"$extra\">$extra_text</a> ":'';
292
  $is_rtl = ( is_rtl() ) ? '-rtl' : '-ltr' ;
293
  $output = ($html != '')?"<div class=\"$visibility$is_rtl\" id=\"skiplinks\" role=\"navigation\">$html</div>":'';
294
+ $skiplinks_js = ( $output )?"$('body').prepend('$output');":'';
295
  // attach language to html element
296
  $lang = ( get_option( 'wpa_lang' ) == 'on' )?get_bloginfo('language'):false;
297
  $dir = ( get_option( 'wpa_lang' ) == 'on' )?get_bloginfo('text_direction'):false;
298
+ $lang_js = "$('html').attr('lang','$lang'); $('html').attr('dir','$dir')";
299
  // force links to open in the same window
300
  $targets = ( get_option( 'wpa_target' ) == 'on' )?"$('a').removeAttr('target');":'';
301
  $tabindex = ( get_option( 'wpa_tabindex') == 'on' )?"$('input,a,select,textarea,button').removeAttr('tabindex');":'';
302
+ $display = ( $skiplinks_js || $targets || $lang_js || $tabindex || $longdesc ) ? true : false ;
303
+
304
+ if ( $display ) {
305
  $script = "
306
  <script>
307
  //<![CDATA[
508
  $wpa_target = ( isset( $_POST['wpa_target'] ) )?'on':'';
509
  $wpa_search = ( isset( $_POST['wpa_search'] ) )?'on':'';
510
  $wpa_tabindex = ( isset ( $_POST['wpa_tabindex'] ) )?'on':'';
511
+ $wpa_longdesc = ( isset ( $_POST['wpa_longdesc'] ) ) ? esc_attr( $_POST['wpa_longdesc'] ) : 'false';
512
  $wpa_image_titles = ( isset ( $_POST['wpa_image_titles'] ) )?'on':'';
513
  $wpa_more = ( isset ( $_POST['wpa_more'] ) )?'on':'';
514
  $wpa_focus = ( isset ( $_POST['wpa_focus'] ) )?'on':'';
524
  update_option('wpa_target', $wpa_target );
525
  update_option('wpa_search', $wpa_search );
526
  update_option('wpa_tabindex', $wpa_tabindex );
527
+ update_option('wpa_longdesc', $wpa_longdesc );
528
  update_option('wpa_image_titles', $wpa_image_titles );
529
  update_option('wpa_more', $wpa_more );
530
  update_option('wpa_focus', $wpa_focus );
688
  <li><input type="checkbox" id="wpa_target" name="wpa_target" <?php if ( get_option('wpa_target') == "on") { echo 'checked="checked" '; } ?>/> <label for="wpa_target"><?php _e('Remove target attribute from links','wp-accessibility'); ?></label></li>
689
  <li><input type="checkbox" id="wpa_search" name="wpa_search" <?php if ( get_option('wpa_search') == "on") { echo 'checked="checked" '; } ?>/> <label for="wpa_search"><?php _e('Force search error on empty search submission (theme must have search.php template)','wp-accessibility'); ?></label></li>
690
  <li><input type="checkbox" id="wpa_tabindex" name="wpa_tabindex" <?php if ( get_option('wpa_tabindex') == "on") { echo 'checked="checked" '; } ?>/> <label for="wpa_tabindex"><?php _e('Remove tabindex from focusable elements','wp-accessibility'); ?></label></li>
691
+ <li><label for="wpa_longdesc"><?php _e('Long Description UI','wp-accessibility'); ?></label> <select id="wpa_longdesc" name="wpa_longdesc">
692
+ <option value='link'<?php if ( get_option('wpa_longdesc') == "link") { echo 'selected="selected" '; } ?>><?php _e('Link to description','wp-accessibility'); ?></option>
693
+ <option value='jquery'<?php if ( get_option('wpa_longdesc') == "jquery") { echo 'selected="selected" '; } ?>><?php _e('Button trigger to overlay image','wp-accessibility'); ?></option>
694
+ <option value='false'<?php if ( get_option('wpa_longdesc') == "false" || !get_option( 'wpa_longdesc' ) ) { echo 'selected="selected" '; } ?>s><?php _e('Browser defaults only','wp-accessibility'); ?></option>
695
+ </select>
696
+ </li>
697
  <li><input type="checkbox" id="wpa_admin_css" name="wpa_admin_css" <?php if ( get_option('wpa_admin_css') == "on") { echo 'checked="checked" '; } ?>/> <label for="wpa_admin_css"><?php _e('Enable WordPress Admin stylesheet','wp-accessibility'); ?></label></li>
698
  <li><input type="checkbox" id="wpa_row_actions" name="wpa_row_actions" <?php if ( get_option('wpa_row_actions') == "on") { echo 'checked="checked" '; } ?>/> <label for="wpa_row_actions"><?php _e('Make row actions always visible','wp-accessibility'); ?></label></li>
699
  <li><input type="checkbox" id="wpa_image_titles" name="wpa_image_titles" <?php if ( get_option('wpa_image_titles') == "on") { echo 'checked="checked" '; } ?>/> <label for="wpa_image_titles"><?php _e('Remove title attribute from images inserted into post content and featured images.','wp-accessibility'); ?></label></li>
837
  <li><a href="http://accessites.org/site/2008/11/wordpress-and-accessibility/#comment-2926">WordPress and Accessibility (Comment)</a></li>
838
  <li><a href="http://wordpress.org/extend/plugins/img-title-removal/">IMG Title Removal</a></li>
839
  <li><a href="http://www.usableinteractions.com/2012/11/accessibility-toolbar/">Accessibility Toolbar</a></li>
840
+ <li><a href="https://wordpress.org/plugins/long-description-for-image-attachments/">WordPress Long Description</a></li>
841
  </ul>
842
  </div>
843
  </div>
845
 
846
  <div class="ui-sortable meta-box-sortables">
847
  <div class="postbox">
848
+ <h3><?php _e('Customization Notes','wp-accessibility'); ?></h3>
849
  <div class="inside">
850
  <p>
851
+ <?php _e('It is almost impossible for the Accessibility Toolbar to guarantee a good result for large text or high contrast modes. Author your own high-contrast styles by placing a stylesheet called <code>a11y-contrast.css</code> in your Theme\'s stylesheet directory.','wp-accessibility'); ?>
852
  </p>
853
  <p>
854
+ <?php _e('Define custom styles for large print by asssigning them in the body class <code>.fontsize</code> in your theme stylesheet.','wp-accessibility' ); ?>
855
  </p>
856
+ <p>
857
+ <?php _e('Define a custom long description template by adding the template "longdesc-template.php" to your theme directory.','wp-accessibility' ); ?>
858
+ </p>
859
  </div>
860
  </div>
861
  </div>
1096
  </div>
1097
  </div>
1098
  </form>";
1099
+ }
1100
+
1101
+
1102
+ /* longdesc support, based on work by Michael Fields (http://wordpress.org/plugins/long-description-for-image-attachments/) */
1103
+
1104
+ define( 'WPA_TEMPLATES', trailingslashit( dirname( __FILE__ ) ).'templates/' );
1105
+
1106
+ /**
1107
+ * Load Template.
1108
+ *
1109
+ * The ID for an image attachment is expected to be
1110
+ * passed via $_GET['longdesc']. If this value exists
1111
+ * and a post is successfully queried, postdata will
1112
+ * be prepared and a template will be loaded to display
1113
+ * the post content.
1114
+ *
1115
+ * This template must be named "longdesc-template.php".
1116
+ *
1117
+ * First, this function will look in the child theme
1118
+ * then in the parent theme and if no template is found
1119
+ * in either theme, the default template will be loaded
1120
+ * from the plugin's folder.
1121
+ *
1122
+ * This function is hooked into the "template_redirect"
1123
+ * action and terminates script execution.
1124
+ *
1125
+ * @return void
1126
+ *
1127
+ * @since 2010-09-26
1128
+ * @alter 2011-03-27
1129
+ */
1130
+ function longdesc_template() {
1131
+
1132
+ /* Return early if there is no reason to proceed. */
1133
+ if ( ! isset( $_GET['longdesc'] ) ) {
1134
+ return;
1135
+ }
1136
+
1137
+ global $post;
1138
+
1139
+ /* Get the image attachment's data. */
1140
+ $id = absint( $_GET['longdesc'] );
1141
+ $post = get_post( $id );
1142
+ if ( is_object( $post ) ) {
1143
+ setup_postdata( $post );
1144
+ }
1145
+
1146
+ /* Attachment must be an image. */
1147
+ if ( false === strpos( get_post_mime_type(), 'image' ) ) {
1148
+ header( 'HTTP/1.0 404 Not Found' );
1149
+ exit;
1150
+ }
1151
+
1152
+ /* The whole point here is to NOT show an image :) */
1153
+ remove_filter( 'the_content', 'prepend_attachment' );
1154
+
1155
+ /* Check to see if there is a template in the theme. */
1156
+ $template = locate_template( array( 'longdesc-template.php' ) );
1157
+ if ( ! empty( $template ) ) {
1158
+ require_once( $template );
1159
+ exit;
1160
+ }
1161
+ /* Use plugin's template file. */
1162
+ else {
1163
+ require_once( WPA_TEMPLATES . 'longdesc-template.php' );
1164
+ exit;
1165
+ }
1166
+
1167
+ /* You've gone too far! */
1168
+ header( 'HTTP/1.0 404 Not Found' );
1169
+ exit;
1170
+ }
1171
+ add_action( 'template_redirect', 'longdesc_template' );
1172
+
1173
+
1174
+ /**
1175
+ * Anchor.
1176
+ *
1177
+ * Create anchor id for linking from a Long Description to referring post.
1178
+ * Also creates an anchor to return from Long Description page.
1179
+ *
1180
+ * @param int ID of the post which contains an image with a longdesc attribute.
1181
+ * @return string
1182
+ *
1183
+ * @since 2010-09-26
1184
+ */
1185
+ function longdesc_return_anchor( $id ) {
1186
+ return 'longdesc-return-' . $id;
1187
+ }
1188
+
1189
+
1190
+ /**
1191
+ * Add Attribute.
1192
+ *
1193
+ * Add longdesc attribute when WordPress sends image to the editor.
1194
+ * Also creates an anchor to return from Long Description page.
1195
+ *
1196
+ * @return string
1197
+ *
1198
+ * @since 2010-09-20
1199
+ * @alter 2011-04-06
1200
+ */
1201
+ function longdesc_add_attr( $html, $id, $caption, $title, $align, $url, $size, $alt ) {
1202
+
1203
+ /* Get data for the image attachment. */
1204
+ $image = get_post( $id );
1205
+ global $post_ID;
1206
+ if ( isset( $image->ID ) && !empty( $image->ID ) ) {
1207
+ $args = array( 'longdesc' => $image->ID );
1208
+ /* The referrer is the post that the image is inserted into. */
1209
+ if ( isset( $_REQUEST['post_id'] ) ) {
1210
+ $args['referrer'] = (int) $_REQUEST['post_id'];
1211
+ }
1212
+ $search = '<img';
1213
+ $replace = $search . ' longdesc="' . esc_url( add_query_arg( $args, home_url() ) ) . '"';
1214
+ $html = str_replace( $search, $replace, $html );
1215
+ $html.= '<a id="' . esc_attr( longdesc_return_anchor( $image->ID ) ) . '"></a>';
1216
+ }
1217
+ return $html;
1218
+ }
1219
+ add_filter( 'image_send_to_editor', 'longdesc_add_attr', 10, 8 );
wpa-style.css CHANGED
@@ -1,3 +1,35 @@
1
  .wpa-hide-rtl#skiplinks a, .wpa-hide-rtl#skiplinks a:hover, .wpa-hide-rtl#skiplinks a:visited { position: absolute !important; right: -999em; }
2
  .wpa-hide-ltr#skiplinks a, .wpa-hide-ltr#skiplinks a:hover, .wpa-hide-ltr#skiplinks a:visited { position: absolute !important; left: -999em; }
3
- .wpa-hide#skiplinks a:active, .wpa-hide#skiplinks a:focus { position: absolute; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  .wpa-hide-rtl#skiplinks a, .wpa-hide-rtl#skiplinks a:hover, .wpa-hide-rtl#skiplinks a:visited { position: absolute !important; right: -999em; }
2
  .wpa-hide-ltr#skiplinks a, .wpa-hide-ltr#skiplinks a:hover, .wpa-hide-ltr#skiplinks a:visited { position: absolute !important; left: -999em; }
3
+ .wpa-hide#skiplinks a:active, .wpa-hide#skiplinks a:focus { position: absolute; }
4
+
5
+ .wpa-ld { display: inline-block; position: relative; }
6
+
7
+ /* basic support for themes that don't define alignleft and alignright for non-image elements. */
8
+ div.alignleft { float: left; }
9
+ div.alignright { float: right; }
10
+ div.aligncenter { display: block; margin: 0 auto; }
11
+
12
+ .wpa-ld a,.wpa-ld button { bottom: 2px; left: 2px; position: absolute; line-height: 1; min-width: 1em; }
13
+ .wpa-ld img { display: block; }
14
+ .wpa-ld button,.wpa-ld button:active,.wpa-ld button:focus,.wpa-ld button:hover {
15
+ border: 1px solid #777; border-radius: 2px; z-index: 10;
16
+ }
17
+
18
+ .wpa-ld .longdesc { position: absolute; width: 100%; height: 100%; top: 0; overflow-y: scroll; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; background: rgba( 255, 255, 255, .95 ); padding: 1.5em; }
19
+
20
+ .wpa-ld button, .wpa-ld button:active, .wpa-ld button:focus, .wpa-ld button:hover, .wpa-ld a {
21
+ font-size: .9em; font-weight: 400; background: rgba( 255, 255, 255, .7 )!important; padding: 0; color: #000!important; text-shadow: 1px 1px #ccc;
22
+ }
23
+ .wpa-ld button:before { content: 'i'; font-style: italic; font-family: serif; }
24
+ .wpa-ld button:focus, .wpa-ld button:hover { background: rgba( 0,0,0, .75 )!important; color: #fff!important; border: 1px solid #000!important; cursor: pointer;}
25
+ .wpa-ld button:focus { padding: 6px; }
26
+ .wpa-ld button span, .longdesc-link span {
27
+ position: absolute !important;
28
+ height: 1px;
29
+ width: 1px;
30
+ overflow: hidden;
31
+ clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
32
+ clip: rect(1px, 1px, 1px, 1px);
33
+ }
34
+
35
+ .template-longdesc { text-align: left; line-height: 1.5; width: 100%; max-width:50em; padding:2em; margin:1em auto; background:#fdfdfd; color:#333; box-shadow: 0 0 5px; font-size: 1.4em; }