Fix get_pagenum_link(). fixes #3930

git-svn-id: http://svn.automattic.com/wordpress/trunk@5481 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
rob1n 2007-05-16 02:47:24 +00:00
parent d4288b9aee
commit 77b86e7c68
1 changed files with 12 additions and 9 deletions

View File

@ -473,22 +473,20 @@ function get_pagenum_link($pagenum = 1) {
$home_root = $home_root['path']; $home_root = $home_root['path'];
$home_root = preg_quote( trailingslashit( $home_root ), '|' ); $home_root = preg_quote( trailingslashit( $home_root ), '|' );
$request = preg_replace('|^'. $home_root . '|', '', $qstr); $request = preg_replace('|^'. $home_root . '|', '', $request);
$request = preg_replace('|^/+|', '', $qstr); $request = preg_replace('|^/+|', '', $request);
$index = $_SERVER['PHP_SELF'];
$index = preg_replace('|^'. $home_root . '|', '', $index);
$index = preg_replace('|^/+|', '', $index);
if ( !$wp_rewrite->using_permalinks() ) { if ( !$wp_rewrite->using_permalinks() ) {
$base = trailingslashit( get_bloginfo( 'home' ) ); $base = trailingslashit( get_bloginfo( 'home' ) );
if ( $pagenum > 1 ) { if ( $pagenum > 1 ) {
$result = add_query_arg( 'paged', $pagenum, $request ); $result = add_query_arg( 'paged', $pagenum, $base . $request );
} else { } else {
$result = $base . $request; $result = $base . $request;
} }
} else { } else {
$request = preg_replace( '|/?page/(.+)/?$|', '', $request);
$qs_regex = '|\?.*?$|'; $qs_regex = '|\?.*?$|';
preg_match( $qs_regex, $request, $qs_match ); preg_match( $qs_regex, $request, $qs_match );
@ -499,13 +497,18 @@ function get_pagenum_link($pagenum = 1) {
$query_string = ''; $query_string = '';
} }
$base = get_bloginfo( 'home' ) . '/'; $base = trailingslashit( get_bloginfo( 'url' ) );
if ( $wp_rewrite->using_index_permalinks() && $pagenum > 1 ) { if ( $wp_rewrite->using_index_permalinks() && $pagenum > 1 ) {
$base .= 'index.php/'; $base .= 'index.php/';
} }
$request = ( $pagenum > 1 ) ? $request . user_trailingslashit( 'page/' . $pagenum, 'paged' ) : $request; if ( $pagenum > 1 ) {
$request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( 'page/' . $pagenum, 'paged' );
} else {
$request = user_trailingslashit( $request );
}
$result = $base . $request . $query_string; $result = $base . $request . $query_string;
} }