PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.19
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.19
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 +51 -319 6.266.19 View file →
@@ -14,9 +14,8 @@
14 14
15 15 /**
16 16 * @param array $values
17 17 * @param bool|string[] $exclude
18 - *
19 18 * @return array
20 19 */
21 20 public static function validate( $values, $exclude = false ) {
22 21 FrmEntry::sanitize_entry_post( $values );
@@ -84,13 +83,8 @@
84 83 $_POST['item_meta'] = array();
85 84 }
86 85 }
87 86
88 - /**
89 - * @param array $values
90 - *
91 - * @return void
92 - */
93 87 private static function set_item_key( &$values ) {
94 88 if ( ! isset( $values['item_key'] ) || $values['item_key'] == '' ) {
95 89 global $wpdb;
96 90 $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' );
@@ -97,14 +91,8 @@
97 91 $_POST['item_key'] = $values['item_key'];
98 92 }
99 93 }
100 94
101 - /**
102 - * @param array $values
103 - * @param array|string $exclude
104 - *
105 - * @return array
106 - */
107 95 private static function get_fields_to_validate( $values, $exclude ) {
108 96 $where = apply_filters( 'frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) );
109 97
110 98 // Don't get subfields
@@ -127,16 +115,8 @@
127 115 */
128 116 return apply_filters( 'frm_fields_to_validate', $fields, compact( 'values', 'exclude', 'where' ) );
129 117 }
130 118
131 - /**
132 - * @param object $posted_field
133 - * @param array $errors
134 - * @param array $values
135 - * @param array $args
136 - *
137 - * @return void
138 - */
139 119 public static function validate_field( $posted_field, &$errors, $values, $args = array() ) {
140 120 $defaults = array(
141 121 'id' => $posted_field->id,
142 122 // The id of the repeat or embed form.
@@ -149,9 +129,9 @@
149 129 );
150 130 $args = wp_parse_args( $args, $defaults );
151 131
152 132 if ( empty( $args['parent_field_id'] ) ) {
153 - $value = $values['item_meta'][ $args['id'] ] ?? '';
133 + $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
154 134 } else {
155 135 // value is from a nested form
156 136 $value = $values;
157 137 }
@@ -161,9 +141,8 @@
161 141
162 142 self::maybe_clear_value_for_default_blank_setting( $posted_field, $value );
163 143
164 144 $should_trim = is_array( $value ) && count( $value ) == 1 && isset( $value[0] ) && $posted_field->type !== 'checkbox';
165 -
166 145 if ( $should_trim ) {
167 146 $value = reset( $value );
168 147 }
169 148
@@ -178,9 +157,8 @@
178 157 }
179 158
180 159 FrmEntriesHelper::set_posted_value( $posted_field, $value, $args );
181 160
182 - self::validate_options( $errors, $posted_field, $value, $args );
183 161 self::validate_field_types( $errors, $posted_field, $value, $args );
184 162
185 163 // Field might want to modify value before other parts of the system
186 164 // e.g. trim off excess values like in the case of fields with limit.
@@ -198,189 +176,8 @@
198 176 }
199 177 }
200 178
201 179 /**
202 - * @since 6.21
203 - *
204 - * @param array $errors
205 - * @param object $posted_field
206 - * @param array|string $value
207 - * @param array $args
208 - *
209 - * @return void
210 - */
211 - private static function validate_options( &$errors, $posted_field, $value, $args ) {
212 - if ( empty( $posted_field->options ) ) {
213 - return;
214 - }
215 -
216 - $option_is_valid = self::option_is_valid( $posted_field, $value, $posted_field->options );
217 -
218 - /**
219 - * @since 6.21
220 - *
221 - * @param bool $option_is_valid
222 - * @param array|string $value
223 - * @param object $field
224 - */
225 - $option_is_valid = (bool) apply_filters( 'frm_option_is_valid', $option_is_valid, $value, $posted_field );
226 -
227 - if ( ! $option_is_valid ) {
228 - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'invalid' );
229 - }
230 - }
231 -
232 - /**
233 - * Validate that value matches one of the options for the field.
234 - *
235 - * @since 6.21
236 - *
237 - * @param stdClass $field
238 - * @param array|string $value
239 - * @param array $options
240 - *
241 - * @return bool
242 - */
243 - private static function option_is_valid( $field, $value, $options ) {
244 - if ( '' === $value ) {
245 - return true;
246 - }
247 -
248 - $field_object = FrmFieldFactory::get_field_type( $field->type, $field );
249 -
250 - if ( ! $field_object->field_type_has_options_settings() ) {
251 - return true;
252 - }
253 -
254 - if ( in_array( $field->type, array( 'likert', 'ranking' ), true ) ) {
255 - // Ignore these field types automatically.
256 - return true;
257 - }
258 -
259 - if ( 'product' === $field->type && 'user_def' === FrmField::get_option( $field, 'data_type' ) ) {
260 - return true;
261 - }
262 -
263 - if ( ! empty( $field->field_options['post_field'] ) ) {
264 - return true;
265 - }
266 -
267 - $value = (array) $value;
268 -
269 - foreach ( $value as $current_value ) {
270 - $match = false;
271 -
272 - foreach ( $options as $key => $option ) {
273 - if ( strpos( $key, 'other_' ) === 0 ) {
274 - // Always return true if an other option is found.
275 - return true;
276 - }
277 -
278 - if ( is_array( $option ) ) {
279 - $separate_value = FrmField::get_option( $field, 'separate_value' );
280 - $option_value = $separate_value ? $option['value'] : $option['label'];
281 - } else {
282 - $option_value = $option;
283 - }
284 -
285 - $match = trim( $current_value ) === trim( $option_value );
286 -
287 - if ( $match ) {
288 - break;
289 - }
290 -
291 - $match = trim( $current_value ) === trim( do_shortcode( $option_value ) );
292 -
293 - if ( $match ) {
294 - break;
295 - }
296 -
297 - $match = self::is_filtered_match( $current_value, $option_value );
298 -
299 - if ( $match ) {
300 - break;
301 - }
302 -
303 - if ( is_numeric( $current_value ) ) {
304 - $match = (int) $current_value === (int) $option_value;
305 -
306 - if ( $match ) {
307 - break;
308 - }
309 - }
310 - }//end foreach
311 -
312 - if ( ! $match ) {
313 - return self::options_are_dynamic_based_on_hook( $field, $value );
314 - }
315 - }//end foreach
316 -
317 - return true;
318 - }
319 -
320 - /**
321 - * Make an extra check after passing $option_value through the_content filter.
322 - * This is to help catch cases where the option's formatting has been modified using
323 - * the_content filter.
324 - *
325 - * @since 6.22
326 - *
327 - * @param string $value
328 - * @param string $option_value
329 - *
330 - * @return bool
331 - */
332 - private static function is_filtered_match( $value, $option_value ) {
333 - // First remove the wpautop filter so it doesn't add extra tags to $option_value.
334 - $filter_priority = has_filter( 'the_content', 'wpautop' );
335 -
336 - if ( is_numeric( $filter_priority ) ) {
337 - remove_filter( 'the_content', 'wpautop', $filter_priority );
338 - }
339 -
340 - $filtered_option = apply_filters( 'the_content', $option_value );
341 -
342 - if ( is_numeric( $filter_priority ) ) {
343 - add_filter( 'the_content', 'wpautop', $filter_priority );
344 - }
345 - return trim( $value ) === trim( $filtered_option );
346 - }
347 -
348 - /**
349 - * Do not validate options if they have been modified with a hook.
350 - * This is to help avoid issues where the options could be based on a URL param for example.
351 - *
352 - * @since 6.21
353 - *
354 - * @param object $field_object The field object.
355 - * @param array|string $value The value to validate.
356 - *
357 - * @return bool
358 - */
359 - private static function options_are_dynamic_based_on_hook( $field_object, $value ) {
360 - $values = (array) $field_object;
361 - $values['value'] = $value;
362 - FrmFieldsHelper::prepare_new_front_field( $values, $field_object );
363 -
364 - $separate_value = FrmField::get_option( $field_object, 'separate_value' );
365 - $map_callback = function ( $option ) use ( $separate_value ) {
366 - if ( is_array( $option ) ) {
367 - $option_value = $separate_value ? $option['value'] : $option['label'];
368 - } else {
369 - $option_value = $option;
370 - }
371 -
372 - $option_value = do_shortcode( $option_value );
373 - return $option_value;
374 - };
375 -
376 - $values_options = array_map( $map_callback, $values['options'] );
377 - $field_object_options = array_map( $map_callback, $field_object->options );
378 -
379 - return $values_options !== $field_object_options;
380 - }
381 -
382 - /**
383 180 * Maybe add item_name to $_POST to save it in items table.
384 181 *
385 182 * @since 5.2.02
386 183 *
@@ -385,14 +182,11 @@
385 182 * @since 5.2.02
386 183 *
387 184 * @param array|string $value Field value.
388 185 * @param object $field Field object.
389 - *
390 - * @return void
391 186 */
392 187 private static function maybe_add_item_name( $value, $field ) {
393 188 $item_name = false;
394 -
395 189 if ( 'name' === $field->type ) {
396 190 $field_obj = FrmFieldFactory::get_field_object( $field );
397 191 $item_name = $field_obj->get_display_value( $value );
398 192 } elseif ( 'text' === $field->type ) {
@@ -409,14 +203,11 @@
409 203 * Set $value to an empty string if it matches its label
410 204 *
411 205 * @param object $field
412 206 * @param string $value
413 - *
414 - * @return void
415 207 */
416 208 private static function maybe_clear_value_for_default_blank_setting( $field, &$value ) {
417 209 $position = FrmField::get_option( $field, 'label' );
418 -
419 210 if ( ! $position ) {
420 211 $position = FrmStylesController::get_style_val( 'position', $field->form_id );
421 212 }
422 213
@@ -424,16 +215,8 @@
424 215 $value = '';
425 216 }
426 217 }
427 218
428 - /**
429 - * @param array $errors
430 - * @param object $posted_field
431 - * @param mixed $value
432 - * @param array $args
433 - *
434 - * @return void
435 - */
436 219 public static function validate_field_types( &$errors, $posted_field, $value, $args ) {
437 220 $field_obj = FrmFieldFactory::get_field_object( $posted_field );
438 221 $args['value'] = $value;
439 222 $args['errors'] = $errors;
@@ -438,22 +221,13 @@
438 221 $args['value'] = $value;
439 222 $args['errors'] = $errors;
440 223
441 224 $new_errors = $field_obj->validate( $args );
442 -
443 225 if ( ! empty( $new_errors ) ) {
444 226 $errors = array_merge( $errors, $new_errors );
445 227 }
446 228 }
447 229
448 - /**
449 - * @param array $errors
450 - * @param object $field
451 - * @param string $value
452 - * @param array $args
453 - *
454 - * @return void
455 - */
456 230 public static function validate_phone_field( &$errors, $field, $value, $args ) {
457 231 $format_value = FrmField::get_option( $field, 'format' );
458 232
459 233 if ( $field->type === 'phone' || ( $field->type === 'text' && $format_value && ! FrmCurrencyHelper::is_currency_format( $format_value ) ) ) {
@@ -464,13 +238,8 @@
464 238 }
465 239 }
466 240 }
467 241
468 - /**
469 - * @param object $field
470 - *
471 - * @return string
472 - */
473 242 public static function phone_format( $field ) {
474 243 if ( FrmField::is_option_empty( $field, 'format' ) ) {
475 244 $pattern = self::default_phone_format();
476 245 } else {
@@ -493,10 +262,8 @@
493 262 }
494 263
495 264 /**
496 265 * @since 3.01
497 - *
498 - * @return string
499 266 */
500 267 private static function default_phone_format() {
501 268 return '^((\+\d{1,3}(-|.| )?\(?\d\)?(-| |.)?\d{1,5})|(\(?\d{2,6}\)?))(-|.| )?(\d{3,4})(-|.| )?(\d{4})(( x| ext)\d{1,5}){0,1}$';
502 269 }
@@ -525,9 +292,8 @@
525 292
526 293 if ( strpos( $pattern, '\?' ) !== false ) {
527 294 $parts = explode( '\?', $pattern );
528 295 $pattern = '';
529 -
530 296 foreach ( $parts as $part ) {
531 297 if ( empty( $pattern ) ) {
532 298 $pattern .= $part;
533 299 } else {
@@ -534,9 +300,8 @@
534 300 $pattern .= '(' . $part . ')?';
535 301 }
536 302 }
537 303 }
538 -
539 304 $pattern = '^' . $pattern . '$';
540 305
541 306 return $pattern;
542 307 }
@@ -541,22 +306,15 @@
541 306 return $pattern;
542 307 }
543 308
544 309 /**
545 - * Check for spam.
310 + * Check for spam
546 311 *
547 312 * @param bool $exclude
548 313 * @param array $values
549 314 * @param array $errors By reference.
550 - *
551 - * @return void
552 315 */
553 316 public static function spam_check( $exclude, $values, &$errors ) {
554 - if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
555 - // Do not check spam on importing.
556 - return;
557 - }
558 -
559 317 if ( ! empty( $exclude ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
560 318 // only check spam if there are no other errors
561 319 return;
562 320 }
@@ -561,20 +319,14 @@
561 319 return;
562 320 }
563 321
564 322 $antispam_check = self::is_antispam_check( $values['form_id'] );
565 - $spam_msg = FrmAntiSpamController::get_default_spam_message();
566 -
567 323 if ( is_string( $antispam_check ) ) {
568 324 $errors['spam'] = $antispam_check;
569 325 } elseif ( self::is_honeypot_spam( $values ) || self::is_spam_bot() ) {
570 - $errors['spam'] = $spam_msg;
571 - } else {
572 - $is_spam = FrmAntiSpamController::is_spam( $values );
573 -
574 - if ( $is_spam ) {
575 - $errors['spam'] = $is_spam;
576 - }
326 + $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
327 + } elseif ( self::blacklist_check( $values ) ) {
328 + $errors['spam'] = __( 'Your entry appears to be blocked spam!', 'formidable' );
577 329 }
578 330
579 331 if ( isset( $errors['spam'] ) || self::form_is_in_progress( $values ) ) {
580 332 return;
@@ -590,9 +342,8 @@
590 342 *
591 343 * @since 5.0.13
592 344 *
593 345 * @param array $values The values.
594 - *
595 346 * @return bool
596 347 */
597 348 private static function form_is_in_progress( $values ) {
598 349 return FrmAppHelper::pro_is_installed() &&
@@ -611,9 +362,8 @@
611 362 }
612 363
613 364 /**
614 365 * @param array $values
615 - *
616 366 * @return bool
617 367 */
618 368 private static function is_honeypot_spam( $values ) {
619 369 $honeypot = new FrmHoneypot( $values['form_id'] );
@@ -630,9 +380,8 @@
630 380 }
631 381
632 382 /**
633 383 * @param array $values
634 - *
635 384 * @return bool
636 385 */
637 386 private static function is_akismet_spam( $values ) {
638 387 global $wpcom_api_key;
@@ -641,9 +390,8 @@
641 390 }
642 391
643 392 /**
644 393 * @param int $form_id
645 - *
646 394 * @return bool
647 395 */
648 396 private static function is_akismet_enabled_for_user( $form_id ) {
649 397 $form = FrmForm::getOne( $form_id );
@@ -650,24 +398,59 @@
650 398
651 399 return ( ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] !== 'logged' || ! is_user_logged_in() ) );
652 400 }
653 401
402 + public static function blacklist_check( $values ) {
403 + if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) {
404 + return false;
405 + }
406 +
407 + $mod_keys = trim( self::get_disallowed_words() );
408 + if ( empty( $mod_keys ) ) {
409 + return false;
410 + }
411 +
412 + $content = FrmEntriesHelper::entry_array_to_string( $values );
413 +
414 + self::prepare_values_for_spam_check( $values );
415 + $ip = FrmAppHelper::get_ip_address();
416 + $user_agent = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' );
417 + $user_info = self::get_spam_check_user_info( $values );
418 +
419 + return self::check_disallowed_words( $user_info['comment_author'], $user_info['comment_author_email'], $user_info['comment_author_url'], $content, $ip, $user_agent );
420 + }
421 +
654 422 /**
655 - * Checks spam using WordPress disallowed words and Frm denylist.
423 + * For WP 5.5 compatibility.
656 424 *
657 - * @param array $values Entry values.
425 + * @since 4.06.02
426 + */
427 + private static function check_disallowed_words( $author, $email, $url, $content, $ip, $user_agent ) {
428 + if ( function_exists( 'wp_check_comment_disallowed_list' ) ) {
429 + return wp_check_comment_disallowed_list( $author, $email, $url, $content, $ip, $user_agent );
430 + }
431 + // phpcs:ignore WordPress.WP.DeprecatedFunctions.wp_blacklist_checkFound
432 + return wp_blacklist_check( $author, $email, $url, $content, $ip, $user_agent );
433 + }
434 +
435 + /**
436 + * For WP 5.5 compatibility.
658 437 *
659 - * @return bool
438 + * @since 4.06.02
660 439 */
661 - public static function blacklist_check( $values ) {
662 - return FrmAntiSpamController::contains_wp_disallowed_words( $values ) || FrmAntiSpamController::is_denylist_spam( $values );
440 + private static function get_disallowed_words() {
441 + $keys = get_option( 'disallowed_keys' );
442 + if ( false === $keys ) {
443 + // Fallback for WP < 5.5.
444 + // phpcs:ignore WordPress.WP.DeprecatedParameterValues.Found
445 + $keys = get_option( 'blacklist_keys' );
446 + }
447 + return $keys;
663 448 }
664 449
665 450 /**
666 451 * Check entries for Akismet spam
667 452 *
668 - * @param array $values Entry values.
669 - *
670 453 * @return bool true if is spam
671 454 */
672 455 public static function akismet( $values ) {
673 456 if ( empty( $values['item_meta'] ) ) {
@@ -695,13 +478,8 @@
695 478 }
696 479
697 480 /**
698 481 * @since 2.0
699 - *
700 - * @param array $datas The array of values being sent to Akismet.
701 - * @param array $values Entry values.
702 - *
703 - * @return void
704 482 */
705 483 private static function parse_akismet_array( &$datas, $values ) {
706 484 self::add_site_info_to_akismet( $datas );
707 485 self::add_server_values_to_akismet( $datas );
@@ -712,13 +490,8 @@
712 490 self::add_user_info_to_akismet( $datas, $values );
713 491 self::add_comment_content_to_akismet( $datas, $values );
714 492 }
715 493
716 - /**
717 - * @param array $datas
718 - *
719 - * @return void
720 - */
721 494 private static function add_site_info_to_akismet( &$datas ) {
722 495 $datas['blog'] = FrmAppHelper::site_url();
723 496 $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() );
724 497 $datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' );
@@ -730,14 +503,8 @@
730 503 $datas['is_test'] = 'true';
731 504 }
732 505 }
733 506
734 - /**
735 - * @param array $datas
736 - * @param array $values
737 - *
738 - * @return void
739 - */
740 507 private static function add_user_info_to_akismet( &$datas, $values ) {
741 508 $user_info = self::get_spam_check_user_info( $values );
742 509 $datas = $datas + $user_info;
743 510
@@ -749,15 +516,13 @@
749 516 /**
750 517 * Gets user info for Akismet spam check.
751 518 *
752 519 * @since 5.0.13 Separate code for guest. Handle value of embedded|repeater.
753 - * @since 6.21 This changed from private to public.
754 520 *
755 521 * @param array $values Entry values after running through {@see FrmEntryValidate::prepare_values_for_spam_check()}.
756 - *
757 522 * @return array
758 523 */
759 - public static function get_spam_check_user_info( $values ) {
524 + private static function get_spam_check_user_info( $values ) {
760 525 if ( ! is_user_logged_in() ) {
761 526 return self::get_spam_check_user_info_for_guest( $values );
762 527 }
763 528
@@ -777,9 +542,8 @@
777 542 *
778 543 * @since 5.0.13
779 544 *
780 545 * @param array $values Entry values after flattened.
781 - *
782 546 * @return array
783 547 */
784 548 private static function get_spam_check_user_info_for_guest( $values ) {
785 549 $datas = array(
@@ -811,10 +575,8 @@
811 575 *
812 576 * @param array $datas Guest data.
813 577 * @param array $values The values.
814 578 * @param int|null $custom_index Custom index (or field ID).
815 - *
816 - * @return void
817 579 */
818 580 private static function recursive_add_akismet_guest_info( &$datas, $values, $custom_index = null ) {
819 581 foreach ( $values as $index => $value ) {
820 582 if ( ! $datas['missing_keys'] ) {
@@ -827,12 +589,10 @@
827 589 continue;
828 590 }
829 591
830 592 $field_id = ! is_null( $custom_index ) ? $custom_index : $index;
831 -
832 593 foreach ( $datas['missing_keys'] as $key_index => $key ) {
833 594 $found = self::is_akismet_guest_info_value( $key, $value, $field_id, $datas['name_field_ids'], $values );
834 -
835 595 if ( $found ) {
836 596 $datas[ $key ] = $value;
837 597 $datas['frm_duplicated'][] = $field_id;
838 598 unset( $datas['missing_keys'][ $key_index ] );
@@ -870,9 +630,8 @@
870 630 if ( $name_field_ids && in_array( $field_id, $name_field_ids, true ) ) {
871 631 // If there is name field in the form, we should always use it as author name.
872 632 return true;
873 633 }
874 -
875 634 $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
876 635 $fields = self::get_name_text_fields( $form_id );
877 636
878 637 foreach ( $fields as $index => $field ) {
@@ -878,14 +637,12 @@
878 637 foreach ( $fields as $index => $field ) {
879 638 if ( 'Name' !== $field->name ) {
880 639 continue;
881 640 }
882 -
883 641 if ( isset( $fields[ $index + 1 ] ) && 'Last' === $fields[ $index + 1 ]->name ) {
884 642 if ( empty( $values[ absint( $fields[ $index + 1 ]->id ) ] ) ) {
885 643 continue;
886 644 }
887 -
888 645 $value .= ' ' . $values[ $fields[ $index + 1 ]->id ];
889 646 return true;
890 647 }
891 648 }
@@ -899,18 +656,15 @@
899 656 *
900 657 * @since 6.17
901 658 *
902 659 * @param int $form_id
903 - *
904 660 * @return array
905 661 */
906 662 private static function get_name_text_fields( $form_id ) {
907 663 $name_text_fields_is_initialized = is_array( self::$name_text_fields );
908 -
909 664 if ( $name_text_fields_is_initialized && isset( self::$name_text_fields[ $form_id ] ) ) {
910 665 return self::$name_text_fields[ $form_id ];
911 666 }
912 -
913 667 if ( ! $name_text_fields_is_initialized ) {
914 668 self::$name_text_fields = array();
915 669 }
916 670 self::$name_text_fields[ $form_id ] = FrmDb::get_results(
@@ -926,13 +680,8 @@
926 680
927 681 return self::$name_text_fields[ $form_id ];
928 682 }
929 683
930 - /**
931 - * @param array $datas
932 - *
933 - * @return void
934 - */
935 684 private static function add_server_values_to_akismet( &$datas ) {
936 685 foreach ( $_SERVER as $key => $value ) {
937 686 $include_value = is_string( $value ) && ! preg_match( '/^HTTP_COOKIE/', $key ) && preg_match( '/^(HTTP_|REMOTE_ADDR|REQUEST_URI|DOCUMENT_URI)/', $key );
938 687
@@ -950,10 +699,8 @@
950 699 * @since 5.0.09
951 700 *
952 701 * @param array $datas The array of values being sent to Akismet.
953 702 * @param array $values Entry values.
954 - *
955 - * @return void
956 703 */
957 704 private static function add_comment_content_to_akismet( &$datas, $values ) {
958 705 if ( isset( $datas['frm_duplicated'] ) ) {
959 706 foreach ( $datas['frm_duplicated'] as $index ) {
@@ -974,14 +721,11 @@
974 721 *
975 722 * @since 5.0.09
976 723 *
977 724 * @param array $values Entry values.
978 - *
979 - * @return void
980 725 */
981 726 private static function skip_adding_values_to_akismet( &$values ) {
982 727 $skipped_fields = self::get_akismet_skipped_field_ids( $values );
983 -
984 728 foreach ( $skipped_fields as $skipped_field ) {
985 729 if ( ! isset( $values['item_meta'][ $skipped_field->id ] ) ) {
986 730 continue;
987 731 }
@@ -987,9 +731,8 @@
987 731 }
988 732
989 733 if ( self::should_really_skip_field( $skipped_field, $values ) ) {
990 734 unset( $values['item_meta'][ $skipped_field->id ] );
991 -
992 735 if ( isset( $values['item_meta']['other'][ $skipped_field->id ] ) ) {
993 736 unset( $values['item_meta']['other'][ $skipped_field->id ] );
994 737 }
995 738 }
@@ -1002,9 +745,8 @@
1002 745 * @since 5.02.04
1003 746 *
1004 747 * @param object $field_data Object contains `id` and `options`.
1005 748 * @param array $values Entry values.
1006 - *
1007 749 * @return bool
1008 750 */
1009 751 private static function should_really_skip_field( $field_data, $values ) {
1010 752 if ( empty( $field_data->options ) ) {
@@ -1012,9 +754,8 @@
1012 754 return true;
1013 755 }
1014 756
1015 757 FrmAppHelper::unserialize_or_decode( $field_data->options );
1016 -
1017 758 if ( ! $field_data->options ) {
1018 759 // Check if an error happens when unserializing, or empty options.
1019 760 return true;
1020 761 }
@@ -1033,10 +774,9 @@
1033 774 }
1034 775
1035 776 // Check if submitted value is same as one of field option.
1036 777 foreach ( $field_data->options as $option ) {
1037 - $option_value = ! is_array( $option ) ? $option : ( $option['value'] ?? '' );
1038 -
778 + $option_value = ! is_array( $option ) ? $option : ( isset( $option['value'] ) ? $option['value'] : '' );
1039 779 if ( $values['item_meta']['other'][ $field_data->id ] === $option_value ) {
1040 780 return true;
1041 781 }
1042 782 }
@@ -1051,9 +791,8 @@
1051 791 * @since 5.0.13 Move out get_all_form_ids_and_flatten_meta() call and get `form_ids` from `$values`.
1052 792 * @since 5.2.04 This method returns array of object contains `id` and `options` instead of array of `id` only.
1053 793 *
1054 794 * @param array $values Entry values after running through {@see FrmEntryValidate::prepare_values_for_spam_check()}.
1055 - *
1056 795 * @return array
1057 796 */
1058 797 private static function get_akismet_skipped_field_ids( $values ) {
1059 798 if ( empty( $values['form_ids'] ) ) {
@@ -1076,15 +815,12 @@
1076 815 /**
1077 816 * Prepares values array for spam check.
1078 817 *
1079 818 * @since 5.0.13
1080 - * @since 6.21 This changed from private to public.
1081 819 *
1082 820 * @param array $values Entry values.
1083 - *
1084 - * @return void
1085 821 */
1086 - public static function prepare_values_for_spam_check( &$values ) {
822 + private static function prepare_values_for_spam_check( &$values ) {
1087 823 $form_ids = self::get_all_form_ids_and_flatten_meta( $values );
1088 824 $values['form_ids'] = $form_ids;
1089 825 }
1090 826
@@ -1095,9 +831,8 @@
1095 831 * @since 5.0.09
1096 832 * @since 5.0.13 Convert name field value to string.
1097 833 *
1098 834 * @param array $values Entry values.
1099 - *
1100 835 * @return array Form IDs.
1101 836 */
1102 837 private static function get_all_form_ids_and_flatten_meta( &$values ) {
1103 838 $values['name_field_ids'] = array();
@@ -1103,9 +838,8 @@
1103 838 $values['name_field_ids'] = array();
1104 839
1105 840 // Blacklist check for File field in the old version doesn't contain `form_id`.
1106 841 $form_ids = isset( $values['form_id'] ) ? array( absint( $values['form_id'] ) ) : array();
1107 -
1108 842 foreach ( $values['item_meta'] as $field_id => $value ) {
1109 843 if ( ! is_numeric( $field_id ) ) {
1110 844 // Maybe `other`.
1111 845 continue;
@@ -1144,11 +878,9 @@
1144 878
1145 879 $values['name_field_ids'][] = $subsubindex;
1146 880 }
1147 881
1148 - if ( is_array( $values['item_meta'][ $subsubindex ] ) ) {
1149 - $values['item_meta'][ $subsubindex ][] = $subsubvalue;
1150 - }
882 + $values['item_meta'][ $subsubindex ][] = $subsubvalue;
1151 883 }
1152 884 }//end foreach
1153 885
1154 886 unset( $values['item_meta'][ $field_id ] );