Completed
Push — master ( def3ec...12c13d )
by Stephanie
03:38
created
classes/models/FrmForm.php 1 patch
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
3
-    die('You are not allowed to call this page directly.');
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+    die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
6 6
 class FrmForm {
@@ -15,24 +15,24 @@  discard block
 block discarded – undo
15 15
 			'form_key'      => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ),
16 16
             'name'          => $values['name'],
17 17
             'description'   => $values['description'],
18
-            'status'        => isset($values['status']) ? $values['status'] : 'draft',
19
-            'logged_in'     => isset($values['logged_in']) ? $values['logged_in'] : 0,
20
-            'is_template'   => isset($values['is_template']) ? (int) $values['is_template'] : 0,
18
+            'status'        => isset( $values['status'] ) ? $values['status'] : 'draft',
19
+            'logged_in'     => isset( $values['logged_in'] ) ? $values['logged_in'] : 0,
20
+            'is_template'   => isset( $values['is_template'] ) ? (int) $values['is_template'] : 0,
21 21
 			'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0,
22
-            'editable'      => isset($values['editable']) ? (int) $values['editable'] : 0,
23
-            'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0,
24
-            'created_at'    => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1),
22
+            'editable'      => isset( $values['editable'] ) ? (int) $values['editable'] : 0,
23
+            'default_template' => isset( $values['default_template'] ) ? (int) $values['default_template'] : 0,
24
+            'created_at'    => isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ),
25 25
         );
26 26
 
27 27
         $options = array();
28 28
 		FrmFormsHelper::fill_form_options( $options, $values );
29 29
 
30
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
31
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
32
-        $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
30
+        $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' );
31
+        $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' );
32
+        $options['submit_html'] = isset( $values['options']['submit_html'] ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' );
33 33
 
34
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
35
-        $new_values['options'] = serialize($options);
34
+        $options = apply_filters( 'frm_form_options_before_update', $options, $values );
35
+        $new_values['options'] = serialize( $options );
36 36
 
37 37
         //if(isset($values['id']) && is_numeric($values['id']))
38 38
         //    $new_values['id'] = $values['id'];
@@ -67,22 +67,22 @@  discard block
 block discarded – undo
67 67
             'status'        => $template ? 'published' : 'draft',
68 68
             'logged_in'     => $values->logged_in ? $values->logged_in : 0,
69 69
             'editable'      => $values->editable ? $values->editable : 0,
70
-            'created_at'    => current_time('mysql', 1),
70
+            'created_at'    => current_time( 'mysql', 1 ),
71 71
             'is_template'   => $template ? 1 : 0,
72 72
         );
73 73
 
74 74
         if ( $blog_id ) {
75 75
             $new_values['status'] = 'published';
76
-            $new_options = maybe_unserialize($values->options);
77
-            $new_options['email_to'] = get_option('admin_email');
76
+            $new_options = maybe_unserialize( $values->options );
77
+            $new_options['email_to'] = get_option( 'admin_email' );
78 78
             $new_options['copy'] = false;
79 79
             $new_values['options'] = $new_options;
80 80
         } else {
81 81
             $new_values['options'] = $values->options;
82 82
         }
83 83
 
84
-        if ( is_array($new_values['options']) ) {
85
-            $new_values['options'] = serialize($new_values['options']);
84
+        if ( is_array( $new_values['options'] ) ) {
85
+            $new_values['options'] = serialize( $new_values['options'] );
86 86
         }
87 87
 
88 88
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 			self::clear_form_cache();
93 93
 
94 94
             $form_id = $wpdb->insert_id;
95
-            FrmField::duplicate($id, $form_id, $copy_keys, $blog_id);
95
+            FrmField::duplicate( $id, $form_id, $copy_keys, $blog_id );
96 96
 
97 97
             // update form settings after fields are created
98 98
 			do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) );
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
     }
104 104
 
105 105
 	public static function after_duplicate( $form_id, $values ) {
106
-        $new_opts = $values['options'] = maybe_unserialize($values['options']);
106
+        $new_opts = $values['options'] = maybe_unserialize( $values['options'] );
107 107
 
108
-        if ( isset($new_opts['success_msg']) ) {
109
-            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
108
+        if ( isset( $new_opts['success_msg'] ) ) {
109
+            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids( $new_opts['success_msg'] );
110 110
         }
111 111
 
112
-        $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
112
+        $new_opts = apply_filters( 'frm_after_duplicate_form_values', $new_opts, $form_id );
113 113
 
114 114
         if ( $new_opts != $values['options'] ) {
115 115
             global $wpdb;
@@ -127,17 +127,17 @@  discard block
 block discarded – undo
127 127
             $values['status'] = 'published';
128 128
         }
129 129
 
130
-        if ( isset($values['form_key']) ) {
130
+        if ( isset( $values['form_key'] ) ) {
131 131
 			$values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id );
132 132
         }
133 133
 
134 134
         $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
135 135
 
136
-        $new_values = self::set_update_options( array(), $values);
136
+        $new_values = self::set_update_options( array(), $values );
137 137
 
138 138
         foreach ( $values as $value_key => $value ) {
139
-            if ( in_array($value_key, $form_fields) ) {
140
-				$new_values[ $value_key ] = $value;
139
+            if ( in_array( $value_key, $form_fields ) ) {
140
+				$new_values[$value_key] = $value;
141 141
             }
142 142
         }
143 143
 
@@ -153,9 +153,9 @@  discard block
 block discarded – undo
153 153
         } else {
154 154
             $query_results = true;
155 155
         }
156
-        unset($new_values);
156
+        unset( $new_values );
157 157
 
158
-        $values = self::update_fields($id, $values);
158
+        $values = self::update_fields( $id, $values );
159 159
 
160 160
 		do_action( 'frm_update_form', $id, $values );
161 161
 		do_action( 'frm_update_form_' . $id, $values );
@@ -167,20 +167,20 @@  discard block
 block discarded – undo
167 167
      * @return array
168 168
      */
169 169
 	public static function set_update_options( $new_values, $values ) {
170
-        if ( ! isset($values['options']) ) {
170
+        if ( ! isset( $values['options'] ) ) {
171 171
             return $new_values;
172 172
         }
173 173
 
174 174
         $options = array();
175 175
 		FrmFormsHelper::fill_form_options( $options, $values );
176 176
 
177
-        $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
178
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
179
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
180
-        $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
177
+        $options['custom_style'] = isset( $values['options']['custom_style'] ) ? $values['options']['custom_style'] : 0;
178
+        $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' );
179
+        $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' );
180
+        $options['submit_html'] = ( isset( $values['options']['submit_html'] ) && $values['options']['submit_html'] != '' ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' );
181 181
 
182
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
183
-        $new_values['options'] = serialize($options);
182
+        $options = apply_filters( 'frm_form_options_before_update', $options, $values );
183
+        $new_values['options'] = serialize( $options );
184 184
 
185 185
         return $new_values;
186 186
     }
@@ -191,57 +191,57 @@  discard block
 block discarded – undo
191 191
      */
192 192
 	public static function update_fields( $id, $values ) {
193 193
 
194
-        if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
194
+        if ( ! isset( $values['options'] ) && ! isset( $values['item_meta'] ) && ! isset( $values['field_options'] ) ) {
195 195
             return $values;
196 196
         }
197 197
 
198
-        $all_fields = FrmField::get_all_for_form($id);
199
-        if ( empty($all_fields) ) {
198
+        $all_fields = FrmField::get_all_for_form( $id );
199
+        if ( empty( $all_fields ) ) {
200 200
             return $values;
201 201
         }
202 202
 
203
-        if ( ! isset($values['item_meta']) ) {
203
+        if ( ! isset( $values['item_meta'] ) ) {
204 204
             $values['item_meta'] = array();
205 205
         }
206 206
 
207 207
         $field_array = array();
208
-        $existing_keys = array_keys($values['item_meta']);
208
+        $existing_keys = array_keys( $values['item_meta'] );
209 209
         foreach ( $all_fields as $fid ) {
210
-            if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
211
-				$values['item_meta'][ $fid->id ] = '';
210
+            if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) {
211
+				$values['item_meta'][$fid->id] = '';
212 212
             }
213
-			$field_array[ $fid->id ] = $fid;
213
+			$field_array[$fid->id] = $fid;
214 214
         }
215
-        unset($all_fields);
215
+        unset( $all_fields );
216 216
 
217 217
         foreach ( $values['item_meta'] as $field_id => $default_value ) {
218
-			if ( isset( $field_array[ $field_id ] ) ) {
219
-				$field = $field_array[ $field_id ];
218
+			if ( isset( $field_array[$field_id] ) ) {
219
+				$field = $field_array[$field_id];
220 220
             } else {
221
-                $field = FrmField::getOne($field_id);
221
+                $field = FrmField::getOne( $field_id );
222 222
             }
223 223
 
224 224
             if ( ! $field ) {
225 225
                 continue;
226 226
             }
227 227
 
228
-			if ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) {
228
+			if ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) ) {
229 229
                 //updating the settings page
230
-				if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) {
231
-					$field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) );
232
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
230
+				if ( isset( $values['field_options']['custom_html_' . $field_id] ) ) {
231
+					$field->field_options['custom_html'] = isset( $values['field_options']['custom_html_' . $field_id] ) ? $values['field_options']['custom_html_' . $field_id] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) );
232
+                    $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values );
233 233
 					FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
234 234
                 } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
235 235
                     $prev_opts = $field->field_options;
236
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
236
+                    $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values );
237 237
                     if ( $prev_opts != $field->field_options ) {
238 238
 						FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
239 239
                     }
240
-                    unset($prev_opts);
240
+                    unset( $prev_opts );
241 241
                 }
242 242
             }
243 243
 
244
-			if ( ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) && ! defined( 'WP_IMPORTING' ) ) {
244
+			if ( ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) ) && ! defined( 'WP_IMPORTING' ) ) {
245 245
                 continue;
246 246
             }
247 247
 
@@ -251,23 +251,23 @@  discard block
 block discarded – undo
251 251
 			$update_options = apply_filters( 'frm_field_options_to_update', $update_options );
252 252
 
253 253
 			foreach ( $update_options as $opt => $default ) {
254
-				$field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default;
254
+				$field->field_options[$opt] = isset( $values['field_options'][$opt . '_' . $field_id] ) ? trim( sanitize_text_field( $values['field_options'][$opt . '_' . $field_id] ) ) : $default;
255 255
             }
256 256
 
257
-            $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
258
-			$default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
259
-			$field_key = isset( $values['field_options'][ 'field_key_' . $field_id ] ) ? $values['field_options'][ 'field_key_' . $field_id ] : $field->field_key;
260
-			$required = isset( $values['field_options'][ 'required_' . $field_id ] ) ? $values['field_options'][ 'required_' . $field_id ] : false;
261
-			$field_type = isset( $values['field_options'][ 'type_' . $field_id ] ) ? $values['field_options'][ 'type_' . $field_id ] : $field->type;
262
-			$field_description = isset( $values['field_options'][ 'description_' . $field_id ] ) ? $values['field_options'][ 'description_' . $field_id ] : $field->description;
257
+            $field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values );
258
+			$default_value = maybe_serialize( $values['item_meta'][$field_id] );
259
+			$field_key = isset( $values['field_options']['field_key_' . $field_id] ) ? $values['field_options']['field_key_' . $field_id] : $field->field_key;
260
+			$required = isset( $values['field_options']['required_' . $field_id] ) ? $values['field_options']['required_' . $field_id] : false;
261
+			$field_type = isset( $values['field_options']['type_' . $field_id] ) ? $values['field_options']['type_' . $field_id] : $field->type;
262
+			$field_description = isset( $values['field_options']['description_' . $field_id] ) ? $values['field_options']['description_' . $field_id] : $field->description;
263 263
 
264
-            FrmField::update($field_id, array(
264
+            FrmField::update( $field_id, array(
265 265
                 'field_key' => $field_key, 'type' => $field_type,
266 266
                 'default_value' => $default_value, 'field_options' => $field->field_options,
267 267
                 'description' => $field_description, 'required' => $required,
268 268
             ) );
269 269
 
270
-            FrmField::delete_form_transient($field->form_id);
270
+            FrmField::delete_form_transient( $field->form_id );
271 271
         }
272 272
 
273 273
         return $values;
@@ -279,17 +279,17 @@  discard block
 block discarded – undo
279 279
      */
280 280
 	public static function set_status( $id, $status ) {
281 281
         if ( 'trash' == $status ) {
282
-            return self::trash($id);
282
+            return self::trash( $id );
283 283
         }
284 284
 
285
-		$statuses  = array( 'published', 'draft', 'trash' );
285
+		$statuses = array( 'published', 'draft', 'trash' );
286 286
         if ( ! in_array( $status, $statuses ) ) {
287 287
             return false;
288 288
         }
289 289
 
290 290
         global $wpdb;
291 291
 
292
-        if ( is_array($id) ) {
292
+        if ( is_array( $id ) ) {
293 293
 			$where = array( 'id' => $id );
294 294
 			FrmDb::get_where_clause_and_values( $where );
295 295
 			array_unshift( $where['values'], $status );
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
             return self::destroy( $id );
315 315
         }
316 316
 
317
-        $form = self::getOne($id);
317
+        $form = self::getOne( $id );
318 318
         if ( ! $form ) {
319 319
             return false;
320 320
         }
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 	public static function destroy( $id ) {
343 343
         global $wpdb;
344 344
 
345
-        $form = self::getOne($id);
345
+        $form = self::getOne( $id );
346 346
         if ( ! $form ) {
347 347
             return false;
348 348
         }
@@ -350,8 +350,8 @@  discard block
 block discarded – undo
350 350
         // Disconnect the entries from this form
351 351
 		$entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) );
352 352
         foreach ( $entries as $entry_id ) {
353
-            FrmEntry::destroy($entry_id);
354
-            unset($entry_id);
353
+            FrmEntry::destroy( $entry_id );
354
+            unset( $entry_id );
355 355
         }
356 356
 
357 357
         // Disconnect the fields from this form
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
         if ( $query_results ) {
362 362
             // Delete all form actions linked to this form
363 363
             $action_control = FrmFormActionsController::get_form_actions( 'email' );
364
-            $action_control->destroy($id, 'all');
364
+            $action_control->destroy( $id, 'all' );
365 365
 
366 366
 			// Clear form caching
367 367
 			self::clear_form_cache();
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 			$form->options = maybe_unserialize( $form->options );
396 396
 			if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) {
397 397
 				self::destroy( $form->id );
398
-				$count++;
398
+				$count ++;
399 399
 			}
400 400
 
401 401
 			unset( $form );
@@ -409,15 +409,15 @@  discard block
 block discarded – undo
409 409
     public static function &getName( $id ) {
410 410
         global $wpdb;
411 411
 
412
-        $form = FrmAppHelper::check_cache($id, 'frm_form');
412
+        $form = FrmAppHelper::check_cache( $id, 'frm_form' );
413 413
         if ( $form ) {
414
-            $r = stripslashes($form->name);
414
+            $r = stripslashes( $form->name );
415 415
             return $r;
416 416
         }
417 417
 
418 418
         $query_key = is_numeric( $id ) ? 'id' : 'form_key';
419 419
         $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
420
-        $r = stripslashes($r);
420
+        $r = stripslashes( $r );
421 421
 
422 422
         return $r;
423 423
     }
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
      */
438 438
 	public static function &getKeyById( $id ) {
439 439
         $id = (int) $id;
440
-        $cache = FrmAppHelper::check_cache($id, 'frm_form');
440
+        $cache = FrmAppHelper::check_cache( $id, 'frm_form' );
441 441
         if ( $cache ) {
442 442
             return $cache->form_key;
443 443
         }
@@ -471,17 +471,17 @@  discard block
 block discarded – undo
471 471
 			$table_name = $prefix . 'frm_forms';
472 472
         } else {
473 473
 			$table_name = $wpdb->prefix . 'frm_forms';
474
-            $cache = wp_cache_get($id, 'frm_form');
474
+            $cache = wp_cache_get( $id, 'frm_form' );
475 475
             if ( $cache ) {
476
-                if ( isset($cache->options) ) {
477
-                    $cache->options = maybe_unserialize($cache->options);
476
+                if ( isset( $cache->options ) ) {
477
+                    $cache->options = maybe_unserialize( $cache->options );
478 478
                 }
479 479
 
480
-                return stripslashes_deep($cache);
480
+                return stripslashes_deep( $cache );
481 481
             }
482 482
         }
483 483
 
484
-        if ( is_numeric($id) ) {
484
+        if ( is_numeric( $id ) ) {
485 485
             $where = array( 'id' => $id );
486 486
         } else {
487 487
             $where = array( 'form_key' => $id );
@@ -489,11 +489,11 @@  discard block
 block discarded – undo
489 489
 
490 490
         $results = FrmDb::get_row( $table_name, $where );
491 491
 
492
-        if ( isset($results->options) ) {
493
-            wp_cache_set($results->id, $results, 'frm_form');
494
-            $results->options = maybe_unserialize($results->options);
492
+        if ( isset( $results->options ) ) {
493
+            wp_cache_set( $results->id, $results, 'frm_form' );
494
+            $results->options = maybe_unserialize( $results->options );
495 495
         }
496
-        return stripslashes_deep($results);
496
+        return stripslashes_deep( $results );
497 497
     }
498 498
 
499 499
     /**
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 			$results = reset( $results );
523 523
 		}
524 524
 
525
-        return stripslashes_deep($results);
525
+        return stripslashes_deep( $results );
526 526
     }
527 527
 
528 528
 	/**
@@ -562,19 +562,19 @@  discard block
 block discarded – undo
562 562
     	foreach ( $results as $row ) {
563 563
             if ( 'trash' != $row->status ) {
564 564
     	        if ( $row->is_template ) {
565
-					$counts['template']++;
565
+					$counts['template'] ++;
566 566
     	        } else {
567
-					$counts['published']++;
567
+					$counts['published'] ++;
568 568
     	        }
569 569
     	    } else {
570
-				$counts['trash']++;
570
+				$counts['trash'] ++;
571 571
         	}
572 572
 
573 573
     	    if ( 'draft' == $row->status ) {
574
-				$counts['draft']++;
574
+				$counts['draft'] ++;
575 575
     	    }
576 576
 
577
-    		unset($row);
577
+    		unset( $row );
578 578
     	}
579 579
 
580 580
     	$counts = (object) $counts;
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 	public static function validate( $values ) {
601 601
         $errors = array();
602 602
 
603
-        return apply_filters('frm_validate_form', $errors, $values);
603
+        return apply_filters( 'frm_validate_form', $errors, $values );
604 604
     }
605 605
 
606 606
 	public static function get_params( $form = null ) {
@@ -612,11 +612,11 @@  discard block
 block discarded – undo
612 612
 			self::maybe_get_form( $form );
613 613
 		}
614 614
 
615
-		if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) {
616
-			return $frm_vars['form_params'][ $form->id ];
615
+		if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][$form->id] ) ) {
616
+			return $frm_vars['form_params'][$form->id];
617 617
 		}
618 618
 
619
-		$action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
619
+		$action_var = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
620 620
 		$action = apply_filters( 'frm_show_new_entry_page', FrmAppHelper::get_param( $action_var, 'new', 'get', 'sanitize_title' ), $form );
621 621
 
622 622
 		$default_values = array(
@@ -634,15 +634,15 @@  discard block
 block discarded – undo
634 634
 			//if there are two forms on the same page, make sure not to submit both
635 635
 			foreach ( $default_values as $var => $default ) {
636 636
 				if ( $var == 'action' ) {
637
-					$values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
637
+					$values[$var] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
638 638
 				} else {
639
-					$values[ $var ] = FrmAppHelper::get_param( $var, $default );
639
+					$values[$var] = FrmAppHelper::get_param( $var, $default );
640 640
 				}
641 641
 				unset( $var, $default );
642 642
 			}
643 643
 		} else {
644 644
 			foreach ( $default_values as $var => $default ) {
645
-				$values[ $var ] = $default;
645
+				$values[$var] = $default;
646 646
 				unset( $var, $default );
647 647
 			}
648 648
 		}
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 	public static function list_page_params() {
658 658
 		$values = array();
659 659
 		foreach ( array( 'template' => 0, 'id' => '', 'paged' => 1, 'form' => '', 'search' => '', 'sort' => '', 'sdir' => '' ) as $var => $default ) {
660
-			$values[ $var ] = FrmAppHelper::get_param( $var, $default );
660
+			$values[$var] = FrmAppHelper::get_param( $var, $default );
661 661
 		}
662 662
 
663 663
 		return $values;
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
 			'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'fid' => '',
678 678
 			'keep_post' => '',
679 679
 		) as $var => $default ) {
680
-			$values[ $var ] = FrmAppHelper::get_param( $var, $default );
680
+			$values[$var] = FrmAppHelper::get_param( $var, $default );
681 681
 		}
682 682
 
683 683
 		return $values;
@@ -719,16 +719,16 @@  discard block
 block discarded – undo
719 719
 		$small_form = new stdClass();
720 720
 		foreach ( array( 'id', 'form_key', 'name' ) as $var ) {
721 721
 			$small_form->{$var} = $form->{$var};
722
-			unset($var);
722
+			unset( $var );
723 723
 		}
724 724
 
725 725
 		$frm_vars['forms_loaded'][] = $small_form;
726 726
 
727
-		if ( $this_load && empty($global_load) ) {
727
+		if ( $this_load && empty( $global_load ) ) {
728 728
 			$global_load = $frm_vars['load_css'] = true;
729 729
 		}
730 730
 
731
-		return ( ( ! isset($frm_vars['css_loaded']) || ! $frm_vars['css_loaded'] ) && $global_load );
731
+		return ( ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) && $global_load );
732 732
 	}
733 733
 
734 734
 	public static function show_submit( $form ) {
Please login to merge, or discard this patch.