Changeset 9046

Show
Ignore:
Timestamp:
10/01/08 15:48:45 (2 months ago)
Author:
ryan
Message:

Comment type filter from Viper007Bond. see #7552

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/edit-comments.php

    r9032 r9046  
    7373$mode = ( ! isset($_GET['mode']) || empty($_GET['mode']) ) ? 'detail' : attribute_escape($_GET['mode']); 
    7474 
    75 $comment_status = isset($_GET['comment_status']) ? attribute_escape($_GET['comment_status']) : ''; 
     75$comment_status = !empty($_GET['comment_status']) ? attribute_escape($_GET['comment_status']) : ''; 
     76 
     77$comment_type = !empty($_GET['comment_type']) ? attribute_escape($_GET['comment_type']) : ''; 
    7678 
    7779$post_id = isset($_GET['p']) ? (int) $_GET['p'] : 0; 
     
    135137$class = ( '' === $comment_status ) ? ' class="current"' : ''; 
    136138$status_links[] = "<li><a href=\"edit-comments.php\"$class>".__('Show All Comments')."</a>"; 
     139$type = ( !$comment_type && 'all' != $comment_type ) ? '' : "&amp;comment_type=$comment_type"; 
    137140foreach ( $stati as $status => $label ) { 
    138141    $class = ''; 
     
    141144        $class = ' class="current"'; 
    142145 
    143     $status_links[] = "<li class='$status'><a href=\"edit-comments.php?comment_status=$status\"$class>$label</a>"; 
     146    $status_links[] = "<li class='$status'><a href=\"edit-comments.php?comment_status=$status$type\"$class>$label</a>"; 
    144147} 
    145148 
     
    150153?> 
    151154</ul> 
     155 
     156<div class="filter"> 
     157<form id="list-filter" action="" method="get"> 
     158<?php if ( $comment_status ) echo "<input type='hidden' name='comment_status' value='$comment_status' />\n"; ?> 
     159<select name="comment_type"> 
     160    <option value="all"><?php _e('Show all comment types'); ?></option> 
     161<?php 
     162    $comment_types = array( 
     163        'comment' => __('Comments'), 
     164        'pingback' => __('Pingbacks'), 
     165        'trackback' => __('Trackbacks'), 
     166    ); 
     167 
     168    foreach ( $comment_types as $type => $label ) { 
     169        echo "  <option value='$type'"; 
     170        selected( $comment_type, $type ); 
     171        echo ">$label</option>\n"; 
     172    } 
     173?> 
     174</select> 
     175<input type="submit" id="post-query-submit" value="<?php _e('Filter'); ?>" class="button-secondary" /> 
     176</form> 
     177</div> 
    152178 
    153179<?php 
     
    161187$start = $offset = ( $page - 1 ) * $comments_per_page; 
    162188 
    163 list($_comments, $total) = _wp_get_comment_list( $comment_status, $search_dirty, $start, $comments_per_page + 5, $post_id ); // Grab a few extra 
     189list($_comments, $total) = _wp_get_comment_list( $comment_status, $search_dirty, $start, $comments_per_page + 5, $post_id, $comment_type ); // Grab a few extra 
    164190 
    165191$comments = array_slice($_comments, 0, $comments_per_page); 
  • trunk/wp-admin/includes/template.php

    r9045 r9046  
    15321532} 
    15331533 
    1534 function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0 ) { 
     1534function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0, $type = '' ) { 
    15351535    global $wpdb; 
    15361536 
     
    15521552    else 
    15531553        $post = ''; 
     1554 
     1555    if ( 'comment' == $type ) 
     1556        $typesql = "AND comment_type = ''"; 
     1557    elseif ( 'pingback' == $type ) 
     1558        $typesql = "AND comment_type = 'pingback'"; 
     1559    elseif ( 'trackback' == $type ) 
     1560        $typesql = "AND comment_type = 'trackback'"; 
     1561    else 
     1562        $typesql = ''; 
    15541563 
    15551564    if ( $s ) { 
     
    15621571            comment_content LIKE ('%$s%') ) AND 
    15631572            $approved 
     1573            $typesql 
    15641574            ORDER BY comment_date_gmt DESC LIMIT $start, $num"); 
    15651575    } else { 
    1566         $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE $approved $post ORDER BY comment_date_gmt DESC LIMIT $start, $num" ); 
     1576        $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE $approved $post $typesql ORDER BY comment_date_gmt DESC LIMIT $start, $num" ); 
    15671577    } 
    15681578