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 +20 -87 1.6.241.6.1 View file →
@@ -120,41 +120,8 @@
120 120 // content type to text/html
121 121 $headers[] = 'Content-Type: text/html; charset=UTF-8';
122 122 $email_body = apply_filters( 'weforms_email_message', $this->get_formatted_body( $message ), $notification['message'], $headers );
123 123
124 - /**
125 - * Added the display style to the safe styles during wp_kses_post().
126 - * WP kses post removes the display css property that we need when formatting the Checkbox and Multiple Choice Grids.
127 - * This function will only run during the notification process.
128 - *
129 - * @since 1.6.17
130 - */
131 - add_filter( 'safe_style_css', function( $styles ) {
132 - $styles[] = 'display';
133 - return $styles;
134 - } );
135 -
136 - /**
137 - * Added the input tag to the allowed html during wp_kses_post().
138 - * WP kses post removes the input tag that we need when formatting the Checkbox and Multiple Choice Grids.
139 - * The $message variable is formatted during the entry creation process. The values from the form are sanitized to avoid
140 - * any issues with malicious inputs.
141 - *
142 - * This function is only used during the notification process.
143 - *
144 - * @since 1.6.17
145 - */
146 - add_filter( 'wp_kses_allowed_html', function( $html ) {
147 - $html['input'] = array(
148 - 'class' => array(),
149 - 'name' => array(),
150 - 'type' => array(),
151 - 'value' => array(),
152 - 'checked' => array(),
153 - 'disabled' => array(),
154 - );
155 - return $html;
156 - } );
157 124 weforms()->emailer->send( $to, $subject, wp_kses_post( htmlspecialchars_decode( $email_body ) ) , $headers );
158 125 }
159 126
160 127 /**
@@ -429,9 +396,9 @@
429 396 return get_permalink( $this->args['page_id'] );
430 397 break;
431 398
432 399 case 'url_referer':
433 - return isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_url( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '';
400 + return isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '';
434 401 break;
435 402
436 403 case 'url_login':
437 404 return wp_login_url();
@@ -495,66 +462,34 @@
495 462 }
496 463 }
497 464
498 465 /**
499 - * Parse out the custom fields with options or values. Since the options are what is stored, options may need to be
500 - * used to find the value from the field settings.
466 + * Parse out the custom fields with entry meta values
501 467 *
502 - * For example, let's say we have the following options:
503 - * DEPARTMENT / EMAIL
504 - * Support / support@example.com
505 - * Sales / sales@example.com
468 + * @param string $text
506 469 *
507 - * Users need the ability to pass {field:department} and get "Support",
508 - * and {value:department} to get support@email.com
509 - *
510 - * @param string $text The text to parse.
511 - * @param int $entry_id The entry ID. Optional. Default null if tags to be replaced are on the frontend.
512 - *
513 - * @return string $text The parsed text.
470 + * @return string
514 471 */
515 - public static function replace_field_tags( $text, $entry_id = null ) {
516 - // Validate data.
517 - if ( empty( $text ) || !isset( $entry_id ) ) {
518 - return;
472 + public static function replace_field_tags( $text, $entry_id ) {
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;
519 480 }
520 481
521 - // Users looking for {field:something} or {value:something}, determine which one.
522 - $is_field = preg_match_all( '/{field:(\w*)}/', $text, $matches_field );
523 - $is_value = preg_match_all( '/{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 );
524 484
525 - if ( $is_field ) {
526 - $meta_keys = $matches_field[1];
527 - // Create an array of meta values to replace.
528 - $meta_values = array();
529 - foreach ( $meta_keys as $meta_key ) {
530 - $meta_value = weforms_get_entry_meta( $entry_id, $meta_key, true );
531 - // Add values to the array.
532 - array_push( $meta_values, $meta_value );
533 - if ( is_array( $meta_value ) ) {
534 - $meta_value = implode( WeForms::$field_separator, $meta_value );
535 - }
485 + if ( is_array( $meta_value ) ) {
486 + $meta_value = implode( WeForms::$field_separator, $meta_value );
536 487 }
537 - // $text may include HTML tags, only replace tag that was matched. Replace all matches.
538 - $text = str_replace( $matches_field[0], $meta_values, $text );
488 +
489 + $text = str_replace( $matches[0][$index], $meta_value, $text );
539 490 }
540 - if ( $is_value ) {
541 - $meta_keys = $matches_value[1];
542 - // Create an array of modified values to replace.
543 - $modified_values = array();
544 - foreach ( $meta_keys as $meta_key ) {
545 - $form_field_values = WeForms_Form_Entry::get_form( $entry_id )->get_field_values()[ $meta_key ]['options'];
546 - $meta_value = weforms_get_entry_meta( $entry_id, $meta_key, true );
547 - $modified_value = array_search( $meta_value, $form_field_values );
548 - // Add values to the array.
549 - array_push( $modified_values, $modified_value );
550 - if ( is_array( $modified_value ) ) {
551 - $modified_value = implode( WeForms::$field_separator, $modified_value );
552 - }
553 - }
554 - // $text may include HTML tags, only replace tag that was matched.
555 - $text = str_replace( $matches_value[0], $modified_values, $text );
556 - }
491 +
557 492 return $text;
558 493 }
559 494
560 495 /**
@@ -712,9 +647,9 @@
712 647 $table .= '</tr>';
713 648 $table .= '<tr class="field-value">';
714 649 $table .= '<td>';
715 650
716 - if ( in_array( $value['type'], array( 'multiple_select', 'checkbox_field' ) ) ) {
651 + if ( in_array( $value['type'], [ 'multiple_select', 'checkbox_field' ] ) ) {
717 652 $field_value = is_array( $field_value ) ? $field_value : [];
718 653
719 654 if ( $field_value ) {
720 655 $table .= '<ul>';
@@ -725,10 +660,8 @@
725 660 $table .= '</ul>';
726 661 } else {
727 662 $table .= '&mdash;';
728 663 }
729 - } elseif ( in_array( $value['type'], array( 'google_map' ) ) ) {
730 - $table .= $field_value['address'];
731 664 } else {
732 665 $table .= $field_value;
733 666 }
734 667