PluginProbe
HTML Forms – Simple WordPress Forms Plugin / 1.7.0
HTML Forms – Simple WordPress Forms Plugin v1.7.0
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/class-form.php +16 -3 1.3.161.7.0 View file →
@@ -51,12 +51,17 @@
51 51 $form_action = apply_filters( 'hf_form_element_action_attr', null, $form );
52 52 $form_action_attr = is_null( $form_action ) ? '' : sprintf( 'action="%s"', $form_action );
53 53
54 54 $data_attributes = $this->get_data_attributes();
55 + $settings = hf_get_settings();
55 56
56 57 $html = '';
57 - $html .= sprintf( '<!-- HTML Forms v%s - %s -->', HTML_FORMS_VERSION, 'https://wordpress.org/plugins/html-forms/' );
58 + $html .= sprintf( '<!-- HTML Forms v%s - %s -->', HTML_FORMS_VERSION, 'https://wordpress.org/plugins/html-forms/' ) . PHP_EOL;
58 59 $html .= sprintf( '<form method="post" %s class="hf-form hf-form-%d %s" %s>', $form_action_attr, $this->ID, esc_attr( $form_classes_attr ), $data_attributes );
60 +
61 + if ( $settings['enable_nonce'] ) {
62 + $html .= wp_nonce_field( 'html_forms_submit', '_wpnonce', true, false );
63 + }
59 64
60 65 $html .= sprintf( '<input type="hidden" name="_hf_form_id" value="%d" />', $this->ID );
61 66 $html .= sprintf( '<div style="display: none;"><input type="text" name="_hf_h%d" value="" /></div>', $this->ID );
62 67 $html .= '<div class="hf-fields-wrap">';
@@ -129,9 +134,13 @@
129 134 /**
130 135 * @return string
131 136 */
132 137 public function get_markup() {
133 - return apply_filters( 'hf_form_markup', $this->markup );
138 + /**
139 + * @param string $markup
140 + * @param Form $form
141 + */
142 + return apply_filters( 'hf_form_markup', $this->markup, $this );
134 143 }
135 144
136 145 /**
137 146 * @return array
@@ -174,11 +183,15 @@
174 183 }
175 184
176 185 /**
177 186 * @return int The number of named fields in the form
187 + *
188 + * Note: this includes all default fields and an additional field for the "was-required" element we include in every request.
178 189 */
179 190 public function get_field_count() {
180 - $count = substr_count( strtolower( $this->get_html() ), ' name=' );
191 + $pattern = '/\bname\s*=\s*["\']/i';
192 + preg_match_all( $pattern, $this->get_html(), $matches );
193 + $count = ! empty( $matches ) ? count( $matches[0] ) : 0;
181 194 $count++; // Add one for 'was-required'
182 195 return $count;
183 196 }
184 197 }