Ticket #7956: 7956_while_fix.2.r9378.patch
File 7956_while_fix.2.r9378.patch, 2.4 KB (added by , 16 years ago) |
---|
-
wp-includes/comment.php
194 194 else 195 195 $approved = "( comment_approved = '0' OR comment_approved = '1' )"; 196 196 197 if ( 'ASC' != $order ) 198 $order = 'DESC'; 197 $order = ( 'ASC' == $order ) ? 'ASC' : 'DESC'; 199 198 200 199 $orderby = 'comment_date_gmt'; // Hard code for now 201 200 … … 484 483 * Calculate the total number of comment pages. 485 484 * 486 485 * @since 2.7.0 486 * @uses get_query_var() Used to fill in the default for $per_page parameter. 487 * @uses get_option() Used to fill in defaults for parameters. 488 * @uses Walker_Comment 487 489 * 488 490 * @param array $comments Optional array of comment objects. Defaults to $wp_query->comments 489 491 * @param int $per_page Optional comments per page. … … 523 525 * Calculate what page number a comment will appear on for comment paging. 524 526 * 525 527 * @since 2.7.0 528 * @uses get_comment() Gets the full comment of the $comment_ID parameter. 529 * @uses get_option() Get various settings to control function and defaults. 530 * @uses get_page_of_comment() Used to loop up to top level comment. 526 531 * 527 532 * @param int $comment_ID Comment ID. 528 533 * @param int $per_page Optional comments per page. 529 534 * @return int|null Comment page number or null on error. 530 535 */ 531 536 function get_page_of_comment( $comment_ID, $per_page = null, $threaded = null ) { 532 $comment = get_comment( $comment_ID ); 533 534 if ( !$comment || 1 != $comment->comment_approved ) 537 if ( !$comment = get_comment( $comment_ID ) ) 535 538 return; 536 539 537 540 if ( !get_option('page_comments') ) 538 541 return 1; 539 542 540 $comments = array_reverse( get_comments( array( 'post_id' => $comment->comment_post_ID ) ) );541 542 543 if ( null === $per_page ) 543 544 $per_page = get_option('comments_per_page'); 544 545 … … 547 548 548 549 // Find this comment's top level parent if threading is enabled 549 550 if ( $threaded && 0 != $comment->comment_parent ) { 550 while ( 0 != $comment->comment_parent ) { 551 $comment = get_comment( $comment->comment_parent ); 552 if ( !$comment || 1 != $comment->comment_approved ) 553 return; 554 } 555 } 551 return get_page_of_comment( $comment->comment_parent, $per_page, $threaded ); 556 552 553 $comments = get_comments( array( 'post_id' => $comment->comment_post_ID, 'order' => 'ASC' ) ); 554 557 555 // Start going through the comments until we find what page number the above top level comment is on 558 556 $page = 1; 559 557 $comthispage = 0;