diff --git src/wp-includes/canonical.php src/wp-includes/canonical.php
index bd10ce5..36d3a35 100644
|
|
function redirect_canonical( $requested_url = null, $do_redirect = true ) { |
245 | 245 | } |
246 | 246 | |
247 | 247 | // Post Paging |
248 | | if ( is_singular() && ! is_front_page() && get_query_var('page') ) { |
249 | | if ( !$redirect_url ) |
250 | | $redirect_url = get_permalink( get_queried_object_id() ); |
251 | | $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' ); |
252 | | $redirect['query'] = remove_query_arg( 'page', $redirect['query'] ); |
| 248 | if ( is_singular() && ! is_front_page() ) { |
| 249 | if ( get_query_var('page') ) { |
| 250 | if ( ! $redirect_url ) |
| 251 | $redirect_url = set_url_scheme( get_permalink( get_queried_object_id() ) ); |
| 252 | $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' ); |
| 253 | $redirect['query'] = remove_query_arg( 'page', $redirect['query'] ); |
| 254 | } else { |
| 255 | $post_url = set_url_scheme( get_permalink( get_queried_object_id() ) ); |
| 256 | // If the full post's URL is not within the requested url, lets redirect there. |
| 257 | if ( strpos( $requested_url, $post_url ) === false ) |
| 258 | $redirect_url = $post_url; |
| 259 | } |
253 | 260 | } |
254 | 261 | |
255 | 262 | // paging and feeds |
diff --git tests/phpunit/tests/canonical.php tests/phpunit/tests/canonical.php
index 458db03..dc7400e 100644
|
|
class Tests_Canonical extends WP_Canonical_UnitTestCase { |
76 | 76 | // array( '/2008/?category_name=cat-a', array( 'url' => '/2008/?category_name=cat-a', 'qv' => array('category_name' => 'cat-a', 'year' => '2008' ) ) ), |
77 | 77 | |
78 | 78 | // Pages |
| 79 | array( '/sample------page/', array( 'url' => '/sample-page/', 'qv' => array('pagename' => 'sample-page', 'page' => '' ) ), 14773 ), |
| 80 | array( '/sample-page---/', array( 'url' => '/sample-page/', 'qv' => array('pagename' => 'sample-page', 'page' => '' ) ), 14773 ), |
| 81 | array( '/---sample-page/', array( 'url' => '/sample-page/', 'qv' => array('pagename' => 'sample-page', 'page' => '' ) ), 14773 ), |
79 | 82 | array( '/child-page-1/', '/parent-page/child-page-1/'), |
80 | 83 | array( '/?page_id=144', '/parent-page/child-page-1/'), |
81 | 84 | array( '/abo', '/about/' ), |