Ticket #9124: 9124.2.diff
File 9124.2.diff, 1.4 KB (added by , 14 years ago) |
---|
-
wp-includes/query.php
2146 2146 if ( ! empty($q['meta_key']) ) 2147 2147 $where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_key = %s ", $q['meta_key']); 2148 2148 if ( ! empty($q['meta_value']) ) { 2149 if ( ! isset($q['meta_compare']) || empty($q['meta_compare']) || ! in_array($q['meta_compare'], array('=', '!=', '>', '>=', '<', '<=' )) )2149 if ( ! isset($q['meta_compare']) || empty($q['meta_compare']) || ! in_array($q['meta_compare'], array('=', '!=', '>', '>=', '<', '<=', 'in')) ) 2150 2150 $q['meta_compare'] = '='; 2151 2152 $where .= $wpdb->prepare("AND $wpdb->postmeta.meta_value {$q['meta_compare']} %s ", $q['meta_value']); 2151 if ( 'in' == $q['meta_compare'] ) { 2152 if ( !is_array($q['meta_value']) ) 2153 $q['meta_value'] = preg_split('!,\s+!', $q['meta_value']); 2154 $meta_field_types = rtrim(str_repeat('%s,', count($q['meta_value'])), ','); 2155 $where .= $wpdb->prepare("AND $wpdb->postmeta.meta_value IN($meta_field_types) ", $q['meta_value']); 2156 unset($meta_field_types); 2157 } else { 2158 $where .= $wpdb->prepare("AND $wpdb->postmeta.meta_value {$q['meta_compare']} %s ", $q['meta_value']); 2159 } 2160 2153 2161 } 2154 2162 2155 2163 // Apply filters on where and join prior to paging so that any