Add screen reader text to checkboxes in list tables. Props MikeLittle, nacin. see #21325

git-svn-id: http://core.svn.wordpress.org/trunk@21317 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2012-07-24 18:01:22 +00:00
parent 5ac8a32840
commit c36145c9aa
7 changed files with 25 additions and 9 deletions

View File

@ -317,8 +317,10 @@ class WP_Comments_List_Table extends WP_List_Table {
}
function column_cb( $comment ) {
if ( $this->user_can )
echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />";
if ( $this->user_can ) {
echo '<label class="screen-reader-text" for="cb-select-' . $comment->comment_ID . '">' . __( 'Select comment' )
. "</label><input id='cb-select-$comment->comment_ID' type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />";
}
}
function column_comment( $comment ) {

View File

@ -129,7 +129,8 @@ class WP_Links_List_Table extends WP_List_Table {
switch ( $column_name ) {
case 'cb':
echo '<th scope="row" class="check-column"><input type="checkbox" name="linkcheck[]" value="'. esc_attr( $link->link_id ) .'" /></th>';
echo '<th scope="row" class="check-column"><label for="cb-select-' . $link->link_id . '" class="screen-reader-text">' . sprintf( __( 'Select %s' ), $link->link_name )
. '</label><input type="checkbox" name="linkcheck[]" id="cb-select-' . $link->link_id . '" value="'. esc_attr( $link->link_id ) .'" /></th>';
break;
case 'name':

View File

@ -664,6 +664,13 @@ class WP_List_Table {
else
$current_order = 'asc';
if ( ! empty( $columns['cb'] ) ) {
static $cb_counter = 1;
$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' )
. '</label><input id="cb-select-all-' . $cb_counter . '" type="checkbox" />';
$cb_counter++;
}
foreach ( $columns as $column_key => $column_display_name ) {
$class = array( 'manage-column', "column-$column_key" );

View File

@ -191,7 +191,8 @@ foreach ( $columns as $column_name => $column_display_name ) {
?>
<th scope="row" class="check-column">
<?php if ( $user_can_edit ) { ?>
<input type="checkbox" name="media[]" value="<?php the_ID(); ?>" />
<label for="cb-select-<?php the_ID(); ?>" class="screen-reader-text"><?php echo sprintf( __( 'Select %s' ), $att_title );?></label>
<input type="checkbox" name="media[]" id="cb-select-<?php the_ID(); ?>" value="<?php the_ID(); ?>" />
<?php } ?>
</th>
<?php

View File

@ -492,7 +492,10 @@ class WP_Posts_List_Table extends WP_List_Table {
case 'cb':
?>
<th scope="row" class="check-column"><?php if ( $can_edit_post ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></th>
<th scope="row" class="check-column"><?php if ( $can_edit_post ) { ?>
<label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php printf( __( 'Select %s' ), $title );
?></label><input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
<?php } ?></th>
<?php
break;

View File

@ -236,9 +236,10 @@ class WP_Terms_List_Table extends WP_List_Table {
$default_term = get_option( 'default_' . $taxonomy );
if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
return '<input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" />';
else
return '&nbsp;';
return '<label for="cb-select-' . $tag->term_id . '" class="screen-reader-text">' . sprintf( __( 'Select %s' ), $tag->name )
. '</label><input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" id="cb-select-' . $tag->term_id . '" />';
return '&nbsp;';
}
function column_name( $tag ) {

View File

@ -256,7 +256,8 @@ class WP_Users_List_Table extends WP_List_Table {
$edit .= $this->row_actions( $actions );
// Set up the checkbox ( because the user is editable, otherwise its empty )
$checkbox = "<input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' />";
$checkbox = '<label for="cb-select-' . $user_object->ID . '" class="screen-reader-text">' . sprintf( __( 'Select %s' ), $user_object->user_login )
. "</label><input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' />";
} else {
$edit = '<strong>' . $user_object->user_login . '</strong>';