WordPress.org

Make WordPress Core

Ticket #39251: 39251.patch

File 39251.patch, 1.9 KB (added by birgire, 3 years ago)
  • src/wp-includes/general-template.php

    diff --git src/wp-includes/general-template.php src/wp-includes/general-template.php
    index bb16f3e..7a01cda 100644
    function paginate_links( $args = '' ) { 
    33603360        }
    33613361        $current  = (int) $args['current'];
    33623362        $end_size = (int) $args['end_size']; // Out of bounds?  Make it the default.
    3363         if ( $end_size < 1 ) {
     3363        if ( $end_size < 0 ) {
    33643364                $end_size = 1;
    33653365        }
    33663366        $mid_size = (int) $args['mid_size'];
    function paginate_links( $args = '' ) { 
    33883388                 */
    33893389                $page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['prev_text'] . '</a>';
    33903390        endif;
     3391
     3392        if( 0 === $end_size && ! $args['show_all'] ) {
     3393                $dots = true;
     3394        }
     3395
    33913396        for ( $n = 1; $n <= $total; $n++ ) :
    33923397                if ( $n == $current ) :
    33933398                        $page_links[] = "<span aria-current='" . esc_attr( $args['aria_current'] ) . "' class='page-numbers current'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . "</span>";
  • tests/phpunit/tests/general/paginateLinks.php

    diff --git tests/phpunit/tests/general/paginateLinks.php tests/phpunit/tests/general/paginateLinks.php
    index 2fe9639..493dc43 100644
    EXPECTED; 
    321321                $page_2_url = home_url() . '?foo=2';
    322322                $this->assertContains( "<a class='page-numbers' href='$page_2_url'>2</a>", $links );
    323323        }
     324
     325        /**
     326         * @ticket 39251
     327         */
     328        public function test_paginate_links_should_support_zero_end_size() {
     329
     330                $links = paginate_links( array(
     331                        'total'         => 10,
     332                        'current'       => 5,
     333                        'mid_size'      => 1,
     334                        'end_size'      => 0,
     335                        'type'          => 'array',
     336                ) );
     337
     338                $this->assertSame( '<span class="page-numbers dots">&hellip;</span>', $links[1] );
     339                $this->assertSame( '<span class="page-numbers dots">&hellip;</span>', $links[5] );
     340        }
    324341}