PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 4.07.01
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v4.07.01
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 +38 -70 6.3.24.07.01 View file →
@@ -5,10 +5,8 @@
5 5
6 6 class FrmEntriesHelper {
7 7
8 8 public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9 - remove_action( 'media_buttons', 'FrmFormsController::insert_form_button' );
10 -
11 9 $values = array(
12 10 'name' => '',
13 11 'description' => '',
14 12 'item_key' => '',
@@ -33,12 +31,8 @@
33 31 $field_array['original_default'] = $original_default;
34 32
35 33 FrmFieldsHelper::prepare_new_front_field( $field_array, $field, $args );
36 34
37 - if ( ! is_array( $field->field_options ) ) {
38 - $field->field_options = array();
39 - }
40 -
41 35 $field_array = array_merge( $field->field_options, $field_array );
42 36
43 37 $values['fields'][] = $field_array;
44 38
@@ -51,11 +45,13 @@
51 45 if ( is_array( $form->options ) ) {
52 46 $values = array_merge( $values, $form->options );
53 47 }
54 48
55 - $form_defaults = FrmFormsHelper::get_default_opts();
56 - $form_defaults['custom_style'] = FrmAppHelper::custom_style_value( array() );
49 + $form_defaults = FrmFormsHelper::get_default_opts();
50 + $frm_settings = FrmAppHelper::get_settings();
57 51
52 + $form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' );
53 +
58 54 $values = array_merge( $form_defaults, $values );
59 55
60 56 return apply_filters( 'frm_setup_new_entry', $values );
61 57 }
@@ -117,15 +113,15 @@
117 113 * @return boolean $value_is_posted
118 114 */
119 115 public static function value_is_posted( $field, $args ) {
120 116 $value_is_posted = false;
121 - if ( $_POST ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
117 + if ( $_POST ) {
122 118 $repeating = isset( $args['repeating'] ) && $args['repeating'];
123 119 if ( $repeating ) {
124 - if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
120 + if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) {
125 121 $value_is_posted = true;
126 122 }
127 - } elseif ( isset( $_POST['item_meta'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
123 + } elseif ( isset( $_POST['item_meta'][ $field->id ] ) ) {
128 124 $value_is_posted = true;
129 125 }
130 126 }
131 127
@@ -132,10 +128,8 @@
132 128 return $value_is_posted;
133 129 }
134 130
135 131 public static function setup_edit_vars( $values, $record ) {
136 - remove_action( 'media_buttons', 'FrmFormsController::insert_form_button' );
137 -
138 132 $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
139 133 $values['form_id'] = $record->form_id;
140 134 $values['is_draft'] = $record->is_draft;
141 135
@@ -171,14 +165,8 @@
171 165
172 166 return $message;
173 167 }
174 168
175 - /**
176 - * @param stdClass $entry
177 - * @param stdClass $field
178 - * @param array $atts
179 - * @return string
180 - */
181 169 public static function prepare_display_value( $entry, $field, $atts ) {
182 170 $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
183 171
184 172 if ( FrmAppHelper::pro_is_installed() ) {
@@ -193,16 +181,14 @@
193 181 if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) {
194 182 return self::display_value( $field_value, $field, $atts );
195 183 }
196 184
197 - if ( ! FrmAppHelper::pro_is_installed() ) {
198 - return '';
199 - }
185 + // This is an embeded form.
186 + $val = '';
200 187
201 - // This is an embeded form.
202 188 if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) {
203 189 // This is a repeating section.
204 - $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ), '', '', true );
190 + $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
205 191 } else {
206 192 // Get all values for this field.
207 193 $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
208 194
@@ -212,10 +198,10 @@
212 198 }
213 199
214 200 $field_value = array();
215 201
216 - if ( empty( $child_entries ) ) {
217 - return '';
202 + if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
203 + return $val;
218 204 }
219 205
220 206 foreach ( $child_entries as $child_entry ) {
221 207 $atts['item_id'] = $child_entry->id;
@@ -223,9 +209,9 @@
223 209
224 210 // Fet the value for this field -- check for post values as well.
225 211 $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field );
226 212
227 - if ( $entry_val || '0' === $entry_val ) {
213 + if ( $entry_val ) {
228 214 // foreach entry get display_value.
229 215 $field_value[] = self::display_value( $entry_val, $field, $atts );
230 216 }
231 217
@@ -295,9 +281,9 @@
295 281 return $value;
296 282 }
297 283
298 284 $unfiltered_value = $value;
299 - FrmFieldsHelper::prepare_field_value( $unfiltered_value, $field->type );
285 + FrmAppHelper::unserialize_or_decode( $unfiltered_value );
300 286
301 287 $value = apply_filters( 'frm_display_value_custom', $unfiltered_value, $field, $atts );
302 288 $value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) );
303 289
@@ -333,19 +319,22 @@
333 319 *
334 320 * @since 4.01
335 321 */
336 322 private static function set_parent_field_posted_value( $field, $value, $args ) {
337 - if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ] ) && is_array( $_POST['item_meta'][ $args['parent_field_id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
338 - 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
339 - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array(); // phpcs:ignore WordPress.Security.NonceVerification.Missing
323 + if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ] ) &&
324 + is_array( $_POST['item_meta'][ $args['parent_field_id'] ] ) ) {
325 +
326 + if ( ! isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) ||
327 + ! is_array( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) ) {
328 + $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array();
340 329 }
341 330 } else {
342 331 // All of the section was probably removed.
343 - $_POST['item_meta'][ $args['parent_field_id'] ] = array(); // phpcs:ignore WordPress.Security.NonceVerification.Missing
344 - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array(); // phpcs:ignore WordPress.Security.NonceVerification.Missing
332 + $_POST['item_meta'][ $args['parent_field_id'] ] = array();
333 + $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array();
345 334 }
346 335
347 - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; // phpcs:ignore WordPress.Security.NonceVerification.Missing
336 + $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
348 337 }
349 338
350 339 public static function get_posted_value( $field, &$value, $args ) {
351 340 if ( is_array( $field ) ) {
@@ -350,12 +339,12 @@
350 339 public static function get_posted_value( $field, &$value, $args ) {
351 340 if ( is_array( $field ) ) {
352 341 $field_id = $field['id'];
353 342 $field_obj = FrmFieldFactory::get_field_object( $field['id'] );
354 - } elseif ( is_object( $field ) ) {
343 + } else if ( is_object( $field ) ) {
355 344 $field_id = $field->id;
356 345 $field_obj = FrmFieldFactory::get_field_object( $field );
357 - } elseif ( is_numeric( $field ) ) {
346 + } else if ( is_numeric( $field ) ) {
358 347 $field_id = $field;
359 348 $field_obj = FrmFieldFactory::get_field_object( $field );
360 349 } else {
361 350 $value = self::get_posted_meta( $field, $args );
@@ -373,11 +362,13 @@
373 362 */
374 363 private static function get_posted_meta( $field_id, $args ) {
375 364 if ( empty( $args['parent_field_id'] ) ) {
376 365 // Sanitizing is done next.
377 - $value = isset( $_POST['item_meta'][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $field_id ] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
366 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
367 + $value = isset( $_POST['item_meta'][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $field_id ] ) : '';
378 368 } else {
379 - $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
369 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
370 + $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) : '';
380 371 }
381 372 return $value;
382 373 }
383 374
@@ -391,9 +382,9 @@
391 382 * @param array $args
392 383 */
393 384 public static function maybe_set_other_validation( $field, &$value, &$args ) {
394 385 $args['other'] = false;
395 - if ( ! $value || ! FrmAppHelper::pro_is_installed() ) {
386 + if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
396 387 return;
397 388 }
398 389
399 390 // Trim excess values if selection limit is exceeded for checkbox. Necessary to do here
@@ -406,9 +397,9 @@
406 397 // Get other value for fields in repeating section.
407 398 self::set_other_repeating_vals( $field, $value, $args );
408 399
409 400 // Check if there are any posted "Other" values.
410 - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
401 + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
411 402
412 403 // Save original value.
413 404 $args['temp_value'] = $value;
414 405 $args['other'] = true;
@@ -413,9 +404,10 @@
413 404 $args['temp_value'] = $value;
414 405 $args['other'] = true;
415 406
416 407 // Sanitizing is done next.
417 - $other_vals = wp_unslash( $_POST['item_meta']['other'][ $field->id ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
408 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
409 + $other_vals = wp_unslash( $_POST['item_meta']['other'][ $field->id ] );
418 410 FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals );
419 411
420 412 // Set the validation value now
421 413 self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -436,14 +428,15 @@
436 428 return;
437 429 }
438 430
439 431 // Check if there are any other posted "other" values for this field.
440 - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
432 + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
441 433 // Save original value
442 434 $args['temp_value'] = $value;
443 435 $args['other'] = true;
444 436
445 - $other_vals = wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
437 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
438 + $other_vals = wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] );
446 439 FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals );
447 440
448 441 // Set the validation value now.
449 442 self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -513,9 +506,8 @@
513 506 /**
514 507 * Add submitted values to a string for spam checking.
515 508 *
516 509 * @param array $values
517 - * @return string
518 510 */
519 511 public static function entry_array_to_string( $values ) {
520 512 $content = '';
521 513 foreach ( $values['item_meta'] as $val ) {
@@ -620,9 +612,9 @@
620 612
621 613 foreach ( $links as $link ) {
622 614 ?>
623 615 <div class="misc-pub-section">
624 - <a href="<?php echo esc_url( $link['url'] ); ?>"
616 + <a href="<?php echo esc_url( FrmAppHelper::maybe_full_screen_link( $link['url'] ) ); ?>"
625 617 <?php
626 618 if ( isset( $link['data'] ) ) {
627 619 foreach ( $link['data'] as $data => $value ) {
628 620 echo 'data-' . esc_attr( $data ) . '="' . esc_attr( $value ) . '" ';
@@ -660,9 +652,9 @@
660 652 }
661 653
662 654 if ( current_user_can( 'frm_delete_entries' ) ) {
663 655 $actions['frm_delete'] = array(
664 - 'url' => wp_nonce_url( admin_url( 'admin.php?page=formidable-entries&frm_action=destroy&id=' . $id . '&form=' . $entry->form_id ) ),
656 + 'url' => admin_url( 'admin.php?page=formidable-entries&frm_action=destroy&id=' . $id . '&form=' . $entry->form_id ),
665 657 'label' => __( 'Delete Entry', 'formidable' ),
666 658 'icon' => 'frm_icon_font frm_delete_icon',
667 659 'data' => array(
668 660 'frmverify' => __( 'Delete this form entry?', 'formidable' ),
@@ -705,30 +697,6 @@
705 697 'icon' => 'frm_icon_font frm_pencil_icon',
706 698 );
707 699
708 700 return apply_filters( 'frm_entry_actions_dropdown', $actions, compact( 'id', 'entry' ) );
709 - }
710 -
711 - /**
712 - * @since 5.0.15
713 - *
714 - * @param string|int $entry_id
715 - * @return void
716 - */
717 - public static function maybe_render_captcha_score( $entry_id ) {
718 - $query = array(
719 - 'item_id' => (int) $entry_id,
720 - 'field_id' => 0,
721 - );
722 - $metas_without_a_field = (array) FrmEntryMeta::getAll( $query, ' ORDER BY it.created_at DESC', '', true );
723 - foreach ( $metas_without_a_field as $meta ) {
724 - if ( ! empty( $meta->meta_value['captcha_score'] ) ) {
725 - echo '<div class="misc-pub-section">';
726 - FrmAppHelper::icon_by_class( 'frm_icon_font frm_shield_check_icon', array( 'aria-hidden' => 'true' ) );
727 - echo ' ' . esc_html__( 'reCAPTCHA Score', 'formidable' ) . ': ';
728 - echo '<b>' . esc_html( $meta->meta_value['captcha_score'] ) . '</b>';
729 - echo '</div>';
730 - return;
731 - }
732 - }
733 701 }
734 702 }