PluginProbe
HTML Forms – Simple WordPress Forms Plugin / 1.3.21
HTML Forms – Simple WordPress Forms Plugin v1.3.21
1.7.0 trunk 1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2.0 1.3.0 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.16 All 67 releases
← All changes | src/actions/class-email.php +14 -30 trunk1.3.21 View file →
@@ -34,33 +34,27 @@
34 34 */
35 35 public function page_settings( $settings, $index ) {
36 36 $settings = array_merge( $this->get_default_settings(), $settings );
37 37 ?>
38 - <span class="hf-action-summary"><?php printf( 'From %s. To %s.', esc_html($settings['from']), esc_html($settings['to']) ); ?></span>
39 - <input type="hidden" name="form[settings][actions][<?php echo esc_attr($index); ?>][type]" value="<?php echo $this->type; ?>" />
40 -
41 - <p class="description">
42 - <?php _e( 'Send out an email notification whenever this form is successfully submitted.', 'html-forms' ); ?>
43 - <a target="_blank" tabindex="-1" class="html-forms-help" href="https://htmlformsplugin.com/kb/sending-email-notifications/"><span class="dashicons dashicons-editor-help"></span></a>
44 - </p>
45 -
38 + <span class="hf-action-summary"><?php printf( 'From %s. To %s.', $settings['from'], $settings['to'] ); ?></span>
39 + <input type="hidden" name="form[settings][actions][<?php echo $index; ?>][type]" value="<?php echo $this->type; ?>" />
46 40 <table class="form-table">
47 41 <tr>
48 42 <th><label><?php echo __( 'From', 'html-forms' ); ?> <span class="hf-required">*</span></label></th>
49 43 <td>
50 - <input name="form[settings][actions][<?php echo esc_attr($index); ?>][from]" value="<?php echo esc_attr( $settings['from'] ); ?>" type="text" class="regular-text" placeholder="jane@email.com" required />
44 + <input name="form[settings][actions][<?php echo $index; ?>][from]" value="<?php echo esc_attr( $settings['from'] ); ?>" type="text" class="regular-text" placeholder="jane@email.com" required />
51 45 </td>
52 46 </tr>
53 47 <tr>
54 48 <th><label><?php echo __( 'To', 'html-forms' ); ?> <span class="hf-required">*</span></label></th>
55 49 <td>
56 - <input name="form[settings][actions][<?php echo esc_attr($index); ?>][to]" value="<?php echo esc_attr( $settings['to'] ); ?>" type="text" class="regular-text" placeholder="john@email.com" required />
50 + <input name="form[settings][actions][<?php echo $index; ?>][to]" value="<?php echo esc_attr( $settings['to'] ); ?>" type="text" class="regular-text" placeholder="john@email.com" required />
57 51 </td>
58 52 </tr>
59 53 <tr>
60 54 <th><label><?php echo __( 'Subject', 'html-forms' ); ?></label></th>
61 55 <td>
62 - <input name="form[settings][actions][<?php echo esc_attr($index); ?>][subject]" value="<?php echo esc_attr( $settings['subject'] ); ?>" type="text" class="regular-text" placeholder="<?php echo esc_attr( __( 'Your email subject', 'html-forms' ) ); ?>" />
56 + <input name="form[settings][actions][<?php echo $index; ?>][subject]" value="<?php echo esc_attr( $settings['subject'] ); ?>" type="text" class="regular-text" placeholder="<?php echo esc_attr( __( 'Your email subject', 'html-forms' ) ); ?>" />
63 57 </td>
64 58 </tr>
65 59
66 60 <tr>
@@ -65,9 +59,9 @@
65 59
66 60 <tr>
67 61 <th><label><?php echo __( 'Message', 'html-forms' ); ?> <span class="hf-required">*</span></label></th>
68 62 <td>
69 - <textarea name="form[settings][actions][<?php echo esc_attr($index); ?>][message]" rows="8" class="widefat" placeholder="<?php echo esc_attr( __( 'Your email message', 'html-forms' ) ); ?>" required><?php echo esc_textarea( $settings['message'] ); ?></textarea>
63 + <textarea name="form[settings][actions][<?php echo $index; ?>][message]" rows="8" class="widefat" placeholder="<?php echo esc_attr( __( 'Your email message', 'html-forms' ) ); ?>" required><?php echo esc_textarea( $settings['message'] ); ?></textarea>
70 64 <p class="help"><?php _e( 'You can use the following variables (in all fields): ', 'html-forms' ); ?><br /><span class="hf-field-names"></span></p>
71 65 </td>
72 66 </tr>
73 67
@@ -73,9 +67,9 @@
73 67
74 68 <tr>
75 69 <th><label><?php echo __( 'Content Type', 'html-forms' ); ?></label></th>
76 70 <td>
77 - <select name="form[settings][actions][<?php echo esc_attr($index); ?>][content_type]" required>
71 + <select name="form[settings][actions][<?php echo $index; ?>][content_type]" required>
78 72 <option <?php selected( $settings['content_type'], 'text/plain' ); ?>>text/plain</option>
79 73 <option <?php selected( $settings['content_type'], 'text/html' ); ?>>text/html</option>
80 74 </select>
81 75 </td>
@@ -81,11 +75,11 @@
81 75 </td>
82 76 </tr>
83 77
84 78 <tr>
85 - <th><label><?php echo __( 'Additional Headers', 'html-forms' ); ?></label></th>
79 + <th><label><?php echo __( 'Additional headers', 'html-forms' ); ?></label></th>
86 80 <td>
87 - <textarea name="form[settings][actions][<?php echo esc_attr($index); ?>][headers]" rows="4" class="widefat" placeholder="<?php echo esc_attr( 'Reply-To: [NAME] <[EMAIL]>' ); ?>"><?php echo esc_textarea( $settings['headers'] ); ?></textarea>
81 + <textarea name="form[settings][actions][<?php echo $index; ?>][headers]" rows="4" class="widefat" placeholder="<?php echo esc_attr( 'Reply-To: [NAME] <[EMAIL]>' ); ?>"><?php echo esc_textarea( $settings['headers'] ); ?></textarea>
88 82 </td>
89 83 </tr>
90 84 </table>
91 85 <?php
@@ -105,27 +99,17 @@
105 99
106 100 $settings = array_merge( $this->get_default_settings(), $settings );
107 101 $html_email = $settings['content_type'] === 'text/html';
108 102
109 - // Strip newlines and tags from substituted values
110 - $sanitize_header_value = function( $value ) {
111 - return str_replace( array( "\r", "\n" ), '', strip_tags( $value ) );
112 - };
113 -
114 - $to = hf_replace_data_variables( $settings['to'], $submission, $sanitize_header_value );
115 - $to = apply_filters( 'hf_action_email_to', $to, $submission );
116 -
117 - $subject = ! empty( $settings['subject'] ) ? hf_replace_data_variables( $settings['subject'], $submission, $sanitize_header_value ) : '';
103 + $to = apply_filters( 'hf_action_email_to', hf_replace_data_variables( $settings['to'], $submission->data, 'strip_tags' ), $submission );
104 + $subject = ! empty( $settings['subject'] ) ? hf_replace_data_variables( $settings['subject'], $submission->data, 'strip_tags' ) : '';
118 105 $subject = apply_filters( 'hf_action_email_subject', $subject, $submission );
106 + $message = apply_filters( 'hf_action_email_message', hf_replace_data_variables( $settings['message'], $submission->data, $html_email ? 'esc_html' : null ), $submission );
119 107
120 - $message = hf_replace_data_variables( $settings['message'], $submission, $html_email ? 'esc_html' : null );
121 - $message = ! $html_email ? str_replace( '<br />', '', $message ) : $message;
122 - $message = apply_filters( 'hf_action_email_message', $message, $submission );
123 -
124 108 // parse additional email headers from settings
125 109 $headers = array();
126 110 if ( ! empty( $settings['headers'] ) ) {
127 - $headers = explode( PHP_EOL, hf_replace_data_variables( $settings['headers'], $submission, $sanitize_header_value ) );
111 + $headers = explode( PHP_EOL, hf_replace_data_variables( $settings['headers'], $submission->data, 'strip_tags' ) );
128 112 }
129 113
130 114 $content_type = $html_email ? 'text/html' : 'text/plain';
131 115 $charset = get_bloginfo( 'charset' );
@@ -131,9 +115,9 @@
131 115 $charset = get_bloginfo( 'charset' );
132 116 $headers[] = sprintf( 'Content-Type: %s; charset=%s', $content_type, $charset );
133 117
134 118 if ( ! empty( $settings['from'] ) ) {
135 - $from = apply_filters( 'hf_action_email_from', hf_replace_data_variables( $settings['from'], $submission, $sanitize_header_value ), $submission );
119 + $from = apply_filters( 'hf_action_email_from', hf_replace_data_variables( $settings['from'], $submission->data, 'strip_tags' ), $submission );
136 120 $headers[] = sprintf( 'From: %s', $from );
137 121 }
138 122
139 123 return wp_mail( $to, $subject, $message, $headers );