PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.6.1
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.6.1
1.6.7 1.6.8 1.6.9 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.19 1.6.2 1.6.20 1.6.21 1.6.22 1.6.23 1.6.24 1.6.25 1.6.26 1.6.27 1.6.28 1.6.3 1.6.4 1.6.5 1.6.6 All 74 releases
← All changes | includes/class-notification.php +16 -37 1.6.121.6.1 View file →
@@ -462,53 +462,34 @@
462 462 }
463 463 }
464 464
465 465 /**
466 - * Parse out the custom fields with options or values. Since the options are what is stored, options may need to be
467 - * used to find the value from the field settings.
466 + * Parse out the custom fields with entry meta values
468 467 *
469 - * For example, let's say we have the following options:
470 - * DEPARTMENT / EMAIL
471 - * Support / support@example.com
472 - * Sales / sales@example.com
468 + * @param string $text
473 469 *
474 - * Users need the ability to pass {field:department} and get "Support",
475 - * and {value:department} to get support@email.com
476 - *
477 - * @param string $text The text to parse.
478 - * @param int $entry_id The entry ID.
479 - *
480 - * @return string $text The parsed text.
470 + * @return string
481 471 */
482 472 public static function replace_field_tags( $text, $entry_id ) {
483 - // Validate data.
484 - if ( empty( $text ) || empty( $entry_id ) ) {
485 - return;
473 + $pattern = '/{field:(\w*)}/';
474 +
475 + preg_match_all( $pattern, $text, $matches );
476 +
477 + // bail out if nothing found to be replaced
478 + if ( !$matches ) {
479 + return $text;
486 480 }
487 481
488 - // Users looking for {field:something} or {value:something}, determine which one.
489 - $is_field = preg_match( '/{field:(\w*)}/', $text, $matches_field );
490 - $is_value = preg_match( '/{value:(\w*)}/', $text, $matches_value );
482 + foreach ( $matches[1] as $index => $meta_key ) {
483 + $meta_value = weforms_get_entry_meta( $entry_id, $meta_key, true );
491 484
492 - if ( $is_field ) {
493 - $meta_key = $matches_field[1];
494 - $meta_value = weforms_get_entry_meta( $entry_id, $meta_key, true );
495 485 if ( is_array( $meta_value ) ) {
496 486 $meta_value = implode( WeForms::$field_separator, $meta_value );
497 487 }
498 - // $text may include HTML tags, only replace tag that was matched.
499 - $text = str_replace( $matches_field[0], $meta_value, $text );
500 - } elseif ( $is_value ) {
501 - $meta_key = $matches_value[1];
502 - $form_field_values = WeForms_Form_Entry::get_form( $entry_id )->get_field_values()[ $meta_key ]['options'];
503 - $meta_value = weforms_get_entry_meta( $entry_id, $meta_key, true );
504 - $modified_value = array_search( $meta_value, $form_field_values );
505 - if ( is_array( $modified_value ) ) {
506 - $modified_value = implode( WeForms::$field_separator, $modified_value );
507 - }
508 - // $text may include HTML tags, only replace tag that was matched.
509 - $text = str_replace( $matches_value[0], $modified_value, $text );
488 +
489 + $text = str_replace( $matches[0][$index], $meta_value, $text );
510 490 }
491 +
511 492 return $text;
512 493 }
513 494
514 495 /**
@@ -666,9 +647,9 @@
666 647 $table .= '</tr>';
667 648 $table .= '<tr class="field-value">';
668 649 $table .= '<td>';
669 650
670 - if ( in_array( $value['type'], array( 'multiple_select', 'checkbox_field' ) ) ) {
651 + if ( in_array( $value['type'], [ 'multiple_select', 'checkbox_field' ] ) ) {
671 652 $field_value = is_array( $field_value ) ? $field_value : [];
672 653
673 654 if ( $field_value ) {
674 655 $table .= '<ul>';
@@ -679,10 +660,8 @@
679 660 $table .= '</ul>';
680 661 } else {
681 662 $table .= '&mdash;';
682 663 }
683 - } elseif ( in_array( $value['type'], array( 'google_map' ) ) ) {
684 - $table .= $field_value['address'];
685 664 } else {
686 665 $table .= $field_value;
687 666 }
688 667