Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor User parse_orderby and add user_registered support #2781

Merged
merged 2 commits into from
May 20, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix logic, prevent error on unsupported clauses
  • Loading branch information
felipeelia committed May 20, 2022
commit 237983ba9fde1728fd6ef7772b835913686a34e2
4 changes: 3 additions & 1 deletion includes/classes/Indexable/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,8 @@ public function parse_orderby( $orderby, $default_order, $query_vars ) {
return $sort;
}

$unsupported_clauses = [ 'rand', 'include', 'login__in', 'nicename__in', 'post_count' ];

foreach ( $orderby as $key => $value ) {
if ( is_string( $key ) ) {
$orderby_clause = $key;
Expand All @@ -634,7 +636,7 @@ public function parse_orderby( $orderby, $default_order, $query_vars ) {
$order = $default_order;
}

if ( empty( $orderby_clause ) && 'rand' === $orderby_clause ) {
if ( empty( $orderby_clause ) || in_array( $orderby_clause, $unsupported_clauses, true ) ) {
continue;
}

Expand Down