Changeset 36486 for trunk/src/wp-includes/class-wp-comment-query.php
- Timestamp:
- 02/06/2016 04:50:05 AM (10 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/class-wp-comment-query.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-comment-query.php
r36480 r36486 221 221 * Default empty. 222 222 * @type int $post_author Post author ID to limit results by. Default empty. 223 * @type string $post_status Post status to retrieve affiliated comments for. 224 * Default empty. 225 * @type string $post_type Post type to retrieve affiliated comments for. 226 * Default empty. 223 * @type string|array $post_status Post status or array of post statuses to retrieve 224 * affiliated comments for. Pass 'any' to match any value. 225 * Default empty. 226 * @type string $post_type Post type or array of post types to retrieve affiliated 227 * comments for. Pass 'any' to match any value. Default empty. 227 228 * @type string $post_name Post name to retrieve affiliated comments for. 228 229 * Default empty. … … 761 762 // If any post-related query vars are passed, join the posts table. 762 763 $join_posts_table = false; 763 $plucked = wp_array_slice_assoc( $this->query_vars, array( 'post_author', 'post_name', 'post_parent' , 'post_status', 'post_type') );764 $plucked = wp_array_slice_assoc( $this->query_vars, array( 'post_author', 'post_name', 'post_parent' ) ); 764 765 $post_fields = array_filter( $plucked ); 765 766 … … 770 771 $esses = array_fill( 0, count( (array) $field_value ), '%s' ); 771 772 $this->sql_clauses['where'][ $field_name ] = $wpdb->prepare( " {$wpdb->posts}.{$field_name} IN (" . implode( ',', $esses ) . ')', $field_value ); 773 } 774 } 775 776 // 'post_status' and 'post_type' are handled separately, due to the specialized behavior of 'any'. 777 foreach ( array( 'post_status', 'post_type' ) as $field_name ) { 778 $q_values = array(); 779 if ( ! empty( $this->query_vars[ $field_name ] ) ) { 780 $q_values = $this->query_vars[ $field_name ]; 781 if ( ! is_array( $q_values ) ) { 782 $q_values = explode( ',', $q_values ); 783 } 784 785 // 'any' will cause the query var to be ignored. 786 if ( in_array( 'any', $q_values, true ) || empty( $q_values ) ) { 787 continue; 788 } 789 790 $join_posts_table = true; 791 792 $esses = array_fill( 0, count( $q_values ), '%s' ); 793 $this->sql_clauses['where'][ $field_name ] = $wpdb->prepare( " {$wpdb->posts}.{$field_name} IN (" . implode( ',', $esses ) . ")", $q_values ); 772 794 } 773 795 }
Note: See TracChangeset
for help on using the changeset viewer.