| 1 | Index: query.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- query.php (revision 17856) |
|---|
| 4 | +++ query.php (working copy) |
|---|
| 5 | @@ -2286,8 +2286,15 @@ |
|---|
| 6 | |
|---|
| 7 | $where .= $search . $whichauthor . $whichmimetype; |
|---|
| 8 | |
|---|
| 9 | - if ( empty($q['order']) || ((strtoupper($q['order']) != 'ASC') && (strtoupper($q['order']) != 'DESC')) ) |
|---|
| 10 | - $q['order'] = 'DESC'; |
|---|
| 11 | + if ( empty($q['order']) ) { |
|---|
| 12 | + $order_array[0] = $q['order'] = 'DESC'; |
|---|
| 13 | + } else { |
|---|
| 14 | + $order_array = explode(' ', $q['order'] ); |
|---|
| 15 | + foreach( $order_array as $i => $order ) { |
|---|
| 16 | + $order_array[ $i ] = strtoupper( $order ) != 'ASC' && strtoupper( $order ) != 'DESC' ? 'DESC' : strtoupper( $order ); |
|---|
| 17 | + } |
|---|
| 18 | + $q['order'] = $order_array[ 0 ]; // Set order to the first item for backward compat |
|---|
| 19 | + } |
|---|
| 20 | |
|---|
| 21 | // Order by |
|---|
| 22 | if ( empty($q['orderby']) ) { |
|---|
| 23 | @@ -2335,13 +2342,9 @@ |
|---|
| 24 | $orderby = "$wpdb->posts.post_" . $orderby; |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | - $q['orderby'] .= (($i == 0) ? '' : ',') . $orderby; |
|---|
| 28 | + $q['orderby'] .= (($i == 0) ? '' : ',') . $orderby . ' ' . $order_array[ ( $i % count( $order_array ) ) ]; |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 31 | - // append ASC or DESC at the end |
|---|
| 32 | - if ( !empty($q['orderby'])) |
|---|
| 33 | - $q['orderby'] .= " {$q['order']}"; |
|---|
| 34 | - |
|---|
| 35 | if ( empty($q['orderby']) ) |
|---|
| 36 | $q['orderby'] = "$wpdb->posts.post_date ".$q['order']; |
|---|
| 37 | } |
|---|