Make WordPress Core


Ignore:
Timestamp:
10/01/2008 03:48:45 PM (16 years ago)
Author:
ryan
Message:

Comment type filter from Viper007Bond. see #7552

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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);
Note: See TracChangeset for help on using the changeset viewer.