Avoid an empty href attribute in paginate_links(). Add unit tests.

props obenland, Nessworthy.
fixes #24606.
Built from https://develop.svn.wordpress.org/trunk@28671


git-svn-id: http://core.svn.wordpress.org/trunk@28489 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2014-06-05 02:10:15 +00:00
parent c20cdfcc38
commit dbff41578e

View File

@ -2476,10 +2476,10 @@ function paginate_links( $args = '' ) {
$r = '';
$page_links = array();
$dots = false;
$base = str_replace( '%_%', $args['format'], $args['base'] );
if ( $args['prev_next'] && $current && 1 < $current ) :
$link = str_replace( '%_%', 2 == $current ? '' : $args['format'], $args['base'] );
$link = str_replace( '%#%', $current - 1, $link );
$link = str_replace( '%#%', $current - 1, $base );
if ( $add_args )
$link = add_query_arg( $add_args, $link );
$link .= $args['add_fragment'];
@ -2499,8 +2499,7 @@ function paginate_links( $args = '' ) {
$dots = true;
else :
if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
$link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] );
$link = str_replace( '%#%', $n, $link );
$link = str_replace( '%#%', $n, $base );
if ( $add_args )
$link = add_query_arg( $add_args, $link );
$link .= $args['add_fragment'];
@ -2515,8 +2514,7 @@ function paginate_links( $args = '' ) {
endif;
endfor;
if ( $args['prev_next'] && $current && ( $current < $total || -1 == $total ) ) :
$link = str_replace( '%_%', $args['format'], $args['base'] );
$link = str_replace( '%#%', $current + 1, $link );
$link = str_replace( '%#%', $current + 1, $base );
if ( $add_args )
$link = add_query_arg( $add_args, $link );
$link .= $args['add_fragment'];