Make WordPress Core

Ticket #24606: 24606.2.diff

File 24606.2.diff, 2.9 KB (added by obenland, 12 years ago)
  • src/wp-includes/general-template.php

     
    19831983 * It is possible to add query vars to the link by using the 'add_args' argument
    19841984 * and see {@link add_query_arg()} for more information.
    19851985 *
    1986  * The 'before_page_number' and 'after_page_number' arguments allow users to 
     1986 * The 'before_page_number' and 'after_page_number' arguments allow users to
    19871987 * augment the links themselves. Typically this might be to add context to the
    19881988 * numbered links so that screen reader users understand what the links are for.
    1989  * The text strings are added before and after the page number - within the 
     1989 * The text strings are added before and after the page number - within the
    19901990 * anchor tag.
    19911991 *
    19921992 * @since 2.1.0
     
    20282028        $page_links = array();
    20292029        $n = 0;
    20302030        $dots = false;
     2031        $base = str_replace( '%_%', $format, $base );
    20312032
    20322033        if ( $prev_next && $current && 1 < $current ) :
    2033                 $link = str_replace('%_%', 2 == $current ? '' : $format, $base);
    2034                 $link = str_replace('%#%', $current - 1, $link);
     2034                $link = str_replace( '%#%', $current - 1, $base );
    20352035                if ( $add_args )
    20362036                        $link = add_query_arg( $add_args, $link );
    20372037                $link .= $add_fragment;
     
    20432043                        $dots = true;
    20442044                else :
    20452045                        if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
    2046                                 $link = str_replace('%_%', 1 == $n ? '' : $format, $base);
    2047                                 $link = str_replace('%#%', $n, $link);
     2046                                $link = str_replace( '%#%', $n, $base );
    20482047                                if ( $add_args )
    20492048                                        $link = add_query_arg( $add_args, $link );
    20502049                                $link .= $add_fragment;
     
    20572056                endif;
    20582057        endfor;
    20592058        if ( $prev_next && $current && ( $current < $total || -1 == $total ) ) :
    2060                 $link = str_replace('%_%', $format, $base);
    2061                 $link = str_replace('%#%', $current + 1, $link);
     2059                $link = str_replace( '%#%', $current + 1, $base );
    20622060                if ( $add_args )
    20632061                        $link = add_query_arg( $add_args, $link );
    20642062                $link .= $add_fragment;
  • tests/phpunit/tests/general/template.php

     
    2828                remove_filter( 'number_format_i18n', array( $this, 'increment_i18n_count' ) );
    2929        }
    3030
     31        /**
     32         * @ticket 24606
     33         */
     34        function test_paginate_links_base_value() {
     35                $links = paginate_links( array(
     36                        'current'  => 2,
     37                        'total'    => 5,
     38                        'end_size' => 1,
     39                        'mid_size' => 1,
     40                        'type'     => 'array',
     41                ) );
     42
     43                $this->assertTag( array( 'attributes' => array( 'href' => '?page=1' ) ), $links[0] );
     44                $this->assertTag( array( 'attributes' => array( 'href' => '?page=1' ) ), $links[1] );
     45        }
    3146}