Ticket #24606: 24606.3.diff
File 24606.3.diff, 3.6 KB (added by , 11 years ago) |
---|
-
src/wp-includes/general-template.php
1983 1983 * It is possible to add query vars to the link by using the 'add_args' argument 1984 1984 * and see {@link add_query_arg()} for more information. 1985 1985 * 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 1987 1987 * augment the links themselves. Typically this might be to add context to the 1988 1988 * 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 1990 1990 * anchor tag. 1991 1991 * 1992 1992 * @since 2.1.0 … … 2028 2028 $page_links = array(); 2029 2029 $n = 0; 2030 2030 $dots = false; 2031 $base = str_replace( '%_%', $format, $base ); 2031 2032 2032 2033 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 ); 2035 2035 if ( $add_args ) 2036 2036 $link = add_query_arg( $add_args, $link ); 2037 2037 $link .= $add_fragment; … … 2043 2043 $dots = true; 2044 2044 else : 2045 2045 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 ); 2048 2047 if ( $add_args ) 2049 2048 $link = add_query_arg( $add_args, $link ); 2050 2049 $link .= $add_fragment; … … 2057 2056 endif; 2058 2057 endfor; 2059 2058 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 ); 2062 2060 if ( $add_args ) 2063 2061 $link = add_query_arg( $add_args, $link ); 2064 2062 $link .= $add_fragment; -
tests/phpunit/tests/general/template.php
28 28 remove_filter( 'number_format_i18n', array( $this, 'increment_i18n_count' ) ); 29 29 } 30 30 31 /** 32 * @ticket 24606 33 */ 34 function test_paginate_links_base_value() { 35 36 // Current page: 2 37 $links = paginate_links( array( 38 'current' => 2, 39 'total' => 5, 40 'end_size' => 1, 41 'mid_size' => 1, 42 'type' => 'array', 43 ) ); 44 45 // It's supposed to link to page 1: 46 $this->assertTag( array( 'tag' => 'a', 'attributes' => array( 'href' => '?page=1' ) ), $links[0] ); 47 $this->assertTag( array( 'tag' => 'a', 'attributes' => array( 'href' => '?page=1' ) ), $links[1] ); 48 49 // It's not supposed to have an empty href. 50 $this->assertNotTag( array( 'tag' => 'a', 'attributes' => array( 'class' => 'prev page-numbers', 'href' => '' ) ), $links[0] ); 51 $this->assertNotTag( array( 'tag' => 'a', 'attributes' => array( 'class' => 'page-numbers', 'href' => '' ) ), $links[1] ); 52 53 // Current page: 1 54 $links = paginate_links( array( 55 'current' => 1, 56 'total' => 5, 57 'end_size' => 1, 58 'mid_size' => 1, 59 'type' => 'array', 60 ) ); 61 62 $this->assertTag( array( 'tag' => 'span', 'attributes' => array( 'class' => 'current' ) ), $links[0] ); 63 $this->assertTag( array( 'tag' => 'a', 'attributes' => array( 'href' => '?page=2' ) ), $links[1] ); 64 } 31 65 }