Make WordPress Core


Ignore:
Timestamp:
06/05/2015 05:00:23 AM (9 years ago)
Author:
obenland
Message:

Text improvements for screen readers in list table paginations.

Removes title attributes where reasonable and uses accessible hidden text.
Screen readers will now correctly read out all available information.

Props afercia, rianrietveld.
Fixes #32028.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-list-table.php

    r32662 r32693  
    702702        $page_links = array();
    703703
     704        $total_pages_before = '<span class="paging-input">';
     705        $total_pages_after  = '</span>';
     706
    704707        $disable_first = $disable_last = '';
    705708        if ( $current == 1 ) {
     
    709712            $disable_last = ' disabled';
    710713        }
    711         $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
     714        $page_links[] = sprintf( "<a class='%s' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
    712715            'first-page' . $disable_first,
    713             esc_attr__( 'Go to the first page' ),
    714716            esc_url( remove_query_arg( 'paged', $current_url ) ),
     717            __( 'First page' ),
    715718            '&laquo;'
    716719        );
    717720
    718         $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
     721        $page_links[] = sprintf( "<a class='%s' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
    719722            'prev-page' . $disable_first,
    720             esc_attr__( 'Go to the previous page' ),
    721723            esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
     724            __( 'Previous page' ),
    722725            '&lsaquo;'
    723726        );
    724727
    725728        if ( 'bottom' == $which ) {
    726             $html_current_page = $current;
     729            $html_current_page  = $current;
     730            $total_pages_before = '<span id="table-paging" class="paging-input">';
    727731        } else {
    728             $html_current_page = sprintf( "%s<input class='current-page' id='current-page-selector' title='%s' type='text' name='paged' value='%s' size='%d' />",
    729                 '<label for="current-page-selector" class="screen-reader-text">' . __( 'Select Page' ) . '</label>',
    730                 esc_attr__( 'Current page' ),
     732            $html_current_page = sprintf( "%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' />",
     733                '<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page' ) . '</label>',
    731734                $current,
    732735                strlen( $total_pages )
     
    734737        }
    735738        $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
    736         $page_links[] = '<span class="paging-input">' . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . '</span>';
    737 
    738         $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
     739        $page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . $total_pages_after;
     740
     741        $page_links[] = sprintf( "<a class='%s' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
    739742            'next-page' . $disable_last,
    740             esc_attr__( 'Go to the next page' ),
    741743            esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
     744            __( 'Next page' ),
    742745            '&rsaquo;'
    743746        );
    744747
    745         $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
     748        $page_links[] = sprintf( "<a class='%s' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
    746749            'last-page' . $disable_last,
    747             esc_attr__( 'Go to the last page' ),
    748750            esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
     751            __( 'Last page' ),
    749752            '&raquo;'
    750753        );
Note: See TracChangeset for help on using the changeset viewer.