Specify default sort order for webhok DS.

This commit is contained in:
vedanshujain 2021-06-22 12:28:44 +05:30
parent 93fe370966
commit 02f7a86db0
1 changed files with 2 additions and 1 deletions

View File

@ -272,7 +272,8 @@ class WC_Webhook_Data_Store implements WC_Webhook_Data_Store_Interface {
'post_modified' => 'date_modified_gmt',
);
$orderby = isset( $orderby_mapping[ $args['orderby'] ] ) ? $orderby_mapping[ $args['orderby'] ] : 'webhook_id';
$order = "ORDER BY {$orderby} " . esc_sql( strtoupper( $args['order'] ) );
$sort = 'ASC' === strtoupper( $args['order'] ) ? 'ASC' : 'DESC';
$order = "ORDER BY {$orderby} {$sort}";
$limit = -1 < $args['limit'] ? $wpdb->prepare( 'LIMIT %d', $args['limit'] ) : '';
$offset = 0 < $args['offset'] ? $wpdb->prepare( 'OFFSET %d', $args['offset'] ) : '';
$status = ! empty( $args['status'] ) ? $wpdb->prepare( 'AND `status` = %s', isset( $statuses[ $args['status'] ] ) ? $statuses[ $args['status'] ] : $args['status'] ) : '';