'parent' => '',
'post_ID' => '',
'post_id' => 0,
+ 'post_author' => '',
+ 'post_name' => '',
+ 'post_parent' => '',
+ 'post_status' => '',
+ 'post_type' => '',
'status' => '',
'type' => '',
'user_id' => '',
if ( '' !== $search )
$where .= $this->get_search_sql( $search, array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_content' ) );
+ $post_fields = array_filter( compact( array( 'post_author', 'post_name', 'post_parent', 'post_status', 'post_type', ) ) );
+ if ( ! empty( $post_fields ) ) {
+ $join = "JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID";
+ foreach( $post_fields as $field_name => $field_value )
+ $where .= $wpdb->prepare( " AND {$wpdb->posts}.{$field_name} = %s", $field_value );
+ }
+
$pieces = array( 'fields', 'join', 'where', 'orderby', 'order', 'limits' );
$clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $pieces ), &$this ) );
foreach ( $pieces as $piece )
$total = 0;
$approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed');
- $known_types = array_keys( $approved );
foreach ( (array) $count as $row ) {
// Don't count post-trashed toward totals
if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] )
$total += $row['num_comments'];
- if ( in_array( $row['comment_approved'], $known_types ) )
+ if ( isset( $approved[$row['comment_approved']] ) )
$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
}
return false;
}
- $comment_old = wp_clone(get_comment($comment_id));
+ $comment_old = clone get_comment($comment_id);
if ( !$wpdb->update( $wpdb->comments, array('comment_approved' => $status), array('comment_ID' => $comment_id) ) ) {
if ( $wp_error )
if ( is_wp_error( $response ) )
return false;
- if ( isset( $response['headers']['x-pingback'] ) )
- return $response['headers']['x-pingback'];
+ if ( wp_remote_retrieve_header( $response, 'x-pingback' ) )
+ return wp_remote_retrieve_header( $response, 'x-pingback' );
// Not an (x)html, sgml, or xml page, no use going further.
- if ( isset( $response['headers']['content-type'] ) && preg_match('#(image|audio|video|model)/#is', $response['headers']['content-type']) )
+ if ( preg_match('#(image|audio|video|model)/#is', wp_remote_retrieve_header( $response, 'content-type' )) )
return false;
// Now do a GET since we're going to look in the html headers (and we're sure its not a binary file)
if ( is_wp_error( $response ) )
return false;
- $contents = $response['body'];
+ $contents = wp_remote_retrieve_body( $response );
$pingback_link_offset_dquote = strpos($contents, $pingback_str_dquote);
$pingback_link_offset_squote = strpos($contents, $pingback_str_squote);
if ( empty($posts) || !is_singular() || !get_option('close_comments_for_old_posts') )
return $posts;
+ $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
+ if ( ! in_array( $posts[0]->post_type, $post_types ) )
+ return $posts;
+
$days_old = (int) get_option('close_comments_days_old');
if ( !$days_old )
return $posts;
$post = get_post($post_id);
+ $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
+ if ( ! in_array( $post->post_type, $post_types ) )
+ return $open;
+
if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) )
return false;