Completed
Push — master ( cbe6b2...d6428c )
by Jamie
03:34
created
classes/models/FrmField.php 1 patch
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 	static $transient_size = 200;
9 9
 
10 10
 	public static function field_selection() {
11
-		$fields = apply_filters('frm_available_fields', array(
11
+		$fields = apply_filters( 'frm_available_fields', array(
12 12
 			'text'      => __( 'Single Line Text', 'formidable' ),
13 13
 			'textarea'  => __( 'Paragraph Text', 'formidable' ),
14 14
 			'checkbox'  => __( 'Checkboxes', 'formidable' ),
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
 			'email'     => __( 'Email Address', 'formidable' ),
18 18
 			'url'       => __( 'Website/URL', 'formidable' ),
19 19
 			'captcha'   => __( 'reCAPTCHA', 'formidable' ),
20
-		));
20
+		) );
21 21
 
22 22
 		return $fields;
23 23
 	}
24 24
 
25 25
 	public static function pro_field_selection() {
26
-		return apply_filters('frm_pro_available_fields', array(
26
+		return apply_filters( 'frm_pro_available_fields', array(
27 27
 			'end_divider' => array(
28 28
 				'name'  => __( 'End Section', 'formidable' ),
29 29
 				'switch_from' => 'divider',
@@ -48,36 +48,36 @@  discard block
 block discarded – undo
48 48
 			'tag'       => __( 'Tags', 'formidable' ),
49 49
 			'credit_card' => __( 'Credit Card', 'formidable' ),
50 50
 			'address'   => __( 'Address', 'formidable' ),
51
-		));
51
+		) );
52 52
 	}
53 53
 
54 54
     public static function create( $values, $return = true ) {
55 55
         global $wpdb, $frm_duplicate_ids;
56 56
 
57 57
         $new_values = array();
58
-        $key = isset($values['field_key']) ? $values['field_key'] : $values['name'];
58
+        $key = isset( $values['field_key'] ) ? $values['field_key'] : $values['name'];
59 59
 		$new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' );
60 60
 
61 61
 		foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) {
62
-			$new_values[ $col ] = $values[ $col ];
62
+			$new_values[$col] = $values[$col];
63 63
         }
64 64
 
65 65
         $new_values['options'] = $values['options'];
66 66
 
67
-        $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null;
68
-        $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0;
69
-        $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null;
67
+        $new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null;
68
+        $new_values['required'] = isset( $values['required'] ) ? (int) $values['required'] : 0;
69
+        $new_values['form_id'] = isset( $values['form_id'] ) ? (int) $values['form_id'] : null;
70 70
         $new_values['field_options'] = $values['field_options'];
71
-        $new_values['created_at'] = current_time('mysql', 1);
71
+        $new_values['created_at'] = current_time( 'mysql', 1 );
72 72
 
73 73
 		if ( isset( $values['id'] ) ) {
74
-			$frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key'];
75
-            $new_values = apply_filters('frm_duplicated_field', $new_values);
74
+			$frm_duplicate_ids[$values['field_key']] = $new_values['field_key'];
75
+            $new_values = apply_filters( 'frm_duplicated_field', $new_values );
76 76
         }
77 77
 
78 78
 		foreach ( $new_values as $k => $v ) {
79 79
             if ( is_array( $v ) ) {
80
-				$new_values[ $k ] = serialize( $v );
80
+				$new_values[$k] = serialize( $v );
81 81
 			}
82 82
             unset( $k, $v );
83 83
         }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
 		if ( $query_results ) {
100 100
 			if ( isset( $values['id'] ) ) {
101
-				$frm_duplicate_ids[ $values['id'] ] = $new_id;
101
+				$frm_duplicate_ids[$values['id']] = $new_id;
102 102
 			}
103 103
 			return $new_id;
104 104
 		} else {
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 		$fields = self::getAll( $where, 'field_order', '', $blog_id );
114 114
 
115 115
         foreach ( (array) $fields as $field ) {
116
-            $new_key = ($copy_keys) ? $field->field_key : '';
117
-            if ( $copy_keys && substr($field->field_key, -1) == 2 ) {
118
-                $new_key = rtrim($new_key, 2);
116
+            $new_key = ( $copy_keys ) ? $field->field_key : '';
117
+            if ( $copy_keys && substr( $field->field_key, -1 ) == 2 ) {
118
+                $new_key = rtrim( $new_key, 2 );
119 119
             }
120 120
 
121 121
             $values = array();
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
 				$values['form_id'] = $new_repeat_form_id;
139 139
 			}
140 140
 
141
-            $values = apply_filters('frm_duplicated_field', $values);
142
-            $new_id = self::create($values);
143
-            $frm_duplicate_ids[ $field->id ] = $new_id;
144
-            $frm_duplicate_ids[ $field->field_key ] = $new_id;
145
-            unset($field);
141
+            $values = apply_filters( 'frm_duplicated_field', $values );
142
+            $new_id = self::create( $values );
143
+            $frm_duplicate_ids[$field->id] = $new_id;
144
+            $frm_duplicate_ids[$field->field_key] = $new_id;
145
+            unset( $field );
146 146
         }
147 147
     }
148 148
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 			$values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id );
156 156
 		}
157 157
 
158
-        if ( isset($values['required']) ) {
158
+        if ( isset( $values['required'] ) ) {
159 159
             $values['required'] = (int) $values['required'];
160 160
         }
161 161
 
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
 
164 164
 		// serialize array values
165 165
 		foreach ( array( 'default_value', 'field_options', 'options' ) as $opt ) {
166
-			if ( isset( $values[ $opt ] ) && is_array( $values[ $opt ] ) ) {
167
-				$values[ $opt ] = serialize( $values[ $opt ] );
166
+			if ( isset( $values[$opt] ) && is_array( $values[$opt] ) ) {
167
+				$values[$opt] = serialize( $values[$opt] );
168 168
 			}
169 169
 		}
170 170
 
@@ -174,18 +174,18 @@  discard block
 block discarded – undo
174 174
 		if ( isset( $values['form_id'] ) ) {
175 175
             $form_id = absint( $values['form_id'] );
176 176
 		} else {
177
-            $field = self::getOne($id);
177
+            $field = self::getOne( $id );
178 178
             if ( $field ) {
179 179
                 $form_id = $field->form_id;
180 180
             }
181
-            unset($field);
181
+            unset( $field );
182 182
         }
183
-        unset($values);
183
+        unset( $values );
184 184
 
185 185
 		if ( $query_results ) {
186 186
             wp_cache_delete( $id, 'frm_field' );
187 187
             if ( $form_id ) {
188
-                self::delete_form_transient($form_id);
188
+                self::delete_form_transient( $form_id );
189 189
             }
190 190
         }
191 191
 
@@ -232,12 +232,12 @@  discard block
 block discarded – undo
232 232
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_' . $form_id . 'ex%', '_transient_frm_form_fields_' . $form_id . 'ex%', '_transient_timeout_frm_form_fields_' . $form_id . 'in%', '_transient_frm_form_fields_' . $form_id . 'in%' ) );
233 233
 
234 234
 		$cache_key = serialize( array( 'fi.form_id' => $form_id ) ) . 'field_orderlb';
235
-        wp_cache_delete($cache_key, 'frm_field');
235
+        wp_cache_delete( $cache_key, 'frm_field' );
236 236
 
237 237
 		// this cache key is autogenerated in FrmDb::get_var
238 238
 		wp_cache_delete( '(__fi.form_id=%d_OR_fr.parent_form_id=%d_)__' . $form_id . '_' . $form_id . '_ORDER_BY_field_orderfi.*__fr.name_as_form_name_results', 'frm_field' );
239 239
 
240
-        $form = FrmForm::getOne($form_id);
240
+        $form = FrmForm::getOne( $form_id );
241 241
         if ( $form && $form->parent_form_id ) {
242 242
             self::delete_form_transient( $form->parent_form_id );
243 243
         }
@@ -259,16 +259,16 @@  discard block
 block discarded – undo
259 259
 
260 260
         global $wpdb;
261 261
 
262
-        $where = is_numeric($id) ? 'id=%d' : 'field_key=%s';
262
+        $where = is_numeric( $id ) ? 'id=%d' : 'field_key=%s';
263 263
 		$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id );
264 264
 
265 265
         $results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
266 266
 
267
-        if ( empty($results) ) {
267
+        if ( empty( $results ) ) {
268 268
             return $results;
269 269
         }
270 270
 
271
-        if ( is_numeric($id) ) {
271
+        if ( is_numeric( $id ) ) {
272 272
             wp_cache_set( $results->field_key, $results, 'frm_field' );
273 273
         } else if ( $results ) {
274 274
             wp_cache_set( $results->id, $results, 'frm_field' );
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 
277 277
 		self::prepare_options( $results );
278 278
 
279
-        return stripslashes_deep($results);
279
+        return stripslashes_deep( $results );
280 280
     }
281 281
 
282 282
     /**
@@ -309,20 +309,20 @@  discard block
 block discarded – undo
309 309
                     continue;
310 310
                 }
311 311
 
312
-				$fields[ $result->id ] = $result;
313
-                $count++;
312
+				$fields[$result->id] = $result;
313
+                $count ++;
314 314
                 if ( $limit == 1 ) {
315 315
                     $fields = $result;
316 316
                     break;
317 317
                 }
318 318
 
319
-                if ( ! empty($limit) && $count >= $limit ) {
319
+                if ( ! empty( $limit ) && $count >= $limit ) {
320 320
                     break;
321 321
                 }
322 322
 
323
-                unset($result);
323
+                unset( $result );
324 324
             }
325
-            return stripslashes_deep($fields);
325
+            return stripslashes_deep( $fields );
326 326
         }
327 327
 
328 328
         self::$use_cache = false;
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 		self::maybe_include_repeating_fields( $inc_sub, $where );
332 332
 		$results = self::getAll( $where, 'field_order', $limit );
333 333
         self::$use_cache = true;
334
-        self::include_sub_fields($results, $inc_sub, $type);
334
+        self::include_sub_fields( $results, $inc_sub, $type );
335 335
 
336 336
         return $results;
337 337
     }
@@ -343,15 +343,15 @@  discard block
 block discarded – undo
343 343
 
344 344
 		$results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) );
345 345
 		if ( ! empty( $results ) ) {
346
-            if ( empty($limit) ) {
346
+            if ( empty( $limit ) ) {
347 347
 				return $results;
348 348
             }
349 349
 
350 350
             $fields = array();
351 351
             $count = 0;
352 352
             foreach ( $results as $result ) {
353
-				$fields[ $result->id ] = $result;
354
-                if ( ! empty($limit) && $count >= $limit ) {
353
+				$fields[$result->id] = $result;
354
+                if ( ! empty( $limit ) && $count >= $limit ) {
355 355
                     break;
356 356
                 }
357 357
             }
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 
370 370
 		self::include_sub_fields( $results, $inc_embed, 'all' );
371 371
 
372
-        if ( empty($limit) ) {
372
+        if ( empty( $limit ) ) {
373 373
 			self::set_field_transient( $results, $form_id, 0, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) );
374 374
         }
375 375
 
@@ -398,22 +398,22 @@  discard block
 block discarded – undo
398 398
         $form_fields = $results;
399 399
 		$index_offset = 1;
400 400
         foreach ( $form_fields as $k => $field ) {
401
-            if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) {
401
+            if ( 'form' != $field->type || ! isset( $field->field_options['form_select'] ) ) {
402 402
                 continue;
403 403
             }
404 404
 
405 405
             if ( $type == 'all' ) {
406 406
                 $sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
407 407
             } else {
408
-                $sub_fields = self::get_all_types_in_form($field->form_id, $type);
408
+                $sub_fields = self::get_all_types_in_form( $field->form_id, $type );
409 409
             }
410 410
 
411
-            if ( ! empty($sub_fields) ) {
411
+            if ( ! empty( $sub_fields ) ) {
412 412
 				$index = $k + $index_offset;
413 413
 				$index_offset += count( $sub_fields );
414
-				array_splice($results, $index, 0, $sub_fields);
414
+				array_splice( $results, $index, 0, $sub_fields );
415 415
             }
416
-            unset($field, $sub_fields);
416
+            unset( $field, $sub_fields );
417 417
         }
418 418
     }
419 419
 
@@ -421,9 +421,9 @@  discard block
 block discarded – undo
421 421
 		$cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id;
422 422
         if ( self::$use_cache ) {
423 423
             // make sure old cache doesn't get saved as a transient
424
-            $results = wp_cache_get($cache_key, 'frm_field');
424
+            $results = wp_cache_get( $cache_key, 'frm_field' );
425 425
             if ( false !== $results ) {
426
-                return stripslashes_deep($results);
426
+                return stripslashes_deep( $results );
427 427
             }
428 428
         }
429 429
 
@@ -448,16 +448,16 @@  discard block
 block discarded – undo
448 448
 			$order_by = ' ORDER BY ' . $order_by;
449 449
 		}
450 450
 
451
-        $limit = FrmAppHelper::esc_limit($limit);
451
+        $limit = FrmAppHelper::esc_limit( $limit );
452 452
 
453 453
         $query = "SELECT fi.*, fr.name as form_name  FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
454 454
         $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results';
455 455
 
456
-        if ( is_array($where) ) {
456
+        if ( is_array( $where ) ) {
457 457
             $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type );
458 458
 		} else {
459 459
 			// if the query is not an array, then it has already been prepared
460
-            $query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
460
+            $query .= FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
461 461
 
462 462
 			$function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results';
463 463
 			$results = $wpdb->$function_name( $query );
@@ -480,9 +480,9 @@  discard block
 block discarded – undo
480 480
 				wp_cache_set( $result->id, $result, 'frm_field' );
481 481
 				wp_cache_set( $result->field_key, $result, 'frm_field' );
482 482
 
483
-				$results[ $r_key ]->field_options = maybe_unserialize( $result->field_options );
484
-				$results[ $r_key ]->options = maybe_unserialize( $result->options );
485
-				$results[ $r_key ]->default_value = maybe_unserialize( $result->default_value );
483
+				$results[$r_key]->field_options = maybe_unserialize( $result->field_options );
484
+				$results[$r_key]->options = maybe_unserialize( $result->options );
485
+				$results[$r_key]->default_value = maybe_unserialize( $result->default_value );
486 486
 
487 487
 				unset( $r_key, $result );
488 488
 			}
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
 	private static function prepare_options( &$results ) {
502 502
 		$results->field_options = maybe_unserialize( $results->field_options );
503 503
 
504
-		$results->options = maybe_unserialize($results->options);
505
-		$results->default_value = maybe_unserialize($results->default_value);
504
+		$results->options = maybe_unserialize( $results->options );
505
+		$results->default_value = maybe_unserialize( $results->default_value );
506 506
 	}
507 507
 
508 508
 	/**
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 
530 530
 			if ( count( $next_fields ) >= self::$transient_size ) {
531 531
 				// if this transient is full, check for another
532
-				$next++;
532
+				$next ++;
533 533
 				self::get_next_transient( $fields, $base_name, $next );
534 534
 			}
535 535
 		}
@@ -555,14 +555,14 @@  discard block
 block discarded – undo
555 555
 				return;
556 556
 			}
557 557
 
558
-			$next++;
558
+			$next ++;
559 559
 		}
560 560
 	}
561 561
 
562 562
 	public static function getIds( $where = '', $order_by = '', $limit = '' ) {
563 563
 		_deprecated_function( __FUNCTION__, '2.0' );
564 564
         global $wpdb;
565
-        if ( ! empty($order_by) && ! strpos($order_by, 'ORDER BY') !== false ) {
565
+        if ( ! empty( $order_by ) && ! strpos( $order_by, 'ORDER BY' ) !== false ) {
566 566
 			$order_by = ' ORDER BY ' . $order_by;
567 567
         }
568 568
 
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 
573 573
         $method = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'get_var' : 'get_col';
574 574
 		$cache_key = 'getIds_' . maybe_serialize( $where ) . $order_by . $limit;
575
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_field', $query, $method);
575
+        $results = FrmAppHelper::check_cache( $cache_key, 'frm_field', $query, $method );
576 576
 
577 577
         return $results;
578 578
     }
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 			$is_multi_value_field = (
604 604
 				$field['type'] == 'checkbox' ||
605 605
 				$field['type'] == 'address' ||
606
-				( $field['type'] == 'data' && isset($field['data_type']) && $field['data_type'] == 'checkbox' ) ||
606
+				( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'checkbox' ) ||
607 607
 				self::is_multiple_select( $field )
608 608
 			);
609 609
 
@@ -627,9 +627,9 @@  discard block
 block discarded – undo
627 627
 	 */
628 628
 	public static function is_multiple_select( $field ) {
629 629
 		if ( is_array( $field ) ) {
630
-			return self::is_option_true( $field, 'multiple' ) && ( ( $field['type'] == 'select' || ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'select') ) );
630
+			return self::is_option_true( $field, 'multiple' ) && ( ( $field['type'] == 'select' || ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'select' ) ) );
631 631
 		} else {
632
-			return self::is_option_true( $field, 'multiple' ) && ( ( $field->type == 'select' || ( $field->type == 'data' && isset($field->field_options['data_type'] ) && $field->field_options['data_type'] == 'select') ) );
632
+			return self::is_option_true( $field, 'multiple' ) && ( ( $field->type == 'select' || ( $field->type == 'data' && isset( $field->field_options['data_type'] ) && $field->field_options['data_type'] == 'select' ) ) );
633 633
 		}
634 634
 	}
635 635
 
@@ -676,23 +676,23 @@  discard block
 block discarded – undo
676 676
 	}
677 677
 
678 678
 	public static function is_option_true_in_array( $field, $option ) {
679
-		return isset( $field[ $option ] ) && $field[ $option ];
679
+		return isset( $field[$option] ) && $field[$option];
680 680
 	}
681 681
 
682 682
 	public static function is_option_true_in_object( $field, $option ) {
683
-		return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ];
683
+		return isset( $field->field_options[$option] ) && $field->field_options[$option];
684 684
 	}
685 685
 
686 686
 	public static function is_option_empty_in_array( $field, $option ) {
687
-		return ! isset( $field[ $option ] ) || empty( $field[ $option ] );
687
+		return ! isset( $field[$option] ) || empty( $field[$option] );
688 688
 	}
689 689
 
690 690
 	public static function is_option_empty_in_object( $field, $option ) {
691
-		return ! isset( $field->field_options[ $option ] ) || empty( $field->field_options[ $option ] );
691
+		return ! isset( $field->field_options[$option] ) || empty( $field->field_options[$option] );
692 692
 	}
693 693
 
694 694
 	public static function is_option_value_in_object( $field, $option ) {
695
-		return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ] != '';
695
+		return isset( $field->field_options[$option] ) && $field->field_options[$option] != '';
696 696
 	}
697 697
 
698 698
 	/**
@@ -708,11 +708,11 @@  discard block
 block discarded – undo
708 708
 	}
709 709
 
710 710
 	public static function get_option_in_array( $field, $option ) {
711
-		return $field[ $option ];
711
+		return $field[$option];
712 712
 	}
713 713
 
714 714
 	public static function get_option_in_object( $field, $option ) {
715
-		return isset( $field->field_options[ $option ] ) ? $field->field_options[ $option ] : '';
715
+		return isset( $field->field_options[$option] ) ? $field->field_options[$option] : '';
716 716
 	}
717 717
 
718 718
 	/**
Please login to merge, or discard this patch.
classes/models/FrmEntryValidate.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -7,20 +7,20 @@  discard block
 block discarded – undo
7 7
         FrmEntry::sanitize_entry_post( $values );
8 8
         $errors = array();
9 9
 
10
-        if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
10
+        if ( ! isset( $values['form_id'] ) || ! isset( $values['item_meta'] ) ) {
11 11
             $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
12 12
             return $errors;
13 13
         }
14 14
 
15
-		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' ) ) ) {
15
+		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' ) ) ) {
16 16
             $errors['form'] = __( 'You do not have permission to do that', 'formidable' );
17 17
         }
18 18
 
19
-        if ( ! isset($values['item_key']) || $values['item_key'] == '' ) {
19
+        if ( ! isset( $values['item_key'] ) || $values['item_key'] == '' ) {
20 20
 			$_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' );
21 21
         }
22 22
 
23
-        $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) );
23
+        $where = apply_filters( 'frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) );
24 24
 		// Don't get subfields
25 25
 		$where['fr.parent_form_id'] = array( null, 0 );
26 26
 		// Don't get excluded fields (like file upload fields in the ajax validation)
@@ -28,20 +28,20 @@  discard block
 block discarded – undo
28 28
 			$where['fi.type not'] = $exclude;
29 29
 		}
30 30
 
31
-        $posted_fields = FrmField::getAll($where, 'field_order');
31
+        $posted_fields = FrmField::getAll( $where, 'field_order' );
32 32
 
33 33
         // Pass exclude value to validate_field function so it can be used for repeating sections
34 34
         $args = array( 'exclude' => $exclude );
35 35
 
36 36
         foreach ( $posted_fields as $posted_field ) {
37
-            self::validate_field($posted_field, $errors, $values, $args);
38
-            unset($posted_field);
37
+            self::validate_field( $posted_field, $errors, $values, $args );
38
+            unset( $posted_field );
39 39
         }
40 40
 
41 41
         // check for spam
42 42
         self::spam_check( $exclude, $values, $errors );
43 43
 
44
-        $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') );
44
+        $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact( 'exclude' ) );
45 45
 
46 46
         return $errors;
47 47
     }
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
         );
56 56
         $args = wp_parse_args( $args, $defaults );
57 57
 
58
-        if ( empty($args['parent_field_id']) ) {
59
-			$value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
58
+        if ( empty( $args['parent_field_id'] ) ) {
59
+			$value = isset( $values['item_meta'][$args['id']] ) ? $values['item_meta'][$args['id']] : '';
60 60
         } else {
61 61
             // value is from a nested form
62 62
             $value = $values;
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
 
70 70
 		// Check for an array with only one value
71 71
 		// Don't reset values in "Other" fields because array keys need to be preserved
72
-		if ( is_array($value) && count( $value ) == 1 && $args['other'] !== true ) {
73
-			$value = reset($value);
72
+		if ( is_array( $value ) && count( $value ) == 1 && $args['other'] !== true ) {
73
+			$value = reset( $value );
74 74
 		}
75 75
 
76 76
         if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
77
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
77
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
78 78
         } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
79 79
             $_POST['item_name'] = $value;
80 80
         }
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
 			self::validate_phone_field( $errors, $posted_field, $value, $args );
87 87
 		}
88 88
 
89
-        FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
89
+        FrmEntriesHelper::set_posted_value( $posted_field, $value, $args );
90 90
 
91
-        self::validate_recaptcha($errors, $posted_field, $args);
91
+        self::validate_recaptcha( $errors, $posted_field, $args );
92 92
 
93
-        $errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args);
93
+        $errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args );
94 94
 		$errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args );
95 95
     }
96 96
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
             return;
106 106
         }
107 107
 
108
-        if ( trim($value) == 'http://' ) {
108
+        if ( trim( $value ) == 'http://' ) {
109 109
             $value = '';
110 110
         } else {
111 111
             $value = esc_url_raw( $value );
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
         }
114 114
 
115 115
         //validate the url format
116
-        if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) {
117
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
116
+        if ( ! preg_match( '/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value ) ) {
117
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
118 118
         }
119 119
     }
120 120
 
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
         }
125 125
 
126 126
         //validate the email format
127
-        if ( ! is_email($value) ) {
128
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
127
+        if ( ! is_email( $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
 			return;
136 136
 		}
137 137
 
138
-		if ( ! is_numeric( $value) ) {
139
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
138
+		if ( ! is_numeric( $value ) ) {
139
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
140 140
 		}
141 141
 
142 142
 		// validate number settings
@@ -146,9 +146,9 @@  discard block
 block discarded – undo
146 146
 			if ( $frm_settings->use_html && isset( $field->field_options['minnum'] ) && isset( $field->field_options['maxnum'] ) ) {
147 147
 				//minnum maxnum
148 148
 				if ( (float) $value < $field->field_options['minnum'] ) {
149
-					$errors[ 'field' . $args['id'] ] = __( 'Please select a higher number', 'formidable' );
149
+					$errors['field' . $args['id']] = __( 'Please select a higher number', 'formidable' );
150 150
 				} else if ( (float) $value > $field->field_options['maxnum'] ) {
151
-					$errors[ 'field' . $args['id'] ] = __( 'Please select a lower number', 'formidable' );
151
+					$errors['field' . $args['id']] = __( 'Please select a lower number', 'formidable' );
152 152
 				}
153 153
 			}
154 154
 		}
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 		$pattern = self::phone_format( $field );
163 163
 
164 164
 		if ( ! preg_match( $pattern, $value ) ) {
165
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
165
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
166 166
 		}
167 167
 	}
168 168
 
@@ -214,11 +214,11 @@  discard block
 block discarded – undo
214 214
 			return;
215 215
 		}
216 216
 
217
-        if ( ! isset($_POST['g-recaptcha-response']) ) {
217
+        if ( ! isset( $_POST['g-recaptcha-response'] ) ) {
218 218
             // If captcha is missing, check if it was already verified
219 219
 			if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) {
220 220
                 // There was no captcha submitted
221
-				$errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' );
221
+				$errors['field' . $args['id']] = __( 'The captcha is missing from this form', 'formidable' );
222 222
             }
223 223
             return;
224 224
         }
@@ -231,15 +231,15 @@  discard block
 block discarded – undo
231 231
 			),
232 232
 		);
233 233
         $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
234
-        $response = json_decode(wp_remote_retrieve_body( $resp ), true);
234
+        $response = json_decode( wp_remote_retrieve_body( $resp ), true );
235 235
 
236 236
         if ( isset( $response['success'] ) && ! $response['success'] ) {
237 237
             // What happens when the CAPTCHA was entered incorrectly
238
-			$errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
238
+			$errors['field' . $args['id']] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
239 239
         } else if ( is_wp_error( $resp ) ) {
240 240
 			$error_string = $resp->get_error_message();
241
-			$errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' );
242
-			$errors[ 'field' . $args['id'] ] .= ' ' . $error_string;
241
+			$errors['field' . $args['id']] = __( 'There was a problem verifying your recaptcha', 'formidable' );
242
+			$errors['field' . $args['id']] .= ' ' . $error_string;
243 243
         }
244 244
     }
245 245
 
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 
269 269
 	private static function is_akismet_spam( $values ) {
270 270
 		global $wpcom_api_key;
271
-		return ( is_callable('Akismet::http_post') && ( get_option('wordpress_api_key') || $wpcom_api_key ) && self::akismet( $values ) );
271
+		return ( is_callable( 'Akismet::http_post' ) && ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) && self::akismet( $values ) );
272 272
 	}
273 273
 
274 274
 	private static function is_akismet_enabled_for_user( $form_id ) {
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	}
278 278
 
279 279
     public static function blacklist_check( $values ) {
280
-        if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
280
+        if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) {
281 281
             return false;
282 282
         }
283 283
 
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
     		return false;
288 288
     	}
289 289
 
290
-    	$content = FrmEntriesHelper::entry_array_to_string($values);
290
+    	$content = FrmEntriesHelper::entry_array_to_string( $values );
291 291
 
292
-		if ( empty($content) ) {
292
+		if ( empty( $content ) ) {
293 293
 		    return false;
294 294
 		}
295 295
 
@@ -298,11 +298,11 @@  discard block
 block discarded – undo
298 298
     	foreach ( (array) $words as $word ) {
299 299
     		$word = trim( $word );
300 300
 
301
-    		if ( empty($word) ) {
301
+    		if ( empty( $word ) ) {
302 302
     			continue;
303 303
     		}
304 304
 
305
-    		if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) {
305
+    		if ( preg_match( '#' . preg_quote( $word, '#' ) . '#', $content ) ) {
306 306
     			return true;
307 307
     		}
308 308
     	}
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 			unset( $key, $data );
332 332
 		}
333 333
 
334
-        $response = Akismet::http_post($query_string, 'comment-check');
334
+        $response = Akismet::http_post( $query_string, 'comment-check' );
335 335
 
336 336
 		return ( is_array( $response ) && $response[1] == 'true' );
337 337
     }
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 
355 355
         foreach ( $_SERVER as $key => $value ) {
356 356
 			if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) {
357
-				$datas[ $key ] = wp_strip_all_tags( $value );
357
+				$datas[$key] = wp_strip_all_tags( $value );
358 358
             } else {
359
-				$datas[ $key ] = '';
359
+				$datas[$key] = '';
360 360
             }
361 361
 
362
-            unset($key, $value);
362
+            unset( $key, $value );
363 363
         }
364 364
     }
365 365
 }
Please login to merge, or discard this patch.