Make WordPress Core

Ticket #41859: 41859.diff

File 41859.diff, 4.7 KB (added by afercia, 8 years ago)
  • src/wp-includes/post-template.php

     
    862862 * Quicktag one or more times). This tag must be within The Loop.
    863863 *
    864864 * @since 1.2.0
     865 * @since 5.0.0 Added the `aria_current` argument.
    865866 *
    866867 * @global int $page
    867868 * @global int $numpages
     
    877878 *                                          Also prepended to the current item, which is not linked. Default empty.
    878879 *     @type string       $link_after       HTML or text to append to each Pages link inside the `<a>` tag.
    879880 *                                          Also appended to the current item, which is not linked. Default empty.
     881 *     @type string       $aria_current     The value for the aria-current attribute. Possible values are 'page',
     882 *                                          'step', 'location', 'date', 'time', 'true', 'false'. Default is 'page'.
    880883 *     @type string       $next_or_number   Indicates whether page numbers should be used. Valid values are number
    881884 *                                          and next. Default is 'number'.
    882885 *     @type string       $separator        Text between pagination links. Default is ' '.
     
    893896        global $page, $numpages, $multipage, $more;
    894897
    895898        $defaults = array(
    896                 'before'           => '<p>' . __( 'Pages:' ),
     899                'before'           => '<p class="page-links">' . __( 'Pages:' ),
    897900                'after'            => '</p>',
    898901                'link_before'      => '',
    899902                'link_after'       => '',
     903                'aria_current'     => 'page',
    900904                'next_or_number'   => 'number',
    901905                'separator'        => ' ',
    902906                'nextpagelink'     => __( 'Next page' ),
     
    924928                                $link = $r['link_before'] . str_replace( '%', $i, $r['pagelink'] ) . $r['link_after'];
    925929                                if ( $i != $page || ! $more && 1 == $page ) {
    926930                                        $link = _wp_link_page( $i ) . $link . '</a>';
    927                                 }
     931                                } elseif ( $i == $page ) {
     932                                        $link = '<span class="page-link current" aria-current="' . esc_attr( $r['aria_current'] ) . '">' . $link . '</span>';
     933                                }
    928934                                /**
    929935                                 * Filters the HTML output of individual page number links.
    930936                                 *
     
    10171023                $url = get_preview_post_link( $post, $query_args, $url );
    10181024        }
    10191025
    1020         return '<a href="' . esc_url( $url ) . '">';
     1026        return '<a href="' . esc_url( $url ) . '" class="page-link">';
    10211027}
    10221028
    10231029//
  • tests/phpunit/tests/post/template.php

     
    1414
    1515                setup_postdata( get_post( $post_id ) );
    1616
    17                 $permalink = sprintf( '<a href="%s">', get_permalink() );
     17                $permalink = sprintf( '<a href="%s" class="page-link">', 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="page-links">Pages: <span class="page-link 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=\"page-link current\" aria-current=\"page\">1</span> {$page2}2</a> {$page3}3</a>";
    2727                $output       = wp_link_pages(
    2828                        array(
    2929                                'echo'   => 0,
     
    3434
    3535                $this->assertEquals( $before_after, $output );
    3636
    37                 $separator = " 1{$page2}2</a>{$page3}3</a>";
     37                $separator = " <span class=\"page-link current\" aria-current=\"page\">1</span>{$page2}2</a>{$page3}3</a>";
    3838                $output    = wp_link_pages(
    3939                        array(
    4040                                'echo'      => 0,
     
    4646
    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=\"page-link 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(
    5252                                'echo'        => 0,
     
    107107                $this->assertEquals( $next_prev_link, $output );
    108108
    109109                $GLOBALS['page'] = 1;
    110                 $separator       = "<p>Pages: 1 | {$page2}2</a> | {$page3}3</a></p>";
     110                $separator       = "<p class=\"page-links\">Pages: <span class=\"page-link current\" aria-current=\"page\">1</span> | {$page2}2</a> | {$page3}3</a></p>";
    111111                $output          = wp_link_pages(
    112112                        array(
    113113                                'echo'      => 0,
     
    117117
    118118                $this->assertEquals( $separator, $output );
    119119
    120                 $pagelink = " Page 1 | {$page2}Page 2</a> | {$page3}Page 3</a>";
     120                $pagelink = " <span class=\"page-link current\" aria-current=\"page\">Page 1</span> | {$page2}Page 2</a> | {$page3}Page 3</a>";
    121121                $output   = wp_link_pages(
    122122                        array(
    123123                                'echo'      => 0,