| @@ -49,13 +49,8 @@ | ||
| 49 | 49 | * @return array An array of the queried achievements |
| 50 | 50 | */ |
| 51 | 51 | function gamipress_get_achievements( $args = array() ) { |
| 52 | 52 | |
| 53 | - // If not properly upgrade to required version fallback to compatibility function | |
| 54 | - if( ! is_gamipress_upgraded_to( '1.5.1' ) ) { | |
| 55 | - return gamipress_get_achievements_old( $args ); | |
| 56 | - } | |
| 57 | - | |
| 58 | 53 | // Setup our defaults |
| 59 | 54 | $defaults = array( |
| 60 | 55 | 'post_type' => array_merge( gamipress_get_achievement_types_slugs(), gamipress_get_requirement_types_slugs() ), |
| 61 | 56 | 'numberposts' => -1, |
| @@ -156,21 +151,8 @@ | ||
| 156 | 151 | * @return object|bool The post object of the achievement, or false if none |
| 157 | 152 | */ |
| 158 | 153 | function gamipress_get_step_achievement( $step_id = 0 ) { |
| 159 | 154 | |
| 160 | - // If not properly upgrade to required version fallback to compatibility function | |
| 161 | - if( ! is_gamipress_upgraded_to( '1.5.1' ) ) { | |
| 162 | - | |
| 163 | - $achievement = gamipress_get_parent_of_achievement( $step_id ); | |
| 164 | - | |
| 165 | - if( $achievement ) { | |
| 166 | - return $achievement; | |
| 167 | - } else { | |
| 168 | - return false; | |
| 169 | - } | |
| 170 | - | |
| 171 | - } | |
| 172 | - | |
| 173 | 155 | // Grab the current post ID if no step ID was specified |
| 174 | 156 | if ( ! $step_id ) { |
| 175 | 157 | global $post; |
| 176 | 158 | $step_id = $post->ID; |
| @@ -199,14 +181,8 @@ | ||
| 199 | 181 | * @return array An array of post objects with the achievement's steps |
| 200 | 182 | */ |
| 201 | 183 | function gamipress_get_achievement_steps( $achievement_id = 0, $post_status = 'publish' ) { |
| 202 | 184 | |
| 203 | - // If not properly upgrade to required version fallback to compatibility function | |
| 204 | - if( ! is_gamipress_upgraded_to( '1.5.1' ) ) { | |
| 205 | - // gamipress_get_assigned_requirements() has backward compatibility and merge new and old results | |
| 206 | - return gamipress_get_assigned_requirements( $achievement_id, 'step', $post_status ); | |
| 207 | - } | |
| 208 | - | |
| 209 | 185 | // Grab the current post ID if no achievement_id was specified |
| 210 | 186 | if ( ! $achievement_id ) { |
| 211 | 187 | global $post; |
| 212 | 188 | $achievement_id = $post->ID; |
| @@ -509,13 +485,8 @@ | ||
| 509 | 485 | * @return array An array of achievements that are dependent on the given achievement |
| 510 | 486 | */ |
| 511 | 487 | function gamipress_get_dependent_achievements( $achievement_id = 0 ) { |
| 512 | 488 | |
| 513 | - // If not properly upgrade to required version fallback to compatibility function | |
| 514 | - if( ! is_gamipress_upgraded_to( '1.5.1' ) ) { | |
| 515 | - return gamipress_get_dependent_achievements_old( $achievement_id ); | |
| 516 | - } | |
| 517 | - | |
| 518 | 489 | global $wpdb; |
| 519 | 490 | |
| 520 | 491 | // Grab the current achievement ID if none specified |
| 521 | 492 | if ( ! $achievement_id ) { |
| @@ -564,13 +535,8 @@ | ||
| 564 | 535 | * @return array An array of achievements that are dependent on the given achievement |
| 565 | 536 | */ |
| 566 | 537 | function gamipress_get_required_achievements_for_achievement( $achievement_id = 0, $post_status = 'publish' ) { |
| 567 | 538 | |
| 568 | - // If not properly upgrade to required version fallback to compatibility function | |
| 569 | - if( ! is_gamipress_upgraded_to( '1.5.1' ) ) { | |
| 570 | - return gamipress_get_required_achievements_for_achievement_old( $achievement_id ); | |
| 571 | - } | |
| 572 | - | |
| 573 | 539 | global $wpdb; |
| 574 | 540 | |
| 575 | 541 | // Grab the current achievement ID if none specified |
| 576 | 542 | if ( ! $achievement_id ) { |
| @@ -884,27 +850,27 @@ | ||
| 884 | 850 | $args = apply_filters( 'gamipress_get_achievement_earners_args', $args, $achievement_id ); |
| 885 | 851 | |
| 886 | 852 | $args = wp_parse_args( $args, $defaults ); |
| 887 | 853 | |
| 854 | + // Sanitization | |
| 855 | + $args['limit'] = absint( $args['limit'] ); | |
| 856 | + $args['order'] = gamipress_validate_from_array( strtoupper( $args['order'] ), array( 'ASC', 'DESC' ), 'DESC' ); | |
| 857 | + | |
| 888 | 858 | // Setup FROM |
| 889 | - if( ! empty( $args['from'] ) ) { | |
| 859 | + if( ! empty( $args['from'] ) ) | |
| 890 | 860 | $from .= $args['from']; |
| 891 | - } | |
| 892 | 861 | |
| 893 | 862 | // Setup WHERE |
| 894 | - if( ! empty( $args['where'] ) ) { | |
| 863 | + if( ! empty( $args['where'] ) ) | |
| 895 | 864 | $where .= $args['where']; |
| 896 | - } | |
| 897 | 865 | |
| 898 | 866 | // Setup LIMIT |
| 899 | - if( (int)( $args['limit'] ) > 0 ) { | |
| 867 | + if( (int)( $args['limit'] ) > 0 ) | |
| 900 | 868 | $limit = '0, ' . $args['limit']; |
| 901 | - } | |
| 902 | 869 | |
| 903 | 870 | // Setup ORDER BY |
| 904 | - if( ! empty( $args['orderby'] ) ) { | |
| 871 | + if( ! empty( $args['orderby'] ) ) | |
| 905 | 872 | $order_by = $args['orderby'] . ' ' . $args['order']; |
| 906 | - } | |
| 907 | 873 | |
| 908 | 874 | $earners = $wpdb->get_col( |
| 909 | 875 | "SELECT u.user_id |
| 910 | 876 | FROM {$from} |
| @@ -1226,14 +1192,8 @@ | ||
| 1226 | 1192 | * @param string $original_type Original achievement type. |
| 1227 | 1193 | * @param string $new_type New achievement type. |
| 1228 | 1194 | */ |
| 1229 | 1195 | function gamipress_update_earned_meta_achievement_types( $original_type = '', $new_type = '' ) { |
| 1230 | - | |
| 1231 | - // If not properly upgrade to required version fallback to compatibility function | |
| 1232 | - if( ! is_gamipress_upgraded_to( '1.2.8' ) ) { | |
| 1233 | - gamipress_update_earned_meta_achievement_types_old( $original_type, $new_type ); | |
| 1234 | - return; | |
| 1235 | - } | |
| 1236 | 1196 | |
| 1237 | 1197 | // Setup CT object |
| 1238 | 1198 | $ct_table = ct_setup_table( 'gamipress_user_earnings' ); |
| 1239 | 1199 | |