Completed
Push — master ( 96188e...703576 )
by Jamie
03:14
created
classes/models/FrmEntryValidate.php 2 patches
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -1,37 +1,37 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmEntryValidate {
4
-    public static function validate( $values, $exclude = false ) {
5
-        FrmEntry::sanitize_entry_post( $values );
6
-        $errors = array();
4
+	public static function validate( $values, $exclude = false ) {
5
+		FrmEntry::sanitize_entry_post( $values );
6
+		$errors = array();
7 7
 
8
-        if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
9
-            $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
10
-            return $errors;
11
-        }
8
+		if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
9
+			$errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
10
+			return $errors;
11
+		}
12 12
 
13 13
 		if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) {
14
-            $errors['form'] = __( 'You do not have permission to do that', 'formidable' );
15
-        }
14
+			$errors['form'] = __( 'You do not have permission to do that', 'formidable' );
15
+		}
16 16
 
17 17
 		self::set_item_key( $values );
18 18
 
19 19
 		$posted_fields = self::get_fields_to_validate( $values, $exclude );
20 20
 
21 21
 		// Pass exclude value to validate_field function so it can be used for repeating sections
22
-	    $args = array( 'exclude' => $exclude );
22
+		$args = array( 'exclude' => $exclude );
23 23
 
24
-	    self::spam_check( $exclude, $values, $errors );
25
-	    if ( ! empty( $errors ) ) {
26
-		    return $errors;
27
-	    }
24
+		self::spam_check( $exclude, $values, $errors );
25
+		if ( ! empty( $errors ) ) {
26
+			return $errors;
27
+		}
28 28
 
29
-	    foreach ( $posted_fields as $posted_field ) {
30
-		    self::validate_field( $posted_field, $errors, $values, $args );
31
-		    unset( $posted_field );
32
-	    }
29
+		foreach ( $posted_fields as $posted_field ) {
30
+			self::validate_field( $posted_field, $errors, $values, $args );
31
+			unset( $posted_field );
32
+		}
33 33
 
34
-	    $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact( 'exclude' ) );
34
+		$errors = apply_filters( 'frm_validate_entry', $errors, $values, compact( 'exclude' ) );
35 35
 
36 36
 		return $errors;
37 37
 	}
@@ -58,24 +58,24 @@  discard block
 block discarded – undo
58 58
 		return FrmField::getAll( $where, 'field_order' );
59 59
 	}
60 60
 
61
-    public static function validate_field( $posted_field, &$errors, $values, $args = array() ) {
62
-        $defaults = array(
63
-            'id'              => $posted_field->id,
64
-            'parent_field_id' => '', // the id of the repeat or embed form
65
-            'key_pointer'     => '', // the pointer in the posted array
66
-            'exclude'         => array(), // exclude these field types from validation
67
-        );
68
-        $args = wp_parse_args( $args, $defaults );
61
+	public static function validate_field( $posted_field, &$errors, $values, $args = array() ) {
62
+		$defaults = array(
63
+			'id'              => $posted_field->id,
64
+			'parent_field_id' => '', // the id of the repeat or embed form
65
+			'key_pointer'     => '', // the pointer in the posted array
66
+			'exclude'         => array(), // exclude these field types from validation
67
+		);
68
+		$args = wp_parse_args( $args, $defaults );
69 69
 
70
-        if ( empty($args['parent_field_id']) ) {
70
+		if ( empty($args['parent_field_id']) ) {
71 71
 			$value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
72
-        } else {
73
-            // value is from a nested form
74
-            $value = $values;
75
-        }
72
+		} else {
73
+			// value is from a nested form
74
+			$value = $values;
75
+		}
76 76
 
77
-        // Check for values in "Other" fields
78
-        FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
77
+		// Check for values in "Other" fields
78
+		FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
79 79
 
80 80
 		self::maybe_clear_value_for_default_blank_setting( $posted_field, $value );
81 81
 
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
 			$value = reset($value);
85 85
 		}
86 86
 
87
-        if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
87
+		if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
88 88
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
89
-        } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
90
-            $_POST['item_name'] = $value;
91
-        }
89
+		} else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
90
+			$_POST['item_name'] = $value;
91
+		}
92 92
 
93 93
 		if ( $value != '' ) {
94 94
 			self::validate_url_field( $errors, $posted_field, $value, $args );
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
 			self::validate_phone_field( $errors, $posted_field, $value, $args );
98 98
 		}
99 99
 
100
-        FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
100
+		FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
101 101
 
102
-        self::validate_recaptcha($errors, $posted_field, $args);
102
+		self::validate_recaptcha($errors, $posted_field, $args);
103 103
 
104 104
 		$errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args );
105 105
 		$errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args );
106
-    }
106
+	}
107 107
 
108 108
 	private static function maybe_clear_value_for_default_blank_setting( $field, &$value ) {
109 109
 		if ( FrmField::is_option_true_in_object( $field, 'default_blank' ) && $value == $field->default_value ) {
@@ -113,32 +113,32 @@  discard block
 block discarded – undo
113 113
 
114 114
 	public static function validate_url_field( &$errors, $field, &$value, $args ) {
115 115
 		if ( $value == '' || ! in_array( $field->type, array( 'website', 'url', 'image' ) ) ) {
116
-            return;
117
-        }
116
+			return;
117
+		}
118 118
 
119
-        if ( trim($value) == 'http://' ) {
120
-            $value = '';
121
-        } else {
122
-            $value = esc_url_raw( $value );
119
+		if ( trim($value) == 'http://' ) {
120
+			$value = '';
121
+		} else {
122
+			$value = esc_url_raw( $value );
123 123
 			$value = preg_match( '/^(https?|ftps?|mailto|news|feed|telnet):/is', $value ) ? $value : 'http://' . $value;
124
-        }
124
+		}
125 125
 
126
-        // validate the url format
126
+		// validate the url format
127 127
 		if ( ! preg_match('/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value) ) {
128 128
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
129 129
 		}
130
-    }
130
+	}
131 131
 
132 132
 	public static function validate_email_field( &$errors, $field, $value, $args ) {
133
-        if ( $value == '' || $field->type != 'email' ) {
134
-            return;
135
-        }
133
+		if ( $value == '' || $field->type != 'email' ) {
134
+			return;
135
+		}
136 136
 
137
-        //validate the email format
138
-        if ( ! is_email($value) ) {
137
+		//validate the email format
138
+		if ( ! is_email($value) ) {
139 139
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
140
-        }
141
-    }
140
+		}
141
+	}
142 142
 
143 143
 	public static function validate_number_field( &$errors, $field, $value, $args ) {
144 144
 		//validate the number format
@@ -232,9 +232,9 @@  discard block
 block discarded – undo
232 232
 	}
233 233
 
234 234
 	public static function validate_recaptcha( &$errors, $field, $args ) {
235
-        if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) {
236
-            return;
237
-        }
235
+		if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) {
236
+			return;
237
+		}
238 238
 
239 239
 		$frm_settings = FrmAppHelper::get_settings();
240 240
 		if ( empty( $frm_settings->pubkey ) ) {
@@ -242,61 +242,61 @@  discard block
 block discarded – undo
242 242
 			return;
243 243
 		}
244 244
 
245
-        if ( ! isset($_POST['g-recaptcha-response']) ) {
246
-            // If captcha is missing, check if it was already verified
245
+		if ( ! isset($_POST['g-recaptcha-response']) ) {
246
+			// If captcha is missing, check if it was already verified
247 247
 			if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) {
248
-                // There was no captcha submitted
248
+				// There was no captcha submitted
249 249
 				$errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' );
250
-            }
251
-            return;
252
-        }
250
+			}
251
+			return;
252
+		}
253 253
 
254
-        $arg_array = array(
255
-            'body'      => array(
254
+		$arg_array = array(
255
+			'body'      => array(
256 256
 				'secret'   => $frm_settings->privkey,
257 257
 				'response' => $_POST['g-recaptcha-response'],
258 258
 				'remoteip' => FrmAppHelper::get_ip_address(),
259 259
 			),
260 260
 		);
261
-        $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
262
-        $response = json_decode(wp_remote_retrieve_body( $resp ), true);
261
+		$resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
262
+		$response = json_decode(wp_remote_retrieve_body( $resp ), true);
263 263
 
264
-        if ( isset( $response['success'] ) && ! $response['success'] ) {
265
-            // What happens when the CAPTCHA was entered incorrectly
264
+		if ( isset( $response['success'] ) && ! $response['success'] ) {
265
+			// What happens when the CAPTCHA was entered incorrectly
266 266
 			$errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
267
-        } else if ( is_wp_error( $resp ) ) {
267
+		} else if ( is_wp_error( $resp ) ) {
268 268
 			$error_string = $resp->get_error_message();
269 269
 			$errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' );
270 270
 			$errors[ 'field' . $args['id'] ] .= ' ' . $error_string;
271
-        }
272
-    }
273
-
274
-    /**
275
-     * check for spam
276
-     * @param boolean $exclude
277
-     * @param array $values
278
-     * @param array $errors by reference
279
-     */
280
-    public static function spam_check( $exclude, $values, &$errors ) {
281
-        if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
282
-            // only check spam if there are no other errors
283
-            return;
284
-        }
271
+		}
272
+	}
273
+
274
+	/**
275
+	 * check for spam
276
+	 * @param boolean $exclude
277
+	 * @param array $values
278
+	 * @param array $errors by reference
279
+	 */
280
+	public static function spam_check( $exclude, $values, &$errors ) {
281
+		if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
282
+			// only check spam if there are no other errors
283
+			return;
284
+		}
285 285
 
286 286
 		if ( self::is_honeypot_spam() || self::is_spam_bot() ) {
287 287
 			$errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
288 288
 		}
289 289
 
290
-    	if ( self::blacklist_check( $values ) ) {
291
-            $errors['spam'] = __( 'Your entry appears to be blacklist spam!', 'formidable' );
292
-    	}
290
+		if ( self::blacklist_check( $values ) ) {
291
+			$errors['spam'] = __( 'Your entry appears to be blacklist spam!', 'formidable' );
292
+		}
293 293
 
294
-        if ( self::is_akismet_spam( $values ) ) {
294
+		if ( self::is_akismet_spam( $values ) ) {
295 295
 			if ( self::is_akismet_enabled_for_user( $values['form_id'] ) ) {
296 296
 				$errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
297 297
 			}
298
-	    }
299
-    }
298
+		}
299
+	}
300 300
 
301 301
 	private static function is_honeypot_spam() {
302 302
 		$honeypot_value = FrmAppHelper::get_param( 'frm_verify', '', 'get', 'sanitize_text_field' );
@@ -318,15 +318,15 @@  discard block
 block discarded – undo
318 318
 		return ( isset( $form->options['akismet'] ) && ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] != 'logged' || ! is_user_logged_in() ) );
319 319
 	}
320 320
 
321
-    public static function blacklist_check( $values ) {
322
-        if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
323
-            return false;
324
-        }
321
+	public static function blacklist_check( $values ) {
322
+		if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
323
+			return false;
324
+		}
325 325
 
326
-    	$mod_keys = trim( get_option( 'blacklist_keys' ) );
327
-    	if ( empty( $mod_keys ) ) {
328
-    		return false;
329
-    	}
326
+		$mod_keys = trim( get_option( 'blacklist_keys' ) );
327
+		if ( empty( $mod_keys ) ) {
328
+			return false;
329
+		}
330 330
 
331 331
 		$content = FrmEntriesHelper::entry_array_to_string( $values );
332 332
 		if ( empty( $content ) ) {
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 		$user_info = self::get_spam_check_user_info( $values );
339 339
 
340 340
 		return wp_blacklist_check( $user_info['comment_author'], $user_info['comment_author_email'], $user_info['comment_author_url'], $content, $ip, $user_agent );
341
-    }
341
+	}
342 342
 
343 343
 	/**
344 344
 	 * Check entries for Akismet spam
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -5,12 +5,12 @@  discard block
 block discarded – undo
5 5
         FrmEntry::sanitize_entry_post( $values );
6 6
         $errors = array();
7 7
 
8
-        if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
8
+        if ( ! isset( $values['form_id'] ) || ! isset( $values['item_meta'] ) ) {
9 9
             $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
10 10
             return $errors;
11 11
         }
12 12
 
13
-		if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) {
13
+		if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values['frm_submit_entry_' . $values['form_id']] ) || ! wp_verify_nonce( $values['frm_submit_entry_' . $values['form_id']], 'frm_submit_entry_nonce' ) ) ) {
14 14
             $errors['form'] = __( 'You do not have permission to do that', 'formidable' );
15 15
         }
16 16
 
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
         );
68 68
         $args = wp_parse_args( $args, $defaults );
69 69
 
70
-        if ( empty($args['parent_field_id']) ) {
71
-			$value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
70
+        if ( empty( $args['parent_field_id'] ) ) {
71
+			$value = isset( $values['item_meta'][$args['id']] ) ? $values['item_meta'][$args['id']] : '';
72 72
         } else {
73 73
             // value is from a nested form
74 74
             $value = $values;
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
 		self::maybe_clear_value_for_default_blank_setting( $posted_field, $value );
81 81
 
82 82
 		// Reset arrays with only one value if it's not a field where array keys need to be preserved
83
-		if ( is_array($value) && count( $value ) == 1 && isset( $value[0] ) ) {
84
-			$value = reset($value);
83
+		if ( is_array( $value ) && count( $value ) == 1 && isset( $value[0] ) ) {
84
+			$value = reset( $value );
85 85
 		}
86 86
 
87 87
         if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
88
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
88
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
89 89
         } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
90 90
             $_POST['item_name'] = $value;
91 91
         }
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 			self::validate_phone_field( $errors, $posted_field, $value, $args );
98 98
 		}
99 99
 
100
-        FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
100
+        FrmEntriesHelper::set_posted_value( $posted_field, $value, $args );
101 101
 
102
-        self::validate_recaptcha($errors, $posted_field, $args);
102
+        self::validate_recaptcha( $errors, $posted_field, $args );
103 103
 
104 104
 		$errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args );
105 105
 		$errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args );
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
             return;
117 117
         }
118 118
 
119
-        if ( trim($value) == 'http://' ) {
119
+        if ( trim( $value ) == 'http://' ) {
120 120
             $value = '';
121 121
         } else {
122 122
             $value = esc_url_raw( $value );
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
         }
125 125
 
126 126
         // validate the url format
127
-		if ( ! preg_match('/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value) ) {
128
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
127
+		if ( ! preg_match( '/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value ) ) {
128
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
129 129
 		}
130 130
     }
131 131
 
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
         }
136 136
 
137 137
         //validate the email format
138
-        if ( ! is_email($value) ) {
139
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
138
+        if ( ! is_email( $value ) ) {
139
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
140 140
         }
141 141
     }
142 142
 
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 			return;
147 147
 		}
148 148
 
149
-		if ( ! is_numeric( $value) ) {
150
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
149
+		if ( ! is_numeric( $value ) ) {
150
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
151 151
 		}
152 152
 
153 153
 		// validate number settings
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
 			if ( $frm_settings->use_html && isset( $field->field_options['minnum'] ) && isset( $field->field_options['maxnum'] ) ) {
158 158
 				//minnum maxnum
159 159
 				if ( (float) $value < $field->field_options['minnum'] ) {
160
-					$errors[ 'field' . $args['id'] ] = __( 'Please select a higher number', 'formidable' );
160
+					$errors['field' . $args['id']] = __( 'Please select a higher number', 'formidable' );
161 161
 				} else if ( (float) $value > $field->field_options['maxnum'] ) {
162
-					$errors[ 'field' . $args['id'] ] = __( 'Please select a lower number', 'formidable' );
162
+					$errors['field' . $args['id']] = __( 'Please select a lower number', 'formidable' );
163 163
 				}
164 164
 			}
165 165
 		}
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 			$pattern = self::phone_format( $field );
172 172
 
173 173
 			if ( ! preg_match( $pattern, $value ) ) {
174
-				$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
174
+				$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
175 175
 			}
176 176
 		}
177 177
 	}
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
 			return;
243 243
 		}
244 244
 
245
-        if ( ! isset($_POST['g-recaptcha-response']) ) {
245
+        if ( ! isset( $_POST['g-recaptcha-response'] ) ) {
246 246
             // If captcha is missing, check if it was already verified
247 247
 			if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) {
248 248
                 // There was no captcha submitted
249
-				$errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' );
249
+				$errors['field' . $args['id']] = __( 'The captcha is missing from this form', 'formidable' );
250 250
             }
251 251
             return;
252 252
         }
@@ -259,15 +259,15 @@  discard block
 block discarded – undo
259 259
 			),
260 260
 		);
261 261
         $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
262
-        $response = json_decode(wp_remote_retrieve_body( $resp ), true);
262
+        $response = json_decode( wp_remote_retrieve_body( $resp ), true );
263 263
 
264 264
         if ( isset( $response['success'] ) && ! $response['success'] ) {
265 265
             // What happens when the CAPTCHA was entered incorrectly
266
-			$errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
266
+			$errors['field' . $args['id']] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
267 267
         } else if ( is_wp_error( $resp ) ) {
268 268
 			$error_string = $resp->get_error_message();
269
-			$errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' );
270
-			$errors[ 'field' . $args['id'] ] .= ' ' . $error_string;
269
+			$errors['field' . $args['id']] = __( 'There was a problem verifying your recaptcha', 'formidable' );
270
+			$errors['field' . $args['id']] .= ' ' . $error_string;
271 271
         }
272 272
     }
273 273
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 
311 311
 	private static function is_akismet_spam( $values ) {
312 312
 		global $wpcom_api_key;
313
-		return ( is_callable('Akismet::http_post') && ( get_option('wordpress_api_key') || $wpcom_api_key ) && self::akismet( $values ) );
313
+		return ( is_callable( 'Akismet::http_post' ) && ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) && self::akismet( $values ) );
314 314
 	}
315 315
 
316 316
 	private static function is_akismet_enabled_for_user( $form_id ) {
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	}
320 320
 
321 321
     public static function blacklist_check( $values ) {
322
-        if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
322
+        if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) {
323 323
             return false;
324 324
         }
325 325
 
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 		$datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' );
376 376
 		$datas['referrer'] = isset( $_SERVER['HTTP_REFERER'] ) ? FrmAppHelper::get_server_value( 'HTTP_REFERER' ) : false;
377 377
 		$datas['blog_lang'] = get_locale();
378
-		$datas['blog_charset'] = get_option('blog_charset');
378
+		$datas['blog_charset'] = get_option( 'blog_charset' );
379 379
 
380 380
 		if ( akismet_test_mode() ) {
381 381
 			$datas['is_test'] = 'true';
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 
430 430
 			// Send any potentially useful $_SERVER vars, but avoid sending junk we don't need.
431 431
 			if ( $include_value ) {
432
-				$datas[ $key ] = $value;
432
+				$datas[$key] = $value;
433 433
 			}
434 434
 			unset( $key, $value );
435 435
 		}
Please login to merge, or discard this patch.