Make WordPress Core


Ignore:
Timestamp:
01/12/2018 08:16:56 PM (7 years ago)
Author:
afercia
Message:

Accessibility: use aria-current for the paginated post links output by wp_link_pages().

Continues the introduction in core of the aria-current attribute after [41683], [41359], and [41371].

  • changes the wp_link_pages() (see the nextpage quicktag) output to use an aria-current attribute on the current item
  • adds post-nav-links and post-page-numbers CSS classes to help themes style these links
  • updates the related tests

Props antonioeatgoat, alexstine.
Fixes #41859.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/template.php

    r42343 r42440  
    1515        setup_postdata( get_post( $post_id ) );
    1616
    17         $permalink = sprintf( '<a href="%s">', get_permalink() );
     17        $permalink = sprintf( '<a href="%s" class="post-page-numbers">', get_permalink() );
    1818        $page2     = _wp_link_page( 2 );
    1919        $page3     = _wp_link_page( 3 );
    2020
    21         $expected = "<p>Pages: 1 {$page2}2</a> {$page3}3</a></p>";
     21        $expected = '<p class="post-nav-links">Pages: <span class="post-page-numbers current" aria-current="page">1</span> ' . $page2 . '2</a> ' . $page3 . '3</a></p>';
    2222        $output   = wp_link_pages( array( 'echo' => 0 ) );
    2323
    2424        $this->assertEquals( $expected, $output );
    2525
    26         $before_after = " 1 {$page2}2</a> {$page3}3</a>";
     26        $before_after = " <span class=\"post-page-numbers current\" aria-current=\"page\">1</span> {$page2}2</a> {$page3}3</a>";
    2727        $output       = wp_link_pages(
    2828            array(
     
    3535        $this->assertEquals( $before_after, $output );
    3636
    37         $separator = " 1{$page2}2</a>{$page3}3</a>";
     37        $separator = " <span class=\"post-page-numbers current\" aria-current=\"page\">1</span>{$page2}2</a>{$page3}3</a>";
    3838        $output    = wp_link_pages(
    3939            array(
     
    4747        $this->assertEquals( $separator, $output );
    4848
    49         $link   = " <em>1</em>{$page2}<em>2</em></a>{$page3}<em>3</em></a>";
     49        $link   = " <span class=\"post-page-numbers current\" aria-current=\"page\"><em>1</em></span>{$page2}<em>2</em></a>{$page3}<em>3</em></a>";
    5050        $output = wp_link_pages(
    5151            array(
     
    108108
    109109        $GLOBALS['page'] = 1;
    110         $separator       = "<p>Pages: 1 | {$page2}2</a> | {$page3}3</a></p>";
     110        $separator       = "<p class=\"post-nav-links\">Pages: <span class=\"post-page-numbers current\" aria-current=\"page\">1</span> | {$page2}2</a> | {$page3}3</a></p>";
    111111        $output          = wp_link_pages(
    112112            array(
     
    118118        $this->assertEquals( $separator, $output );
    119119
    120         $pagelink = " Page 1 | {$page2}Page 2</a> | {$page3}Page 3</a>";
     120        $pagelink = " <span class=\"post-page-numbers current\" aria-current=\"page\">Page 1</span> | {$page2}Page 2</a> | {$page3}Page 3</a>";
    121121        $output   = wp_link_pages(
    122122            array(
Note: See TracChangeset for help on using the changeset viewer.