Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/comment.php

    r17053 r18087  
    214214                        'post_ID' => '',
    215215                        'post_id' => 0,
     216                        'post_author' => '',
     217                        'post_name' => '',
     218                        'post_parent' => '',
     219                        'post_status' => '',
     220                        'post_type' => '',
    216221                        'status' => '',
    217222                        'type' => '',
     
    320325                        $where .= $this->get_search_sql( $search, array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_content' ) );
    321326
     327                $post_fields = array_filter( compact( array( 'post_author', 'post_name', 'post_parent', 'post_status', 'post_type', ) ) );
     328                if ( ! empty( $post_fields ) ) {
     329                        $join = "JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID";
     330                        foreach( $post_fields as $field_name => $field_value )
     331                                $where .= $wpdb->prepare( " AND {$wpdb->posts}.{$field_name} = %s", $field_value );
     332                }
     333
    322334                $pieces = array( 'fields', 'join', 'where', 'orderby', 'order', 'limits' );
    323335                $clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $pieces ), &$this ) );
     
    893905        $total = 0;
    894906        $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed');
    895         $known_types = array_keys( $approved );
    896907        foreach ( (array) $count as $row ) {
    897908                // Don't count post-trashed toward totals
    898909                if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] )
    899910                        $total += $row['num_comments'];
    900                 if ( in_array( $row['comment_approved'], $known_types ) )
     911                if ( isset( $approved[$row['comment_approved']] ) )
    901912                        $stats[$approved[$row['comment_approved']]] = $row['num_comments'];
    902913        }
     
    13951406        }
    13961407
    1397         $comment_old = wp_clone(get_comment($comment_id));
     1408        $comment_old = clone get_comment($comment_id);
    13981409
    13991410        if ( !$wpdb->update( $wpdb->comments, array('comment_approved' => $status), array('comment_ID' => $comment_id) ) ) {
     
    16091620                return false;
    16101621
    1611         if ( isset( $response['headers']['x-pingback'] ) )
    1612                 return $response['headers']['x-pingback'];
     1622        if ( wp_remote_retrieve_header( $response, 'x-pingback' ) )
     1623                return wp_remote_retrieve_header( $response, 'x-pingback' );
    16131624
    16141625        // Not an (x)html, sgml, or xml page, no use going further.
    1615         if ( isset( $response['headers']['content-type'] ) && preg_match('#(image|audio|video|model)/#is', $response['headers']['content-type']) )
     1626        if ( preg_match('#(image|audio|video|model)/#is', wp_remote_retrieve_header( $response, 'content-type' )) )
    16161627                return false;
    16171628
     
    16221633                return false;
    16231634
    1624         $contents = $response['body'];
     1635        $contents = wp_remote_retrieve_body( $response );
    16251636
    16261637        $pingback_link_offset_dquote = strpos($contents, $pingback_str_dquote);
     
    19551966                return $posts;
    19561967
     1968        $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
     1969        if ( ! in_array( $posts[0]->post_type, $post_types ) )
     1970                return $posts;
     1971
    19571972        $days_old = (int) get_option('close_comments_days_old');
    19581973        if ( !$days_old )
     
    19902005        $post = get_post($post_id);
    19912006
     2007        $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
     2008        if ( ! in_array( $post->post_type, $post_types ) )
     2009                return $open;
     2010
    19922011        if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) )
    19932012                return false;
Note: See TracChangeset for help on using the changeset viewer.