PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.6.21
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.6.21
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 +65 -19 1.6.121.6.21 View file →
@@ -120,8 +120,41 @@
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 + } );
124 157 weforms()->emailer->send( $to, $subject, wp_kses_post( htmlspecialchars_decode( $email_body ) ) , $headers );
125 158 }
126 159
127 160 /**
@@ -474,40 +507,53 @@
474 507 * Users need the ability to pass {field:department} and get "Support",
475 508 * and {value:department} to get support@email.com
476 509 *
477 510 * @param string $text The text to parse.
478 - * @param int $entry_id The entry ID.
511 + * @param int $entry_id The entry ID. Optional. Default null if tags to be replaced are on the frontend.
479 512 *
480 513 * @return string $text The parsed text.
481 514 */
482 - public static function replace_field_tags( $text, $entry_id ) {
515 + public static function replace_field_tags( $text, $entry_id = null ) {
483 516 // Validate data.
484 - if ( empty( $text ) || empty( $entry_id ) ) {
517 + if ( empty( $text ) || !isset( $entry_id ) ) {
485 518 return;
486 519 }
487 520
488 521 // 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 );
522 + $is_field = preg_match_all( '/{field:(\w*)}/', $text, $matches_field );
523 + $is_value = preg_match_all( '/{value:(\w*)}/', $text, $matches_value );
491 524
492 525 if ( $is_field ) {
493 - $meta_key = $matches_field[1];
494 - $meta_value = weforms_get_entry_meta( $entry_id, $meta_key, true );
495 - if ( is_array( $meta_value ) ) {
496 - $meta_value = implode( WeForms::$field_separator, $meta_value );
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 + }
497 536 }
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 );
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 );
539 + }
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 + }
507 553 }
508 554 // $text may include HTML tags, only replace tag that was matched.
509 - $text = str_replace( $matches_value[0], $modified_value, $text );
555 + $text = str_replace( $matches_value[0], $modified_values, $text );
510 556 }
511 557 return $text;
512 558 }
513 559