WordPress.org

Make WordPress Core


Ignore:
Timestamp:
06/25/2015 08:31:51 PM (7 years ago)
Author:
wonderboymusic
Message:

List tables: when post navigation links point to the current page, use <span>s and text instead of <a>s.

Props afercia.
Fixes #32253.

File:
1 edited

Legend:

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

    r32800 r32948  
    705705        $total_pages_after  = '</span>';
    706706
    707         $disable_first = $disable_last = '';
    708         if ( $current == 1 ) {
    709             $disable_first = ' disabled';
    710         }
    711         if ( $current == $total_pages ) {
    712             $disable_last = ' disabled';
    713         }
    714         $page_links[] = sprintf( "<a class='%s' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
    715             'first-page' . $disable_first,
    716             esc_url( remove_query_arg( 'paged', $current_url ) ),
    717             __( 'First page' ),
    718             '&laquo;'
    719         );
    720 
    721         $page_links[] = sprintf( "<a class='%s' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
    722             'prev-page' . $disable_first,
    723             esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
    724             __( 'Previous page' ),
    725             '&lsaquo;'
    726         );
     707        $disable_first = $disable_last = $disable_prev = $disable_next = false;
     708
     709        if ( $current == 1 ) {
     710            $disable_first = true;
     711            $disable_prev = true;
     712        }
     713        if ( $current == 2 ) {
     714            $disable_first = true;
     715        }
     716        if ( $current == $total_pages ) {
     717            $disable_last = true;
     718            $disable_next = true;
     719        }
     720        if ( $current == $total_pages - 1 ) {
     721            $disable_last = true;
     722        }
     723
     724        if ( $disable_first ) {
     725            $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&laquo;</span>';
     726        } else {
     727            $page_links[] = sprintf( "<a class='first-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
     728                esc_url( remove_query_arg( 'paged', $current_url ) ),
     729                __( 'First page' ),
     730                '&laquo;'
     731            );
     732        }
     733
     734        if ( $disable_prev ) {
     735            $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&lsaquo;</span>';
     736        } else {
     737            $page_links[] = sprintf( "<a class='prev-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
     738                esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
     739                __( 'Previous page' ),
     740                '&lsaquo;'
     741            );
     742        }
    727743
    728744        if ( 'bottom' == $which ) {
    729745            $html_current_page  = $current;
    730             $total_pages_before = '<span id="table-paging" class="paging-input">';
     746            $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page' ) . '</span><span id="table-paging" class="paging-input">';
    731747        } else {
    732748            $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' />",
     
    739755        $page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . $total_pages_after;
    740756
    741         $page_links[] = sprintf( "<a class='%s' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
    742             'next-page' . $disable_last,
    743             esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
    744             __( 'Next page' ),
    745             '&rsaquo;'
    746         );
    747 
    748         $page_links[] = sprintf( "<a class='%s' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
    749             'last-page' . $disable_last,
    750             esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
    751             __( 'Last page' ),
    752             '&raquo;'
    753         );
     757        if ( $disable_next ) {
     758            $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&rsaquo;</span>';
     759        } else {
     760            $page_links[] = sprintf( "<a class='next-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
     761                esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
     762                __( 'Next page' ),
     763                '&rsaquo;'
     764            );
     765        }
     766
     767        if ( $disable_last ) {
     768            $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&raquo;</span>';
     769        } else {
     770            $page_links[] = sprintf( "<a class='last-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
     771                esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
     772                __( 'Last page' ),
     773                '&raquo;'
     774            );
     775        }
    754776
    755777        $pagination_links_class = 'pagination-links';
Note: See TracChangeset for help on using the changeset viewer.