Changeset 51118
- Timestamp:
- 06/08/2021 10:49:27 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/canonical.php
r50132 r51118 28 28 * 29 29 * @since 2.3.0 30 * @since 5.8.0 Checks comment page count to limit pagination. 30 31 * 31 32 * @global WP_Rewrite $wp_rewrite WordPress rewrite component. … … 505 506 || 'newest' !== $default_comments_page && $cpage > 1 ) 506 507 ) { 507 $addl_path = ( ! empty( $addl_path ) ? trailingslashit( $addl_path ) : '' ); 508 $addl_path .= user_trailingslashit( $wp_rewrite->comments_pagination_base . '-' . $cpage, 'commentpaged' ); 508 // Checks comment page count to limit pagination. 509 $per_page = get_option( 'comments_per_page' ); 510 511 // Get the total number of pages for comments. 512 $comments_total_pages = ceil( ( $wp_query->post->comment_count ) / $per_page ); 513 if ( $cpage <= $comments_total_pages ) { 514 $addl_path = ( ! empty( $addl_path ) ? trailingslashit( $addl_path ) : '' ); 515 $addl_path .= user_trailingslashit( $wp_rewrite->comments_pagination_base . '-' . $cpage, 'commentpaged' ); 516 } 509 517 510 518 $redirect['query'] = remove_query_arg( 'cpage', $redirect['query'] ); -
trunk/tests/phpunit/tests/link/wpGetCanonicalUrl.php
r50452 r51118 153 153 154 154 /** 155 * Limit pagination for comments. 156 * 157 * @ticket 50233 158 */ 159 public function test_comments_limit_paged_with_plain_permalink_structure() { 160 $cpage = 5; 161 162 $link = add_query_arg( 163 array( 164 'cpage' => $cpage, 165 'foo' => 'bar', 166 ), 167 get_permalink( self::$post_id ) 168 ); 169 170 $this->go_to( $link ); 171 $expected = get_permalink( self::$post_id ) . '#comments'; 172 $this->assertSame( $expected, wp_get_canonical_url( self::$post_id ) ); 173 } 174 175 /** 155 176 * Filter callback for testing of filter usage. 156 177 *
Note: See TracChangeset
for help on using the changeset viewer.