Skip to content

Commit

Permalink
chore: validate orderby param for payment query
Browse files Browse the repository at this point in the history
  • Loading branch information
ravinderk committed Jul 12, 2019
1 parent 6adb2e7 commit 97b9b5f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions includes/payments/class-payments-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,26 @@ public function gateway_filter() {
private function get_sql() {
global $wpdb;

$allowed_keys = array(
'post_name',
'post_author',
'post_date',
'post_title',
'post_status',
'post_modified',
'post_parent',
'post_type',
'menu_order',
'comment_count',
);

$this->args['orderby'] = 'post_parent__in';

// Whitelist orderby.
if( ! in_array( $this->args['orderby'], $allowed_keys ) ) {
$this->args['orderby'] = 'ID';
}

$where = "WHERE {$wpdb->posts}.post_type = 'give_payment'";
$where .= " AND {$wpdb->posts}.post_status IN ('" . implode( "','", $this->args['post_status'] ) . "')";

Expand Down

0 comments on commit 97b9b5f

Please sign in to comment.