Make WordPress Core

Changeset 15887


Ignore:
Timestamp:
10/21/2010 02:03:25 PM (13 years ago)
Author:
scribu
Message:

Allow filtering comments by user_id via URL. Props neoxx. Fixes #14163

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/default-list-tables.php

    r15882 r15887  
    20942094        $search = ( isset( $_REQUEST['s'] ) ) ? $_REQUEST['s'] : '';
    20952095
     2096        $user_id = ( isset( $_REQUEST['user_id'] ) ) ? $_REQUEST['user_id'] : '';
     2097
    20962098        $comments_per_page = $this->get_items_per_page( 'edit_comments_per_page' );
    20972099        $comments_per_page = apply_filters( 'comments_per_page', $comments_per_page, $comment_status );
     
    21142116            'status' => isset( $status_map[$comment_status] ) ? $status_map[$comment_status] : $comment_status,
    21152117            'search' => $search,
     2118            'user_id' => $user_id,
    21162119            'offset' => $start,
    21172120            'number' => $number,
  • trunk/wp-includes/query.php

    r15874 r15887  
    11861186            , 's'
    11871187            , 'sentence'
     1188            , 'fields'
    11881189        );
    11891190
    11901191        foreach ( $keys as $key ) {
    1191             if ( !isset($array[$key]))
     1192            if ( !isset($array[$key]) )
    11921193                $array[$key] = '';
    11931194        }
     
    11971198
    11981199        foreach ( $array_keys as $key ) {
    1199             if ( !isset($array[$key]))
     1200            if ( !isset($array[$key]) )
    12001201                $array[$key] = array();
    12011202        }
     
    16491650        $search = '';
    16501651        $groupby = '';
    1651         $fields = "$wpdb->posts.*";
     1652        $fields = '';
    16521653        $post_status_join = false;
    16531654        $page = 1;
     
    17291730        else
    17301731            $q['no_found_rows'] = false;
     1732
     1733        switch ( $q['fields'] ) {
     1734            case 'ids':
     1735                $fields = "$wpdb->posts.ID";
     1736                break;
     1737            case 'id=>parent':
     1738                $fields = "$wpdb->posts.ID, $wpdb->posts.post_parent";
     1739                break;
     1740            default:
     1741                $fields = "$wpdb->posts.*";
     1742        }
    17311743
    17321744        // If a month is specified in the querystring, load that month
     
    22732285        if ( !empty( $orderby ) )
    22742286            $orderby = 'ORDER BY ' . $orderby;
     2287
    22752288        $found_rows = '';
    22762289        if ( !$q['no_found_rows'] && !empty($limits) )
     
    22812294            $this->request = apply_filters_ref_array('posts_request', array( $this->request, &$this ) );
    22822295
     2296        if ( 'ids' == $q['fields'] ) {
     2297            $this->posts = $wpdb->get_col($this->request);
     2298
     2299            return $this->posts;
     2300        }
     2301
     2302        if ( 'id=>parent' == $q['fields'] ) {
     2303            $this->posts = $wpdb->get_results($this->request);
     2304
     2305            $r = array();
     2306            foreach ( $this->posts as $post )
     2307                $r[ $post->ID ] = $post->post_parent;
     2308
     2309            return $r;
     2310        }
     2311
    22832312        $this->posts = $wpdb->get_results($this->request);
     2313
    22842314        // Raw results filter.  Prior to status checks.
    22852315        if ( !$q['suppress_filters'] )
Note: See TracChangeset for help on using the changeset viewer.