| 2137 | |
| 2138 | // Comment query |
| 2139 | if( isset( $q['comment_count'] ) ) { |
| 2140 | if( is_numeric( $q['comment_count'] ) ) { |
| 2141 | $q['comment_count'] = array( |
| 2142 | 'value' => absint($q['comment_count']), |
| 2143 | ); |
| 2144 | } // Falltrough to default array |
| 2145 | |
| 2146 | if( isset( $q['comment_count']['value'] ) ) { |
| 2147 | $q['comment_count'] = wp_parse_args($q['comment_count'], array( |
| 2148 | 'compare' => '=', |
| 2149 | ) ); |
| 2150 | |
| 2151 | $where .= " AND ( {$wpdb->posts}.comment_count "; |
| 2152 | |
| 2153 | $compare_operators = array( '=', '!=', '>', '>=', '<', '<=' ); |
| 2154 | if ( in_array( $q['comment_count']['compare'], $compare_operators, true ) ) { |
| 2155 | $where .= $q['comment_count']['compare']; |
| 2156 | } else { |
| 2157 | // Fallback to equal sign |
| 2158 | $where .= "="; |
| 2159 | } |
| 2160 | |
| 2161 | // Now add the count |
| 2162 | $where .= ' ' . absint( $q['comment_count']['value'] ) . ')'; |
| 2163 | } |
| 2164 | } |
| 2165 | |