| @@ -33,12 +33,8 @@ | ||
| 33 | 33 | $field_array['original_default'] = $original_default; |
| 34 | 34 | |
| 35 | 35 | FrmFieldsHelper::prepare_new_front_field( $field_array, $field, $args ); |
| 36 | 36 | |
| 37 | - if ( ! is_array( $field->field_options ) ) { | |
| 38 | - $field->field_options = array(); | |
| 39 | - } | |
| 40 | - | |
| 41 | 37 | $field_array = array_merge( $field->field_options, $field_array ); |
| 42 | 38 | |
| 43 | 39 | $values['fields'][] = $field_array; |
| 44 | 40 | |
| @@ -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 | |
| @@ -171,14 +167,8 @@ | ||
| 171 | 167 | |
| 172 | 168 | return $message; |
| 173 | 169 | } |
| 174 | 170 | |
| 175 | - /** | |
| 176 | - * @param stdClass $entry | |
| 177 | - * @param stdClass $field | |
| 178 | - * @param array $atts | |
| 179 | - * @return string | |
| 180 | - */ | |
| 181 | 171 | public static function prepare_display_value( $entry, $field, $atts ) { |
| 182 | 172 | $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false; |
| 183 | 173 | |
| 184 | 174 | if ( FrmAppHelper::pro_is_installed() ) { |
| @@ -193,16 +183,14 @@ | ||
| 193 | 183 | if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) { |
| 194 | 184 | return self::display_value( $field_value, $field, $atts ); |
| 195 | 185 | } |
| 196 | 186 | |
| 197 | - if ( ! FrmAppHelper::pro_is_installed() ) { | |
| 198 | - return ''; | |
| 199 | - } | |
| 187 | + // This is an embeded form. | |
| 188 | + $val = ''; | |
| 200 | 189 | |
| 201 | - // This is an embeded form. | |
| 202 | 190 | if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) { |
| 203 | 191 | // This is a repeating section. |
| 204 | - $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ), '', '', true ); | |
| 192 | + $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) ); | |
| 205 | 193 | } else { |
| 206 | 194 | // Get all values for this field. |
| 207 | 195 | $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
| 208 | 196 | |
| @@ -212,10 +200,10 @@ | ||
| 212 | 200 | } |
| 213 | 201 | |
| 214 | 202 | $field_value = array(); |
| 215 | 203 | |
| 216 | - if ( empty( $child_entries ) ) { | |
| 217 | - return ''; | |
| 204 | + if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { | |
| 205 | + return $val; | |
| 218 | 206 | } |
| 219 | 207 | |
| 220 | 208 | foreach ( $child_entries as $child_entry ) { |
| 221 | 209 | $atts['item_id'] = $child_entry->id; |
| @@ -223,9 +211,9 @@ | ||
| 223 | 211 | |
| 224 | 212 | // Fet the value for this field -- check for post values as well. |
| 225 | 213 | $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field ); |
| 226 | 214 | |
| 227 | - if ( $entry_val || '0' === $entry_val ) { | |
| 215 | + if ( $entry_val ) { | |
| 228 | 216 | // foreach entry get display_value. |
| 229 | 217 | $field_value[] = self::display_value( $entry_val, $field, $atts ); |
| 230 | 218 | } |
| 231 | 219 | |
| @@ -295,9 +283,9 @@ | ||
| 295 | 283 | return $value; |
| 296 | 284 | } |
| 297 | 285 | |
| 298 | 286 | $unfiltered_value = $value; |
| 299 | - FrmFieldsHelper::prepare_field_value( $unfiltered_value, $field->type ); | |
| 287 | + FrmAppHelper::unserialize_or_decode( $unfiltered_value ); | |
| 300 | 288 | |
| 301 | 289 | $value = apply_filters( 'frm_display_value_custom', $unfiltered_value, $field, $atts ); |
| 302 | 290 | $value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) ); |
| 303 | 291 | |
| @@ -333,19 +321,22 @@ | ||
| 333 | 321 | * |
| 334 | 322 | * @since 4.01 |
| 335 | 323 | */ |
| 336 | 324 | 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 | |
| 325 | + if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ] ) && | |
| 326 | + is_array( $_POST['item_meta'][ $args['parent_field_id'] ] ) ) { | |
| 327 | + | |
| 328 | + if ( ! isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) || | |
| 329 | + ! is_array( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) ) { | |
| 330 | + $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array(); | |
| 340 | 331 | } |
| 341 | 332 | } else { |
| 342 | 333 | // 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 | |
| 334 | + $_POST['item_meta'][ $args['parent_field_id'] ] = array(); | |
| 335 | + $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array(); | |
| 345 | 336 | } |
| 346 | 337 | |
| 347 | - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 338 | + $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; | |
| 348 | 339 | } |
| 349 | 340 | |
| 350 | 341 | public static function get_posted_value( $field, &$value, $args ) { |
| 351 | 342 | if ( is_array( $field ) ) { |
| @@ -350,12 +341,12 @@ | ||
| 350 | 341 | public static function get_posted_value( $field, &$value, $args ) { |
| 351 | 342 | if ( is_array( $field ) ) { |
| 352 | 343 | $field_id = $field['id']; |
| 353 | 344 | $field_obj = FrmFieldFactory::get_field_object( $field['id'] ); |
| 354 | - } elseif ( is_object( $field ) ) { | |
| 345 | + } else if ( is_object( $field ) ) { | |
| 355 | 346 | $field_id = $field->id; |
| 356 | 347 | $field_obj = FrmFieldFactory::get_field_object( $field ); |
| 357 | - } elseif ( is_numeric( $field ) ) { | |
| 348 | + } else if ( is_numeric( $field ) ) { | |
| 358 | 349 | $field_id = $field; |
| 359 | 350 | $field_obj = FrmFieldFactory::get_field_object( $field ); |
| 360 | 351 | } else { |
| 361 | 352 | $value = self::get_posted_meta( $field, $args ); |
| @@ -373,11 +364,13 @@ | ||
| 373 | 364 | */ |
| 374 | 365 | private static function get_posted_meta( $field_id, $args ) { |
| 375 | 366 | if ( empty( $args['parent_field_id'] ) ) { |
| 376 | 367 | // 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 | |
| 368 | + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 369 | + $value = isset( $_POST['item_meta'][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $field_id ] ) : ''; | |
| 378 | 370 | } 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 | |
| 371 | + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 372 | + $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 | 373 | } |
| 381 | 374 | return $value; |
| 382 | 375 | } |
| 383 | 376 | |
| @@ -391,9 +384,9 @@ | ||
| 391 | 384 | * @param array $args |
| 392 | 385 | */ |
| 393 | 386 | public static function maybe_set_other_validation( $field, &$value, &$args ) { |
| 394 | 387 | $args['other'] = false; |
| 395 | - if ( ! $value || ! FrmAppHelper::pro_is_installed() ) { | |
| 388 | + if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) { | |
| 396 | 389 | return; |
| 397 | 390 | } |
| 398 | 391 | |
| 399 | 392 | // Trim excess values if selection limit is exceeded for checkbox. Necessary to do here |
| @@ -406,9 +399,9 @@ | ||
| 406 | 399 | // Get other value for fields in repeating section. |
| 407 | 400 | self::set_other_repeating_vals( $field, $value, $args ); |
| 408 | 401 | |
| 409 | 402 | // 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 | |
| 403 | + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { | |
| 411 | 404 | |
| 412 | 405 | // Save original value. |
| 413 | 406 | $args['temp_value'] = $value; |
| 414 | 407 | $args['other'] = true; |
| @@ -413,9 +406,10 @@ | ||
| 413 | 406 | $args['temp_value'] = $value; |
| 414 | 407 | $args['other'] = true; |
| 415 | 408 | |
| 416 | 409 | // 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 | |
| 410 | + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 411 | + $other_vals = wp_unslash( $_POST['item_meta']['other'][ $field->id ] ); | |
| 418 | 412 | FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals ); |
| 419 | 413 | |
| 420 | 414 | // Set the validation value now |
| 421 | 415 | self::set_other_validation_val( $value, $other_vals, $field, $args ); |
| @@ -436,14 +430,15 @@ | ||
| 436 | 430 | return; |
| 437 | 431 | } |
| 438 | 432 | |
| 439 | 433 | // 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 | |
| 434 | + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { | |
| 441 | 435 | // Save original value |
| 442 | 436 | $args['temp_value'] = $value; |
| 443 | 437 | $args['other'] = true; |
| 444 | 438 | |
| 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 | |
| 439 | + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 440 | + $other_vals = wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ); | |
| 446 | 441 | FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals ); |
| 447 | 442 | |
| 448 | 443 | // Set the validation value now. |
| 449 | 444 | self::set_other_validation_val( $value, $other_vals, $field, $args ); |
| @@ -513,9 +508,8 @@ | ||
| 513 | 508 | /** |
| 514 | 509 | * Add submitted values to a string for spam checking. |
| 515 | 510 | * |
| 516 | 511 | * @param array $values |
| 517 | - * @return string | |
| 518 | 512 | */ |
| 519 | 513 | public static function entry_array_to_string( $values ) { |
| 520 | 514 | $content = ''; |
| 521 | 515 | foreach ( $values['item_meta'] as $val ) { |
| @@ -620,9 +614,9 @@ | ||
| 620 | 614 | |
| 621 | 615 | foreach ( $links as $link ) { |
| 622 | 616 | ?> |
| 623 | 617 | <div class="misc-pub-section"> |
| 624 | - <a href="<?php echo esc_url( $link['url'] ); ?>" | |
| 618 | + <a href="<?php echo esc_url( FrmAppHelper::maybe_full_screen_link( $link['url'] ) ); ?>" | |
| 625 | 619 | <?php |
| 626 | 620 | if ( isset( $link['data'] ) ) { |
| 627 | 621 | foreach ( $link['data'] as $data => $value ) { |
| 628 | 622 | echo 'data-' . esc_attr( $data ) . '="' . esc_attr( $value ) . '" '; |
| @@ -660,9 +654,9 @@ | ||
| 660 | 654 | } |
| 661 | 655 | |
| 662 | 656 | if ( current_user_can( 'frm_delete_entries' ) ) { |
| 663 | 657 | $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 ) ), | |
| 658 | + 'url' => admin_url( 'admin.php?page=formidable-entries&frm_action=destroy&id=' . $id . '&form=' . $entry->form_id ), | |
| 665 | 659 | 'label' => __( 'Delete Entry', 'formidable' ), |
| 666 | 660 | 'icon' => 'frm_icon_font frm_delete_icon', |
| 667 | 661 | 'data' => array( |
| 668 | 662 | 'frmverify' => __( 'Delete this form entry?', 'formidable' ), |
| @@ -705,30 +699,6 @@ | ||
| 705 | 699 | 'icon' => 'frm_icon_font frm_pencil_icon', |
| 706 | 700 | ); |
| 707 | 701 | |
| 708 | 702 | 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 | 703 | } |
| 734 | 704 | } |