Make WordPress Core

Ticket #40833: 40833.2.diff

File 40833.2.diff, 5.1 KB (added by afercia, 7 years ago)
  • src/wp-includes/general-template.php

     
    32613261 * anchor tag.
    32623262 *
    32633263 * @since 2.1.0
     3264 * @since 4.9.0 Added the `aria_current` argument.
    32643265 *
    32653266 * @global WP_Query   $wp_query
    32663267 * @global WP_Rewrite $wp_rewrite
     
    32733274 *     @type int    $total              The total amount of pages. Default is the value WP_Query's
    32743275 *                                      `max_num_pages` or 1.
    32753276 *     @type int    $current            The current page number. Default is 'paged' query var or 1.
     3277 *     @type string $aria_current       The value for the aria-current attribute. Possible values are 'page',
     3278 *                                      'step', 'location', 'date', 'time', 'true', 'false'. Default is 'page'.
    32763279 *     @type bool   $show_all           Whether to show all pages. Default false.
    32773280 *     @type int    $end_size           How many numbers on either the start and the end list edges.
    32783281 *                                      Default 1.
     
    33083311        $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%';
    33093312
    33103313        $defaults = array(
    3311                 'base' => $pagenum_link, // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
    3312                 'format' => $format, // ?page=%#% : %#% is replaced by the page number
    3313                 'total' => $total,
    3314                 'current' => $current,
    3315                 'show_all' => false,
    3316                 'prev_next' => true,
    3317                 'prev_text' => __('« Previous'),
    3318                 'next_text' => __('Next »'),
    3319                 'end_size' => 1,
    3320                 'mid_size' => 2,
    3321                 'type' => 'plain',
    3322                 'add_args' => array(), // array of query args to add
    3323                 'add_fragment' => '',
     3314                'base'               => $pagenum_link, // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
     3315                'format'             => $format, // ?page=%#% : %#% is replaced by the page number
     3316                'total'              => $total,
     3317                'current'            => $current,
     3318                'aria_current'       => 'page',
     3319                'show_all'           => false,
     3320                'prev_next'          => true,
     3321                'prev_text'          => __( '« Previous' ),
     3322                'next_text'          => __( 'Next »' ),
     3323                'end_size'           => 1,
     3324                'mid_size'           => 2,
     3325                'type'               => 'plain',
     3326                'add_args'           => array(), // array of query args to add
     3327                'add_fragment'       => '',
    33243328                'before_page_number' => '',
    3325                 'after_page_number' => ''
     3329                'after_page_number'  => '',
    33263330        );
    33273331
    33283332        $args = wp_parse_args( $args, $defaults );
     
    33863390        endif;
    33873391        for ( $n = 1; $n <= $total; $n++ ) :
    33883392                if ( $n == $current ) :
    3389                         $page_links[] = "<span class='page-numbers current'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . "</span>";
     3393                        $page_links[] = "<span aria-current='" . $args['aria_current'] . "' class='page-numbers current'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . "</span>";
    33903394                        $dots = true;
    33913395                else :
    33923396                        if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
  • tests/phpunit/tests/general/paginateLinks.php

     
    1616                $page50 = get_pagenum_link( 50 );
    1717
    1818                $expected =<<<EXPECTED
    19 <span class='page-numbers current'>1</span>
     19<span aria-current='page' class='page-numbers current'>1</span>
    2020<a class='page-numbers' href='$page2'>2</a>
    2121<a class='page-numbers' href='$page3'>3</a>
    2222<span class="page-numbers dots">&hellip;</span>
     
    3434                $page50 = home_url( '/page/50/' );
    3535
    3636                $expected =<<<EXPECTED
    37 <span class='page-numbers current'>1</span>
     37<span aria-current='page' class='page-numbers current'>1</span>
    3838<a class='page-numbers' href='$page2'>2</a>
    3939<a class='page-numbers' href='$page3'>3</a>
    4040<span class="page-numbers dots">&hellip;</span>
     
    5454
    5555                $expected =<<<EXPECTED
    5656<a class='page-numbers' href='$home'>1</a>
    57 <span class='page-numbers current'>2</span>
     57<span aria-current='page' class='page-numbers current'>2</span>
    5858<a class='page-numbers' href='$page3'>3</a>
    5959<a class='page-numbers' href='$page4'>4</a>
    6060<span class="page-numbers dots">&hellip;</span>
     
    7474                $expected =<<<EXPECTED
    7575<a class="prev page-numbers" href="$home">&laquo; Previous</a>
    7676<a class='page-numbers' href='$home'>1</a>
    77 <span class='page-numbers current'>2</span>
     77<span aria-current='page' class='page-numbers current'>2</span>
    7878<a class='page-numbers' href='$page3'>3</a>
    7979<a class='page-numbers' href='$page4'>4</a>
    8080<span class="page-numbers dots">&hellip;</span>
     
    299299                        'type'    => 'array',
    300300                ) );
    301301
    302                 $this->assertContains( "<span class='page-numbers current'>3</span>", $links );
     302                $this->assertContains( "<span aria-current='page' class='page-numbers current'>3</span>", $links );
    303303        }
    304304
    305305        /**