PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.16.1.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.16.1.2
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/helpers/FrmEntriesHelper.php +18 -139 6.266.16.1.2 View file →
@@ -8,9 +8,8 @@
8 8 /**
9 9 * "Submitted" entry status.
10 10 *
11 11 * @since 6.4.2
12 - *
13 12 * @var int
14 13 */
15 14 const SUBMITTED_ENTRY_STATUS = 0;
16 15
@@ -17,21 +16,12 @@
17 16 /**
18 17 * "Draft" entry status.
19 18 *
20 19 * @since 6.4.2
21 - *
22 20 * @var int
23 21 */
24 22 const DRAFT_ENTRY_STATUS = 1;
25 23
26 - /**
27 - * @param mixed $fields
28 - * @param object|string $form
29 - * @param bool $reset
30 - * @param array $args
31 - *
32 - * @return array
33 - */
34 24 public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
35 25 remove_action( 'media_buttons', 'FrmFormsController::insert_form_button' );
36 26
37 27 $values = array(
@@ -40,9 +30,8 @@
40 30 'item_key' => '',
41 31 );
42 32
43 33 $values['fields'] = array();
44 -
45 34 if ( empty( $fields ) ) {
46 35 return apply_filters( 'frm_setup_new_entry', $values );
47 36 }
48 37
@@ -53,11 +42,11 @@
53 42
54 43 $field_array = FrmAppHelper::start_field_array( $field );
55 44 $field_array['value'] = $new_value;
56 45 $field_array['type'] = apply_filters( 'frm_field_type', $field->type, $field, $new_value );
57 - $field_array['parent_form_id'] = $args['parent_form_id'] ?? $field->form_id;
46 + $field_array['parent_form_id'] = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
58 47 $field_array['reset_value'] = $reset;
59 - $field_array['in_embed_form'] = $args['in_embed_form'] ?? '0';
48 + $field_array['in_embed_form'] = isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0';
60 49 $field_array['original_default'] = $original_default;
61 50
62 51 FrmFieldsHelper::prepare_new_front_field( $field_array, $field, $args );
63 52
@@ -74,9 +63,8 @@
74 63 }
75 64 }//end foreach
76 65
77 66 FrmAppHelper::unserialize_or_decode( $form->options );
78 -
79 67 if ( is_array( $form->options ) ) {
80 68 $values = array_merge( $values, $form->options );
81 69 }
82 70
@@ -91,10 +79,8 @@
91 79 /**
92 80 * @since 2.05
93 81 *
94 82 * @param object $field
95 - *
96 - * @return void
97 83 */
98 84 private static function prepare_field_default_value( &$field ) {
99 85 // If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array.
100 86 $return_array = FrmField::is_field_with_multiple_values( $field );
@@ -147,12 +133,10 @@
147 133 * @return bool $value_is_posted
148 134 */
149 135 public static function value_is_posted( $field, $args ) {
150 136 $value_is_posted = false;
151 -
152 137 if ( $_POST ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
153 138 $repeating = isset( $args['repeating'] ) && $args['repeating'];
154 -
155 139 if ( $repeating ) {
156 140 if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
157 141 $value_is_posted = true;
158 142 }
@@ -163,14 +147,8 @@
163 147
164 148 return $value_is_posted;
165 149 }
166 150
167 - /**
168 - * @param array $values
169 - * @param object $record
170 - *
171 - * @return array
172 - */
173 151 public static function setup_edit_vars( $values, $record ) {
174 152 remove_action( 'media_buttons', 'FrmFormsController::insert_form_button' );
175 153
176 154 $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
@@ -179,14 +157,8 @@
179 157
180 158 return apply_filters( 'frm_setup_edit_entry_vars', $values, $record );
181 159 }
182 160
183 - /**
184 - * @param string $message
185 - * @param array $atts
186 - *
187 - * @return string
188 - */
189 161 public static function replace_default_message( $message, $atts ) {
190 162 if ( strpos( $message, '[default-message' ) === false &&
191 163 strpos( $message, '[default_message' ) === false &&
192 164 ! empty( $message ) ) {
@@ -200,9 +172,8 @@
200 172 preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
201 173
202 174 foreach ( $shortcodes[0] as $short_key => $tag ) {
203 175 $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
204 -
205 176 if ( ! empty( $add_atts ) ) {
206 177 $this_atts = array_merge( $atts, $add_atts );
207 178 } else {
208 179 $this_atts = $atts;
@@ -220,18 +191,16 @@
220 191 /**
221 192 * @param stdClass $entry
222 193 * @param stdClass $field
223 194 * @param array $atts
224 - *
225 195 * @return string
226 196 */
227 197 public static function prepare_display_value( $entry, $field, $atts ) {
228 - $field_value = $entry->metas[ $field->id ] ?? false;
198 + $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
229 199
230 200 if ( FrmAppHelper::pro_is_installed() ) {
231 201 $empty = empty( $field_value );
232 202 FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
233 -
234 203 if ( $empty && ! empty( $field_value ) ) {
235 204 // We've got an entry id, so switch it to a value.
236 205 $atts['force_id'] = true;
237 206 }
@@ -243,9 +212,8 @@
243 212
244 213 if ( ! FrmAppHelper::pro_is_installed() ) {
245 214 return '';
246 215 }
247 -
248 216 if ( is_callable( 'FrmProEntriesHelper::prepare_child_display_value' ) ) {
249 217 return FrmProEntriesHelper::prepare_child_display_value( $entry, $field, $atts );
250 218 }
251 219
@@ -254,9 +222,9 @@
254 222 // This is a repeating section.
255 223 $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ), '', '', true );
256 224 } else {
257 225 // Get all values for this field.
258 - $child_values = $entry->metas[ $atts['embedded_field_id'] ] ?? false;
226 + $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
259 227
260 228 if ( $child_values ) {
261 229 $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
262 230 }
@@ -283,13 +251,11 @@
283 251 unset( $child_entry );
284 252 }
285 253
286 254 $sep = ', ';
287 -
288 255 if ( strpos( implode( ' ', $field_value ), '<img' ) !== false ) {
289 256 $sep = '<br/>';
290 257 }
291 -
292 258 $val = implode( $sep, $field_value );
293 259
294 260 return FrmAppHelper::kses( $val, 'all' );
295 261 }
@@ -341,9 +307,9 @@
341 307
342 308 if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] === 'tag' ) ) {
343 309 $atts['pre_truncate'] = $atts['truncate'];
344 310 $atts['truncate'] = true;
345 - $atts['exclude_cat'] = $field->field_options['exclude_cat'] ?? 0;
311 + $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0;
346 312
347 313 $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts );
348 314 $atts['truncate'] = $atts['pre_truncate'];
349 315 }
@@ -372,21 +338,13 @@
372 338
373 339 return apply_filters( 'frm_display_value', $value, $field, $atts );
374 340 }
375 341
376 - /**
377 - * @param object $field
378 - * @param mixed $value
379 - * @param array $args
380 - *
381 - * @return void
382 - */
383 342 public static function set_posted_value( $field, $value, $args ) {
384 343 // If validating a field with "other" opt, set back to prev value now.
385 344 if ( ! empty( $args['other'] ) ) {
386 345 $value = $args['temp_value'];
387 346 }
388 -
389 347 if ( empty( $args['parent_field_id'] ) ) {
390 348 $_POST['item_meta'][ $field->id ] = $value;
391 349 } else {
392 350 self::set_parent_field_posted_value( $field, $value, $args );
@@ -396,14 +354,8 @@
396 354 /**
397 355 * Init arrays if necessary, else we get fatal error.
398 356 *
399 357 * @since 4.01
400 - *
401 - * @param object $field Field object.
402 - * @param mixed $value Value to set.
403 - * @param array $args Additional arguments.
404 - *
405 - * @return void
406 358 */
407 359 private static function set_parent_field_posted_value( $field, $value, $args ) {
408 360 if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ] ) && is_array( $_POST['item_meta'][ $args['parent_field_id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
409 361 if ( ! isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) || ! is_array( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
@@ -417,15 +369,8 @@
417 369
418 370 $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; // phpcs:ignore WordPress.Security.NonceVerification.Missing
419 371 }
420 372
421 - /**
422 - * @param array|int|object $field
423 - * @param mixed $value
424 - * @param array $args
425 - *
426 - * @return void
427 - */
428 373 public static function get_posted_value( $field, &$value, $args ) {
429 374 if ( is_array( $field ) ) {
430 375 $field_id = $field['id'];
431 376 $field_obj = FrmFieldFactory::get_field_object( $field['id'] );
@@ -430,14 +375,9 @@
430 375 $field_id = $field['id'];
431 376 $field_obj = FrmFieldFactory::get_field_object( $field['id'] );
432 377 } elseif ( is_object( $field ) ) {
433 378 $field_id = $field->id;
434 -
435 - if ( 'hidden' === $field->type && ! empty( $field->field_options['original_type'] ) ) {
436 - $field_obj = FrmFieldFactory::get_field_type( $field->field_options['original_type'], $field );
437 - } else {
438 - $field_obj = FrmFieldFactory::get_field_object( $field );
439 - }
379 + $field_obj = FrmFieldFactory::get_field_object( $field );
440 380 } elseif ( is_numeric( $field ) ) {
441 381 $field_id = $field;
442 382 $field_obj = FrmFieldFactory::get_field_object( $field );
443 383 } else {
@@ -452,13 +392,8 @@
452 392 }
453 393
454 394 /**
455 395 * @since 4.02.04
456 - *
457 - * @param int|string $field_id Field ID.
458 - * @param array $args Additional arguments.
459 - *
460 - * @return mixed
461 396 */
462 397 private static function get_posted_meta( $field_id, $args ) {
463 398 if ( empty( $args['parent_field_id'] ) ) {
464 399 // Sanitizing is done next.
@@ -473,17 +408,14 @@
473 408 * Check if field has an "Other" option and if any other values are posted
474 409 *
475 410 * @since 2.0
476 411 *
477 - * @param object $field Field object.
478 - * @param array|string $value Field value, passed by reference.
479 - * @param array $args Arguments array, passed by reference.
480 - *
481 - * @return void
412 + * @param object $field
413 + * @param array|string $value
414 + * @param array $args
482 415 */
483 416 public static function maybe_set_other_validation( $field, &$value, &$args ) {
484 417 $args['other'] = false;
485 -
486 418 if ( ! $value || ! FrmAppHelper::pro_is_installed() ) {
487 419 return;
488 420 }
489 421
@@ -517,13 +449,11 @@
517 449 * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
518 450 *
519 451 * @since 2.0
520 452 *
521 - * @param object $field Field object.
522 - * @param array|string $value Field value, passed by reference.
523 - * @param array $args Arguments array, passed by reference.
524 - *
525 - * @return void
453 + * @param object $field
454 + * @param array|string $value
455 + * @param array $args
526 456 */
527 457 public static function set_other_repeating_vals( $field, &$value, &$args ) {
528 458 if ( ! $args['parent_field_id'] ) {
529 459 return;
@@ -555,10 +485,8 @@
555 485 * @param array|string $value
556 486 * @param array|string $other_vals (usually of posted values).
557 487 * @param object $field
558 488 * @param array $args
559 - *
560 - * @return void
561 489 */
562 490 public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
563 491 // Checkboxes and multi-select dropdowns.
564 492 if ( is_array( $value ) && $field->type === 'checkbox' ) {
@@ -594,9 +522,8 @@
594 522 }
595 523
596 524 $args['temp_value'] = $value;
597 525 $value[ $other_key ] = reset( $other_vals );
598 -
599 526 if ( FrmAppHelper::is_empty_value( $value[ $other_key ] ) ) {
600 527 unset( $value[ $other_key ] );
601 528 }
602 529 }
@@ -609,16 +536,14 @@
609 536 /**
610 537 * Add submitted values to a string for spam checking.
611 538 *
612 539 * @param array $values
613 - *
614 540 * @return string
615 541 */
616 542 public static function entry_array_to_string( $values ) {
617 543 $content = '';
618 -
619 544 foreach ( $values['item_meta'] as $val ) {
620 - if ( $content !== '' ) {
545 + if ( $content != '' ) {
621 546 $content .= "\n\n";
622 547 }
623 548
624 549 if ( is_array( $val ) ) {
@@ -680,9 +605,9 @@
680 605 }
681 606
682 607 // finally get the correct version number
683 608 $known = array( 'Version', $ub, 'other' );
684 - $pattern = '#(?<browser>' . implode( '|', $known ) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
609 + $pattern = '#(?<browser>' . join( '|', $known ) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
685 610 // Get the matching numbers.
686 611 preg_match_all( $pattern, $u_agent, $matches );
687 612
688 613 // see how many we have
@@ -702,9 +627,9 @@
702 627 $version = '';
703 628 }
704 629
705 630 // check if we have a number
706 - if ( $version === '' ) {
631 + if ( $version == '' ) {
707 632 $version = '?';
708 633 }
709 634
710 635 return $bname . ' ' . $version . ' / ' . $platform;
@@ -711,15 +636,11 @@
711 636 }
712 637
713 638 /**
714 639 * @since 3.0
715 - *
716 - * @param array $atts Action dropdown attributes.
717 - *
718 - * @return void
719 640 */
720 641 public static function actions_dropdown( $atts ) {
721 - $id = $atts['id'] ?? FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
642 + $id = isset( $atts['id'] ) ? $atts['id'] : FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
722 643 $links = self::get_action_links( $id, $atts['entry'] );
723 644
724 645 foreach ( $links as $link ) {
725 646 ?>
@@ -730,13 +651,11 @@
730 651 foreach ( $link['data'] as $data => $value ) {
731 652 echo 'data-' . esc_attr( $data ) . '="' . esc_attr( $value ) . '" ';
732 653 }
733 654 }
734 -
735 655 if ( isset( $link['class'] ) ) {
736 656 echo 'class="' . esc_attr( $link['class'] ) . '" ';
737 657 }
738 -
739 658 if ( isset( $link['id'] ) ) {
740 659 echo 'id="' . esc_attr( $link['id'] ) . '" ';
741 660 }
742 661 ?>
@@ -750,13 +669,8 @@
750 669 }
751 670
752 671 /**
753 672 * @since 3.0
754 - *
755 - * @param int $id Entry ID.
756 - * @param array|object $entry Entry object.
757 - *
758 - * @return array
759 673 */
760 674 private static function get_action_links( $id, $entry ) {
761 675 $page = FrmAppHelper::get_param( 'frm_action' );
762 676 $actions = array();
@@ -774,10 +688,9 @@
774 688 'url' => wp_nonce_url( admin_url( 'admin.php?page=formidable-entries&frm_action=destroy&id=' . $id . '&form=' . $entry->form_id ) ),
775 689 'label' => __( 'Delete Entry', 'formidable' ),
776 690 'icon' => 'frm_icon_font frm_delete_icon',
777 691 'data' => array(
778 - 'frmverify' => __( 'Permanently delete this entry?', 'formidable' ),
779 - 'frmverify-btn' => 'frm-button-red',
692 + 'frmverify' => __( 'Delete this form entry?', 'formidable' ),
780 693 ),
781 694 );
782 695 }
783 696
@@ -803,9 +716,9 @@
803 716 ),
804 717 'icon' => 'frm_icon_font frm_email_icon',
805 718 );
806 719
807 - if ( ! function_exists( 'frm_pdfs_autoloader' ) ) {
720 + if ( ! function_exists( 'frm_pdfs_autoloader' ) && FrmAppHelper::show_new_feature( 'pdfs' ) ) {
808 721 $actions['frm_download_pdf'] = array(
809 722 'url' => '#',
810 723 'label' => __( 'Download as PDF', 'formidable' ),
811 724 'class' => 'frm_noallow',
@@ -832,9 +745,8 @@
832 745 /**
833 746 * Gets data attributes for PDFs addon upgrade link.
834 747 *
835 748 * @param string $medium The source of the upgrade link used for analytics data.
836 - *
837 749 * @return array
838 750 */
839 751 private static function get_pdfs_upgrade_link_data( $medium = 'pdfs' ) {
840 752 $data = array(
@@ -844,9 +756,8 @@
844 756 'medium' => $medium,
845 757 );
846 758
847 759 $upgrading = FrmAddonsController::install_link( 'pdfs' );
848 -
849 760 if ( isset( $upgrading['url'] ) ) {
850 761 $data['oneclick'] = json_encode( $upgrading );
851 762 } else {
852 763 $data['requires'] = FrmAddonsController::get_addon_required_plan( 28136428 );
@@ -858,9 +769,8 @@
858 769 /**
859 770 * @since 5.0.15
860 771 *
861 772 * @param int|string $entry_id
862 - *
863 773 * @return void
864 774 */
865 775 public static function maybe_render_captcha_score( $entry_id ) {
866 776 $query = array(
@@ -867,9 +777,8 @@
867 777 'item_id' => (int) $entry_id,
868 778 'field_id' => 0,
869 779 );
870 780 $metas_without_a_field = (array) FrmEntryMeta::getAll( $query, ' ORDER BY it.created_at DESC', '', true );
871 -
872 781 foreach ( $metas_without_a_field as $meta ) {
873 782 if ( ! empty( $meta->meta_value['captcha_score'] ) ) {
874 783 echo '<div class="misc-pub-section">';
875 784 FrmAppHelper::icon_by_class( 'frm_icon_font frm_shield_check_icon', array( 'aria-hidden' => 'true' ) );
@@ -955,36 +864,6 @@
955 864
956 865 $existing_entry_statuses = array_replace( $default_entry_statuses, $extended_entry_status );
957 866
958 867 return $existing_entry_statuses;
959 - }
960 -
961 - /**
962 - * @since 6.17
963 - *
964 - * @return int
965 - */
966 - public static function get_visible_unread_inbox_count() {
967 - $menu_name = FrmAppHelper::get_menu_name();
968 -
969 - if ( ! in_array( $menu_name, array( 'Formidable', 'Forms' ), true ) ) {
970 - return 0;
971 - }
972 -
973 - $inbox = new FrmInbox();
974 - $inbox_count = count( $inbox->unread() );
975 -
976 - if ( ! $inbox_count ) {
977 - return 0;
978 - }
979 -
980 - if ( is_callable( 'FrmProSettingsController::inbox_badge' ) ) {
981 - $inbox_count = FrmProSettingsController::inbox_badge( $inbox_count );
982 -
983 - if ( ! $inbox_count ) {
984 - return 0;
985 - }
986 - }
987 -
988 - return $inbox_count;
989 868 }
990 869 }