Changeset 47760
- Timestamp:
- 05/04/2020 10:40:06 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/canonical.php
r47759 r47760 187 187 } 188 188 189 // Strip off non-existing <!--nextpage--> links from single posts or pages. 190 if ( get_query_var( 'page' ) ) { 191 $post_id = 0; 192 193 if ( $wp_query->queried_object instanceof WP_Post ) { 194 $post_id = $wp_query->queried_object->ID; 195 } elseif ( $wp_query->post ) { 196 $post_id = $wp_query->post->ID; 197 } 198 199 $redirect_url = get_permalink( $post_id ); 200 201 $redirect['path'] = rtrim( $redirect['path'], (int) get_query_var( 'page' ) . '/' ); 202 $redirect['query'] = remove_query_arg( 'page', $redirect['query'] ); 203 } 204 189 205 if ( ! $redirect_url ) { 190 206 $redirect_url = redirect_guess_404_permalink(); … … 197 213 ); 198 214 } 199 }200 201 // Strip off non-existing page links from single posts or pages.202 if ( get_query_var( 'page' ) && $wp_query->post ) {203 $redirect['path'] = rtrim( $redirect['path'], (int) get_query_var( 'page' ) . '/' );204 $redirect['query'] = remove_query_arg( 'page', $redirect['query'] );205 206 $redirect_url = get_permalink( $wp_query->post->ID );207 215 } 208 216 } elseif ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) { -
trunk/src/wp-includes/class-wp.php
r47738 r47760 671 671 $content_found = true; 672 672 673 $post = isset( $wp_query->post ) ? $wp_query->post : null;674 675 // Only set X-Pingback for single posts that allow pings.676 if ( is_singular() && $post && pings_open( $post ) && ! headers_sent() ) {677 header( 'X-Pingback: ' . get_bloginfo( 'pingback_url', 'display' ) );678 }679 680 // Check for paged content that exceeds the max number of pages.681 673 if ( is_singular() ) { 674 $post = isset( $wp_query->post ) ? $wp_query->post : null; 675 676 // Only set X-Pingback for single posts that allow pings. 677 if ( $post && pings_open( $post ) && ! headers_sent() ) { 678 header( 'X-Pingback: ' . get_bloginfo( 'pingback_url', 'display' ) ); 679 } 680 681 // Check for paged content that exceeds the max number of pages. 682 682 $next = '<!--nextpage-->'; 683 683 if ( $post && ! empty( $this->query_vars['page'] ) ) { … … 692 692 } 693 693 694 // The posts page does not support the <!--nextpage--> pagination. 695 if ( $wp_query->is_posts_page && ! empty( $this->query_vars['page'] ) ) { 696 $content_found = false; 697 } 698 694 699 if ( $content_found ) { 695 700 $set_404 = false; -
trunk/tests/phpunit/tests/canonical/pageOnFront.php
r47122 r47760 59 59 // The page designated as the front page should redirect to the front of the site. 60 60 array( '/front-page/', '/' ), 61 // The front page supports the <!--nextpage--> pagination. 61 62 array( '/front-page/2/', '/page/2/' ), 62 63 array( '/front-page/?page=2', '/page/2/' ), 64 // The posts page does not support the <!--nextpage--> pagination. 65 array( '/blog-page/2/', '/blog-page/' ), 66 array( '/blog-page/?page=2', '/blog-page/' ), 67 // The posts page supports regular pagination. 63 68 array( '/blog-page/?paged=2', '/blog-page/page/2/' ), 64 69 ); -
trunk/tests/phpunit/tests/canonical/paged.php
r46586 r47760 7 7 class Tests_Canonical_Paged extends WP_Canonical_UnitTestCase { 8 8 9 function test_ nextpage() {9 function test_redirect_canonical_with_nextpage_pagination() { 10 10 $para = 'This is a paragraph. 11 11 This is a paragraph. … … 20 20 ); 21 21 22 $link = parse_url( get_permalink( $post_id ), PHP_URL_PATH ); 23 $paged = $link . '4/'; 22 $link = parse_url( get_permalink( $post_id ), PHP_URL_PATH ); 24 23 25 $this->assertCanonical( $paged, $link ); 24 // Existing page should be displayed as is. 25 $this->assertCanonical( $link . '3/', $link . '3/' ); 26 // Non-existing page should redirect to the permalink. 27 $this->assertCanonical( $link . '4/', $link ); 26 28 } 29 27 30 }
Note: See TracChangeset
for help on using the changeset viewer.