Created
January 5, 2019 13:12
-
-
Save mgibbs189/8ac315debafabca6b4fd3d3bf27d717b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
} else { | |
$orderby_array = array(); | |
if ( is_array( $q['orderby'] ) ) { | |
foreach ( $q['orderby'] as $_orderby => $order ) { | |
$orderby = addslashes_gpc( urldecode( $_orderby ) ); | |
$parsed = $this->parse_orderby( $orderby ); | |
if ( ! $parsed ) { | |
continue; | |
} | |
$orderby_array[] = $parsed . ' ' . $this->parse_order( $order ); | |
} | |
$orderby = implode( ', ', $orderby_array ); | |
} else { | |
$q['orderby'] = urldecode( $q['orderby'] ); | |
$q['orderby'] = addslashes_gpc( $q['orderby'] ); | |
foreach ( explode( ' ', $q['orderby'] ) as $i => $orderby ) { | |
$parsed = $this->parse_orderby( $orderby ); | |
// Only allow certain values for safety. | |
if ( ! $parsed ) { | |
continue; | |
} | |
$orderby_array[] = $parsed; | |
} | |
$orderby = implode( ' ' . $q['order'] . ', ', $orderby_array ); | |
if ( empty( $orderby ) ) { | |
$orderby = "{$wpdb->posts}.post_date " . $q['order']; | |
} elseif ( ! empty( $q['order'] ) ) { | |
$orderby .= " {$q['order']}"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment