| @@ -51,17 +51,12 @@ | ||
| 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(); | |
| 56 | 55 | |
| 57 | 56 | $html = ''; |
| 58 | - $html .= sprintf( '<!-- HTML Forms v%s - %s -->', HTML_FORMS_VERSION, 'https://wordpress.org/plugins/html-forms/' ) . PHP_EOL; | |
| 57 | + $html .= sprintf( '<!-- HTML Forms v%s - %s -->', HTML_FORMS_VERSION, 'https://wordpress.org/plugins/html-forms/' ); | |
| 59 | 58 | $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 | - } | |
| 64 | 59 | |
| 65 | 60 | $html .= sprintf( '<input type="hidden" name="_hf_form_id" value="%d" />', $this->ID ); |
| 66 | 61 | $html .= sprintf( '<div style="display: none;"><input type="text" name="_hf_h%d" value="" /></div>', $this->ID ); |
| 67 | 62 | $html .= '<div class="hf-fields-wrap">'; |
| @@ -183,15 +178,11 @@ | ||
| 183 | 178 | } |
| 184 | 179 | |
| 185 | 180 | /** |
| 186 | 181 | * @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. | |
| 189 | 182 | */ |
| 190 | 183 | public function get_field_count() { |
| 191 | - $pattern = '/\bname\s*=\s*["\']/i'; | |
| 192 | - preg_match_all( $pattern, $this->get_html(), $matches ); | |
| 193 | - $count = ! empty( $matches ) ? count( $matches[0] ) : 0; | |
| 184 | + $count = substr_count( strtolower( $this->get_html() ), ' name=' ); | |
| 194 | 185 | $count++; // Add one for 'was-required' |
| 195 | 186 | return $count; |
| 196 | 187 | } |
| 197 | 188 | } |