Changeset 29935 for trunk/src/wp-includes/comment.php
- Timestamp:
- 10/17/2014 01:57:18 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment.php
r29808 r29935 258 258 * 259 259 * @since 3.1.0 260 * @since 4.1.0 Introduced 'comment__in', 'comment__not_in', 260 * @since 4.1.0 Introduced 'comment__in', 'comment__not_in', 'post_author__in', 261 * 'post_author__not_in', 'author__in', 'author__not_in', 261 262 * 'post__in', and 'post__not_in' to $query_vars. 262 263 * … … 269 270 $defaults = array( 270 271 'author_email' => '', 272 'author__in' => '', 273 'author__not_in' => '', 271 274 'fields' => '', 272 275 'ID' => '', … … 279 282 'order' => 'DESC', 280 283 'parent' => '', 284 'post_author__in' => '', 285 'post_author__not_in' => '', 281 286 'post_ID' => '', 282 287 'post_id' => 0, … … 468 473 } 469 474 475 // If any post-related query vars are passed, join the posts table. 476 $join_posts_table = false; 470 477 $plucked = wp_array_slice_assoc( $this->query_vars, array( 'post_author', 'post_name', 'post_parent', 'post_status', 'post_type' ) ); 471 478 $post_fields = array_filter( $plucked ); 472 479 473 480 if ( ! empty( $post_fields ) ) { 481 $join_posts_table = true; 482 foreach ( $post_fields as $field_name => $field_value ) { 483 $where .= $wpdb->prepare( " AND {$wpdb->posts}.{$field_name} = %s", $field_value ); 484 } 485 } 486 487 // Comment author IDs for an IN clause. 488 if ( ! empty( $this->query_vars['author__in'] ) ) { 489 $where .= ' AND user_id IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['author__in'] ) ) . ' )'; 490 } 491 492 // Comment author IDs for a NOT IN clause. 493 if ( ! empty( $this->query_vars['author__not_in'] ) ) { 494 $where .= ' AND user_id NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['author__not_in'] ) ) . ' )'; 495 } 496 497 // Post author IDs for an IN clause. 498 if ( ! empty( $this->query_vars['post_author__in'] ) ) { 499 $join_posts_table = true; 500 $where .= ' AND post_author IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post_author__in'] ) ) . ' )'; 501 } 502 503 // Post author IDs for a NOT IN clause. 504 if ( ! empty( $this->query_vars['post_author__not_in'] ) ) { 505 $join_posts_table = true; 506 $where .= ' AND post_author NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post_author__not_in'] ) ) . ' )'; 507 } 508 509 if ( $join_posts_table ) { 474 510 $join = "JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID"; 475 foreach( $post_fields as $field_name => $field_value )476 $where .= $wpdb->prepare( " AND {$wpdb->posts}.{$field_name} = %s", $field_value );477 511 } 478 512
Note: See TracChangeset
for help on using the changeset viewer.