Make WordPress Core

Ticket #25735: 25735.2.patch

File 25735.2.patch, 2.3 KB (added by johnpbloch, 12 years ago)

Unified patch

  • src/wp-includes/general-template.php

     
    20272027                $page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $prev_text . '</a>';
    20282028        endif;
    20292029        for ( $n = 1; $n <= $total; $n++ ) :
    2030                 $n_display = number_format_i18n($n);
    20312030                if ( $n == $current ) :
    2032                         $page_links[] = "<span class='page-numbers current'>$n_display</span>";
     2031                        $page_links[] = "<span class='page-numbers current'>" . number_format_i18n($n) . "</span>";
    20332032                        $dots = true;
    20342033                else :
    20352034                        if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
     
    20382037                                if ( $add_args )
    20392038                                        $link = add_query_arg( $add_args, $link );
    20402039                                $link .= $add_fragment;
    2041                                 $page_links[] = "<a class='page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>$n_display</a>";
     2040                                $page_links[] = "<a class='page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>" . number_format_i18n($n) . "</a>";
    20422041                                $dots = true;
    20432042                        elseif ( $dots && !$show_all ) :
    20442043                                $page_links[] = '<span class="page-numbers dots">' . __( '&hellip;' ) . '</span>';
  • tests/phpunit/tests/general/template.php

     
     1<?php
     2
     3class Tests_General_Template extends WP_UnitTestCase {
     4
     5        private $i18n_count = 0;
     6
     7        function increment_i18n_count() {
     8                $this->i18n_count += 1;
     9        }
     10
     11        /**
     12         * @ticket 25735
     13         */
     14        function test_paginate_links_number_format() {
     15                $this->i18n_count = 0;
     16                add_filter( 'number_format_i18n', array( $this, 'increment_i18n_count' ) );
     17                paginate_links( array(
     18                        'total'     => 100,
     19                        'current'   => 50,
     20                        'show_all'  => false,
     21                        'prev_next' => true,
     22                        'end_size'  => 1,
     23                        'mid_size'  => 1,
     24                ) );
     25                // The links should be:
     26                // < Previous 1 ... 49 50 51 ... 100 Next >
     27                $this->assertEquals( 5, $this->i18n_count );
     28                remove_filter( 'number_format_i18n', array( $this, 'increment_i18n_count' ) );
     29        }
     30
     31}