PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.22.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.22.1
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/FrmEntryValidate.php +304 -111 6.4.16.22.1 View file →
@@ -5,10 +5,17 @@
5 5
6 6 class FrmEntryValidate {
7 7
8 8 /**
9 + * @since 6.17
10 + *
11 + * @var array|null
12 + */
13 + private static $name_text_fields;
14 +
15 + /**
9 16 * @param array $values
10 - * @param string[]|bool $exclude
17 + * @param bool|string[] $exclude
11 18 * @return array
12 19 */
13 20 public static function validate( $values, $exclude = false ) {
14 21 FrmEntry::sanitize_entry_post( $values );
@@ -24,8 +31,9 @@
24 31 $frm_settings = FrmAppHelper::get_settings();
25 32 $errors['form'] = $frm_settings->admin_permission;
26 33 }
27 34
35 + self::maybe_fix_item_meta();
28 36 self::set_item_key( $values );
29 37
30 38 $posted_fields = self::get_fields_to_validate( $values, $exclude );
31 39
@@ -54,14 +62,29 @@
54 62
55 63 if ( is_array( $filtered_errors ) ) {
56 64 $errors = $filtered_errors;
57 65 } else {
58 - _doing_it_wrong( __FUNCTION__, 'Only arrays should be returned when using the frm_validate_entry filter.', '6.3' );
66 + _doing_it_wrong( __METHOD__, 'Only arrays should be returned when using the frm_validate_entry filter.', '6.3' );
59 67 }
60 68
61 69 return $errors;
62 70 }
63 71
72 + /**
73 + * In case $_POST['item_meta'] is not an array, change it to an empty array.
74 + * This helps to avoid some warnings and errors when $_POST['item_meta'] is updated.
75 + *
76 + * @since 6.6
77 + *
78 + * @return void
79 + */
80 + private static function maybe_fix_item_meta() {
81 + // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
82 + if ( ! isset( $_POST['item_meta'] ) || ! is_array( $_POST['item_meta'] ) ) {
83 + $_POST['item_meta'] = array();
84 + }
85 + }
86 +
64 87 private static function set_item_key( &$values ) {
65 88 if ( ! isset( $values['item_key'] ) || $values['item_key'] == '' ) {
66 89 global $wpdb;
67 90 $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' );
@@ -95,13 +118,17 @@
95 118
96 119 public static function validate_field( $posted_field, &$errors, $values, $args = array() ) {
97 120 $defaults = array(
98 121 'id' => $posted_field->id,
99 - 'parent_field_id' => '', // the id of the repeat or embed form
100 - 'key_pointer' => '', // the pointer in the posted array
101 - 'exclude' => array(), // exclude these field types from validation
122 + // The id of the repeat or embed form.
123 + 'parent_field_id' => '',
124 + // The pointer in the posted array.
125 + 'key_pointer' => '',
126 + // Exclude these field types from validation.
127 + 'exclude' => array(),
128 +
102 129 );
103 - $args = wp_parse_args( $args, $defaults );
130 + $args = wp_parse_args( $args, $defaults );
104 131
105 132 if ( empty( $args['parent_field_id'] ) ) {
106 133 $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
107 134 } else {
@@ -130,8 +157,9 @@
130 157 }
131 158
132 159 FrmEntriesHelper::set_posted_value( $posted_field, $value, $args );
133 160
161 + self::validate_options( $errors, $posted_field, $value, $args );
134 162 self::validate_field_types( $errors, $posted_field, $value, $args );
135 163
136 164 // Field might want to modify value before other parts of the system
137 165 // e.g. trim off excess values like in the case of fields with limit.
@@ -142,16 +170,183 @@
142 170 }
143 171
144 172 $errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args );
145 173 $errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args );
174 +
175 + if ( ! FrmAppHelper::pro_is_installed() && empty( $args['other'] ) ) {
176 + FrmEntriesHelper::get_posted_value( $posted_field, $value, $args );
177 + }
146 178 }
147 179
148 180 /**
181 + * @since 6.21
182 + *
183 + * @param array $errors
184 + * @param object $posted_field
185 + * @param array|string $value
186 + * @param array $args
187 + *
188 + * @return void
189 + */
190 + private static function validate_options( &$errors, $posted_field, $value, $args ) {
191 + if ( empty( $posted_field->options ) ) {
192 + return;
193 + }
194 +
195 + $option_is_valid = self::option_is_valid( $posted_field, $value, $posted_field->options );
196 +
197 + /**
198 + * @since 6.21
199 + *
200 + * @param bool $option_is_valid
201 + * @param array|string $value
202 + * @param object $field
203 + */
204 + $option_is_valid = (bool) apply_filters( 'frm_option_is_valid', $option_is_valid, $value, $posted_field );
205 +
206 + if ( ! $option_is_valid ) {
207 + $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'invalid' );
208 + }
209 + }
210 +
211 + /**
212 + * Validate that value matches one of the options for the field.
213 + *
214 + * @since 6.21
215 + *
216 + * @param stdClass $field
217 + * @param array|string $value
218 + * @param array $options
219 + * @return bool
220 + */
221 + private static function option_is_valid( $field, $value, $options ) {
222 + if ( '' === $value ) {
223 + return true;
224 + }
225 +
226 + if ( in_array( $field->type, array( 'likert', 'ranking' ), true ) ) {
227 + // Ignore these field types automatically.
228 + return true;
229 + }
230 +
231 + if ( 'product' === $field->type && 'user_def' === FrmField::get_option( $field, 'data_type' ) ) {
232 + return true;
233 + }
234 +
235 + if ( ! empty( $field->field_options['post_field'] ) ) {
236 + return true;
237 + }
238 +
239 + $value = (array) $value;
240 +
241 + foreach ( $value as $current_value ) {
242 + $match = false;
243 +
244 + foreach ( $options as $key => $option ) {
245 + if ( strpos( $key, 'other_' ) === 0 ) {
246 + // Always return true if an other option is found.
247 + return true;
248 + }
249 +
250 + if ( is_array( $option ) ) {
251 + $separate_value = FrmField::get_option( $field, 'separate_value' );
252 + $option_value = $separate_value ? $option['value'] : $option['label'];
253 + } else {
254 + $option_value = $option;
255 + }
256 +
257 + $match = trim( $current_value ) === trim( $option_value );
258 + if ( $match ) {
259 + break;
260 + }
261 +
262 + $match = trim( $current_value ) === trim( do_shortcode( $option_value ) );
263 + if ( $match ) {
264 + break;
265 + }
266 +
267 + $match = self::is_filtered_match( $current_value, $option_value );
268 + if ( $match ) {
269 + break;
270 + }
271 +
272 + if ( is_numeric( $current_value ) ) {
273 + $match = (int) $current_value === (int) $option_value;
274 + if ( $match ) {
275 + break;
276 + }
277 + }
278 + }//end foreach
279 +
280 + if ( ! $match ) {
281 + return self::options_are_dynamic_based_on_hook( $field, $value );
282 + }
283 + }//end foreach
284 +
285 + return true;
286 + }
287 +
288 + /**
289 + * Make an extra check after passing $option_value through the_content filter.
290 + * This is to help catch cases where the option's formatting has been modified using
291 + * the_content filter.
292 + *
293 + * @since 6.22
294 + *
295 + * @param string $value
296 + * @param string $option_value
297 + * @return bool
298 + */
299 + private static function is_filtered_match( $value, $option_value ) {
300 + // First remove the wpautop filter so it doesn't add extra tags to $option_value.
301 + $filter_priority = has_filter( 'the_content', 'wpautop' );
302 + if ( is_numeric( $filter_priority ) ) {
303 + remove_filter( 'the_content', 'wpautop', $filter_priority );
304 + }
305 + $filtered_option = apply_filters( 'the_content', $option_value );
306 + if ( is_numeric( $filter_priority ) ) {
307 + add_filter( 'the_content', 'wpautop', $filter_priority );
308 + }
309 + return trim( $value ) === trim( $filtered_option );
310 + }
311 +
312 + /**
313 + * Do not validate options if they have been modified with a hook.
314 + * This is to help avoid issues where the options could be based on a URL param for example.
315 + *
316 + * @since 6.21
317 + *
318 + * @return bool
319 + */
320 + private static function options_are_dynamic_based_on_hook( $field_object, $value ) {
321 + $values = (array) $field_object;
322 + $values['value'] = $value;
323 + FrmFieldsHelper::prepare_new_front_field( $values, $field_object );
324 +
325 + $separate_value = FrmField::get_option( $field_object, 'separate_value' );
326 + $map_callback = function ( $option ) use ( $separate_value ) {
327 + if ( is_array( $option ) ) {
328 + $option_value = $separate_value ? $option['value'] : $option['label'];
329 + } else {
330 + $option_value = $option;
331 + }
332 + $option_value = do_shortcode( $option_value );
333 + return $option_value;
334 + };
335 +
336 + $values_options = array_map( $map_callback, $values['options'] );
337 + $field_object_options = array_map( $map_callback, $field_object->options );
338 +
339 + return $values_options !== $field_object_options;
340 + }
341 +
342 + /**
149 343 * Maybe add item_name to $_POST to save it in items table.
150 344 *
151 345 * @since 5.2.02
152 346 *
153 - * @param object $field Field object.
347 + * @param array|string $value Field value.
348 + * @param object $field Field object.
154 349 */
155 350 private static function maybe_add_item_name( $value, $field ) {
156 351 $item_name = false;
157 352 if ( 'name' === $field->type ) {
@@ -195,10 +390,11 @@
195 390 }
196 391 }
197 392
198 393 public static function validate_phone_field( &$errors, $field, $value, $args ) {
199 - if ( $field->type == 'phone' || ( $field->type == 'text' && FrmField::is_option_true_in_object( $field, 'format' ) ) ) {
394 + $format_value = FrmField::get_option( $field, 'format' );
200 395
396 + if ( $field->type === 'phone' || ( $field->type === 'text' && $format_value && ! FrmCurrencyHelper::is_currency_format( $format_value ) ) ) {
201 397 $pattern = self::phone_format( $field );
202 398
203 399 if ( ! preg_match( $pattern, $value ) ) {
204 400 $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
@@ -212,8 +408,11 @@
212 408 } else {
213 409 $pattern = FrmField::get_option( $field, 'format' );
214 410 }
215 411
412 + // Ampersands are saved as &.
413 + // Reverse it here so we are checking for the correct character.
414 + $pattern = html_entity_decode( $pattern );
216 415 $pattern = apply_filters( 'frm_phone_pattern', $pattern, $field );
217 416
218 417 // Create a regexp if format is not already a regexp
219 418 if ( strpos( $pattern, '^' ) !== 0 ) {
@@ -270,27 +469,36 @@
270 469 return $pattern;
271 470 }
272 471
273 472 /**
274 - * Check for spam
473 + * Check for spam.
275 474 *
276 - * @param boolean $exclude
475 + * @param bool $exclude
277 476 * @param array $values
278 - * @param array $errors by reference
477 + * @param array $errors By reference.
279 478 */
280 479 public static function spam_check( $exclude, $values, &$errors ) {
281 - if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
480 + if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
481 + // Do not check spam on importing.
482 + return;
483 + }
484 +
485 + if ( ! empty( $exclude ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
282 486 // only check spam if there are no other errors
283 487 return;
284 488 }
285 489
286 490 $antispam_check = self::is_antispam_check( $values['form_id'] );
491 + $spam_msg = FrmAntiSpamController::get_default_spam_message();
287 492 if ( is_string( $antispam_check ) ) {
288 493 $errors['spam'] = $antispam_check;
289 494 } elseif ( self::is_honeypot_spam( $values ) || self::is_spam_bot() ) {
290 - $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
291 - } elseif ( self::blacklist_check( $values ) ) {
292 - $errors['spam'] = __( 'Your entry appears to be blocked spam!', 'formidable' );
495 + $errors['spam'] = $spam_msg;
496 + } else {
497 + $is_spam = FrmAntiSpamController::is_spam( $values );
498 + if ( $is_spam ) {
499 + $errors['spam'] = $is_spam;
500 + }
293 501 }
294 502
295 503 if ( isset( $errors['spam'] ) || self::form_is_in_progress( $values ) ) {
296 504 return;
@@ -326,9 +534,9 @@
326 534 }
327 535
328 536 /**
329 537 * @param array $values
330 - * @return boolean
538 + * @return bool
331 539 */
332 540 private static function is_honeypot_spam( $values ) {
333 541 $honeypot = new FrmHoneypot( $values['form_id'] );
334 542 return ! $honeypot->validate();
@@ -334,9 +542,9 @@
334 542 return ! $honeypot->validate();
335 543 }
336 544
337 545 /**
338 - * @return boolean
546 + * @return bool
339 547 */
340 548 private static function is_spam_bot() {
341 549 $ip = FrmAppHelper::get_ip_address();
342 550
@@ -344,9 +552,9 @@
344 552 }
345 553
346 554 /**
347 555 * @param array $values
348 - * @return boolean
556 + * @return bool
349 557 */
350 558 private static function is_akismet_spam( $values ) {
351 559 global $wpcom_api_key;
352 560
@@ -362,59 +570,23 @@
362 570
363 571 return ( ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] !== 'logged' || ! is_user_logged_in() ) );
364 572 }
365 573
366 - public static function blacklist_check( $values ) {
367 - if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) {
368 - return false;
369 - }
370 -
371 - $mod_keys = trim( self::get_disallowed_words() );
372 - if ( empty( $mod_keys ) ) {
373 - return false;
374 - }
375 -
376 - $content = FrmEntriesHelper::entry_array_to_string( $values );
377 -
378 - self::prepare_values_for_spam_check( $values );
379 - $ip = FrmAppHelper::get_ip_address();
380 - $user_agent = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' );
381 - $user_info = self::get_spam_check_user_info( $values );
382 -
383 - return self::check_disallowed_words( $user_info['comment_author'], $user_info['comment_author_email'], $user_info['comment_author_url'], $content, $ip, $user_agent );
384 - }
385 -
386 574 /**
387 - * For WP 5.5 compatibility.
575 + * Checks spam using WordPress disallowed words and Frm denylist.
388 576 *
389 - * @since 4.06.02
390 - */
391 - private static function check_disallowed_words( $author, $email, $url, $content, $ip, $user_agent ) {
392 - if ( function_exists( 'wp_check_comment_disallowed_list' ) ) {
393 - return wp_check_comment_disallowed_list( $author, $email, $url, $content, $ip, $user_agent );
394 - } else {
395 - return wp_blacklist_check( $author, $email, $url, $content, $ip, $user_agent );
396 - }
397 - }
398 -
399 - /**
400 - * For WP 5.5 compatibility.
577 + * @param array $values Entry values.
401 578 *
402 - * @since 4.06.02
579 + * @return bool
403 580 */
404 - private static function get_disallowed_words() {
405 - $keys = get_option( 'disallowed_keys' );
406 - if ( false === $keys ) {
407 - // Fallback for WP < 5.5.
408 - $keys = get_option( 'blacklist_keys' );
409 - }
410 - return $keys;
581 + public static function blacklist_check( $values ) {
582 + return FrmAntiSpamController::contains_wp_disallowed_words( $values ) || FrmAntiSpamController::is_denylist_spam( $values );
411 583 }
412 584
413 585 /**
414 586 * Check entries for Akismet spam
415 587 *
416 - * @return boolean true if is spam
588 + * @return bool true if is spam
417 589 */
418 590 public static function akismet( $values ) {
419 591 if ( empty( $values['item_meta'] ) ) {
420 592 return false;
@@ -436,9 +608,9 @@
436 608
437 609 $query_string = _http_build_query( $datas, '', '&' );
438 610 $response = Akismet::http_post( $query_string, 'comment-check' );
439 611
440 - return ( is_array( $response ) && $response[1] == 'true' );
612 + return ( is_array( $response ) && $response[1] === 'true' );
441 613 }
442 614
443 615 /**
444 616 * @since 2.0
@@ -447,8 +619,9 @@
447 619 self::add_site_info_to_akismet( $datas );
448 620 self::add_server_values_to_akismet( $datas );
449 621
450 622 self::prepare_values_for_spam_check( $values );
623 + self::skip_adding_values_to_akismet( $values );
451 624
452 625 self::add_user_info_to_akismet( $datas, $values );
453 626 self::add_comment_content_to_akismet( $datas, $values );
454 627 }
@@ -478,13 +651,14 @@
478 651 /**
479 652 * Gets user info for Akismet spam check.
480 653 *
481 654 * @since 5.0.13 Separate code for guest. Handle value of embedded|repeater.
655 + * @since 6.21 This changed from private to public.
482 656 *
483 657 * @param array $values Entry values after running through {@see FrmEntryValidate::prepare_values_for_spam_check()}.
484 658 * @return array
485 659 */
486 - private static function get_spam_check_user_info( $values ) {
660 + public static function get_spam_check_user_info( $values ) {
487 661 if ( ! is_user_logged_in() ) {
488 662 return self::get_spam_check_user_info_for_guest( $values );
489 663 }
490 664
@@ -541,9 +715,10 @@
541 715 */
542 716 private static function recursive_add_akismet_guest_info( &$datas, $values, $custom_index = null ) {
543 717 foreach ( $values as $index => $value ) {
544 718 if ( ! $datas['missing_keys'] ) {
545 - return; // Found all info.
719 + // Found all info.
720 + return;
546 721 }
547 722
548 723 if ( is_array( $value ) ) {
549 724 self::recursive_add_akismet_guest_info( $datas, $value, $index );
@@ -551,9 +726,9 @@
551 726 }
552 727
553 728 $field_id = ! is_null( $custom_index ) ? $custom_index : $index;
554 729 foreach ( $datas['missing_keys'] as $key_index => $key ) {
555 - $found = self::is_akismet_guest_info_value( $key, $value, $field_id, $datas['name_field_ids'] );
730 + $found = self::is_akismet_guest_info_value( $key, $value, $field_id, $datas['name_field_ids'], $values );
556 731 if ( $found ) {
557 732 $datas[ $key ] = $value;
558 733 $datas['frm_duplicated'][] = $field_id;
559 734 unset( $datas['missing_keys'][ $key_index ] );
@@ -558,9 +733,9 @@
558 733 $datas['frm_duplicated'][] = $field_id;
559 734 unset( $datas['missing_keys'][ $key_index ] );
560 735 }
561 736 }
562 - }
737 + }//end foreach
563 738 }
564 739
565 740 /**
566 741 * Checks if given value is an akismet guest info.
@@ -570,11 +745,13 @@
570 745 * @param string $key Guest info key.
571 746 * @param string $value Value to check.
572 747 * @param int $field_id Field ID.
573 748 * @param array $name_field_ids Name field IDs.
749 + * @param array $values Array of posted values.
750 + *
574 751 * @return bool
575 752 */
576 - private static function is_akismet_guest_info_value( $key, $value, $field_id, $name_field_ids ) {
753 + private static function is_akismet_guest_info_value( $key, &$value, $field_id, $name_field_ids, $values ) {
577 754 if ( ! $value || is_numeric( $value ) ) {
578 755 return false;
579 756 }
580 757
@@ -585,16 +762,60 @@
585 762 case 'comment_author_url':
586 763 return 0 === strpos( $value, 'http' );
587 764
588 765 case 'comment_author':
589 - if ( $name_field_ids ) {
766 + if ( $name_field_ids && in_array( $field_id, $name_field_ids, true ) ) {
590 767 // If there is name field in the form, we should always use it as author name.
591 - return in_array( $field_id, $name_field_ids, true );
768 + return true;
592 769 }
593 - return strlen( $value ) < 200;
770 + $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
771 + $fields = self::get_name_text_fields( $form_id );
772 +
773 + foreach ( $fields as $index => $field ) {
774 + if ( 'Name' !== $field->name ) {
775 + continue;
776 + }
777 + if ( isset( $fields[ $index + 1 ] ) && 'Last' === $fields[ $index + 1 ]->name ) {
778 + if ( empty( $values[ absint( $fields[ $index + 1 ]->id ) ] ) ) {
779 + continue;
780 + }
781 + $value .= ' ' . $values[ $fields[ $index + 1 ]->id ];
782 + return true;
783 + }
784 + }
785 + }//end switch
786 +
787 + return false;
788 + }
789 +
790 + /**
791 + * Returns fields that have 'Name' and 'Last' as their name.
792 + *
793 + * @since 6.17
794 + *
795 + * @param int $form_id
796 + * @return array
797 + */
798 + private static function get_name_text_fields( $form_id ) {
799 + $name_text_fields_is_initialized = is_array( self::$name_text_fields );
800 + if ( $name_text_fields_is_initialized && isset( self::$name_text_fields[ $form_id ] ) ) {
801 + return self::$name_text_fields[ $form_id ];
594 802 }
803 + if ( ! $name_text_fields_is_initialized ) {
804 + self::$name_text_fields = array();
805 + }
806 + self::$name_text_fields[ $form_id ] = FrmDb::get_results(
807 + 'frm_fields',
808 + array(
809 + 'form_id' => $form_id,
810 + 'type' => 'text',
811 + 'name' => array( 'Name', 'Last' ),
812 + ),
813 + 'id,name',
814 + array( 'order_by' => 'field_order ASC' )
815 + );
595 816
596 - return false;
817 + return self::$name_text_fields[ $form_id ];
597 818 }
598 819
599 820 private static function add_server_values_to_akismet( &$datas ) {
600 821 foreach ( $_SERVER as $key => $value ) {
@@ -627,10 +848,8 @@
627 848 }
628 849 unset( $datas['frm_duplicated'] );
629 850 }
630 851
631 - self::skip_adding_values_to_akismet( $values );
632 -
633 852 $datas['comment_content'] = FrmEntriesHelper::entry_array_to_string( $values );
634 853 }
635 854
636 855 /**
@@ -665,14 +884,16 @@
665 884 * @param array $values Entry values.
666 885 * @return bool
667 886 */
668 887 private static function should_really_skip_field( $field_data, $values ) {
669 - if ( empty( $field_data->options ) ) { // This is skipped field types.
888 + if ( empty( $field_data->options ) ) {
889 + // This is skipped field types.
670 890 return true;
671 891 }
672 892
673 893 FrmAppHelper::unserialize_or_decode( $field_data->options );
674 - if ( ! $field_data->options ) { // Check if an error happens when unserializing, or empty options.
894 + if ( ! $field_data->options ) {
895 + // Check if an error happens when unserializing, or empty options.
675 896 return true;
676 897 }
677 898
678 899 end( $field_data->options );
@@ -730,12 +951,13 @@
730 951 /**
731 952 * Prepares values array for spam check.
732 953 *
733 954 * @since 5.0.13
955 + * @since 6.21 This changed from private to public.
734 956 *
735 957 * @param array $values Entry values.
736 958 */
737 - private static function prepare_values_for_spam_check( &$values ) {
959 + public static function prepare_values_for_spam_check( &$values ) {
738 960 $form_ids = self::get_all_form_ids_and_flatten_meta( $values );
739 961 $values['form_ids'] = $form_ids;
740 962 }
741 963
@@ -754,9 +976,10 @@
754 976
755 977 // Blacklist check for File field in the old version doesn't contain `form_id`.
756 978 $form_ids = isset( $values['form_id'] ) ? array( absint( $values['form_id'] ) ) : array();
757 979 foreach ( $values['item_meta'] as $field_id => $value ) {
758 - if ( ! is_numeric( $field_id ) ) { // Maybe `other`.
980 + if ( ! is_numeric( $field_id ) ) {
981 + // Maybe `other`.
759 982 continue;
760 983 }
761 984
762 985 // Convert name array to string.
@@ -792,46 +1015,16 @@
792 1015
793 1016 $values['name_field_ids'][] = $subsubindex;
794 1017 }
795 1018
796 - $values['item_meta'][ $subsubindex ][] = $subsubvalue;
1019 + if ( is_array( $values['item_meta'][ $subsubindex ] ) ) {
1020 + $values['item_meta'][ $subsubindex ][] = $subsubvalue;
1021 + }
797 1022 }
798 - }
1023 + }//end foreach
799 1024
800 1025 unset( $values['item_meta'][ $field_id ] );
801 - }
1026 + }//end foreach
802 1027
803 1028 return $form_ids;
804 - }
805 -
806 - /**
807 - * @deprecated 3.0
808 - * @codeCoverageIgnore
809 - */
810 - public static function validate_url_field( &$errors, $field, $value, $args ) {
811 - FrmDeprecated::validate_url_field( $errors, $field, $value, $args );
812 - }
813 -
814 - /**
815 - * @deprecated 3.0
816 - * @codeCoverageIgnore
817 - */
818 - public static function validate_email_field( &$errors, $field, $value, $args ) {
819 - FrmDeprecated::validate_email_field( $errors, $field, $value, $args );
820 - }
821 -
822 - /**
823 - * @deprecated 3.0
824 - * @codeCoverageIgnore
825 - */
826 - public static function validate_number_field( &$errors, $field, $value, $args ) {
827 - FrmDeprecated::validate_number_field( $errors, $field, $value, $args );
828 - }
829 -
830 - /**
831 - * @deprecated 3.0
832 - * @codeCoverageIgnore
833 - */
834 - public static function validate_recaptcha( &$errors, $field, $args ) {
835 - FrmDeprecated::validate_recaptcha( $errors, $field, $args );
836 1029 }
837 1030 }