Ticket #7552: comment_type-filter.patch
File comment_type-filter.patch, 4.2 KB (added by , 16 years ago) |
---|
-
wp-admin/edit-comments.php
72 72 73 73 $mode = ( ! isset($_GET['mode']) || empty($_GET['mode']) ) ? 'detail' : attribute_escape($_GET['mode']); 74 74 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 76 77 $comment_type = !empty($_GET['comment_type']) ? attribute_escape($_GET['comment_type']) : ''; 78 77 79 $post_id = isset($_GET['p']) ? (int) $_GET['p'] : 0; 78 80 79 81 $search_dirty = ( isset($_GET['s']) ) ? $_GET['s'] : ''; … … 134 136 ); 135 137 $class = ( '' === $comment_status ) ? ' class="current"' : ''; 136 138 $status_links[] = "<li><a href=\"edit-comments.php\"$class>".__('Show All Comments')."</a>"; 139 $type = ( !$comment_type && 'all' != $comment_type ) ? '' : "&comment_type=$comment_type"; 137 140 foreach ( $stati as $status => $label ) { 138 141 $class = ''; 139 142 140 143 if ( $status == $comment_status ) 141 144 $class = ' class="current"'; 142 145 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>"; 144 147 } 145 148 146 149 $status_links = apply_filters( 'comment_status_links', $status_links ); … … 150 153 ?> 151 154 </ul> 152 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> 153 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> 178 179 <?php 154 180 $comments_per_page = apply_filters('comments_per_page', 20, $comment_status); 155 181 156 182 if ( isset( $_GET['apage'] ) ) … … 160 186 161 187 $start = $offset = ( $page - 1 ) * $comments_per_page; 162 188 163 list($_comments, $total) = _wp_get_comment_list( $comment_status, $search_dirty, $start, $comments_per_page + 5, $post_id ); // Grab a few extra189 list($_comments, $total) = _wp_get_comment_list( $comment_status, $search_dirty, $start, $comments_per_page + 5, $post_id, $comment_type ); // Grab a few extra 164 190 165 191 $comments = array_slice($_comments, 0, $comments_per_page); 166 192 $extra_comments = array_slice($_comments, $comments_per_page); -
wp-admin/includes/template.php
1531 1531 return $r; 1532 1532 } 1533 1533 1534 function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0 ) {1534 function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0, $type = '' ) { 1535 1535 global $wpdb; 1536 1536 1537 1537 $start = abs( (int) $start ); … … 1552 1552 else 1553 1553 $post = ''; 1554 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 = ''; 1563 1555 1564 if ( $s ) { 1556 1565 $s = $wpdb->escape($s); 1557 1566 $comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE … … 1561 1570 comment_author_IP LIKE ('%$s%') OR 1562 1571 comment_content LIKE ('%$s%') ) AND 1563 1572 $approved 1573 $typesql 1564 1574 ORDER BY comment_date_gmt DESC LIMIT $start, $num"); 1565 1575 } 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" ); 1567 1577 } 1568 1578 1569 1579 update_comment_cache($comments);