WordPress.org

Plugin Directory

Changeset 618053


Ignore:
Timestamp:
10/27/12 16:41:04 (18 months ago)
Author:
joedolson
Message:

Commit version 1.1.0; new features, bug fix.

Location:
wp-accessibility/trunk
Files:
3 edited

Legend:

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

    r615809 r618053  
    1212== Description == 
    1313 
    14 This plug-in is targeted towards correcting a variety of accessibility issues frequently 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 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.  
     15 
     16All features can be disabled according to your theme's needs. 
    1517 
    1618At the moment, the plug-in can: 
     
    1820* Remove redundant title attributes from page lists, category lists, and archive menus.  
    1921* Enable skip links with WebKit support by enqueuing JavaScript support for moving keyboard focus. 
    20 * Add skip links with user-defined targets. 
     22* Add skip links with user-defined targets. (Customizable targets and appearance.) 
    2123* Add language and text direction attributes to your HTML attribute 
    2224* Remove the target attribute from links. 
    23 * Force a search page error when a search is made with an empty text string.  
     25* Force a search page error when a search is made with an empty text string. (If your theme has a search.php template.) 
    2426* Remove tabindex from elements that are focusable. 
    2527* Strip title attributes from images inserted into content.  
    2628* Add post titles to standard "read more" links. 
     29* Add an outline to the keyboard focus state for focusable elements.  
     30* Show the color contrast between two provided hexadecimal color values. 
    2731 
    2832The plug-in is intended to make up for some deficiencies commonly found in themes. It can't correct every problem (by a long shot), but can provide some assistance. 
     33 
     34Translating my plug-ins is always appreciated. Visit <a href="http://translate.joedolson.com">my translations site</a> to start getting your language into shape! 
     35 
    2936 
    3037== Installation == 
     
    3542 
    3643== Changelog == 
     44 
     45= 1.1.0 = 
     46 
     47* Added ability to add focus outline in :focus pseudo class. 
     48* Added color contrast tool. 
     49* Added settings link to plugins listing. 
     50* Added link to translations site for this plug-in.  
     51* Improved response for forcing search error on empty search submission. 
     52* Bug fix for adding custom skip link. 
    3753 
    3854= 1.0.0 = 
     
    5672== Upgrade Notice == 
    5773 
    58 * No notices yet! 
     74* Bug fix for custom skiplink target; Added focus outline option; Added color contrast tool. 
  • wp-accessibility/trunk/wp-accessibility.php

    r615802 r618053  
    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.0 
     6Version: 1.1.0 
    77Author: Joe Dolson 
    88Author URI: http://www.joedolson.com/ 
     
    3030load_plugin_textdomain( 'wp-accessibility',false, dirname( plugin_basename( __FILE__ ) ) . '/lang' ); 
    3131 
     32// ADMIN MENU 
     33function add_wpa_admin_menu() { 
     34    add_action( 'admin_print_footer_scripts', 'wpa_write_js' ); 
     35    add_options_page('WP Accessibility', 'WP Accessibility', 'manage_options', __FILE__, 'wpa_admin_menu'); 
     36} 
     37 
     38 
    3239// ACTIVATION 
    3340function wpa_install() { 
     41    $wpa_version = '1.1.0'; 
    3442    if ( get_option('wpa_installed') != 'true' ) { 
    3543        add_option('rta_from_nav_menu', 'on'); 
     
    4755        add_option('wpa_tabindex','on'); 
    4856        add_option('wpa_continue','Continue Reading'); 
    49     } 
    50     add_option( 'wpa_installed', 'true' ); 
    51     add_option( 'wpa_version', '1.0.0' ); 
     57        add_option('wpa_focus',''); 
     58        add_option( 'wpa_installed', 'true' ); 
     59        add_option( 'wpa_version', $version );       
     60    } else { 
     61        wpa_check_version(); 
     62        update_option( 'wpa_version', $version ); 
     63    } 
    5264} 
    5365 
    5466function wpa_check_version() { 
    55     return; // for future updates 
    56 } 
     67    return true; // not needed for 1.0.1 
     68} 
     69 
     70function wpa_plugin_action($links, $file) { 
     71    if ( $file == plugin_basename(dirname( __FILE__).'/wp-accessibility.php') ) { 
     72        $admin_url = admin_url('options-general.php?page=wp-accessibility/wp-accessibility.php'); 
     73        $links[] = "<a href='$admin_url'>" . __('Accessibility Settings', 'wp-accessibility', 'wp-accessibility') . "</a>"; 
     74    } 
     75    return $links; 
     76} 
     77//Add Plugin Actions to WordPress 
     78add_filter('plugin_action_links', 'wpa_plugin_action', -10, 2); 
    5779 
    5880add_action( 'init', 'wpa_register_scripts'); 
    59  
     81add_action( 'admin_menu', 'wpa_javascript' ); 
     82 
     83function wpa_javascript() {  
     84    if ( isset($_GET['page']) && $_GET['page'] == 'wp-accessibility/wp-accessibility.php' ) { 
     85        wp_enqueue_script('farbtastic' );    
     86    } 
     87} 
     88 
     89function wpa_write_js() { 
     90    if ( isset($_GET['page']) && $_GET['page']=='wp-accessibility/wp-accessibility.php' ) { 
     91    ?> 
     92<script type="text/javascript"> 
     93jQuery(document).ready(function($) { 
     94    $('#fore').farbtastic('#color1'); 
     95    $('#back').farbtastic('#color2'); 
     96}); 
     97 </script> 
     98    <?php 
     99    } 
     100} 
    60101function wpa_register_scripts() { 
    61102    // register jQuery script; 
     
    66107    // insert skiplinks into DOM via jQuery 
    67108    add_action( 'wp_head', 'wpa_jquery_asl' ); 
    68     add_action( 'wp_head', 'wpa_css_asl' ); 
    69109    add_action( 'wp_enqueue_scripts','wpa_enqueue_scripts' ); 
    70110} 
     111 
     112add_action( 'wp_head', 'wpa_css' ); 
    71113 
    72114function wpa_enqueue_scripts() { 
     
    74116} 
    75117 
    76 function wpa_css_asl() { 
    77     $focus = get_option( 'asl_styles_focus' ); 
    78     $passive = get_option( 'asl_styles_passive' ); 
    79     $vis = $invis = ''; 
    80     // if links are visible, "hover" is a focus style, otherwise, it's a passive style. 
    81     if ( get_option( 'asl_visible' ) == 'on' ) {  
    82         $vis = '#skiplinks a:hover,';  
    83     } else {  
    84         $invis = '#skiplinks a:hover,';  
    85     } 
    86     $styles = " 
     118function wpa_css() { 
     119    $styles = ''; 
     120    if ( get_option( 'asl_enable') == 'on' ) { 
     121        $focus = get_option( 'asl_styles_focus' ); 
     122        $passive = get_option( 'asl_styles_passive' ); 
     123        $vis = $invis = ''; 
     124        // if links are visible, "hover" is a focus style, otherwise, it's a passive style. 
     125        if ( get_option( 'asl_visible' ) == 'on' ) {  
     126            $vis = '#skiplinks a:hover,';  
     127        } else {  
     128            $invis = '#skiplinks a:hover,';  
     129        } 
     130        $styles .= " 
     131        #skiplinks a, $invis #skiplinks a:visited { $passive } 
     132        #skiplinks a:active, $vis #skiplinks a:focus { $focus  } 
     133        "; 
     134    } 
     135    if ( get_option( 'wpa_focus' ) == 'on' ) { 
     136        $color = ( get_option('wpa_focus_color') != '' )?" #".get_option('wpa_focus_color'):''; 
     137        $styles .= " 
     138        :focus { outline: 1px solid$color!important; } 
     139        "; 
     140    } 
     141    if ( $styles != '' ) { 
     142        echo " 
    87143<style type='text/css'> 
    88     #skiplinks a, $invis #skiplinks a:visited { $passive } 
    89     #skiplinks a:active, $vis #skiplinks a:focus { $focus  } 
     144    $styles 
    90145</style>"; 
    91     echo $styles; 
     146    } 
     147} 
     148 
     149function wpa_is_url($url) { 
     150    return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url); 
    92151} 
    93152 
    94153function wpa_jquery_asl() { 
    95     $content = esc_attr(get_option('asl_content')); 
     154    $content = str_replace( '#','',esc_attr( get_option('asl_content') ) ); 
    96155    $visibility = ( get_option( 'asl_visible' ) == 'on' )?'wpa-visible':'wpa-hide'; 
    97     $nav = esc_attr(get_option('asl_navigation')); 
     156    $nav = str_replace( '#','',esc_attr( get_option('asl_navigation') ) ); 
    98157    $sitemap = esc_url(get_option( 'asl_sitemap' )); 
    99158    $extra = get_option( 'asl_extra_target' ); 
    100     $extra = ( esc_url($extra) )?esc_url($extra):esc_attr( $extra ); 
     159    $extra = ( wpa_is_url($extra) )?esc_url($extra):str_replace('#','',esc_attr( $extra )); 
     160    if ( $extra != '' && !wpa_is_url($extra) ) { $extra = "#$extra"; } 
    101161    $extra_text = stripslashes(get_option( 'asl_extra_text' )); 
    102162    $html = ''; 
     
    138198    wp_register_style( 'wpa-style', plugins_url('wpa-style.css', __FILE__) ); 
    139199    wp_enqueue_style( 'wpa-style' ); 
     200} 
     201 
     202function wpa_luminosity($r,$r2,$g,$g2,$b,$b2) { 
     203    $RsRGB = $r/255; 
     204    $GsRGB = $g/255; 
     205    $BsRGB = $b/255; 
     206    $R = ($RsRGB <= 0.03928) ? $RsRGB/12.92 : pow(($RsRGB+0.055)/1.055, 2.4); 
     207    $G = ($GsRGB <= 0.03928) ? $GsRGB/12.92 : pow(($GsRGB+0.055)/1.055, 2.4); 
     208    $B = ($BsRGB <= 0.03928) ? $BsRGB/12.92 : pow(($BsRGB+0.055)/1.055, 2.4); 
     209 
     210    $RsRGB2 = $r2/255; 
     211    $GsRGB2 = $g2/255; 
     212    $BsRGB2 = $b2/255; 
     213    $R2 = ($RsRGB2 <= 0.03928) ? $RsRGB2/12.92 : pow(($RsRGB2+0.055)/1.055, 2.4); 
     214    $G2 = ($GsRGB2 <= 0.03928) ? $GsRGB2/12.92 : pow(($GsRGB2+0.055)/1.055, 2.4); 
     215    $B2 = ($BsRGB2 <= 0.03928) ? $BsRGB2/12.92 : pow(($BsRGB2+0.055)/1.055, 2.4); 
     216 
     217    if ($r+$g+$b <= $r2+$g2+$b2) {   
     218        $l2 = (.2126 * $R + 0.7152 * $G + 0.0722 * $B); 
     219        $l1 = (.2126 * $R2 + 0.7152 * $G2 + 0.0722 * $B2); 
     220    } else { 
     221        $l1 = (.2126 * $R + 0.7152 * $G + 0.0722 * $B); 
     222        $l2 = (.2126 * $R2 + 0.7152 * $G2 + 0.0722 * $B2);   
     223    } 
     224    $luminosity = round(($l1 + 0.05)/($l2 + 0.05),2); 
     225    return $luminosity; 
     226} 
     227 
     228function wpa_rgb2hex($r, $g=-1, $b=-1) { 
     229    if (is_array($r) && sizeof($r) == 3) {  list($r, $g, $b) = $r; } 
     230    $r = intval($r); $g = intval($g); 
     231    $b = intval($b); 
     232 
     233    $r = dechex($r<0?0:($r>255?255:$r)); 
     234    $g = dechex($g<0?0:($g>255?255:$g)); 
     235    $b = dechex($b<0?0:($b>255?255:$b)); 
     236 
     237    $color = (strlen($r) < 2?'0':'').$r; 
     238    $color .= (strlen($g) < 2?'0':'').$g; 
     239    $color .= (strlen($b) < 2?'0':'').$b; 
     240    return '#'.$color; 
     241} 
     242 
     243function wpa_hex2rgb($color){ 
     244    $color = str_replace('#', '', $color); 
     245    if (strlen($color) != 6){ return array(0,0,0); } 
     246    $rgb = array(); 
     247    for ($x=0;$x<3;$x++){ 
     248        $rgb[$x] = hexdec(substr($color,(2*$x),2)); 
     249    } 
     250    return $rgb; 
     251} 
     252 
     253function wpa_contrast() { 
     254    if ( !empty($_POST) ) { 
     255    $nonce=$_REQUEST['_wpnonce'];   if (! wp_verify_nonce($nonce,'wpa-nonce') ) die("Security check failed");   
     256        if (isset($_POST['color']) && $_POST['color'] != "") { 
     257            $fore_color = $_POST['color']; 
     258            if ($fore_color[0] == "#") { 
     259                $fore_color = str_replace('#','',$fore_color); 
     260            } 
     261            if (strlen($fore_color) == 3)  { 
     262                $color6char  = $fore_color[0] . $fore_color[0]; 
     263                $color6char .= $fore_color[1] . $fore_color[1]; 
     264                $color6char .= $fore_color[2] . $fore_color[2]; 
     265                $fore_color = $color6char; 
     266            } 
     267            if (preg_match('/^#?([0-9a-f]{1,2}){3}$/i', $fore_color)) { 
     268                $echo_hex_fore = str_replace('#','',$fore_color); 
     269            } else { 
     270                $echo_hex_fore = 'FFFFFF'; 
     271            } 
     272            if (isset($_POST['color2']) && $_POST['color2'] != "") { 
     273                $back_color = $_POST['color2']; 
     274                if ($back_color[0] == "#") { 
     275                    $back_color = str_replace('#','',$back_color); 
     276                } 
     277                if (strlen($back_color) == 3)  { 
     278                    $color6char  = $back_color[0] . $back_color[0]; 
     279                    $color6char .= $back_color[1] . $back_color[1]; 
     280                    $color6char .= $back_color[2] . $back_color[2]; 
     281                    $back_color = $color6char; 
     282                } 
     283                if (preg_match('/^#?([0-9a-f]{1,2}){3}$/i', $back_color)) { 
     284                    $echo_hex_back = str_replace('#','',$back_color); 
     285                } else { 
     286                    $echo_hex_back = 'FFFFFF'; 
     287                } 
     288                $color = wpa_hex2rgb($echo_hex_fore); 
     289                $color2 = wpa_hex2rgb($echo_hex_back); 
     290                $rfore = $color[0]; 
     291                $gfore = $color[1]; 
     292                $bfore = $color[2]; 
     293                $rback = $color2[0]; 
     294                $gback = $color2[1]; 
     295                $bback = $color2[2]; 
     296                $colors = array( 'hex1'=>$echo_hex_fore, 'hex2'=>$echo_hex_back, 'red1'=>$rfore, 'green1'=>$gfore, 'blue1'=>$bfore, 'red2'=>$rback, 'green2'=>$gback, 'blue2'=>$bback ); 
     297                return $colors; 
     298            } else { 
     299                return false; 
     300            } 
     301        } 
     302    } 
     303    return false; 
    140304} 
    141305 
     
    196360            $wpa_image_titles = ( isset ( $_POST['wpa_image_titles'] ) )?'on':''; 
    197361            $wpa_more = ( isset ( $_POST['wpa_more'] ) )?'on':''; 
     362            $wpa_focus = ( isset ( $_POST['wpa_focus'] ) )?'on':''; 
     363            $wpa_focus_color = ( isset( $_POST['wpa_focus_color'] ) )?str_replace( '#', '', $_POST['wpa_focus_color'] ):''; 
    198364            $wpa_continue = ( isset( $_POST['wpa_continue'] ) )?$_POST['wpa_continue']:'Continue Reading'; 
    199365            update_option('wpa_lang', $wpa_lang ); 
     
    203369            update_option('wpa_image_titles', $wpa_image_titles ); 
    204370            update_option('wpa_more', $wpa_more ); 
     371            update_option('wpa_focus', $wpa_focus ); 
     372            update_option('wpa_focus_color', $wpa_focus_color ); 
    205373            update_option('wpa_continue', $wpa_continue ); 
    206374            $message = __("Miscellaneous Accessibility Settings Updated",'wp-accessibility'); 
     
    219387        $query->query_vars['s'] = '&#32;'; 
    220388        $query->set( 'is_search', 1 ); 
     389        add_action('template_redirect','wpa_search_error'); 
    221390    } 
    222391    return $query; 
     392} 
     393 
     394function wpa_search_error() { 
     395    $search = locate_template( 'search.php' ); 
     396    if ( $search ) { 
     397        load_template( $search ); 
     398    } 
    223399} 
    224400 
     
    266442} 
    267443 
    268 // ADMIN MENU 
    269 function add_wpa_admin_menu() { 
    270     add_options_page('WP Accessibility', 'WP Accessibility', 'manage_options', __FILE__, 'wpa_admin_menu'); 
    271 } 
    272  
    273444add_action( "admin_head", 'wpa_admin_styles' ); 
    274445 
    275446function wpa_admin_styles() { 
    276447    if (  isset($_GET['page']) && ($_GET['page'] == 'wp-accessibility/wp-accessibility.php' ) ) { 
     448        wp_enqueue_style('farbtastic'); 
    277449        echo '<link type="text/css" rel="stylesheet" href="'.plugins_url( 'wpa-styles.css', __FILE__ ).'" />'; 
    278450    } 
     
    323495                        <li><label for="asl_content"><?php _e('Skip to Content link target (ID of your main content container)','wp-accessibility'); ?></label> <input type="text" id="asl_content" name="asl_content" value="<?php echo esc_attr(get_option('asl_content')); ?>" /></li> 
    324496                        <li><label for="asl_navigation"><?php _e('Skip to Navigation link target (ID of your main navigation container)','wp-accessibility'); ?></label> <input type="text" id="asl_navigation" name="asl_navigation" value="<?php echo esc_attr(get_option('asl_navigation')); ?>" /></li> 
    325                         <li><label for="asl_sitemap"><?php _e('Site Map link target (URL for your site map)','wp-accessibility'); ?></label><input type="text" id="asl_sitemap" name="asl_sitemap" value="<?php echo esc_attr(get_option('asl_sitemap')); ?>" /></li> 
     497                        <li><label for="asl_sitemap"><?php _e('Site Map link target (URL for your site map)','wp-accessibility'); ?></label><input type="text" id="asl_sitemap" name="asl_sitemap" size="44" value="<?php echo esc_attr(get_option('asl_sitemap')); ?>" /></li> 
    326498                        <li><label for="asl_extra_target"><?php _e('Add your own link (link or container ID)','wp-accessibility'); ?></label> <input type="text" id="asl_extra_target" name="asl_extra_target" value="<?php echo esc_attr(get_option('asl_extra_target')); ?>" /> <label for="asl_extra_text"><?php _e('Link text for your link','wp-accessibility'); ?></label> <input type="text" id="asl_extra_text" name="asl_extra_text" value="<?php echo esc_attr(get_option('asl_extra_text')); ?>" /></li> 
    327499                        <li><label for="asl_styles_focus"><?php _e('Styles for Skiplinks when they have focus', 'wp-accessibility'); ?></label><br /> 
     
    342514             
    343515            <div class="postbox"> 
    344                 <h3><?php _e('Miscellaneous Accessibility Settings','wp-accessibility'); ?></h3> 
     516                <h3 id="contrast"><?php _e('Miscellaneous Accessibility Settings','wp-accessibility'); ?></h3> 
    345517                <div class="inside">     
    346518                <form method="post" action="<?php echo admin_url('options-general.php?page=wp-accessibility/wp-accessibility.php'); ?>"> 
     
    350522                        <li><input type="checkbox" id="wpa_lang" name="wpa_lang" <?php if ( get_option('wpa_lang') == "on") { echo 'checked="checked" '; } ?>/> <label for="wpa_lang"><?php _e('Add Site Language and text direction to HTML element','wp-accessibility'); ?></label></li> 
    351523                        <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> 
    352                         <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','wp-accessibility'); ?></label></li> 
     524                        <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> 
    353525                        <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> 
    354526                        <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> 
    355527                        <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> 
    356528                            <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> 
     529                        <li><input type="checkbox" id="wpa_focus" name="wpa_focus" <?php if ( get_option('wpa_focus') == "on") { echo 'checked="checked" '; } ?>/> <label for="wpa_focus"><?php _e('Add outline to elements on keyboard focus','wp-accessibility'); ?></label> <label for="wpa_focus_color"><?php _e('Outline color (hexadecimal, optional)','wp-accessibility' ); ?></label><input type="text" id="wpa_focus_color" name="wpa_focus_color" value="#<?php echo esc_attr(get_option('wpa_focus_color') ); ?>" /></li>                     
    357530                    </ul> 
    358531                </fieldset> 
     
    364537                </form> 
    365538                </div> 
    366             </div>           
    367              
     539            </div> 
     540            <div class="postbox"> 
     541                <h3><?php _e('Color Contrast Tester','wp-accessibility'); ?></h3> 
     542                <div class="inside">     
     543<?php 
     544$colors = wpa_contrast(); 
     545if ( $colors ) { 
     546    $l_contrast = wpa_luminosity( $colors['red1'],$colors['red2'],$colors['green1'],$colors['green2'],$colors['blue1'],$colors['blue2'] ) . ':1'; 
     547    $luminance_raw = wpa_luminosity( $colors['red1'],$colors['red2'],$colors['green1'],$colors['green2'],$colors['blue1'],$colors['blue2'] ); 
     548    $hex1 = esc_attr($colors['hex1']); 
     549    $hex2 = esc_attr($colors['hex2']); 
     550} else { 
     551    $hex1 = ''; 
     552    $hex2 = ''; 
     553    $l_contrast = false; 
     554} 
     555if ( $l_contrast ) { 
     556    $results = " 
     557            <div class='updated notice'>"; 
     558    $results .= "<p class=\"stats wcag2\">".sprintf(__('Luminosity Contrast Ratio for <code>#%2$s</code> and <code>#%3$s</code> is <strong>%1$s</strong> (Threshold: greater than 7:1 for AAA, 4.5:1 for AA)','wp-accessibility'),$l_contrast,$hex1,$hex2)."</p><p>"; 
     559    if ($luminance_raw >= 7) { 
     560        $results .= __("The colors compared <strong>pass</strong> the relative luminosity test at level AAA.",'wp-accessibility'); 
     561    } 
     562    if ($luminance_raw >= 4.5 && $luminance_raw < 7) { 
     563        $results .= __("The colors compared <strong>pass</strong> the relative luminosity test at level AA.",'wp-accessibility'); 
     564    }  
     565    if ($luminance_raw >= 3 && $luminance_raw < 4.5) { 
     566        $results .= __("The colors compared pass the relative luminosity test <strong>only when used in large print</strong> situations (greater than 18pt text or 14pt bold text.)",'wp-accessibility'); 
     567    }  
     568    if ($luminance_raw <3) { 
     569        $results .= __("The colors compared <strong>do not pass</strong> the relative luminosity test.",'wp-accessibility'); 
     570    } 
     571    $results .= " <a href='#contrast'>".__('Test another set of colors','wp-accessibility')."</a>"; 
     572    $results .="</p>"; 
     573    $results .= " 
     574                <div class=\"views\"> 
     575                    <p class='large' style=\"font-size: 2em; line-height: 1.4;color: #$hex1;background: #$hex2;border: 3px solid #$hex1\">Large Print Example</p> 
     576                    <p class='small' style=\"font-size: .9em;color: #$hex1;background: #$hex2;border: 3px solid #$hex1\">Small Print Example</p> 
     577                    <p class='large' style=\"font-size: 2em; line-height: 1.4;color: #$hex2;background: #$hex1;border: 3px solid #$hex2\">Large Print Example (Inverted)</p> 
     578                    <p class='small' style=\"font-size: .9em;color: #$hex2;background: #$hex1;border: 3px solid #$hex2\">Small Print Example (Inverted)</p> 
     579                </div> 
     580            </div>"; 
     581    echo $results; 
     582} 
     583?> 
     584                <form method="post" action="<?php echo admin_url('options-general.php?page=wp-accessibility/wp-accessibility.php'); ?>"> 
     585                <fieldset> 
     586                    <legend><?php _e('Test of relative luminosity','wp-accessibility'); ?></legend> 
     587                    <ul> 
     588                        <li class='fore'><div id="fore"></div><label for="color1"><?php _e('Foreground color','wp-accessibility'); ?></label><br /><input type="text" name="color" value="#<?php echo $hex1; ?>" size="34" id="color1" /></li> 
     589                        <li class='back'><div id="back"></div><label for="color2"><?php _e('Background color','wp-accessibility'); ?></label><br /><input type="text" name="color2" value="#<?php echo $hex2; ?>" size="34" id="color2" /></li> 
     590                    </ul> 
     591                </fieldset> 
     592                    <p> 
     593                        <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('wpa-nonce'); ?>" /> 
     594                        <input type="hidden" name="action" value="contrast" /> 
     595                    </p> 
     596                    <p><input type="submit" name="wpa-settings" class="button-primary" value="<?php _e('Check Color Contrast','wp-accessibility') ?>" /></p> 
     597                </form> 
     598                </div> 
     599            </div> 
    368600            <div class="postbox" id="get-support"> 
    369601            <h3><?php _e('Get Plug-in Support','wp-accessibility'); ?></h3> 
     
    382614                <h3><?php _e('Support this Plugin','wp-accessibility'); ?></h3> 
    383615                <div class="inside"> 
    384                     <p><?php _e("If you've found WP Accessibility useful, then please consider <a href='http://wordpress.org/extend/plugins/wp-accessibility/'>rating it five stars</a> or <a href='http://www.joedolson.com/donate.php'>making a donation</a>.",'wp-accessibility'); ?></p> 
     616                    <p><?php _e("If you've found WP Accessibility useful, then please consider <a href='http://wordpress.org/extend/plugins/wp-accessibility/'>rating it five stars</a>, <a href='http://www.joedolson.com/donate.php'>making a donation</a>, or <a href='http://translate.joedolson.com/projects/wp-accessibility'>helping with translation</a>.",'wp-accessibility'); ?></p> 
    385617                            <div> 
    386618                    <p><?php _e('<a href="http://www.joedolson.com/donate.php">Make a donation today!</a> Every donation counts - donate $2, $10, or $100 and help me keep this plug-in running!','wp-to-twitter'); ?></p> 
     
    469701    function WP_Widget_Recent_Posts_No_Title_Attributes() { 
    470702        $widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( "The most recent posts on your blog") ); 
    471         $this->WP_Widget('recent-posts-no-title-attributes', __('WP A11y: Recent Posts'), $widget_ops); 
     703        $this->WP_Widget('recent-posts-no-title-attributes', __('WP A11y: Recent Posts','wp-accessibility'), $widget_ops); 
    472704        $this->alt_option_name = 'widget_recent_entries'; 
    473705 
  • wp-accessibility/trunk/wpa-styles.css

    r615802 r618053  
    33#wpa_settings_page .meta-box-sortables { min-height: 0; } 
    44#wpa_settings_page legend { font-weight: 700; } 
     5li.fore { float: left; width: 200px; margin-right: 30px; } 
     6li.back { margin-left: 230px; } 
Note: See TracChangeset for help on using the changeset viewer.