diff --git src/wp-includes/comment-template.php src/wp-includes/comment-template.php
index 7b6e44c..9b270d2 100644
|
|
|
function get_comment_link( $comment = null, $args = array() ) { |
| 691 | 691 | $args['page'] = 0; |
| 692 | 692 | } |
| 693 | 693 | |
| 694 | | if ( $args['per_page'] ) { |
| 695 | | if ( '' == $args['page'] ) |
| 696 | | $args['page'] = ( !empty($in_comment_loop) ) ? get_query_var('cpage') : get_page_of_comment( $comment->comment_ID, $args ); |
| | 694 | $link = get_permalink( $comment->comment_post_ID ); |
| | 695 | if ( '' == $args['page'] ) { |
| | 696 | if ( ! empty( $in_comment_loop ) ) { |
| | 697 | $args['page'] = get_query_var( 'cpage' ); |
| | 698 | } else { |
| | 699 | $args['page'] = get_page_of_comment( $comment->comment_ID, $args ); |
| | 700 | } |
| | 701 | } |
| 697 | 702 | |
| 698 | | if ( $wp_rewrite->using_permalinks() ) |
| 699 | | $link = user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . $wp_rewrite->comments_pagination_base . '-' . $args['page'], 'comment' ); |
| 700 | | else |
| 701 | | $link = add_query_arg( 'cpage', $args['page'], get_permalink( $comment->comment_post_ID ) ); |
| | 703 | // Drop the 'page' var if we're on the default page. |
| | 704 | $comment_post = get_post( $comment->comment_post_ID ); |
| | 705 | if ( $args['per_page'] ) { |
| | 706 | $total_pages = ceil( $comment_post->comment_count / $args['per_page'] ); |
| 702 | 707 | } else { |
| 703 | | $link = get_permalink( $comment->comment_post_ID ); |
| | 708 | $total_pages = 1; |
| | 709 | } |
| | 710 | |
| | 711 | $default_comments_page = get_option( 'default_comments_page' ); |
| | 712 | if ( |
| | 713 | ( 'newest' === $default_comments_page && $args['page'] == $total_pages ) || |
| | 714 | ( 'oldest' === $default_comments_page && $args['page'] == 1 ) |
| | 715 | ) { |
| | 716 | $args['page'] = ''; |
| | 717 | } |
| | 718 | |
| | 719 | if ( $args['page'] ) { |
| | 720 | if ( $wp_rewrite->using_permalinks() ) { |
| | 721 | if ( $args['page'] ) { |
| | 722 | $link = trailingslashit( $link ) . $wp_rewrite->comments_pagination_base . '-' . $args['page']; |
| | 723 | } |
| | 724 | |
| | 725 | $link = user_trailingslashit( $link, 'comment' ); |
| | 726 | } elseif ( $args['page'] ) { |
| | 727 | $link = add_query_arg( 'cpage', $args['page'], $link ); |
| | 728 | } |
| | 729 | |
| | 730 | } |
| | 731 | |
| | 732 | if ( $wp_rewrite->using_permalinks() ) { |
| | 733 | $link = user_trailingslashit( $link, 'comment' ); |
| 704 | 734 | } |
| 705 | 735 | |
| 706 | 736 | $link = $link . '#comment-' . $comment->comment_ID; |