Ticket #31122: query.php.patch
File query.php.patch, 1.6 KB (added by , 10 years ago) |
---|
-
query.php
2230 2230 'post_parent', 'post_type', 'name', 'author', 'date', 'title', 'modified', 2231 2231 'parent', 'type', 'ID', 'menu_order', 'comment_count', 'rand', 2232 2232 ); 2233 2234 $allowed_keys = apply_filters( 'allowed_orderby_keys', $allowed_keys ); 2233 2235 2234 2236 $primary_meta_key = ''; 2235 2237 $primary_meta_query = false; … … 2260 2262 case 'ID': 2261 2263 case 'menu_order': 2262 2264 case 'comment_count': 2263 $orderby = "$wpdb->posts.{$orderby}";2265 $orderby_clause = "$wpdb->posts.{$orderby}"; 2264 2266 break; 2265 2267 case 'rand': 2266 $orderby = 'RAND()';2268 $orderby_clause = 'RAND()'; 2267 2269 break; 2268 2270 case $primary_meta_key: 2269 2271 case 'meta_value': 2270 2272 if ( ! empty( $primary_meta_query['type'] ) ) { 2271 2273 $sql_type = $this->meta_query->get_cast_for_type( $primary_meta_query['type'] ); 2272 $orderby = "CAST($wpdb->postmeta.meta_value AS {$sql_type})";2274 $orderby_clause = "CAST($wpdb->postmeta.meta_value AS {$sql_type})"; 2273 2275 } else { 2274 $orderby = "$wpdb->postmeta.meta_value";2276 $orderby_clause = "$wpdb->postmeta.meta_value"; 2275 2277 } 2276 2278 break; 2277 2279 case 'meta_value_num': 2278 $orderby = "$wpdb->postmeta.meta_value+0";2280 $orderby_clause = "$wpdb->postmeta.meta_value+0"; 2279 2281 break; 2280 2282 default: 2281 $orderby = "$wpdb->posts.post_" . $orderby;2283 $orderby_clause = "$wpdb->posts.post_" . $orderby; 2282 2284 break; 2283 2285 } 2284 2285 return $orderby;2286 2287 return apply_filters( 'parse_orderby', $orderby_clause, $orderby ); 2286 2288 } 2287 2289 2288 2290 /**