Ticket #12668: 12668-get_approved_comments-WP_COMMENT_QUERY.patch
File 12668-get_approved_comments-WP_COMMENT_QUERY.patch, 3.4 KB (added by , 10 years ago) |
---|
-
src/wp-admin/includes/class-wp-comments-list-table.php
58 58 if ( !in_array( $comment_status, array( 'all', 'moderated', 'approved', 'spam', 'trash' ) ) ) 59 59 $comment_status = 'all'; 60 60 61 $comment_type = ! empty( $_REQUEST['comment_type'] ) ? $_REQUEST['comment_type'] : '';61 $comment_type = ! empty( $_REQUEST['comment_type'] ) ? $_REQUEST['comment_type'] : array( 'pingback', 'trackback', 'comment' ); 62 62 63 63 $search = ( isset( $_REQUEST['s'] ) ) ? $_REQUEST['s'] : ''; 64 64 … … 108 108 'type' => $comment_type, 109 109 'orderby' => $orderby, 110 110 'order' => $order, 111 'post_type' => $post_type ,111 'post_type' => $post_type 112 112 ); 113 113 114 114 $_comments = get_comments( $args ); -
src/wp-admin/includes/dashboard.php
752 752 753 753 $comments_query = array( 754 754 'number' => $total_items * 5, 755 'offset' => 0 755 'offset' => 0, 756 'type' => array( 'pingback', 'trackback', 'comment' ) 756 757 ); 757 758 if ( ! current_user_can( 'edit_posts' ) ) 758 759 $comments_query['status'] = 'approve'; -
src/wp-includes/comment.php
131 131 * @uses $wpdb 132 132 * 133 133 * @param int $post_id The ID of the post 134 * @param array $args WP_Comment_Query args 134 135 * @return array $comments The approved comments 135 136 */ 136 function get_approved_comments($post_id) { 137 global $wpdb; 138 return $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1' ORDER BY comment_date", $post_id)); 137 function get_approved_comments( $post_id = 0, $args = array() ) { 138 $defaults = array( 139 'status' => 1, 140 'post_id' => $post_id 141 ); 142 $r = wp_parse_args( $args, $defaults ); 143 144 $query = new WP_Comment_Query; 145 return $query->query( $r ); 139 146 } 140 147 141 148 /** … … 447 454 } elseif( 'pings' == $this->query_vars['type'] ) { 448 455 $where .= ' AND comment_type IN ("pingback", "trackback")'; 449 456 } elseif ( ! empty( $this->query_vars['type'] ) ) { 450 $where .= $wpdb->prepare( ' AND comment_type = %s', $this->query_vars['type'] ); 457 if ( is_array( $this->query_vars['type'] ) ) { 458 $where .= ' AND comment_type IN (' . implode( ',', $this->query_vars['type'] ) . ')'; 459 } elseif ( '' !== $this->query_vars['type'] ) { 460 $where .= $wpdb->prepare( ' AND comment_type = %d', $this->query_vars['type'] ); 461 } 451 462 } 452 463 453 464 if ( '' !== $this->query_vars['parent'] ) { -
src/wp-includes/default-widgets.php
856 856 $comments = get_comments( apply_filters( 'widget_comments_args', array( 857 857 'number' => $number, 858 858 'status' => 'approve', 859 'post_status' => 'publish' 859 'post_status' => 'publish', 860 'type' => array( 'pingback', 'trackback', 'comment' ) 860 861 ) ) ); 861 862 862 863 $output .= $args['before_widget'];