From 9e48d38752eb71ad0f10a35f922f5f899af88efe Mon Sep 17 00:00:00 2001 From: markjaquith Date: Wed, 29 Aug 2007 18:10:11 +0000 Subject: [PATCH] Fix paging and preview links for canonical stuff. see #4773. fixes #4862 git-svn-id: http://svn.automattic.com/wordpress/trunk@5974 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/canonical.php | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php index 896c5387cf..229c623932 100644 --- a/wp-includes/canonical.php +++ b/wp-includes/canonical.php @@ -64,28 +64,31 @@ function redirect_canonical() { $redirect['query'] = remove_query_arg('author', $redirect['author']); } - // paging - if ( is_paged() && strpos($redirect['query'], 'paged=') !== false ) { - if ( $paged = get_query_var('paged') ) { - if ( $paged > 1 ) { - if ( !$redirect_url ) - $redirect_url = $requested_url; - $paged_redirect = @parse_url($redirect_url); - $paged_redirect['path'] = preg_replace('|/index.php/?$|', '/', $paged_redirect['path']); - $paged_redirect['path'] = trailingslashit($paged_redirect['path']); - if ( $wp_rewrite->using_index_permalinks() && strpos($paged_redirect['path'], '/index.php/') === false ) - $paged_redirect['path'] .= 'index.php/'; - $paged_redirect['path'] .= user_trailingslashit("page/$paged"); - $redirect_url = $paged_redirect['scheme'] . '://' . $paged_redirect['host'] . $paged_redirect['path']; - } - $redirect['query'] = remove_query_arg('paged', $redirect['query']); + // paging + if ( $paged = get_query_var('paged') ) { + if ( $paged > 1 ) { + if ( !$redirect_url ) + $redirect_url = $requested_url; + $paged_redirect = @parse_url($redirect_url); + $paged_redirect['path'] = preg_replace('|/index.php/?$|', '/', $paged_redirect['path']); + $paged_redirect['path'] = trailingslashit($paged_redirect['path']); + if ( $wp_rewrite->using_index_permalinks() && strpos($paged_redirect['path'], '/index.php/') === false ) + $paged_redirect['path'] .= 'index.php/'; + $paged_redirect['path'] .= user_trailingslashit("page/$paged"); + $redirect_url = $paged_redirect['scheme'] . '://' . $paged_redirect['host'] . $paged_redirect['path']; } + $redirect['query'] = remove_query_arg('paged', $redirect['query']); } } // tack on any additional query vars - if ( $redirect_url && $redirect['query'] ) - $redirect_url .= '?' . $redirect['query']; + if ( $redirect_url && $redirect['query'] ) { + if ( strpos($redirect_url, '?') !== false ) + $redirect_url .= '&'; + else + $redirect_url .= '?'; + $redirect_url .= $redirect['query']; + } if ( !$redirect_url ) { // we're only going down this road if we don't have a WP-generated link from above