WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/11/2010 09:54:51 PM (10 years ago)
Author:
scribu
Message:

Ajaxify list-type screens in the admin. See #14579

File:
1 edited

Legend:

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

    r13995 r15491  
    205205        'type' => '',
    206206        'user_id' => '',
     207        'search' => '',
     208        'count' => false
    207209    );
    208210
     
    236238        $approved = "( comment_approved = '0' OR comment_approved = '1' )";
    237239
    238     $order = ( 'ASC' == $order ) ? 'ASC' : 'DESC';
     240    $order = ( 'ASC' == strtoupper($order) ) ? 'ASC' : 'DESC';
    239241
    240242    if ( ! empty( $orderby ) ) {
     
    270272    if ( !empty($number) ) {
    271273        if ( $offset )
    272             $number = 'LIMIT ' . $offset . ',' . $number;
     274            $limit = 'LIMIT ' . $offset . ',' . $number;
    273275        else
    274             $number = 'LIMIT ' . $number;
    275 
     276            $limit = 'LIMIT ' . $number;
    276277    } else {
    277         $number = '';
    278     }
    279 
    280     $post_where = '';
     278        $limit = '';
     279    }
     280
     281    $post_where = "WHERE $approved";
    281282
    282283    if ( ! empty($post_id) )
    283         $post_where .= $wpdb->prepare( 'comment_post_ID = %d AND ', $post_id );
     284        $post_where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
    284285    if ( '' !== $author_email )
    285         $post_where .= $wpdb->prepare( 'comment_author_email = %s AND ', $author_email );
     286        $post_where .= $wpdb->prepare( 'AND comment_author_email = %s', $author_email );
    286287    if ( '' !== $karma )
    287         $post_where .= $wpdb->prepare( 'comment_karma = %d AND ', $karma );
     288        $post_where .= $wpdb->prepare( 'AND comment_karma = %d', $karma );
    288289    if ( 'comment' == $type )
    289         $post_where .= "comment_type = '' AND ";
     290        $post_where .= " AND comment_type = ''";
    290291    elseif ( ! empty( $type ) )
    291         $post_where .= $wpdb->prepare( 'comment_type = %s AND ', $type );
     292        $post_where .= $wpdb->prepare( ' AND comment_type = %s', $type );
    292293    if ( '' !== $parent )
    293         $post_where .= $wpdb->prepare( 'comment_parent = %d AND ', $parent );
     294        $post_where .= $wpdb->prepare( ' AND comment_parent = %d', $parent );
    294295    if ( '' !== $user_id )
    295         $post_where .= $wpdb->prepare( 'user_id = %d AND ', $user_id );
    296 
    297     $comments = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE $post_where $approved ORDER BY $orderby $order $number" );
     296        $post_where .= $wpdb->prepare( ' AND user_id = %d', $user_id );
     297    if ( '' !== $search )
     298        $post_where .= _wp_search_sql($search, array('comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_content'));
     299
     300    if ( $count )
     301        return $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments $post_where ORDER BY $orderby $order $limit" );
     302
     303    $comments = $wpdb->get_results( "SELECT * FROM $wpdb->comments $post_where ORDER BY $orderby $order $limit" );
     304
    298305    wp_cache_add( $cache_key, $comments, 'comment' );
    299306
     
    12831290
    12841291        if ( get_option('comments_notify') && $commentdata['comment_approved'] && ( ! isset( $commentdata['user_id'] ) || $post->post_author != $commentdata['user_id'] ) )
    1285             wp_notify_postauthor($comment_ID, empty( $commentdata['comment_type'] ) ? $commentdata['comment_type'] : '' );
     1292            wp_notify_postauthor($comment_ID, isset( $commentdata['comment_type'] ) ? $commentdata['comment_type'] : '' );
    12861293    }
    12871294
Note: See TracChangeset for help on using the changeset viewer.