WordPress.org

Make WordPress Core

Ticket #13939: get_page_of_comment.diff

File get_page_of_comment.diff, 1.4 KB (added by laceous, 10 years ago)

initial patch

  • wp-includes/comment.php

     
    712712        $args = wp_parse_args( $args, $defaults );
    713713
    714714        if ( '' === $args['per_page'] && get_option('page_comments') )
    715                 $args['per_page'] = get_query_var('comments_per_page');
     715                $args['per_page'] = get_option('comments_per_page');
    716716        if ( empty($args['per_page']) ) {
    717717                $args['per_page'] = 0;
    718718                $args['page'] = 0;
     
    739739
    740740        $comtypewhere = ( 'all' != $args['type'] && isset($allowedtypes[$args['type']]) ) ? " AND comment_type = '" . $allowedtypes[$args['type']] . "'" : '';
    741741
     742        if ( $args['max_depth'] > 1 )
     743                $fromparent = ' AND comment_parent = 0';
     744        else
     745                $fromparent = '';
     746
    742747        // Count comments older than this one
    743         $oldercoms = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = 0 AND comment_approved = '1' AND comment_date_gmt < '%s'" . $comtypewhere, $comment->comment_post_ID, $comment->comment_date_gmt ) );
     748        $oldercoms = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = %d" . $fromparent . " AND comment_approved = '1' AND comment_date_gmt < '%s'" . $comtypewhere, $comment->comment_post_ID, $comment->comment_date_gmt ) );
    744749
    745750        // No older comments? Then it's page #1.
    746751        if ( 0 == $oldercoms )