Make WordPress Core

Ticket #11329: 11329.006.diff

File 11329.006.diff, 2.0 KB (added by pampfelimetten, 13 years ago)
  • wp-admin/includes/template.php

     
    19261926        $post = (int) $post;
    19271927        $count = wp_count_comments();
    19281928        $index = '';
     1929        $userid = apply_filters( 'get_comment_list_by_user', false );
    19291930
    19301931        if ( 'moderated' == $status ) {
    19311932                $approved = "c.comment_approved = '0'";
     
    19601961                $typesql = "AND ( c.comment_type = 'pingback' OR c.comment_type = 'trackback' )";
    19611962        elseif ( 'all' == $type )
    19621963                $typesql = '';
    1963         elseif ( !empty($type) )
    1964                 $typesql = $wpdb->prepare("AND c.comment_type = %s", $type);
     1964        elseif ( ! empty( $type ) )
     1965                $typesql = $wpdb->prepare( "AND c.comment_type = %s", $type );
    19651966        else
    19661967                $typesql = '';
    19671968
    1968         if ( !empty($type) )
     1969        if ( ! empty( $type ) )
    19691970                $total = '';
    19701971
    19711972        $query = "FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ";
     1973       
     1974        if ( $userid && ! empty( $userid ) ) {
     1975                $total = '';
     1976            if( ! is_array( $userid ) ) {
     1977                        $userid = absint( $userid );
     1978                        $query .= "AND p.post_author = '$userid' ";
     1979                } else {
     1980                        $userids = array_map( 'absint', $userid );
     1981                        $query .= "AND p.post_author IN ( '" . implode( "', '", $userids ) . "' ) ";
     1982                }
     1983        }
     1984       
    19721985        if ( $s ) {
    19731986                $total = '';
    1974                 $s = $wpdb->escape($s);
     1987                $s = $wpdb->escape( $s );
    19751988                $query .= "AND
    19761989                        (c.comment_author LIKE '%$s%' OR
    19771990                        c.comment_author_email LIKE '%$s%' OR
     
    19841997                $query .= "AND $approved $post $typesql";
    19851998        }
    19861999
    1987         $comments = $wpdb->get_results("SELECT * $query $orderby");
     2000        $comments = $wpdb->get_results( "SELECT * $query $orderby" );
    19882001        if ( '' === $total )
    1989                 $total = $wpdb->get_var("SELECT COUNT(c.comment_ID) $query");
     2002                $total = $wpdb->get_var( "SELECT COUNT(c.comment_ID) $query" );
    19902003
    1991         update_comment_cache($comments);
     2004        update_comment_cache( $comments );
    19922005
    1993         return array($comments, $total);
     2006        return array( $comments, $total );
    19942007}
    19952008
    19962009/**