| @@ -17,13 +17,13 @@ | ||
| 17 | 17 | * |
| 18 | 18 | * @param array $data Submitted form data |
| 19 | 19 | * @param string $type Form type. |
| 20 | 20 | * @param array|bool $fields Fields applicable for validation. |
| 21 | - * @param string $extra_where Extra where query. | |
| 22 | 21 | * |
| 23 | 22 | * @return array|mixed|WP_Error Validated form data. |
| 24 | 23 | */ |
| 25 | - public function validate_fields( $data, $type, $fields = false, $extra_where = '' ) { | |
| 24 | + public function validate_fields($data, $type, $fields = false) { | |
| 25 | + | |
| 26 | 26 | $errors = new WP_Error(); |
| 27 | 27 | |
| 28 | 28 | $errors = apply_filters('uwp_validate_fields_before', $errors, $data, $type); |
| 29 | 29 | |
| @@ -44,9 +44,9 @@ | ||
| 44 | 44 | $fields = get_register_validate_form_fields($form_id); |
| 45 | 45 | } elseif ($type == 'change') { |
| 46 | 46 | $fields = get_change_validate_form_fields(); |
| 47 | 47 | } elseif ($type == 'account') { |
| 48 | - $fields = get_account_form_fields( $extra_where ); | |
| 48 | + $fields = get_account_form_fields(); | |
| 49 | 49 | } else { |
| 50 | 50 | $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $table_name . " WHERE form_type = %s AND field_type != 'fieldset' AND field_type != 'file' AND is_active = '1' ORDER BY sort_order ASC", array($type))); |
| 51 | 51 | } |
| 52 | 52 | } |
| @@ -181,23 +181,11 @@ | ||
| 181 | 181 | case 'editor': |
| 182 | 182 | $sanitized_value = wp_kses_post( strip_shortcodes( $value ) ); |
| 183 | 183 | break; |
| 184 | 184 | |
| 185 | - case 'url': | |
| 186 | - $sanitized_value = sanitize_url( wp_unslash( $value ) ); | |
| 187 | - break; | |
| 188 | - | |
| 189 | - case 'file': | |
| 190 | - $sanitized_value = sanitize_text_field( $value ); | |
| 191 | - | |
| 192 | - // Validate the file path. | |
| 193 | - if ( $sanitized_value && validate_file( $sanitized_value ) !== 0 ) { | |
| 194 | - $sanitized_value = ''; | |
| 195 | - } | |
| 196 | - break; | |
| 197 | - | |
| 198 | 185 | default: |
| 199 | 186 | $sanitized_value = sanitize_text_field($value); |
| 187 | + | |
| 200 | 188 | } |
| 201 | 189 | } |
| 202 | 190 | |
| 203 | 191 | if ($field->is_required == 1 && $sanitized_value == '' && $field->field_type != 'file') { |
| @@ -243,13 +231,13 @@ | ||
| 243 | 231 | if (username_exists($sanitized_value)) { |
| 244 | 232 | $errors->add('username_exists', __('<strong>Error</strong>: This username is already registered. Please choose another one.', 'userswp')); |
| 245 | 233 | return $errors; |
| 246 | 234 | } |
| 247 | - $username_length = uwp_get_option( 'register_username_length', 4); | |
| 248 | - $username_length_max = uwp_get_option( 'register_username_length_max', 20); | |
| 235 | + $username_length = uwp_get_option( 'register_username_length'); | |
| 236 | + $username_length = !empty($username_length) ? (int)$username_length : 4; | |
| 249 | 237 | |
| 250 | - if(!empty($sanitized_value) && (strlen($sanitized_value) < $username_length || strlen($sanitized_value) > $username_length_max)) { | |
| 251 | - $errors->add('username_length', sprintf(__('<strong>Error</strong>: Username must be between %s and %s characters.', 'userswp'), $username_length, $username_length_max)); | |
| 238 | + if(!empty($sanitized_value) && strlen($sanitized_value) < $username_length) { | |
| 239 | + $errors->add('username_length', sprintf(__('<strong>Error</strong>: Username must be %s characters or more.', 'userswp'), $username_length)); | |
| 252 | 240 | return $errors; |
| 253 | 241 | } |
| 254 | 242 | } |
| 255 | 243 | |