PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
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/FrmEntryFormatter.php +42 -43 6.27 → trunk View file →
@@ -10,9 +10,9 @@
10 10
11 11 /**
12 12 * @since 2.04
13 13 *
14 - * @var stdClass|null
14 + * @var false|stdClass|null
15 15 */
16 16 protected $entry;
17 17
18 18 /**
@@ -416,18 +416,14 @@
416 416 }
417 417
418 418 if ( $this->format === 'json' ) {
419 419 $content = json_encode( $this->prepare_array() );
420 -
421 420 } elseif ( $this->format === 'array' ) {
422 421 $content = $this->prepare_array();
423 -
424 422 } elseif ( $this->format === 'table' ) {
425 423 $content = $this->prepare_html_table();
426 -
427 424 } elseif ( $this->format === 'plain_text_block' ) {
428 425 $content = $this->prepare_plain_text_block();
429 -
430 426 } else {
431 427 $content = '';
432 428 }
433 429
@@ -465,13 +461,9 @@
465 461 $this->add_user_info_to_html_table( $content );
466 462
467 463 $content .= $this->table_generator->generate_table_footer();
468 464
469 - if ( $this->is_clickable ) {
470 - $content = make_clickable( $content );
471 - }
472 -
473 - return $content;
465 + return $this->is_clickable ? make_clickable( $content ) : $content;
474 466 }
475 467
476 468 /**
477 469 * Add field values to table or plain text content
@@ -553,16 +545,18 @@
553 545 *
554 546 * @return void
555 547 */
556 548 protected function push_single_field_to_array( $field_value, &$output ) {
557 - if ( $this->include_field_in_content( $field_value ) ) {
558 - $displayed_value = $this->prepare_display_value_for_array( $field_value->get_displayed_value() );
559 - $output[ $this->get_key_or_id( $field_value ) ] = $displayed_value;
560 - $has_separate_value = (bool) $field_value->get_field_option( 'separate_value' );
549 + if ( ! $this->include_field_in_content( $field_value ) ) {
550 + return;
551 + }
561 552
562 - if ( $has_separate_value || $displayed_value !== $field_value->get_saved_value() ) {
563 - $output[ $this->get_key_or_id( $field_value ) . '-value' ] = $field_value->get_saved_value();
564 - }
553 + $displayed_value = $this->prepare_display_value_for_array( $field_value->get_displayed_value() );
554 + $output[ $this->get_key_or_id( $field_value ) ] = $displayed_value;
555 + $has_separate_value = (bool) $field_value->get_field_option( 'separate_value' );
556 +
557 + if ( $has_separate_value || $displayed_value !== $field_value->get_saved_value() ) {
558 + $output[ $this->get_key_or_id( $field_value ) . '-value' ] = $field_value->get_saved_value();
565 559 }
566 560 }
567 561
568 562 /**
@@ -598,9 +592,8 @@
598 592 */
599 593 protected function add_field_value_to_content( $field_value, &$content ) {
600 594 if ( $this->is_extra_field( $field_value ) ) {
601 595 $this->add_row_for_extra_field( $field_value, $content );
602 -
603 596 } else {
604 597 $this->add_row_for_standard_field( $field_value, $content );
605 598 }
606 599 }
@@ -795,18 +788,20 @@
795 788 *
796 789 * @return void
797 790 */
798 791 protected function add_user_info_to_html_table( &$content ) {
799 - if ( $this->include_user_info ) {
800 - foreach ( $this->entry_values->get_user_info() as $user_info ) {
801 - $value_args = array(
802 - 'label' => $user_info['label'],
803 - 'value' => $user_info['value'],
804 - 'field_type' => 'none',
805 - );
792 + if ( ! $this->include_user_info ) {
793 + return;
794 + }
806 795
807 - $this->add_html_row( $value_args, $content );
808 - }
796 + foreach ( $this->entry_values->get_user_info() as $user_info ) {
797 + $value_args = array(
798 + 'label' => $user_info['label'],
799 + 'value' => $user_info['value'],
800 + 'field_type' => 'none',
801 + );
802 +
803 + $this->add_html_row( $value_args, $content );
809 804 }
810 805 }
811 806
812 807 /**
@@ -818,13 +813,15 @@
818 813 *
819 814 * @return void
820 815 */
821 816 protected function add_user_info_to_plain_text_content( &$content ) {
822 - if ( $this->include_user_info ) {
823 - foreach ( $this->entry_values->get_user_info() as $user_info ) {
824 - $this->add_plain_text_row( $user_info['label'], $user_info['value'], $content );
825 - }
817 + if ( ! $this->include_user_info ) {
818 + return;
826 819 }
820 +
821 + foreach ( $this->entry_values->get_user_info() as $user_info ) {
822 + $this->add_plain_text_row( $user_info['label'], $user_info['value'], $content );
823 + }
827 824 }
828 825
829 826 /**
830 827 * Check if a field should be included in the content
@@ -924,9 +921,9 @@
924 921 protected function prepare_display_value_for_html_table( $display_value, $field_type = '' ) {
925 922 $display_value = $this->flatten_array( $display_value );
926 923
927 924 if ( ! isset( $this->atts['line_breaks'] ) || ! empty( $this->atts['line_breaks'] ) ) {
928 - $display_value = str_replace( array( "\r\n", "\n" ), '<br/>', $display_value );
925 + return str_replace( array( "\r\n", "\n" ), '<br/>', $display_value );
929 926 }
930 927
931 928 return $display_value;
932 929 }
@@ -972,21 +969,23 @@
972 969 *
973 970 * @return mixed
974 971 */
975 972 protected function strip_html( $value ) {
976 - if ( $this->is_plain_text ) {
977 - if ( is_array( $value ) ) {
978 - foreach ( $value as $key => $single_value ) {
979 - $value[ $key ] = $this->strip_html( $single_value );
980 - }
981 - } elseif ( $this->is_plain_text && ! is_array( $value ) ) {
982 - if ( str_contains( $value, '<img' ) ) {
983 - $value = str_replace( array( '<img', 'src=', '/>', '"' ), '', $value );
984 - $value = trim( $value );
985 - }
973 + if ( ! $this->is_plain_text ) {
974 + return $value;
975 + }
986 976
987 - $value = strip_tags( $value );
977 + if ( is_array( $value ) ) {
978 + foreach ( $value as $key => $single_value ) {
979 + $value[ $key ] = $this->strip_html( $single_value );
988 980 }
981 + } elseif ( $this->is_plain_text && ! is_array( $value ) ) {
982 + if ( str_contains( $value, '<img' ) ) {
983 + $value = str_replace( array( '<img', 'src=', '/>', '"' ), '', $value );
984 + $value = trim( $value );
985 + }
986 +
987 + $value = strip_tags( $value );
989 988 }
990 989
991 990 return $value;
992 991 }