WordPress.org

Make WordPress Core

Changeset 9379


Ignore:
Timestamp:
10/28/08 07:29:04 (5 years ago)
Author:
ryan
Message:

get_page_of_comment() fixes from Viper007Bond. see #7956

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/comment.php

    r9377 r9379  
    195195        $approved = "( comment_approved = '0' OR comment_approved = '1' )"; 
    196196 
    197     if ( 'ASC' != $order ) 
    198         $order = 'DESC'; 
     197    $order = ( 'ASC' == $order ) ? 'ASC' : 'DESC'; 
    199198 
    200199    $orderby = 'comment_date_gmt';  // Hard code for now 
     
    485484 * 
    486485 * @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 
    487489 * 
    488490 * @param array $comments Optional array of comment objects.  Defaults to $wp_query->comments 
     
    524526 * 
    525527 * @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. 
    526531 * 
    527532 * @param int $comment_ID Comment ID. 
     
    530535 */ 
    531536function 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 ) ) 
    535538        return; 
    536539 
     
    538541        return 1; 
    539542 
    540     $comments = array_reverse( get_comments( array( 'post_id' => $comment->comment_post_ID ) ) ); 
    541  
    542543    if ( null === $per_page ) 
    543544        $per_page = get_option('comments_per_page'); 
     
    547548 
    548549    // Find this comment's top level parent if threading is enabled 
    549     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     } 
     550    if ( $threaded && 0 != $comment->comment_parent ) 
     551        return get_page_of_comment( $comment->comment_parent, $per_page, $threaded ); 
     552 
     553    $comments = get_comments( array( 'post_id' => $comment->comment_post_ID, 'order' => 'ASC' ) ); 
    556554 
    557555    // Start going through the comments until we find what page number the above top level comment is on 
Note: See TracChangeset for help on using the changeset viewer.