WordPress.org

Plugin Directory

Changeset 664937


Ignore:
Timestamp:
02/07/13 22:10:55 (15 months ago)
Author:
joedolson
Message:

Updates: a11y toolbar, admin styles

Location:
wp-accessibility/trunk
Files:
16 added
3 edited

Legend:

Unmodified
Added
Removed
  • wp-accessibility/trunk/readme.txt

    r638923 r664937  
    88License: GPLv2 or later 
    99 
    10 WP Accessibility provides features that fix accessibility issues in your WordPress site.  
     10WP Accessibility provides fixes for common accessibility issues in your WordPress site. 
    1111 
    1212== Description == 
    1313 
    14 This plug-in is targeted at correcting a variety of common accessibility issues encountered in WordPress themes. This plug-in will probably change frequently, as I add support for additional issues or (hopefully) remove features that are no longer needed.  
     14This plug-in is for correcting a variety of common accessibility issues encountered in WordPress themes. While most accessibility issues can't be easily addressed using abstracted code, WP Accessibility can provide a number of accessibility features with a minimum mount of setup and expert knowledge. 
    1515 
    16 All features can be disabled according to your theme's needs. 
     16All features can be disabled according to your theme's needs. All of the functions based on modifying stylesheets can be customized using your own custom styles by placing the appropriate stylesheet in your theme directory. 
    1717 
    1818At the moment, the plug-in can: 
     
    2828* Add post titles to standard "read more" links. 
    2929* Add an outline to the keyboard focus state for focusable elements.  
     30* Add a toolbar toggling between high contrast, large print, and desaturated (grayscale) views of your theme. 
     31* Fix certain accessibility issues in the WordPress admin styles 
    3032* Show the color contrast between two provided hexadecimal color values. 
    3133* Read more about <a href="http://make.wordpress.org/accessibility/wp-accessibility-plugin/">the accessibility problems corrected</a> 
     
    4345 
    4446== Changelog == 
     47 
     48= 1.2.0 = 
     49 
     50* Added space between content output and continue reading text in excerpt context. 
     51* Added German translation 
     52* Added Accessibility Toolbar (<a href="http://www.usableinteractions.com/2012/11/accessibility-toolbar/">Source</a>) 
     53* Added WP admin stylesheet: 
     54* Some contrast improvements. 
     55* Placed post row action links (Edit, Quick Edit, Trash, View) into screen reader visible and keyboard usable position. 
     56* Added underlines to links on hover 
     57* Supports your own custom wp-admin stylesheet via your Theme directory.  
    4558 
    4659= 1.1.2 = 
  • wp-accessibility/trunk/uninstall.php

    r627427 r664937  
    2828    delete_option( 'wpa_more' ); 
    2929    delete_option( 'wpa_continue' ); 
     30    delete_option( 'wpa_toolbar' ); 
    3031} 
  • wp-accessibility/trunk/wp-accessibility.php

    r638923 r664937  
    44Plugin URI: http://www.joedolson.com/articles/wp-accessibility/ 
    55Description: Provides options to improve accessibility in your WordPress site, including removing title attributes. 
    6 Version: 1.1.2 
     6Version: 1.2.0 
    77Author: Joe Dolson 
    88Author URI: http://www.joedolson.com/ 
     
    3636} 
    3737 
    38  
    3938// ACTIVATION 
    4039function wpa_install() { 
    41     $wpa_version = '1.1.2'; 
     40    $wpa_version = '1.2.0'; 
    4241    if ( get_option('wpa_installed') != 'true' ) { 
    4342        add_option('rta_from_nav_menu', 'on'); 
     
    8786} 
    8887 
     88function wpa_admin_stylesheet() { 
     89    if ( get_option( 'wpa_admin_css' ) == 'on' ) { 
     90        if ( file_exists( get_stylesheet_directory() . '/wp-admin.css' ) ) { 
     91            $file = get_stylesheet_directory_uri() . '/wp-admin.css'; 
     92        } else { 
     93            $file = plugins_url('wp-admin.css', __FILE__); 
     94        } 
     95        wp_register_style( 'wp-a11y-css', $file ); 
     96        wp_enqueue_style( 'wp-a11y-css' ); 
     97    } 
     98} 
     99function wpa_admin_js() {} // just a placeholder 
     100 
     101add_action('admin_head', 'wpa_admin_stylesheet'); 
     102add_action('admin_head', 'wpa_admin_js'); 
     103 
    89104function wpa_write_js() { 
    90105    if ( isset($_GET['page']) && $_GET['page']=='wp-accessibility/wp-accessibility.php' ) { 
     
    102117    // register jQuery script; 
    103118    wp_register_script( 'skiplinks.webkit', plugins_url( 'wp-accessibility/js/skiplinks.webkit.js' ) );  
     119    wp_register_script( 'ui-a11y.js', plugins_url( 'wp-accessibility/toolbar/js/a11y.js' ), array( 'jquery' ), '1.0', true ); 
     120    wp_register_script( 'scrollTo', plugins_url( 'wp-accessibility/toolbar/js/jquery.scrollto.min.js' ), array( 'jquery' ), '1.0', true ); 
    104121} 
    105122 
    106123if ( get_option( 'asl_enable') == 'on' ) { 
    107124    // insert skiplinks into DOM via jQuery 
    108     add_action( 'wp_head', 'wpa_jquery_asl' ); 
    109     add_action( 'wp_enqueue_scripts','wpa_enqueue_scripts' ); 
    110 } 
    111  
     125    add_action( 'wp_footer', 'wpa_jquery_asl' ); 
     126} 
     127if ( get_option( 'wpa_toolbar' ) == 'on' ) { 
     128    add_action( 'wp_footer', 'wpa_path_a11y' ); 
     129} 
     130 
     131add_action( 'wp_enqueue_scripts','wpa_enqueue_scripts' ); 
    112132add_action( 'wp_head', 'wpa_css' ); 
    113133add_action( 'wp_enqueue_scripts', 'wpa_core_scripts' ); 
     
    117137} 
    118138 
     139function wpa_path_a11y() { 
     140    $plugin_path = plugins_url( 'wp-accessibility/toolbar/css/a11y-contrast.css' ); 
     141    if ( file_exists( get_stylesheet_directory() . '/a11y-contrast.css' ) ) { 
     142        $plugin_path = get_stylesheet_directory_uri() . '/a11y-contrast.css'; 
     143    } 
     144    echo "<span class='a11y_stylesheet_path'>$plugin_path</span>\n"; 
     145} 
     146 
    119147function wpa_enqueue_scripts() { 
    120     wp_enqueue_script( 'skiplinks.webkit' ); 
     148    if ( get_option( 'asl_enable') == 'on' ) { 
     149        wp_enqueue_script( 'skiplinks.webkit' ); 
     150    } 
     151    if ( get_option( 'wpa_toolbar' ) == 'on' ) { 
     152        wp_enqueue_script( 'scrollTo' ); 
     153        wp_enqueue_script( 'ui-a11y.js' ); 
     154        add_action( 'wp_footer','wpa_toolbar_js'); 
     155    } 
     156} 
     157 
     158function wpa_toolbar_js() { 
     159    $contrast = __('Toggle High Contrast','wp-accessibility'); 
     160    $grayscale = __('Toggle Grayscale','wp-accessibility'); 
     161    $fontsize = __('Toggle Font size','wp-accessibility'); 
     162echo     
     163    " 
     164<script type='text/javascript'> 
     165    jQuery(document).ready(function($) { 
     166        // Prepend our toolbar to the left side of the page, right under <body> 
     167        var insert_a11y_toolbar = '<!-- a11y toolbar -->'; 
     168        insert_a11y_toolbar += '<div class=\"a11y-toolbar\">'; 
     169        insert_a11y_toolbar += '<ul>'; 
     170        insert_a11y_toolbar += '<li><a href=\"#\" class=\"a11y-toggle-contrast toggle-contrast\" id=\"is_normal_contrast\" title=\"$contrast\"><span class=\"offscreen\">$contrast</span><i class=\"icon icon-adjust\"></i></a></li>'; 
     171        insert_a11y_toolbar += '<li><a href=\"#\" class=\"a11y-toggle-grayscale toggle-grayscale\" id=\"is_normal_color\" title=\"$grayscale\"><span class=\"offscreen\">$grayscale</span><i class=\"icon icon-tint\"></i></a></li>'; 
     172        insert_a11y_toolbar += '<li><a href=\"#\" class=\"a11y-toggle-fontsize toggle-fontsize\" id=\"is_normal_fontsize\" title=\"$fontsize\"><span class=\"offscreen\">$fontsize</span><i class=\"icon icon-font\"></i></a></li>'; 
     173        insert_a11y_toolbar += '</ul>'; 
     174        insert_a11y_toolbar += '</div>'; 
     175        insert_a11y_toolbar += '<!-- // a11y toolbar -->'; 
     176        $(document).find('body').prepend(insert_a11y_toolbar); 
     177    }); 
     178</script>"; 
    121179} 
    122180 
     
    137195        #skiplinks a:active, $vis #skiplinks a:focus { $focus  } 
    138196        "; 
     197    } 
     198    $ua = $_SERVER['HTTP_USER_AGENT']; 
     199    $is_firefox = (stristr($ua, 'Firefox')); 
     200    if ( get_option( 'wpa_toolbar' ) == 'on' && $is_firefox ) { 
     201        $styles .= ".a11y-toolbar ul li:nth-child(2) { display: none; }"; 
    139202    } 
    140203    if ( get_option( 'wpa_focus' ) == 'on' ) { 
     
    203266    wp_register_style( 'wpa-style', plugins_url('wpa-style.css', __FILE__) ); 
    204267    wp_enqueue_style( 'wpa-style' ); 
     268    wp_register_style( 'ui-a11y.css', plugins_url( 'toolbar/css/a11y.css', __FILE__) ); 
     269    wp_enqueue_style( 'ui-a11y.css' ); 
    205270} 
    206271 
     
    368433            $wpa_focus_color = ( isset( $_POST['wpa_focus_color'] ) )?str_replace( '#', '', $_POST['wpa_focus_color'] ):''; 
    369434            $wpa_continue = ( isset( $_POST['wpa_continue'] ) )?$_POST['wpa_continue']:'Continue Reading'; 
     435            $wpa_toolbar = ( isset( $_POST['wpa_toolbar'] ) )?'on':''; 
     436            $wpa_admin_css = ( isset( $_POST['wpa_admin_css'] ) )?'on':''; 
    370437            update_option('wpa_lang', $wpa_lang ); 
    371438            update_option('wpa_target', $wpa_target ); 
     
    375442            update_option('wpa_more', $wpa_more ); 
    376443            update_option('wpa_focus', $wpa_focus ); 
     444            update_option('wpa_toolbar', $wpa_toolbar ); 
    377445            update_option('wpa_focus_color', $wpa_focus_color ); 
    378446            update_option('wpa_continue', $wpa_continue ); 
     447            update_option('wpa_admin_css', $wpa_admin_css ); 
    379448            $message = __("Miscellaneous Accessibility Settings Updated",'wp-accessibility'); 
    380449            return "<div class='updated'><p>".$message."</p></div>"; 
     
    432501function wpa_excerpt_more($more) { 
    433502    global $id; 
    434   return '&hellip;'.wpa_continue_reading( $id ); 
     503    return '&hellip; '.wpa_continue_reading( $id ); 
    435504} 
    436505 
    437506function wpa_content_more($more) { 
    438507    global $id; 
    439   return wpa_continue_reading( $id ); 
     508    return wpa_continue_reading( $id ); 
    440509} 
    441510 
    442511function wpa_custom_excerpt_more($output) { 
    443   if (has_excerpt() && !is_attachment()) { 
    444     global $id; 
    445     $output .= wpa_continue_reading( $id ); 
    446   } 
    447   return $output; 
     512    if (has_excerpt() && !is_attachment()) { 
     513        global $id; 
     514        $output .= ' '.wpa_continue_reading( $id ); // insert a blank space. 
     515    } 
     516    return $output; 
    448517} 
    449518 
     
    530599                        <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> 
    531600                        <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> 
     601                        <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> 
    532602                        <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> 
     603                        <li><input type="checkbox" id="wpa_toolbar" name="wpa_toolbar" <?php if ( get_option('wpa_toolbar') == "on") { echo 'checked="checked" '; } ?>/> <label for="wpa_toolbar"><?php _e('Add Accessibility toolbar with fontsize adjustment, contrast toggle, and grayscale switch. (Grayscale not available for Firefox)','wp-accessibility'); ?></label></li>       
    533604                        <li><input type="checkbox" id="wpa_more" name="wpa_more" <?php if ( get_option('wpa_more') == "on") { echo 'checked="checked" '; } ?>/> <label for="wpa_more"><?php _e('Add post title to "more" links.','wp-accessibility'); ?></label> 
    534605                            <label for="wpa_continue"><?php _e('Continue reading text','wp-accessibility'); ?></label> <input type="text" id="wpa_continue" name="wpa_continue" value="<?php echo esc_attr(get_option('wpa_continue') ); ?>" /></li> 
     
    621692                <div class="inside"> 
    622693                    <p> 
    623                     <a href="https://twitter.com/intent/tweet?screen_name=joedolson&text=WP%20Accessibility" class="twitter-mention-button" data-size="large" data-related="joedolson">Tweet to @joedolson</a> 
     694                    <a href="https://twitter.com/intent/tweet?screen_name=joedolson&text=WP%20Accessibility%20is%20great!" class="twitter-mention-button" data-size="large" data-related="joedolson">Tweet to @joedolson</a> 
    624695                    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> 
    625696                    </p> 
     
    666737                        <li><a href="http://accessites.org/site/2008/11/wordpress-and-accessibility/#comment-2926">WordPress and Accessibility (Comment)</a></li> 
    667738                        <li><a href="http://wordpress.org/extend/plugins/img-title-removal/">IMG Title Removal</a></li> 
     739                        <li><a href="http://www.usableinteractions.com/2012/11/accessibility-toolbar/">Accessibility Toolbar</a></li> 
    668740                    </ul> 
     741                </div> 
     742            </div> 
     743        </div>   
     744 
     745        <div class="ui-sortable meta-box-sortables"> 
     746            <div class="postbox"> 
     747                <h3><?php _e('Accessibility Toolbar Notes','wp-accessibility'); ?></h3> 
     748                <div class="inside"> 
     749                    <p> 
     750                    <?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'); ?> 
     751                    </p> 
     752                    <p> 
     753                    <?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.'); ?> 
     754                    </p> 
    669755                </div> 
    670756            </div> 
Note: See TracChangeset for help on using the changeset viewer.