| @@ -850,27 +850,27 @@ | ||
| 850 | 850 | $args = apply_filters( 'gamipress_get_achievement_earners_args', $args, $achievement_id ); |
| 851 | 851 | |
| 852 | 852 | $args = wp_parse_args( $args, $defaults ); |
| 853 | 853 | |
| 854 | + // Sanitization | |
| 855 | + $args['limit'] = absint( $args['limit'] ); | |
| 856 | + $args['order'] = gamipress_validate_from_array( strtoupper( $args['order'] ), array( 'ASC', 'DESC' ), 'DESC' ); | |
| 857 | + | |
| 854 | 858 | // Setup FROM |
| 855 | - if( ! empty( $args['from'] ) ) { | |
| 859 | + if( ! empty( $args['from'] ) ) | |
| 856 | 860 | $from .= $args['from']; |
| 857 | - } | |
| 858 | 861 | |
| 859 | 862 | // Setup WHERE |
| 860 | - if( ! empty( $args['where'] ) ) { | |
| 863 | + if( ! empty( $args['where'] ) ) | |
| 861 | 864 | $where .= $args['where']; |
| 862 | - } | |
| 863 | 865 | |
| 864 | 866 | // Setup LIMIT |
| 865 | - if( (int)( $args['limit'] ) > 0 ) { | |
| 867 | + if( (int)( $args['limit'] ) > 0 ) | |
| 866 | 868 | $limit = '0, ' . $args['limit']; |
| 867 | - } | |
| 868 | 869 | |
| 869 | 870 | // Setup ORDER BY |
| 870 | - if( ! empty( $args['orderby'] ) ) { | |
| 871 | + if( ! empty( $args['orderby'] ) ) | |
| 871 | 872 | $order_by = $args['orderby'] . ' ' . $args['order']; |
| 872 | - } | |
| 873 | 873 | |
| 874 | 874 | $earners = $wpdb->get_col( |
| 875 | 875 | "SELECT u.user_id |
| 876 | 876 | FROM {$from} |