Changeset 28671
- Timestamp:
- 06/05/2014 02:09:12 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/general-template.php
r28669 r28671 2477 2477 $page_links = array(); 2478 2478 $dots = false; 2479 $base = str_replace( '%_%', $args['format'], $args['base'] ); 2479 2480 2480 2481 if ( $args['prev_next'] && $current && 1 < $current ) : 2481 $link = str_replace( '%_%', 2 == $current ? '' : $args['format'], $args['base'] ); 2482 $link = str_replace( '%#%', $current - 1, $link ); 2482 $link = str_replace( '%#%', $current - 1, $base ); 2483 2483 if ( $add_args ) 2484 2484 $link = add_query_arg( $add_args, $link ); … … 2500 2500 else : 2501 2501 if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) : 2502 $link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] ); 2503 $link = str_replace( '%#%', $n, $link ); 2502 $link = str_replace( '%#%', $n, $base ); 2504 2503 if ( $add_args ) 2505 2504 $link = add_query_arg( $add_args, $link ); … … 2516 2515 endfor; 2517 2516 if ( $args['prev_next'] && $current && ( $current < $total || -1 == $total ) ) : 2518 $link = str_replace( '%_%', $args['format'], $args['base'] ); 2519 $link = str_replace( '%#%', $current + 1, $link ); 2517 $link = str_replace( '%#%', $current + 1, $base ); 2520 2518 if ( $add_args ) 2521 2519 $link = add_query_arg( $add_args, $link ); -
trunk/tests/phpunit/tests/general/paginateLinks.php
r28397 r28671 80 80 remove_filter( 'number_format_i18n', array( $this, 'increment_i18n_count' ) ); 81 81 } 82 83 /** 84 * @ticket 24606 85 */ 86 function test_paginate_links_base_value() { 87 88 // Current page: 2 89 $links = paginate_links( array( 90 'current' => 2, 91 'total' => 5, 92 'end_size' => 1, 93 'mid_size' => 1, 94 'type' => 'array', 95 ) ); 96 97 // It's supposed to link to page 1: 98 $this->assertTag( array( 'tag' => 'a', 'attributes' => array( 'href' => '?page=1' ) ), $links[0] ); 99 $this->assertTag( array( 'tag' => 'a', 'attributes' => array( 'href' => '?page=1' ) ), $links[1] ); 100 101 // It's not supposed to have an empty href. 102 $this->assertNotTag( array( 'tag' => 'a', 'attributes' => array( 'class' => 'prev page-numbers', 'href' => '' ) ), $links[0] ); 103 $this->assertNotTag( array( 'tag' => 'a', 'attributes' => array( 'class' => 'page-numbers', 'href' => '' ) ), $links[1] ); 104 105 // Current page: 1 106 $links = paginate_links( array( 107 'current' => 1, 108 'total' => 5, 109 'end_size' => 1, 110 'mid_size' => 1, 111 'type' => 'array', 112 ) ); 113 114 $this->assertTag( array( 'tag' => 'span', 'attributes' => array( 'class' => 'current' ) ), $links[0] ); 115 $this->assertTag( array( 'tag' => 'a', 'attributes' => array( 'href' => '?page=2' ) ), $links[1] ); 116 } 117 82 118 }
Note: See TracChangeset
for help on using the changeset viewer.