Changeset 9522 for trunk/wp-includes/comment.php
- Timestamp:
- 11/05/2008 07:09:20 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/comment.php
r9511 r9522 553 553 */ 554 554 function get_page_of_comment( $comment_ID, $per_page = null, $threaded = null ) { 555 global $wpdb; 556 555 557 if ( !$comment = get_comment( $comment_ID ) ) 556 558 return; … … 569 571 return get_page_of_comment( $comment->comment_parent, $per_page, $threaded ); 570 572 571 $comments = get_comments( array( 'post_id' => $comment->comment_post_ID, 'order' => 'ASC' ) ); 572 573 // Start going through the comments until we find what page number the above top level comment is on 574 $page = 1; 575 $comthispage = 0; 576 foreach ( $comments as $com ) { 577 if ( $threaded && 0 != $com->comment_parent ) 578 continue; 579 580 if ( $com->comment_ID == $comment->comment_ID ) 581 return $page; 582 583 $comthispage++; 584 585 if ( $comthispage >= $per_page ) { 586 $page++; 587 $comthispage = 0; 588 } 589 } 573 // Count comments older than this one 574 $oldercoms = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = 0 AND comment_date_gmt < '%s'", $comment->comment_post_ID, $comment->comment_date_gmt ) ); 575 576 // No older comments? Then it's page #1. 577 if ( 0 == $oldercoms ) 578 return 1; 579 580 // Divide comments older than this one by comments per page to get this comment's page number 581 return ceil( ( $oldercoms + 1 ) / $per_page ); 590 582 } 591 583
Note: See TracChangeset
for help on using the changeset viewer.