Completed
Push — master ( af4004...c351ef )
by Jamie
03:28
created
classes/models/FrmEntry.php 3 patches
Indentation   +398 added lines, -398 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@  discard block
 block discarded – undo
6 6
 class FrmEntry {
7 7
 
8 8
 	/**
9
-	* Create a new entry
10
-	*
11
-	* @param array $values
12
-	* @return int | boolean $entry_id
13
-	*/
9
+	 * Create a new entry
10
+	 *
11
+	 * @param array $values
12
+	 * @return int | boolean $entry_id
13
+	 */
14 14
 	public static function create( $values ) {
15 15
 		$entry_id = self::create_entry( $values, 'standard' );
16 16
 
@@ -18,12 +18,12 @@  discard block
 block discarded – undo
18 18
 	}
19 19
 
20 20
 	/**
21
-	* Create a new entry with some differences depending on type
22
-	*
23
-	* @param array $values
24
-	* @param string $type
25
-	* @return int | boolean $entry_id
26
-	*/
21
+	 * Create a new entry with some differences depending on type
22
+	 *
23
+	 * @param array $values
24
+	 * @param string $type
25
+	 * @return int | boolean $entry_id
26
+	 */
27 27
 	private static function create_entry( $values, $type ) {
28 28
 		$new_values = self::before_insert_entry_in_database( $values, $type );
29 29
 
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
 		return $entry_id;
38 38
 	}
39 39
 
40
-    /**
41
-     * check for duplicate entries created in the last minute
42
-     * @return boolean
43
-     */
40
+	/**
41
+	 * check for duplicate entries created in the last minute
42
+	 * @return boolean
43
+	 */
44 44
 	public static function is_duplicate( $new_values, $values ) {
45 45
 		$duplicate_entry_time = 60;
46 46
 
@@ -48,55 +48,55 @@  discard block
 block discarded – undo
48 48
 			return false;
49 49
 		}
50 50
 
51
-        $check_val = $new_values;
51
+		$check_val = $new_values;
52 52
 		$check_val['created_at >'] = date( 'Y-m-d H:i:s', ( strtotime( $new_values['created_at'] ) - absint( $duplicate_entry_time ) ) );
53 53
 
54 54
 		unset( $check_val['created_at'], $check_val['updated_at'] );
55 55
 		unset( $check_val['is_draft'], $check_val['id'], $check_val['item_key'] );
56 56
 
57
-        if ( $new_values['item_key'] == $new_values['name'] ) {
58
-            unset($check_val['name']);
59
-        }
57
+		if ( $new_values['item_key'] == $new_values['name'] ) {
58
+			unset($check_val['name']);
59
+		}
60 60
 
61
-        global $wpdb;
61
+		global $wpdb;
62 62
 		$entry_exists = FrmDb::get_col( $wpdb->prefix . 'frm_items', $check_val, 'id', array( 'order_by' => 'created_at DESC' ) );
63 63
 
64
-        if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) {
65
-            return false;
66
-        }
64
+		if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) {
65
+			return false;
66
+		}
67 67
 
68
-        $is_duplicate = false;
69
-        foreach ( $entry_exists as $entry_exist ) {
70
-            $is_duplicate = true;
68
+		$is_duplicate = false;
69
+		foreach ( $entry_exists as $entry_exist ) {
70
+			$is_duplicate = true;
71 71
 
72
-            //add more checks here to make sure it's a duplicate
73
-            $metas = FrmEntryMeta::get_entry_meta_info($entry_exist);
74
-            $field_metas = array();
75
-            foreach ( $metas as $meta ) {
72
+			//add more checks here to make sure it's a duplicate
73
+			$metas = FrmEntryMeta::get_entry_meta_info($entry_exist);
74
+			$field_metas = array();
75
+			foreach ( $metas as $meta ) {
76 76
 				$field_metas[ $meta->field_id ] = $meta->meta_value;
77
-            }
78
-
79
-            // If prev entry is empty and current entry is not, they are not duplicates
80
-            $filtered_vals = array_filter( $values['item_meta'] );
81
-            if ( empty( $field_metas ) && ! empty( $filtered_vals ) ) {
82
-                return false;
83
-            }
84
-
85
-            $diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta']));
86
-            foreach ( $diff as $field_id => $meta_value ) {
87
-                if ( ! empty($meta_value) ) {
88
-                    $is_duplicate = false;
89
-                    continue;
90
-                }
91
-            }
92
-
93
-            if ( $is_duplicate ) {
77
+			}
78
+
79
+			// If prev entry is empty and current entry is not, they are not duplicates
80
+			$filtered_vals = array_filter( $values['item_meta'] );
81
+			if ( empty( $field_metas ) && ! empty( $filtered_vals ) ) {
82
+				return false;
83
+			}
84
+
85
+			$diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta']));
86
+			foreach ( $diff as $field_id => $meta_value ) {
87
+				if ( ! empty($meta_value) ) {
88
+					$is_duplicate = false;
89
+					continue;
90
+				}
91
+			}
92
+
93
+			if ( $is_duplicate ) {
94 94
 				break;
95
-            }
96
-        }
95
+			}
96
+		}
97 97
 
98
-        return $is_duplicate;
99
-    }
98
+		return $is_duplicate;
99
+	}
100 100
 
101 101
 	/**
102 102
 	 * Determine if an entry needs to be checked as a possible duplicate
@@ -127,46 +127,46 @@  discard block
 block discarded – undo
127 127
 		return true;
128 128
 	}
129 129
 
130
-    public static function duplicate( $id ) {
131
-        global $wpdb;
130
+	public static function duplicate( $id ) {
131
+		global $wpdb;
132 132
 
133
-        $values = self::getOne( $id );
133
+		$values = self::getOne( $id );
134 134
 
135
-        $new_values = array();
136
-        $new_values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_items', 'item_key');
137
-        $new_values['name'] = $values->name;
138
-        $new_values['is_draft'] = $values->is_draft;
139
-        $new_values['user_id'] = $new_values['updated_by'] = (int) $values->user_id;
140
-        $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null;
141
-        $new_values['created_at'] = $new_values['updated_at'] = current_time('mysql', 1);
135
+		$new_values = array();
136
+		$new_values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_items', 'item_key');
137
+		$new_values['name'] = $values->name;
138
+		$new_values['is_draft'] = $values->is_draft;
139
+		$new_values['user_id'] = $new_values['updated_by'] = (int) $values->user_id;
140
+		$new_values['form_id'] = $values->form_id ? (int) $values->form_id: null;
141
+		$new_values['created_at'] = $new_values['updated_at'] = current_time('mysql', 1);
142 142
 
143
-        $query_results = $wpdb->insert( $wpdb->prefix .'frm_items', $new_values );
144
-        if ( ! $query_results ) {
145
-            return false;
146
-        }
143
+		$query_results = $wpdb->insert( $wpdb->prefix .'frm_items', $new_values );
144
+		if ( ! $query_results ) {
145
+			return false;
146
+		}
147 147
 
148
-        $entry_id = $wpdb->insert_id;
148
+		$entry_id = $wpdb->insert_id;
149 149
 
150
-        global $frm_vars;
151
-        if ( ! isset($frm_vars['saved_entries']) ) {
152
-            $frm_vars['saved_entries'] = array();
153
-        }
154
-        $frm_vars['saved_entries'][] = (int) $entry_id;
150
+		global $frm_vars;
151
+		if ( ! isset($frm_vars['saved_entries']) ) {
152
+			$frm_vars['saved_entries'] = array();
153
+		}
154
+		$frm_vars['saved_entries'][] = (int) $entry_id;
155 155
 
156
-        FrmEntryMeta::duplicate_entry_metas($id, $entry_id);
156
+		FrmEntryMeta::duplicate_entry_metas($id, $entry_id);
157 157
 		self::clear_cache();
158 158
 
159 159
 		do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) );
160
-        return $entry_id;
161
-    }
160
+		return $entry_id;
161
+	}
162 162
 
163 163
 	/**
164
-	* Update an entry (not via XML)
165
-	*
166
-	* @param int $id
167
-	* @param array $values
168
-	* @return boolean|int $update_results
169
-	*/
164
+	 * Update an entry (not via XML)
165
+	 *
166
+	 * @param int $id
167
+	 * @param array $values
168
+	 * @return boolean|int $update_results
169
+	 */
170 170
 	public static function update( $id, $values ) {
171 171
 		$update_results = self::update_entry( $id, $values, 'standard' );
172 172
 
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 	}
175 175
 
176 176
 	/**
177
-	* Update an entry with some differences depending on the update type
178
-	*
179
-	* @since 2.0.16
180
-	*
181
-	* @param int $id
182
-	* @param array $values
183
-	* @return boolean|int $query_results
184
-	*/
177
+	 * Update an entry with some differences depending on the update type
178
+	 *
179
+	 * @since 2.0.16
180
+	 *
181
+	 * @param int $id
182
+	 * @param array $values
183
+	 * @return boolean|int $query_results
184
+	 */
185 185
 	private static function update_entry( $id, $values, $update_type ) {
186 186
 		global $wpdb;
187 187
 
@@ -200,34 +200,34 @@  discard block
 block discarded – undo
200 200
 	}
201 201
 
202 202
 	public static function &destroy( $id ) {
203
-        global $wpdb;
204
-        $id = (int) $id;
203
+		global $wpdb;
204
+		$id = (int) $id;
205 205
 
206 206
 		$entry = self::getOne( $id );
207
-        if ( ! $entry ) {
208
-            $result = false;
209
-            return $result;
210
-        }
207
+		if ( ! $entry ) {
208
+			$result = false;
209
+			return $result;
210
+		}
211 211
 
212
-        do_action('frm_before_destroy_entry', $id, $entry);
212
+		do_action('frm_before_destroy_entry', $id, $entry);
213 213
 
214
-        $wpdb->query( $wpdb->prepare('DELETE FROM ' . $wpdb->prefix .'frm_item_metas WHERE item_id=%d', $id) );
215
-        $result = $wpdb->query( $wpdb->prepare('DELETE FROM ' . $wpdb->prefix .'frm_items WHERE id=%d', $id) );
214
+		$wpdb->query( $wpdb->prepare('DELETE FROM ' . $wpdb->prefix .'frm_item_metas WHERE item_id=%d', $id) );
215
+		$result = $wpdb->query( $wpdb->prepare('DELETE FROM ' . $wpdb->prefix .'frm_items WHERE id=%d', $id) );
216 216
 
217 217
 		self::clear_cache();
218 218
 
219
-        return $result;
220
-    }
219
+		return $result;
220
+	}
221 221
 
222 222
 	public static function &update_form( $id, $value, $form_id ) {
223
-        global $wpdb;
224
-        $form_id = isset($value) ? $form_id : null;
223
+		global $wpdb;
224
+		$form_id = isset($value) ? $form_id : null;
225 225
 		$result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) );
226 226
 		if ( $result ) {
227 227
 			self::clear_cache();
228 228
 		}
229
-        return $result;
230
-    }
229
+		return $result;
230
+	}
231 231
 
232 232
 	/**
233 233
 	 * Clear entry caching
@@ -263,161 +263,161 @@  discard block
 block discarded – undo
263 263
 	}
264 264
 
265 265
 	public static function getOne( $id, $meta = false ) {
266
-        global $wpdb;
266
+		global $wpdb;
267 267
 
268
-        $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
268
+		$query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
269 269
                   LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE ";
270 270
 
271
-        $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s';
272
-        $query_args = array( $id );
273
-        $query = $wpdb->prepare( $query, $query_args );
271
+		$query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s';
272
+		$query_args = array( $id );
273
+		$query = $wpdb->prepare( $query, $query_args );
274 274
 
275
-        if ( ! $meta ) {
276
-            $entry = FrmAppHelper::check_cache( $id .'_nometa', 'frm_entry', $query, 'get_row' );
277
-            return stripslashes_deep($entry);
278
-        }
275
+		if ( ! $meta ) {
276
+			$entry = FrmAppHelper::check_cache( $id .'_nometa', 'frm_entry', $query, 'get_row' );
277
+			return stripslashes_deep($entry);
278
+		}
279 279
 
280
-        $entry = FrmAppHelper::check_cache( $id, 'frm_entry' );
281
-        if ( $entry !== false ) {
282
-            return stripslashes_deep($entry);
283
-        }
280
+		$entry = FrmAppHelper::check_cache( $id, 'frm_entry' );
281
+		if ( $entry !== false ) {
282
+			return stripslashes_deep($entry);
283
+		}
284 284
 
285
-        $entry = $wpdb->get_row( $query );
286
-        $entry = self::get_meta($entry);
285
+		$entry = $wpdb->get_row( $query );
286
+		$entry = self::get_meta($entry);
287 287
 
288
-        return stripslashes_deep($entry);
289
-    }
288
+		return stripslashes_deep($entry);
289
+	}
290 290
 
291 291
 	public static function get_meta( $entry ) {
292
-        if ( ! $entry ) {
293
-            return $entry;
294
-        }
292
+		if ( ! $entry ) {
293
+			return $entry;
294
+		}
295 295
 
296
-        global $wpdb;
296
+		global $wpdb;
297 297
 		$metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas m LEFT JOIN ' . $wpdb->prefix . 'frm_fields f ON m.field_id=f.id', array( 'item_id' => $entry->id, 'field_id !' => 0 ), 'field_id, meta_value, field_key, item_id' );
298 298
 
299
-        $entry->metas = array();
299
+		$entry->metas = array();
300 300
 
301 301
 		$include_key = apply_filters( 'frm_include_meta_keys', false );
302
-        foreach ( $metas as $meta_val ) {
303
-            if ( $meta_val->item_id == $entry->id ) {
302
+		foreach ( $metas as $meta_val ) {
303
+			if ( $meta_val->item_id == $entry->id ) {
304 304
 				$entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
305 305
 				if ( $include_key ) {
306 306
 					$entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ];
307 307
 				}
308
-                 continue;
309
-            }
308
+				 continue;
309
+			}
310 310
 
311
-            // include sub entries in an array
311
+			// include sub entries in an array
312 312
 			if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) {
313 313
 				$entry->metas[ $meta_val->field_id ] = array();
314
-            }
314
+			}
315 315
 
316 316
 			$entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value );
317 317
 
318
-            unset($meta_val);
319
-        }
320
-        unset($metas);
318
+			unset($meta_val);
319
+		}
320
+		unset($metas);
321 321
 
322
-        wp_cache_set( $entry->id, $entry, 'frm_entry');
322
+		wp_cache_set( $entry->id, $entry, 'frm_entry');
323 323
 
324
-        return $entry;
325
-    }
324
+		return $entry;
325
+	}
326 326
 
327
-    /**
328
-     * @param string $id
329
-     */
327
+	/**
328
+	 * @param string $id
329
+	 */
330 330
 	public static function &exists( $id ) {
331
-        global $wpdb;
331
+		global $wpdb;
332 332
 
333
-        if ( FrmAppHelper::check_cache( $id, 'frm_entry' ) ) {
334
-            $exists = true;
335
-            return $exists;
336
-        }
333
+		if ( FrmAppHelper::check_cache( $id, 'frm_entry' ) ) {
334
+			$exists = true;
335
+			return $exists;
336
+		}
337 337
 
338
-        if ( is_numeric($id) ) {
339
-            $where = array( 'id' => $id );
340
-        } else {
341
-            $where = array( 'item_key' => $id );
342
-        }
343
-        $id = FrmDb::get_var( $wpdb->prefix .'frm_items', $where );
338
+		if ( is_numeric($id) ) {
339
+			$where = array( 'id' => $id );
340
+		} else {
341
+			$where = array( 'item_key' => $id );
342
+		}
343
+		$id = FrmDb::get_var( $wpdb->prefix .'frm_items', $where );
344 344
 
345
-        $exists = ($id && $id > 0) ? true : false;
346
-        return $exists;
347
-    }
345
+		$exists = ($id && $id > 0) ? true : false;
346
+		return $exists;
347
+	}
348 348
 
349
-    public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
349
+	public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
350 350
 		global $wpdb;
351 351
 
352
-        $limit = FrmAppHelper::esc_limit($limit);
352
+		$limit = FrmAppHelper::esc_limit($limit);
353 353
 
354
-        $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form;
355
-        $entries = wp_cache_get($cache_key, 'frm_entry');
354
+		$cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form;
355
+		$entries = wp_cache_get($cache_key, 'frm_entry');
356 356
 
357
-        if ( false === $entries ) {
358
-            $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft';
359
-            $table = $wpdb->prefix .'frm_items it ';
357
+		if ( false === $entries ) {
358
+			$fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft';
359
+			$table = $wpdb->prefix .'frm_items it ';
360 360
 
361
-            if ( $inc_form ) {
362
-                $fields = 'it.*, fr.name as form_name,fr.form_key as form_key';
363
-                $table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id ';
364
-            }
361
+			if ( $inc_form ) {
362
+				$fields = 'it.*, fr.name as form_name,fr.form_key as form_key';
363
+				$table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id ';
364
+			}
365 365
 
366
-            if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) {
367
-    		    // sort by a requested field
368
-                $field_id = (int) $order_matches[1];
366
+			if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) {
367
+				// sort by a requested field
368
+				$field_id = (int) $order_matches[1];
369 369
 				$fields .= ', (SELECT meta_value FROM '. $wpdb->prefix .'frm_item_metas WHERE field_id = '. $field_id .' AND item_id = it.id) as meta_'. $field_id;
370 370
 				unset( $order_matches, $field_id );
371
-		    }
371
+			}
372 372
 
373 373
 			// prepare the query
374 374
 			$query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
375 375
 
376
-            $entries = $wpdb->get_results($query, OBJECT_K);
377
-            unset($query);
376
+			$entries = $wpdb->get_results($query, OBJECT_K);
377
+			unset($query);
378 378
 
379 379
 			if ( ! FrmAppHelper::prevent_caching() ) {
380 380
 				wp_cache_set( $cache_key, $entries, 'frm_entry', 300 );
381 381
 			}
382
-        }
382
+		}
383 383
 
384
-        if ( ! $meta || ! $entries ) {
385
-            return stripslashes_deep($entries);
386
-        }
387
-        unset($meta);
384
+		if ( ! $meta || ! $entries ) {
385
+			return stripslashes_deep($entries);
386
+		}
387
+		unset($meta);
388 388
 
389
-        if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) {
389
+		if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) {
390 390
 			$where = array( 'it.form_id' => substr( $where, 11 ) );
391
-        }
391
+		}
392 392
 
393
-        $meta_where = array( 'field_id !' => 0 );
394
-        if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) {
395
-            $meta_where['fi.form_id'] = $where['it.form_id'];
396
-        } else {
397
-            $meta_where['item_id'] = array_keys( $entries );
398
-        }
393
+		$meta_where = array( 'field_id !' => 0 );
394
+		if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) {
395
+			$meta_where['fi.form_id'] = $where['it.form_id'];
396
+		} else {
397
+			$meta_where['item_id'] = array_keys( $entries );
398
+		}
399 399
 
400
-        $metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON (it.field_id = fi.id)', $meta_where, 'item_id, meta_value, field_id, field_key, form_id' );
400
+		$metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON (it.field_id = fi.id)', $meta_where, 'item_id, meta_value, field_id, field_key, form_id' );
401 401
 
402
-        unset( $meta_where );
402
+		unset( $meta_where );
403 403
 
404
-        if ( ! $metas ) {
405
-            return stripslashes_deep($entries);
406
-        }
404
+		if ( ! $metas ) {
405
+			return stripslashes_deep($entries);
406
+		}
407 407
 
408
-        foreach ( $metas as $m_key => $meta_val ) {
409
-            if ( ! isset( $entries[ $meta_val->item_id ] ) ) {
410
-                continue;
411
-            }
408
+		foreach ( $metas as $m_key => $meta_val ) {
409
+			if ( ! isset( $entries[ $meta_val->item_id ] ) ) {
410
+				continue;
411
+			}
412 412
 
413
-            if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
413
+			if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
414 414
 				$entries[ $meta_val->item_id ]->metas = array();
415
-            }
415
+			}
416 416
 
417 417
 			$entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
418 418
 
419
-            unset($m_key, $meta_val);
420
-        }
419
+			unset($m_key, $meta_val);
420
+		}
421 421
 
422 422
 		if ( ! FrmAppHelper::prevent_caching() ) {
423 423
 			foreach ( $entries as $entry ) {
@@ -426,46 +426,46 @@  discard block
 block discarded – undo
426 426
 			}
427 427
 		}
428 428
 
429
-        return stripslashes_deep($entries);
430
-    }
431
-
432
-    // Pagination Methods
433
-    public static function getRecordCount( $where = '' ) {
434
-        global $wpdb;
435
-        $table_join = $wpdb->prefix .'frm_items it LEFT OUTER JOIN '. $wpdb->prefix .'frm_forms fr ON it.form_id=fr.id';
436
-
437
-        if ( is_numeric($where) ) {
438
-            $table_join = 'frm_items';
439
-            $where = array( 'form_id' => $where );
440
-        }
441
-
442
-        if ( is_array( $where ) ) {
443
-            $count = FrmDb::get_count( $table_join, $where );
444
-        } else {
445
-            $cache_key = 'count_'. maybe_serialize($where);
446
-            $query = 'SELECT COUNT(*) FROM '. $table_join . FrmAppHelper::prepend_and_or_where(' WHERE ', $where);
447
-            $count = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_var');
448
-        }
449
-
450
-        return $count;
451
-    }
452
-
453
-    public static function getPageCount( $p_size, $where = '' ) {
454
-        if ( is_numeric($where) ) {
455
-            return ceil( (int) $where / (int) $p_size );
456
-        } else {
457
-            return ceil( (int) self::getRecordCount($where) / (int) $p_size );
458
-        }
459
-    }
460
-
461
-	/**
462
-	* Prepare the data before inserting it into the database
463
-	*
464
-	* @since 2.0.16
465
-	* @param array $values
466
-	* @param string $type
467
-	* @return array $new_values
468
-	*/
429
+		return stripslashes_deep($entries);
430
+	}
431
+
432
+	// Pagination Methods
433
+	public static function getRecordCount( $where = '' ) {
434
+		global $wpdb;
435
+		$table_join = $wpdb->prefix .'frm_items it LEFT OUTER JOIN '. $wpdb->prefix .'frm_forms fr ON it.form_id=fr.id';
436
+
437
+		if ( is_numeric($where) ) {
438
+			$table_join = 'frm_items';
439
+			$where = array( 'form_id' => $where );
440
+		}
441
+
442
+		if ( is_array( $where ) ) {
443
+			$count = FrmDb::get_count( $table_join, $where );
444
+		} else {
445
+			$cache_key = 'count_'. maybe_serialize($where);
446
+			$query = 'SELECT COUNT(*) FROM '. $table_join . FrmAppHelper::prepend_and_or_where(' WHERE ', $where);
447
+			$count = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_var');
448
+		}
449
+
450
+		return $count;
451
+	}
452
+
453
+	public static function getPageCount( $p_size, $where = '' ) {
454
+		if ( is_numeric($where) ) {
455
+			return ceil( (int) $where / (int) $p_size );
456
+		} else {
457
+			return ceil( (int) self::getRecordCount($where) / (int) $p_size );
458
+		}
459
+	}
460
+
461
+	/**
462
+	 * Prepare the data before inserting it into the database
463
+	 *
464
+	 * @since 2.0.16
465
+	 * @param array $values
466
+	 * @param string $type
467
+	 * @return array $new_values
468
+	 */
469 469
 	private static function before_insert_entry_in_database( &$values, $type ) {
470 470
 
471 471
 		self::sanitize_entry_post( $values );
@@ -480,13 +480,13 @@  discard block
 block discarded – undo
480 480
 	}
481 481
 
482 482
 	/**
483
-	* Create an entry and perform after create actions
484
-	*
485
-	* @since 2.0.16
486
-	* @param array $values
487
-	* @param array $new_values
488
-	* @return boolean|int $entry_id
489
-	*/
483
+	 * Create an entry and perform after create actions
484
+	 *
485
+	 * @since 2.0.16
486
+	 * @param array $values
487
+	 * @param array $new_values
488
+	 * @return boolean|int $entry_id
489
+	 */
490 490
 	private static function continue_to_create_entry( $values, $new_values ) {
491 491
 		$entry_id = self::insert_entry_into_database( $new_values );
492 492
 		if ( ! $entry_id ) {
@@ -498,37 +498,37 @@  discard block
 block discarded – undo
498 498
 		return $entry_id;
499 499
 	}
500 500
 
501
-    /**
502
-     * Sanitize the POST values before we use them
503
-     *
504
-     * @since 2.0
505
-     * @param array $values The POST values by reference
506
-     */
507
-    public static function sanitize_entry_post( &$values ) {
508
-        $sanitize_method = array(
509
-            'form_id'       => 'absint',
510
-            'frm_action'    => 'sanitize_title',
511
-            'form_key'      => 'sanitize_title',
512
-            'item_key'      => 'sanitize_title',
513
-            'item_name'     => 'sanitize_text_field',
514
-            'frm_saving_draft' => 'absint',
515
-            'is_draft'      => 'absint',
516
-            'post_id'       => 'absint',
517
-            'parent_item_id' => 'absint',
518
-            'created_at'    => 'sanitize_text_field',
519
-            'updated_at'    => 'sanitize_text_field',
520
-        );
521
-
522
-        FrmAppHelper::sanitize_request( $sanitize_method, $values );
523
-    }
524
-
525
-	/**
526
-	* Prepare the new values for inserting into the database
527
-	*
528
-	* @since 2.0.16
529
-	* @param array $values
530
-	* @return array $new_values
531
-	*/
501
+	/**
502
+	 * Sanitize the POST values before we use them
503
+	 *
504
+	 * @since 2.0
505
+	 * @param array $values The POST values by reference
506
+	 */
507
+	public static function sanitize_entry_post( &$values ) {
508
+		$sanitize_method = array(
509
+			'form_id'       => 'absint',
510
+			'frm_action'    => 'sanitize_title',
511
+			'form_key'      => 'sanitize_title',
512
+			'item_key'      => 'sanitize_title',
513
+			'item_name'     => 'sanitize_text_field',
514
+			'frm_saving_draft' => 'absint',
515
+			'is_draft'      => 'absint',
516
+			'post_id'       => 'absint',
517
+			'parent_item_id' => 'absint',
518
+			'created_at'    => 'sanitize_text_field',
519
+			'updated_at'    => 'sanitize_text_field',
520
+		);
521
+
522
+		FrmAppHelper::sanitize_request( $sanitize_method, $values );
523
+	}
524
+
525
+	/**
526
+	 * Prepare the new values for inserting into the database
527
+	 *
528
+	 * @since 2.0.16
529
+	 * @param array $values
530
+	 * @return array $new_values
531
+	 */
532 532
 	private static function package_entry_data( &$values ) {
533 533
 		global $wpdb;
534 534
 
@@ -561,67 +561,67 @@  discard block
 block discarded – undo
561 561
 	}
562 562
 
563 563
 	/**
564
-	* Get the is_draft value for a new entry
565
-	*
566
-	* @since 2.0.16
567
-	* @param array $values
568
-	* @return int
569
-	*/
564
+	 * Get the is_draft value for a new entry
565
+	 *
566
+	 * @since 2.0.16
567
+	 * @param array $values
568
+	 * @return int
569
+	 */
570 570
 	private static function get_is_draft_value( $values ) {
571 571
 		return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) ||  ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0;
572 572
 	}
573 573
 
574 574
 	/**
575
-	* Get the form_id value for a new entry
576
-	*
577
-	* @since 2.0.16
578
-	* @param array $values
579
-	* @return int|null
580
-	*/
575
+	 * Get the form_id value for a new entry
576
+	 *
577
+	 * @since 2.0.16
578
+	 * @param array $values
579
+	 * @return int|null
580
+	 */
581 581
 	private static function get_form_id( $values ) {
582 582
 		return isset( $values['form_id'] ) ? (int) $values['form_id'] : null;
583 583
 	}
584 584
 
585 585
 	/**
586
-	* Get the post_id value for a new entry
587
-	*
588
-	* @since 2.0.16
589
-	* @param array $values
590
-	* @return int
591
-	*/
586
+	 * Get the post_id value for a new entry
587
+	 *
588
+	 * @since 2.0.16
589
+	 * @param array $values
590
+	 * @return int
591
+	 */
592 592
 	private static function get_post_id( $values ) {
593 593
 		return isset( $values['post_id'] ) ? (int) $values['post_id']: 0;
594 594
 	}
595 595
 
596 596
 	/**
597
-	* Get the parent_item_id value for a new entry
598
-	*
599
-	* @since 2.0.16
600
-	* @param array $values
601
-	* @return int
602
-	*/
597
+	 * Get the parent_item_id value for a new entry
598
+	 *
599
+	 * @since 2.0.16
600
+	 * @param array $values
601
+	 * @return int
602
+	 */
603 603
 	private static function get_parent_item_id( $values ) {
604 604
 		return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id']: 0;
605 605
 	}
606 606
 
607 607
 	/**
608
-	* Get the created_at value for a new entry
609
-	*
610
-	* @since 2.0.16
611
-	* @param array $values
612
-	* @return string
613
-	*/
608
+	 * Get the created_at value for a new entry
609
+	 *
610
+	 * @since 2.0.16
611
+	 * @param array $values
612
+	 * @return string
613
+	 */
614 614
 	private static function get_created_at( $values ) {
615 615
 		return isset( $values['created_at'] ) ? $values['created_at']: current_time('mysql', 1);
616 616
 	}
617 617
 
618 618
 	/**
619
-	* Get the updated_at value for a new entry
620
-	*
621
-	* @since 2.0.16
622
-	* @param array $values
623
-	* @return string
624
-	*/
619
+	 * Get the updated_at value for a new entry
620
+	 *
621
+	 * @since 2.0.16
622
+	 * @param array $values
623
+	 * @return string
624
+	 */
625 625
 	private static function get_updated_at( $values ) {
626 626
 		if ( isset( $values['updated_at'] ) ) {
627 627
 			$updated_at = $values['updated_at'];
@@ -633,12 +633,12 @@  discard block
 block discarded – undo
633 633
 	}
634 634
 
635 635
 	/**
636
-	* Get the description value for a new entry
637
-	*
638
-	* @since 2.0.16
639
-	* @param array $values
640
-	* @return string
641
-	*/
636
+	 * Get the description value for a new entry
637
+	 *
638
+	 * @since 2.0.16
639
+	 * @param array $values
640
+	 * @return string
641
+	 */
642 642
 	private static function get_entry_description( $values ) {
643 643
 		if ( isset( $values['description'] ) && ! empty( $values['description'] ) ) {
644 644
 			$description = maybe_serialize( $values['description'] );
@@ -653,12 +653,12 @@  discard block
 block discarded – undo
653 653
 	}
654 654
 
655 655
 	/**
656
-	* Get the user_id value for a new entry
657
-	*
658
-	* @since 2.0.16
659
-	* @param array $values
660
-	* @return int
661
-	*/
656
+	 * Get the user_id value for a new entry
657
+	 *
658
+	 * @since 2.0.16
659
+	 * @param array $values
660
+	 * @return int
661
+	 */
662 662
 	private static function get_entry_user_id( $values ) {
663 663
 		if ( isset( $values['frm_user_id'] ) && ( is_numeric( $values['frm_user_id'] ) || FrmAppHelper::is_admin() ) ) {
664 664
 			$user_id = $values['frm_user_id'];
@@ -671,12 +671,12 @@  discard block
 block discarded – undo
671 671
 	}
672 672
 
673 673
 	/**
674
-	* Insert new entry into the database
675
-	*
676
-	* @since 2.0.16
677
-	* @param array $new_values
678
-	* @return int | boolean $entry_id
679
-	*/
674
+	 * Insert new entry into the database
675
+	 *
676
+	 * @since 2.0.16
677
+	 * @param array $new_values
678
+	 * @return int | boolean $entry_id
679
+	 */
680 680
 	private static function insert_entry_into_database( $new_values ) {
681 681
 		global $wpdb;
682 682
 
@@ -692,11 +692,11 @@  discard block
 block discarded – undo
692 692
 	}
693 693
 
694 694
 	/**
695
-	* Add the new entry to global $frm_vars
696
-	*
697
-	* @since 2.0.16
698
-	* @param int $entry_id
699
-	*/
695
+	 * Add the new entry to global $frm_vars
696
+	 *
697
+	 * @since 2.0.16
698
+	 * @param int $entry_id
699
+	 */
700 700
 	private static function add_new_entry_to_frm_vars( $entry_id ) {
701 701
 		global $frm_vars;
702 702
 
@@ -708,12 +708,12 @@  discard block
 block discarded – undo
708 708
 	}
709 709
 
710 710
 	/**
711
-	* Add entry metas, if there are any
712
-	*
713
-	* @since 2.0.16
714
-	* @param array $values
715
-	* @param int $entry_id
716
-	*/
711
+	 * Add entry metas, if there are any
712
+	 *
713
+	 * @since 2.0.16
714
+	 * @param array $values
715
+	 * @param int $entry_id
716
+	 */
717 717
 	private static function maybe_add_entry_metas( $values, $entry_id ) {
718 718
 		if ( isset($values['item_meta']) ) {
719 719
 			FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] );
@@ -721,12 +721,12 @@  discard block
 block discarded – undo
721 721
 	}
722 722
 
723 723
 	/**
724
-	* Trigger frm_after_create_entry hooks
725
-	*
726
-	* @since 2.0.16
727
-	* @param int $entry_id
728
-	* @param array $new_values
729
-	*/
724
+	 * Trigger frm_after_create_entry hooks
725
+	 *
726
+	 * @since 2.0.16
727
+	 * @param int $entry_id
728
+	 * @param array $new_values
729
+	 */
730 730
 	private static function after_entry_created_actions( $entry_id, $values, $new_values ) {
731 731
 		// this is a child entry
732 732
 		$is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' );
@@ -736,13 +736,13 @@  discard block
 block discarded – undo
736 736
 	}
737 737
 
738 738
 	/**
739
-	* Actions to perform immediately after an entry is inserted in the frm_items database
740
-	*
741
-	* @since 2.0.16
742
-	* @param array $values
743
-	* @param array $new_values
744
-	* @param int $entry_id
745
-	*/
739
+	 * Actions to perform immediately after an entry is inserted in the frm_items database
740
+	 *
741
+	 * @since 2.0.16
742
+	 * @param array $values
743
+	 * @param array $new_values
744
+	 * @param int $entry_id
745
+	 */
746 746
 	private static function after_insert_entry_in_database( $values, $new_values, $entry_id ) {
747 747
 
748 748
 		self::add_new_entry_to_frm_vars( $entry_id );
@@ -755,14 +755,14 @@  discard block
 block discarded – undo
755 755
 	}
756 756
 
757 757
 	/**
758
-	* Perform some actions right before updating an entry
759
-	*
760
-	* @since 2.0.16
761
-	* @param int $id
762
-	* @param array $values
763
-	* @param string $update_type
764
-	* @return boolean $update
765
-	*/
758
+	 * Perform some actions right before updating an entry
759
+	 *
760
+	 * @since 2.0.16
761
+	 * @param int $id
762
+	 * @param array $values
763
+	 * @param string $update_type
764
+	 * @return boolean $update
765
+	 */
766 766
 	private static function before_update_entry( $id, &$values, $update_type ) {
767 767
 		$update = true;
768 768
 
@@ -780,13 +780,13 @@  discard block
 block discarded – undo
780 780
 	}
781 781
 
782 782
 	/**
783
-	* Package the entry data for updating
784
-	*
785
-	* @since 2.0.16
786
-	* @param int $id
787
-	* @param array $values
788
-	* @return array $new_values
789
-	*/
783
+	 * Package the entry data for updating
784
+	 *
785
+	 * @since 2.0.16
786
+	 * @param int $id
787
+	 * @param array $values
788
+	 * @return array $new_values
789
+	 */
790 790
 	private static function package_entry_to_update( $id, $values ) {
791 791
 		global $wpdb;
792 792
 
@@ -820,14 +820,14 @@  discard block
 block discarded – undo
820 820
 	}
821 821
 
822 822
 	/**
823
-	* Perform some actions right after updating an entry
824
-	*
825
-	* @since 2.0.16
826
-	* @param boolean|int $query_results
827
-	* @param int $id
828
-	* @param array $values
829
-	* @param array $new_values
830
-	*/
823
+	 * Perform some actions right after updating an entry
824
+	 *
825
+	 * @since 2.0.16
826
+	 * @param boolean|int $query_results
827
+	 * @param int $id
828
+	 * @param array $values
829
+	 * @param array $new_values
830
+	 */
831 831
 	private static function after_update_entry( $query_results, $id, $values, $new_values ) {
832 832
 		if ( $query_results ) {
833 833
 			self::clear_cache();
@@ -849,13 +849,13 @@  discard block
 block discarded – undo
849 849
 	}
850 850
 
851 851
 	/**
852
-	* Create entry from an XML import
853
-	* Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.)
854
-	*
855
-	* @since 2.0.16
856
-	* @param array $values
857
-	* @return int | boolean $entry_id
858
-	*/
852
+	 * Create entry from an XML import
853
+	 * Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.)
854
+	 *
855
+	 * @since 2.0.16
856
+	 * @param array $values
857
+	 * @return int | boolean $entry_id
858
+	 */
859 859
 	public static function create_entry_from_xml( $values ) {
860 860
 		$entry_id = self::create_entry( $values, 'xml' );
861 861
 
@@ -863,28 +863,28 @@  discard block
 block discarded – undo
863 863
 	}
864 864
 
865 865
 	/**
866
-	* Update entry from an XML import
867
-	* Certain actions aren't necessary when importing (like saving sub entries and modifying other vals)
868
-	*
869
-	* @since 2.0.16
870
-	* @param int $id
871
-	* @param array $values
872
-	* @return int | boolean $updated
873
-	*/
866
+	 * Update entry from an XML import
867
+	 * Certain actions aren't necessary when importing (like saving sub entries and modifying other vals)
868
+	 *
869
+	 * @since 2.0.16
870
+	 * @param int $id
871
+	 * @param array $values
872
+	 * @return int | boolean $updated
873
+	 */
874 874
 	public static function update_entry_from_xml( $id, $values ) {
875 875
 		$updated = self::update_entry( $id, $values, 'xml' );
876 876
 
877 877
 		return $updated;
878 878
 	}
879 879
 
880
-    /**
881
-     * @param string $key
882
-     * @return int entry_id
883
-     */
880
+	/**
881
+	 * @param string $key
882
+	 * @return int entry_id
883
+	 */
884 884
 	public static function get_id_by_key( $key ) {
885
-        $entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) );
886
-        return $entry_id;
887
-    }
885
+		$entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) );
886
+		return $entry_id;
887
+	}
888 888
 
889 889
 	public static function validate( $values, $exclude = false ) {
890 890
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryValidate::validate' );
Please login to merge, or discard this patch.
Spacing   +87 added lines, -87 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
 
@@ -55,13 +55,13 @@  discard block
 block discarded – undo
55 55
 		unset( $check_val['is_draft'], $check_val['id'], $check_val['item_key'] );
56 56
 
57 57
         if ( $new_values['item_key'] == $new_values['name'] ) {
58
-            unset($check_val['name']);
58
+            unset( $check_val['name'] );
59 59
         }
60 60
 
61 61
         global $wpdb;
62 62
 		$entry_exists = FrmDb::get_col( $wpdb->prefix . 'frm_items', $check_val, 'id', array( 'order_by' => 'created_at DESC' ) );
63 63
 
64
-        if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) {
64
+        if ( ! $entry_exists || empty( $entry_exists ) || ! isset( $values['item_meta'] ) ) {
65 65
             return false;
66 66
         }
67 67
 
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
             $is_duplicate = true;
71 71
 
72 72
             //add more checks here to make sure it's a duplicate
73
-            $metas = FrmEntryMeta::get_entry_meta_info($entry_exist);
73
+            $metas = FrmEntryMeta::get_entry_meta_info( $entry_exist );
74 74
             $field_metas = array();
75 75
             foreach ( $metas as $meta ) {
76
-				$field_metas[ $meta->field_id ] = $meta->meta_value;
76
+				$field_metas[$meta->field_id] = $meta->meta_value;
77 77
             }
78 78
 
79 79
             // If prev entry is empty and current entry is not, they are not duplicates
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
                 return false;
83 83
             }
84 84
 
85
-            $diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta']));
85
+            $diff = array_diff_assoc( $field_metas, array_map( 'maybe_serialize', $values['item_meta'] ) );
86 86
             foreach ( $diff as $field_id => $meta_value ) {
87
-                if ( ! empty($meta_value) ) {
87
+                if ( ! empty( $meta_value ) ) {
88 88
                     $is_duplicate = false;
89 89
                     continue;
90 90
                 }
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
 	 * @param int $duplicate_entry_time
108 108
 	 * @return bool
109 109
 	 */
110
-	private static function is_duplicate_check_needed( $new_values, $values, &$duplicate_entry_time ){
110
+	private static function is_duplicate_check_needed( $new_values, $values, &$duplicate_entry_time ) {
111 111
 		// If CSV is importing, don't check for duplicates
112
-		if ( defined('WP_IMPORTING') && WP_IMPORTING ) {
112
+		if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
113 113
 			return false;
114 114
 		}
115 115
 
@@ -133,14 +133,14 @@  discard block
 block discarded – undo
133 133
         $values = self::getOne( $id );
134 134
 
135 135
         $new_values = array();
136
-        $new_values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_items', 'item_key');
136
+        $new_values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' );
137 137
         $new_values['name'] = $values->name;
138 138
         $new_values['is_draft'] = $values->is_draft;
139 139
         $new_values['user_id'] = $new_values['updated_by'] = (int) $values->user_id;
140
-        $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null;
141
-        $new_values['created_at'] = $new_values['updated_at'] = current_time('mysql', 1);
140
+        $new_values['form_id'] = $values->form_id ? (int) $values->form_id : null;
141
+        $new_values['created_at'] = $new_values['updated_at'] = current_time( 'mysql', 1 );
142 142
 
143
-        $query_results = $wpdb->insert( $wpdb->prefix .'frm_items', $new_values );
143
+        $query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values );
144 144
         if ( ! $query_results ) {
145 145
             return false;
146 146
         }
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
         $entry_id = $wpdb->insert_id;
149 149
 
150 150
         global $frm_vars;
151
-        if ( ! isset($frm_vars['saved_entries']) ) {
151
+        if ( ! isset( $frm_vars['saved_entries'] ) ) {
152 152
             $frm_vars['saved_entries'] = array();
153 153
         }
154 154
         $frm_vars['saved_entries'][] = (int) $entry_id;
155 155
 
156
-        FrmEntryMeta::duplicate_entry_metas($id, $entry_id);
156
+        FrmEntryMeta::duplicate_entry_metas( $id, $entry_id );
157 157
 		self::clear_cache();
158 158
 
159 159
 		do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) );
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
 		$new_values = self::package_entry_to_update( $id, $values );
194 194
 
195
-		$query_results = $wpdb->update( $wpdb->prefix .'frm_items', $new_values, compact('id') );
195
+		$query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact( 'id' ) );
196 196
 
197 197
 		self::after_update_entry( $query_results, $id, $values, $new_values );
198 198
 
@@ -209,10 +209,10 @@  discard block
 block discarded – undo
209 209
             return $result;
210 210
         }
211 211
 
212
-        do_action('frm_before_destroy_entry', $id, $entry);
212
+        do_action( 'frm_before_destroy_entry', $id, $entry );
213 213
 
214
-        $wpdb->query( $wpdb->prepare('DELETE FROM ' . $wpdb->prefix .'frm_item_metas WHERE item_id=%d', $id) );
215
-        $result = $wpdb->query( $wpdb->prepare('DELETE FROM ' . $wpdb->prefix .'frm_items WHERE id=%d', $id) );
214
+        $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) );
215
+        $result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) );
216 216
 
217 217
 		self::clear_cache();
218 218
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 
222 222
 	public static function &update_form( $id, $value, $form_id ) {
223 223
         global $wpdb;
224
-        $form_id = isset($value) ? $form_id : null;
224
+        $form_id = isset( $value ) ? $form_id : null;
225 225
 		$result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) );
226 226
 		if ( $result ) {
227 227
 			self::clear_cache();
@@ -268,24 +268,24 @@  discard block
 block discarded – undo
268 268
         $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
269 269
                   LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE ";
270 270
 
271
-        $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s';
271
+        $query .= is_numeric( $id ) ? 'it.id=%d' : 'it.item_key=%s';
272 272
         $query_args = array( $id );
273 273
         $query = $wpdb->prepare( $query, $query_args );
274 274
 
275 275
         if ( ! $meta ) {
276
-            $entry = FrmAppHelper::check_cache( $id .'_nometa', 'frm_entry', $query, 'get_row' );
277
-            return stripslashes_deep($entry);
276
+            $entry = FrmAppHelper::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' );
277
+            return stripslashes_deep( $entry );
278 278
         }
279 279
 
280 280
         $entry = FrmAppHelper::check_cache( $id, 'frm_entry' );
281 281
         if ( $entry !== false ) {
282
-            return stripslashes_deep($entry);
282
+            return stripslashes_deep( $entry );
283 283
         }
284 284
 
285 285
         $entry = $wpdb->get_row( $query );
286
-        $entry = self::get_meta($entry);
286
+        $entry = self::get_meta( $entry );
287 287
 
288
-        return stripslashes_deep($entry);
288
+        return stripslashes_deep( $entry );
289 289
     }
290 290
 
291 291
 	public static function get_meta( $entry ) {
@@ -301,25 +301,25 @@  discard block
 block discarded – undo
301 301
 		$include_key = apply_filters( 'frm_include_meta_keys', false );
302 302
         foreach ( $metas as $meta_val ) {
303 303
             if ( $meta_val->item_id == $entry->id ) {
304
-				$entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
304
+				$entry->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value );
305 305
 				if ( $include_key ) {
306
-					$entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ];
306
+					$entry->metas[$meta_val->field_key] = $entry->metas[$meta_val->field_id];
307 307
 				}
308 308
                  continue;
309 309
             }
310 310
 
311 311
             // include sub entries in an array
312
-			if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) {
313
-				$entry->metas[ $meta_val->field_id ] = array();
312
+			if ( ! isset( $entry_metas[$meta_val->field_id] ) ) {
313
+				$entry->metas[$meta_val->field_id] = array();
314 314
             }
315 315
 
316
-			$entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value );
316
+			$entry->metas[$meta_val->field_id][] = maybe_unserialize( $meta_val->meta_value );
317 317
 
318
-            unset($meta_val);
318
+            unset( $meta_val );
319 319
         }
320
-        unset($metas);
320
+        unset( $metas );
321 321
 
322
-        wp_cache_set( $entry->id, $entry, 'frm_entry');
322
+        wp_cache_set( $entry->id, $entry, 'frm_entry' );
323 323
 
324 324
         return $entry;
325 325
     }
@@ -335,28 +335,28 @@  discard block
 block discarded – undo
335 335
             return $exists;
336 336
         }
337 337
 
338
-        if ( is_numeric($id) ) {
338
+        if ( is_numeric( $id ) ) {
339 339
             $where = array( 'id' => $id );
340 340
         } else {
341 341
             $where = array( 'item_key' => $id );
342 342
         }
343
-        $id = FrmDb::get_var( $wpdb->prefix .'frm_items', $where );
343
+        $id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where );
344 344
 
345
-        $exists = ($id && $id > 0) ? true : false;
345
+        $exists = ( $id && $id > 0 ) ? true : false;
346 346
         return $exists;
347 347
     }
348 348
 
349 349
     public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
350 350
 		global $wpdb;
351 351
 
352
-        $limit = FrmAppHelper::esc_limit($limit);
352
+        $limit = FrmAppHelper::esc_limit( $limit );
353 353
 
354
-        $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form;
355
-        $entries = wp_cache_get($cache_key, 'frm_entry');
354
+        $cache_key = maybe_serialize( $where ) . $order_by . $limit . $inc_form;
355
+        $entries = wp_cache_get( $cache_key, 'frm_entry' );
356 356
 
357 357
         if ( false === $entries ) {
358 358
             $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft';
359
-            $table = $wpdb->prefix .'frm_items it ';
359
+            $table = $wpdb->prefix . 'frm_items it ';
360 360
 
361 361
             if ( $inc_form ) {
362 362
                 $fields = 'it.*, fr.name as form_name,fr.form_key as form_key';
@@ -366,15 +366,15 @@  discard block
 block discarded – undo
366 366
             if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) {
367 367
     		    // sort by a requested field
368 368
                 $field_id = (int) $order_matches[1];
369
-				$fields .= ', (SELECT meta_value FROM '. $wpdb->prefix .'frm_item_metas WHERE field_id = '. $field_id .' AND item_id = it.id) as meta_'. $field_id;
369
+				$fields .= ', (SELECT meta_value FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id = ' . $field_id . ' AND item_id = it.id) as meta_' . $field_id;
370 370
 				unset( $order_matches, $field_id );
371 371
 		    }
372 372
 
373 373
 			// prepare the query
374
-			$query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
374
+			$query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
375 375
 
376
-            $entries = $wpdb->get_results($query, OBJECT_K);
377
-            unset($query);
376
+            $entries = $wpdb->get_results( $query, OBJECT_K );
377
+            unset( $query );
378 378
 
379 379
 			if ( ! FrmAppHelper::prevent_caching() ) {
380 380
 				wp_cache_set( $cache_key, $entries, 'frm_entry', 300 );
@@ -382,16 +382,16 @@  discard block
 block discarded – undo
382 382
         }
383 383
 
384 384
         if ( ! $meta || ! $entries ) {
385
-            return stripslashes_deep($entries);
385
+            return stripslashes_deep( $entries );
386 386
         }
387
-        unset($meta);
387
+        unset( $meta );
388 388
 
389
-        if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) {
389
+        if ( ! is_array( $where ) && preg_match( '/^it\.form_id=\d+$/', $where ) ) {
390 390
 			$where = array( 'it.form_id' => substr( $where, 11 ) );
391 391
         }
392 392
 
393 393
         $meta_where = array( 'field_id !' => 0 );
394
-        if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) {
394
+        if ( $limit == '' && is_array( $where ) && count( $where ) == 1 && isset( $where['it.form_id'] ) ) {
395 395
             $meta_where['fi.form_id'] = $where['it.form_id'];
396 396
         } else {
397 397
             $meta_where['item_id'] = array_keys( $entries );
@@ -402,21 +402,21 @@  discard block
 block discarded – undo
402 402
         unset( $meta_where );
403 403
 
404 404
         if ( ! $metas ) {
405
-            return stripslashes_deep($entries);
405
+            return stripslashes_deep( $entries );
406 406
         }
407 407
 
408 408
         foreach ( $metas as $m_key => $meta_val ) {
409
-            if ( ! isset( $entries[ $meta_val->item_id ] ) ) {
409
+            if ( ! isset( $entries[$meta_val->item_id] ) ) {
410 410
                 continue;
411 411
             }
412 412
 
413
-            if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
414
-				$entries[ $meta_val->item_id ]->metas = array();
413
+            if ( ! isset( $entries[$meta_val->item_id]->metas ) ) {
414
+				$entries[$meta_val->item_id]->metas = array();
415 415
             }
416 416
 
417
-			$entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
417
+			$entries[$meta_val->item_id]->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value );
418 418
 
419
-            unset($m_key, $meta_val);
419
+            unset( $m_key, $meta_val );
420 420
         }
421 421
 
422 422
 		if ( ! FrmAppHelper::prevent_caching() ) {
@@ -426,15 +426,15 @@  discard block
 block discarded – undo
426 426
 			}
427 427
 		}
428 428
 
429
-        return stripslashes_deep($entries);
429
+        return stripslashes_deep( $entries );
430 430
     }
431 431
 
432 432
     // Pagination Methods
433 433
     public static function getRecordCount( $where = '' ) {
434 434
         global $wpdb;
435
-        $table_join = $wpdb->prefix .'frm_items it LEFT OUTER JOIN '. $wpdb->prefix .'frm_forms fr ON it.form_id=fr.id';
435
+        $table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id';
436 436
 
437
-        if ( is_numeric($where) ) {
437
+        if ( is_numeric( $where ) ) {
438 438
             $table_join = 'frm_items';
439 439
             $where = array( 'form_id' => $where );
440 440
         }
@@ -442,19 +442,19 @@  discard block
 block discarded – undo
442 442
         if ( is_array( $where ) ) {
443 443
             $count = FrmDb::get_count( $table_join, $where );
444 444
         } else {
445
-            $cache_key = 'count_'. maybe_serialize($where);
446
-            $query = 'SELECT COUNT(*) FROM '. $table_join . FrmAppHelper::prepend_and_or_where(' WHERE ', $where);
447
-            $count = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_var');
445
+            $cache_key = 'count_' . maybe_serialize( $where );
446
+            $query = 'SELECT COUNT(*) FROM ' . $table_join . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where );
447
+            $count = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, 'get_var' );
448 448
         }
449 449
 
450 450
         return $count;
451 451
     }
452 452
 
453 453
     public static function getPageCount( $p_size, $where = '' ) {
454
-        if ( is_numeric($where) ) {
454
+        if ( is_numeric( $where ) ) {
455 455
             return ceil( (int) $where / (int) $p_size );
456 456
         } else {
457
-            return ceil( (int) self::getRecordCount($where) / (int) $p_size );
457
+            return ceil( (int) self::getRecordCount( $where ) / (int) $p_size );
458 458
         }
459 459
     }
460 460
 
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 		self::sanitize_entry_post( $values );
472 472
 
473 473
 		if ( $type != 'xml' ) {
474
-			$values = apply_filters('frm_pre_create_entry', $values);
474
+			$values = apply_filters( 'frm_pre_create_entry', $values );
475 475
 		}
476 476
 
477 477
 		$new_values = self::package_entry_data( $values );
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 
539 539
 		$item_name = self::get_new_entry_name( $values, $values['item_key'] );
540 540
 		$new_values = array(
541
-			'item_key'  => FrmAppHelper::get_unique_key($values['item_key'], $wpdb->prefix .'frm_items', 'item_key'),
541
+			'item_key'  => FrmAppHelper::get_unique_key( $values['item_key'], $wpdb->prefix . 'frm_items', 'item_key' ),
542 542
 			'name'      => FrmAppHelper::truncate( $item_name, 255, 1, '' ),
543 543
 			'ip'        => FrmAppHelper::get_ip_address(),
544 544
 			'is_draft'  => self::get_is_draft_value( $values ),
@@ -551,11 +551,11 @@  discard block
 block discarded – undo
551 551
 			'user_id' => self::get_entry_user_id( $values ),
552 552
 		);
553 553
 
554
-		if ( is_array($new_values['name']) ) {
555
-			$new_values['name'] = reset($new_values['name']);
554
+		if ( is_array( $new_values['name'] ) ) {
555
+			$new_values['name'] = reset( $new_values['name'] );
556 556
 		}
557 557
 
558
-		$new_values['updated_by'] = isset($values['updated_by']) ? $values['updated_by'] : $new_values['user_id'];
558
+		$new_values['updated_by'] = isset( $values['updated_by'] ) ? $values['updated_by'] : $new_values['user_id'];
559 559
 
560 560
 		return $new_values;
561 561
 	}
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 	* @return int
569 569
 	*/
570 570
 	private static function get_is_draft_value( $values ) {
571
-		return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) ||  ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0;
571
+		return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) || ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0;
572 572
 	}
573 573
 
574 574
 	/**
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 	* @return int
591 591
 	*/
592 592
 	private static function get_post_id( $values ) {
593
-		return isset( $values['post_id'] ) ? (int) $values['post_id']: 0;
593
+		return isset( $values['post_id'] ) ? (int) $values['post_id'] : 0;
594 594
 	}
595 595
 
596 596
 	/**
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 	* @return int
602 602
 	*/
603 603
 	private static function get_parent_item_id( $values ) {
604
-		return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id']: 0;
604
+		return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id'] : 0;
605 605
 	}
606 606
 
607 607
 	/**
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 	* @return string
613 613
 	*/
614 614
 	private static function get_created_at( $values ) {
615
-		return isset( $values['created_at'] ) ? $values['created_at']: current_time('mysql', 1);
615
+		return isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 );
616 616
 	}
617 617
 
618 618
 	/**
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
 	private static function insert_entry_into_database( $new_values ) {
681 681
 		global $wpdb;
682 682
 
683
-		$query_results = $wpdb->insert( $wpdb->prefix .'frm_items', $new_values );
683
+		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values );
684 684
 
685 685
 		if ( ! $query_results ) {
686 686
 			$entry_id = false;
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 	private static function add_new_entry_to_frm_vars( $entry_id ) {
701 701
 		global $frm_vars;
702 702
 
703
-		if ( ! isset($frm_vars['saved_entries']) ) {
703
+		if ( ! isset( $frm_vars['saved_entries'] ) ) {
704 704
 			$frm_vars['saved_entries'] = array();
705 705
 		}
706 706
 
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 	* @param int $entry_id
716 716
 	*/
717 717
 	private static function maybe_add_entry_metas( $values, $entry_id ) {
718
-		if ( isset($values['item_meta']) ) {
718
+		if ( isset( $values['item_meta'] ) ) {
719 719
 			FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] );
720 720
 		}
721 721
 	}
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 		$is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' );
733 733
 
734 734
 		do_action( 'frm_after_create_entry', $entry_id, $new_values['form_id'], compact( 'is_child' ) );
735
-		do_action( 'frm_after_create_entry_'. $new_values['form_id'], $entry_id , compact( 'is_child' ) );
735
+		do_action( 'frm_after_create_entry_' . $new_values['form_id'], $entry_id, compact( 'is_child' ) );
736 736
 	}
737 737
 
738 738
 	/**
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
 		}
774 774
 
775 775
 		if ( $update && $update_type != 'xml' ) {
776
-			$values = apply_filters('frm_pre_update_entry', $values, $id);
776
+			$values = apply_filters( 'frm_pre_update_entry', $values, $id );
777 777
 		}
778 778
 
779 779
 		return $update;
@@ -794,27 +794,27 @@  discard block
 block discarded – undo
794 794
 			'name'      => self::get_new_entry_name( $values ),
795 795
 			'form_id'   => self::get_form_id( $values ),
796 796
 			'is_draft'  => self::get_is_draft_value( $values ),
797
-			'updated_at' => current_time('mysql', 1),
798
-			'updated_by' => isset($values['updated_by']) ? $values['updated_by'] : get_current_user_id(),
797
+			'updated_at' => current_time( 'mysql', 1 ),
798
+			'updated_by' => isset( $values['updated_by'] ) ? $values['updated_by'] : get_current_user_id(),
799 799
 		);
800 800
 
801
-		if ( isset($values['post_id']) ) {
801
+		if ( isset( $values['post_id'] ) ) {
802 802
 			$new_values['post_id'] = (int) $values['post_id'];
803 803
 		}
804 804
 
805
-		if ( isset($values['item_key']) ) {
806
-			$new_values['item_key'] = FrmAppHelper::get_unique_key($values['item_key'], $wpdb->prefix .'frm_items', 'item_key', $id);
805
+		if ( isset( $values['item_key'] ) ) {
806
+			$new_values['item_key'] = FrmAppHelper::get_unique_key( $values['item_key'], $wpdb->prefix . 'frm_items', 'item_key', $id );
807 807
 		}
808 808
 
809
-		if ( isset($values['parent_item_id']) ) {
809
+		if ( isset( $values['parent_item_id'] ) ) {
810 810
 			$new_values['parent_item_id'] = (int) $values['parent_item_id'];
811 811
 		}
812 812
 
813
-		if ( isset($values['frm_user_id']) && is_numeric($values['frm_user_id']) ) {
813
+		if ( isset( $values['frm_user_id'] ) && is_numeric( $values['frm_user_id'] ) ) {
814 814
 			$new_values['user_id'] = $values['frm_user_id'];
815 815
 		}
816 816
 
817
-		$new_values = apply_filters('frm_update_entry', $new_values, $id);
817
+		$new_values = apply_filters( 'frm_update_entry', $new_values, $id );
818 818
 
819 819
 		return $new_values;
820 820
 	}
@@ -844,8 +844,8 @@  discard block
 block discarded – undo
844 844
 			FrmEntryMeta::update_entry_metas( $id, $values['item_meta'] );
845 845
 		}
846 846
 
847
-		do_action('frm_after_update_entry', $id, $new_values['form_id'] );
848
-		do_action('frm_after_update_entry_'. $new_values['form_id'], $id );
847
+		do_action( 'frm_after_update_entry', $id, $new_values['form_id'] );
848
+		do_action( 'frm_after_update_entry_' . $new_values['form_id'], $id );
849 849
 	}
850 850
 
851 851
 	/**
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@
 block discarded – undo
107 107
 	 * @param int $duplicate_entry_time
108 108
 	 * @return bool
109 109
 	 */
110
-	private static function is_duplicate_check_needed( $new_values, $values, &$duplicate_entry_time ){
110
+	private static function is_duplicate_check_needed( $new_values, $values, &$duplicate_entry_time ) {
111 111
 		// If CSV is importing, don't check for duplicates
112 112
 		if ( defined('WP_IMPORTING') && WP_IMPORTING ) {
113 113
 			return false;
Please login to merge, or discard this patch.
classes/controllers/FrmAppController.php 2 patches
Indentation   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -3,14 +3,14 @@  discard block
 block discarded – undo
3 3
 class FrmAppController {
4 4
 
5 5
 	public static function menu() {
6
-        FrmAppHelper::maybe_add_permissions();
7
-        if ( ! current_user_can( 'frm_view_forms' ) ) {
8
-            return;
9
-        }
6
+		FrmAppHelper::maybe_add_permissions();
7
+		if ( ! current_user_can( 'frm_view_forms' ) ) {
8
+			return;
9
+		}
10 10
 
11 11
 		$menu_name = FrmAppHelper::get_menu_name();
12 12
 		add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', FrmAppHelper::plugin_url() . '/images/form_16.png', self::get_menu_position() );
13
-    }
13
+	}
14 14
 
15 15
 	private static function get_menu_position() {
16 16
 		$count = count( get_post_types( array( 'show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ) );
@@ -19,39 +19,39 @@  discard block
 block discarded – undo
19 19
 		return $pos;
20 20
 	}
21 21
 
22
-    public static function load_wp_admin_style() {
23
-        FrmAppHelper::load_font_style();
24
-    }
22
+	public static function load_wp_admin_style() {
23
+		FrmAppHelper::load_font_style();
24
+	}
25 25
 
26 26
 	public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) {
27
-        global $pagenow, $frm_vars;
27
+		global $pagenow, $frm_vars;
28 28
 
29 29
 		$show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' );
30
-        if ( empty( $show_nav ) ) {
31
-            return;
32
-        }
30
+		if ( empty( $show_nav ) ) {
31
+			return;
32
+		}
33 33
 
34 34
 		$current_page = isset( $_GET['page'] ) ? FrmAppHelper::simple_get( 'page', 'sanitize_title' ) : FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' );
35 35
 		if ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) {
36 36
 			$current_page = 'frm_display';
37 37
 		}
38 38
 
39
-        if ( $form ) {
39
+		if ( $form ) {
40 40
 			FrmForm::maybe_get_form( $form );
41 41
 
42
-            if ( is_object( $form ) ) {
43
-                $id = $form->id;
44
-            }
45
-        }
42
+			if ( is_object( $form ) ) {
43
+				$id = $form->id;
44
+			}
45
+		}
46 46
 
47
-        if ( ! isset( $id ) ) {
48
-            $form = $id = false;
49
-        }
47
+		if ( ! isset( $id ) ) {
48
+			$form = $id = false;
49
+		}
50 50
 
51 51
 		$nav_items = self::get_form_nav_items( $id );
52 52
 
53
-        include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' );
54
-    }
53
+		include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' );
54
+	}
55 55
 
56 56
 	private static function get_form_nav_items( $id ) {
57 57
 		$nav_items = array(
@@ -82,28 +82,28 @@  discard block
 block discarded – undo
82 82
 		return $nav_items;
83 83
 	}
84 84
 
85
-    // Adds a settings link to the plugins page
86
-    public static function settings_link( $links ) {
85
+	// Adds a settings link to the plugins page
86
+	public static function settings_link( $links ) {
87 87
 		$settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings' ) ) . '">' . __( 'Settings', 'formidable' ) . '</a>';
88
-        array_unshift( $links, $settings );
88
+		array_unshift( $links, $settings );
89 89
 
90
-        return $links;
91
-    }
90
+		return $links;
91
+	}
92 92
 
93
-    public static function pro_get_started_headline() {
93
+	public static function pro_get_started_headline() {
94 94
 		self::maybe_show_upgrade_bar();
95 95
 
96
-        // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message
97
-        if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) {
98
-            return;
99
-        }
96
+		// Don't display this error as we're upgrading the thing, or if the user shouldn't see the message
97
+		if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) {
98
+			return;
99
+		}
100 100
 
101 101
 		if ( get_site_option( 'frmpro-authorized' ) && ! file_exists( FrmAppHelper::plugin_path() . '/pro/formidable-pro.php' ) ) {
102
-            FrmAppHelper::load_admin_wide_js();
102
+			FrmAppHelper::load_admin_wide_js();
103 103
 
104
-            // user is authorized, but running free version
105
-            $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/';
106
-        ?>
104
+			// user is authorized, but running free version
105
+			$inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/';
106
+		?>
107 107
 <div class="error" class="frm_previous_install">
108 108
 		<?php
109 109
 		echo wp_kses_post( apply_filters( 'frm_pro_update_msg',
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 		) ); ?>
116 116
 </div>
117 117
 <?php
118
-        }
119
-    }
118
+		}
119
+	}
120 120
 
121 121
 	private static function maybe_show_upgrade_bar() {
122 122
 		$page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		}
217 217
 	}
218 218
 
219
-    public static function admin_js() {
219
+	public static function admin_js() {
220 220
 		$version = FrmAppHelper::plugin_version();
221 221
 		FrmAppHelper::load_admin_wide_js( false );
222 222
 
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 			'bootstrap_tooltip', 'bootstrap-multiselect',
228 228
 		), $version, true );
229 229
 		wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version );
230
-        wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
230
+		wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
231 231
 
232 232
 		// load multselect js
233 233
 		wp_register_script( 'bootstrap-multiselect', FrmAppHelper::plugin_url() . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip' ), '0.9.8', true );
@@ -238,79 +238,79 @@  discard block
 block discarded – undo
238 238
 		global $pagenow;
239 239
 		if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) {
240 240
 
241
-            wp_enqueue_script( 'admin-widgets' );
242
-            wp_enqueue_style( 'widgets' );
243
-            wp_enqueue_script( 'formidable' );
244
-            wp_enqueue_script( 'formidable_admin' );
241
+			wp_enqueue_script( 'admin-widgets' );
242
+			wp_enqueue_style( 'widgets' );
243
+			wp_enqueue_script( 'formidable' );
244
+			wp_enqueue_script( 'formidable_admin' );
245 245
 			FrmAppHelper::localize_script( 'admin' );
246 246
 
247
-            wp_enqueue_style( 'formidable-admin' );
247
+			wp_enqueue_style( 'formidable-admin' );
248 248
 			FrmStylesController::enqueue_css( 'admin' );
249
-            add_thickbox();
249
+			add_thickbox();
250 250
 
251
-            wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' );
251
+			wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' );
252 252
 
253
-        } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) {
254
-            if ( isset( $_REQUEST['post_type'] ) ) {
255
-                $post_type = sanitize_title( $_REQUEST['post_type'] );
253
+		} else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) {
254
+			if ( isset( $_REQUEST['post_type'] ) ) {
255
+				$post_type = sanitize_title( $_REQUEST['post_type'] );
256 256
 			} else if ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) {
257 257
 				$post = get_post( absint( $_REQUEST['post'] ) );
258
-                if ( ! $post ) {
259
-                    return;
260
-                }
261
-                $post_type = $post->post_type;
262
-            } else {
263
-                return;
264
-            }
265
-
266
-            if ( $post_type == 'frm_display' ) {
267
-                wp_enqueue_script( 'jquery-ui-draggable' );
268
-                wp_enqueue_script( 'formidable_admin' );
269
-                wp_enqueue_style( 'formidable-admin' );
258
+				if ( ! $post ) {
259
+					return;
260
+				}
261
+				$post_type = $post->post_type;
262
+			} else {
263
+				return;
264
+			}
265
+
266
+			if ( $post_type == 'frm_display' ) {
267
+				wp_enqueue_script( 'jquery-ui-draggable' );
268
+				wp_enqueue_script( 'formidable_admin' );
269
+				wp_enqueue_style( 'formidable-admin' );
270 270
 				FrmAppHelper::localize_script( 'admin' );
271
-            }
272
-        } else if ( $pagenow == 'widgets.php' ) {
273
-            FrmAppHelper::load_admin_wide_js();
274
-        }
275
-    }
276
-
277
-    public static function wp_admin_body_class( $classes ) {
278
-        global $wp_version;
279
-        //we need this class everywhere in the admin for the menu
280
-        if ( version_compare( $wp_version, '3.7.2', '>' ) ) {
281
-            $classes .= ' frm_38_trigger';
282
-        }
283
-
284
-        return $classes;
285
-    }
286
-
287
-    public static function load_lang() {
288
-        load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' );
289
-    }
290
-
291
-    /**
292
-     * Filter shortcodes in text widgets
293
-     */
294
-    public static function widget_text_filter( $content ) {
295
-    	$regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/';
296
-    	return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content );
297
-    }
298
-
299
-    public static function widget_text_filter_callback( $matches ) {
300
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' );
301
-        return FrmAppHelper::widget_text_filter_callback( $matches );
302
-    }
303
-
304
-    public static function front_head() {
305
-        if ( is_multisite() ) {
306
-            $old_db_version = get_option( 'frm_db_version' );
307
-            $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false;
308
-            if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) ||
309
-                ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) {
310
-                self::install( $old_db_version );
311
-            }
312
-        }
313
-    }
271
+			}
272
+		} else if ( $pagenow == 'widgets.php' ) {
273
+			FrmAppHelper::load_admin_wide_js();
274
+		}
275
+	}
276
+
277
+	public static function wp_admin_body_class( $classes ) {
278
+		global $wp_version;
279
+		//we need this class everywhere in the admin for the menu
280
+		if ( version_compare( $wp_version, '3.7.2', '>' ) ) {
281
+			$classes .= ' frm_38_trigger';
282
+		}
283
+
284
+		return $classes;
285
+	}
286
+
287
+	public static function load_lang() {
288
+		load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' );
289
+	}
290
+
291
+	/**
292
+	 * Filter shortcodes in text widgets
293
+	 */
294
+	public static function widget_text_filter( $content ) {
295
+		$regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/';
296
+		return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content );
297
+	}
298
+
299
+	public static function widget_text_filter_callback( $matches ) {
300
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' );
301
+		return FrmAppHelper::widget_text_filter_callback( $matches );
302
+	}
303
+
304
+	public static function front_head() {
305
+		if ( is_multisite() ) {
306
+			$old_db_version = get_option( 'frm_db_version' );
307
+			$pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false;
308
+			if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) ||
309
+				( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) {
310
+				self::install( $old_db_version );
311
+			}
312
+		}
313
+	}
314 314
 
315 315
 	public static function localize_script( $location ) {
316 316
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmAppHelper::localize_script' );
@@ -370,20 +370,20 @@  discard block
 block discarded – undo
370 370
 		wp_die();
371 371
 	}
372 372
 
373
-    public static function activation_install() {
374
-        FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' );
375
-        FrmFormActionsController::actions_init();
376
-        self::install();
377
-    }
373
+	public static function activation_install() {
374
+		FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' );
375
+		FrmFormActionsController::actions_init();
376
+		self::install();
377
+	}
378 378
 
379
-    public static function install( $old_db_version = false ) {
380
-        $frmdb = new FrmDb();
381
-        $frmdb->upgrade( $old_db_version );
382
-    }
379
+	public static function install( $old_db_version = false ) {
380
+		$frmdb = new FrmDb();
381
+		$frmdb->upgrade( $old_db_version );
382
+	}
383 383
 
384
-    public static function uninstall() {
384
+	public static function uninstall() {
385 385
 		FrmAppHelper::permission_check('administrator');
386
-        check_ajax_referer( 'frm_ajax', 'nonce' );
386
+		check_ajax_referer( 'frm_ajax', 'nonce' );
387 387
 
388 388
 		$frmdb = new FrmDb();
389 389
 		$frmdb->uninstall();
@@ -392,48 +392,48 @@  discard block
 block discarded – undo
392 392
 		deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false );
393 393
 		echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) );
394 394
 
395
-        wp_die();
396
-    }
395
+		wp_die();
396
+	}
397 397
 
398
-    public static function drop_tables( $tables ) {
399
-        global $wpdb;
400
-        $tables[] = $wpdb->prefix . 'frm_fields';
401
-        $tables[] = $wpdb->prefix . 'frm_forms';
402
-        $tables[] = $wpdb->prefix . 'frm_items';
403
-        $tables[] = $wpdb->prefix . 'frm_item_metas';
404
-        return $tables;
405
-    }
398
+	public static function drop_tables( $tables ) {
399
+		global $wpdb;
400
+		$tables[] = $wpdb->prefix . 'frm_fields';
401
+		$tables[] = $wpdb->prefix . 'frm_forms';
402
+		$tables[] = $wpdb->prefix . 'frm_items';
403
+		$tables[] = $wpdb->prefix . 'frm_item_metas';
404
+		return $tables;
405
+	}
406 406
 
407
-    // Routes for wordpress pages -- we're just replacing content here folks.
408
-    public static function page_route( $content ) {
409
-        global $post;
407
+	// Routes for wordpress pages -- we're just replacing content here folks.
408
+	public static function page_route( $content ) {
409
+		global $post;
410 410
 
411
-        $frm_settings = FrmAppHelper::get_settings();
412
-        if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) {
413
-            $content = FrmFormsController::page_preview();
414
-        }
411
+		$frm_settings = FrmAppHelper::get_settings();
412
+		if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) {
413
+			$content = FrmFormsController::page_preview();
414
+		}
415 415
 
416
-        return $content;
417
-    }
416
+		return $content;
417
+	}
418 418
 
419
-    public static function deauthorize() {
419
+	public static function deauthorize() {
420 420
 		FrmAppHelper::permission_check('frm_change_settings');
421
-        check_ajax_referer( 'frm_ajax', 'nonce' );
422
-
423
-        delete_option( 'frmpro-credentials' );
424
-        delete_option( 'frmpro-authorized' );
425
-        delete_site_option( 'frmpro-credentials' );
426
-        delete_site_option( 'frmpro-authorized' );
427
-        wp_die();
428
-    }
429
-
430
-    public static function get_form_shortcode( $atts ) {
431
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' );
432
-        return FrmFormsController::get_form_shortcode( $atts );
433
-    }
434
-
435
-    public static function get_postbox_class() {
436
-        _deprecated_function( __FUNCTION__, '2.0' );
437
-        return 'postbox-container';
438
-    }
421
+		check_ajax_referer( 'frm_ajax', 'nonce' );
422
+
423
+		delete_option( 'frmpro-credentials' );
424
+		delete_option( 'frmpro-authorized' );
425
+		delete_site_option( 'frmpro-credentials' );
426
+		delete_site_option( 'frmpro-authorized' );
427
+		wp_die();
428
+	}
429
+
430
+	public static function get_form_shortcode( $atts ) {
431
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' );
432
+		return FrmFormsController::get_form_shortcode( $atts );
433
+	}
434
+
435
+	public static function get_postbox_class() {
436
+		_deprecated_function( __FUNCTION__, '2.0' );
437
+		return 'postbox-container';
438
+	}
439 439
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 <div class="update-nag frm-update-to-pro">
136 136
 	<?php echo FrmAppHelper::kses( $tip['tip'] ) ?>
137 137
 	<span><?php echo FrmAppHelper::kses( $tip['call'] ) ?></span>
138
-	<a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidablepro.com?banner=1&tip=' . absint( $tip['num'] ) ) ) ?>" class="button">Upgrade to Pro</a>
138
+	<a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidablepro.com?banner=1&tip=' . absint( $tip['num'] ) ) ) ?>" class="button">Upgrade to Pro</a>
139 139
 </div>
140 140
 <?php
141 141
 		}
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
     }
386 386
 
387 387
     public static function uninstall() {
388
-		FrmAppHelper::permission_check('administrator');
388
+		FrmAppHelper::permission_check( 'administrator' );
389 389
         check_ajax_referer( 'frm_ajax', 'nonce' );
390 390
 
391 391
 		$frmdb = new FrmDb();
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
     }
421 421
 
422 422
     public static function deauthorize() {
423
-		FrmAppHelper::permission_check('frm_change_settings');
423
+		FrmAppHelper::permission_check( 'frm_change_settings' );
424 424
         check_ajax_referer( 'frm_ajax', 'nonce' );
425 425
 
426 426
         delete_option( 'frmpro-credentials' );
Please login to merge, or discard this patch.
classes/views/frm-fields/input.php 2 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -3,48 +3,48 @@  discard block
 block discarded – undo
3 3
 <?php } else if ( $field['type'] == 'textarea' ) { ?>
4 4
 <textarea name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php
5 5
 if ( $field['max'] ) {
6
-    echo 'rows="'. esc_attr( $field['max'] ) .'" ';
6
+	echo 'rows="'. esc_attr( $field['max'] ) .'" ';
7 7
 }
8 8
 do_action('frm_field_input_html', $field);
9 9
 ?>><?php echo FrmAppHelper::esc_textarea($field['value']) ?></textarea>
10 10
 <?php
11 11
 
12 12
 } else if ( $field['type'] == 'radio' ) {
13
-    $read_only = false;
13
+	$read_only = false;
14 14
 	if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
15
-        $read_only = true; ?>
15
+		$read_only = true; ?>
16 16
 <input type="hidden" value="<?php echo esc_attr( $field['value'] ) ?>" name="<?php echo esc_attr( $field_name ) ?>" />
17 17
 <?php
18
-    }
18
+	}
19 19
 
20
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
20
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
21 21
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
22
-    } else if ( is_array($field['options']) ) {
23
-        foreach ( $field['options'] as $opt_key => $opt ) {
22
+	} else if ( is_array($field['options']) ) {
23
+		foreach ( $field['options'] as $opt_key => $opt ) {
24 24
 			if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
25
-                continue;
26
-            }
25
+				continue;
26
+			}
27 27
 
28
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
28
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
30 30
 			<div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php
31 31
 
32 32
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
33 33
 				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
34
-            }
35
-            $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
34
+			}
35
+			$checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
36 36
 
37
-            $other_opt = false;
38
-            $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39
-            ?>
37
+			$other_opt = false;
38
+			$other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39
+			?>
40 40
             <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php
41
-            echo $checked;
42
-            do_action('frm_field_input_html', $field);
41
+			echo $checked;
42
+			do_action('frm_field_input_html', $field);
43 43
 ?>/><?php
44 44
 
45 45
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
46
-                echo ' '. $opt .'</label>';
47
-            }
46
+				echo ' '. $opt .'</label>';
47
+			}
48 48
 
49 49
 			FrmFieldsHelper::include_other_input( array(
50 50
 				'other_opt' => $other_opt, 'read_only' => $read_only,
@@ -53,14 +53,14 @@  discard block
 block discarded – undo
53 53
 				'html_id' => $html_id, 'opt_key' => $opt_key,
54 54
 			) );
55 55
 
56
-            unset( $other_opt, $other_args );
56
+			unset( $other_opt, $other_args );
57 57
 ?></div>
58 58
 <?php
59
-        }
60
-    }
59
+		}
60
+	}
61 61
 } else if ( $field['type'] == 'select' ) {
62
-    $read_only = false;
63
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
62
+	$read_only = false;
63
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
64 64
 		echo FrmFieldsHelper::dropdown_categories( array( 'name' => $field_name, 'field' => $field ) );
65 65
 	} else {
66 66
 		if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 			?>
94 94
 		<option value="<?php echo esc_attr($field_val) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : '';?>><?php echo ($opt == '') ? ' ' : $opt; ?></option>
95 95
     <?php
96
-    	} ?>
96
+		} ?>
97 97
 </select>
98 98
 <?php
99 99
 		FrmFieldsHelper::include_other_input( array(
@@ -102,52 +102,52 @@  discard block
 block discarded – undo
102 102
 			'value' => $other_args['value'], 'field' => $field,
103 103
 			'html_id' => $html_id, 'opt_key' => false,
104 104
 		) );
105
-    }
105
+	}
106 106
 } else if ( $field['type'] == 'checkbox' ) {
107
-    $checked_values = $field['value'];
108
-    $read_only = false;
107
+	$checked_values = $field['value'];
108
+	$read_only = false;
109 109
 
110 110
 	if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
111
-        $read_only = true;
112
-        if ( $checked_values ) {
113
-            foreach ( (array) $checked_values as $checked_value ) { ?>
111
+		$read_only = true;
112
+		if ( $checked_values ) {
113
+			foreach ( (array) $checked_values as $checked_value ) { ?>
114 114
 <input type="hidden" value="<?php echo esc_attr( $checked_value ) ?>" name="<?php echo esc_attr( $field_name ) ?>[]" />
115 115
 <?php
116
-            }
117
-        } else { ?>
116
+			}
117
+		} else { ?>
118 118
 <input type="hidden" value="" name="<?php echo esc_attr( $field_name ) ?>[]" />
119 119
 <?php
120
-        }
121
-    }
120
+		}
121
+	}
122 122
 
123
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
123
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
124 124
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
125
-    } else if ( $field['options'] ) {
126
-        foreach ( $field['options'] as $opt_key => $opt ) {
127
-            if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
128
-                continue;
129
-            }
130
-
131
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
132
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
133
-            $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
134
-
135
-            // Check if other opt, and get values for other field if needed
136
-            $other_opt = false;
125
+	} else if ( $field['options'] ) {
126
+		foreach ( $field['options'] as $opt_key => $opt ) {
127
+			if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
128
+				continue;
129
+			}
130
+
131
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
132
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
133
+			$checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
134
+
135
+			// Check if other opt, and get values for other field if needed
136
+			$other_opt = false;
137 137
 			$other_args = FrmFieldsHelper::prepare_other_input( compact( 'field', 'field_name', 'opt_key' ), $other_opt, $checked );
138 138
 
139
-            ?>
139
+			?>
140 140
 			<div class="<?php echo esc_attr( apply_filters( 'frm_checkbox_class', 'frm_checkbox', $field, $field_val ) ) ?>" id="frm_checkbox_<?php echo esc_attr( $field['id'] ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
141 141
 
142
-            if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
143
-                ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
144
-            }
142
+			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
143
+				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
144
+			}
145 145
 
146
-            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
146
+			?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
147 147
 
148
-            if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
149
-                echo ' '. $opt .'</label>';
150
-            }
148
+			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
149
+				echo ' '. $opt .'</label>';
150
+			}
151 151
 
152 152
 			FrmFieldsHelper::include_other_input( array(
153 153
 				'other_opt' => $other_opt, 'read_only' => $read_only,
@@ -156,17 +156,17 @@  discard block
 block discarded – undo
156 156
 				'html_id' => $html_id, 'opt_key' => $opt_key,
157 157
 			) );
158 158
 
159
-            unset( $other_opt, $other_args, $checked );
159
+			unset( $other_opt, $other_args, $checked );
160 160
 
161
-            ?></div>
161
+			?></div>
162 162
 <?php
163
-        }
164
-    }
163
+		}
164
+	}
165 165
 } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) {
166
-    $frm_settings = FrmAppHelper::get_settings();
167
-    if ( ! empty($frm_settings->pubkey) ) {
168
-        FrmFieldsHelper::display_recaptcha($field);
169
-    }
166
+	$frm_settings = FrmAppHelper::get_settings();
167
+	if ( ! empty($frm_settings->pubkey) ) {
168
+		FrmFieldsHelper::display_recaptcha($field);
169
+	}
170 170
 } else {
171 171
 	do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) );
172 172
 	do_action( 'frm_form_field_' . $field['type'], $field, $field_name, compact( 'errors', 'html_id' ) );
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php if ( in_array( $field['type'], array( 'email', 'url', 'text' ) ) ) { ?>
2
-<input type="<?php echo ( $frm_settings->use_html || $field['type'] == 'password' ) ? $field['type'] : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action('frm_field_input_html', $field) ?>/>
2
+<input type="<?php echo ( $frm_settings->use_html || $field['type'] == 'password' ) ? $field['type'] : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>/>
3 3
 <?php } else if ( $field['type'] == 'textarea' ) { ?>
4 4
 <textarea name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php
5 5
 if ( $field['max'] ) {
6
-    echo 'rows="'. esc_attr( $field['max'] ) .'" ';
6
+    echo 'rows="' . esc_attr( $field['max'] ) . '" ';
7 7
 }
8
-do_action('frm_field_input_html', $field);
9
-?>><?php echo FrmAppHelper::esc_textarea($field['value']) ?></textarea>
8
+do_action( 'frm_field_input_html', $field );
9
+?>><?php echo FrmAppHelper::esc_textarea( $field['value'] ) ?></textarea>
10 10
 <?php
11 11
 
12 12
 } else if ( $field['type'] == 'radio' ) {
@@ -17,33 +17,33 @@  discard block
 block discarded – undo
17 17
 <?php
18 18
     }
19 19
 
20
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
20
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
21 21
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
22
-    } else if ( is_array($field['options']) ) {
22
+    } else if ( is_array( $field['options'] ) ) {
23 23
         foreach ( $field['options'] as $opt_key => $opt ) {
24 24
 			if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
25 25
                 continue;
26 26
             }
27 27
 
28
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
28
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
29
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); ?>
30 30
 			<div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php
31 31
 
32 32
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
33 33
 				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
34 34
             }
35
-            $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
35
+            $checked = FrmAppHelper::check_selected( $field['value'], $field_val ) ? 'checked="checked" ' : ' ';
36 36
 
37 37
             $other_opt = false;
38 38
             $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39 39
             ?>
40 40
             <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php
41 41
             echo $checked;
42
-            do_action('frm_field_input_html', $field);
42
+            do_action( 'frm_field_input_html', $field );
43 43
 ?>/><?php
44 44
 
45 45
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
46
-                echo ' '. $opt .'</label>';
46
+                echo ' ' . $opt . '</label>';
47 47
             }
48 48
 
49 49
 			FrmFieldsHelper::include_other_input( array(
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     }
61 61
 } else if ( $field['type'] == 'select' ) {
62 62
     $read_only = false;
63
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
63
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
64 64
 		echo FrmFieldsHelper::dropdown_categories( array( 'name' => $field_name, 'field' => $field ) );
65 65
 	} else {
66 66
 		if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
 					<input type="hidden" value="<?php echo esc_attr( $selected_value ) ?>" name="<?php echo esc_attr( $field_name ) ?>[]" /> <?php
72 72
 				}
73 73
 			} else { ?>
74
-				<input type="hidden" value="<?php echo esc_attr($field['value']) ?>" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" /> <?php
74
+				<input type="hidden" value="<?php echo esc_attr( $field['value'] ) ?>" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" /> <?php
75 75
 			} ?>
76
-				<select disabled="disabled" <?php do_action('frm_field_input_html', $field) ?>> <?php
76
+				<select disabled="disabled" <?php do_action( 'frm_field_input_html', $field ) ?>> <?php
77 77
 
78 78
 		} else { ?>
79
-<select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action('frm_field_input_html', $field) ?>>
79
+<select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>>
80 80
 <?php   }
81 81
 
82 82
 		$other_opt = $other_checked = false;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 				}
92 92
 			}
93 93
 			?>
94
-		<option value="<?php echo esc_attr($field_val) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : '';?>><?php echo ($opt == '') ? ' ' : $opt; ?></option>
94
+		<option value="<?php echo esc_attr( $field_val ) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : ''; ?>><?php echo ( $opt == '' ) ? ' ' : $opt; ?></option>
95 95
     <?php
96 96
     	} ?>
97 97
 </select>
@@ -120,17 +120,17 @@  discard block
 block discarded – undo
120 120
         }
121 121
     }
122 122
 
123
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
123
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
124 124
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
125 125
     } else if ( $field['options'] ) {
126 126
         foreach ( $field['options'] as $opt_key => $opt ) {
127
-            if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
127
+            if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
128 128
                 continue;
129 129
             }
130 130
 
131
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
132
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
133
-            $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
131
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
132
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
133
+            $checked = FrmAppHelper::check_selected( $checked_values, $field_val ) ? ' checked="checked"' : '';
134 134
 
135 135
             // Check if other opt, and get values for other field if needed
136 136
             $other_opt = false;
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
                 ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
144 144
             }
145 145
 
146
-            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
146
+            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action( 'frm_field_input_html', $field ) ?> /><?php
147 147
 
148 148
             if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
149
-                echo ' '. $opt .'</label>';
149
+                echo ' ' . $opt . '</label>';
150 150
             }
151 151
 
152 152
 			FrmFieldsHelper::include_other_input( array(
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
     }
165 165
 } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) {
166 166
     $frm_settings = FrmAppHelper::get_settings();
167
-    if ( ! empty($frm_settings->pubkey) ) {
168
-        FrmFieldsHelper::display_recaptcha($field);
167
+    if ( ! empty( $frm_settings->pubkey ) ) {
168
+        FrmFieldsHelper::display_recaptcha( $field );
169 169
     }
170 170
 } else {
171 171
 	do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) );
Please login to merge, or discard this patch.
classes/helpers/FrmFieldsHelper.php 2 patches
Indentation   +814 added lines, -814 removed lines patch added patch discarded remove patch
@@ -7,71 +7,71 @@  discard block
 block discarded – undo
7 7
 
8 8
 	public static function setup_new_vars( $type = '', $form_id = '' ) {
9 9
 
10
-        if ( strpos($type, '|') ) {
11
-            list($type, $setting) = explode('|', $type);
12
-        }
13
-
14
-        $defaults = self::get_default_field_opts($type, $form_id);
15
-        $defaults['field_options']['custom_html'] = self::get_default_html($type);
16
-
17
-        $values = array();
18
-
19
-        foreach ( $defaults as $var => $default ) {
20
-            if ( $var == 'field_options' ) {
21
-                $values['field_options'] = array();
22
-                foreach ( $default as $opt_var => $opt_default ) {
23
-                    $values['field_options'][ $opt_var ] = $opt_default;
24
-                    unset($opt_var, $opt_default);
25
-                }
26
-            } else {
27
-                $values[ $var ] = $default;
28
-            }
29
-            unset($var, $default);
30
-        }
31
-
32
-        if ( isset( $setting ) && ! empty( $setting ) ) {
33
-            if ( 'data' == $type ) {
34
-                $values['field_options']['data_type'] = $setting;
35
-            } else {
36
-                $values['field_options'][ $setting ] = 1;
37
-            }
38
-        }
39
-
40
-        if ( $type == 'radio' || $type == 'checkbox' ) {
41
-            $values['options'] = serialize( array(
42
-                __( 'Option 1', 'formidable' ),
43
-                __( 'Option 2', 'formidable' ),
44
-            ) );
45
-        } else if ( $type == 'select' ) {
46
-            $values['options'] = serialize( array(
47
-                '', __( 'Option 1', 'formidable' ),
48
-            ) );
49
-        } else if ( $type == 'textarea' ) {
50
-            $values['field_options']['max'] = '5';
51
-        } else if ( $type == 'captcha' ) {
52
-            $frm_settings = FrmAppHelper::get_settings();
53
-            $values['invalid'] = $frm_settings->re_msg;
54
-        } else if ( 'url' == $type ) {
55
-            $values['name'] = __( 'Website', 'formidable' );
56
-        }
10
+		if ( strpos($type, '|') ) {
11
+			list($type, $setting) = explode('|', $type);
12
+		}
13
+
14
+		$defaults = self::get_default_field_opts($type, $form_id);
15
+		$defaults['field_options']['custom_html'] = self::get_default_html($type);
16
+
17
+		$values = array();
18
+
19
+		foreach ( $defaults as $var => $default ) {
20
+			if ( $var == 'field_options' ) {
21
+				$values['field_options'] = array();
22
+				foreach ( $default as $opt_var => $opt_default ) {
23
+					$values['field_options'][ $opt_var ] = $opt_default;
24
+					unset($opt_var, $opt_default);
25
+				}
26
+			} else {
27
+				$values[ $var ] = $default;
28
+			}
29
+			unset($var, $default);
30
+		}
31
+
32
+		if ( isset( $setting ) && ! empty( $setting ) ) {
33
+			if ( 'data' == $type ) {
34
+				$values['field_options']['data_type'] = $setting;
35
+			} else {
36
+				$values['field_options'][ $setting ] = 1;
37
+			}
38
+		}
39
+
40
+		if ( $type == 'radio' || $type == 'checkbox' ) {
41
+			$values['options'] = serialize( array(
42
+				__( 'Option 1', 'formidable' ),
43
+				__( 'Option 2', 'formidable' ),
44
+			) );
45
+		} else if ( $type == 'select' ) {
46
+			$values['options'] = serialize( array(
47
+				'', __( 'Option 1', 'formidable' ),
48
+			) );
49
+		} else if ( $type == 'textarea' ) {
50
+			$values['field_options']['max'] = '5';
51
+		} else if ( $type == 'captcha' ) {
52
+			$frm_settings = FrmAppHelper::get_settings();
53
+			$values['invalid'] = $frm_settings->re_msg;
54
+		} else if ( 'url' == $type ) {
55
+			$values['name'] = __( 'Website', 'formidable' );
56
+		}
57 57
 
58 58
 		$fields = FrmField::field_selection();
59
-        $fields = array_merge($fields, FrmField::pro_field_selection());
59
+		$fields = array_merge($fields, FrmField::pro_field_selection());
60 60
 
61
-        if ( isset( $fields[ $type ] ) ) {
62
-            $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
63
-        }
61
+		if ( isset( $fields[ $type ] ) ) {
62
+			$values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
63
+		}
64 64
 
65
-        unset($fields);
65
+		unset($fields);
66 66
 
67
-        return $values;
68
-    }
67
+		return $values;
68
+	}
69 69
 
70 70
 	public static function get_html_id( $field, $plus = '' ) {
71
-        return apply_filters('frm_field_html_id', 'field_'. $field['field_key'] . $plus, $field);
72
-    }
71
+		return apply_filters('frm_field_html_id', 'field_'. $field['field_key'] . $plus, $field);
72
+	}
73 73
 
74
-    public static function setup_edit_vars( $record, $doing_ajax = false ) {
74
+	public static function setup_edit_vars( $record, $doing_ajax = false ) {
75 75
 		$values = array( 'id' => $record->id, 'form_id' => $record->form_id );
76 76
 		$defaults = array(
77 77
 			'name'          => $record->name,
@@ -84,86 +84,86 @@  discard block
 block discarded – undo
84 84
 		);
85 85
 
86 86
 		if ( $doing_ajax ) {
87
-            $values = $values + $defaults;
88
-            $values['form_name'] = '';
87
+			$values = $values + $defaults;
88
+			$values['form_name'] = '';
89 89
 		} else {
90 90
 			foreach ( $defaults as $var => $default ) {
91
-                $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
-                unset($var, $default);
93
-            }
91
+				$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
+				unset($var, $default);
93
+			}
94 94
 
95 95
 			$values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : '';
96
-        }
96
+		}
97 97
 
98 98
 		unset( $defaults );
99 99
 
100
-        $values['options'] = $record->options;
101
-        $values['field_options'] = $record->field_options;
100
+		$values['options'] = $record->options;
101
+		$values['field_options'] = $record->field_options;
102 102
 
103
-        $defaults = self::get_default_field_opts($values['type'], $record, true);
103
+		$defaults = self::get_default_field_opts($values['type'], $record, true);
104 104
 
105 105
 		if ( $values['type'] == 'captcha' ) {
106
-            $frm_settings = FrmAppHelper::get_settings();
107
-            $defaults['invalid'] = $frm_settings->re_msg;
108
-        }
106
+			$frm_settings = FrmAppHelper::get_settings();
107
+			$defaults['invalid'] = $frm_settings->re_msg;
108
+		}
109 109
 
110 110
 		foreach ( $defaults as $opt => $default ) {
111
-            $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
112
-            unset($opt, $default);
113
-        }
111
+			$values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
112
+			unset($opt, $default);
113
+		}
114 114
 
115
-        $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
115
+		$values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
116 116
 
117 117
 		return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) );
118
-    }
118
+	}
119 119
 
120
-    public static function get_default_field_opts( $type, $field, $limit = false ) {
121
-        $field_options = array(
122
-            'size' => '', 'max' => '', 'label' => '', 'blank' => '',
123
-            'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0,
124
-            'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '',
120
+	public static function get_default_field_opts( $type, $field, $limit = false ) {
121
+		$field_options = array(
122
+			'size' => '', 'max' => '', 'label' => '', 'blank' => '',
123
+			'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0,
124
+			'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '',
125 125
 			'custom_html' => '', 'captcha_size' => 'default',
126
-        );
126
+		);
127 127
 
128 128
 		if ( $limit ) {
129
-            return $field_options;
129
+			return $field_options;
130 130
 		}
131 131
 
132
-        global $wpdb;
132
+		global $wpdb;
133 133
 
134
-        $form_id = (is_numeric($field)) ? $field : $field->form_id;
134
+		$form_id = (is_numeric($field)) ? $field : $field->form_id;
135 135
 
136
-        $key = is_numeric($field) ? FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_fields', 'field_key') : $field->field_key;
136
+		$key = is_numeric($field) ? FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_fields', 'field_key') : $field->field_key;
137 137
 
138
-        $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) );
138
+		$field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) );
139 139
 
140
-        $frm_settings = FrmAppHelper::get_settings();
141
-        return array(
142
-            'name' => __( 'Untitled', 'formidable' ), 'description' => '',
140
+		$frm_settings = FrmAppHelper::get_settings();
141
+		return array(
142
+			'name' => __( 'Untitled', 'formidable' ), 'description' => '',
143 143
 			'field_key' => $key, 'type' => $type, 'options' => '', 'default_value' => '',
144 144
 			'field_order' => $field_count + 1, 'required' => false,
145
-            'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg,
146
-            'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id,
145
+			'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg,
146
+			'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id,
147 147
 			'field_options' => $field_options,
148
-        );
149
-    }
148
+		);
149
+	}
150 150
 
151
-    public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
152
-        global $wpdb;
151
+	public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
152
+		global $wpdb;
153 153
 
154
-        $values['field_key'] = FrmAppHelper::get_unique_key($new_key, $wpdb->prefix .'frm_fields', 'field_key');
155
-        $values['form_id'] = $form_id;
156
-        $values['options'] = maybe_serialize($field->options);
157
-        $values['default_value'] = maybe_serialize($field->default_value);
154
+		$values['field_key'] = FrmAppHelper::get_unique_key($new_key, $wpdb->prefix .'frm_fields', 'field_key');
155
+		$values['form_id'] = $form_id;
156
+		$values['options'] = maybe_serialize($field->options);
157
+		$values['default_value'] = maybe_serialize($field->default_value);
158 158
 
159
-        foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
160
-            $values[ $col ] = $field->{$col};
161
-        }
162
-    }
159
+		foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
160
+			$values[ $col ] = $field->{$col};
161
+		}
162
+	}
163 163
 
164
-    /**
165
-     * @since 2.0
166
-     */
164
+	/**
165
+	 * @since 2.0
166
+	 */
167 167
 	public static function get_error_msg( $field, $error ) {
168 168
 		$frm_settings = FrmAppHelper::get_settings();
169 169
 		$default_settings = $frm_settings->default_options();
@@ -180,21 +180,21 @@  discard block
 block discarded – undo
180 180
 		return $msg;
181 181
 	}
182 182
 
183
-    public static function get_form_fields( $form_id, $error = false ) {
184
-        $fields = FrmField::get_all_for_form($form_id);
185
-        $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error);
186
-        return $fields;
187
-    }
183
+	public static function get_form_fields( $form_id, $error = false ) {
184
+		$fields = FrmField::get_all_for_form($form_id);
185
+		$fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error);
186
+		return $fields;
187
+	}
188 188
 
189 189
 	public static function get_default_html( $type = 'text' ) {
190 190
 		if ( apply_filters( 'frm_normal_field_type_html', true, $type ) ) {
191 191
 			$input = ( in_array( $type, array( 'radio', 'checkbox', 'data' ) ) ) ? '<div class="frm_opt_container">[input]</div>' : '[input]';
192
-            $for = '';
192
+			$for = '';
193 193
 			if ( ! in_array( $type, array( 'radio', 'checkbox', 'data', 'scale' ) ) ) {
194
-                $for = 'for="field_[key]"';
195
-            }
194
+				$for = 'for="field_[key]"';
195
+			}
196 196
 
197
-            $default_html = <<<DEFAULT_HTML
197
+			$default_html = <<<DEFAULT_HTML
198 198
 <div id="frm_field_[id]_container" class="frm_form_field form-field [required_class][error_class]">
199 199
     <label $for class="frm_primary_label">[field_name]
200 200
         <span class="frm_required">[required_label]</span>
@@ -204,145 +204,145 @@  discard block
 block discarded – undo
204 204
     [if error]<div class="frm_error">[error]</div>[/if error]
205 205
 </div>
206 206
 DEFAULT_HTML;
207
-        } else {
207
+		} else {
208 208
 			$default_html = apply_filters('frm_other_custom_html', '', $type);
209
-        }
209
+		}
210 210
 
211
-        return apply_filters('frm_custom_html', $default_html, $type);
212
-    }
211
+		return apply_filters('frm_custom_html', $default_html, $type);
212
+	}
213 213
 
214 214
 	public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) {
215
-        $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
216
-
217
-        $defaults = array(
218
-            'field_name'  => 'item_meta['. $field['id'] .']',
219
-            'field_id'    => $field['id'],
220
-            'field_plus_id' => '',
221
-            'section_id'    => '',
222
-        );
223
-        $args = wp_parse_args($args, $defaults);
224
-        $field_name = $args['field_name'];
225
-        $field_id = $args['field_id'];
226
-        $html_id = self::get_html_id($field, $args['field_plus_id']);
227
-
228
-        if ( FrmField::is_multiple_select($field) ) {
229
-            $field_name .= '[]';
230
-        }
231
-
232
-        //replace [id]
233
-        $html = str_replace('[id]', $field_id, $html);
234
-
235
-        // Remove the for attribute for captcha
236
-        if ( $field['type'] == 'captcha' ) {
237
-            $html = str_replace(' for="field_[key]"', '', $html);
238
-        }
239
-
240
-        // set the label for
241
-        $html = str_replace('field_[key]', $html_id, $html);
242
-
243
-        //replace [key]
244
-        $html = str_replace('[key]', $field['field_key'], $html);
245
-
246
-        //replace [description] and [required_label] and [error]
215
+		$html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
216
+
217
+		$defaults = array(
218
+			'field_name'  => 'item_meta['. $field['id'] .']',
219
+			'field_id'    => $field['id'],
220
+			'field_plus_id' => '',
221
+			'section_id'    => '',
222
+		);
223
+		$args = wp_parse_args($args, $defaults);
224
+		$field_name = $args['field_name'];
225
+		$field_id = $args['field_id'];
226
+		$html_id = self::get_html_id($field, $args['field_plus_id']);
227
+
228
+		if ( FrmField::is_multiple_select($field) ) {
229
+			$field_name .= '[]';
230
+		}
231
+
232
+		//replace [id]
233
+		$html = str_replace('[id]', $field_id, $html);
234
+
235
+		// Remove the for attribute for captcha
236
+		if ( $field['type'] == 'captcha' ) {
237
+			$html = str_replace(' for="field_[key]"', '', $html);
238
+		}
239
+
240
+		// set the label for
241
+		$html = str_replace('field_[key]', $html_id, $html);
242
+
243
+		//replace [key]
244
+		$html = str_replace('[key]', $field['field_key'], $html);
245
+
246
+		//replace [description] and [required_label] and [error]
247 247
 		$required = FrmField::is_required( $field ) ? $field['required_indicator'] : '';
248
-        if ( ! is_array( $errors ) ) {
249
-            $errors = array();
250
-        }
248
+		if ( ! is_array( $errors ) ) {
249
+			$errors = array();
250
+		}
251 251
 		$error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false;
252 252
 
253
-        //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
254
-        if ( $field['type'] == 'divider' ) {
255
-            if ( FrmField::is_option_true( $field, 'description' ) ) {
256
-                $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
257
-            } else {
258
-                $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
259
-            }
260
-        }
253
+		//If field type is section heading, add class so a bottom margin can be added to either the h3 or description
254
+		if ( $field['type'] == 'divider' ) {
255
+			if ( FrmField::is_option_true( $field, 'description' ) ) {
256
+				$html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
257
+			} else {
258
+				$html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
259
+			}
260
+		}
261 261
 
262 262
 		foreach ( array( 'description' => $field['description'], 'required_label' => $required, 'error' => $error ) as $code => $value ) {
263
-            self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html );
264
-        }
263
+			self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html );
264
+		}
265 265
 
266
-        //replace [required_class]
266
+		//replace [required_class]
267 267
 		$required_class = FrmField::is_required( $field ) ? ' frm_required_field' : '';
268
-        $html = str_replace('[required_class]', $required_class, $html);
268
+		$html = str_replace('[required_class]', $required_class, $html);
269 269
 
270
-        //replace [label_position]
271
-        $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
272
-        $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
270
+		//replace [label_position]
271
+		$field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
272
+		$field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
273 273
 		$html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html );
274 274
 
275
-        //replace [field_name]
276
-        $html = str_replace('[field_name]', $field['name'], $html);
275
+		//replace [field_name]
276
+		$html = str_replace('[field_name]', $field['name'], $html);
277 277
 
278
-        //replace [error_class]
278
+		//replace [error_class]
279 279
 		$error_class = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : '';
280 280
 		self::get_more_field_classes( $error_class, $field, $field_id, $html );
281 281
 		if ( $field['type'] == 'html' && strpos( $html, '[error_class]' ) === false ) {
282 282
 			// there is no error_class shortcode to use for addign fields
283 283
 			$html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . $error_class, $html );
284 284
 		}
285
-        $html = str_replace('[error_class]', $error_class, $html);
285
+		$html = str_replace('[error_class]', $error_class, $html);
286 286
 
287
-        //replace [entry_key]
288
-        $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
289
-        $html = str_replace('[entry_key]', $entry_key, $html);
287
+		//replace [entry_key]
288
+		$entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
289
+		$html = str_replace('[entry_key]', $entry_key, $html);
290 290
 
291
-        //replace [input]
292
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
293
-        global $frm_vars;
294
-        $frm_settings = FrmAppHelper::get_settings();
291
+		//replace [input]
292
+		preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
293
+		global $frm_vars;
294
+		$frm_settings = FrmAppHelper::get_settings();
295 295
 
296
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
297
-            $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
296
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
297
+			$atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
298 298
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
299 299
 
300
-            $replace_with = '';
300
+			$replace_with = '';
301 301
 
302
-            if ( $tag == 'input' ) {
303
-                if ( isset($atts['opt']) ) {
304
-                    $atts['opt']--;
305
-                }
302
+			if ( $tag == 'input' ) {
303
+				if ( isset($atts['opt']) ) {
304
+					$atts['opt']--;
305
+				}
306 306
 
307
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
308
-                if ( isset($atts['class']) ) {
309
-                    unset($atts['class']);
310
-                }
307
+				$field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
308
+				if ( isset($atts['class']) ) {
309
+					unset($atts['class']);
310
+				}
311 311
 
312
-                $field['shortcodes'] = $atts;
313
-                ob_start();
314
-                include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/input.php');
315
-                $replace_with = ob_get_contents();
316
-                ob_end_clean();
317
-            } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
318
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
319
-            }
312
+				$field['shortcodes'] = $atts;
313
+				ob_start();
314
+				include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/input.php');
315
+				$replace_with = ob_get_contents();
316
+				ob_end_clean();
317
+			} else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
318
+				$replace_with = FrmProEntriesController::entry_delete_link($atts);
319
+			}
320 320
 
321
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
322
-        }
321
+			$html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
322
+		}
323 323
 
324 324
 		if ( $form ) {
325
-            $form = (array) $form;
325
+			$form = (array) $form;
326 326
 
327
-            //replace [form_key]
328
-            $html = str_replace('[form_key]', $form['form_key'], $html);
327
+			//replace [form_key]
328
+			$html = str_replace('[form_key]', $form['form_key'], $html);
329 329
 
330
-            //replace [form_name]
331
-            $html = str_replace('[form_name]', $form['name'], $html);
332
-        }
333
-        $html .= "\n";
330
+			//replace [form_name]
331
+			$html = str_replace('[form_name]', $form['name'], $html);
332
+		}
333
+		$html .= "\n";
334 334
 
335
-        //Return html if conf_field to prevent loop
336
-        if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
337
-            return $html;
338
-        }
335
+		//Return html if conf_field to prevent loop
336
+		if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
337
+			return $html;
338
+		}
339 339
 
340
-        //If field is in repeating section
341
-        if ( $args['section_id'] ) {
342
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ));
343
-        } else {
344
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
345
-        }
340
+		//If field is in repeating section
341
+		if ( $args['section_id'] ) {
342
+			$html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ));
343
+		} else {
344
+			$html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
345
+		}
346 346
 
347 347
 		self::remove_collapse_shortcode( $html );
348 348
 
@@ -350,18 +350,18 @@  discard block
 block discarded – undo
350 350
 			$html = do_shortcode( $html );
351 351
 		}
352 352
 
353
-        return $html;
354
-    }
353
+		return $html;
354
+	}
355 355
 
356 356
 	/**
357
-	* Add more classes to certain fields (like confirmation fields, other fields, repeating fields, etc.)
358
-	*
359
-	* @since 2.0
360
-	* @param $error_class string, pass by reference
361
-	* @param $field array
362
-	* @param $field_id int
363
-	* @param $html string
364
-	*/
357
+	 * Add more classes to certain fields (like confirmation fields, other fields, repeating fields, etc.)
358
+	 *
359
+	 * @since 2.0
360
+	 * @param $error_class string, pass by reference
361
+	 * @param $field array
362
+	 * @param $field_id int
363
+	 * @param $html string
364
+	 */
365 365
 	private static function get_more_field_classes( &$error_class, $field, $field_id, $html ) {
366 366
 		$error_class .= ' frm_'. $field['label'] .'_container';
367 367
 		if ( $field['id'] != $field_id ) {
@@ -425,46 +425,46 @@  discard block
 block discarded – undo
425 425
 		}
426 426
 	}
427 427
 
428
-    public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
429
-        if ( $no_vars ) {
430
-            $html = str_replace( '[if '. $code.']', '', $html );
431
-    	    $html = str_replace( '[/if '. $code.']', '', $html );
432
-        } else {
433
-            $html = preg_replace( '/(\[if\s+'. $code .'\])(.*?)(\[\/if\s+'. $code .'\])/mis', '', $html );
434
-        }
428
+	public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
429
+		if ( $no_vars ) {
430
+			$html = str_replace( '[if '. $code.']', '', $html );
431
+			$html = str_replace( '[/if '. $code.']', '', $html );
432
+		} else {
433
+			$html = preg_replace( '/(\[if\s+'. $code .'\])(.*?)(\[\/if\s+'. $code .'\])/mis', '', $html );
434
+		}
435 435
 
436
-        $html = str_replace( '['. $code .']', $replace_with, $html );
437
-    }
436
+		$html = str_replace( '['. $code .']', $replace_with, $html );
437
+	}
438 438
 
439 439
 	public static function get_shortcode_tag( $shortcodes, $short_key, $args ) {
440 440
 		$args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) );
441
-        if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
442
-            $args['conditional_check'] = true;
443
-        }
444
-
445
-        $prefix = '';
446
-        if ( $args['conditional_check'] ) {
447
-            if ( $args['conditional'] ) {
448
-                $prefix = 'if ';
449
-            } else if ( $args['foreach'] ) {
450
-                $prefix = 'foreach ';
451
-            }
452
-        }
453
-
454
-        $with_tags = $args['conditional_check'] ? 3 : 2;
455
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
456
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
457
-            $tag = str_replace(']', '', $tag);
458
-            $tags = explode(' ', $tag);
459
-            if ( is_array($tags) ) {
460
-                $tag = $tags[0];
461
-            }
462
-        } else {
463
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
464
-        }
465
-
466
-        return $tag;
467
-    }
441
+		if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
442
+			$args['conditional_check'] = true;
443
+		}
444
+
445
+		$prefix = '';
446
+		if ( $args['conditional_check'] ) {
447
+			if ( $args['conditional'] ) {
448
+				$prefix = 'if ';
449
+			} else if ( $args['foreach'] ) {
450
+				$prefix = 'foreach ';
451
+			}
452
+		}
453
+
454
+		$with_tags = $args['conditional_check'] ? 3 : 2;
455
+		if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
456
+			$tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
457
+			$tag = str_replace(']', '', $tag);
458
+			$tags = explode(' ', $tag);
459
+			if ( is_array($tags) ) {
460
+				$tag = $tags[0];
461
+			}
462
+		} else {
463
+			$tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
464
+		}
465
+
466
+		return $tag;
467
+	}
468 468
 
469 469
 	/**
470 470
 	 * Remove [collapse_this] if it's still included after all processing
@@ -477,128 +477,128 @@  discard block
 block discarded – undo
477 477
 	}
478 478
 
479 479
 	public static function display_recaptcha( $field ) {
480
-        $frm_settings = FrmAppHelper::get_settings();
481
-        $lang = apply_filters('frm_recaptcha_lang', $frm_settings->re_lang, $field);
480
+		$frm_settings = FrmAppHelper::get_settings();
481
+		$lang = apply_filters('frm_recaptcha_lang', $frm_settings->re_lang, $field);
482 482
 
483
-        $api_js_url = 'https://www.google.com/recaptcha/api.js?onload=frmRecaptcha&render=explicit';
484
-        if ( $lang != 'en' ) {
485
-            $api_js_url .= '&hl='. $lang;
486
-        }
487
-        $api_js_url = apply_filters('frm_recpatcha_js_url', $api_js_url);
483
+		$api_js_url = 'https://www.google.com/recaptcha/api.js?onload=frmRecaptcha&render=explicit';
484
+		if ( $lang != 'en' ) {
485
+			$api_js_url .= '&hl='. $lang;
486
+		}
487
+		$api_js_url = apply_filters('frm_recpatcha_js_url', $api_js_url);
488 488
 
489
-        wp_register_script('recaptcha-api', $api_js_url, '', true);
490
-        wp_enqueue_script('recaptcha-api');
489
+		wp_register_script('recaptcha-api', $api_js_url, '', true);
490
+		wp_enqueue_script('recaptcha-api');
491 491
 
492 492
 ?>
493 493
 <div id="field_<?php echo esc_attr( $field['field_key'] ) ?>" class="frm-g-recaptcha" data-sitekey="<?php echo esc_attr( $frm_settings->pubkey ) ?>" data-size="<?php echo esc_attr( $field['captcha_size'] ) ?>"></div>
494 494
 <?php
495
-    }
495
+	}
496 496
 
497 497
 	public static function show_single_option( $field ) {
498
-        $field_name = $field['name'];
499
-        $html_id = self::get_html_id($field);
500
-        foreach ( $field['options'] as $opt_key => $opt ) {
501
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
502
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
498
+		$field_name = $field['name'];
499
+		$html_id = self::get_html_id($field);
500
+		foreach ( $field['options'] as $opt_key => $opt ) {
501
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
502
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
503 503
 
504
-            // If this is an "Other" option, get the HTML for it
504
+			// If this is an "Other" option, get the HTML for it
505 505
 			if ( self::is_other_opt( $opt_key ) ) {
506
-                // Get string for Other text field, if needed
506
+				// Get string for Other text field, if needed
507 507
 				$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
508
-                require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php');
509
-            } else {
510
-                require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php');
511
-            }
512
-        }
513
-    }
508
+				require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php');
509
+			} else {
510
+				require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php');
511
+			}
512
+		}
513
+	}
514 514
 
515 515
 	public static function dropdown_categories( $args ) {
516 516
 		$defaults = array( 'field' => false, 'name' => false, 'show_option_all' => ' ' );
517
-        $args = wp_parse_args($args, $defaults);
517
+		$args = wp_parse_args($args, $defaults);
518 518
 
519
-        if ( ! $args['field'] ) {
520
-            return;
521
-        }
519
+		if ( ! $args['field'] ) {
520
+			return;
521
+		}
522 522
 
523
-        if ( ! $args['name'] ) {
524
-            $args['name'] = 'item_meta['. $args['field']['id'] .']';
525
-        }
523
+		if ( ! $args['name'] ) {
524
+			$args['name'] = 'item_meta['. $args['field']['id'] .']';
525
+		}
526 526
 
527
-        $id = self::get_html_id($args['field']);
528
-        $class = $args['field']['type'];
527
+		$id = self::get_html_id($args['field']);
528
+		$class = $args['field']['type'];
529 529
 
530
-        $exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat'];
531
-        $exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']);
530
+		$exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat'];
531
+		$exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']);
532 532
 
533
-        if ( is_array($args['field']['value']) ) {
534
-            if ( ! empty($exclude) ) {
535
-                $args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude));
536
-            }
537
-            $selected = reset($args['field']['value']);
538
-        } else {
539
-            $selected = $args['field']['value'];
540
-        }
533
+		if ( is_array($args['field']['value']) ) {
534
+			if ( ! empty($exclude) ) {
535
+				$args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude));
536
+			}
537
+			$selected = reset($args['field']['value']);
538
+		} else {
539
+			$selected = $args['field']['value'];
540
+		}
541 541
 
542
-        $tax_atts = array(
543
-            'show_option_all' => $args['show_option_all'], 'hierarchical' => 1, 'name' => $args['name'],
544
-            'id' => $id, 'exclude' => $exclude, 'class' => $class, 'selected' => $selected,
545
-            'hide_empty' => false, 'echo' => 0, 'orderby' => 'name',
546
-        );
542
+		$tax_atts = array(
543
+			'show_option_all' => $args['show_option_all'], 'hierarchical' => 1, 'name' => $args['name'],
544
+			'id' => $id, 'exclude' => $exclude, 'class' => $class, 'selected' => $selected,
545
+			'hide_empty' => false, 'echo' => 0, 'orderby' => 'name',
546
+		);
547 547
 
548
-        $tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']);
548
+		$tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']);
549 549
 
550
-        if ( FrmAppHelper::pro_is_installed() ) {
551
-            $post_type = FrmProFormsHelper::post_type($args['field']['form_id']);
552
-            $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']);
553
-            if ( ! $tax_atts['taxonomy'] ) {
554
-                return;
555
-            }
550
+		if ( FrmAppHelper::pro_is_installed() ) {
551
+			$post_type = FrmProFormsHelper::post_type($args['field']['form_id']);
552
+			$tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']);
553
+			if ( ! $tax_atts['taxonomy'] ) {
554
+				return;
555
+			}
556 556
 
557
-            // If field type is dropdown (not Dynamic), exclude children when parent is excluded
558
-            if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) {
559
-                $tax_atts['exclude_tree'] = $exclude;
560
-            }
561
-        }
557
+			// If field type is dropdown (not Dynamic), exclude children when parent is excluded
558
+			if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) {
559
+				$tax_atts['exclude_tree'] = $exclude;
560
+			}
561
+		}
562 562
 
563
-        $dropdown = wp_dropdown_categories($tax_atts);
563
+		$dropdown = wp_dropdown_categories($tax_atts);
564 564
 
565
-        $add_html = FrmFieldsController::input_html($args['field'], false);
565
+		$add_html = FrmFieldsController::input_html($args['field'], false);
566 566
 
567
-        if ( FrmAppHelper::pro_is_installed() ) {
568
-            $add_html .= FrmProFieldsController::input_html($args['field'], false);
569
-        }
567
+		if ( FrmAppHelper::pro_is_installed() ) {
568
+			$add_html .= FrmProFieldsController::input_html($args['field'], false);
569
+		}
570 570
 
571 571
 		$dropdown = str_replace( "<select name='" . esc_attr( $args['name'] ) ."' id='" . esc_attr( $id ) . "' class='" . esc_attr( $class ) . "'", "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' " . $add_html, $dropdown );
572 572
 
573
-        if ( is_array($args['field']['value']) ) {
574
-            $skip = true;
575
-            foreach ( $args['field']['value'] as $v ) {
573
+		if ( is_array($args['field']['value']) ) {
574
+			$skip = true;
575
+			foreach ( $args['field']['value'] as $v ) {
576 576
 				if ( $skip ) {
577
-                    $skip = false;
578
-                    continue;
579
-                }
577
+					$skip = false;
578
+					continue;
579
+				}
580 580
 				$dropdown = str_replace(' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown );
581
-                unset($v);
582
-            }
583
-        }
581
+				unset($v);
582
+			}
583
+		}
584 584
 
585
-        return $dropdown;
586
-    }
585
+		return $dropdown;
586
+	}
587 587
 
588 588
 	public static function get_term_link( $tax_id ) {
589
-        $tax = get_taxonomy($tax_id);
590
-        if ( ! $tax ) {
591
-            return;
592
-        }
589
+		$tax = get_taxonomy($tax_id);
590
+		if ( ! $tax ) {
591
+			return;
592
+		}
593 593
 
594
-        $link = sprintf(
595
-            __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
596
-            '<a href="'. esc_url( admin_url( 'edit-tags.php?taxonomy='. $tax->name ) ) .'" target="_blank">'. ( empty($tax->labels->name) ? __( 'Categories' ) : $tax->labels->name ) .'</a>'
597
-        );
598
-        unset($tax);
594
+		$link = sprintf(
595
+			__( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
596
+			'<a href="'. esc_url( admin_url( 'edit-tags.php?taxonomy='. $tax->name ) ) .'" target="_blank">'. ( empty($tax->labels->name) ? __( 'Categories' ) : $tax->labels->name ) .'</a>'
597
+		);
598
+		unset($tax);
599 599
 
600
-        return $link;
601
-    }
600
+		return $link;
601
+	}
602 602
 
603 603
 	public static function value_meets_condition( $observed_value, $cond, $hide_opt ) {
604 604
 		// Remove white space from hide_opt
@@ -606,195 +606,195 @@  discard block
 block discarded – undo
606 606
 			$hide_opt = rtrim( $hide_opt );
607 607
 		}
608 608
 
609
-        if ( is_array($observed_value) ) {
610
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
611
-        }
612
-
613
-        $m = false;
614
-        if ( $cond == '==' ) {
615
-            $m = $observed_value == $hide_opt;
616
-        } else if ( $cond == '!=' ) {
617
-            $m = $observed_value != $hide_opt;
618
-        } else if ( $cond == '>' ) {
619
-            $m = $observed_value > $hide_opt;
620
-        } else if ( $cond == '<' ) {
621
-            $m = $observed_value < $hide_opt;
622
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
623
-            $m = stripos($observed_value, $hide_opt);
624
-            if ( $cond == 'not LIKE' ) {
625
-                $m = ( $m === false ) ? true : false;
626
-            } else {
627
-                $m = ( $m === false ) ? false : true;
628
-            }
629
-        }
630
-        return $m;
631
-    }
609
+		if ( is_array($observed_value) ) {
610
+			return self::array_value_condition($observed_value, $cond, $hide_opt);
611
+		}
612
+
613
+		$m = false;
614
+		if ( $cond == '==' ) {
615
+			$m = $observed_value == $hide_opt;
616
+		} else if ( $cond == '!=' ) {
617
+			$m = $observed_value != $hide_opt;
618
+		} else if ( $cond == '>' ) {
619
+			$m = $observed_value > $hide_opt;
620
+		} else if ( $cond == '<' ) {
621
+			$m = $observed_value < $hide_opt;
622
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
623
+			$m = stripos($observed_value, $hide_opt);
624
+			if ( $cond == 'not LIKE' ) {
625
+				$m = ( $m === false ) ? true : false;
626
+			} else {
627
+				$m = ( $m === false ) ? false : true;
628
+			}
629
+		}
630
+		return $m;
631
+	}
632 632
 
633 633
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
634
-        $m = false;
635
-        if ( $cond == '==' ) {
636
-            if ( is_array($hide_opt) ) {
637
-                $m = array_intersect($hide_opt, $observed_value);
638
-                $m = empty($m) ? false : true;
639
-            } else {
640
-                $m = in_array($hide_opt, $observed_value);
641
-            }
642
-        } else if ( $cond == '!=' ) {
643
-            $m = ! in_array($hide_opt, $observed_value);
644
-        } else if ( $cond == '>' ) {
645
-            $min = min($observed_value);
646
-            $m = $min > $hide_opt;
647
-        } else if ( $cond == '<' ) {
648
-            $max = max($observed_value);
649
-            $m = $max < $hide_opt;
650
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
651
-            foreach ( $observed_value as $ob ) {
652
-                $m = strpos($ob, $hide_opt);
653
-                if ( $m !== false ) {
654
-                    $m = true;
655
-                    break;
656
-                }
657
-            }
658
-
659
-            if ( $cond == 'not LIKE' ) {
660
-                $m = ( $m === false ) ? true : false;
661
-            }
662
-        }
663
-
664
-        return $m;
665
-    }
666
-
667
-    /**
668
-     * Replace a few basic shortcodes and field ids
669
-     * @since 2.0
670
-     * @return string
671
-     */
634
+		$m = false;
635
+		if ( $cond == '==' ) {
636
+			if ( is_array($hide_opt) ) {
637
+				$m = array_intersect($hide_opt, $observed_value);
638
+				$m = empty($m) ? false : true;
639
+			} else {
640
+				$m = in_array($hide_opt, $observed_value);
641
+			}
642
+		} else if ( $cond == '!=' ) {
643
+			$m = ! in_array($hide_opt, $observed_value);
644
+		} else if ( $cond == '>' ) {
645
+			$min = min($observed_value);
646
+			$m = $min > $hide_opt;
647
+		} else if ( $cond == '<' ) {
648
+			$max = max($observed_value);
649
+			$m = $max < $hide_opt;
650
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
651
+			foreach ( $observed_value as $ob ) {
652
+				$m = strpos($ob, $hide_opt);
653
+				if ( $m !== false ) {
654
+					$m = true;
655
+					break;
656
+				}
657
+			}
658
+
659
+			if ( $cond == 'not LIKE' ) {
660
+				$m = ( $m === false ) ? true : false;
661
+			}
662
+		}
663
+
664
+		return $m;
665
+	}
666
+
667
+	/**
668
+	 * Replace a few basic shortcodes and field ids
669
+	 * @since 2.0
670
+	 * @return string
671
+	 */
672 672
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
673
-        if ( strpos($value, '[sitename]') !== false ) {
674
-            $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
675
-            $value = str_replace('[sitename]', $new_value, $value);
676
-        }
673
+		if ( strpos($value, '[sitename]') !== false ) {
674
+			$new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
675
+			$value = str_replace('[sitename]', $new_value, $value);
676
+		}
677 677
 
678
-        $value = apply_filters('frm_content', $value, $form, $entry);
679
-        $value = do_shortcode($value);
678
+		$value = apply_filters('frm_content', $value, $form, $entry);
679
+		$value = do_shortcode($value);
680 680
 
681
-        return $value;
682
-    }
681
+		return $value;
682
+	}
683 683
 
684 684
 	public static function get_shortcodes( $content, $form_id ) {
685
-        if ( FrmAppHelper::pro_is_installed() ) {
686
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
687
-        }
685
+		if ( FrmAppHelper::pro_is_installed() ) {
686
+			return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
687
+		}
688 688
 
689
-        $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
689
+		$fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
690 690
 
691
-        $tagregexp = self::allowed_shortcodes($fields);
691
+		$tagregexp = self::allowed_shortcodes($fields);
692 692
 
693
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
693
+		preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
694 694
 
695
-        return $matches;
696
-    }
695
+		return $matches;
696
+	}
697 697
 
698 698
 	public static function allowed_shortcodes( $fields = array() ) {
699
-        $tagregexp = array(
700
-            'editlink', 'id', 'key', 'ip',
701
-            'siteurl', 'sitename', 'admin_email',
702
-            'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
699
+		$tagregexp = array(
700
+			'editlink', 'id', 'key', 'ip',
701
+			'siteurl', 'sitename', 'admin_email',
702
+			'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
703 703
 			'parent[-|_]id',
704
-        );
704
+		);
705 705
 
706
-        foreach ( $fields as $field ) {
707
-            $tagregexp[] = $field->id;
708
-            $tagregexp[] = $field->field_key;
709
-        }
706
+		foreach ( $fields as $field ) {
707
+			$tagregexp[] = $field->id;
708
+			$tagregexp[] = $field->field_key;
709
+		}
710 710
 
711
-        $tagregexp = implode('|', $tagregexp);
712
-        return $tagregexp;
713
-    }
711
+		$tagregexp = implode('|', $tagregexp);
712
+		return $tagregexp;
713
+	}
714 714
 
715 715
 	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
716
-        $shortcode_values = array(
717
-           'id'     => $entry->id,
718
-           'key'    => $entry->item_key,
719
-           'ip'     => $entry->ip,
720
-        );
716
+		$shortcode_values = array(
717
+		   'id'     => $entry->id,
718
+		   'key'    => $entry->item_key,
719
+		   'ip'     => $entry->ip,
720
+		);
721 721
 
722
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
723
-            $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
722
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
723
+			$atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
724 724
 
725
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
725
+			if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
726 726
 				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
727
-                $tags = explode(' ', $tag);
728
-                if ( is_array($tags) ) {
729
-                    $tag = $tags[0];
730
-                }
731
-            } else {
732
-                $tag = $shortcodes[2][ $short_key ];
733
-            }
734
-
735
-            switch ( $tag ) {
736
-                case 'id':
737
-                case 'key':
738
-                case 'ip':
739
-                    $replace_with = $shortcode_values[ $tag ];
740
-                break;
741
-
742
-                case 'user_agent':
743
-                case 'user-agent':
744
-                    $entry->description = maybe_unserialize($entry->description);
727
+				$tags = explode(' ', $tag);
728
+				if ( is_array($tags) ) {
729
+					$tag = $tags[0];
730
+				}
731
+			} else {
732
+				$tag = $shortcodes[2][ $short_key ];
733
+			}
734
+
735
+			switch ( $tag ) {
736
+				case 'id':
737
+				case 'key':
738
+				case 'ip':
739
+					$replace_with = $shortcode_values[ $tag ];
740
+				break;
741
+
742
+				case 'user_agent':
743
+				case 'user-agent':
744
+					$entry->description = maybe_unserialize($entry->description);
745 745
 					$replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] );
746
-                break;
747
-
748
-                case 'created_at':
749
-                case 'created-at':
750
-                case 'updated_at':
751
-                case 'updated-at':
752
-                    if ( isset($atts['format']) ) {
753
-                        $time_format = ' ';
754
-                    } else {
755
-                        $atts['format'] = get_option('date_format');
756
-                        $time_format = '';
757
-                    }
758
-
759
-                    $this_tag = str_replace('-', '_', $tag);
760
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
761
-                    unset($this_tag);
762
-                break;
763
-
764
-                case 'created_by':
765
-                case 'created-by':
766
-                case 'updated_by':
767
-                case 'updated-by':
768
-                    $this_tag = str_replace('-', '_', $tag);
746
+				break;
747
+
748
+				case 'created_at':
749
+				case 'created-at':
750
+				case 'updated_at':
751
+				case 'updated-at':
752
+					if ( isset($atts['format']) ) {
753
+						$time_format = ' ';
754
+					} else {
755
+						$atts['format'] = get_option('date_format');
756
+						$time_format = '';
757
+					}
758
+
759
+					$this_tag = str_replace('-', '_', $tag);
760
+					$replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
761
+					unset($this_tag);
762
+				break;
763
+
764
+				case 'created_by':
765
+				case 'created-by':
766
+				case 'updated_by':
767
+				case 'updated-by':
768
+					$this_tag = str_replace('-', '_', $tag);
769 769
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
770
-                    unset($this_tag);
771
-                break;
772
-
773
-                case 'admin_email':
774
-                case 'siteurl':
775
-                case 'frmurl':
776
-                case 'sitename':
777
-                case 'get':
778
-                    $replace_with = self::dynamic_default_values( $tag, $atts );
779
-                break;
780
-
781
-                default:
782
-                    $field = FrmField::getOne( $tag );
783
-                    if ( ! $field ) {
784
-                        break;
785
-                    }
786
-
787
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
788
-
789
-                    $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
790
-
791
-                    $atts['entry_id'] = $entry->id;
792
-                    $atts['entry_key'] = $entry->item_key;
793
-
794
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
795
-                        $replace_with = $field->name;
796
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
797
-                        $replace_with = $field->description;
770
+					unset($this_tag);
771
+				break;
772
+
773
+				case 'admin_email':
774
+				case 'siteurl':
775
+				case 'frmurl':
776
+				case 'sitename':
777
+				case 'get':
778
+					$replace_with = self::dynamic_default_values( $tag, $atts );
779
+				break;
780
+
781
+				default:
782
+					$field = FrmField::getOne( $tag );
783
+					if ( ! $field ) {
784
+						break;
785
+					}
786
+
787
+					$sep = isset($atts['sep']) ? $atts['sep'] : ', ';
788
+
789
+					$replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
790
+
791
+					$atts['entry_id'] = $entry->id;
792
+					$atts['entry_key'] = $entry->item_key;
793
+
794
+					if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
795
+						$replace_with = $field->name;
796
+					} else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
797
+						$replace_with = $field->description;
798 798
 					} else {
799 799
 						$string_value = $replace_with;
800 800
 						if ( is_array( $replace_with ) ) {
@@ -808,82 +808,82 @@  discard block
 block discarded – undo
808 808
 						}
809 809
 					}
810 810
 
811
-                    unset($field);
812
-                break;
813
-            }
811
+					unset($field);
812
+				break;
813
+			}
814 814
 
815
-            if ( isset($replace_with) ) {
816
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
817
-            }
815
+			if ( isset($replace_with) ) {
816
+				$content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
817
+			}
818 818
 
819
-            unset($atts, $conditional, $replace_with);
819
+			unset($atts, $conditional, $replace_with);
820 820
 		}
821 821
 
822 822
 		return $content;
823
-    }
824
-
825
-    /**
826
-     * Get the value to replace a few standard shortcodes
827
-     *
828
-     * @since 2.0
829
-     * @return string
830
-     */
831
-    public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
832
-        $new_value = '';
833
-        switch ( $tag ) {
834
-            case 'admin_email':
835
-                $new_value = get_option('admin_email');
836
-                break;
837
-            case 'siteurl':
838
-                $new_value = FrmAppHelper::site_url();
839
-                break;
840
-            case 'frmurl':
841
-                $new_value = FrmAppHelper::plugin_url();
842
-                break;
843
-            case 'sitename':
844
-                $new_value = FrmAppHelper::site_name();
845
-                break;
846
-            case 'get':
847
-                $new_value = self::process_get_shortcode( $atts, $return_array );
848
-                break;
849
-        }
850
-
851
-        return $new_value;
852
-    }
853
-
854
-    /**
855
-     * Process the [get] shortcode
856
-     *
857
-     * @since 2.0
858
-     * @return string|array
859
-     */
860
-    public static function process_get_shortcode( $atts, $return_array = false ) {
861
-        if ( ! isset($atts['param']) ) {
862
-            return '';
863
-        }
864
-
865
-        if ( strpos($atts['param'], '&#91;') ) {
866
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
867
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
868
-        }
869
-
870
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
871
-        $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
872
-
873
-        if ( $new_value == '' ) {
874
-            if ( ! isset($atts['prev_val']) ) {
875
-                $atts['prev_val'] = '';
876
-            }
877
-
878
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
879
-        }
880
-
881
-        if ( is_array($new_value) && ! $return_array ) {
882
-            $new_value = implode(', ', $new_value);
883
-        }
884
-
885
-        return $new_value;
886
-    }
823
+	}
824
+
825
+	/**
826
+	 * Get the value to replace a few standard shortcodes
827
+	 *
828
+	 * @since 2.0
829
+	 * @return string
830
+	 */
831
+	public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
832
+		$new_value = '';
833
+		switch ( $tag ) {
834
+			case 'admin_email':
835
+				$new_value = get_option('admin_email');
836
+				break;
837
+			case 'siteurl':
838
+				$new_value = FrmAppHelper::site_url();
839
+				break;
840
+			case 'frmurl':
841
+				$new_value = FrmAppHelper::plugin_url();
842
+				break;
843
+			case 'sitename':
844
+				$new_value = FrmAppHelper::site_name();
845
+				break;
846
+			case 'get':
847
+				$new_value = self::process_get_shortcode( $atts, $return_array );
848
+				break;
849
+		}
850
+
851
+		return $new_value;
852
+	}
853
+
854
+	/**
855
+	 * Process the [get] shortcode
856
+	 *
857
+	 * @since 2.0
858
+	 * @return string|array
859
+	 */
860
+	public static function process_get_shortcode( $atts, $return_array = false ) {
861
+		if ( ! isset($atts['param']) ) {
862
+			return '';
863
+		}
864
+
865
+		if ( strpos($atts['param'], '&#91;') ) {
866
+			$atts['param'] = str_replace('&#91;', '[', $atts['param']);
867
+			$atts['param'] = str_replace('&#93;', ']', $atts['param']);
868
+		}
869
+
870
+		$new_value = FrmAppHelper::get_param($atts['param'], '');
871
+		$new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
872
+
873
+		if ( $new_value == '' ) {
874
+			if ( ! isset($atts['prev_val']) ) {
875
+				$atts['prev_val'] = '';
876
+			}
877
+
878
+			$new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
879
+		}
880
+
881
+		if ( is_array($new_value) && ! $return_array ) {
882
+			$new_value = implode(', ', $new_value);
883
+		}
884
+
885
+		return $new_value;
886
+	}
887 887
 
888 888
 	public static function get_display_value( $replace_with, $field, $atts = array() ) {
889 889
 		$atts['sep'] = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
@@ -891,14 +891,14 @@  discard block
 block discarded – undo
891 891
 		$replace_with = apply_filters( 'frm_get_' . $field->type . '_display_value', $replace_with, $field, $atts );
892 892
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
893 893
 
894
-        if ( $field->type == 'textarea' || $field->type == 'rte' ) {
895
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
896
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
897
-                if ( is_array($replace_with) ) {
898
-                    $replace_with = implode("\n", $replace_with);
899
-                }
900
-                $replace_with = wpautop($replace_with);
901
-            }
894
+		if ( $field->type == 'textarea' || $field->type == 'rte' ) {
895
+			$autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
896
+			if ( apply_filters('frm_use_wpautop', $autop) ) {
897
+				if ( is_array($replace_with) ) {
898
+					$replace_with = implode("\n", $replace_with);
899
+				}
900
+				$replace_with = wpautop($replace_with);
901
+			}
902 902
 			unset( $autop );
903 903
 		} else if ( is_array( $replace_with ) ) {
904 904
 			$replace_with = implode( $atts['sep'], $replace_with );
@@ -908,57 +908,57 @@  discard block
 block discarded – undo
908 908
 	}
909 909
 
910 910
 	public static function get_field_types( $type ) {
911
-        $single_input = array(
912
-            'text', 'textarea', 'rte', 'number', 'email', 'url',
913
-            'image', 'file', 'date', 'phone', 'hidden', 'time',
914
-            'user_id', 'tag', 'password',
915
-        );
911
+		$single_input = array(
912
+			'text', 'textarea', 'rte', 'number', 'email', 'url',
913
+			'image', 'file', 'date', 'phone', 'hidden', 'time',
914
+			'user_id', 'tag', 'password',
915
+		);
916 916
 		$multiple_input = array( 'radio', 'checkbox', 'select', 'scale' );
917 917
 		$other_type = array( 'divider', 'html', 'break' );
918 918
 
919 919
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
920 920
 
921
-        $field_types = array();
922
-        if ( in_array($type, $single_input) ) {
923
-            self::field_types_for_input( $single_input, $field_selection, $field_types );
924
-        } else if ( in_array($type, $multiple_input) ) {
925
-            self::field_types_for_input( $multiple_input, $field_selection, $field_types );
926
-        } else if ( in_array($type, $other_type) ) {
927
-            self::field_types_for_input( $other_type, $field_selection, $field_types );
921
+		$field_types = array();
922
+		if ( in_array($type, $single_input) ) {
923
+			self::field_types_for_input( $single_input, $field_selection, $field_types );
924
+		} else if ( in_array($type, $multiple_input) ) {
925
+			self::field_types_for_input( $multiple_input, $field_selection, $field_types );
926
+		} else if ( in_array($type, $other_type) ) {
927
+			self::field_types_for_input( $other_type, $field_selection, $field_types );
928 928
 		} else if ( isset( $field_selection[ $type ] ) ) {
929
-            $field_types[ $type ] = $field_selection[ $type ];
930
-        }
931
-
932
-        return $field_types;
933
-    }
934
-
935
-    private static function field_types_for_input( $inputs, $fields, &$field_types ) {
936
-        foreach ( $inputs as $input ) {
937
-            $field_types[ $input ] = $fields[ $input ];
938
-            unset($input);
939
-        }
940
-    }
941
-
942
-    /**
943
-    * Check if current field option is an "other" option
944
-    *
945
-    * @since 2.0.6
946
-    *
947
-    * @param string $opt_key
948
-    * @return boolean Returns true if current field option is an "Other" option
949
-    */
950
-    public static function is_other_opt( $opt_key ) {
951
-        return $opt_key && strpos( $opt_key, 'other' ) !== false;
952
-    }
953
-
954
-    /**
955
-    * Get value that belongs in "Other" text box
956
-    *
957
-    * @since 2.0.6
958
-    *
959
-    * @param array $args
960
-    */
961
-    public static function get_other_val( $args ) {
929
+			$field_types[ $type ] = $field_selection[ $type ];
930
+		}
931
+
932
+		return $field_types;
933
+	}
934
+
935
+	private static function field_types_for_input( $inputs, $fields, &$field_types ) {
936
+		foreach ( $inputs as $input ) {
937
+			$field_types[ $input ] = $fields[ $input ];
938
+			unset($input);
939
+		}
940
+	}
941
+
942
+	/**
943
+	 * Check if current field option is an "other" option
944
+	 *
945
+	 * @since 2.0.6
946
+	 *
947
+	 * @param string $opt_key
948
+	 * @return boolean Returns true if current field option is an "Other" option
949
+	 */
950
+	public static function is_other_opt( $opt_key ) {
951
+		return $opt_key && strpos( $opt_key, 'other' ) !== false;
952
+	}
953
+
954
+	/**
955
+	 * Get value that belongs in "Other" text box
956
+	 *
957
+	 * @since 2.0.6
958
+	 *
959
+	 * @param array $args
960
+	 */
961
+	public static function get_other_val( $args ) {
962 962
 		$defaults = array(
963 963
 			'opt_key' => 0, 'field' => array(),
964 964
 			'parent' => false, 'pointer' => false,
@@ -1034,20 +1034,20 @@  discard block
 block discarded – undo
1034 1034
 		}
1035 1035
 
1036 1036
 		return $other_val;
1037
-    }
1038
-
1039
-    /**
1040
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
1041
-    * Intended for front-end use
1042
-    *
1043
-    * @since 2.0.6
1044
-    *
1045
-    * @param array $args should include field, opt_key and field name
1046
-    * @param boolean $other_opt
1047
-    * @param string $checked
1048
-    * @return string $other_val
1049
-    */
1050
-    public static function prepare_other_input( $args, &$other_opt, &$checked ) {
1037
+	}
1038
+
1039
+	/**
1040
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
1041
+	 * Intended for front-end use
1042
+	 *
1043
+	 * @since 2.0.6
1044
+	 *
1045
+	 * @param array $args should include field, opt_key and field name
1046
+	 * @param boolean $other_opt
1047
+	 * @param string $checked
1048
+	 * @return string $other_val
1049
+	 */
1050
+	public static function prepare_other_input( $args, &$other_opt, &$checked ) {
1051 1051
 		//Check if this is an "Other" option
1052 1052
 		if ( ! self::is_other_opt( $args['opt_key'] ) ) {
1053 1053
 			return;
@@ -1063,8 +1063,8 @@  discard block
 block discarded – undo
1063 1063
 			$checked = 'checked="checked" ';
1064 1064
 		}
1065 1065
 
1066
-        return $other_args;
1067
-    }
1066
+		return $other_args;
1067
+	}
1068 1068
 
1069 1069
 	/**
1070 1070
 	 * @param array $args
@@ -1113,8 +1113,8 @@  discard block
 block discarded – undo
1113 1113
 	 * @since 2.0.6
1114 1114
 	 */
1115 1115
 	public static function include_other_input( $args ) {
1116
-        if ( ! $args['other_opt'] ) {
1117
-        	return;
1116
+		if ( ! $args['other_opt'] ) {
1117
+			return;
1118 1118
 		}
1119 1119
 
1120 1120
 		$classes = array( 'frm_other_input' );
@@ -1135,15 +1135,15 @@  discard block
 block discarded – undo
1135 1135
 	}
1136 1136
 
1137 1137
 	/**
1138
-	* Get the HTML id for an "Other" text field
1139
-	* Note: This does not affect fields in repeating sections
1140
-	*
1141
-	* @since 2.0.08
1142
-	* @param string $type - field type
1143
-	* @param string $html_id
1144
-	* @param string|boolean $opt_key
1145
-	* @return string $other_id
1146
-	*/
1138
+	 * Get the HTML id for an "Other" text field
1139
+	 * Note: This does not affect fields in repeating sections
1140
+	 *
1141
+	 * @since 2.0.08
1142
+	 * @param string $type - field type
1143
+	 * @param string $html_id
1144
+	 * @param string|boolean $opt_key
1145
+	 * @return string $other_id
1146
+	 */
1147 1147
 	public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) {
1148 1148
 		$other_id = $html_id;
1149 1149
 
@@ -1201,171 +1201,171 @@  discard block
 block discarded – undo
1201 1201
 	}
1202 1202
 
1203 1203
 	public static function switch_field_ids( $val ) {
1204
-        global $frm_duplicate_ids;
1205
-        $replace = array();
1206
-        $replace_with = array();
1207
-        foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1208
-            $replace[] = '[if '. $old .']';
1209
-            $replace_with[] = '[if '. $new .']';
1210
-            $replace[] = '[if '. $old .' ';
1211
-            $replace_with[] = '[if '. $new .' ';
1212
-            $replace[] = '[/if '. $old .']';
1213
-            $replace_with[] = '[/if '. $new .']';
1214
-            $replace[] = '[foreach '. $old .']';
1215
-            $replace_with[] = '[foreach '. $new .']';
1216
-            $replace[] = '[/foreach '. $old .']';
1217
-            $replace_with[] = '[/foreach '. $new .']';
1218
-            $replace[] = '['. $old .']';
1219
-            $replace_with[] = '['. $new .']';
1220
-            $replace[] = '['. $old .' ';
1221
-            $replace_with[] = '['. $new .' ';
1222
-            unset($old, $new);
1223
-        }
1204
+		global $frm_duplicate_ids;
1205
+		$replace = array();
1206
+		$replace_with = array();
1207
+		foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1208
+			$replace[] = '[if '. $old .']';
1209
+			$replace_with[] = '[if '. $new .']';
1210
+			$replace[] = '[if '. $old .' ';
1211
+			$replace_with[] = '[if '. $new .' ';
1212
+			$replace[] = '[/if '. $old .']';
1213
+			$replace_with[] = '[/if '. $new .']';
1214
+			$replace[] = '[foreach '. $old .']';
1215
+			$replace_with[] = '[foreach '. $new .']';
1216
+			$replace[] = '[/foreach '. $old .']';
1217
+			$replace_with[] = '[/foreach '. $new .']';
1218
+			$replace[] = '['. $old .']';
1219
+			$replace_with[] = '['. $new .']';
1220
+			$replace[] = '['. $old .' ';
1221
+			$replace_with[] = '['. $new .' ';
1222
+			unset($old, $new);
1223
+		}
1224 1224
 		if ( is_array( $val ) ) {
1225 1225
 			foreach ( $val as $k => $v ) {
1226
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1227
-                unset($k, $v);
1228
-            }
1229
-        } else {
1230
-            $val = str_replace($replace, $replace_with, $val);
1231
-        }
1232
-
1233
-        return $val;
1234
-    }
1235
-
1236
-    public static function get_us_states() {
1237
-        return apply_filters( 'frm_us_states', array(
1238
-            'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1239
-            'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1240
-            'DC' => 'District of Columbia',
1241
-            'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1242
-            'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1243
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1244
-            'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1245
-            'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1246
-            'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1247
-            'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1248
-            'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1249
-            'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1250
-            'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1251
-            'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1252
-        ) );
1253
-    }
1254
-
1255
-    public static function get_countries() {
1256
-        return apply_filters( 'frm_countries', array(
1257
-            __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1258
-            __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1259
-            __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1260
-            __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1261
-            __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1262
-            __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1263
-            __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1264
-            __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1265
-            __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1266
-            __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1267
-            __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1268
-            __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1269
-            __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1270
-            __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1271
-            __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1272
-            __( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1273
-            __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1274
-            __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1275
-            __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1276
-            __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1277
-            __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1278
-            __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1279
-            __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1280
-            __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1281
-            __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1282
-            __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1283
-            __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1284
-            __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1285
-            __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1286
-            __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1287
-            __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1288
-            __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1289
-            __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1290
-            __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1291
-            __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1292
-            __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1293
-            __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1294
-            __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1295
-            __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1296
-            __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1297
-            __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1298
-            __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1299
-            __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1300
-            __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1301
-            __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1302
-            __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1303
-            __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1304
-            __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1305
-            __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1306
-            __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1307
-            __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1308
-            __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1309
-            __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1310
-            __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1311
-            __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1312
-            __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1313
-            __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1314
-            __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1315
-            __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1316
-            __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1317
-            __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1318
-            __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1319
-            __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1320
-            __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1321
-            __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1322
-            __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1323
-            __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1324
-            __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1325
-            __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1326
-            __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1327
-            __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1328
-            __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1329
-            __( 'Zimbabwe', 'formidable' ),
1330
-        ) );
1331
-    }
1226
+				$val[ $k ] = str_replace( $replace, $replace_with, $v );
1227
+				unset($k, $v);
1228
+			}
1229
+		} else {
1230
+			$val = str_replace($replace, $replace_with, $val);
1231
+		}
1232
+
1233
+		return $val;
1234
+	}
1235
+
1236
+	public static function get_us_states() {
1237
+		return apply_filters( 'frm_us_states', array(
1238
+			'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1239
+			'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1240
+			'DC' => 'District of Columbia',
1241
+			'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1242
+			'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1243
+			'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1244
+			'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1245
+			'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1246
+			'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1247
+			'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1248
+			'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1249
+			'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1250
+			'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1251
+			'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1252
+		) );
1253
+	}
1254
+
1255
+	public static function get_countries() {
1256
+		return apply_filters( 'frm_countries', array(
1257
+			__( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1258
+			__( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1259
+			__( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1260
+			__( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1261
+			__( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1262
+			__( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1263
+			__( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1264
+			__( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1265
+			__( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1266
+			__( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1267
+			__( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1268
+			__( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1269
+			__( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1270
+			__( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1271
+			__( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1272
+			__( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1273
+			__( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1274
+			__( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1275
+			__( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1276
+			__( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1277
+			__( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1278
+			__( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1279
+			__( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1280
+			__( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1281
+			__( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1282
+			__( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1283
+			__( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1284
+			__( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1285
+			__( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1286
+			__( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1287
+			__( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1288
+			__( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1289
+			__( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1290
+			__( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1291
+			__( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1292
+			__( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1293
+			__( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1294
+			__( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1295
+			__( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1296
+			__( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1297
+			__( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1298
+			__( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1299
+			__( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1300
+			__( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1301
+			__( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1302
+			__( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1303
+			__( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1304
+			__( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1305
+			__( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1306
+			__( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1307
+			__( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1308
+			__( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1309
+			__( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1310
+			__( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1311
+			__( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1312
+			__( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1313
+			__( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1314
+			__( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1315
+			__( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1316
+			__( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1317
+			__( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1318
+			__( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1319
+			__( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1320
+			__( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1321
+			__( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1322
+			__( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1323
+			__( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1324
+			__( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1325
+			__( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1326
+			__( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1327
+			__( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1328
+			__( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1329
+			__( 'Zimbabwe', 'formidable' ),
1330
+		) );
1331
+	}
1332 1332
 
1333 1333
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1334 1334
 		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1335 1335
 
1336
-        $states = FrmFieldsHelper::get_us_states();
1337
-        $state_abv = array_keys($states);
1338
-        sort($state_abv);
1336
+		$states = FrmFieldsHelper::get_us_states();
1337
+		$state_abv = array_keys($states);
1338
+		sort($state_abv);
1339 1339
 		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1340 1340
 
1341
-        $states = array_values($states);
1342
-        sort($states);
1341
+		$states = array_values($states);
1342
+		sort($states);
1343 1343
 		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1344
-        unset($state_abv, $states);
1344
+		unset($state_abv, $states);
1345 1345
 
1346 1346
 		$prepop[ __( 'Age', 'formidable' ) ] = array(
1347
-            __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1348
-            __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1349
-            __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1350
-        );
1347
+			__( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1348
+			__( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1349
+			__( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1350
+		);
1351 1351
 
1352 1352
 		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1353
-            __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1354
-            __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1355
-        );
1353
+			__( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1354
+			__( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1355
+		);
1356 1356
 
1357 1357
 		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1358
-            __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1359
-            __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1360
-        );
1358
+			__( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1359
+			__( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1360
+		);
1361 1361
 
1362 1362
 		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1363
-            __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1364
-            __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1365
-        );
1363
+			__( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1364
+			__( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1365
+		);
1366 1366
 
1367 1367
 		$prepop = apply_filters( 'frm_bulk_field_choices', $prepop );
1368
-    }
1368
+	}
1369 1369
 
1370 1370
 	public static function field_selection() {
1371 1371
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::field_selection' );
@@ -1402,8 +1402,8 @@  discard block
 block discarded – undo
1402 1402
 		return FrmField::is_required( $field );
1403 1403
 	}
1404 1404
 
1405
-    public static function maybe_get_field( &$field ) {
1405
+	public static function maybe_get_field( &$field ) {
1406 1406
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' );
1407 1407
 		FrmField::maybe_get_field( $field );
1408
-    }
1408
+	}
1409 1409
 }
Please login to merge, or discard this patch.
Spacing   +221 added lines, -221 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
 
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
 
8 8
 	public static function setup_new_vars( $type = '', $form_id = '' ) {
9 9
 
10
-        if ( strpos($type, '|') ) {
11
-            list($type, $setting) = explode('|', $type);
10
+        if ( strpos( $type, '|' ) ) {
11
+            list( $type, $setting ) = explode( '|', $type );
12 12
         }
13 13
 
14
-        $defaults = self::get_default_field_opts($type, $form_id);
15
-        $defaults['field_options']['custom_html'] = self::get_default_html($type);
14
+        $defaults = self::get_default_field_opts( $type, $form_id );
15
+        $defaults['field_options']['custom_html'] = self::get_default_html( $type );
16 16
 
17 17
         $values = array();
18 18
 
@@ -20,20 +20,20 @@  discard block
 block discarded – undo
20 20
             if ( $var == 'field_options' ) {
21 21
                 $values['field_options'] = array();
22 22
                 foreach ( $default as $opt_var => $opt_default ) {
23
-                    $values['field_options'][ $opt_var ] = $opt_default;
24
-                    unset($opt_var, $opt_default);
23
+                    $values['field_options'][$opt_var] = $opt_default;
24
+                    unset( $opt_var, $opt_default );
25 25
                 }
26 26
             } else {
27
-                $values[ $var ] = $default;
27
+                $values[$var] = $default;
28 28
             }
29
-            unset($var, $default);
29
+            unset( $var, $default );
30 30
         }
31 31
 
32 32
         if ( isset( $setting ) && ! empty( $setting ) ) {
33 33
             if ( 'data' == $type ) {
34 34
                 $values['field_options']['data_type'] = $setting;
35 35
             } else {
36
-                $values['field_options'][ $setting ] = 1;
36
+                $values['field_options'][$setting] = 1;
37 37
             }
38 38
         }
39 39
 
@@ -56,19 +56,19 @@  discard block
 block discarded – undo
56 56
         }
57 57
 
58 58
 		$fields = FrmField::field_selection();
59
-        $fields = array_merge($fields, FrmField::pro_field_selection());
59
+        $fields = array_merge( $fields, FrmField::pro_field_selection() );
60 60
 
61
-        if ( isset( $fields[ $type ] ) ) {
62
-            $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
61
+        if ( isset( $fields[$type] ) ) {
62
+            $values['name'] = is_array( $fields[$type] ) ? $fields[$type]['name'] : $fields[$type];
63 63
         }
64 64
 
65
-        unset($fields);
65
+        unset( $fields );
66 66
 
67 67
         return $values;
68 68
     }
69 69
 
70 70
 	public static function get_html_id( $field, $plus = '' ) {
71
-        return apply_filters('frm_field_html_id', 'field_'. $field['field_key'] . $plus, $field);
71
+        return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field );
72 72
     }
73 73
 
74 74
     public static function setup_edit_vars( $record, $doing_ajax = false ) {
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
             $values['form_name'] = '';
89 89
 		} else {
90 90
 			foreach ( $defaults as $var => $default ) {
91
-                $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
-                unset($var, $default);
91
+                $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
+                unset( $var, $default );
93 93
             }
94 94
 
95 95
 			$values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : '';
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         $values['options'] = $record->options;
101 101
         $values['field_options'] = $record->field_options;
102 102
 
103
-        $defaults = self::get_default_field_opts($values['type'], $record, true);
103
+        $defaults = self::get_default_field_opts( $values['type'], $record, true );
104 104
 
105 105
 		if ( $values['type'] == 'captcha' ) {
106 106
             $frm_settings = FrmAppHelper::get_settings();
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
         }
109 109
 
110 110
 		foreach ( $defaults as $opt => $default ) {
111
-            $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
112
-            unset($opt, $default);
111
+            $values[$opt] = isset( $record->field_options[$opt] ) ? $record->field_options[$opt] : $default;
112
+            unset( $opt, $default );
113 113
         }
114 114
 
115
-        $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
115
+        $values['custom_html'] = ( isset( $record->field_options['custom_html'] ) ) ? $record->field_options['custom_html'] : self::get_default_html( $record->type );
116 116
 
117 117
 		return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) );
118 118
     }
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 
132 132
         global $wpdb;
133 133
 
134
-        $form_id = (is_numeric($field)) ? $field : $field->form_id;
134
+        $form_id = ( is_numeric( $field ) ) ? $field : $field->form_id;
135 135
 
136
-        $key = is_numeric($field) ? FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_fields', 'field_key') : $field->field_key;
136
+        $key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key;
137 137
 
138 138
         $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) );
139 139
 
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
     public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
152 152
         global $wpdb;
153 153
 
154
-        $values['field_key'] = FrmAppHelper::get_unique_key($new_key, $wpdb->prefix .'frm_fields', 'field_key');
154
+        $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
155 155
         $values['form_id'] = $form_id;
156
-        $values['options'] = maybe_serialize($field->options);
157
-        $values['default_value'] = maybe_serialize($field->default_value);
156
+        $values['options'] = maybe_serialize( $field->options );
157
+        $values['default_value'] = maybe_serialize( $field->default_value );
158 158
 
159 159
         foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
160
-            $values[ $col ] = $field->{$col};
160
+            $values[$col] = $field->{$col};
161 161
         }
162 162
     }
163 163
 
@@ -170,19 +170,19 @@  discard block
 block discarded – undo
170 170
 		$field_name = is_array( $field ) ? $field['name'] : $field->name;
171 171
 
172 172
 		$defaults = array(
173
-			'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __('%s must be unique', 'formidable' ), $field_name ) ),
174
-			'invalid'   => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __('%s is invalid', 'formidable' ), $field_name ) ),
173
+			'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __( '%s must be unique', 'formidable' ), $field_name ) ),
174
+			'invalid'   => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __( '%s is invalid', 'formidable' ), $field_name ) ),
175 175
 			'blank'     => array( 'full' => $frm_settings->blank_msg, 'part' => $frm_settings->blank_msg ),
176 176
 		);
177 177
 
178 178
 		$msg = FrmField::get_option( $field, $error );
179
-		$msg = ( $msg == $defaults[ $error ]['full'] || empty( $msg ) ) ? $defaults[ $error ]['part'] : $msg;
179
+		$msg = ( $msg == $defaults[$error]['full'] || empty( $msg ) ) ? $defaults[$error]['part'] : $msg;
180 180
 		return $msg;
181 181
 	}
182 182
 
183 183
     public static function get_form_fields( $form_id, $error = false ) {
184
-        $fields = FrmField::get_all_for_form($form_id);
185
-        $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error);
184
+        $fields = FrmField::get_all_for_form( $form_id );
185
+        $fields = apply_filters( 'frm_get_paged_fields', $fields, $form_id, $error );
186 186
         return $fields;
187 187
     }
188 188
 
@@ -205,57 +205,57 @@  discard block
 block discarded – undo
205 205
 </div>
206 206
 DEFAULT_HTML;
207 207
         } else {
208
-			$default_html = apply_filters('frm_other_custom_html', '', $type);
208
+			$default_html = apply_filters( 'frm_other_custom_html', '', $type );
209 209
         }
210 210
 
211
-        return apply_filters('frm_custom_html', $default_html, $type);
211
+        return apply_filters( 'frm_custom_html', $default_html, $type );
212 212
     }
213 213
 
214 214
 	public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) {
215
-        $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
215
+        $html = apply_filters( 'frm_before_replace_shortcodes', $html, $field, $errors, $form );
216 216
 
217 217
         $defaults = array(
218
-            'field_name'  => 'item_meta['. $field['id'] .']',
218
+            'field_name'  => 'item_meta[' . $field['id'] . ']',
219 219
             'field_id'    => $field['id'],
220 220
             'field_plus_id' => '',
221 221
             'section_id'    => '',
222 222
         );
223
-        $args = wp_parse_args($args, $defaults);
223
+        $args = wp_parse_args( $args, $defaults );
224 224
         $field_name = $args['field_name'];
225 225
         $field_id = $args['field_id'];
226
-        $html_id = self::get_html_id($field, $args['field_plus_id']);
226
+        $html_id = self::get_html_id( $field, $args['field_plus_id'] );
227 227
 
228
-        if ( FrmField::is_multiple_select($field) ) {
228
+        if ( FrmField::is_multiple_select( $field ) ) {
229 229
             $field_name .= '[]';
230 230
         }
231 231
 
232 232
         //replace [id]
233
-        $html = str_replace('[id]', $field_id, $html);
233
+        $html = str_replace( '[id]', $field_id, $html );
234 234
 
235 235
         // Remove the for attribute for captcha
236 236
         if ( $field['type'] == 'captcha' ) {
237
-            $html = str_replace(' for="field_[key]"', '', $html);
237
+            $html = str_replace( ' for="field_[key]"', '', $html );
238 238
         }
239 239
 
240 240
         // set the label for
241
-        $html = str_replace('field_[key]', $html_id, $html);
241
+        $html = str_replace( 'field_[key]', $html_id, $html );
242 242
 
243 243
         //replace [key]
244
-        $html = str_replace('[key]', $field['field_key'], $html);
244
+        $html = str_replace( '[key]', $field['field_key'], $html );
245 245
 
246 246
         //replace [description] and [required_label] and [error]
247 247
 		$required = FrmField::is_required( $field ) ? $field['required_indicator'] : '';
248 248
         if ( ! is_array( $errors ) ) {
249 249
             $errors = array();
250 250
         }
251
-		$error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false;
251
+		$error = isset( $errors['field' . $field_id] ) ? $errors['field' . $field_id] : false;
252 252
 
253 253
         //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
254 254
         if ( $field['type'] == 'divider' ) {
255 255
             if ( FrmField::is_option_true( $field, 'description' ) ) {
256 256
                 $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
257 257
             } else {
258
-                $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
258
+                $html = str_replace( '[label_position]', '[label_position] frm_section_spacing', $html );
259 259
             }
260 260
         }
261 261
 
@@ -265,83 +265,83 @@  discard block
 block discarded – undo
265 265
 
266 266
         //replace [required_class]
267 267
 		$required_class = FrmField::is_required( $field ) ? ' frm_required_field' : '';
268
-        $html = str_replace('[required_class]', $required_class, $html);
268
+        $html = str_replace( '[required_class]', $required_class, $html );
269 269
 
270 270
         //replace [label_position]
271
-        $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
271
+        $field['label'] = apply_filters( 'frm_html_label_position', $field['label'], $field, $form );
272 272
         $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
273 273
 		$html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html );
274 274
 
275 275
         //replace [field_name]
276
-        $html = str_replace('[field_name]', $field['name'], $html);
276
+        $html = str_replace( '[field_name]', $field['name'], $html );
277 277
 
278 278
         //replace [error_class]
279
-		$error_class = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : '';
279
+		$error_class = isset( $errors['field' . $field_id] ) ? ' frm_blank_field' : '';
280 280
 		self::get_more_field_classes( $error_class, $field, $field_id, $html );
281 281
 		if ( $field['type'] == 'html' && strpos( $html, '[error_class]' ) === false ) {
282 282
 			// there is no error_class shortcode to use for addign fields
283 283
 			$html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . $error_class, $html );
284 284
 		}
285
-        $html = str_replace('[error_class]', $error_class, $html);
285
+        $html = str_replace( '[error_class]', $error_class, $html );
286 286
 
287 287
         //replace [entry_key]
288 288
         $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
289
-        $html = str_replace('[entry_key]', $entry_key, $html);
289
+        $html = str_replace( '[entry_key]', $entry_key, $html );
290 290
 
291 291
         //replace [input]
292
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
292
+        preg_match_all( "/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER );
293 293
         global $frm_vars;
294 294
         $frm_settings = FrmAppHelper::get_settings();
295 295
 
296 296
         foreach ( $shortcodes[0] as $short_key => $tag ) {
297
-            $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
297
+            $atts = shortcode_parse_atts( $shortcodes[2][$short_key] );
298 298
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
299 299
 
300 300
             $replace_with = '';
301 301
 
302 302
             if ( $tag == 'input' ) {
303
-                if ( isset($atts['opt']) ) {
304
-                    $atts['opt']--;
303
+                if ( isset( $atts['opt'] ) ) {
304
+                    $atts['opt'] --;
305 305
                 }
306 306
 
307
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
308
-                if ( isset($atts['class']) ) {
309
-                    unset($atts['class']);
307
+                $field['input_class'] = isset( $atts['class'] ) ? $atts['class'] : '';
308
+                if ( isset( $atts['class'] ) ) {
309
+                    unset( $atts['class'] );
310 310
                 }
311 311
 
312 312
                 $field['shortcodes'] = $atts;
313 313
                 ob_start();
314
-                include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/input.php');
314
+                include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' );
315 315
                 $replace_with = ob_get_contents();
316 316
                 ob_end_clean();
317 317
             } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
318
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
318
+                $replace_with = FrmProEntriesController::entry_delete_link( $atts );
319 319
             }
320 320
 
321
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
321
+            $html = str_replace( $shortcodes[0][$short_key], $replace_with, $html );
322 322
         }
323 323
 
324 324
 		if ( $form ) {
325 325
             $form = (array) $form;
326 326
 
327 327
             //replace [form_key]
328
-            $html = str_replace('[form_key]', $form['form_key'], $html);
328
+            $html = str_replace( '[form_key]', $form['form_key'], $html );
329 329
 
330 330
             //replace [form_name]
331
-            $html = str_replace('[form_name]', $form['name'], $html);
331
+            $html = str_replace( '[form_name]', $form['name'], $html );
332 332
         }
333 333
         $html .= "\n";
334 334
 
335 335
         //Return html if conf_field to prevent loop
336
-        if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
336
+        if ( isset( $field['conf_field'] ) && $field['conf_field'] == 'stop' ) {
337 337
             return $html;
338 338
         }
339 339
 
340 340
         //If field is in repeating section
341 341
         if ( $args['section_id'] ) {
342
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ));
342
+            $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ) );
343 343
         } else {
344
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
344
+            $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ) );
345 345
         }
346 346
 
347 347
 		self::remove_collapse_shortcode( $html );
@@ -363,10 +363,10 @@  discard block
 block discarded – undo
363 363
 	* @param $html string
364 364
 	*/
365 365
 	private static function get_more_field_classes( &$error_class, $field, $field_id, $html ) {
366
-		$error_class .= ' frm_'. $field['label'] .'_container';
366
+		$error_class .= ' frm_' . $field['label'] . '_container';
367 367
 		if ( $field['id'] != $field_id ) {
368 368
 			// add a class for repeating/embedded fields
369
-			$error_class .= ' frm_field_'. $field['id'] .'_container';
369
+			$error_class .= ' frm_field_' . $field['id'] . '_container';
370 370
 		}
371 371
 
372 372
 		// Add class to embedded form field
@@ -418,22 +418,22 @@  discard block
 block discarded – undo
418 418
 
419 419
 		//insert custom CSS classes
420 420
 		if ( ! empty( $field['classes'] ) ) {
421
-			if ( ! strpos( $html, 'frm_form_field ') ) {
421
+			if ( ! strpos( $html, 'frm_form_field ' ) ) {
422 422
 				$error_class .= ' frm_form_field';
423 423
 			}
424
-			$error_class .= ' '. $field['classes'];
424
+			$error_class .= ' ' . $field['classes'];
425 425
 		}
426 426
 	}
427 427
 
428 428
     public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
429 429
         if ( $no_vars ) {
430
-            $html = str_replace( '[if '. $code.']', '', $html );
431
-    	    $html = str_replace( '[/if '. $code.']', '', $html );
430
+            $html = str_replace( '[if ' . $code . ']', '', $html );
431
+    	    $html = str_replace( '[/if ' . $code . ']', '', $html );
432 432
         } else {
433
-            $html = preg_replace( '/(\[if\s+'. $code .'\])(.*?)(\[\/if\s+'. $code .'\])/mis', '', $html );
433
+            $html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html );
434 434
         }
435 435
 
436
-        $html = str_replace( '['. $code .']', $replace_with, $html );
436
+        $html = str_replace( '[' . $code . ']', $replace_with, $html );
437 437
     }
438 438
 
439 439
 	public static function get_shortcode_tag( $shortcodes, $short_key, $args ) {
@@ -452,15 +452,15 @@  discard block
 block discarded – undo
452 452
         }
453 453
 
454 454
         $with_tags = $args['conditional_check'] ? 3 : 2;
455
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
456
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
457
-            $tag = str_replace(']', '', $tag);
458
-            $tags = explode(' ', $tag);
459
-            if ( is_array($tags) ) {
455
+        if ( ! empty( $shortcodes[$with_tags][$short_key] ) ) {
456
+            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][$short_key] );
457
+            $tag = str_replace( ']', '', $tag );
458
+            $tags = explode( ' ', $tag );
459
+            if ( is_array( $tags ) ) {
460 460
                 $tag = $tags[0];
461 461
             }
462 462
         } else {
463
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
463
+            $tag = $shortcodes[$with_tags - 1][$short_key];
464 464
         }
465 465
 
466 466
         return $tag;
@@ -478,16 +478,16 @@  discard block
 block discarded – undo
478 478
 
479 479
 	public static function display_recaptcha( $field ) {
480 480
         $frm_settings = FrmAppHelper::get_settings();
481
-        $lang = apply_filters('frm_recaptcha_lang', $frm_settings->re_lang, $field);
481
+        $lang = apply_filters( 'frm_recaptcha_lang', $frm_settings->re_lang, $field );
482 482
 
483 483
         $api_js_url = 'https://www.google.com/recaptcha/api.js?onload=frmRecaptcha&render=explicit';
484 484
         if ( $lang != 'en' ) {
485
-            $api_js_url .= '&hl='. $lang;
485
+            $api_js_url .= '&hl=' . $lang;
486 486
         }
487
-        $api_js_url = apply_filters('frm_recpatcha_js_url', $api_js_url);
487
+        $api_js_url = apply_filters( 'frm_recpatcha_js_url', $api_js_url );
488 488
 
489
-        wp_register_script('recaptcha-api', $api_js_url, '', true);
490
-        wp_enqueue_script('recaptcha-api');
489
+        wp_register_script( 'recaptcha-api', $api_js_url, '', true );
490
+        wp_enqueue_script( 'recaptcha-api' );
491 491
 
492 492
 ?>
493 493
 <div id="field_<?php echo esc_attr( $field['field_key'] ) ?>" class="frm-g-recaptcha" data-sitekey="<?php echo esc_attr( $frm_settings->pubkey ) ?>" data-size="<?php echo esc_attr( $field['captcha_size'] ) ?>"></div>
@@ -496,45 +496,45 @@  discard block
 block discarded – undo
496 496
 
497 497
 	public static function show_single_option( $field ) {
498 498
         $field_name = $field['name'];
499
-        $html_id = self::get_html_id($field);
499
+        $html_id = self::get_html_id( $field );
500 500
         foreach ( $field['options'] as $opt_key => $opt ) {
501
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
502
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
501
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
502
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
503 503
 
504 504
             // If this is an "Other" option, get the HTML for it
505 505
 			if ( self::is_other_opt( $opt_key ) ) {
506 506
                 // Get string for Other text field, if needed
507 507
 				$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
508
-                require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php');
508
+                require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
509 509
             } else {
510
-                require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php');
510
+                require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
511 511
             }
512 512
         }
513 513
     }
514 514
 
515 515
 	public static function dropdown_categories( $args ) {
516 516
 		$defaults = array( 'field' => false, 'name' => false, 'show_option_all' => ' ' );
517
-        $args = wp_parse_args($args, $defaults);
517
+        $args = wp_parse_args( $args, $defaults );
518 518
 
519 519
         if ( ! $args['field'] ) {
520 520
             return;
521 521
         }
522 522
 
523 523
         if ( ! $args['name'] ) {
524
-            $args['name'] = 'item_meta['. $args['field']['id'] .']';
524
+            $args['name'] = 'item_meta[' . $args['field']['id'] . ']';
525 525
         }
526 526
 
527
-        $id = self::get_html_id($args['field']);
527
+        $id = self::get_html_id( $args['field'] );
528 528
         $class = $args['field']['type'];
529 529
 
530
-        $exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat'];
531
-        $exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']);
530
+        $exclude = ( is_array( $args['field']['exclude_cat'] ) ) ? implode( ',', $args['field']['exclude_cat'] ) : $args['field']['exclude_cat'];
531
+        $exclude = apply_filters( 'frm_exclude_cats', $exclude, $args['field'] );
532 532
 
533
-        if ( is_array($args['field']['value']) ) {
534
-            if ( ! empty($exclude) ) {
535
-                $args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude));
533
+        if ( is_array( $args['field']['value'] ) ) {
534
+            if ( ! empty( $exclude ) ) {
535
+                $args['field']['value'] = array_diff( $args['field']['value'], explode( ',', $exclude ) );
536 536
             }
537
-            $selected = reset($args['field']['value']);
537
+            $selected = reset( $args['field']['value'] );
538 538
         } else {
539 539
             $selected = $args['field']['value'];
540 540
         }
@@ -545,40 +545,40 @@  discard block
 block discarded – undo
545 545
             'hide_empty' => false, 'echo' => 0, 'orderby' => 'name',
546 546
         );
547 547
 
548
-        $tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']);
548
+        $tax_atts = apply_filters( 'frm_dropdown_cat', $tax_atts, $args['field'] );
549 549
 
550 550
         if ( FrmAppHelper::pro_is_installed() ) {
551
-            $post_type = FrmProFormsHelper::post_type($args['field']['form_id']);
552
-            $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']);
551
+            $post_type = FrmProFormsHelper::post_type( $args['field']['form_id'] );
552
+            $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy( $post_type, $args['field'] );
553 553
             if ( ! $tax_atts['taxonomy'] ) {
554 554
                 return;
555 555
             }
556 556
 
557 557
             // If field type is dropdown (not Dynamic), exclude children when parent is excluded
558
-            if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) {
558
+            if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical( $tax_atts['taxonomy'] ) ) {
559 559
                 $tax_atts['exclude_tree'] = $exclude;
560 560
             }
561 561
         }
562 562
 
563
-        $dropdown = wp_dropdown_categories($tax_atts);
563
+        $dropdown = wp_dropdown_categories( $tax_atts );
564 564
 
565
-        $add_html = FrmFieldsController::input_html($args['field'], false);
565
+        $add_html = FrmFieldsController::input_html( $args['field'], false );
566 566
 
567 567
         if ( FrmAppHelper::pro_is_installed() ) {
568
-            $add_html .= FrmProFieldsController::input_html($args['field'], false);
568
+            $add_html .= FrmProFieldsController::input_html( $args['field'], false );
569 569
         }
570 570
 
571
-		$dropdown = str_replace( "<select name='" . esc_attr( $args['name'] ) ."' id='" . esc_attr( $id ) . "' class='" . esc_attr( $class ) . "'", "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' " . $add_html, $dropdown );
571
+		$dropdown = str_replace( "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' class='" . esc_attr( $class ) . "'", "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' " . $add_html, $dropdown );
572 572
 
573
-        if ( is_array($args['field']['value']) ) {
573
+        if ( is_array( $args['field']['value'] ) ) {
574 574
             $skip = true;
575 575
             foreach ( $args['field']['value'] as $v ) {
576 576
 				if ( $skip ) {
577 577
                     $skip = false;
578 578
                     continue;
579 579
                 }
580
-				$dropdown = str_replace(' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown );
581
-                unset($v);
580
+				$dropdown = str_replace( ' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown );
581
+                unset( $v );
582 582
             }
583 583
         }
584 584
 
@@ -586,16 +586,16 @@  discard block
 block discarded – undo
586 586
     }
587 587
 
588 588
 	public static function get_term_link( $tax_id ) {
589
-        $tax = get_taxonomy($tax_id);
589
+        $tax = get_taxonomy( $tax_id );
590 590
         if ( ! $tax ) {
591 591
             return;
592 592
         }
593 593
 
594 594
         $link = sprintf(
595 595
             __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
596
-            '<a href="'. esc_url( admin_url( 'edit-tags.php?taxonomy='. $tax->name ) ) .'" target="_blank">'. ( empty($tax->labels->name) ? __( 'Categories' ) : $tax->labels->name ) .'</a>'
596
+            '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
597 597
         );
598
-        unset($tax);
598
+        unset( $tax );
599 599
 
600 600
         return $link;
601 601
     }
@@ -606,8 +606,8 @@  discard block
 block discarded – undo
606 606
 			$hide_opt = rtrim( $hide_opt );
607 607
 		}
608 608
 
609
-        if ( is_array($observed_value) ) {
610
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
609
+        if ( is_array( $observed_value ) ) {
610
+            return self::array_value_condition( $observed_value, $cond, $hide_opt );
611 611
         }
612 612
 
613 613
         $m = false;
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
         } else if ( $cond == '<' ) {
621 621
             $m = $observed_value < $hide_opt;
622 622
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
623
-            $m = stripos($observed_value, $hide_opt);
623
+            $m = stripos( $observed_value, $hide_opt );
624 624
             if ( $cond == 'not LIKE' ) {
625 625
                 $m = ( $m === false ) ? true : false;
626 626
             } else {
@@ -633,23 +633,23 @@  discard block
 block discarded – undo
633 633
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
634 634
         $m = false;
635 635
         if ( $cond == '==' ) {
636
-            if ( is_array($hide_opt) ) {
637
-                $m = array_intersect($hide_opt, $observed_value);
638
-                $m = empty($m) ? false : true;
636
+            if ( is_array( $hide_opt ) ) {
637
+                $m = array_intersect( $hide_opt, $observed_value );
638
+                $m = empty( $m ) ? false : true;
639 639
             } else {
640
-                $m = in_array($hide_opt, $observed_value);
640
+                $m = in_array( $hide_opt, $observed_value );
641 641
             }
642 642
         } else if ( $cond == '!=' ) {
643
-            $m = ! in_array($hide_opt, $observed_value);
643
+            $m = ! in_array( $hide_opt, $observed_value );
644 644
         } else if ( $cond == '>' ) {
645
-            $min = min($observed_value);
645
+            $min = min( $observed_value );
646 646
             $m = $min > $hide_opt;
647 647
         } else if ( $cond == '<' ) {
648
-            $max = max($observed_value);
648
+            $max = max( $observed_value );
649 649
             $m = $max < $hide_opt;
650 650
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
651 651
             foreach ( $observed_value as $ob ) {
652
-                $m = strpos($ob, $hide_opt);
652
+                $m = strpos( $ob, $hide_opt );
653 653
                 if ( $m !== false ) {
654 654
                     $m = true;
655 655
                     break;
@@ -670,27 +670,27 @@  discard block
 block discarded – undo
670 670
      * @return string
671 671
      */
672 672
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
673
-        if ( strpos($value, '[sitename]') !== false ) {
673
+        if ( strpos( $value, '[sitename]' ) !== false ) {
674 674
             $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
675
-            $value = str_replace('[sitename]', $new_value, $value);
675
+            $value = str_replace( '[sitename]', $new_value, $value );
676 676
         }
677 677
 
678
-        $value = apply_filters('frm_content', $value, $form, $entry);
679
-        $value = do_shortcode($value);
678
+        $value = apply_filters( 'frm_content', $value, $form, $entry );
679
+        $value = do_shortcode( $value );
680 680
 
681 681
         return $value;
682 682
     }
683 683
 
684 684
 	public static function get_shortcodes( $content, $form_id ) {
685 685
         if ( FrmAppHelper::pro_is_installed() ) {
686
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
686
+            return FrmProDisplaysHelper::get_shortcodes( $content, $form_id );
687 687
         }
688 688
 
689 689
         $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
690 690
 
691
-        $tagregexp = self::allowed_shortcodes($fields);
691
+        $tagregexp = self::allowed_shortcodes( $fields );
692 692
 
693
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
693
+        preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER );
694 694
 
695 695
         return $matches;
696 696
     }
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
             $tagregexp[] = $field->field_key;
709 709
         }
710 710
 
711
-        $tagregexp = implode('|', $tagregexp);
711
+        $tagregexp = implode( '|', $tagregexp );
712 712
         return $tagregexp;
713 713
     }
714 714
 
@@ -720,28 +720,28 @@  discard block
 block discarded – undo
720 720
         );
721 721
 
722 722
         foreach ( $shortcodes[0] as $short_key => $tag ) {
723
-            $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
723
+            $atts = shortcode_parse_atts( $shortcodes[3][$short_key] );
724 724
 
725
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
726
-				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
727
-                $tags = explode(' ', $tag);
728
-                if ( is_array($tags) ) {
725
+            if ( ! empty( $shortcodes[3][$short_key] ) ) {
726
+				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][$short_key] );
727
+                $tags = explode( ' ', $tag );
728
+                if ( is_array( $tags ) ) {
729 729
                     $tag = $tags[0];
730 730
                 }
731 731
             } else {
732
-                $tag = $shortcodes[2][ $short_key ];
732
+                $tag = $shortcodes[2][$short_key];
733 733
             }
734 734
 
735 735
             switch ( $tag ) {
736 736
                 case 'id':
737 737
                 case 'key':
738 738
                 case 'ip':
739
-                    $replace_with = $shortcode_values[ $tag ];
739
+                    $replace_with = $shortcode_values[$tag];
740 740
                 break;
741 741
 
742 742
                 case 'user_agent':
743 743
                 case 'user-agent':
744
-                    $entry->description = maybe_unserialize($entry->description);
744
+                    $entry->description = maybe_unserialize( $entry->description );
745 745
 					$replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] );
746 746
                 break;
747 747
 
@@ -749,25 +749,25 @@  discard block
 block discarded – undo
749 749
                 case 'created-at':
750 750
                 case 'updated_at':
751 751
                 case 'updated-at':
752
-                    if ( isset($atts['format']) ) {
752
+                    if ( isset( $atts['format'] ) ) {
753 753
                         $time_format = ' ';
754 754
                     } else {
755
-                        $atts['format'] = get_option('date_format');
755
+                        $atts['format'] = get_option( 'date_format' );
756 756
                         $time_format = '';
757 757
                     }
758 758
 
759
-                    $this_tag = str_replace('-', '_', $tag);
760
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
761
-                    unset($this_tag);
759
+                    $this_tag = str_replace( '-', '_', $tag );
760
+                    $replace_with = FrmAppHelper::get_formatted_time( $entry->{$this_tag}, $atts['format'], $time_format );
761
+                    unset( $this_tag );
762 762
                 break;
763 763
 
764 764
                 case 'created_by':
765 765
                 case 'created-by':
766 766
                 case 'updated_by':
767 767
                 case 'updated-by':
768
-                    $this_tag = str_replace('-', '_', $tag);
768
+                    $this_tag = str_replace( '-', '_', $tag );
769 769
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
770
-                    unset($this_tag);
770
+                    unset( $this_tag );
771 771
                 break;
772 772
 
773 773
                 case 'admin_email':
@@ -784,16 +784,16 @@  discard block
 block discarded – undo
784 784
                         break;
785 785
                     }
786 786
 
787
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
787
+                    $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
788 788
 
789 789
                     $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
790 790
 
791 791
                     $atts['entry_id'] = $entry->id;
792 792
                     $atts['entry_key'] = $entry->item_key;
793 793
 
794
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
794
+                    if ( isset( $atts['show'] ) && $atts['show'] == 'field_label' ) {
795 795
                         $replace_with = $field->name;
796
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
796
+                    } else if ( isset( $atts['show'] ) && $atts['show'] == 'description' ) {
797 797
                         $replace_with = $field->description;
798 798
 					} else {
799 799
 						$string_value = $replace_with;
@@ -808,15 +808,15 @@  discard block
 block discarded – undo
808 808
 						}
809 809
 					}
810 810
 
811
-                    unset($field);
811
+                    unset( $field );
812 812
                 break;
813 813
             }
814 814
 
815
-            if ( isset($replace_with) ) {
816
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
815
+            if ( isset( $replace_with ) ) {
816
+                $content = str_replace( $shortcodes[0][$short_key], $replace_with, $content );
817 817
             }
818 818
 
819
-            unset($atts, $conditional, $replace_with);
819
+            unset( $atts, $conditional, $replace_with );
820 820
 		}
821 821
 
822 822
 		return $content;
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
         $new_value = '';
833 833
         switch ( $tag ) {
834 834
             case 'admin_email':
835
-                $new_value = get_option('admin_email');
835
+                $new_value = get_option( 'admin_email' );
836 836
                 break;
837 837
             case 'siteurl':
838 838
                 $new_value = FrmAppHelper::site_url();
@@ -858,28 +858,28 @@  discard block
 block discarded – undo
858 858
      * @return string|array
859 859
      */
860 860
     public static function process_get_shortcode( $atts, $return_array = false ) {
861
-        if ( ! isset($atts['param']) ) {
861
+        if ( ! isset( $atts['param'] ) ) {
862 862
             return '';
863 863
         }
864 864
 
865
-        if ( strpos($atts['param'], '&#91;') ) {
866
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
867
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
865
+        if ( strpos( $atts['param'], '&#91;' ) ) {
866
+            $atts['param'] = str_replace( '&#91;', '[', $atts['param'] );
867
+            $atts['param'] = str_replace( '&#93;', ']', $atts['param'] );
868 868
         }
869 869
 
870
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
870
+        $new_value = FrmAppHelper::get_param( $atts['param'], '' );
871 871
         $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
872 872
 
873 873
         if ( $new_value == '' ) {
874
-            if ( ! isset($atts['prev_val']) ) {
874
+            if ( ! isset( $atts['prev_val'] ) ) {
875 875
                 $atts['prev_val'] = '';
876 876
             }
877 877
 
878
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
878
+            $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val'];
879 879
         }
880 880
 
881
-        if ( is_array($new_value) && ! $return_array ) {
882
-            $new_value = implode(', ', $new_value);
881
+        if ( is_array( $new_value ) && ! $return_array ) {
882
+            $new_value = implode( ', ', $new_value );
883 883
         }
884 884
 
885 885
         return $new_value;
@@ -892,12 +892,12 @@  discard block
 block discarded – undo
892 892
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
893 893
 
894 894
         if ( $field->type == 'textarea' || $field->type == 'rte' ) {
895
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
896
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
897
-                if ( is_array($replace_with) ) {
898
-                    $replace_with = implode("\n", $replace_with);
895
+            $autop = isset( $atts['wpautop'] ) ? $atts['wpautop'] : true;
896
+            if ( apply_filters( 'frm_use_wpautop', $autop ) ) {
897
+                if ( is_array( $replace_with ) ) {
898
+                    $replace_with = implode( "\n", $replace_with );
899 899
                 }
900
-                $replace_with = wpautop($replace_with);
900
+                $replace_with = wpautop( $replace_with );
901 901
             }
902 902
 			unset( $autop );
903 903
 		} else if ( is_array( $replace_with ) ) {
@@ -919,14 +919,14 @@  discard block
 block discarded – undo
919 919
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
920 920
 
921 921
         $field_types = array();
922
-        if ( in_array($type, $single_input) ) {
922
+        if ( in_array( $type, $single_input ) ) {
923 923
             self::field_types_for_input( $single_input, $field_selection, $field_types );
924
-        } else if ( in_array($type, $multiple_input) ) {
924
+        } else if ( in_array( $type, $multiple_input ) ) {
925 925
             self::field_types_for_input( $multiple_input, $field_selection, $field_types );
926
-        } else if ( in_array($type, $other_type) ) {
926
+        } else if ( in_array( $type, $other_type ) ) {
927 927
             self::field_types_for_input( $other_type, $field_selection, $field_types );
928
-		} else if ( isset( $field_selection[ $type ] ) ) {
929
-            $field_types[ $type ] = $field_selection[ $type ];
928
+		} else if ( isset( $field_selection[$type] ) ) {
929
+            $field_types[$type] = $field_selection[$type];
930 930
         }
931 931
 
932 932
         return $field_types;
@@ -934,8 +934,8 @@  discard block
 block discarded – undo
934 934
 
935 935
     private static function field_types_for_input( $inputs, $fields, &$field_types ) {
936 936
         foreach ( $inputs as $input ) {
937
-            $field_types[ $input ] = $fields[ $input ];
938
-            unset($input);
937
+            $field_types[$input] = $fields[$input];
938
+            unset( $input );
939 939
         }
940 940
     }
941 941
 
@@ -980,21 +980,21 @@  discard block
 block discarded – undo
980 980
 		// Check posted vals before checking saved values
981 981
 
982 982
 		// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
983
-		if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) {
983
+		if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) {
984 984
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
985
-				$other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) : '';
985
+				$other_val = isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) : '';
986 986
 			} else {
987
-				$other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] );
987
+				$other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] );
988 988
 			}
989 989
 			return $other_val;
990 990
 
991
-		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) {
991
+		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) {
992 992
 			// For normal fields
993 993
 
994 994
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
995
-				$other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : '';
995
+				$other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : '';
996 996
 			} else {
997
-				$other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] );
997
+				$other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] );
998 998
 			}
999 999
 			return $other_val;
1000 1000
 		}
@@ -1003,8 +1003,8 @@  discard block
 block discarded – undo
1003 1003
 		if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) {
1004 1004
 			// Check if there is an "other" val in saved value and make sure the
1005 1005
 			// "other" val is not equal to the Other checkbox option
1006
-			if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
1007
-				$other_val = $field['value'][ $opt_key ];
1006
+			if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) {
1007
+				$other_val = $field['value'][$opt_key];
1008 1008
 			}
1009 1009
 		} else {
1010 1010
 			/**
@@ -1016,8 +1016,8 @@  discard block
 block discarded – undo
1016 1016
 				// Multi-select dropdowns - key is not preserved
1017 1017
 				if ( is_array( $field['value'] ) ) {
1018 1018
 					$o_key = array_search( $temp_val, $field['value'] );
1019
-					if ( isset( $field['value'][ $o_key ] ) ) {
1020
-						unset( $field['value'][ $o_key ], $o_key );
1019
+					if ( isset( $field['value'][$o_key] ) ) {
1020
+						unset( $field['value'][$o_key], $o_key );
1021 1021
 					}
1022 1022
 				} else if ( $temp_val == $field['value'] ) {
1023 1023
 					// For radio and regular dropdowns
@@ -1074,7 +1074,7 @@  discard block
 block discarded – undo
1074 1074
 	private static function set_other_name( $args, &$other_args ) {
1075 1075
 		//Set up name for other field
1076 1076
 		$other_args['name'] = str_replace( '[]', '', $args['field_name'] );
1077
-		$other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']);
1077
+		$other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] );
1078 1078
 		$other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']';
1079 1079
 
1080 1080
 		//Converts item_meta[field_id] => item_meta[other][field_id] and
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
 		// Count should only be greater than 3 if inside of a repeating section
1101 1101
 		if ( count( $temp_array ) > 3 ) {
1102 1102
 			$parent = str_replace( ']', '', $temp_array[1] );
1103
-			$pointer = str_replace( ']', '', $temp_array[2]);
1103
+			$pointer = str_replace( ']', '', $temp_array[2] );
1104 1104
 		}
1105 1105
 
1106 1106
 		// Get text for "other" text field
@@ -1167,11 +1167,11 @@  discard block
 block discarded – undo
1167 1167
 
1168 1168
 			if ( $display['default_blank'] ) {
1169 1169
 				self::show_default_blank_js( $field['default_blank'] );
1170
-				echo '<input type="hidden" name="field_options[default_blank_'. esc_attr( $field['id'] ) .']" value="' . esc_attr( $field['default_blank'] ) .'" />';
1170
+				echo '<input type="hidden" name="field_options[default_blank_' . esc_attr( $field['id'] ) . ']" value="' . esc_attr( $field['default_blank'] ) . '" />';
1171 1171
 			}
1172 1172
 
1173 1173
 			self::show_onfocus_js( $field['clear_on_focus'] );
1174
-			echo '<input type="hidden" name="field_options[clear_on_focus_'. esc_attr( $field['id'] ) .']" value="' . esc_attr( $field['default_blank'] ) .'" />';
1174
+			echo '<input type="hidden" name="field_options[clear_on_focus_' . esc_attr( $field['id'] ) . ']" value="' . esc_attr( $field['default_blank'] ) . '" />';
1175 1175
 
1176 1176
 			echo '</span>';
1177 1177
 		}
@@ -1205,29 +1205,29 @@  discard block
 block discarded – undo
1205 1205
         $replace = array();
1206 1206
         $replace_with = array();
1207 1207
         foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1208
-            $replace[] = '[if '. $old .']';
1209
-            $replace_with[] = '[if '. $new .']';
1210
-            $replace[] = '[if '. $old .' ';
1211
-            $replace_with[] = '[if '. $new .' ';
1212
-            $replace[] = '[/if '. $old .']';
1213
-            $replace_with[] = '[/if '. $new .']';
1214
-            $replace[] = '[foreach '. $old .']';
1215
-            $replace_with[] = '[foreach '. $new .']';
1216
-            $replace[] = '[/foreach '. $old .']';
1217
-            $replace_with[] = '[/foreach '. $new .']';
1218
-            $replace[] = '['. $old .']';
1219
-            $replace_with[] = '['. $new .']';
1220
-            $replace[] = '['. $old .' ';
1221
-            $replace_with[] = '['. $new .' ';
1222
-            unset($old, $new);
1208
+            $replace[] = '[if ' . $old . ']';
1209
+            $replace_with[] = '[if ' . $new . ']';
1210
+            $replace[] = '[if ' . $old . ' ';
1211
+            $replace_with[] = '[if ' . $new . ' ';
1212
+            $replace[] = '[/if ' . $old . ']';
1213
+            $replace_with[] = '[/if ' . $new . ']';
1214
+            $replace[] = '[foreach ' . $old . ']';
1215
+            $replace_with[] = '[foreach ' . $new . ']';
1216
+            $replace[] = '[/foreach ' . $old . ']';
1217
+            $replace_with[] = '[/foreach ' . $new . ']';
1218
+            $replace[] = '[' . $old . ']';
1219
+            $replace_with[] = '[' . $new . ']';
1220
+            $replace[] = '[' . $old . ' ';
1221
+            $replace_with[] = '[' . $new . ' ';
1222
+            unset( $old, $new );
1223 1223
         }
1224 1224
 		if ( is_array( $val ) ) {
1225 1225
 			foreach ( $val as $k => $v ) {
1226
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1227
-                unset($k, $v);
1226
+                $val[$k] = str_replace( $replace, $replace_with, $v );
1227
+                unset( $k, $v );
1228 1228
             }
1229 1229
         } else {
1230
-            $val = str_replace($replace, $replace_with, $val);
1230
+            $val = str_replace( $replace, $replace_with, $val );
1231 1231
         }
1232 1232
 
1233 1233
         return $val;
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
             'DC' => 'District of Columbia',
1241 1241
             'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1242 1242
             'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1243
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1243
+            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland',
1244 1244
             'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1245 1245
             'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1246 1246
             'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
@@ -1331,35 +1331,35 @@  discard block
 block discarded – undo
1331 1331
     }
1332 1332
 
1333 1333
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1334
-		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1334
+		$prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries();
1335 1335
 
1336 1336
         $states = FrmFieldsHelper::get_us_states();
1337
-        $state_abv = array_keys($states);
1338
-        sort($state_abv);
1339
-		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1337
+        $state_abv = array_keys( $states );
1338
+        sort( $state_abv );
1339
+		$prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv;
1340 1340
 
1341
-        $states = array_values($states);
1342
-        sort($states);
1343
-		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1344
-        unset($state_abv, $states);
1341
+        $states = array_values( $states );
1342
+        sort( $states );
1343
+		$prepop[__( 'U.S. States', 'formidable' )] = $states;
1344
+        unset( $state_abv, $states );
1345 1345
 
1346
-		$prepop[ __( 'Age', 'formidable' ) ] = array(
1346
+		$prepop[__( 'Age', 'formidable' )] = array(
1347 1347
             __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1348 1348
             __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1349 1349
             __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1350 1350
         );
1351 1351
 
1352
-		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1352
+		$prepop[__( 'Satisfaction', 'formidable' )] = array(
1353 1353
             __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1354 1354
             __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1355 1355
         );
1356 1356
 
1357
-		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1357
+		$prepop[__( 'Importance', 'formidable' )] = array(
1358 1358
             __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1359 1359
             __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1360 1360
         );
1361 1361
 
1362
-		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1362
+		$prepop[__( 'Agreement', 'formidable' )] = array(
1363 1363
             __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1364 1364
             __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1365 1365
         );
Please login to merge, or discard this patch.
classes/controllers/FrmEntriesController.php 2 patches
Indentation   +335 added lines, -335 removed lines patch added patch discarded remove patch
@@ -2,201 +2,201 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmEntriesController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		FrmAppHelper::force_capability( 'frm_view_entries' );
7 7
 
8
-        add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
8
+		add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
9 9
 
10 10
 		if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
11 11
 			$menu_name = FrmAppHelper::get_menu_name();
12 12
 			add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' );
13 13
 			add_filter( 'get_user_option_manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' );
14 14
 			add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_sortable_columns', 'FrmEntriesController::sortable_columns' );
15
-        }
16
-    }
15
+		}
16
+	}
17 17
 
18
-    /* Display in Back End */
19
-    public static function route() {
18
+	/* Display in Back End */
19
+	public static function route() {
20 20
 		$action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
21 21
 
22
-        switch ( $action ) {
23
-            case 'show':
24
-            case 'destroy':
25
-            case 'destroy_all':
26
-                return self::$action();
22
+		switch ( $action ) {
23
+			case 'show':
24
+			case 'destroy':
25
+			case 'destroy_all':
26
+				return self::$action();
27 27
 
28
-            default:
29
-                do_action( 'frm_entry_action_route', $action );
30
-                if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
31
-                    return;
32
-                }
28
+			default:
29
+				do_action( 'frm_entry_action_route', $action );
30
+				if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
31
+					return;
32
+				}
33 33
 
34
-                return self::display_list();
35
-        }
36
-    }
34
+				return self::display_list();
35
+		}
36
+	}
37 37
 
38 38
 	public static function contextual_help( $help, $screen_id, $screen ) {
39
-        // Only add to certain screens. add_help_tab was introduced in WordPress 3.3
40
-        if ( ! method_exists( $screen, 'add_help_tab' ) ) {
41
-            return $help;
42
-        }
39
+		// Only add to certain screens. add_help_tab was introduced in WordPress 3.3
40
+		if ( ! method_exists( $screen, 'add_help_tab' ) ) {
41
+			return $help;
42
+		}
43 43
 
44 44
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
45 45
 		$page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
46 46
 		if ( $page != 'formidable-entries' || ( ! empty( $action ) && $action != 'list' ) ) {
47
-            return $help;
48
-        }
47
+			return $help;
48
+		}
49 49
 
50 50
 		unset( $action, $page );
51 51
 
52
-        $screen->add_help_tab( array(
53
-            'id'      => 'formidable-entries-tab',
54
-            'title'   => __( 'Overview', 'formidable' ),
52
+		$screen->add_help_tab( array(
53
+			'id'      => 'formidable-entries-tab',
54
+			'title'   => __( 'Overview', 'formidable' ),
55 55
 			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
56
-        ));
56
+		));
57 57
 
58
-        $screen->set_help_sidebar(
58
+		$screen->set_help_sidebar(
59 59
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
60 60
 			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com/knowledgebase/manage-entries-from-the-back-end/' ) ) . '" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' .
61 61
 			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>'
62
-    	);
62
+		);
63 63
 
64
-        return $help;
65
-    }
64
+		return $help;
65
+	}
66 66
 
67 67
 	public static function manage_columns( $columns ) {
68
-        global $frm_vars, $wpdb;
68
+		global $frm_vars, $wpdb;
69 69
 		$form_id = FrmForm::get_current_form_id();
70 70
 
71 71
 		$columns[ $form_id . '_id' ] = 'ID';
72 72
 		$columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
73 73
 
74
-        if ( ! $form_id ) {
75
-            return $columns;
76
-        }
74
+		if ( ! $form_id ) {
75
+			return $columns;
76
+		}
77 77
 
78
-        $form_cols = FrmField::get_all_for_form($form_id, '', 'include');
78
+		$form_cols = FrmField::get_all_for_form($form_id, '', 'include');
79 79
 
80
-        foreach ( $form_cols as $form_col ) {
80
+		foreach ( $form_cols as $form_col ) {
81 81
 			if ( FrmField::is_no_save_field( $form_col->type ) ) {
82
-                continue;
83
-            }
82
+				continue;
83
+			}
84 84
 
85
-            if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) {
85
+			if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) {
86 86
 				$sub_form_cols = FrmField::get_all_for_form( $form_col->field_options['form_select'] );
87 87
 
88
-                if ( $sub_form_cols ) {
89
-                    foreach ( $sub_form_cols as $k => $sub_form_col ) {
88
+				if ( $sub_form_cols ) {
89
+					foreach ( $sub_form_cols as $k => $sub_form_col ) {
90 90
 						if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
91
-                            unset( $sub_form_cols[ $k ] );
92
-                            continue;
93
-                        }
91
+							unset( $sub_form_cols[ $k ] );
92
+							continue;
93
+						}
94 94
 						$columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
95
-                        unset($sub_form_col);
96
-                    }
97
-                }
98
-                unset($sub_form_cols);
99
-            } else {
100
-                $col_id = $form_col->field_key;
101
-                if ( $form_col->form_id != $form_id ) {
95
+						unset($sub_form_col);
96
+					}
97
+				}
98
+				unset($sub_form_cols);
99
+			} else {
100
+				$col_id = $form_col->field_key;
101
+				if ( $form_col->form_id != $form_id ) {
102 102
 					$col_id .= '-_-form' . $form_col->form_id;
103
-                }
103
+				}
104 104
 
105
-                if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
105
+				if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
106 106
 					$columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
107
-                }
107
+				}
108 108
 				$columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
109
-            }
110
-        }
109
+			}
110
+		}
111 111
 
112 112
 		$columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' );
113 113
 		$columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
114 114
 		$columns[ $form_id . '_ip' ] = 'IP';
115 115
 
116
-        $frm_vars['cols'] = $columns;
116
+		$frm_vars['cols'] = $columns;
117 117
 
118 118
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
119 119
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
120 120
 			add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) );
121
-        }
121
+		}
122 122
 
123
-        return $columns;
124
-    }
123
+		return $columns;
124
+	}
125 125
 
126 126
 	public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
127 127
 		$menu_name = FrmAppHelper::get_menu_name();
128 128
 		$this_page_name = 'manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden';
129 129
 		if ( $meta_key != $this_page_name || $meta_value == $prev_value ) {
130
-            return $check;
131
-        }
130
+			return $check;
131
+		}
132 132
 
133 133
 		if ( empty( $prev_value ) ) {
134 134
 			$prev_value = get_metadata( 'user', $object_id, $meta_key, true );
135 135
 		}
136 136
 
137
-        global $frm_vars;
138
-        //add a check so we don't create a loop
139
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
137
+		global $frm_vars;
138
+		//add a check so we don't create a loop
139
+		$frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
140 140
 
141
-        return $check;
142
-    }
141
+		return $check;
142
+	}
143 143
 
144
-    //add hidden columns back from other forms
144
+	//add hidden columns back from other forms
145 145
 	public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
146 146
 		$menu_name = FrmAppHelper::get_menu_name();
147 147
 		$sanitized = sanitize_title( $menu_name );
148 148
 		$this_page_name = 'manage' .  $sanitized . '_page_formidable-entriescolumnshidden';
149 149
 		if ( $meta_key != $this_page_name ) {
150
-            return;
151
-        }
152
-
153
-        global $frm_vars;
154
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
155
-            return; //don't continue if there's no previous value
156
-        }
157
-
158
-        foreach ( $meta_value as $mk => $mv ) {
159
-            //remove blank values
160
-            if ( empty( $mv )  ) {
161
-                unset( $meta_value[ $mk ] );
162
-            }
163
-        }
164
-
165
-        $cur_form_prefix = reset($meta_value);
166
-        $cur_form_prefix = explode('_', $cur_form_prefix);
167
-        $cur_form_prefix = $cur_form_prefix[0];
168
-        $save = false;
169
-
170
-        foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
150
+			return;
151
+		}
152
+
153
+		global $frm_vars;
154
+		if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
155
+			return; //don't continue if there's no previous value
156
+		}
157
+
158
+		foreach ( $meta_value as $mk => $mv ) {
159
+			//remove blank values
160
+			if ( empty( $mv )  ) {
161
+				unset( $meta_value[ $mk ] );
162
+			}
163
+		}
164
+
165
+		$cur_form_prefix = reset($meta_value);
166
+		$cur_form_prefix = explode('_', $cur_form_prefix);
167
+		$cur_form_prefix = $cur_form_prefix[0];
168
+		$save = false;
169
+
170
+		foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
171 171
 			if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) {
172
-                //don't add blank cols or process included cols
173
-                continue;
174
-            }
172
+				//don't add blank cols or process included cols
173
+				continue;
174
+			}
175 175
 
176 176
 			$form_prefix = explode( '_', $prev_hidden );
177
-            $form_prefix = $form_prefix[0];
178
-            if ( $form_prefix == $cur_form_prefix ) {
179
-                //don't add back columns that are meant to be hidden
180
-                continue;
181
-            }
177
+			$form_prefix = $form_prefix[0];
178
+			if ( $form_prefix == $cur_form_prefix ) {
179
+				//don't add back columns that are meant to be hidden
180
+				continue;
181
+			}
182 182
 
183
-            $meta_value[] = $prev_hidden;
184
-            $save = true;
185
-            unset($form_prefix);
186
-        }
183
+			$meta_value[] = $prev_hidden;
184
+			$save = true;
185
+			unset($form_prefix);
186
+		}
187 187
 
188 188
 		if ( $save ) {
189
-            $user = wp_get_current_user();
189
+			$user = wp_get_current_user();
190 190
 			update_user_option( $user->ID, $this_page_name, $meta_value, true );
191
-        }
192
-    }
191
+		}
192
+	}
193 193
 
194 194
 	public static function save_per_page( $save, $option, $value ) {
195
-        if ( $option == 'formidable_page_formidable_entries_per_page' ) {
196
-            $save = (int) $value;
197
-        }
198
-        return $save;
199
-    }
195
+		if ( $option == 'formidable_page_formidable_entries_per_page' ) {
196
+			$save = (int) $value;
197
+		}
198
+		return $save;
199
+	}
200 200
 
201 201
 	public static function sortable_columns() {
202 202
 		$form_id = FrmForm::get_current_form_id();
@@ -222,226 +222,226 @@  discard block
 block discarded – undo
222 222
 	}
223 223
 
224 224
 	public static function hidden_columns( $result ) {
225
-        global $frm_vars;
225
+		global $frm_vars;
226 226
 
227 227
 		$form_id = FrmForm::get_current_form_id();
228 228
 
229
-        $return = false;
230
-        foreach ( (array) $result as $r ) {
231
-            if ( ! empty( $r ) ) {
232
-                $form_prefix = explode( '_', $r );
233
-                $form_prefix = $form_prefix[0];
229
+		$return = false;
230
+		foreach ( (array) $result as $r ) {
231
+			if ( ! empty( $r ) ) {
232
+				$form_prefix = explode( '_', $r );
233
+				$form_prefix = $form_prefix[0];
234 234
 
235
-                if ( (int) $form_prefix == (int) $form_id ) {
236
-                    $return = true;
237
-                    break;
238
-                }
235
+				if ( (int) $form_prefix == (int) $form_id ) {
236
+					$return = true;
237
+					break;
238
+				}
239 239
 
240
-                unset($form_prefix);
241
-            }
242
-        }
240
+				unset($form_prefix);
241
+			}
242
+		}
243 243
 
244
-        if ( $return ) {
244
+		if ( $return ) {
245 245
 			return $result;
246 246
 		}
247 247
 
248
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
249
-        $max_columns = 8;
250
-        if ( $i <= $max_columns ) {
248
+		$i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
249
+		$max_columns = 8;
250
+		if ( $i <= $max_columns ) {
251 251
 			return $result;
252 252
 		}
253 253
 
254
-        global $frm_vars;
255
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
256
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
257
-        }
254
+		global $frm_vars;
255
+		if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
256
+			$frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
257
+		}
258 258
 
259
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) {
260
-            $result = $frm_vars['current_form']->options['hidden_cols'];
261
-        } else {
262
-            $cols = $frm_vars['cols'];
263
-            $cols = array_reverse($cols, true);
259
+		if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) {
260
+			$result = $frm_vars['current_form']->options['hidden_cols'];
261
+		} else {
262
+			$cols = $frm_vars['cols'];
263
+			$cols = array_reverse($cols, true);
264 264
 
265 265
 			$result[] = $form_id . '_id';
266
-            $i--;
266
+			$i--;
267 267
 
268 268
 			$result[] = $form_id . '_item_key';
269
-            $i--;
269
+			$i--;
270 270
 
271 271
 			foreach ( $cols as $col_key => $col ) {
272
-                if ( $i > $max_columns ) {
272
+				if ( $i > $max_columns ) {
273 273
 					$result[] = $col_key;
274 274
 				}
275
-                //remove some columns by default
276
-                $i--;
277
-                unset($col_key, $col);
278
-            }
279
-        }
275
+				//remove some columns by default
276
+				$i--;
277
+				unset($col_key, $col);
278
+			}
279
+		}
280 280
 
281
-        return $result;
282
-    }
281
+		return $result;
282
+	}
283 283
 
284 284
 	public static function display_list( $message = '', $errors = array() ) {
285
-        global $wpdb, $frm_vars;
285
+		global $wpdb, $frm_vars;
286 286
 
287 287
 		$form = FrmForm::get_current_form();
288 288
 		$params = FrmForm::get_admin_params( $form );
289 289
 
290
-        if ( $form ) {
291
-            $params['form'] = $form->id;
292
-            $frm_vars['current_form'] = $form;
290
+		if ( $form ) {
291
+			$params['form'] = $form->id;
292
+			$frm_vars['current_form'] = $form;
293 293
 
294
-	        if ( 'trash' == $form->status ) {
295
-	            $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
296
-	            $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
297
-	            $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete );
298
-	            unset( $time_to_delete, $delete_timestamp );
299
-	        }
294
+			if ( 'trash' == $form->status ) {
295
+				$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
296
+				$time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
297
+				$errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete );
298
+				unset( $time_to_delete, $delete_timestamp );
299
+			}
300 300
 		}
301 301
 
302
-        $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
302
+		$table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
303 303
 
304
-        $wp_list_table = new $table_class( array( 'params' => $params ) );
304
+		$wp_list_table = new $table_class( array( 'params' => $params ) );
305 305
 
306
-        $pagenum = $wp_list_table->get_pagenum();
306
+		$pagenum = $wp_list_table->get_pagenum();
307 307
 
308
-        $wp_list_table->prepare_items();
308
+		$wp_list_table->prepare_items();
309 309
 
310
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
311
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
310
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
311
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
312 312
 			$url = add_query_arg( 'paged', $total_pages );
313
-            if ( headers_sent() ) {
314
-                echo FrmAppHelper::js_redirect($url);
315
-            } else {
316
-                wp_redirect( esc_url_raw( $url ) );
317
-            }
318
-            die();
319
-        }
320
-
321
-        if ( empty($message) && isset($_GET['import-message']) ) {
322
-            $message = __( 'Your import is complete', 'formidable' );
323
-        }
313
+			if ( headers_sent() ) {
314
+				echo FrmAppHelper::js_redirect($url);
315
+			} else {
316
+				wp_redirect( esc_url_raw( $url ) );
317
+			}
318
+			die();
319
+		}
320
+
321
+		if ( empty($message) && isset($_GET['import-message']) ) {
322
+			$message = __( 'Your import is complete', 'formidable' );
323
+		}
324 324
 
325 325
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' );
326
-    }
326
+	}
327 327
 
328
-    /* Back End CRUD */
328
+	/* Back End CRUD */
329 329
 	public static function show( $id = 0 ) {
330
-        FrmAppHelper::permission_check('frm_view_entries');
330
+		FrmAppHelper::permission_check('frm_view_entries');
331 331
 
332
-        if ( ! $id ) {
332
+		if ( ! $id ) {
333 333
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
334 334
 
335
-            if ( ! $id ) {
335
+			if ( ! $id ) {
336 336
 				$id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' );
337
-            }
338
-        }
337
+			}
338
+		}
339 339
 
340
-        $entry = FrmEntry::getOne($id, true);
340
+		$entry = FrmEntry::getOne($id, true);
341 341
 
342
-        $data = maybe_unserialize($entry->description);
342
+		$data = maybe_unserialize($entry->description);
343 343
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
344 344
 			$data = array( 'referrer' => $data );
345 345
 		}
346 346
 
347 347
 		$fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
348
-        $to_emails = array();
348
+		$to_emails = array();
349 349
 
350 350
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' );
351
-    }
351
+	}
352 352
 
353
-    public static function destroy() {
354
-        FrmAppHelper::permission_check('frm_delete_entries');
353
+	public static function destroy() {
354
+		FrmAppHelper::permission_check('frm_delete_entries');
355 355
 
356 356
 		$params = FrmForm::get_admin_params();
357 357
 
358
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
359
-            //unlink entry from post
360
-            global $wpdb;
358
+		if ( isset($params['keep_post']) && $params['keep_post'] ) {
359
+			//unlink entry from post
360
+			global $wpdb;
361 361
 			$wpdb->update( $wpdb->prefix .'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
362
-        }
362
+		}
363 363
 
364
-        $message = '';
365
-        if ( FrmEntry::destroy( $params['id'] ) ) {
366
-            $message = __( 'Entry was Successfully Destroyed', 'formidable' );
367
-        }
364
+		$message = '';
365
+		if ( FrmEntry::destroy( $params['id'] ) ) {
366
+			$message = __( 'Entry was Successfully Destroyed', 'formidable' );
367
+		}
368 368
 
369
-        self::display_list( $message );
370
-    }
369
+		self::display_list( $message );
370
+	}
371 371
 
372
-    public static function destroy_all() {
373
-        if ( ! current_user_can( 'frm_delete_entries' ) ) {
374
-            $frm_settings = FrmAppHelper::get_settings();
375
-            wp_die( $frm_settings->admin_permission );
376
-        }
372
+	public static function destroy_all() {
373
+		if ( ! current_user_can( 'frm_delete_entries' ) ) {
374
+			$frm_settings = FrmAppHelper::get_settings();
375
+			wp_die( $frm_settings->admin_permission );
376
+		}
377 377
 
378
-        global $wpdb;
378
+		global $wpdb;
379 379
 		$params = FrmForm::get_admin_params();
380
-        $message = '';
381
-        $errors = array();
382
-        $form_id = (int) $params['form'];
380
+		$message = '';
381
+		$errors = array();
382
+		$form_id = (int) $params['form'];
383 383
 
384
-        if ( $form_id ) {
385
-            $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
384
+		if ( $form_id ) {
385
+			$entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
386 386
 			$action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 );
387 387
 
388
-            if ( $action ) {
389
-                // this action takes a while, so only trigger it if there are posts to delete
390
-                foreach ( $entry_ids as $entry_id ) {
391
-                    do_action( 'frm_before_destroy_entry', $entry_id );
392
-                    unset( $entry_id );
393
-                }
394
-            }
395
-
396
-            $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) );
397
-            $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
398
-            if ( $results ) {
399
-                $message = __( 'Entries were Successfully Destroyed', 'formidable' );
400
-            }
401
-        } else {
402
-            $errors = __( 'No entries were specified', 'formidable' );
403
-        }
404
-
405
-        self::display_list( $message, $errors );
406
-    }
407
-
408
-    public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
409
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
410
-        return FrmFormsController::show_form( $id, $key, $title, $description );
411
-    }
412
-
413
-    public static function get_form( $filename, $form, $title, $description ) {
414
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
415
-        return FrmFormsController::get_form( $form, $title, $description );
416
-    }
417
-
418
-    public static function process_entry( $errors = '', $ajax = false ) {
388
+			if ( $action ) {
389
+				// this action takes a while, so only trigger it if there are posts to delete
390
+				foreach ( $entry_ids as $entry_id ) {
391
+					do_action( 'frm_before_destroy_entry', $entry_id );
392
+					unset( $entry_id );
393
+				}
394
+			}
395
+
396
+			$wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) );
397
+			$results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
398
+			if ( $results ) {
399
+				$message = __( 'Entries were Successfully Destroyed', 'formidable' );
400
+			}
401
+		} else {
402
+			$errors = __( 'No entries were specified', 'formidable' );
403
+		}
404
+
405
+		self::display_list( $message, $errors );
406
+	}
407
+
408
+	public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
409
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
410
+		return FrmFormsController::show_form( $id, $key, $title, $description );
411
+	}
412
+
413
+	public static function get_form( $filename, $form, $title, $description ) {
414
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
415
+		return FrmFormsController::get_form( $form, $title, $description );
416
+	}
417
+
418
+	public static function process_entry( $errors = '', $ajax = false ) {
419 419
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
420 420
 		if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) {
421
-            return;
422
-        }
421
+			return;
422
+		}
423 423
 
424
-        global $frm_vars;
424
+		global $frm_vars;
425 425
 
426 426
 		$form = FrmForm::getOne( $form_id );
427
-        if ( ! $form ) {
428
-            return;
429
-        }
427
+		if ( ! $form ) {
428
+			return;
429
+		}
430 430
 
431 431
 		$params = FrmForm::get_params( $form );
432 432
 
433
-        if ( ! isset( $frm_vars['form_params'] ) ) {
434
-            $frm_vars['form_params'] = array();
435
-        }
433
+		if ( ! isset( $frm_vars['form_params'] ) ) {
434
+			$frm_vars['form_params'] = array();
435
+		}
436 436
 		$frm_vars['form_params'][ $form->id ] = $params;
437 437
 
438 438
 		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
439
-            return;
440
-        }
439
+			return;
440
+		}
441 441
 
442
-        if ( $errors == '' ) {
442
+		if ( $errors == '' ) {
443 443
 			$errors = FrmEntryValidate::validate( $_POST );
444
-        }
444
+		}
445 445
 
446 446
 		/**
447 447
 		 * Use this filter to add trigger actions and add errors after
@@ -452,102 +452,102 @@  discard block
 block discarded – undo
452 452
 
453 453
 		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
454 454
 
455
-        if ( empty( $errors ) ) {
455
+		if ( empty( $errors ) ) {
456 456
 			$_POST['frm_skip_cookie'] = 1;
457
-            if ( $params['action'] == 'create' ) {
457
+			if ( $params['action'] == 'create' ) {
458 458
 				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
459 459
 					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
460
-                }
461
-            }
460
+				}
461
+			}
462 462
 
463
-            do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
463
+			do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
464 464
 			unset( $_POST['frm_skip_cookie'] );
465
-        }
466
-    }
467
-
468
-    public static function delete_entry_before_redirect( $url, $form, $atts ) {
469
-        self::_delete_entry( $atts['id'], $form );
470
-        return $url;
471
-    }
472
-
473
-    //Delete entry if not redirected
474
-    public static function delete_entry_after_save( $atts ) {
475
-        self::_delete_entry( $atts['entry_id'], $atts['form'] );
476
-    }
477
-
478
-    private static function _delete_entry( $entry_id, $form ) {
479
-        if ( ! $form ) {
480
-            return;
481
-        }
482
-
483
-        $form->options = maybe_unserialize( $form->options );
484
-        if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
485
-            FrmEntry::destroy( $entry_id );
486
-        }
487
-    }
465
+		}
466
+	}
467
+
468
+	public static function delete_entry_before_redirect( $url, $form, $atts ) {
469
+		self::_delete_entry( $atts['id'], $form );
470
+		return $url;
471
+	}
472
+
473
+	//Delete entry if not redirected
474
+	public static function delete_entry_after_save( $atts ) {
475
+		self::_delete_entry( $atts['entry_id'], $atts['form'] );
476
+	}
477
+
478
+	private static function _delete_entry( $entry_id, $form ) {
479
+		if ( ! $form ) {
480
+			return;
481
+		}
482
+
483
+		$form->options = maybe_unserialize( $form->options );
484
+		if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
485
+			FrmEntry::destroy( $entry_id );
486
+		}
487
+	}
488 488
 
489 489
 	public static function show_entry_shortcode( $atts ) {
490 490
 		return FrmEntryFormat::show_entry( $atts );
491 491
 	}
492 492
 
493
-    public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
494
-        $field = FrmField::getOne($meta->field_id);
495
-        if ( ! $field ) {
496
-            return $value;
497
-        }
493
+	public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
494
+		$field = FrmField::getOne($meta->field_id);
495
+		if ( ! $field ) {
496
+			return $value;
497
+		}
498 498
 
499
-        $value = self::filter_display_value($value, $field, $atts);
500
-        return $value;
501
-    }
499
+		$value = self::filter_display_value($value, $field, $atts);
500
+		return $value;
501
+	}
502 502
 
503 503
 	public static function &filter_shortcode_value( $value, $tag, $atts, $field ) {
504
-        $plain_text = add_filter('frm_plain_text_email', true);
504
+		$plain_text = add_filter('frm_plain_text_email', true);
505 505
 		FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value );
506 506
 
507
-        if ( isset($atts['show']) && $atts['show'] == 'value' ) {
508
-            return $value;
509
-        }
507
+		if ( isset($atts['show']) && $atts['show'] == 'value' ) {
508
+			return $value;
509
+		}
510 510
 
511
-        return self::filter_display_value($value, $field, $atts);
512
-    }
511
+		return self::filter_display_value($value, $field, $atts);
512
+	}
513 513
 
514
-    public static function &filter_display_value( $value, $field, $atts = array() ) {
515
-        $saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
514
+	public static function &filter_display_value( $value, $field, $atts = array() ) {
515
+		$saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
516 516
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'radio', 'select' ) ) || ! FrmField::is_option_true( $field, 'separate_value' ) || $saved_value ) {
517
-            return $value;
518
-        }
519
-
520
-        $f_values = $f_labels = array();
521
-
522
-        foreach ( $field->options as $opt_key => $opt ) {
523
-            if ( ! is_array($opt) ) {
524
-                continue;
525
-            }
526
-
527
-            $f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
528
-            $f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
529
-            if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
530
-                unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
531
-            }
532
-            unset($opt_key, $opt);
533
-        }
534
-
535
-        if ( ! empty($f_values) ) {
536
-            foreach ( (array) $value as $v_key => $val ) {
537
-                if ( in_array($val, $f_values) ) {
538
-                    $opt = array_search($val, $f_values);
539
-                    if ( is_array($value) ) {
540
-                        $value[ $v_key ] = $f_labels[ $opt ];
541
-                    } else {
542
-                        $value = $f_labels[ $opt ];
543
-                    }
544
-                }
545
-                unset($v_key, $val);
546
-            }
547
-        }
548
-
549
-        return $value;
550
-    }
517
+			return $value;
518
+		}
519
+
520
+		$f_values = $f_labels = array();
521
+
522
+		foreach ( $field->options as $opt_key => $opt ) {
523
+			if ( ! is_array($opt) ) {
524
+				continue;
525
+			}
526
+
527
+			$f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
528
+			$f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
529
+			if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
530
+				unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
531
+			}
532
+			unset($opt_key, $opt);
533
+		}
534
+
535
+		if ( ! empty($f_values) ) {
536
+			foreach ( (array) $value as $v_key => $val ) {
537
+				if ( in_array($val, $f_values) ) {
538
+					$opt = array_search($val, $f_values);
539
+					if ( is_array($value) ) {
540
+						$value[ $v_key ] = $f_labels[ $opt ];
541
+					} else {
542
+						$value = $f_labels[ $opt ];
543
+					}
544
+				}
545
+				unset($v_key, $val);
546
+			}
547
+		}
548
+
549
+		return $value;
550
+	}
551 551
 
552 552
 	public static function get_params( $form = null ) {
553 553
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_params' );
@@ -555,13 +555,13 @@  discard block
 block discarded – undo
555 555
 	}
556 556
 
557 557
 	public static function entry_sidebar( $entry ) {
558
-        $data = maybe_unserialize($entry->description);
559
-        $date_format = get_option('date_format');
560
-        $time_format = get_option('time_format');
558
+		$data = maybe_unserialize($entry->description);
559
+		$date_format = get_option('date_format');
560
+		$time_format = get_option('time_format');
561 561
 		if ( isset( $data['browser'] ) ) {
562 562
 			$browser = FrmEntryFormat::get_browser( $data['browser'] );
563 563
 		}
564 564
 
565 565
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
566
-    }
566
+	}
567 567
 }
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
     public static function menu() {
6 6
 		FrmAppHelper::force_capability( 'frm_view_entries' );
7 7
 
8
-        add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
8
+        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
9 9
 
10 10
 		if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
11 11
 			$menu_name = FrmAppHelper::get_menu_name();
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
             'id'      => 'formidable-entries-tab',
54 54
             'title'   => __( 'Overview', 'formidable' ),
55 55
 			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
56
-        ));
56
+        ) );
57 57
 
58 58
         $screen->set_help_sidebar(
59 59
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
         global $frm_vars, $wpdb;
69 69
 		$form_id = FrmForm::get_current_form_id();
70 70
 
71
-		$columns[ $form_id . '_id' ] = 'ID';
72
-		$columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
71
+		$columns[$form_id . '_id'] = 'ID';
72
+		$columns[$form_id . '_item_key'] = esc_html__( 'Entry Key', 'formidable' );
73 73
 
74 74
         if ( ! $form_id ) {
75 75
             return $columns;
76 76
         }
77 77
 
78
-        $form_cols = FrmField::get_all_for_form($form_id, '', 'include');
78
+        $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' );
79 79
 
80 80
         foreach ( $form_cols as $form_col ) {
81 81
 			if ( FrmField::is_no_save_field( $form_col->type ) ) {
@@ -88,30 +88,30 @@  discard block
 block discarded – undo
88 88
                 if ( $sub_form_cols ) {
89 89
                     foreach ( $sub_form_cols as $k => $sub_form_col ) {
90 90
 						if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
91
-                            unset( $sub_form_cols[ $k ] );
91
+                            unset( $sub_form_cols[$k] );
92 92
                             continue;
93 93
                         }
94
-						$columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
95
-                        unset($sub_form_col);
94
+						$columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
95
+                        unset( $sub_form_col );
96 96
                     }
97 97
                 }
98
-                unset($sub_form_cols);
98
+                unset( $sub_form_cols );
99 99
             } else {
100 100
                 $col_id = $form_col->field_key;
101 101
                 if ( $form_col->form_id != $form_id ) {
102 102
 					$col_id .= '-_-form' . $form_col->form_id;
103 103
                 }
104 104
 
105
-                if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
106
-					$columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
105
+                if ( isset( $form_col->field_options['separate_value'] ) && $form_col->field_options['separate_value'] ) {
106
+					$columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
107 107
                 }
108
-				$columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
108
+				$columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
109 109
             }
110 110
         }
111 111
 
112
-		$columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' );
113
-		$columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
114
-		$columns[ $form_id . '_ip' ] = 'IP';
112
+		$columns[$form_id . '_created_at'] = __( 'Entry creation date', 'formidable' );
113
+		$columns[$form_id . '_updated_at'] = __( 'Entry update date', 'formidable' );
114
+		$columns[$form_id . '_ip'] = 'IP';
115 115
 
116 116
         $frm_vars['cols'] = $columns;
117 117
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 
137 137
         global $frm_vars;
138 138
         //add a check so we don't create a loop
139
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
139
+        $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
140 140
 
141 141
         return $check;
142 142
     }
@@ -145,25 +145,25 @@  discard block
 block discarded – undo
145 145
 	public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
146 146
 		$menu_name = FrmAppHelper::get_menu_name();
147 147
 		$sanitized = sanitize_title( $menu_name );
148
-		$this_page_name = 'manage' .  $sanitized . '_page_formidable-entriescolumnshidden';
148
+		$this_page_name = 'manage' . $sanitized . '_page_formidable-entriescolumnshidden';
149 149
 		if ( $meta_key != $this_page_name ) {
150 150
             return;
151 151
         }
152 152
 
153 153
         global $frm_vars;
154
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
154
+        if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
155 155
             return; //don't continue if there's no previous value
156 156
         }
157 157
 
158 158
         foreach ( $meta_value as $mk => $mv ) {
159 159
             //remove blank values
160
-            if ( empty( $mv )  ) {
161
-                unset( $meta_value[ $mk ] );
160
+            if ( empty( $mv ) ) {
161
+                unset( $meta_value[$mk] );
162 162
             }
163 163
         }
164 164
 
165
-        $cur_form_prefix = reset($meta_value);
166
-        $cur_form_prefix = explode('_', $cur_form_prefix);
165
+        $cur_form_prefix = reset( $meta_value );
166
+        $cur_form_prefix = explode( '_', $cur_form_prefix );
167 167
         $cur_form_prefix = $cur_form_prefix[0];
168 168
         $save = false;
169 169
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
             $meta_value[] = $prev_hidden;
184 184
             $save = true;
185
-            unset($form_prefix);
185
+            unset( $form_prefix );
186 186
         }
187 187
 
188 188
 		if ( $save ) {
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		foreach ( $fields as $field ) {
215 215
 			if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) {
216 216
 				// Can't sort on checkboxes because they are stored serialized, or post fields
217
-				$columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
217
+				$columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id;
218 218
 			}
219 219
 		}
220 220
 
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
                     break;
238 238
                 }
239 239
 
240
-                unset($form_prefix);
240
+                unset( $form_prefix );
241 241
             }
242 242
         }
243 243
 
@@ -245,36 +245,36 @@  discard block
 block discarded – undo
245 245
 			return $result;
246 246
 		}
247 247
 
248
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
248
+        $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
249 249
         $max_columns = 8;
250 250
         if ( $i <= $max_columns ) {
251 251
 			return $result;
252 252
 		}
253 253
 
254 254
         global $frm_vars;
255
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
256
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
255
+        if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] ) {
256
+            $frm_vars['current_form']->options = maybe_unserialize( $frm_vars['current_form']->options );
257 257
         }
258 258
 
259
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) {
259
+        if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) ) {
260 260
             $result = $frm_vars['current_form']->options['hidden_cols'];
261 261
         } else {
262 262
             $cols = $frm_vars['cols'];
263
-            $cols = array_reverse($cols, true);
263
+            $cols = array_reverse( $cols, true );
264 264
 
265 265
 			$result[] = $form_id . '_id';
266
-            $i--;
266
+            $i --;
267 267
 
268 268
 			$result[] = $form_id . '_item_key';
269
-            $i--;
269
+            $i --;
270 270
 
271 271
 			foreach ( $cols as $col_key => $col ) {
272 272
                 if ( $i > $max_columns ) {
273 273
 					$result[] = $col_key;
274 274
 				}
275 275
                 //remove some columns by default
276
-                $i--;
277
-                unset($col_key, $col);
276
+                $i --;
277
+                unset( $col_key, $col );
278 278
             }
279 279
         }
280 280
 
@@ -311,14 +311,14 @@  discard block
 block discarded – undo
311 311
         if ( $pagenum > $total_pages && $total_pages > 0 ) {
312 312
 			$url = add_query_arg( 'paged', $total_pages );
313 313
             if ( headers_sent() ) {
314
-                echo FrmAppHelper::js_redirect($url);
314
+                echo FrmAppHelper::js_redirect( $url );
315 315
             } else {
316 316
                 wp_redirect( esc_url_raw( $url ) );
317 317
             }
318 318
             die();
319 319
         }
320 320
 
321
-        if ( empty($message) && isset($_GET['import-message']) ) {
321
+        if ( empty( $message ) && isset( $_GET['import-message'] ) ) {
322 322
             $message = __( 'Your import is complete', 'formidable' );
323 323
         }
324 324
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 
328 328
     /* Back End CRUD */
329 329
 	public static function show( $id = 0 ) {
330
-        FrmAppHelper::permission_check('frm_view_entries');
330
+        FrmAppHelper::permission_check( 'frm_view_entries' );
331 331
 
332 332
         if ( ! $id ) {
333 333
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
@@ -337,9 +337,9 @@  discard block
 block discarded – undo
337 337
             }
338 338
         }
339 339
 
340
-        $entry = FrmEntry::getOne($id, true);
340
+        $entry = FrmEntry::getOne( $id, true );
341 341
 
342
-        $data = maybe_unserialize($entry->description);
342
+        $data = maybe_unserialize( $entry->description );
343 343
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
344 344
 			$data = array( 'referrer' => $data );
345 345
 		}
@@ -351,14 +351,14 @@  discard block
 block discarded – undo
351 351
     }
352 352
 
353 353
     public static function destroy() {
354
-        FrmAppHelper::permission_check('frm_delete_entries');
354
+        FrmAppHelper::permission_check( 'frm_delete_entries' );
355 355
 
356 356
 		$params = FrmForm::get_admin_params();
357 357
 
358
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
358
+        if ( isset( $params['keep_post'] ) && $params['keep_post'] ) {
359 359
             //unlink entry from post
360 360
             global $wpdb;
361
-			$wpdb->update( $wpdb->prefix .'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
361
+			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
362 362
         }
363 363
 
364 364
         $message = '';
@@ -433,9 +433,9 @@  discard block
 block discarded – undo
433 433
         if ( ! isset( $frm_vars['form_params'] ) ) {
434 434
             $frm_vars['form_params'] = array();
435 435
         }
436
-		$frm_vars['form_params'][ $form->id ] = $params;
436
+		$frm_vars['form_params'][$form->id] = $params;
437 437
 
438
-		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
438
+		if ( isset( $frm_vars['created_entries'][$form_id] ) ) {
439 439
             return;
440 440
         }
441 441
 
@@ -450,13 +450,13 @@  discard block
 block discarded – undo
450 450
 		 */
451 451
 		$errors = apply_filters( 'frm_entries_before_create', $errors, $form );
452 452
 
453
-		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
453
+		$frm_vars['created_entries'][$form_id] = array( 'errors' => $errors );
454 454
 
455 455
         if ( empty( $errors ) ) {
456 456
 			$_POST['frm_skip_cookie'] = 1;
457 457
             if ( $params['action'] == 'create' ) {
458
-				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
459
-					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
458
+				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) {
459
+					$frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST );
460 460
                 }
461 461
             }
462 462
 
@@ -491,28 +491,28 @@  discard block
 block discarded – undo
491 491
 	}
492 492
 
493 493
     public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
494
-        $field = FrmField::getOne($meta->field_id);
494
+        $field = FrmField::getOne( $meta->field_id );
495 495
         if ( ! $field ) {
496 496
             return $value;
497 497
         }
498 498
 
499
-        $value = self::filter_display_value($value, $field, $atts);
499
+        $value = self::filter_display_value( $value, $field, $atts );
500 500
         return $value;
501 501
     }
502 502
 
503 503
 	public static function &filter_shortcode_value( $value, $tag, $atts, $field ) {
504
-        $plain_text = add_filter('frm_plain_text_email', true);
504
+        $plain_text = add_filter( 'frm_plain_text_email', true );
505 505
 		FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value );
506 506
 
507
-        if ( isset($atts['show']) && $atts['show'] == 'value' ) {
507
+        if ( isset( $atts['show'] ) && $atts['show'] == 'value' ) {
508 508
             return $value;
509 509
         }
510 510
 
511
-        return self::filter_display_value($value, $field, $atts);
511
+        return self::filter_display_value( $value, $field, $atts );
512 512
     }
513 513
 
514 514
     public static function &filter_display_value( $value, $field, $atts = array() ) {
515
-        $saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
515
+        $saved_value = ( isset( $atts['saved_value'] ) && $atts['saved_value'] ) ? true : false;
516 516
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'radio', 'select' ) ) || ! FrmField::is_option_true( $field, 'separate_value' ) || $saved_value ) {
517 517
             return $value;
518 518
         }
@@ -520,29 +520,29 @@  discard block
 block discarded – undo
520 520
         $f_values = $f_labels = array();
521 521
 
522 522
         foreach ( $field->options as $opt_key => $opt ) {
523
-            if ( ! is_array($opt) ) {
523
+            if ( ! is_array( $opt ) ) {
524 524
                 continue;
525 525
             }
526 526
 
527
-            $f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
528
-            $f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
529
-            if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
530
-                unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
527
+            $f_labels[$opt_key] = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
528
+            $f_values[$opt_key] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[$opt_key];
529
+            if ( $f_labels[$opt_key] == $f_values[$opt_key] ) {
530
+                unset( $f_values[$opt_key], $f_labels[$opt_key] );
531 531
             }
532
-            unset($opt_key, $opt);
532
+            unset( $opt_key, $opt );
533 533
         }
534 534
 
535
-        if ( ! empty($f_values) ) {
535
+        if ( ! empty( $f_values ) ) {
536 536
             foreach ( (array) $value as $v_key => $val ) {
537
-                if ( in_array($val, $f_values) ) {
538
-                    $opt = array_search($val, $f_values);
539
-                    if ( is_array($value) ) {
540
-                        $value[ $v_key ] = $f_labels[ $opt ];
537
+                if ( in_array( $val, $f_values ) ) {
538
+                    $opt = array_search( $val, $f_values );
539
+                    if ( is_array( $value ) ) {
540
+                        $value[$v_key] = $f_labels[$opt];
541 541
                     } else {
542
-                        $value = $f_labels[ $opt ];
542
+                        $value = $f_labels[$opt];
543 543
                     }
544 544
                 }
545
-                unset($v_key, $val);
545
+                unset( $v_key, $val );
546 546
             }
547 547
         }
548 548
 
@@ -555,9 +555,9 @@  discard block
 block discarded – undo
555 555
 	}
556 556
 
557 557
 	public static function entry_sidebar( $entry ) {
558
-        $data = maybe_unserialize($entry->description);
559
-        $date_format = get_option('date_format');
560
-        $time_format = get_option('time_format');
558
+        $data = maybe_unserialize( $entry->description );
559
+        $date_format = get_option( 'date_format' );
560
+        $time_format = get_option( 'time_format' );
561 561
 		if ( isset( $data['browser'] ) ) {
562 562
 			$browser = FrmEntryFormat::get_browser( $data['browser'] );
563 563
 		}
Please login to merge, or discard this patch.
classes/controllers/FrmFormsController.php 2 patches
Indentation   +596 added lines, -596 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmFormsController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		$menu_label = __( 'Forms', 'formidable' );
7 7
 		if ( ! FrmAppHelper::pro_is_installed() ) {
8 8
 			$menu_label .= ' (Lite)';
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 		add_submenu_page('formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
11 11
 
12 12
 		self::maybe_load_listing_hooks();
13
-    }
13
+	}
14 14
 
15 15
 	public static function maybe_load_listing_hooks() {
16 16
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
@@ -24,128 +24,128 @@  discard block
 block discarded – undo
24 24
 		add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
25 25
 	}
26 26
 
27
-    public static function head() {
28
-        wp_enqueue_script('formidable-editinplace');
27
+	public static function head() {
28
+		wp_enqueue_script('formidable-editinplace');
29 29
 
30
-        if ( wp_is_mobile() ) {
31
-    		wp_enqueue_script( 'jquery-touch-punch' );
32
-    	}
33
-    }
30
+		if ( wp_is_mobile() ) {
31
+			wp_enqueue_script( 'jquery-touch-punch' );
32
+		}
33
+	}
34 34
 
35
-    public static function register_widgets() {
36
-        require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
-        register_widget('FrmShowForm');
38
-    }
35
+	public static function register_widgets() {
36
+		require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
+		register_widget('FrmShowForm');
38
+	}
39 39
 
40
-    public static function list_form() {
41
-        FrmAppHelper::permission_check('frm_view_forms');
40
+	public static function list_form() {
41
+		FrmAppHelper::permission_check('frm_view_forms');
42 42
 
43 43
 		$params = FrmForm::list_page_params();
44
-        $errors = self::process_bulk_form_actions( array());
45
-        $errors = apply_filters('frm_admin_list_form_action', $errors);
44
+		$errors = self::process_bulk_form_actions( array());
45
+		$errors = apply_filters('frm_admin_list_form_action', $errors);
46 46
 
47 47
 		return self::display_forms_list( $params, '', $errors );
48
-    }
48
+	}
49 49
 
50 50
 	public static function new_form( $values = array() ) {
51
-        FrmAppHelper::permission_check('frm_edit_forms');
51
+		FrmAppHelper::permission_check('frm_edit_forms');
52 52
 
53
-        global $frm_vars;
53
+		global $frm_vars;
54 54
 
55
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
55
+		$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
56 56
 		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
57 57
 
58 58
 		if ( $action == 'create' ) {
59
-            return self::create($values);
59
+			return self::create($values);
60 60
 		} else if ( $action == 'new' ) {
61 61
 			$frm_field_selection = FrmField::field_selection();
62
-            $values = FrmFormsHelper::setup_new_vars($values);
63
-            $id = FrmForm::create( $values );
64
-            $form = FrmForm::getOne($id);
62
+			$values = FrmFormsHelper::setup_new_vars($values);
63
+			$id = FrmForm::create( $values );
64
+			$form = FrmForm::getOne($id);
65 65
 
66
-            // add default email notification
67
-            $action_control = FrmFormActionsController::get_form_actions( 'email' );
68
-            $action_control->create($form->id);
66
+			// add default email notification
67
+			$action_control = FrmFormActionsController::get_form_actions( 'email' );
68
+			$action_control->create($form->id);
69 69
 
70 70
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
71 71
 
72
-            $values['id'] = $id;
72
+			$values['id'] = $id;
73 73
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
74
-        }
75
-    }
74
+		}
75
+	}
76 76
 
77 77
 	public static function create( $values = array() ) {
78
-        FrmAppHelper::permission_check('frm_edit_forms');
78
+		FrmAppHelper::permission_check('frm_edit_forms');
79 79
 
80
-        global $frm_vars;
81
-        if ( empty( $values ) ) {
82
-            $values = $_POST;
83
-        }
80
+		global $frm_vars;
81
+		if ( empty( $values ) ) {
82
+			$values = $_POST;
83
+		}
84 84
 
85
-        //Set radio button and checkbox meta equal to "other" value
86
-        if ( FrmAppHelper::pro_is_installed() ) {
87
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
88
-        }
85
+		//Set radio button and checkbox meta equal to "other" value
86
+		if ( FrmAppHelper::pro_is_installed() ) {
87
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
88
+		}
89 89
 
90 90
 		$id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
91 91
 
92
-        if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
93
-            $frm_settings = FrmAppHelper::get_settings();
94
-            $errors = array( 'form' => $frm_settings->admin_permission );
95
-        } else {
96
-            $errors = FrmForm::validate($values);
97
-        }
92
+		if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
93
+			$frm_settings = FrmAppHelper::get_settings();
94
+			$errors = array( 'form' => $frm_settings->admin_permission );
95
+		} else {
96
+			$errors = FrmForm::validate($values);
97
+		}
98 98
 
99
-        if ( count($errors) > 0 ) {
100
-            $hide_preview = true;
99
+		if ( count($errors) > 0 ) {
100
+			$hide_preview = true;
101 101
 			$frm_field_selection = FrmField::field_selection();
102
-            $form = FrmForm::getOne( $id );
103
-            $fields = FrmField::get_all_for_form($id);
102
+			$form = FrmForm::getOne( $id );
103
+			$fields = FrmField::get_all_for_form($id);
104 104
 
105
-            $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
105
+			$values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
106 106
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
107 107
 
108 108
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
109
-        } else {
110
-            FrmForm::update( $id, $values, true );
109
+		} else {
110
+			FrmForm::update( $id, $values, true );
111 111
 			$url = admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id );
112 112
 			die( FrmAppHelper::js_redirect( $url ) );
113
-        }
114
-    }
113
+		}
114
+	}
115 115
 
116
-    public static function edit( $values = false ) {
117
-        FrmAppHelper::permission_check('frm_edit_forms');
116
+	public static function edit( $values = false ) {
117
+		FrmAppHelper::permission_check('frm_edit_forms');
118 118
 
119 119
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
120
-        return self::get_edit_vars($id);
121
-    }
120
+		return self::get_edit_vars($id);
121
+	}
122 122
 
123
-    public static function settings( $id = false, $message = '' ) {
124
-        FrmAppHelper::permission_check('frm_edit_forms');
123
+	public static function settings( $id = false, $message = '' ) {
124
+		FrmAppHelper::permission_check('frm_edit_forms');
125 125
 
126
-        if ( ! $id || ! is_numeric($id) ) {
126
+		if ( ! $id || ! is_numeric($id) ) {
127 127
 			$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
128
-        }
128
+		}
129 129
 		return self::get_settings_vars( $id, array(), $message );
130
-    }
130
+	}
131 131
 
132
-    public static function update_settings() {
133
-        FrmAppHelper::permission_check('frm_edit_forms');
132
+	public static function update_settings() {
133
+		FrmAppHelper::permission_check('frm_edit_forms');
134 134
 
135 135
 		$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
136 136
 
137
-        $errors = FrmForm::validate($_POST);
138
-        if ( count($errors) > 0 ) {
139
-            return self::get_settings_vars($id, $errors);
140
-        }
137
+		$errors = FrmForm::validate($_POST);
138
+		if ( count($errors) > 0 ) {
139
+			return self::get_settings_vars($id, $errors);
140
+		}
141 141
 
142
-        do_action('frm_before_update_form_settings', $id);
142
+		do_action('frm_before_update_form_settings', $id);
143 143
 
144 144
 		FrmForm::update( $id, $_POST );
145 145
 
146
-        $message = __( 'Settings Successfully Updated', 'formidable' );
146
+		$message = __( 'Settings Successfully Updated', 'formidable' );
147 147
 		return self::get_settings_vars( $id, array(), $message );
148
-    }
148
+	}
149 149
 
150 150
 	public static function edit_key() {
151 151
 		$values = self::edit_in_place_value( 'form_key' );
@@ -175,43 +175,43 @@  discard block
 block discarded – undo
175 175
 
176 176
 	public static function update( $values = array() ) {
177 177
 		if ( empty( $values ) ) {
178
-            $values = $_POST;
179
-        }
178
+			$values = $_POST;
179
+		}
180 180
 
181
-        //Set radio button and checkbox meta equal to "other" value
182
-        if ( FrmAppHelper::pro_is_installed() ) {
183
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
184
-        }
181
+		//Set radio button and checkbox meta equal to "other" value
182
+		if ( FrmAppHelper::pro_is_installed() ) {
183
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
184
+		}
185 185
 
186
-        $errors = FrmForm::validate( $values );
187
-        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
188
-        if ( $permission_error !== false ) {
189
-            $errors['form'] = $permission_error;
190
-        }
186
+		$errors = FrmForm::validate( $values );
187
+		$permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
188
+		if ( $permission_error !== false ) {
189
+			$errors['form'] = $permission_error;
190
+		}
191 191
 
192 192
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
193 193
 
194 194
 		if ( count( $errors ) > 0 ) {
195
-            return self::get_edit_vars( $id, $errors );
195
+			return self::get_edit_vars( $id, $errors );
196 196
 		} else {
197
-            FrmForm::update( $id, $values );
198
-            $message = __( 'Form was Successfully Updated', 'formidable' );
199
-            if ( defined( 'DOING_AJAX' ) ) {
197
+			FrmForm::update( $id, $values );
198
+			$message = __( 'Form was Successfully Updated', 'formidable' );
199
+			if ( defined( 'DOING_AJAX' ) ) {
200 200
 				wp_die( $message );
201
-            }
201
+			}
202 202
 			return self::get_edit_vars( $id, array(), $message );
203
-        }
204
-    }
203
+		}
204
+	}
205 205
 
206
-    public static function bulk_create_template( $ids ) {
207
-        FrmAppHelper::permission_check( 'frm_edit_forms' );
206
+	public static function bulk_create_template( $ids ) {
207
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
208 208
 
209
-        foreach ( $ids as $id ) {
210
-            FrmForm::duplicate( $id, true, true );
211
-        }
209
+		foreach ( $ids as $id ) {
210
+			FrmForm::duplicate( $id, true, true );
211
+		}
212 212
 
213
-        return __( 'Form template was Successfully Created', 'formidable' );
214
-    }
213
+		return __( 'Form template was Successfully Created', 'formidable' );
214
+	}
215 215
 
216 216
 	/**
217 217
 	 * Redirect to the url for creating from a template
@@ -233,45 +233,45 @@  discard block
 block discarded – undo
233 233
 		wp_die();
234 234
 	}
235 235
 
236
-    public static function duplicate() {
237
-        FrmAppHelper::permission_check('frm_edit_forms');
236
+	public static function duplicate() {
237
+		FrmAppHelper::permission_check('frm_edit_forms');
238 238
 
239 239
 		$params = FrmForm::list_page_params();
240
-        $form = FrmForm::duplicate( $params['id'], $params['template'], true );
241
-        $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
242
-        if ( $form ) {
240
+		$form = FrmForm::duplicate( $params['id'], $params['template'], true );
241
+		$message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
242
+		if ( $form ) {
243 243
 			return self::get_edit_vars( $form, array(), $message, true );
244
-        } else {
245
-            return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
246
-        }
247
-    }
244
+		} else {
245
+			return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
246
+		}
247
+	}
248 248
 
249
-    public static function page_preview() {
249
+	public static function page_preview() {
250 250
 		$params = FrmForm::list_page_params();
251
-        if ( ! $params['form'] ) {
252
-            return;
253
-        }
254
-
255
-        $form = FrmForm::getOne( $params['form'] );
256
-        if ( ! $form ) {
257
-            return;
258
-        }
259
-        return self::show_form( $form->id, '', true, true );
260
-    }
261
-
262
-    public static function preview() {
263
-        do_action( 'frm_wp' );
264
-
265
-        global $frm_vars;
266
-        $frm_vars['preview'] = true;
267
-
268
-        if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
269
-            global $wp;
270
-            $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
251
+		if ( ! $params['form'] ) {
252
+			return;
253
+		}
254
+
255
+		$form = FrmForm::getOne( $params['form'] );
256
+		if ( ! $form ) {
257
+			return;
258
+		}
259
+		return self::show_form( $form->id, '', true, true );
260
+	}
261
+
262
+	public static function preview() {
263
+		do_action( 'frm_wp' );
264
+
265
+		global $frm_vars;
266
+		$frm_vars['preview'] = true;
267
+
268
+		if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
269
+			global $wp;
270
+			$root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
271 271
 			include_once( $root . '/wp-config.php' );
272
-            $wp->init();
273
-            $wp->register_globals();
274
-        }
272
+			$wp->init();
273
+			$wp->register_globals();
274
+		}
275 275
 
276 276
 		self::register_pro_scripts();
277 277
 
@@ -285,11 +285,11 @@  discard block
 block discarded – undo
285 285
 		$form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 );
286 286
 		if ( empty( $form ) ) {
287 287
 			$form = FrmForm::getAll( array(), '', 1 );
288
-        }
288
+		}
289 289
 
290 290
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' );
291
-        wp_die();
292
-    }
291
+		wp_die();
292
+	}
293 293
 
294 294
 	public static function register_pro_scripts() {
295 295
 		if ( FrmAppHelper::pro_is_installed() ) {
@@ -299,22 +299,22 @@  discard block
 block discarded – undo
299 299
 		}
300 300
 	}
301 301
 
302
-    public static function untrash() {
302
+	public static function untrash() {
303 303
 		self::change_form_status( 'untrash' );
304
-    }
304
+	}
305 305
 
306 306
 	public static function bulk_untrash( $ids ) {
307
-        FrmAppHelper::permission_check('frm_edit_forms');
307
+		FrmAppHelper::permission_check('frm_edit_forms');
308 308
 
309
-        $count = FrmForm::set_status( $ids, 'published' );
309
+		$count = FrmForm::set_status( $ids, 'published' );
310 310
 
311
-        $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
312
-        return $message;
313
-    }
311
+		$message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
312
+		return $message;
313
+	}
314 314
 
315
-    public static function trash() {
315
+	public static function trash() {
316 316
 		self::change_form_status( 'trash' );
317
-    }
317
+	}
318 318
 
319 319
 	/**
320 320
 	 * @param string $status
@@ -352,68 +352,68 @@  discard block
 block discarded – undo
352 352
 	}
353 353
 
354 354
 	public static function bulk_trash( $ids ) {
355
-        FrmAppHelper::permission_check('frm_delete_forms');
355
+		FrmAppHelper::permission_check('frm_delete_forms');
356 356
 
357
-        $count = 0;
358
-        foreach ( $ids as $id ) {
359
-            if ( FrmForm::trash( $id ) ) {
360
-                $count++;
361
-            }
362
-        }
357
+		$count = 0;
358
+		foreach ( $ids as $id ) {
359
+			if ( FrmForm::trash( $id ) ) {
360
+				$count++;
361
+			}
362
+		}
363 363
 
364
-        $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
364
+		$current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
365 365
 		$message = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type=' . $current_page . '&item-action[]=' . implode( 'item-action[]=', $ids ), 'bulk-toplevel_page_formidable' ) ) . '">', '</a>' );
366 366
 
367
-        return $message;
368
-    }
367
+		return $message;
368
+	}
369 369
 
370
-    public static function destroy() {
371
-        FrmAppHelper::permission_check('frm_delete_forms');
370
+	public static function destroy() {
371
+		FrmAppHelper::permission_check('frm_delete_forms');
372 372
 
373 373
 		$params = FrmForm::list_page_params();
374 374
 
375
-        //check nonce url
376
-        check_admin_referer('destroy_form_' . $params['id']);
375
+		//check nonce url
376
+		check_admin_referer('destroy_form_' . $params['id']);
377 377
 
378
-        $count = 0;
379
-        if ( FrmForm::destroy( $params['id'] ) ) {
380
-            $count++;
381
-        }
378
+		$count = 0;
379
+		if ( FrmForm::destroy( $params['id'] ) ) {
380
+			$count++;
381
+		}
382 382
 
383
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
383
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
384 384
 
385 385
 		self::display_forms_list( $params, $message );
386
-    }
386
+	}
387 387
 
388 388
 	public static function bulk_destroy( $ids ) {
389
-        FrmAppHelper::permission_check('frm_delete_forms');
389
+		FrmAppHelper::permission_check('frm_delete_forms');
390 390
 
391
-        $count = 0;
392
-        foreach ( $ids as $id ) {
393
-            $d = FrmForm::destroy( $id );
394
-            if ( $d ) {
395
-                $count++;
396
-            }
397
-        }
391
+		$count = 0;
392
+		foreach ( $ids as $id ) {
393
+			$d = FrmForm::destroy( $id );
394
+			if ( $d ) {
395
+				$count++;
396
+			}
397
+		}
398 398
 
399
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
399
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
400 400
 
401
-        return $message;
402
-    }
401
+		return $message;
402
+	}
403 403
 
404
-    private static function delete_all() {
405
-        //check nonce url
406
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
407
-        if ( $permission_error !== false ) {
404
+	private static function delete_all() {
405
+		//check nonce url
406
+		$permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
407
+		if ( $permission_error !== false ) {
408 408
 			self::display_forms_list( array(), '', array( $permission_error ) );
409
-            return;
410
-        }
409
+			return;
410
+		}
411 411
 
412 412
 		$count = FrmForm::scheduled_delete( time() );
413
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
413
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
414 414
 
415 415
 		self::display_forms_list( array(), $message );
416
-    }
416
+	}
417 417
 
418 418
 	public static function scheduled_delete( $delete_timestamp = '' ) {
419 419
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::scheduled_delete' );
@@ -421,11 +421,11 @@  discard block
 block discarded – undo
421 421
 	}
422 422
 
423 423
 	/**
424
-	* Inserts Formidable button
425
-	* Hook exists since 2.5.0
426
-	*
427
-	* @since 2.0.15
428
-	*/
424
+	 * Inserts Formidable button
425
+	 * Hook exists since 2.5.0
426
+	 *
427
+	 * @since 2.0.15
428
+	 */
429 429
 	public static function insert_form_button() {
430 430
 		if ( current_user_can('frm_view_forms') ) {
431 431
 			$menu_name = FrmAppHelper::get_menu_name();
@@ -436,49 +436,49 @@  discard block
 block discarded – undo
436 436
 		}
437 437
 	}
438 438
 
439
-    public static function insert_form_popup() {
439
+	public static function insert_form_popup() {
440 440
 		$page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) );
441 441
 		if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) {
442
-            return;
443
-        }
442
+			return;
443
+		}
444 444
 
445
-        FrmAppHelper::load_admin_wide_js();
445
+		FrmAppHelper::load_admin_wide_js();
446 446
 
447
-        $shortcodes = array(
447
+		$shortcodes = array(
448 448
 			'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ),
449
-        );
449
+		);
450 450
 
451
-        $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
451
+		$shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
452 452
 
453 453
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
454
-    }
454
+	}
455 455
 
456
-    public static function get_shortcode_opts() {
456
+	public static function get_shortcode_opts() {
457 457
 		FrmAppHelper::permission_check('frm_view_forms');
458
-        check_ajax_referer( 'frm_ajax', 'nonce' );
458
+		check_ajax_referer( 'frm_ajax', 'nonce' );
459 459
 
460 460
 		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
461
-        if ( empty($shortcode) ) {
462
-            wp_die();
463
-        }
461
+		if ( empty($shortcode) ) {
462
+			wp_die();
463
+		}
464 464
 
465 465
 		echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">';
466 466
 		echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />';
467 467
 
468
-        $form_id = '';
469
-        $opts = array();
468
+		$form_id = '';
469
+		$opts = array();
470 470
 		switch ( $shortcode ) {
471
-            case 'formidable':
472
-                $opts = array(
471
+			case 'formidable':
472
+				$opts = array(
473 473
 					'form_id'       => 'id',
474
-                    //'key' => ',
474
+					//'key' => ',
475 475
 					'title'         => array( 'val' => 1, 'label' => __( 'Display form title', 'formidable' ) ),
476 476
 					'description'   => array( 'val' => 1, 'label' => __( 'Display form description', 'formidable' ) ),
477 477
 					'minimize'      => array( 'val' => 1, 'label' => __( 'Minimize form HTML', 'formidable' ) ),
478
-                );
479
-            break;
480
-        }
481
-        $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
478
+				);
479
+			break;
480
+		}
481
+		$opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
482 482
 
483 483
 		if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
484 484
 			// allow other shortcodes to use the required form id option
@@ -488,61 +488,61 @@  discard block
 block discarded – undo
488 488
 
489 489
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
490 490
 
491
-        echo '</div>';
491
+		echo '</div>';
492 492
 
493
-        wp_die();
494
-    }
493
+		wp_die();
494
+	}
495 495
 
496 496
 	public static function display_forms_list( $params = array(), $message = '', $errors = array(), $deprecated_errors = array() ) {
497
-        FrmAppHelper::permission_check( 'frm_view_forms' );
497
+		FrmAppHelper::permission_check( 'frm_view_forms' );
498 498
 		if ( ! empty( $deprecated_errors ) ) {
499 499
 			$errors = $deprecated_errors;
500 500
 			_deprecated_argument( 'errors', '2.0.8' );
501 501
 		}
502 502
 
503
-        global $wpdb, $frm_vars;
503
+		global $wpdb, $frm_vars;
504 504
 
505 505
 		if ( empty( $params ) ) {
506 506
 			$params = FrmForm::list_page_params();
507
-        }
507
+		}
508 508
 
509
-        $wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
509
+		$wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
510 510
 
511
-        $pagenum = $wp_list_table->get_pagenum();
511
+		$pagenum = $wp_list_table->get_pagenum();
512 512
 
513
-        $wp_list_table->prepare_items();
513
+		$wp_list_table->prepare_items();
514 514
 
515
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
516
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
515
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
516
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
517 517
 			wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
518
-            die();
519
-        }
518
+			die();
519
+		}
520 520
 
521 521
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' );
522
-    }
522
+	}
523 523
 
524 524
 	public static function get_columns( $columns ) {
525
-	    $columns['cb'] = '<input type="checkbox" />';
526
-	    $columns['id'] = 'ID';
525
+		$columns['cb'] = '<input type="checkbox" />';
526
+		$columns['id'] = 'ID';
527 527
 
528
-        $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published';
528
+		$type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published';
529 529
 
530
-        if ( 'template' == $type ) {
531
-            $columns['name']        = __( 'Template Name', 'formidable' );
532
-            $columns['type']        = __( 'Type', 'formidable' );
533
-            $columns['form_key']    = __( 'Key', 'formidable' );
534
-        } else {
535
-            $columns['name']        = __( 'Form Title', 'formidable' );
536
-            $columns['entries']     = __( 'Entries', 'formidable' );
537
-            $columns['form_key']    = __( 'Key', 'formidable' );
538
-            $columns['shortcode']   = __( 'Shortcodes', 'formidable' );
539
-        }
530
+		if ( 'template' == $type ) {
531
+			$columns['name']        = __( 'Template Name', 'formidable' );
532
+			$columns['type']        = __( 'Type', 'formidable' );
533
+			$columns['form_key']    = __( 'Key', 'formidable' );
534
+		} else {
535
+			$columns['name']        = __( 'Form Title', 'formidable' );
536
+			$columns['entries']     = __( 'Entries', 'formidable' );
537
+			$columns['form_key']    = __( 'Key', 'formidable' );
538
+			$columns['shortcode']   = __( 'Shortcodes', 'formidable' );
539
+		}
540 540
 
541
-        $columns['created_at'] = __( 'Date', 'formidable' );
541
+		$columns['created_at'] = __( 'Date', 'formidable' );
542 542
 
543 543
 		add_screen_option( 'per_page', array( 'label' => __( 'Forms', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_per_page' ) );
544 544
 
545
-        return $columns;
545
+		return $columns;
546 546
 	}
547 547
 
548 548
 	public static function get_sortable_columns() {
@@ -556,110 +556,110 @@  discard block
 block discarded – undo
556 556
 	}
557 557
 
558 558
 	public static function hidden_columns( $result ) {
559
-        $return = false;
560
-        foreach ( (array) $result as $r ) {
561
-            if ( ! empty( $r ) ) {
562
-                $return = true;
563
-                break;
564
-            }
565
-        }
559
+		$return = false;
560
+		foreach ( (array) $result as $r ) {
561
+			if ( ! empty( $r ) ) {
562
+				$return = true;
563
+				break;
564
+			}
565
+		}
566 566
 
567
-        if ( $return ) {
568
-            return $result;
567
+		if ( $return ) {
568
+			return $result;
569 569
 		}
570 570
 
571
-        $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
571
+		$type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
572 572
 
573
-        $result[] = 'created_at';
574
-        if ( $type == 'template' ) {
575
-            $result[] = 'id';
576
-            $result[] = 'form_key';
577
-        }
573
+		$result[] = 'created_at';
574
+		if ( $type == 'template' ) {
575
+			$result[] = 'id';
576
+			$result[] = 'form_key';
577
+		}
578 578
 
579
-        return $result;
580
-    }
579
+		return $result;
580
+	}
581 581
 
582 582
 	public static function save_per_page( $save, $option, $value ) {
583
-        if ( $option == 'formidable_page_formidable_per_page' ) {
584
-            $save = (int) $value;
585
-        }
586
-        return $save;
587
-    }
583
+		if ( $option == 'formidable_page_formidable_per_page' ) {
584
+			$save = (int) $value;
585
+		}
586
+		return $save;
587
+	}
588 588
 
589 589
 	private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
590
-        global $frm_vars;
590
+		global $frm_vars;
591 591
 
592
-        $form = FrmForm::getOne( $id );
593
-        if ( ! $form ) {
594
-            wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) );
595
-        }
592
+		$form = FrmForm::getOne( $id );
593
+		if ( ! $form ) {
594
+			wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) );
595
+		}
596 596
 
597
-        if ( $form->parent_form_id ) {
597
+		if ( $form->parent_form_id ) {
598 598
 			wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ));
599
-        }
599
+		}
600 600
 
601 601
 		$frm_field_selection = FrmField::field_selection();
602
-        $fields = FrmField::get_all_for_form($form->id);
602
+		$fields = FrmField::get_all_for_form($form->id);
603 603
 
604
-        // Automatically add end section fields if they don't exist (2.0 migration)
605
-        $reset_fields = false;
606
-        FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
604
+		// Automatically add end section fields if they don't exist (2.0 migration)
605
+		$reset_fields = false;
606
+		FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
607 607
 
608
-        if ( $reset_fields ) {
609
-            $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
610
-        }
608
+		if ( $reset_fields ) {
609
+			$fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
610
+		}
611 611
 
612
-        unset($end_section_values, $last_order, $open, $reset_fields);
612
+		unset($end_section_values, $last_order, $open, $reset_fields);
613 613
 
614
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
614
+		$values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
615 615
 
616
-        $edit_message = __( 'Form was Successfully Updated', 'formidable' );
617
-        if ( $form->is_template && $message == $edit_message ) {
618
-            $message = __( 'Template was Successfully Updated', 'formidable' );
619
-        }
616
+		$edit_message = __( 'Form was Successfully Updated', 'formidable' );
617
+		if ( $form->is_template && $message == $edit_message ) {
618
+			$message = __( 'Template was Successfully Updated', 'formidable' );
619
+		}
620 620
 
621 621
 		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
622 622
 
623
-        if ( $form->default_template ) {
624
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
625
-        } else if ( defined('DOING_AJAX') ) {
626
-            wp_die();
627
-        } else if ( $create_link ) {
623
+		if ( $form->default_template ) {
624
+			wp_die(__( 'That template cannot be edited', 'formidable' ));
625
+		} else if ( defined('DOING_AJAX') ) {
626
+			wp_die();
627
+		} else if ( $create_link ) {
628 628
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
629
-        } else {
629
+		} else {
630 630
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
631
-        }
632
-    }
631
+		}
632
+	}
633 633
 
634 634
 	public static function get_settings_vars( $id, $errors = array(), $message = '' ) {
635 635
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
636 636
 
637
-        global $frm_vars;
637
+		global $frm_vars;
638 638
 
639
-        $form = FrmForm::getOne( $id );
639
+		$form = FrmForm::getOne( $id );
640 640
 
641
-        $fields = FrmField::get_all_for_form($id);
642
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
641
+		$fields = FrmField::get_all_for_form($id);
642
+		$values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
643 643
 
644
-        if ( isset($values['default_template']) && $values['default_template'] ) {
645
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
646
-        }
644
+		if ( isset($values['default_template']) && $values['default_template'] ) {
645
+			wp_die(__( 'That template cannot be edited', 'formidable' ));
646
+		}
647 647
 
648
-        $action_controls = FrmFormActionsController::get_form_actions();
648
+		$action_controls = FrmFormActionsController::get_form_actions();
649 649
 
650
-        $sections = apply_filters('frm_add_form_settings_section', array(), $values);
651
-        $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
650
+		$sections = apply_filters('frm_add_form_settings_section', array(), $values);
651
+		$pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
652 652
 
653
-        $styles = apply_filters('frm_get_style_opts', array());
653
+		$styles = apply_filters('frm_get_style_opts', array());
654 654
 
655 655
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
656
-    }
656
+	}
657 657
 
658
-    public static function mb_tags_box( $form_id, $class = '' ) {
659
-        $fields = FrmField::get_all_for_form($form_id, '', 'include');
660
-        $linked_forms = array();
661
-        $col = 'one';
662
-        $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
658
+	public static function mb_tags_box( $form_id, $class = '' ) {
659
+		$fields = FrmField::get_all_for_form($form_id, '', 'include');
660
+		$linked_forms = array();
661
+		$col = 'one';
662
+		$settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
663 663
 
664 664
 		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
665 665
 		$adv_shortcodes = self::get_advanced_shortcodes();
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 		$entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
668 668
 
669 669
 		include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' );
670
-    }
670
+	}
671 671
 
672 672
 	/**
673 673
 	 * Get an array of the options to display in the advanced tab
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
 			''          => '',
709 709
 			'siteurl'   => __( 'Site URL', 'formidable' ),
710 710
 			'sitename'  => __( 'Site Name', 'formidable' ),
711
-        );
711
+		);
712 712
 
713 713
 		if ( ! FrmAppHelper::pro_is_installed() ) {
714 714
 			unset( $entry_shortcodes['post_id'] );
@@ -735,39 +735,39 @@  discard block
 block discarded – undo
735 735
 		return $entry_shortcodes;
736 736
 	}
737 737
 
738
-    // Insert the form class setting into the form
738
+	// Insert the form class setting into the form
739 739
 	public static function form_classes( $form ) {
740
-        if ( isset($form->options['form_class']) ) {
740
+		if ( isset($form->options['form_class']) ) {
741 741
 			echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
742
-        }
743
-    }
742
+		}
743
+	}
744 744
 
745
-    public static function get_email_html() {
745
+	public static function get_email_html() {
746 746
 		FrmAppHelper::permission_check('frm_view_forms');
747
-        check_ajax_referer( 'frm_ajax', 'nonce' );
747
+		check_ajax_referer( 'frm_ajax', 'nonce' );
748 748
 		echo FrmEntryFormat::show_entry( array(
749 749
 			'form_id'       => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
750
-	        'default_email' => true,
750
+			'default_email' => true,
751 751
 			'plain_text'    => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ),
752
-	    ) );
753
-	    wp_die();
752
+		) );
753
+		wp_die();
754 754
 	}
755 755
 
756
-    public static function filter_content( $content, $form, $entry = false ) {
756
+	public static function filter_content( $content, $form, $entry = false ) {
757 757
 		self::get_entry_by_param( $entry );
758
-        if ( ! $entry ) {
759
-            return $content;
760
-        }
758
+		if ( ! $entry ) {
759
+			return $content;
760
+		}
761 761
 
762
-        if ( is_object( $form ) ) {
763
-            $form = $form->id;
764
-        }
762
+		if ( is_object( $form ) ) {
763
+			$form = $form->id;
764
+		}
765 765
 
766
-        $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
767
-        $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
766
+		$shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
767
+		$content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
768 768
 
769
-        return $content;
770
-    }
769
+		return $content;
770
+	}
771 771
 
772 772
 	private static function get_entry_by_param( &$entry ) {
773 773
 		if ( ! $entry || ! is_object( $entry ) ) {
@@ -779,287 +779,287 @@  discard block
 block discarded – undo
779 779
 		}
780 780
 	}
781 781
 
782
-    public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
783
-        return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
784
-    }
782
+	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
783
+		return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
784
+	}
785 785
 
786
-    public static function process_bulk_form_actions( $errors ) {
787
-        if ( ! $_REQUEST ) {
788
-            return $errors;
789
-        }
786
+	public static function process_bulk_form_actions( $errors ) {
787
+		if ( ! $_REQUEST ) {
788
+			return $errors;
789
+		}
790 790
 
791 791
 		$bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
792
-        if ( $bulkaction == -1 ) {
792
+		if ( $bulkaction == -1 ) {
793 793
 			$bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
794
-        }
795
-
796
-        if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
797
-            FrmAppHelper::remove_get_action();
798
-
799
-            $bulkaction = str_replace( 'bulk_', '', $bulkaction );
800
-        }
801
-
802
-        $ids = FrmAppHelper::get_param( 'item-action', '' );
803
-        if ( empty( $ids ) ) {
804
-            $errors[] = __( 'No forms were specified', 'formidable' );
805
-            return $errors;
806
-        }
807
-
808
-        $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
809
-        if ( $permission_error !== false ) {
810
-            $errors[] = $permission_error;
811
-            return $errors;
812
-        }
813
-
814
-        if ( ! is_array( $ids ) ) {
815
-            $ids = explode( ',', $ids );
816
-        }
817
-
818
-        switch ( $bulkaction ) {
819
-            case 'delete':
820
-                $message = self::bulk_destroy( $ids );
821
-            break;
822
-            case 'trash':
823
-                $message = self::bulk_trash( $ids );
824
-            break;
825
-            case 'untrash':
826
-                $message = self::bulk_untrash( $ids );
827
-            break;
828
-            case 'create_template':
829
-                $message = self::bulk_create_template( $ids );
830
-            break;
831
-        }
832
-
833
-        if ( isset( $message ) && ! empty( $message ) ) {
794
+		}
795
+
796
+		if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
797
+			FrmAppHelper::remove_get_action();
798
+
799
+			$bulkaction = str_replace( 'bulk_', '', $bulkaction );
800
+		}
801
+
802
+		$ids = FrmAppHelper::get_param( 'item-action', '' );
803
+		if ( empty( $ids ) ) {
804
+			$errors[] = __( 'No forms were specified', 'formidable' );
805
+			return $errors;
806
+		}
807
+
808
+		$permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
809
+		if ( $permission_error !== false ) {
810
+			$errors[] = $permission_error;
811
+			return $errors;
812
+		}
813
+
814
+		if ( ! is_array( $ids ) ) {
815
+			$ids = explode( ',', $ids );
816
+		}
817
+
818
+		switch ( $bulkaction ) {
819
+			case 'delete':
820
+				$message = self::bulk_destroy( $ids );
821
+			break;
822
+			case 'trash':
823
+				$message = self::bulk_trash( $ids );
824
+			break;
825
+			case 'untrash':
826
+				$message = self::bulk_untrash( $ids );
827
+			break;
828
+			case 'create_template':
829
+				$message = self::bulk_create_template( $ids );
830
+			break;
831
+		}
832
+
833
+		if ( isset( $message ) && ! empty( $message ) ) {
834 834
 			echo '<div id="message" class="updated frm_msg_padding">' . FrmAppHelper::kses( $message ) . '</div>';
835
-        }
835
+		}
836 836
 
837
-        return $errors;
838
-    }
837
+		return $errors;
838
+	}
839 839
 
840
-    public static function add_default_templates( $path, $default = true, $template = true ) {
841
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
840
+	public static function add_default_templates( $path, $default = true, $template = true ) {
841
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
842 842
 
843
-        $path = untrailingslashit(trim($path));
843
+		$path = untrailingslashit(trim($path));
844 844
 		$templates = glob( $path . '/*.php' );
845 845
 
846 846
 		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
847 847
 			$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) );
848 848
 			$template_query = array( 'form_key' => $filename );
849
-            if ( $template ) {
850
-                $template_query['is_template'] = 1;
851
-            }
852
-            if ( $default ) {
853
-                $template_query['default_template'] = 1;
854
-            }
849
+			if ( $template ) {
850
+				$template_query['is_template'] = 1;
851
+			}
852
+			if ( $default ) {
853
+				$template_query['default_template'] = 1;
854
+			}
855 855
 			$form = FrmForm::getAll( $template_query, '', 1 );
856 856
 
857
-            $values = FrmFormsHelper::setup_new_vars();
858
-            $values['form_key'] = $filename;
859
-            $values['is_template'] = $template;
860
-            $values['status'] = 'published';
861
-            if ( $default ) {
862
-                $values['default_template'] = 1;
863
-            }
864
-
865
-            include( $templates[ $i ] );
866
-
867
-            //get updated form
868
-            if ( isset($form) && ! empty($form) ) {
869
-                $old_id = $form->id;
870
-                $form = FrmForm::getOne($form->id);
871
-            } else {
872
-                $old_id = false;
857
+			$values = FrmFormsHelper::setup_new_vars();
858
+			$values['form_key'] = $filename;
859
+			$values['is_template'] = $template;
860
+			$values['status'] = 'published';
861
+			if ( $default ) {
862
+				$values['default_template'] = 1;
863
+			}
864
+
865
+			include( $templates[ $i ] );
866
+
867
+			//get updated form
868
+			if ( isset($form) && ! empty($form) ) {
869
+				$old_id = $form->id;
870
+				$form = FrmForm::getOne($form->id);
871
+			} else {
872
+				$old_id = false;
873 873
 				$form = FrmForm::getAll( $template_query, '', 1 );
874
-            }
874
+			}
875 875
 
876
-            if ( $form ) {
876
+			if ( $form ) {
877 877
 				do_action( 'frm_after_duplicate_form', $form->id, (array) $form, array( 'old_id' => $old_id ) );
878
-            }
879
-        }
880
-    }
878
+			}
879
+		}
880
+	}
881 881
 
882
-    public static function route() {
883
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
884
-        $vars = array();
882
+	public static function route() {
883
+		$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
884
+		$vars = array();
885 885
 		if ( isset( $_POST['frm_compact_fields'] ) ) {
886 886
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
887 887
 
888
-            $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
889
-            $json_vars = json_decode($json_vars, true);
890
-            if ( empty($json_vars) ) {
891
-                // json decoding failed so we should return an error message
888
+			$json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
889
+			$json_vars = json_decode($json_vars, true);
890
+			if ( empty($json_vars) ) {
891
+				// json decoding failed so we should return an error message
892 892
 				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
893
-                if ( 'edit' == $action ) {
894
-                    $action = 'update';
895
-                }
896
-
897
-                add_filter('frm_validate_form', 'FrmFormsController::json_error');
898
-            } else {
899
-                $vars = FrmAppHelper::json_to_array($json_vars);
900
-                $action = $vars[ $action ];
893
+				if ( 'edit' == $action ) {
894
+					$action = 'update';
895
+				}
896
+
897
+				add_filter('frm_validate_form', 'FrmFormsController::json_error');
898
+			} else {
899
+				$vars = FrmAppHelper::json_to_array($json_vars);
900
+				$action = $vars[ $action ];
901 901
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
902 902
 				$_REQUEST = array_merge( $_REQUEST, $vars );
903 903
 				$_POST = array_merge( $_POST, $_REQUEST );
904
-            }
905
-        } else {
904
+			}
905
+		} else {
906 906
 			$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
907
-    		if ( isset( $_REQUEST['delete_all'] ) ) {
908
-                // override the action for this page
909
-    			$action = 'delete_all';
910
-            }
911
-        }
907
+			if ( isset( $_REQUEST['delete_all'] ) ) {
908
+				// override the action for this page
909
+				$action = 'delete_all';
910
+			}
911
+		}
912 912
 
913 913
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
914
-        FrmAppHelper::trigger_hook_load( 'form' );
915
-
916
-        switch ( $action ) {
917
-            case 'new':
918
-                return self::new_form($vars);
919
-            case 'create':
920
-            case 'edit':
921
-            case 'update':
922
-            case 'duplicate':
923
-            case 'trash':
924
-            case 'untrash':
925
-            case 'destroy':
926
-            case 'delete_all':
927
-            case 'settings':
928
-            case 'update_settings':
914
+		FrmAppHelper::trigger_hook_load( 'form' );
915
+
916
+		switch ( $action ) {
917
+			case 'new':
918
+				return self::new_form($vars);
919
+			case 'create':
920
+			case 'edit':
921
+			case 'update':
922
+			case 'duplicate':
923
+			case 'trash':
924
+			case 'untrash':
925
+			case 'destroy':
926
+			case 'delete_all':
927
+			case 'settings':
928
+			case 'update_settings':
929 929
 				return self::$action( $vars );
930
-            default:
930
+			default:
931 931
 				do_action( 'frm_form_action_' . $action );
932 932
 				if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
933
-                    return;
934
-                }
933
+					return;
934
+				}
935 935
 
936 936
 				$action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
937
-                if ( $action == -1 ) {
937
+				if ( $action == -1 ) {
938 938
 					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
939
-                }
939
+				}
940 940
 
941
-                if ( strpos($action, 'bulk_') === 0 ) {
942
-                    FrmAppHelper::remove_get_action();
943
-                    return self::list_form();
944
-                }
941
+				if ( strpos($action, 'bulk_') === 0 ) {
942
+					FrmAppHelper::remove_get_action();
943
+					return self::list_form();
944
+				}
945 945
 
946
-                return self::display_forms_list();
947
-        }
948
-    }
946
+				return self::display_forms_list();
947
+		}
948
+	}
949 949
 
950
-    public static function json_error( $errors ) {
951
-        $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
952
-        return $errors;
953
-    }
950
+	public static function json_error( $errors ) {
951
+		$errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
952
+		return $errors;
953
+	}
954 954
 
955 955
 
956
-    /* FRONT-END FORMS */
957
-    public static function admin_bar_css() {
956
+	/* FRONT-END FORMS */
957
+	public static function admin_bar_css() {
958 958
 		if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
959
-            return;
960
-        }
959
+			return;
960
+		}
961 961
 
962 962
 		add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' );
963 963
 		FrmAppHelper::load_font_style();
964 964
 	}
965 965
 
966 966
 	public static function admin_bar_configure() {
967
-        global $frm_vars;
968
-        if ( empty($frm_vars['forms_loaded']) ) {
969
-            return;
970
-        }
971
-
972
-        $actions = array();
973
-        foreach ( $frm_vars['forms_loaded'] as $form ) {
974
-            if ( is_object($form) ) {
975
-                $actions[ $form->id ] = $form->name;
976
-            }
977
-            unset($form);
978
-        }
979
-
980
-        if ( empty($actions) ) {
981
-            return;
982
-        }
983
-
984
-        asort($actions);
985
-
986
-        global $wp_admin_bar;
987
-
988
-        if ( count($actions) == 1 ) {
989
-            $wp_admin_bar->add_menu( array(
990
-                'title' => 'Edit Form',
967
+		global $frm_vars;
968
+		if ( empty($frm_vars['forms_loaded']) ) {
969
+			return;
970
+		}
971
+
972
+		$actions = array();
973
+		foreach ( $frm_vars['forms_loaded'] as $form ) {
974
+			if ( is_object($form) ) {
975
+				$actions[ $form->id ] = $form->name;
976
+			}
977
+			unset($form);
978
+		}
979
+
980
+		if ( empty($actions) ) {
981
+			return;
982
+		}
983
+
984
+		asort($actions);
985
+
986
+		global $wp_admin_bar;
987
+
988
+		if ( count($actions) == 1 ) {
989
+			$wp_admin_bar->add_menu( array(
990
+				'title' => 'Edit Form',
991 991
 				'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ),
992
-                'id'    => 'frm-forms',
993
-            ) );
994
-        } else {
995
-            $wp_admin_bar->add_menu( array(
996
-        		'id'    => 'frm-forms',
997
-        		'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>',
992
+				'id'    => 'frm-forms',
993
+			) );
994
+		} else {
995
+			$wp_admin_bar->add_menu( array(
996
+				'id'    => 'frm-forms',
997
+				'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>',
998 998
 				'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ),
999
-        		'meta'  => array(
999
+				'meta'  => array(
1000 1000
 					'title' => __( 'Edit Forms', 'formidable' ),
1001
-        		),
1002
-        	) );
1001
+				),
1002
+			) );
1003 1003
 
1004
-        	foreach ( $actions as $form_id => $name ) {
1004
+			foreach ( $actions as $form_id => $name ) {
1005 1005
 
1006
-        		$wp_admin_bar->add_menu( array(
1007
-        			'parent'    => 'frm-forms',
1006
+				$wp_admin_bar->add_menu( array(
1007
+					'parent'    => 'frm-forms',
1008 1008
 					'id'        => 'edit_form_' . $form_id,
1009
-        			'title'     => empty($name) ? __( '(no title)') : $name,
1009
+					'title'     => empty($name) ? __( '(no title)') : $name,
1010 1010
 					'href'      => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ),
1011
-        		) );
1012
-        	}
1013
-        }
1014
-    }
1011
+				) );
1012
+			}
1013
+		}
1014
+	}
1015 1015
 
1016
-    //formidable shortcode
1016
+	//formidable shortcode
1017 1017
 	public static function get_form_shortcode( $atts ) {
1018
-        global $frm_vars;
1019
-        if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1020
-            $sc = '[formidable';
1018
+		global $frm_vars;
1019
+		if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1020
+			$sc = '[formidable';
1021 1021
 			if ( ! empty( $atts ) ) {
1022 1022
 				foreach ( $atts as $k => $v ) {
1023 1023
 					$sc .= ' ' . $k . '="' . esc_attr( $v ) . '"';
1024 1024
 				}
1025 1025
 			}
1026 1026
 			return $sc . ']';
1027
-        }
1028
-
1029
-        $shortcode_atts = shortcode_atts( array(
1030
-            'id' => '', 'key' => '', 'title' => false, 'description' => false,
1031
-            'readonly' => false, 'entry_id' => false, 'fields' => array(),
1032
-            'exclude_fields' => array(), 'minimize' => false,
1033
-        ), $atts);
1034
-        do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1035
-
1036
-        return self::show_form(
1037
-            $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
1038
-            $shortcode_atts['description'], $atts
1039
-        );
1040
-    }
1041
-
1042
-    public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1043
-        if ( empty( $id ) ) {
1044
-            $id = $key;
1045
-        }
1046
-
1047
-        // no form id or key set
1048
-        if ( empty( $id ) ) {
1049
-            return __( 'Please select a valid form', 'formidable' );
1050
-        }
1051
-
1052
-        $form = FrmForm::getOne( $id );
1053
-        if ( ! $form || $form->parent_form_id ) {
1054
-            return __( 'Please select a valid form', 'formidable' );
1055
-        }
1027
+		}
1028
+
1029
+		$shortcode_atts = shortcode_atts( array(
1030
+			'id' => '', 'key' => '', 'title' => false, 'description' => false,
1031
+			'readonly' => false, 'entry_id' => false, 'fields' => array(),
1032
+			'exclude_fields' => array(), 'minimize' => false,
1033
+		), $atts);
1034
+		do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1035
+
1036
+		return self::show_form(
1037
+			$shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
1038
+			$shortcode_atts['description'], $atts
1039
+		);
1040
+	}
1041
+
1042
+	public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1043
+		if ( empty( $id ) ) {
1044
+			$id = $key;
1045
+		}
1046
+
1047
+		// no form id or key set
1048
+		if ( empty( $id ) ) {
1049
+			return __( 'Please select a valid form', 'formidable' );
1050
+		}
1051
+
1052
+		$form = FrmForm::getOne( $id );
1053
+		if ( ! $form || $form->parent_form_id ) {
1054
+			return __( 'Please select a valid form', 'formidable' );
1055
+		}
1056 1056
 
1057 1057
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1058
-        FrmAppHelper::trigger_hook_load( 'form', $form );
1058
+		FrmAppHelper::trigger_hook_load( 'form', $form );
1059 1059
 
1060
-        $form = apply_filters( 'frm_pre_display_form', $form );
1060
+		$form = apply_filters( 'frm_pre_display_form', $form );
1061 1061
 
1062
-        $frm_settings = FrmAppHelper::get_settings();
1062
+		$frm_settings = FrmAppHelper::get_settings();
1063 1063
 
1064 1064
 		if ( self::is_viewable_draft_form( $form ) ) {
1065 1065
 			// don't show a draft form on a page
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
 		}
1081 1081
 
1082 1082
 		return $form;
1083
-    }
1083
+	}
1084 1084
 
1085 1085
 	private static function is_viewable_draft_form( $form ) {
1086 1086
 		global $post;
@@ -1096,98 +1096,98 @@  discard block
 block discarded – undo
1096 1096
 		return $form->logged_in && get_current_user_id() && isset( $form->options['logged_in_role'] ) && $form->options['logged_in_role'] != '' && ! FrmAppHelper::user_has_permission( $form->options['logged_in_role'] );
1097 1097
 	}
1098 1098
 
1099
-    public static function get_form( $form, $title, $description, $atts = array() ) {
1100
-        ob_start();
1099
+	public static function get_form( $form, $title, $description, $atts = array() ) {
1100
+		ob_start();
1101 1101
 
1102
-        self::get_form_contents( $form, $title, $description, $atts );
1102
+		self::get_form_contents( $form, $title, $description, $atts );
1103 1103
 		self::enqueue_scripts( FrmForm::get_params( $form ) );
1104 1104
 
1105
-        $contents = ob_get_contents();
1106
-        ob_end_clean();
1105
+		$contents = ob_get_contents();
1106
+		ob_end_clean();
1107 1107
 
1108 1108
 		self::maybe_minimize_form( $atts, $contents );
1109 1109
 
1110
-        return $contents;
1111
-    }
1110
+		return $contents;
1111
+	}
1112 1112
 
1113 1113
 	public static function enqueue_scripts( $params ) {
1114 1114
 		do_action( 'frm_enqueue_form_scripts', $params );
1115 1115
 	}
1116 1116
 
1117 1117
 	public static function get_form_contents( $form, $title, $description, $atts ) {
1118
-        global $frm_vars;
1118
+		global $frm_vars;
1119 1119
 
1120
-        $frm_settings = FrmAppHelper::get_settings();
1120
+		$frm_settings = FrmAppHelper::get_settings();
1121 1121
 
1122
-        $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
1122
+		$submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
1123 1123
 
1124
-        $user_ID = get_current_user_id();
1124
+		$user_ID = get_current_user_id();
1125 1125
 		$params = FrmForm::get_params( $form );
1126
-        $message = $errors = '';
1126
+		$message = $errors = '';
1127 1127
 
1128
-        if ( $params['posted_form_id'] == $form->id && $_POST ) {
1129
-            $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array();
1130
-        }
1128
+		if ( $params['posted_form_id'] == $form->id && $_POST ) {
1129
+			$errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array();
1130
+		}
1131 1131
 
1132 1132
 		$include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
1133
-        $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) );
1133
+		$fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) );
1134 1134
 
1135
-        if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) {
1136
-            do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
1137
-            if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) {
1138
-                $values = FrmEntriesHelper::setup_new_vars($fields, $form);
1135
+		if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) {
1136
+			do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
1137
+			if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) {
1138
+				$values = FrmEntriesHelper::setup_new_vars($fields, $form);
1139 1139
 				include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1140
-            }
1141
-            return;
1142
-        }
1140
+			}
1141
+			return;
1142
+		}
1143 1143
 
1144
-        if ( ! empty($errors) ) {
1145
-            $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
1144
+		if ( ! empty($errors) ) {
1145
+			$values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
1146 1146
 			include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1147
-            return;
1148
-        }
1147
+			return;
1148
+		}
1149 1149
 
1150
-        do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
1151
-        if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) {
1152
-            return;
1153
-        }
1150
+		do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
1151
+		if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) {
1152
+			return;
1153
+		}
1154 1154
 
1155
-        $values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
1156
-        $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0;
1157
-        $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create');
1155
+		$values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
1156
+		$created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0;
1157
+		$conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create');
1158 1158
 
1159
-        if ( $created && is_numeric($created) && $conf_method != 'message' ) {
1160
-            do_action('frm_success_action', $conf_method, $form, $form->options, $created);
1159
+		if ( $created && is_numeric($created) && $conf_method != 'message' ) {
1160
+			do_action('frm_success_action', $conf_method, $form, $form->options, $created);
1161 1161
 			do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
1162
-            return;
1163
-        }
1162
+			return;
1163
+		}
1164 1164
 
1165
-        if ( $created && is_numeric($created) ) {
1166
-            $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
1167
-            $class = 'frm_message';
1168
-        } else {
1169
-            $message = $frm_settings->failed_msg;
1170
-            $class = 'frm_error_style';
1171
-        }
1165
+		if ( $created && is_numeric($created) ) {
1166
+			$message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
1167
+			$class = 'frm_message';
1168
+		} else {
1169
+			$message = $frm_settings->failed_msg;
1170
+			$class = 'frm_error_style';
1171
+		}
1172 1172
 
1173 1173
 		$message = FrmFormsHelper::get_success_message( array(
1174 1174
 			'message' => $message, 'form' => $form,
1175 1175
 			'entry_id' => $created, 'class' => $class,
1176 1176
 		) );
1177
-        $message = apply_filters('frm_main_feedback', $message, $form, $created);
1177
+		$message = apply_filters('frm_main_feedback', $message, $form, $created);
1178 1178
 
1179
-        if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) {
1179
+		if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) {
1180 1180
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1181
-        } else {
1182
-            global $frm_vars;
1181
+		} else {
1182
+			global $frm_vars;
1183 1183
 			self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
1184 1184
 
1185 1185
 			$include_extra_container = 'frm_forms' . FrmFormsHelper::get_form_style_class( $values );
1186 1186
 			include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' );
1187
-        }
1187
+		}
1188 1188
 
1189 1189
 		do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
1190
-    }
1190
+	}
1191 1191
 
1192 1192
 	public static function front_head() {
1193 1193
 		$version = FrmAppHelper::plugin_version();
@@ -1216,10 +1216,10 @@  discard block
 block discarded – undo
1216 1216
 	}
1217 1217
 
1218 1218
 	public static function defer_script_loading( $tag, $handle ) {
1219
-	    if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1220
-	        $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1219
+		if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1220
+			$tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1221 1221
 		}
1222
-	    return $tag;
1222
+		return $tag;
1223 1223
 	}
1224 1224
 
1225 1225
 	public static function footer_js( $location = 'footer' ) {
Please login to merge, or discard this patch.
Spacing   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 		if ( ! FrmAppHelper::pro_is_installed() ) {
8 8
 			$menu_label .= ' (Lite)';
9 9
 		}
10
-		add_submenu_page('formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
10
+		add_submenu_page( 'formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
11 11
 
12 12
 		self::maybe_load_listing_hooks();
13 13
     }
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 			return;
19 19
 		}
20 20
 
21
-		add_filter('get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
21
+		add_filter( 'get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
22 22
 
23
-		add_filter('manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
24
-		add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
23
+		add_filter( 'manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
24
+		add_filter( 'manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
25 25
 	}
26 26
 
27 27
     public static function head() {
28
-        wp_enqueue_script('formidable-editinplace');
28
+        wp_enqueue_script( 'formidable-editinplace' );
29 29
 
30 30
         if ( wp_is_mobile() ) {
31 31
     		wp_enqueue_script( 'jquery-touch-punch' );
@@ -33,39 +33,39 @@  discard block
 block discarded – undo
33 33
     }
34 34
 
35 35
     public static function register_widgets() {
36
-        require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
-        register_widget('FrmShowForm');
36
+        require_once( FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php' );
37
+        register_widget( 'FrmShowForm' );
38 38
     }
39 39
 
40 40
     public static function list_form() {
41
-        FrmAppHelper::permission_check('frm_view_forms');
41
+        FrmAppHelper::permission_check( 'frm_view_forms' );
42 42
 
43 43
 		$params = FrmForm::list_page_params();
44
-        $errors = self::process_bulk_form_actions( array());
45
-        $errors = apply_filters('frm_admin_list_form_action', $errors);
44
+        $errors = self::process_bulk_form_actions( array() );
45
+        $errors = apply_filters( 'frm_admin_list_form_action', $errors );
46 46
 
47 47
 		return self::display_forms_list( $params, '', $errors );
48 48
     }
49 49
 
50 50
 	public static function new_form( $values = array() ) {
51
-        FrmAppHelper::permission_check('frm_edit_forms');
51
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
52 52
 
53 53
         global $frm_vars;
54 54
 
55
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
56
-		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
55
+        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
56
+		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[$action];
57 57
 
58 58
 		if ( $action == 'create' ) {
59
-            return self::create($values);
59
+            return self::create( $values );
60 60
 		} else if ( $action == 'new' ) {
61 61
 			$frm_field_selection = FrmField::field_selection();
62
-            $values = FrmFormsHelper::setup_new_vars($values);
62
+            $values = FrmFormsHelper::setup_new_vars( $values );
63 63
             $id = FrmForm::create( $values );
64
-            $form = FrmForm::getOne($id);
64
+            $form = FrmForm::getOne( $id );
65 65
 
66 66
             // add default email notification
67 67
             $action_control = FrmFormActionsController::get_form_actions( 'email' );
68
-            $action_control->create($form->id);
68
+            $action_control->create( $form->id );
69 69
 
70 70
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
71 71
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     }
76 76
 
77 77
 	public static function create( $values = array() ) {
78
-        FrmAppHelper::permission_check('frm_edit_forms');
78
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
79 79
 
80 80
         global $frm_vars;
81 81
         if ( empty( $values ) ) {
@@ -87,22 +87,22 @@  discard block
 block discarded – undo
87 87
             $values = FrmProEntry::mod_other_vals( $values, 'back' );
88 88
         }
89 89
 
90
-		$id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
90
+		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
91 91
 
92 92
         if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
93 93
             $frm_settings = FrmAppHelper::get_settings();
94 94
             $errors = array( 'form' => $frm_settings->admin_permission );
95 95
         } else {
96
-            $errors = FrmForm::validate($values);
96
+            $errors = FrmForm::validate( $values );
97 97
         }
98 98
 
99
-        if ( count($errors) > 0 ) {
99
+        if ( count( $errors ) > 0 ) {
100 100
             $hide_preview = true;
101 101
 			$frm_field_selection = FrmField::field_selection();
102 102
             $form = FrmForm::getOne( $id );
103
-            $fields = FrmField::get_all_for_form($id);
103
+            $fields = FrmField::get_all_for_form( $id );
104 104
 
105
-            $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
105
+            $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
106 106
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
107 107
 
108 108
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
@@ -114,32 +114,32 @@  discard block
 block discarded – undo
114 114
     }
115 115
 
116 116
     public static function edit( $values = false ) {
117
-        FrmAppHelper::permission_check('frm_edit_forms');
117
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
118 118
 
119 119
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
120
-        return self::get_edit_vars($id);
120
+        return self::get_edit_vars( $id );
121 121
     }
122 122
 
123 123
     public static function settings( $id = false, $message = '' ) {
124
-        FrmAppHelper::permission_check('frm_edit_forms');
124
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
125 125
 
126
-        if ( ! $id || ! is_numeric($id) ) {
126
+        if ( ! $id || ! is_numeric( $id ) ) {
127 127
 			$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
128 128
         }
129 129
 		return self::get_settings_vars( $id, array(), $message );
130 130
     }
131 131
 
132 132
     public static function update_settings() {
133
-        FrmAppHelper::permission_check('frm_edit_forms');
133
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
134 134
 
135 135
 		$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
136 136
 
137
-        $errors = FrmForm::validate($_POST);
138
-        if ( count($errors) > 0 ) {
139
-            return self::get_settings_vars($id, $errors);
137
+        $errors = FrmForm::validate( $_POST );
138
+        if ( count( $errors ) > 0 ) {
139
+            return self::get_settings_vars( $id, $errors );
140 140
         }
141 141
 
142
-        do_action('frm_before_update_form_settings', $id);
142
+        do_action( 'frm_before_update_form_settings', $id );
143 143
 
144 144
 		FrmForm::update( $id, $_POST );
145 145
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 
162 162
 	private static function edit_in_place_value( $field ) {
163 163
 		check_ajax_referer( 'frm_ajax', 'nonce' );
164
-		FrmAppHelper::permission_check('frm_edit_forms', 'hide');
164
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
165 165
 
166 166
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
167 167
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_filter_post_kses' );
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	 * @since 2.0
220 220
 	 */
221 221
 	public static function _create_from_template() {
222
-		FrmAppHelper::permission_check('frm_edit_forms');
222
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
223 223
 		check_ajax_referer( 'frm_ajax', 'nonce' );
224 224
 
225 225
 		$current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' );
@@ -234,15 +234,15 @@  discard block
 block discarded – undo
234 234
 	}
235 235
 
236 236
     public static function duplicate() {
237
-        FrmAppHelper::permission_check('frm_edit_forms');
237
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
238 238
 
239 239
 		$params = FrmForm::list_page_params();
240 240
         $form = FrmForm::duplicate( $params['id'], $params['template'], true );
241
-        $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
241
+        $message = ( $params['template'] ) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
242 242
         if ( $form ) {
243 243
 			return self::get_edit_vars( $form, array(), $message, true );
244 244
         } else {
245
-            return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
245
+            return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) );
246 246
         }
247 247
     }
248 248
 
@@ -304,11 +304,11 @@  discard block
 block discarded – undo
304 304
     }
305 305
 
306 306
 	public static function bulk_untrash( $ids ) {
307
-        FrmAppHelper::permission_check('frm_edit_forms');
307
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
308 308
 
309 309
         $count = FrmForm::set_status( $ids, 'published' );
310 310
 
311
-        $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
311
+        $message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
312 312
         return $message;
313 313
     }
314 314
 
@@ -327,11 +327,11 @@  discard block
 block discarded – undo
327 327
 			'trash'   => array( 'permission' => 'frm_delete_forms', 'new_status' => 'trash' ),
328 328
 		);
329 329
 
330
-		if ( ! isset( $available_status[ $status ] ) ) {
330
+		if ( ! isset( $available_status[$status] ) ) {
331 331
 			return;
332 332
 		}
333 333
 
334
-		FrmAppHelper::permission_check( $available_status[ $status ]['permission'] );
334
+		FrmAppHelper::permission_check( $available_status[$status]['permission'] );
335 335
 
336 336
 		$params = FrmForm::list_page_params();
337 337
 
@@ -339,25 +339,25 @@  discard block
 block discarded – undo
339 339
 		check_admin_referer( $status . '_form_' . $params['id'] );
340 340
 
341 341
 		$count = 0;
342
-		if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
343
-			$count++;
342
+		if ( FrmForm::set_status( $params['id'], $available_status[$status]['new_status'] ) ) {
343
+			$count ++;
344 344
 		}
345 345
 
346
-		$available_status['untrash']['message'] = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
346
+		$available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
347 347
 		$available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type=' . ( isset( $_REQUEST['form_type'] ) ? sanitize_title( $_REQUEST['form_type'] ) : '' ) . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
348 348
 
349
-		$message = $available_status[ $status ]['message'];
349
+		$message = $available_status[$status]['message'];
350 350
 
351 351
 		self::display_forms_list( $params, $message );
352 352
 	}
353 353
 
354 354
 	public static function bulk_trash( $ids ) {
355
-        FrmAppHelper::permission_check('frm_delete_forms');
355
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
356 356
 
357 357
         $count = 0;
358 358
         foreach ( $ids as $id ) {
359 359
             if ( FrmForm::trash( $id ) ) {
360
-                $count++;
360
+                $count ++;
361 361
             }
362 362
         }
363 363
 
@@ -368,49 +368,49 @@  discard block
 block discarded – undo
368 368
     }
369 369
 
370 370
     public static function destroy() {
371
-        FrmAppHelper::permission_check('frm_delete_forms');
371
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
372 372
 
373 373
 		$params = FrmForm::list_page_params();
374 374
 
375 375
         //check nonce url
376
-        check_admin_referer('destroy_form_' . $params['id']);
376
+        check_admin_referer( 'destroy_form_' . $params['id'] );
377 377
 
378 378
         $count = 0;
379 379
         if ( FrmForm::destroy( $params['id'] ) ) {
380
-            $count++;
380
+            $count ++;
381 381
         }
382 382
 
383
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
383
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
384 384
 
385 385
 		self::display_forms_list( $params, $message );
386 386
     }
387 387
 
388 388
 	public static function bulk_destroy( $ids ) {
389
-        FrmAppHelper::permission_check('frm_delete_forms');
389
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
390 390
 
391 391
         $count = 0;
392 392
         foreach ( $ids as $id ) {
393 393
             $d = FrmForm::destroy( $id );
394 394
             if ( $d ) {
395
-                $count++;
395
+                $count ++;
396 396
             }
397 397
         }
398 398
 
399
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
399
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
400 400
 
401 401
         return $message;
402 402
     }
403 403
 
404 404
     private static function delete_all() {
405 405
         //check nonce url
406
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
406
+        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
407 407
         if ( $permission_error !== false ) {
408 408
 			self::display_forms_list( array(), '', array( $permission_error ) );
409 409
             return;
410 410
         }
411 411
 
412 412
 		$count = FrmForm::scheduled_delete( time() );
413
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
413
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
414 414
 
415 415
 		self::display_forms_list( array(), $message );
416 416
     }
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 	* @since 2.0.15
428 428
 	*/
429 429
 	public static function insert_form_button() {
430
-		if ( current_user_can('frm_view_forms') ) {
430
+		if ( current_user_can( 'frm_view_forms' ) ) {
431 431
 			$menu_name = FrmAppHelper::get_menu_name();
432 432
 			$content = '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '">
433 433
 				<span class="frm-buttons-icon wp-media-buttons-icon"></span> ' .
@@ -448,17 +448,17 @@  discard block
 block discarded – undo
448 448
 			'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ),
449 449
         );
450 450
 
451
-        $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
451
+        $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes );
452 452
 
453 453
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
454 454
     }
455 455
 
456 456
     public static function get_shortcode_opts() {
457
-		FrmAppHelper::permission_check('frm_view_forms');
457
+		FrmAppHelper::permission_check( 'frm_view_forms' );
458 458
         check_ajax_referer( 'frm_ajax', 'nonce' );
459 459
 
460 460
 		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
461
-        if ( empty($shortcode) ) {
461
+        if ( empty( $shortcode ) ) {
462 462
             wp_die();
463 463
         }
464 464
 
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
                 );
479 479
             break;
480 480
         }
481
-        $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
481
+        $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode );
482 482
 
483 483
 		if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
484 484
 			// allow other shortcodes to use the required form id option
@@ -595,11 +595,11 @@  discard block
 block discarded – undo
595 595
         }
596 596
 
597 597
         if ( $form->parent_form_id ) {
598
-			wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ));
598
+			wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ) );
599 599
         }
600 600
 
601 601
 		$frm_field_selection = FrmField::field_selection();
602
-        $fields = FrmField::get_all_for_form($form->id);
602
+        $fields = FrmField::get_all_for_form( $form->id );
603 603
 
604 604
         // Automatically add end section fields if they don't exist (2.0 migration)
605 605
         $reset_fields = false;
@@ -609,9 +609,9 @@  discard block
 block discarded – undo
609 609
             $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
610 610
         }
611 611
 
612
-        unset($end_section_values, $last_order, $open, $reset_fields);
612
+        unset( $end_section_values, $last_order, $open, $reset_fields );
613 613
 
614
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
614
+        $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
615 615
 
616 616
         $edit_message = __( 'Form was Successfully Updated', 'formidable' );
617 617
         if ( $form->is_template && $message == $edit_message ) {
@@ -621,8 +621,8 @@  discard block
 block discarded – undo
621 621
 		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
622 622
 
623 623
         if ( $form->default_template ) {
624
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
625
-        } else if ( defined('DOING_AJAX') ) {
624
+            wp_die( __( 'That template cannot be edited', 'formidable' ) );
625
+        } else if ( defined( 'DOING_AJAX' ) ) {
626 626
             wp_die();
627 627
         } else if ( $create_link ) {
628 628
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
@@ -638,28 +638,28 @@  discard block
 block discarded – undo
638 638
 
639 639
         $form = FrmForm::getOne( $id );
640 640
 
641
-        $fields = FrmField::get_all_for_form($id);
642
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
641
+        $fields = FrmField::get_all_for_form( $id );
642
+        $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
643 643
 
644
-        if ( isset($values['default_template']) && $values['default_template'] ) {
645
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
644
+        if ( isset( $values['default_template'] ) && $values['default_template'] ) {
645
+            wp_die( __( 'That template cannot be edited', 'formidable' ) );
646 646
         }
647 647
 
648 648
         $action_controls = FrmFormActionsController::get_form_actions();
649 649
 
650
-        $sections = apply_filters('frm_add_form_settings_section', array(), $values);
650
+        $sections = apply_filters( 'frm_add_form_settings_section', array(), $values );
651 651
         $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
652 652
 
653
-        $styles = apply_filters('frm_get_style_opts', array());
653
+        $styles = apply_filters( 'frm_get_style_opts', array() );
654 654
 
655 655
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
656 656
     }
657 657
 
658 658
     public static function mb_tags_box( $form_id, $class = '' ) {
659
-        $fields = FrmField::get_all_for_form($form_id, '', 'include');
659
+        $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
660 660
         $linked_forms = array();
661 661
         $col = 'one';
662
-        $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
662
+        $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
663 663
 
664 664
 		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
665 665
 		$adv_shortcodes = self::get_advanced_shortcodes();
@@ -737,13 +737,13 @@  discard block
 block discarded – undo
737 737
 
738 738
     // Insert the form class setting into the form
739 739
 	public static function form_classes( $form ) {
740
-        if ( isset($form->options['form_class']) ) {
740
+        if ( isset( $form->options['form_class'] ) ) {
741 741
 			echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
742 742
         }
743 743
     }
744 744
 
745 745
     public static function get_email_html() {
746
-		FrmAppHelper::permission_check('frm_view_forms');
746
+		FrmAppHelper::permission_check( 'frm_view_forms' );
747 747
         check_ajax_referer( 'frm_ajax', 'nonce' );
748 748
 		echo FrmEntryFormat::show_entry( array(
749 749
 			'form_id'       => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
@@ -840,11 +840,11 @@  discard block
 block discarded – undo
840 840
     public static function add_default_templates( $path, $default = true, $template = true ) {
841 841
         _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
842 842
 
843
-        $path = untrailingslashit(trim($path));
843
+        $path = untrailingslashit( trim( $path ) );
844 844
 		$templates = glob( $path . '/*.php' );
845 845
 
846
-		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
847
-			$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) );
846
+		for ( $i = count( $templates ) - 1; $i >= 0; $i -- ) {
847
+			$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[$i] ) );
848 848
 			$template_query = array( 'form_key' => $filename );
849 849
             if ( $template ) {
850 850
                 $template_query['is_template'] = 1;
@@ -862,12 +862,12 @@  discard block
 block discarded – undo
862 862
                 $values['default_template'] = 1;
863 863
             }
864 864
 
865
-            include( $templates[ $i ] );
865
+            include( $templates[$i] );
866 866
 
867 867
             //get updated form
868
-            if ( isset($form) && ! empty($form) ) {
868
+            if ( isset( $form ) && ! empty( $form ) ) {
869 869
                 $old_id = $form->id;
870
-                $form = FrmForm::getOne($form->id);
870
+                $form = FrmForm::getOne( $form->id );
871 871
             } else {
872 872
                 $old_id = false;
873 873
 				$form = FrmForm::getAll( $template_query, '', 1 );
@@ -880,24 +880,24 @@  discard block
 block discarded – undo
880 880
     }
881 881
 
882 882
     public static function route() {
883
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
883
+        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
884 884
         $vars = array();
885 885
 		if ( isset( $_POST['frm_compact_fields'] ) ) {
886 886
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
887 887
 
888
-            $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
889
-            $json_vars = json_decode($json_vars, true);
890
-            if ( empty($json_vars) ) {
888
+            $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '&quot;', '\\\"', $_POST['frm_compact_fields'] ) ) ) );
889
+            $json_vars = json_decode( $json_vars, true );
890
+            if ( empty( $json_vars ) ) {
891 891
                 // json decoding failed so we should return an error message
892 892
 				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
893 893
                 if ( 'edit' == $action ) {
894 894
                     $action = 'update';
895 895
                 }
896 896
 
897
-                add_filter('frm_validate_form', 'FrmFormsController::json_error');
897
+                add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
898 898
             } else {
899
-                $vars = FrmAppHelper::json_to_array($json_vars);
900
-                $action = $vars[ $action ];
899
+                $vars = FrmAppHelper::json_to_array( $json_vars );
900
+                $action = $vars[$action];
901 901
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
902 902
 				$_REQUEST = array_merge( $_REQUEST, $vars );
903 903
 				$_POST = array_merge( $_POST, $_REQUEST );
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
 
916 916
         switch ( $action ) {
917 917
             case 'new':
918
-                return self::new_form($vars);
918
+                return self::new_form( $vars );
919 919
             case 'create':
920 920
             case 'edit':
921 921
             case 'update':
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
 					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
939 939
                 }
940 940
 
941
-                if ( strpos($action, 'bulk_') === 0 ) {
941
+                if ( strpos( $action, 'bulk_' ) === 0 ) {
942 942
                     FrmAppHelper::remove_get_action();
943 943
                     return self::list_form();
944 944
                 }
@@ -965,27 +965,27 @@  discard block
 block discarded – undo
965 965
 
966 966
 	public static function admin_bar_configure() {
967 967
         global $frm_vars;
968
-        if ( empty($frm_vars['forms_loaded']) ) {
968
+        if ( empty( $frm_vars['forms_loaded'] ) ) {
969 969
             return;
970 970
         }
971 971
 
972 972
         $actions = array();
973 973
         foreach ( $frm_vars['forms_loaded'] as $form ) {
974
-            if ( is_object($form) ) {
975
-                $actions[ $form->id ] = $form->name;
974
+            if ( is_object( $form ) ) {
975
+                $actions[$form->id] = $form->name;
976 976
             }
977
-            unset($form);
977
+            unset( $form );
978 978
         }
979 979
 
980
-        if ( empty($actions) ) {
980
+        if ( empty( $actions ) ) {
981 981
             return;
982 982
         }
983 983
 
984
-        asort($actions);
984
+        asort( $actions );
985 985
 
986 986
         global $wp_admin_bar;
987 987
 
988
-        if ( count($actions) == 1 ) {
988
+        if ( count( $actions ) == 1 ) {
989 989
             $wp_admin_bar->add_menu( array(
990 990
                 'title' => 'Edit Form',
991 991
 				'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ),
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
         		$wp_admin_bar->add_menu( array(
1007 1007
         			'parent'    => 'frm-forms',
1008 1008
 					'id'        => 'edit_form_' . $form_id,
1009
-        			'title'     => empty($name) ? __( '(no title)') : $name,
1009
+        			'title'     => empty( $name ) ? __( '(no title)' ) : $name,
1010 1010
 					'href'      => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ),
1011 1011
         		) );
1012 1012
         	}
@@ -1016,7 +1016,7 @@  discard block
 block discarded – undo
1016 1016
     //formidable shortcode
1017 1017
 	public static function get_form_shortcode( $atts ) {
1018 1018
         global $frm_vars;
1019
-        if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1019
+        if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1020 1020
             $sc = '[formidable';
1021 1021
 			if ( ! empty( $atts ) ) {
1022 1022
 				foreach ( $atts as $k => $v ) {
@@ -1030,8 +1030,8 @@  discard block
 block discarded – undo
1030 1030
             'id' => '', 'key' => '', 'title' => false, 'description' => false,
1031 1031
             'readonly' => false, 'entry_id' => false, 'fields' => array(),
1032 1032
             'exclude_fields' => array(), 'minimize' => false,
1033
-        ), $atts);
1034
-        do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1033
+        ), $atts );
1034
+        do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts );
1035 1035
 
1036 1036
         return self::show_form(
1037 1037
             $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
@@ -1119,51 +1119,51 @@  discard block
 block discarded – undo
1119 1119
 
1120 1120
         $frm_settings = FrmAppHelper::get_settings();
1121 1121
 
1122
-        $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
1122
+        $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value;
1123 1123
 
1124 1124
         $user_ID = get_current_user_id();
1125 1125
 		$params = FrmForm::get_params( $form );
1126 1126
         $message = $errors = '';
1127 1127
 
1128 1128
         if ( $params['posted_form_id'] == $form->id && $_POST ) {
1129
-            $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array();
1129
+            $errors = isset( $frm_vars['created_entries'][$form->id] ) ? $frm_vars['created_entries'][$form->id]['errors'] : array();
1130 1130
         }
1131 1131
 
1132 1132
 		$include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
1133 1133
         $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) );
1134 1134
 
1135 1135
         if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) {
1136
-            do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
1137
-            if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) {
1138
-                $values = FrmEntriesHelper::setup_new_vars($fields, $form);
1136
+            do_action( 'frm_display_form_action', $params, $fields, $form, $title, $description );
1137
+            if ( apply_filters( 'frm_continue_to_new', true, $form->id, $params['action'] ) ) {
1138
+                $values = FrmEntriesHelper::setup_new_vars( $fields, $form );
1139 1139
 				include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1140 1140
             }
1141 1141
             return;
1142 1142
         }
1143 1143
 
1144
-        if ( ! empty($errors) ) {
1145
-            $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
1144
+        if ( ! empty( $errors ) ) {
1145
+            $values = $fields ? FrmEntriesHelper::setup_new_vars( $fields, $form ) : array();
1146 1146
 			include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1147 1147
             return;
1148 1148
         }
1149 1149
 
1150
-        do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
1151
-        if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) {
1150
+        do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description );
1151
+        if ( ! apply_filters( 'frm_continue_to_create', true, $form->id ) ) {
1152 1152
             return;
1153 1153
         }
1154 1154
 
1155
-        $values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
1156
-        $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0;
1157
-        $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create');
1155
+        $values = FrmEntriesHelper::setup_new_vars( $fields, $form, true );
1156
+        $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][$form->id] ) ) ? $frm_vars['created_entries'][$form->id]['entry_id'] : 0;
1157
+        $conf_method = apply_filters( 'frm_success_filter', 'message', $form, $form->options, 'create' );
1158 1158
 
1159
-        if ( $created && is_numeric($created) && $conf_method != 'message' ) {
1160
-            do_action('frm_success_action', $conf_method, $form, $form->options, $created);
1159
+        if ( $created && is_numeric( $created ) && $conf_method != 'message' ) {
1160
+            do_action( 'frm_success_action', $conf_method, $form, $form->options, $created );
1161 1161
 			do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
1162 1162
             return;
1163 1163
         }
1164 1164
 
1165
-        if ( $created && is_numeric($created) ) {
1166
-            $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
1165
+        if ( $created && is_numeric( $created ) ) {
1166
+            $message = isset( $form->options['success_msg'] ) ? $form->options['success_msg'] : $frm_settings->success_msg;
1167 1167
             $class = 'frm_message';
1168 1168
         } else {
1169 1169
             $message = $frm_settings->failed_msg;
@@ -1174,9 +1174,9 @@  discard block
 block discarded – undo
1174 1174
 			'message' => $message, 'form' => $form,
1175 1175
 			'entry_id' => $created, 'class' => $class,
1176 1176
 		) );
1177
-        $message = apply_filters('frm_main_feedback', $message, $form, $created);
1177
+        $message = apply_filters( 'frm_main_feedback', $message, $form, $created );
1178 1178
 
1179
-        if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) {
1179
+        if ( ! isset( $form->options['show_form'] ) || $form->options['show_form'] ) {
1180 1180
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1181 1181
         } else {
1182 1182
             global $frm_vars;
Please login to merge, or discard this patch.
classes/controllers/FrmFieldsController.php 2 patches
Indentation   +438 added lines, -438 removed lines patch added patch discarded remove patch
@@ -2,137 +2,137 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmFieldsController {
4 4
 
5
-    public static function load_field() {
5
+	public static function load_field() {
6 6
 		FrmAppHelper::permission_check('frm_edit_forms');
7
-        check_ajax_referer( 'frm_ajax', 'nonce' );
7
+		check_ajax_referer( 'frm_ajax', 'nonce' );
8 8
 
9
-        $fields = $_POST['field'];
10
-        if ( empty( $fields ) ) {
11
-            wp_die();
12
-        }
9
+		$fields = $_POST['field'];
10
+		if ( empty( $fields ) ) {
11
+			wp_die();
12
+		}
13 13
 
14
-        $_GET['page'] = 'formidable';
15
-        $fields = stripslashes_deep( $fields );
14
+		$_GET['page'] = 'formidable';
15
+		$fields = stripslashes_deep( $fields );
16 16
 
17
-        $ajax = true;
17
+		$ajax = true;
18 18
 		$values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) );
19
-        $path = FrmAppHelper::plugin_path();
20
-        $field_html = array();
21
-
22
-        foreach ( $fields as $field ) {
23
-            $field = htmlspecialchars_decode( nl2br( $field ) );
24
-            $field = json_decode( $field, true );
25
-            if ( ! isset( $field['id'] ) ) {
26
-                // this field may have already been loaded
27
-                continue;
28
-            }
19
+		$path = FrmAppHelper::plugin_path();
20
+		$field_html = array();
21
+
22
+		foreach ( $fields as $field ) {
23
+			$field = htmlspecialchars_decode( nl2br( $field ) );
24
+			$field = json_decode( $field, true );
25
+			if ( ! isset( $field['id'] ) ) {
26
+				// this field may have already been loaded
27
+				continue;
28
+			}
29 29
 
30
-            $field_id = absint( $field['id'] );
30
+			$field_id = absint( $field['id'] );
31 31
 
32
-            if ( ! isset( $field['value'] ) ) {
33
-                $field['value'] = '';
34
-            }
32
+			if ( ! isset( $field['value'] ) ) {
33
+				$field['value'] = '';
34
+			}
35 35
 
36 36
 			$field_name = 'item_meta['. $field_id .']';
37
-            $html_id = FrmFieldsHelper::get_html_id($field);
37
+			$html_id = FrmFieldsHelper::get_html_id($field);
38 38
 
39
-            ob_start();
39
+			ob_start();
40 40
 			include( $path . '/classes/views/frm-forms/add_field.php' );
41
-            $field_html[ $field_id ] = ob_get_contents();
42
-            ob_end_clean();
43
-        }
41
+			$field_html[ $field_id ] = ob_get_contents();
42
+			ob_end_clean();
43
+		}
44 44
 
45
-        unset($path);
45
+		unset($path);
46 46
 
47
-        echo json_encode($field_html);
47
+		echo json_encode($field_html);
48 48
 
49
-        wp_die();
50
-    }
49
+		wp_die();
50
+	}
51 51
 
52
-    public static function create() {
52
+	public static function create() {
53 53
 		FrmAppHelper::permission_check('frm_edit_forms');
54
-        check_ajax_referer( 'frm_ajax', 'nonce' );
54
+		check_ajax_referer( 'frm_ajax', 'nonce' );
55 55
 
56 56
 		$field_type = FrmAppHelper::get_post_param( 'field', '', 'sanitize_text_field' );
57 57
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
58 58
 
59
-        $field = self::include_new_field($field_type, $form_id);
59
+		$field = self::include_new_field($field_type, $form_id);
60 60
 
61
-        // this hook will allow for multiple fields to be added at once
62
-        do_action('frm_after_field_created', $field, $form_id);
61
+		// this hook will allow for multiple fields to be added at once
62
+		do_action('frm_after_field_created', $field, $form_id);
63 63
 
64
-        wp_die();
65
-    }
64
+		wp_die();
65
+	}
66 66
 
67
-    /**
68
-     * @param integer $form_id
69
-     */
67
+	/**
68
+	 * @param integer $form_id
69
+	 */
70 70
 	public static function include_new_field( $field_type, $form_id ) {
71
-        $values = array();
72
-        if ( FrmAppHelper::pro_is_installed() ) {
73
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
74
-        }
71
+		$values = array();
72
+		if ( FrmAppHelper::pro_is_installed() ) {
73
+			$values['post_type'] = FrmProFormsHelper::post_type($form_id);
74
+		}
75 75
 
76
-        $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id));
77
-        $field_id = FrmField::create( $field_values );
76
+		$field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id));
77
+		$field_id = FrmField::create( $field_values );
78 78
 
79
-        if ( ! $field_id ) {
80
-            return false;
81
-        }
79
+		if ( ! $field_id ) {
80
+			return false;
81
+		}
82 82
 
83
-        $field = self::include_single_field($field_id, $values, $form_id);
83
+		$field = self::include_single_field($field_id, $values, $form_id);
84 84
 
85
-        return $field;
86
-    }
85
+		return $field;
86
+	}
87 87
 
88
-    public static function update_form_id() {
88
+	public static function update_form_id() {
89 89
 		FrmAppHelper::permission_check('frm_edit_forms');
90
-        check_ajax_referer( 'frm_ajax', 'nonce' );
90
+		check_ajax_referer( 'frm_ajax', 'nonce' );
91 91
 
92 92
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
93 93
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
94 94
 
95
-        if ( ! $field_id || ! $form_id ) {
96
-            wp_die();
97
-        }
95
+		if ( ! $field_id || ! $form_id ) {
96
+			wp_die();
97
+		}
98 98
 
99 99
 		$updated = FrmField::update( $field_id, compact( 'form_id' ) );
100 100
 		echo absint( $updated );
101 101
 
102
-        wp_die();
103
-    }
102
+		wp_die();
103
+	}
104 104
 
105 105
 	public static function edit_name( $field = 'name', $id = '' ) {
106 106
 		FrmAppHelper::permission_check('frm_edit_forms');
107
-        check_ajax_referer( 'frm_ajax', 'nonce' );
107
+		check_ajax_referer( 'frm_ajax', 'nonce' );
108 108
 
109
-        if ( empty($field) ) {
110
-            $field = 'name';
111
-        }
109
+		if ( empty($field) ) {
110
+			$field = 'name';
111
+		}
112 112
 
113
-        if ( empty($id) ) {
113
+		if ( empty($id) ) {
114 114
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
115 115
 			$id = str_replace( 'field_label_', '', $id );
116
-        }
116
+		}
117 117
 
118 118
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
119 119
 		$value = trim( $value );
120
-        if ( trim(strip_tags($value)) == '' ) {
121
-            // set blank value if there is no content
122
-            $value = '';
123
-        }
120
+		if ( trim(strip_tags($value)) == '' ) {
121
+			// set blank value if there is no content
122
+			$value = '';
123
+		}
124 124
 
125 125
 		FrmField::update( $id, array( $field => $value ) );
126 126
 
127 127
 		do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) );
128 128
 
129 129
 		echo stripslashes( wp_kses_post( $value ) );
130
-        wp_die();
131
-    }
130
+		wp_die();
131
+	}
132 132
 
133
-    public static function update_ajax_option() {
133
+	public static function update_ajax_option() {
134 134
 		FrmAppHelper::permission_check('frm_edit_forms');
135
-        check_ajax_referer( 'frm_ajax', 'nonce' );
135
+		check_ajax_referer( 'frm_ajax', 'nonce' );
136 136
 
137 137
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
138 138
 		if ( ! $field_id ) {
@@ -147,141 +147,141 @@  discard block
 block discarded – undo
147 147
 			unset($new_val);
148 148
 		}
149 149
 
150
-        FrmField::update( $field_id, array(
151
-            'field_options' => $field->field_options,
150
+		FrmField::update( $field_id, array(
151
+			'field_options' => $field->field_options,
152 152
 			'form_id'		=> $field->form_id,
153
-        ) );
154
-        wp_die();
155
-    }
153
+		) );
154
+		wp_die();
155
+	}
156 156
 
157
-    public static function duplicate() {
157
+	public static function duplicate() {
158 158
 		FrmAppHelper::permission_check('frm_edit_forms');
159
-        check_ajax_referer( 'frm_ajax', 'nonce' );
159
+		check_ajax_referer( 'frm_ajax', 'nonce' );
160 160
 
161
-        global $wpdb;
161
+		global $wpdb;
162 162
 
163 163
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
164 164
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
165 165
 
166 166
 		$copy_field = FrmField::getOne( $field_id );
167
-        if ( ! $copy_field ) {
168
-            wp_die();
169
-        }
167
+		if ( ! $copy_field ) {
168
+			wp_die();
169
+		}
170 170
 
171 171
 		do_action( 'frm_duplicate_field', $copy_field, $form_id );
172 172
 		do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id );
173 173
 
174
-        $values = array( 'id' => $form_id );
175
-        FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
174
+		$values = array( 'id' => $form_id );
175
+		FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
176 176
 
177 177
 		$field_count = FrmDb::get_count( $wpdb->prefix . 'frm_fields fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) );
178 178
 
179
-        $values['field_order'] = $field_count + 1;
179
+		$values['field_order'] = $field_count + 1;
180 180
 
181
-        if ( ! $field_id = FrmField::create($values) ) {
182
-            wp_die();
183
-        }
181
+		if ( ! $field_id = FrmField::create($values) ) {
182
+			wp_die();
183
+		}
184 184
 
185
-        self::include_single_field($field_id, $values);
185
+		self::include_single_field($field_id, $values);
186 186
 
187
-        wp_die();
188
-    }
187
+		wp_die();
188
+	}
189 189
 
190
-    /**
191
-     * Load a single field in the form builder along with all needed variables
192
-     */
193
-    public static function include_single_field( $field_id, $values, $form_id = 0 ) {
194
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
190
+	/**
191
+	 * Load a single field in the form builder along with all needed variables
192
+	 */
193
+	public static function include_single_field( $field_id, $values, $form_id = 0 ) {
194
+		$field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
195 195
 		$field_name = 'item_meta[' . $field_id . ']';
196
-        $html_id = FrmFieldsHelper::get_html_id($field);
197
-        $id = $form_id ? $form_id : $field['form_id'];
198
-        if ( $field['type'] == 'html' ) {
199
-            $field['stop_filter'] = true;
200
-        }
196
+		$html_id = FrmFieldsHelper::get_html_id($field);
197
+		$id = $form_id ? $form_id : $field['form_id'];
198
+		if ( $field['type'] == 'html' ) {
199
+			$field['stop_filter'] = true;
200
+		}
201 201
 
202 202
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' );
203 203
 
204
-        return $field;
205
-    }
204
+		return $field;
205
+	}
206 206
 
207
-    public static function destroy() {
207
+	public static function destroy() {
208 208
 		FrmAppHelper::permission_check('frm_edit_forms');
209
-        check_ajax_referer( 'frm_ajax', 'nonce' );
209
+		check_ajax_referer( 'frm_ajax', 'nonce' );
210 210
 
211 211
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
212 212
 		FrmField::destroy( $field_id );
213
-        wp_die();
214
-    }
213
+		wp_die();
214
+	}
215 215
 
216
-    /* Field Options */
216
+	/* Field Options */
217 217
 
218
-    //Add Single Option or Other Option
219
-    public static function add_option() {
218
+	//Add Single Option or Other Option
219
+	public static function add_option() {
220 220
 		FrmAppHelper::permission_check('frm_edit_forms');
221
-        check_ajax_referer( 'frm_ajax', 'nonce' );
221
+		check_ajax_referer( 'frm_ajax', 'nonce' );
222 222
 
223 223
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
224 224
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
225 225
 
226
-        //Get the field
227
-        $field = FrmField::getOne($id);
226
+		//Get the field
227
+		$field = FrmField::getOne($id);
228 228
 
229 229
 		if ( ! empty( $field->options ) ) {
230 230
 			$keys = array_keys( $field->options );
231
-            $last = str_replace( 'other_', '', end( $keys ) );
232
-        } else {
233
-            $last = 0;
234
-        }
235
-        $opt_key = $last + 1;
231
+			$last = str_replace( 'other_', '', end( $keys ) );
232
+		} else {
233
+			$last = 0;
234
+		}
235
+		$opt_key = $last + 1;
236 236
 
237
-        if ( 'other' == $opt_type ) {
237
+		if ( 'other' == $opt_type ) {
238 238
 			$opt = esc_html__( 'Other', 'formidable' );
239
-            $other_val = '';
240
-            $opt_key = 'other_' . $opt_key;
241
-
242
-            //Update value of "other" in DB
243
-            $field_options = maybe_unserialize( $field->field_options );
244
-            $field_options['other'] = 1;
245
-            FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
246
-        } else {
239
+			$other_val = '';
240
+			$opt_key = 'other_' . $opt_key;
241
+
242
+			//Update value of "other" in DB
243
+			$field_options = maybe_unserialize( $field->field_options );
244
+			$field_options['other'] = 1;
245
+			FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
246
+		} else {
247 247
 			$first_opt = reset( $field->options );
248 248
 			$next_opt = count( $field->options );
249
-            if ( $first_opt != '' ) {
250
-                $next_opt++;
251
-            }
249
+			if ( $first_opt != '' ) {
250
+				$next_opt++;
251
+			}
252 252
 			$opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt;
253
-            unset($next_opt);
254
-        }
255
-        $field_val = $opt;
253
+			unset($next_opt);
254
+		}
255
+		$field_val = $opt;
256 256
 		$field->options[ $opt_key ] = $opt;
257 257
 
258
-        //Update options in DB
258
+		//Update options in DB
259 259
 		FrmField::update( $id, array( 'options' => $field->options ) );
260 260
 
261
-        $field_data = $field;
262
-        $field = array(
263
-            'type'  => $field_data->type,
264
-            'id'    => $id,
265
-            'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
266
-            'form_id' => $field_data->form_id,
267
-            'field_key' => $field_data->field_key,
268
-        );
261
+		$field_data = $field;
262
+		$field = array(
263
+			'type'  => $field_data->type,
264
+			'id'    => $id,
265
+			'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
266
+			'form_id' => $field_data->form_id,
267
+			'field_key' => $field_data->field_key,
268
+		);
269 269
 
270 270
 		$field_name = 'item_meta[' . $id . ']';
271
-        $html_id = FrmFieldsHelper::get_html_id($field);
272
-        $checked = '';
271
+		$html_id = FrmFieldsHelper::get_html_id($field);
272
+		$checked = '';
273 273
 
274
-        if ( 'other' == $opt_type ) {
274
+		if ( 'other' == $opt_type ) {
275 275
 			require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
276
-        } else {
276
+		} else {
277 277
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
278
-        }
279
-        wp_die();
280
-    }
278
+		}
279
+		wp_die();
280
+	}
281 281
 
282
-    public static function edit_option() {
282
+	public static function edit_option() {
283 283
 		FrmAppHelper::permission_check('frm_edit_forms');
284
-        check_ajax_referer( 'frm_ajax', 'nonce' );
284
+		check_ajax_referer( 'frm_ajax', 'nonce' );
285 285
 
286 286
 		$element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
287 287
 		$ids = explode( '-', $element_id );
@@ -289,43 +289,43 @@  discard block
 block discarded – undo
289 289
 
290 290
 		$orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ) );
291 291
 		if ( strpos( $element_id, 'key_' ) ) {
292
-            $new_value = $update_value;
293
-        } else {
294
-            $new_label = $update_value;
295
-        }
292
+			$new_value = $update_value;
293
+		} else {
294
+			$new_label = $update_value;
295
+		}
296 296
 
297
-        $field = FrmField::getOne($id);
298
-        $separate_values = FrmField::is_option_true( $field, 'separate_value' );
297
+		$field = FrmField::getOne($id);
298
+		$separate_values = FrmField::is_option_true( $field, 'separate_value' );
299 299
 
300
-        $this_opt_id = end($ids);
300
+		$this_opt_id = end($ids);
301 301
 		$this_opt = (array) $field->options[ $this_opt_id ];
302 302
 		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false );
303 303
 
304
-        $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
305
-        $value = isset($this_opt['value']) ? $this_opt['value'] : '';
304
+		$label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
305
+		$value = isset($this_opt['value']) ? $this_opt['value'] : '';
306 306
 
307
-        if ( ! isset( $new_label ) ) {
308
-            $new_label = $label;
309
-        }
307
+		if ( ! isset( $new_label ) ) {
308
+			$new_label = $label;
309
+		}
310 310
 
311
-        if ( isset($new_value) || isset($value) ) {
312
-            $update_value = isset($new_value) ? $new_value : $value;
313
-        }
311
+		if ( isset($new_value) || isset($value) ) {
312
+			$update_value = isset($new_value) ? $new_value : $value;
313
+		}
314 314
 
315 315
 		if ( $update_value != $new_label && $other_opt === false && $separate_values ) {
316 316
 			$field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label );
317
-        } else {
317
+		} else {
318 318
 			$field->options[ $this_opt_id ] = $orig_update_value;
319
-        }
319
+		}
320 320
 
321 321
 		FrmField::update( $field->id, array( 'options' => $field->options ) );
322 322
 		echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value );
323
-        wp_die();
324
-    }
323
+		wp_die();
324
+	}
325 325
 
326
-    public static function delete_option() {
326
+	public static function delete_option() {
327 327
 		FrmAppHelper::permission_check('frm_edit_forms');
328
-        check_ajax_referer( 'frm_ajax', 'nonce' );
328
+		check_ajax_referer( 'frm_ajax', 'nonce' );
329 329
 
330 330
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
331 331
 		$field = FrmField::getOne( $field_id );
@@ -333,310 +333,310 @@  discard block
 block discarded – undo
333 333
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' );
334 334
 
335 335
 		$options = $field->options;
336
-        unset( $options[ $opt_key ] );
337
-        $response = array( 'other' => true );
336
+		unset( $options[ $opt_key ] );
337
+		$response = array( 'other' => true );
338 338
 
339
-        //If the deleted option is an "other" option
339
+		//If the deleted option is an "other" option
340 340
 		if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
341
-            //Assume all other options are gone, unless proven otherwise
342
-            $other = false;
341
+			//Assume all other options are gone, unless proven otherwise
342
+			$other = false;
343 343
 
344
-            //Check if all other options are really gone
345
-            foreach ( $options as $o_key => $o_val ) {
346
-                //If there is still an other option in the field, set other to true
344
+			//Check if all other options are really gone
345
+			foreach ( $options as $o_key => $o_val ) {
346
+				//If there is still an other option in the field, set other to true
347 347
 				if ( FrmFieldsHelper::is_other_opt( $o_key ) ) {
348
-                    $other = true;
349
-                    break;
350
-                }
351
-                unset( $o_key, $o_val );
352
-            }
353
-
354
-            //If all other options are gone
355
-            if ( false === $other ) {
356
-                $field_options = maybe_unserialize( $field->field_options );
357
-                $field_options['other'] = 0;
348
+					$other = true;
349
+					break;
350
+				}
351
+				unset( $o_key, $o_val );
352
+			}
353
+
354
+			//If all other options are gone
355
+			if ( false === $other ) {
356
+				$field_options = maybe_unserialize( $field->field_options );
357
+				$field_options['other'] = 0;
358 358
 				FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) );
359
-                $response = array( 'other' => false );
360
-            }
361
-        }
362
-        echo json_encode( $response );
359
+				$response = array( 'other' => false );
360
+			}
361
+		}
362
+		echo json_encode( $response );
363 363
 
364 364
 		FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) );
365 365
 
366
-        wp_die();
367
-    }
366
+		wp_die();
367
+	}
368 368
 
369
-    public static function import_choices() {
370
-        FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
369
+	public static function import_choices() {
370
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
371 371
 
372 372
 		$field_id = absint( $_REQUEST['field_id'] );
373 373
 
374
-        global $current_screen, $hook_suffix;
374
+		global $current_screen, $hook_suffix;
375 375
 
376
-        // Catch plugins that include admin-header.php before admin.php completes.
377
-        if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
378
-            $hook_suffix = '';
379
-        	set_current_screen();
380
-        }
376
+		// Catch plugins that include admin-header.php before admin.php completes.
377
+		if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
378
+			$hook_suffix = '';
379
+			set_current_screen();
380
+		}
381 381
 
382
-        if ( function_exists( 'register_admin_color_schemes' ) ) {
383
-            register_admin_color_schemes();
384
-        }
382
+		if ( function_exists( 'register_admin_color_schemes' ) ) {
383
+			register_admin_color_schemes();
384
+		}
385 385
 
386
-        $hook_suffix = $admin_body_class = '';
386
+		$hook_suffix = $admin_body_class = '';
387 387
 
388
-        if ( get_user_setting( 'mfold' ) == 'f' ) {
389
-        	$admin_body_class .= ' folded';
390
-        }
388
+		if ( get_user_setting( 'mfold' ) == 'f' ) {
389
+			$admin_body_class .= ' folded';
390
+		}
391 391
 
392
-        if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
393
-        	$admin_body_class .= ' admin-bar';
394
-        }
392
+		if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
393
+			$admin_body_class .= ' admin-bar';
394
+		}
395 395
 
396
-        if ( is_rtl() ) {
397
-        	$admin_body_class .= ' rtl';
398
-        }
396
+		if ( is_rtl() ) {
397
+			$admin_body_class .= ' rtl';
398
+		}
399 399
 
400
-        $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
401
-        $prepop = array();
402
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
400
+		$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
401
+		$prepop = array();
402
+		FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
403 403
 
404
-        $field = FrmField::getOne($field_id);
404
+		$field = FrmField::getOne($field_id);
405 405
 
406
-        wp_enqueue_script( 'utils' );
406
+		wp_enqueue_script( 'utils' );
407 407
 		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
408
-        FrmAppHelper::load_admin_wide_js();
408
+		FrmAppHelper::load_admin_wide_js();
409 409
 
410 410
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' );
411
-        wp_die();
412
-    }
411
+		wp_die();
412
+	}
413 413
 
414
-    public static function import_options() {
414
+	public static function import_options() {
415 415
 		FrmAppHelper::permission_check('frm_edit_forms');
416
-        check_ajax_referer( 'frm_ajax', 'nonce' );
416
+		check_ajax_referer( 'frm_ajax', 'nonce' );
417 417
 
418
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
419
-            return;
420
-        }
418
+		if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
419
+			return;
420
+		}
421 421
 
422 422
 		$field_id = absint( $_POST['field_id'] );
423
-        $field = FrmField::getOne($field_id);
423
+		$field = FrmField::getOne($field_id);
424 424
 
425 425
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
426
-            return;
427
-        }
428
-
429
-        $field = FrmFieldsHelper::setup_edit_vars($field);
430
-        $opts = stripslashes_deep($_POST['opts']);
431
-        $opts = explode("\n", rtrim($opts, "\n"));
432
-        if ( $field['separate_value'] ) {
433
-            foreach ( $opts as $opt_key => $opt ) {
434
-                if ( strpos($opt, '|') !== false ) {
435
-                    $vals = explode('|', $opt);
436
-                    if ( $vals[0] != $vals[1] ) {
437
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
438
-                    }
439
-                    unset($vals);
440
-                }
441
-                unset($opt_key, $opt);
442
-            }
443
-        }
444
-
445
-        //Keep other options after bulk update
446
-        if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
447
-            $other_array = array();
448
-            foreach ( $field['options'] as $opt_key => $opt ) {
449
-                if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
450
-                    $other_array[ $opt_key ] = $opt;
451
-                }
452
-                unset($opt_key, $opt);
453
-            }
454
-            if ( ! empty($other_array) ) {
455
-                $opts = array_merge( $opts, $other_array);
456
-            }
457
-        }
458
-
459
-        FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
460
-
461
-        $field['options'] = $opts;
462
-        $field_name = $field['name'];
463
-
464
-        // Get html_id which will be used in single-option.php
465
-        $html_id = FrmFieldsHelper::get_html_id( $field );
466
-
467
-        if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
426
+			return;
427
+		}
428
+
429
+		$field = FrmFieldsHelper::setup_edit_vars($field);
430
+		$opts = stripslashes_deep($_POST['opts']);
431
+		$opts = explode("\n", rtrim($opts, "\n"));
432
+		if ( $field['separate_value'] ) {
433
+			foreach ( $opts as $opt_key => $opt ) {
434
+				if ( strpos($opt, '|') !== false ) {
435
+					$vals = explode('|', $opt);
436
+					if ( $vals[0] != $vals[1] ) {
437
+						$opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
438
+					}
439
+					unset($vals);
440
+				}
441
+				unset($opt_key, $opt);
442
+			}
443
+		}
444
+
445
+		//Keep other options after bulk update
446
+		if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
447
+			$other_array = array();
448
+			foreach ( $field['options'] as $opt_key => $opt ) {
449
+				if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
450
+					$other_array[ $opt_key ] = $opt;
451
+				}
452
+				unset($opt_key, $opt);
453
+			}
454
+			if ( ! empty($other_array) ) {
455
+				$opts = array_merge( $opts, $other_array);
456
+			}
457
+		}
458
+
459
+		FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
460
+
461
+		$field['options'] = $opts;
462
+		$field_name = $field['name'];
463
+
464
+		// Get html_id which will be used in single-option.php
465
+		$html_id = FrmFieldsHelper::get_html_id( $field );
466
+
467
+		if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
468 468
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
469
-        } else {
470
-            FrmFieldsHelper::show_single_option($field);
471
-        }
469
+		} else {
470
+			FrmFieldsHelper::show_single_option($field);
471
+		}
472 472
 
473
-        wp_die();
474
-    }
473
+		wp_die();
474
+	}
475 475
 
476
-    public static function update_order() {
476
+	public static function update_order() {
477 477
 		FrmAppHelper::permission_check('frm_edit_forms');
478
-        check_ajax_referer( 'frm_ajax', 'nonce' );
478
+		check_ajax_referer( 'frm_ajax', 'nonce' );
479 479
 
480 480
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
481 481
 		foreach ( (array) $fields as $position => $item ) {
482 482
 			FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) );
483 483
 		}
484
-        wp_die();
485
-    }
484
+		wp_die();
485
+	}
486 486
 
487 487
 	public static function change_type( $type ) {
488
-        $type_switch = array(
489
-            'scale'     => 'radio',
490
-            '10radio'   => 'radio',
491
-            'rte'       => 'textarea',
492
-            'website'   => 'url',
493
-        );
494
-        if ( isset( $type_switch[ $type ] ) ) {
495
-            $type = $type_switch[ $type ];
496
-        }
488
+		$type_switch = array(
489
+			'scale'     => 'radio',
490
+			'10radio'   => 'radio',
491
+			'rte'       => 'textarea',
492
+			'website'   => 'url',
493
+		);
494
+		if ( isset( $type_switch[ $type ] ) ) {
495
+			$type = $type_switch[ $type ];
496
+		}
497 497
 
498 498
 		$frm_field_selection = FrmField::field_selection();
499
-        $types = array_keys($frm_field_selection);
500
-        if ( ! in_array($type, $types) && $type != 'captcha' ) {
501
-            $type = 'text';
502
-        }
499
+		$types = array_keys($frm_field_selection);
500
+		if ( ! in_array($type, $types) && $type != 'captcha' ) {
501
+			$type = 'text';
502
+		}
503 503
 
504
-        return $type;
505
-    }
504
+		return $type;
505
+	}
506 506
 
507 507
 	public static function display_field_options( $display ) {
508 508
 		switch ( $display['type'] ) {
509
-            case 'captcha':
510
-                $display['required'] = false;
511
-                $display['invalid'] = true;
512
-                $display['default_blank'] = false;
509
+			case 'captcha':
510
+				$display['required'] = false;
511
+				$display['invalid'] = true;
512
+				$display['default_blank'] = false;
513 513
 				$display['captcha_size'] = true;
514
-            break;
515
-            case 'radio':
516
-                $display['default_blank'] = false;
517
-            break;
518
-            case 'text':
519
-            case 'textarea':
520
-                $display['size'] = true;
521
-                $display['clear_on_focus'] = true;
522
-            break;
523
-            case 'select':
524
-                $display['size'] = true;
525
-            break;
526
-            case 'url':
527
-            case 'website':
528
-            case 'email':
529
-                $display['size'] = true;
530
-                $display['clear_on_focus'] = true;
531
-                $display['invalid'] = true;
532
-        }
533
-
534
-        return $display;
535
-    }
536
-
537
-    public static function input_html( $field, $echo = true ) {
538
-        $class = array(); //$field['type'];
539
-        self::add_input_classes($field, $class);
540
-
541
-        $add_html = array();
542
-        self::add_html_size($field, $add_html);
543
-        self::add_html_length($field, $add_html);
544
-        self::add_html_placeholder($field, $add_html, $class);
514
+			break;
515
+			case 'radio':
516
+				$display['default_blank'] = false;
517
+			break;
518
+			case 'text':
519
+			case 'textarea':
520
+				$display['size'] = true;
521
+				$display['clear_on_focus'] = true;
522
+			break;
523
+			case 'select':
524
+				$display['size'] = true;
525
+			break;
526
+			case 'url':
527
+			case 'website':
528
+			case 'email':
529
+				$display['size'] = true;
530
+				$display['clear_on_focus'] = true;
531
+				$display['invalid'] = true;
532
+		}
533
+
534
+		return $display;
535
+	}
536
+
537
+	public static function input_html( $field, $echo = true ) {
538
+		$class = array(); //$field['type'];
539
+		self::add_input_classes($field, $class);
540
+
541
+		$add_html = array();
542
+		self::add_html_size($field, $add_html);
543
+		self::add_html_length($field, $add_html);
544
+		self::add_html_placeholder($field, $add_html, $class);
545 545
 		self::add_validation_messages( $field, $add_html );
546 546
 
547
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
547
+		$class = apply_filters('frm_field_classes', implode(' ', $class), $field);
548 548
 
549 549
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
550 550
 
551
-        self::add_shortcodes_to_html($field, $add_html);
551
+		self::add_shortcodes_to_html($field, $add_html);
552 552
 
553 553
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
554 554
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
555 555
 
556
-        if ( $echo ) {
557
-            echo $add_html;
558
-        }
556
+		if ( $echo ) {
557
+			echo $add_html;
558
+		}
559 559
 
560
-        return $add_html;
561
-    }
560
+		return $add_html;
561
+	}
562 562
 
563 563
 	private static function add_input_classes( $field, array &$class ) {
564
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
565
-            $class[] = $field['input_class'];
566
-        }
564
+		if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
565
+			$class[] = $field['input_class'];
566
+		}
567 567
 
568
-        if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
569
-            return;
570
-        }
568
+		if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
569
+			return;
570
+		}
571 571
 
572
-        global $frm_vars;
572
+		global $frm_vars;
573 573
 		if ( is_admin() && ! FrmAppHelper::is_preview_page() && ! in_array( $field['type'], array( 'scale', 'radio', 'checkbox', 'data' ) ) ) {
574
-            $class[] = 'dyn_default_value';
575
-        }
574
+			$class[] = 'dyn_default_value';
575
+		}
576 576
 
577
-        if ( isset($field['size']) && $field['size'] > 0 ) {
578
-            $class[] = 'auto_width';
579
-        }
580
-    }
577
+		if ( isset($field['size']) && $field['size'] > 0 ) {
578
+			$class[] = 'auto_width';
579
+		}
580
+	}
581 581
 
582 582
 	private static function add_html_size( $field, array &$add_html ) {
583 583
 		if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden' ) ) ) {
584
-            return;
585
-        }
584
+			return;
585
+		}
586 586
 
587
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
588
-            return;
589
-        }
587
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
588
+			return;
589
+		}
590 590
 
591
-        if ( is_numeric($field['size']) ) {
592
-            $field['size'] .= 'px';
593
-        }
591
+		if ( is_numeric($field['size']) ) {
592
+			$field['size'] .= 'px';
593
+		}
594 594
 
595
-        $important = apply_filters('frm_use_important_width', 1, $field);
596
-        // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
595
+		$important = apply_filters('frm_use_important_width', 1, $field);
596
+		// Note: This inline styling must stay since we cannot realistically set a class for every possible field size
597 597
 		$add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
598 598
 
599
-        self::add_html_cols($field, $add_html);
600
-    }
599
+		self::add_html_cols($field, $add_html);
600
+	}
601 601
 
602 602
 	private static function add_html_cols( $field, array &$add_html ) {
603 603
 		if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
604
-            return;
605
-        }
604
+			return;
605
+		}
606 606
 
607
-        // convert to cols for textareas
608
-        $calc = array(
609
-            ''      => 9,
610
-            'px'    => 9,
611
-            'rem'   => 0.444,
612
-            'em'    => 0.544,
613
-        );
607
+		// convert to cols for textareas
608
+		$calc = array(
609
+			''      => 9,
610
+			'px'    => 9,
611
+			'rem'   => 0.444,
612
+			'em'    => 0.544,
613
+		);
614 614
 
615
-        // include "col" for valid html
616
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
615
+		// include "col" for valid html
616
+		$unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
617 617
 
618
-        if ( ! isset( $calc[ $unit ] ) ) {
619
-            return;
620
-        }
618
+		if ( ! isset( $calc[ $unit ] ) ) {
619
+			return;
620
+		}
621 621
 
622
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
622
+		$size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
623 623
 
624 624
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
625
-    }
625
+	}
626 626
 
627 627
 	private static function add_html_length( $field, array &$add_html ) {
628
-        // check for max setting and if this field accepts maxlength
628
+		// check for max setting and if this field accepts maxlength
629 629
 		if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden' ) ) ) {
630
-            return;
631
-        }
630
+			return;
631
+		}
632 632
 
633
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
634
-            // don't load on form builder page
635
-            return;
636
-        }
633
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
634
+			// don't load on form builder page
635
+			return;
636
+		}
637 637
 
638 638
 		$add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"';
639
-    }
639
+	}
640 640
 
641 641
 	private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
642 642
 		if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) {
@@ -644,35 +644,35 @@  discard block
 block discarded – undo
644 644
 		}
645 645
 
646 646
 		$default_value_array = is_array( $field['default_value'] );
647
-        if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
647
+		if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
648 648
 			if ( $default_value_array ) {
649 649
 				$field['default_value'] = json_encode( $field['default_value'] );
650 650
 			}
651 651
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"';
652
-            return;
653
-        }
652
+			return;
653
+		}
654 654
 
655 655
 		if ( $default_value_array ) {
656 656
 			// don't include a json placeholder
657 657
 			return;
658 658
 		}
659 659
 
660
-        $frm_settings = FrmAppHelper::get_settings();
660
+		$frm_settings = FrmAppHelper::get_settings();
661 661
 
662 662
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
663
-            // use HMTL5 placeholder with js fallback
663
+			// use HMTL5 placeholder with js fallback
664 664
 			$add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"';
665
-            wp_enqueue_script('jquery-placeholder');
666
-        } else if ( ! $frm_settings->use_html ) {
665
+			wp_enqueue_script('jquery-placeholder');
666
+		} else if ( ! $frm_settings->use_html ) {
667 667
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
668 668
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"';
669
-            $class[] = 'frm_toggle_default';
669
+			$class[] = 'frm_toggle_default';
670 670
 
671
-            if ( $field['value'] == $field['default_value'] ) {
672
-                $class[] = 'frm_default';
673
-            }
674
-        }
675
-    }
671
+			if ( $field['value'] == $field['default_value'] ) {
672
+				$class[] = 'frm_default';
673
+			}
674
+		}
675
+	}
676 676
 
677 677
 	private static function add_validation_messages( $field, array &$add_html ) {
678 678
 		if ( FrmField::is_required( $field ) ) {
@@ -693,44 +693,44 @@  discard block
 block discarded – undo
693 693
 		}
694 694
 	}
695 695
 
696
-    private static function add_shortcodes_to_html( $field, array &$add_html ) {
697
-        if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
698
-            return;
699
-        }
696
+	private static function add_shortcodes_to_html( $field, array &$add_html ) {
697
+		if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
698
+			return;
699
+		}
700 700
 
701
-        foreach ( $field['shortcodes'] as $k => $v ) {
702
-            if ( 'opt' === $k ) {
703
-                continue;
704
-            }
701
+		foreach ( $field['shortcodes'] as $k => $v ) {
702
+			if ( 'opt' === $k ) {
703
+				continue;
704
+			}
705 705
 
706
-            if ( is_numeric($k) && strpos($v, '=') ) {
707
-                $add_html[] = $v;
708
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
706
+			if ( is_numeric($k) && strpos($v, '=') ) {
707
+				$add_html[] = $v;
708
+			} else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
709 709
 				$add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
710
-            } else {
710
+			} else {
711 711
 				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
712
-            }
713
-
714
-            unset($k, $v);
715
-        }
716
-    }
717
-
718
-    public static function check_value( $opt, $opt_key, $field ) {
719
-        if ( is_array( $opt ) ) {
720
-            if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
721
-                $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
722
-            } else {
723
-                $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
724
-            }
725
-        }
726
-        return $opt;
727
-    }
712
+			}
713
+
714
+			unset($k, $v);
715
+		}
716
+	}
717
+
718
+	public static function check_value( $opt, $opt_key, $field ) {
719
+		if ( is_array( $opt ) ) {
720
+			if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
721
+				$opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
722
+			} else {
723
+				$opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
724
+			}
725
+		}
726
+		return $opt;
727
+	}
728 728
 
729 729
 	public static function check_label( $opt ) {
730
-        if ( is_array($opt) ) {
731
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
732
-        }
730
+		if ( is_array($opt) ) {
731
+			$opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
732
+		}
733 733
 
734
-        return $opt;
735
-    }
734
+		return $opt;
735
+	}
736 736
 }
Please login to merge, or discard this patch.
Spacing   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 class FrmFieldsController {
4 4
 
5 5
     public static function load_field() {
6
-		FrmAppHelper::permission_check('frm_edit_forms');
6
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
7 7
         check_ajax_referer( 'frm_ajax', 'nonce' );
8 8
 
9 9
         $fields = $_POST['field'];
@@ -33,33 +33,33 @@  discard block
 block discarded – undo
33 33
                 $field['value'] = '';
34 34
             }
35 35
 
36
-			$field_name = 'item_meta['. $field_id .']';
37
-            $html_id = FrmFieldsHelper::get_html_id($field);
36
+			$field_name = 'item_meta[' . $field_id . ']';
37
+            $html_id = FrmFieldsHelper::get_html_id( $field );
38 38
 
39 39
             ob_start();
40 40
 			include( $path . '/classes/views/frm-forms/add_field.php' );
41
-            $field_html[ $field_id ] = ob_get_contents();
41
+            $field_html[$field_id] = ob_get_contents();
42 42
             ob_end_clean();
43 43
         }
44 44
 
45
-        unset($path);
45
+        unset( $path );
46 46
 
47
-        echo json_encode($field_html);
47
+        echo json_encode( $field_html );
48 48
 
49 49
         wp_die();
50 50
     }
51 51
 
52 52
     public static function create() {
53
-		FrmAppHelper::permission_check('frm_edit_forms');
53
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
54 54
         check_ajax_referer( 'frm_ajax', 'nonce' );
55 55
 
56 56
 		$field_type = FrmAppHelper::get_post_param( 'field', '', 'sanitize_text_field' );
57 57
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
58 58
 
59
-        $field = self::include_new_field($field_type, $form_id);
59
+        $field = self::include_new_field( $field_type, $form_id );
60 60
 
61 61
         // this hook will allow for multiple fields to be added at once
62
-        do_action('frm_after_field_created', $field, $form_id);
62
+        do_action( 'frm_after_field_created', $field, $form_id );
63 63
 
64 64
         wp_die();
65 65
     }
@@ -70,23 +70,23 @@  discard block
 block discarded – undo
70 70
 	public static function include_new_field( $field_type, $form_id ) {
71 71
         $values = array();
72 72
         if ( FrmAppHelper::pro_is_installed() ) {
73
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
73
+            $values['post_type'] = FrmProFormsHelper::post_type( $form_id );
74 74
         }
75 75
 
76
-        $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id));
76
+        $field_values = apply_filters( 'frm_before_field_created', FrmFieldsHelper::setup_new_vars( $field_type, $form_id ) );
77 77
         $field_id = FrmField::create( $field_values );
78 78
 
79 79
         if ( ! $field_id ) {
80 80
             return false;
81 81
         }
82 82
 
83
-        $field = self::include_single_field($field_id, $values, $form_id);
83
+        $field = self::include_single_field( $field_id, $values, $form_id );
84 84
 
85 85
         return $field;
86 86
     }
87 87
 
88 88
     public static function update_form_id() {
89
-		FrmAppHelper::permission_check('frm_edit_forms');
89
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
90 90
         check_ajax_referer( 'frm_ajax', 'nonce' );
91 91
 
92 92
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
@@ -103,21 +103,21 @@  discard block
 block discarded – undo
103 103
     }
104 104
 
105 105
 	public static function edit_name( $field = 'name', $id = '' ) {
106
-		FrmAppHelper::permission_check('frm_edit_forms');
106
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
107 107
         check_ajax_referer( 'frm_ajax', 'nonce' );
108 108
 
109
-        if ( empty($field) ) {
109
+        if ( empty( $field ) ) {
110 110
             $field = 'name';
111 111
         }
112 112
 
113
-        if ( empty($id) ) {
113
+        if ( empty( $id ) ) {
114 114
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
115 115
 			$id = str_replace( 'field_label_', '', $id );
116 116
         }
117 117
 
118 118
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
119 119
 		$value = trim( $value );
120
-        if ( trim(strip_tags($value)) == '' ) {
120
+        if ( trim( strip_tags( $value ) ) == '' ) {
121 121
             // set blank value if there is no content
122 122
             $value = '';
123 123
         }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     }
132 132
 
133 133
     public static function update_ajax_option() {
134
-		FrmAppHelper::permission_check('frm_edit_forms');
134
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
135 135
         check_ajax_referer( 'frm_ajax', 'nonce' );
136 136
 
137 137
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		if ( isset( $_POST['separate_value'] ) ) {
145 145
 			$new_val = FrmField::is_option_true( $field, 'separate_value' ) ? 0 : 1;
146 146
 			$field->field_options['separate_value'] = $new_val;
147
-			unset($new_val);
147
+			unset( $new_val );
148 148
 		}
149 149
 
150 150
         FrmField::update( $field_id, array(
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
     }
156 156
 
157 157
     public static function duplicate() {
158
-		FrmAppHelper::permission_check('frm_edit_forms');
158
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
159 159
         check_ajax_referer( 'frm_ajax', 'nonce' );
160 160
 
161 161
         global $wpdb;
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
 
179 179
         $values['field_order'] = $field_count + 1;
180 180
 
181
-        if ( ! $field_id = FrmField::create($values) ) {
181
+        if ( ! $field_id = FrmField::create( $values ) ) {
182 182
             wp_die();
183 183
         }
184 184
 
185
-        self::include_single_field($field_id, $values);
185
+        self::include_single_field( $field_id, $values );
186 186
 
187 187
         wp_die();
188 188
     }
@@ -191,9 +191,9 @@  discard block
 block discarded – undo
191 191
      * Load a single field in the form builder along with all needed variables
192 192
      */
193 193
     public static function include_single_field( $field_id, $values, $form_id = 0 ) {
194
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
194
+        $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) );
195 195
 		$field_name = 'item_meta[' . $field_id . ']';
196
-        $html_id = FrmFieldsHelper::get_html_id($field);
196
+        $html_id = FrmFieldsHelper::get_html_id( $field );
197 197
         $id = $form_id ? $form_id : $field['form_id'];
198 198
         if ( $field['type'] == 'html' ) {
199 199
             $field['stop_filter'] = true;
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
     }
206 206
 
207 207
     public static function destroy() {
208
-		FrmAppHelper::permission_check('frm_edit_forms');
208
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
209 209
         check_ajax_referer( 'frm_ajax', 'nonce' );
210 210
 
211 211
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
 
218 218
     //Add Single Option or Other Option
219 219
     public static function add_option() {
220
-		FrmAppHelper::permission_check('frm_edit_forms');
220
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
221 221
         check_ajax_referer( 'frm_ajax', 'nonce' );
222 222
 
223 223
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
224 224
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
225 225
 
226 226
         //Get the field
227
-        $field = FrmField::getOne($id);
227
+        $field = FrmField::getOne( $id );
228 228
 
229 229
 		if ( ! empty( $field->options ) ) {
230 230
 			$keys = array_keys( $field->options );
@@ -247,13 +247,13 @@  discard block
 block discarded – undo
247 247
 			$first_opt = reset( $field->options );
248 248
 			$next_opt = count( $field->options );
249 249
             if ( $first_opt != '' ) {
250
-                $next_opt++;
250
+                $next_opt ++;
251 251
             }
252 252
 			$opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt;
253
-            unset($next_opt);
253
+            unset( $next_opt );
254 254
         }
255 255
         $field_val = $opt;
256
-		$field->options[ $opt_key ] = $opt;
256
+		$field->options[$opt_key] = $opt;
257 257
 
258 258
         //Update options in DB
259 259
 		FrmField::update( $id, array( 'options' => $field->options ) );
@@ -262,13 +262,13 @@  discard block
 block discarded – undo
262 262
         $field = array(
263 263
             'type'  => $field_data->type,
264 264
             'id'    => $id,
265
-            'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
265
+            'separate_value' => isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0,
266 266
             'form_id' => $field_data->form_id,
267 267
             'field_key' => $field_data->field_key,
268 268
         );
269 269
 
270 270
 		$field_name = 'item_meta[' . $id . ']';
271
-        $html_id = FrmFieldsHelper::get_html_id($field);
271
+        $html_id = FrmFieldsHelper::get_html_id( $field );
272 272
         $checked = '';
273 273
 
274 274
         if ( 'other' == $opt_type ) {
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
     }
281 281
 
282 282
     public static function edit_option() {
283
-		FrmAppHelper::permission_check('frm_edit_forms');
283
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
284 284
         check_ajax_referer( 'frm_ajax', 'nonce' );
285 285
 
286 286
 		$element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
@@ -294,28 +294,28 @@  discard block
 block discarded – undo
294 294
             $new_label = $update_value;
295 295
         }
296 296
 
297
-        $field = FrmField::getOne($id);
297
+        $field = FrmField::getOne( $id );
298 298
         $separate_values = FrmField::is_option_true( $field, 'separate_value' );
299 299
 
300
-        $this_opt_id = end($ids);
301
-		$this_opt = (array) $field->options[ $this_opt_id ];
302
-		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false );
300
+        $this_opt_id = end( $ids );
301
+		$this_opt = (array) $field->options[$this_opt_id];
302
+		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other' ) !== false );
303 303
 
304
-        $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
305
-        $value = isset($this_opt['value']) ? $this_opt['value'] : '';
304
+        $label = isset( $this_opt['label'] ) ? $this_opt['label'] : reset( $this_opt );
305
+        $value = isset( $this_opt['value'] ) ? $this_opt['value'] : '';
306 306
 
307 307
         if ( ! isset( $new_label ) ) {
308 308
             $new_label = $label;
309 309
         }
310 310
 
311
-        if ( isset($new_value) || isset($value) ) {
312
-            $update_value = isset($new_value) ? $new_value : $value;
311
+        if ( isset( $new_value ) || isset( $value ) ) {
312
+            $update_value = isset( $new_value ) ? $new_value : $value;
313 313
         }
314 314
 
315 315
 		if ( $update_value != $new_label && $other_opt === false && $separate_values ) {
316
-			$field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label );
316
+			$field->options[$this_opt_id] = array( 'value' => $update_value, 'label' => $new_label );
317 317
         } else {
318
-			$field->options[ $this_opt_id ] = $orig_update_value;
318
+			$field->options[$this_opt_id] = $orig_update_value;
319 319
         }
320 320
 
321 321
 		FrmField::update( $field->id, array( 'options' => $field->options ) );
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
     }
325 325
 
326 326
     public static function delete_option() {
327
-		FrmAppHelper::permission_check('frm_edit_forms');
327
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
328 328
         check_ajax_referer( 'frm_ajax', 'nonce' );
329 329
 
330 330
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' );
334 334
 
335 335
 		$options = $field->options;
336
-        unset( $options[ $opt_key ] );
336
+        unset( $options[$opt_key] );
337 337
         $response = array( 'other' => true );
338 338
 
339 339
         //If the deleted option is an "other" option
@@ -399,9 +399,9 @@  discard block
 block discarded – undo
399 399
 
400 400
         $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
401 401
         $prepop = array();
402
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
402
+        FrmFieldsHelper::get_bulk_prefilled_opts( $prepop );
403 403
 
404
-        $field = FrmField::getOne($field_id);
404
+        $field = FrmField::getOne( $field_id );
405 405
 
406 406
         wp_enqueue_script( 'utils' );
407 407
 		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
@@ -412,33 +412,33 @@  discard block
 block discarded – undo
412 412
     }
413 413
 
414 414
     public static function import_options() {
415
-		FrmAppHelper::permission_check('frm_edit_forms');
415
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
416 416
         check_ajax_referer( 'frm_ajax', 'nonce' );
417 417
 
418
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
418
+        if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
419 419
             return;
420 420
         }
421 421
 
422 422
 		$field_id = absint( $_POST['field_id'] );
423
-        $field = FrmField::getOne($field_id);
423
+        $field = FrmField::getOne( $field_id );
424 424
 
425 425
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
426 426
             return;
427 427
         }
428 428
 
429
-        $field = FrmFieldsHelper::setup_edit_vars($field);
430
-        $opts = stripslashes_deep($_POST['opts']);
431
-        $opts = explode("\n", rtrim($opts, "\n"));
429
+        $field = FrmFieldsHelper::setup_edit_vars( $field );
430
+        $opts = stripslashes_deep( $_POST['opts'] );
431
+        $opts = explode( "\n", rtrim( $opts, "\n" ) );
432 432
         if ( $field['separate_value'] ) {
433 433
             foreach ( $opts as $opt_key => $opt ) {
434
-                if ( strpos($opt, '|') !== false ) {
435
-                    $vals = explode('|', $opt);
434
+                if ( strpos( $opt, '|' ) !== false ) {
435
+                    $vals = explode( '|', $opt );
436 436
                     if ( $vals[0] != $vals[1] ) {
437
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
437
+                        $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
438 438
                     }
439
-                    unset($vals);
439
+                    unset( $vals );
440 440
                 }
441
-                unset($opt_key, $opt);
441
+                unset( $opt_key, $opt );
442 442
             }
443 443
         }
444 444
 
@@ -447,12 +447,12 @@  discard block
 block discarded – undo
447 447
             $other_array = array();
448 448
             foreach ( $field['options'] as $opt_key => $opt ) {
449 449
                 if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
450
-                    $other_array[ $opt_key ] = $opt;
450
+                    $other_array[$opt_key] = $opt;
451 451
                 }
452
-                unset($opt_key, $opt);
452
+                unset( $opt_key, $opt );
453 453
             }
454
-            if ( ! empty($other_array) ) {
455
-                $opts = array_merge( $opts, $other_array);
454
+            if ( ! empty( $other_array ) ) {
455
+                $opts = array_merge( $opts, $other_array );
456 456
             }
457 457
         }
458 458
 
@@ -467,14 +467,14 @@  discard block
 block discarded – undo
467 467
         if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
468 468
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
469 469
         } else {
470
-            FrmFieldsHelper::show_single_option($field);
470
+            FrmFieldsHelper::show_single_option( $field );
471 471
         }
472 472
 
473 473
         wp_die();
474 474
     }
475 475
 
476 476
     public static function update_order() {
477
-		FrmAppHelper::permission_check('frm_edit_forms');
477
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
478 478
         check_ajax_referer( 'frm_ajax', 'nonce' );
479 479
 
480 480
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
@@ -491,13 +491,13 @@  discard block
 block discarded – undo
491 491
             'rte'       => 'textarea',
492 492
             'website'   => 'url',
493 493
         );
494
-        if ( isset( $type_switch[ $type ] ) ) {
495
-            $type = $type_switch[ $type ];
494
+        if ( isset( $type_switch[$type] ) ) {
495
+            $type = $type_switch[$type];
496 496
         }
497 497
 
498 498
 		$frm_field_selection = FrmField::field_selection();
499
-        $types = array_keys($frm_field_selection);
500
-        if ( ! in_array($type, $types) && $type != 'captcha' ) {
499
+        $types = array_keys( $frm_field_selection );
500
+        if ( ! in_array( $type, $types ) && $type != 'captcha' ) {
501 501
             $type = 'text';
502 502
         }
503 503
 
@@ -536,19 +536,19 @@  discard block
 block discarded – undo
536 536
 
537 537
     public static function input_html( $field, $echo = true ) {
538 538
         $class = array(); //$field['type'];
539
-        self::add_input_classes($field, $class);
539
+        self::add_input_classes( $field, $class );
540 540
 
541 541
         $add_html = array();
542
-        self::add_html_size($field, $add_html);
543
-        self::add_html_length($field, $add_html);
544
-        self::add_html_placeholder($field, $add_html, $class);
542
+        self::add_html_size( $field, $add_html );
543
+        self::add_html_length( $field, $add_html );
544
+        self::add_html_placeholder( $field, $add_html, $class );
545 545
 		self::add_validation_messages( $field, $add_html );
546 546
 
547
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
547
+        $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field );
548 548
 
549 549
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
550 550
 
551
-        self::add_shortcodes_to_html($field, $add_html);
551
+        self::add_shortcodes_to_html( $field, $add_html );
552 552
 
553 553
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
554 554
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
     }
562 562
 
563 563
 	private static function add_input_classes( $field, array &$class ) {
564
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
564
+        if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) {
565 565
             $class[] = $field['input_class'];
566 566
         }
567 567
 
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
             $class[] = 'dyn_default_value';
575 575
         }
576 576
 
577
-        if ( isset($field['size']) && $field['size'] > 0 ) {
577
+        if ( isset( $field['size'] ) && $field['size'] > 0 ) {
578 578
             $class[] = 'auto_width';
579 579
         }
580 580
     }
@@ -584,19 +584,19 @@  discard block
 block discarded – undo
584 584
             return;
585 585
         }
586 586
 
587
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
587
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
588 588
             return;
589 589
         }
590 590
 
591
-        if ( is_numeric($field['size']) ) {
591
+        if ( is_numeric( $field['size'] ) ) {
592 592
             $field['size'] .= 'px';
593 593
         }
594 594
 
595
-        $important = apply_filters('frm_use_important_width', 1, $field);
595
+        $important = apply_filters( 'frm_use_important_width', 1, $field );
596 596
         // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
597 597
 		$add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
598 598
 
599
-        self::add_html_cols($field, $add_html);
599
+        self::add_html_cols( $field, $add_html );
600 600
     }
601 601
 
602 602
 	private static function add_html_cols( $field, array &$add_html ) {
@@ -613,13 +613,13 @@  discard block
 block discarded – undo
613 613
         );
614 614
 
615 615
         // include "col" for valid html
616
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
616
+        $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) );
617 617
 
618
-        if ( ! isset( $calc[ $unit ] ) ) {
618
+        if ( ! isset( $calc[$unit] ) ) {
619 619
             return;
620 620
         }
621 621
 
622
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
622
+        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit];
623 623
 
624 624
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
625 625
     }
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
             return;
631 631
         }
632 632
 
633
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
633
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
634 634
             // don't load on form builder page
635 635
             return;
636 636
         }
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
663 663
             // use HMTL5 placeholder with js fallback
664 664
 			$add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"';
665
-            wp_enqueue_script('jquery-placeholder');
665
+            wp_enqueue_script( 'jquery-placeholder' );
666 666
         } else if ( ! $frm_settings->use_html ) {
667 667
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
668 668
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"';
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 			$format = FrmEntryValidate::phone_format( $field );
690 690
 			$format = substr( $format, 2, -2 );
691 691
 			$key = 'pattern';
692
-			$add_html[ $key ] = $key . '="' . esc_attr( $format ) . '"';
692
+			$add_html[$key] = $key . '="' . esc_attr( $format ) . '"';
693 693
 		}
694 694
 	}
695 695
 
@@ -703,15 +703,15 @@  discard block
 block discarded – undo
703 703
                 continue;
704 704
             }
705 705
 
706
-            if ( is_numeric($k) && strpos($v, '=') ) {
706
+            if ( is_numeric( $k ) && strpos( $v, '=' ) ) {
707 707
                 $add_html[] = $v;
708
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
709
-				$add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
708
+            } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) {
709
+				$add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] );
710 710
             } else {
711
-				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
711
+				$add_html[$k] = $k . '="' . esc_attr( $v ) . '"';
712 712
             }
713 713
 
714
-            unset($k, $v);
714
+            unset( $k, $v );
715 715
         }
716 716
     }
717 717
 
@@ -727,8 +727,8 @@  discard block
 block discarded – undo
727 727
     }
728 728
 
729 729
 	public static function check_label( $opt ) {
730
-        if ( is_array($opt) ) {
731
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
730
+        if ( is_array( $opt ) ) {
731
+            $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
732 732
         }
733 733
 
734 734
         return $opt;
Please login to merge, or discard this patch.
classes/controllers/FrmAddonsController.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
 		$keyed_addons = array();
41 41
 		foreach ( $addons as $addon ) {
42
-			$keyed_addons[ $addon['info']['slug'] ] = $addon;
42
+			$keyed_addons[$addon['info']['slug']] = $addon;
43 43
 		}
44 44
 
45 45
 		$plugin_order = array(
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 		);
50 50
 		$ordered_addons = array();
51 51
 		foreach ( $plugin_order as $plugin ) {
52
-			if ( isset( $keyed_addons[ $plugin ] ) ) {
53
-				$ordered_addons[] = $keyed_addons[ $plugin ];
54
-				unset( $keyed_addons[ $plugin ] );
52
+			if ( isset( $keyed_addons[$plugin] ) ) {
53
+				$ordered_addons[] = $keyed_addons[$plugin];
54
+				unset( $keyed_addons[$plugin] );
55 55
 			}
56 56
 		}
57 57
 		$addons = $ordered_addons + $keyed_addons;
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
 	}
87 87
 
88 88
 	public static function get_licenses() {
89
-		FrmAppHelper::permission_check('frm_change_settings');
89
+		FrmAppHelper::permission_check( 'frm_change_settings' );
90 90
 		check_ajax_referer( 'frm_ajax', 'nonce' );
91 91
 
92
-		$license = get_option('frmpro-credentials');
92
+		$license = get_option( 'frmpro-credentials' );
93 93
 		if ( $license && is_array( $license ) && isset( $license['license'] ) ) {
94 94
 			$url = 'http://formidablepro.com/frm-edd-api/licenses?l=' . urlencode( base64_encode( $license['license'] ) );
95 95
 			$licenses = self::send_api_request( $url, array( 'name' => 'frm_api_licence', 'expires' => 60 * 60 * 5 ) );
Please login to merge, or discard this patch.
classes/controllers/FrmXMLController.php 2 patches
Indentation   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -2,110 +2,110 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmXMLController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		add_submenu_page( 'formidable', 'Formidable | ' . __( 'Import/Export', 'formidable' ), __( 'Import/Export', 'formidable' ), 'frm_edit_forms', 'formidable-import', 'FrmXMLController::route' );
7
-    }
7
+	}
8 8
 
9
-    public static function add_default_templates() {
9
+	public static function add_default_templates() {
10 10
 		if ( ! function_exists( 'libxml_disable_entity_loader' ) ) {
11
-    		// XML import is not enabled on your server
12
-    		return;
13
-    	}
11
+			// XML import is not enabled on your server
12
+			return;
13
+		}
14 14
 
15
-        $set_err = libxml_use_internal_errors(true);
16
-        $loader = libxml_disable_entity_loader( true );
15
+		$set_err = libxml_use_internal_errors(true);
16
+		$loader = libxml_disable_entity_loader( true );
17 17
 
18 18
 		$files = apply_filters( 'frm_default_templates_files', array( FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml' ) );
19 19
 
20
-        foreach ( (array) $files as $file ) {
21
-            FrmXMLHelper::import_xml($file);
22
-            unset($file);
23
-        }
24
-        /*
20
+		foreach ( (array) $files as $file ) {
21
+			FrmXMLHelper::import_xml($file);
22
+			unset($file);
23
+		}
24
+		/*
25 25
         if(is_wp_error($result))
26 26
             $errors[] = $result->get_error_message();
27 27
         else if($result)
28 28
             $message = $result;
29 29
         */
30 30
 
31
-        unset( $files );
31
+		unset( $files );
32 32
 
33
-        libxml_use_internal_errors( $set_err );
34
-    	libxml_disable_entity_loader( $loader );
35
-    }
33
+		libxml_use_internal_errors( $set_err );
34
+		libxml_disable_entity_loader( $loader );
35
+	}
36 36
 
37
-    public static function route() {
38
-        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
37
+	public static function route() {
38
+		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
39 39
 		$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
40 40
 		if ( $action == 'import_xml' ) {
41
-            return self::import_xml();
41
+			return self::import_xml();
42 42
 		} else if ( $action == 'export_xml' ) {
43
-            return self::export_xml();
44
-        } else {
45
-            if ( apply_filters( 'frm_xml_route', true, $action ) ) {
46
-                return self::form();
47
-            }
48
-        }
49
-    }
50
-
51
-    public static function form( $errors = array(), $message = '' ) {
43
+			return self::export_xml();
44
+		} else {
45
+			if ( apply_filters( 'frm_xml_route', true, $action ) ) {
46
+				return self::form();
47
+			}
48
+		}
49
+	}
50
+
51
+	public static function form( $errors = array(), $message = '' ) {
52 52
 		$where = array(
53 53
 			'parent_form_id' => array( null, 0 ),
54 54
 			'status' => array( null, '', 'published' ),
55 55
 		);
56 56
 		$forms = FrmForm::getAll( $where, 'name' );
57 57
 
58
-        $export_types = apply_filters( 'frm_xml_export_types',
59
-            array( 'forms' => __( 'Forms', 'formidable' ), 'items' => __( 'Entries', 'formidable' ) )
60
-        );
58
+		$export_types = apply_filters( 'frm_xml_export_types',
59
+			array( 'forms' => __( 'Forms', 'formidable' ), 'items' => __( 'Entries', 'formidable' ) )
60
+		);
61 61
 
62
-        $export_format = apply_filters( 'frm_export_formats', array(
63
-            'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ),
62
+		$export_format = apply_filters( 'frm_export_formats', array(
63
+			'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ),
64 64
 			'csv' => array( 'name' => 'CSV', 'support' => 'items', 'count' => 'single' ),
65
-        ) );
65
+		) );
66 66
 
67 67
 		include( FrmAppHelper::plugin_path() . '/classes/views/xml/import_form.php' );
68
-    }
68
+	}
69 69
 
70
-    public static function import_xml() {
71
-        $errors = array();
72
-        $message = '';
70
+	public static function import_xml() {
71
+		$errors = array();
72
+		$message = '';
73 73
 
74
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce');
75
-        if ( $permission_error !== false ) {
76
-            $errors[] = $permission_error;
77
-            self::form($errors);
78
-            return;
79
-        }
74
+		$permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce');
75
+		if ( $permission_error !== false ) {
76
+			$errors[] = $permission_error;
77
+			self::form($errors);
78
+			return;
79
+		}
80 80
 
81
-        if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
82
-            $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' );
83
-            self::form($errors);
84
-            return;
85
-        }
81
+		if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
82
+			$errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' );
83
+			self::form($errors);
84
+			return;
85
+		}
86 86
 
87
-        $file = $_FILES['frm_import_file']['tmp_name'];
87
+		$file = $_FILES['frm_import_file']['tmp_name'];
88 88
 
89
-        if ( ! is_uploaded_file( $file ) ) {
90
-            unset($file);
91
-            $errors[] = __( 'The file does not exist, please try again.', 'formidable' );
92
-            self::form($errors);
93
-            return;
94
-        }
89
+		if ( ! is_uploaded_file( $file ) ) {
90
+			unset($file);
91
+			$errors[] = __( 'The file does not exist, please try again.', 'formidable' );
92
+			self::form($errors);
93
+			return;
94
+		}
95 95
 
96
-        //add_filter('upload_mimes', 'FrmXMLController::allow_mime');
96
+		//add_filter('upload_mimes', 'FrmXMLController::allow_mime');
97 97
 
98
-        $export_format = apply_filters('frm_export_formats', array(
98
+		$export_format = apply_filters('frm_export_formats', array(
99 99
 			'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ),
100 100
 		) );
101 101
 
102
-        $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION));
103
-        if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) {
104
-            // allow other file types to be imported
102
+		$file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION));
103
+		if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) {
104
+			// allow other file types to be imported
105 105
 			do_action( 'frm_before_import_' . $file_type );
106
-            return;
107
-        }
108
-        unset($file_type);
106
+			return;
107
+		}
108
+		unset($file_type);
109 109
 
110 110
 		if ( ! function_exists( 'libxml_disable_entity_loader' ) ) {
111 111
 			$errors[] = __( 'XML import is not enabled on your server.', 'formidable' );
@@ -124,148 +124,148 @@  discard block
 block discarded – undo
124 124
 		libxml_use_internal_errors( $set_err );
125 125
 		libxml_disable_entity_loader( $loader );
126 126
 
127
-        self::form($errors, $message);
128
-    }
127
+		self::form($errors, $message);
128
+	}
129 129
 
130
-    public static function export_xml() {
131
-        $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' );
132
-        if ( ! empty($error) ) {
133
-            wp_die( $error );
134
-        }
130
+	public static function export_xml() {
131
+		$error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' );
132
+		if ( ! empty($error) ) {
133
+			wp_die( $error );
134
+		}
135 135
 
136 136
 		$ids = FrmAppHelper::get_post_param( 'frm_export_forms', array() );
137 137
 		$type = FrmAppHelper::get_post_param( 'type', array() );
138 138
 		$format = FrmAppHelper::get_post_param( 'format', 'xml', 'sanitize_title' );
139 139
 
140
-        if ( ! headers_sent() && ! $type ) {
141
-            wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) );
142
-            die();
143
-        }
140
+		if ( ! headers_sent() && ! $type ) {
141
+			wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) );
142
+			die();
143
+		}
144 144
 
145
-        if ( $format == 'xml' ) {
146
-            self::generate_xml($type, compact('ids'));
145
+		if ( $format == 'xml' ) {
146
+			self::generate_xml($type, compact('ids'));
147 147
 		} if ( $format == 'csv' ) {
148 148
 			self::generate_csv( compact('ids') );
149
-        } else {
149
+		} else {
150 150
 			do_action( 'frm_export_format_' . $format, compact('ids') );
151
-        }
151
+		}
152 152
 
153
-        wp_die();
154
-    }
153
+		wp_die();
154
+	}
155 155
 
156 156
 	public static function generate_xml( $type, $args = array() ) {
157
-    	global $wpdb;
157
+		global $wpdb;
158 158
 
159
-	    $type = (array) $type;
160
-        if ( in_array( 'items', $type) && ! in_array( 'forms', $type) ) {
161
-            // make sure the form is included if there are entries
162
-            $type[] = 'forms';
163
-        }
159
+		$type = (array) $type;
160
+		if ( in_array( 'items', $type) && ! in_array( 'forms', $type) ) {
161
+			// make sure the form is included if there are entries
162
+			$type[] = 'forms';
163
+		}
164 164
 
165
-	    if ( in_array( 'forms', $type) ) {
166
-            // include actions with forms
167
-	        $type[] = 'actions';
168
-	    }
165
+		if ( in_array( 'forms', $type) ) {
166
+			// include actions with forms
167
+			$type[] = 'actions';
168
+		}
169 169
 
170
-	    $tables = array(
170
+		$tables = array(
171 171
 			'items'     => $wpdb->prefix . 'frm_items',
172 172
 			'forms'     => $wpdb->prefix . 'frm_forms',
173
-	        'posts'     => $wpdb->posts,
174
-	        'styles'    => $wpdb->posts,
175
-	        'actions'   => $wpdb->posts,
176
-	    );
173
+			'posts'     => $wpdb->posts,
174
+			'styles'    => $wpdb->posts,
175
+			'actions'   => $wpdb->posts,
176
+		);
177 177
 
178 178
 		$defaults = array( 'ids' => false );
179
-	    $args = wp_parse_args( $args, $defaults );
179
+		$args = wp_parse_args( $args, $defaults );
180 180
 
181
-        $sitename = sanitize_key( get_bloginfo( 'name' ) );
181
+		$sitename = sanitize_key( get_bloginfo( 'name' ) );
182 182
 
183
-    	if ( ! empty( $sitename ) ) {
183
+		if ( ! empty( $sitename ) ) {
184 184
 			$sitename .= '.';
185 185
 		}
186
-    	$filename = $sitename . 'formidable.' . date( 'Y-m-d' ) . '.xml';
186
+		$filename = $sitename . 'formidable.' . date( 'Y-m-d' ) . '.xml';
187 187
 
188
-    	header( 'Content-Description: File Transfer' );
189
-    	header( 'Content-Disposition: attachment; filename=' . $filename );
190
-    	header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
188
+		header( 'Content-Description: File Transfer' );
189
+		header( 'Content-Disposition: attachment; filename=' . $filename );
190
+		header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
191 191
 
192
-        //make sure ids are numeric
193
-    	if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) {
194
-	        $args['ids'] = array_filter( $args['ids'], 'is_numeric' );
195
-	    }
192
+		//make sure ids are numeric
193
+		if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) {
194
+			$args['ids'] = array_filter( $args['ids'], 'is_numeric' );
195
+		}
196 196
 
197
-	    $records = array();
197
+		$records = array();
198 198
 
199 199
 		foreach ( $type as $tb_type ) {
200
-            $where = array();
200
+			$where = array();
201 201
 			$join = '';
202
-            $table = $tables[ $tb_type ];
202
+			$table = $tables[ $tb_type ];
203 203
 
204 204
 			$select = $table . '.id';
205
-            $query_vars = array();
205
+			$query_vars = array();
206 206
 
207
-            switch ( $tb_type ) {
208
-                case 'forms':
209
-                    //add forms
210
-                    if ( $args['ids'] ) {
207
+			switch ( $tb_type ) {
208
+				case 'forms':
209
+					//add forms
210
+					if ( $args['ids'] ) {
211 211
 						$where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table . '.parent_form_id' => $args['ids'] );
212
-                	} else {
212
+					} else {
213 213
 						$where[ $table . '.status !' ] = 'draft';
214
-                	}
215
-                break;
216
-                case 'actions':
214
+					}
215
+				break;
216
+				case 'actions':
217 217
 					$select = $table . '.ID';
218 218
 					$where['post_type'] = FrmFormActionsController::$action_post_type;
219
-                    if ( ! empty($args['ids']) ) {
219
+					if ( ! empty($args['ids']) ) {
220 220
 						$where['menu_order'] = $args['ids'];
221
-                    }
222
-                break;
223
-                case 'items':
224
-                    //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)";
225
-                    if ( $args['ids'] ) {
221
+					}
222
+				break;
223
+				case 'items':
224
+					//$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)";
225
+					if ( $args['ids'] ) {
226 226
 						$where[ $table . '.form_id' ] = $args['ids'];
227
-                    }
228
-                break;
229
-                case 'styles':
230
-                    // Loop through all exported forms and get their selected style IDs
231
-                    $form_ids = $args['ids'];
232
-                    $style_ids = array();
233
-                    foreach ( $form_ids as $form_id ) {
234
-                        $form_data = FrmForm::getOne( $form_id );
235
-                        // For forms that have not been updated while running 2.0, check if custom_style is set
236
-                        if ( isset( $form_data->options['custom_style'] ) ) {
237
-                            $style_ids[] = $form_data->options['custom_style'];
238
-                        }
239
-                        unset( $form_id, $form_data );
240
-                    }
227
+					}
228
+				break;
229
+				case 'styles':
230
+					// Loop through all exported forms and get their selected style IDs
231
+					$form_ids = $args['ids'];
232
+					$style_ids = array();
233
+					foreach ( $form_ids as $form_id ) {
234
+						$form_data = FrmForm::getOne( $form_id );
235
+						// For forms that have not been updated while running 2.0, check if custom_style is set
236
+						if ( isset( $form_data->options['custom_style'] ) ) {
237
+							$style_ids[] = $form_data->options['custom_style'];
238
+						}
239
+						unset( $form_id, $form_data );
240
+					}
241 241
 					$select = $table . '.ID';
242
-                    $where['post_type'] = 'frm_styles';
243
-
244
-                    // Only export selected styles
245
-                    if ( ! empty( $style_ids ) ) {
246
-                        $where['ID'] = $style_ids;
247
-                    }
248
-                break;
249
-                default:
242
+					$where['post_type'] = 'frm_styles';
243
+
244
+					// Only export selected styles
245
+					if ( ! empty( $style_ids ) ) {
246
+						$where['ID'] = $style_ids;
247
+					}
248
+				break;
249
+				default:
250 250
 					$select = $table . '.ID';
251
-                    $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)';
252
-                    $where['pm.meta_key'] = 'frm_form_id';
253
-
254
-                    if ( empty($args['ids']) ) {
255
-                        $where['pm.meta_value >'] = 1;
256
-                    } else {
257
-                        $where['pm.meta_value'] = $args['ids'];
258
-                    }
259
-                break;
260
-            }
251
+					$join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)';
252
+					$where['pm.meta_key'] = 'frm_form_id';
253
+
254
+					if ( empty($args['ids']) ) {
255
+						$where['pm.meta_value >'] = 1;
256
+					} else {
257
+						$where['pm.meta_value'] = $args['ids'];
258
+					}
259
+				break;
260
+			}
261 261
 
262 262
 			$records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select );
263
-            unset($tb_type);
264
-        }
263
+			unset($tb_type);
264
+		}
265 265
 
266 266
 		echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo('charset') ) . "\" ?>\n";
267 267
 		include( FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php' );
268
-    }
268
+	}
269 269
 
270 270
 
271 271
 	public static function generate_csv( $atts ) {
@@ -336,14 +336,14 @@  discard block
 block discarded – undo
336 336
 	}
337 337
 
338 338
 	/**
339
-	* Get the fields that should be included in the CSV export
340
-	*
341
-	* @since 2.0.19
342
-	*
343
-	* @param int $form_id
344
-	* @param object $form
345
-	* @return array $csv_fields
346
-	*/
339
+	 * Get the fields that should be included in the CSV export
340
+	 *
341
+	 * @since 2.0.19
342
+	 *
343
+	 * @param int $form_id
344
+	 * @param object $form
345
+	 * @return array $csv_fields
346
+	 */
347 347
 	private static function get_fields_for_csv_export( $form_id, $form ) {
348 348
 		// Phase frm_csv_field_ids out by 2.01.05
349 349
 		$csv_field_ids = apply_filters( 'frm_csv_field_ids', '', $form_id, array( 'form' => $form ) );
@@ -373,16 +373,16 @@  discard block
 block discarded – undo
373 373
 	}
374 374
 
375 375
 	public static function allow_mime( $mimes ) {
376
-        if ( ! isset( $mimes['csv'] ) ) {
377
-            // allow csv files
378
-            $mimes['csv'] = 'text/csv';
379
-        }
380
-
381
-        if ( ! isset( $mimes['xml'] ) ) {
382
-            // allow xml
383
-            $mimes['xml'] = 'text/xml';
384
-        }
385
-
386
-        return $mimes;
387
-    }
376
+		if ( ! isset( $mimes['csv'] ) ) {
377
+			// allow csv files
378
+			$mimes['csv'] = 'text/csv';
379
+		}
380
+
381
+		if ( ! isset( $mimes['xml'] ) ) {
382
+			// allow xml
383
+			$mimes['xml'] = 'text/xml';
384
+		}
385
+
386
+		return $mimes;
387
+	}
388 388
 }
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
     		return;
13 13
     	}
14 14
 
15
-        $set_err = libxml_use_internal_errors(true);
15
+        $set_err = libxml_use_internal_errors( true );
16 16
         $loader = libxml_disable_entity_loader( true );
17 17
 
18 18
 		$files = apply_filters( 'frm_default_templates_files', array( FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml' ) );
19 19
 
20 20
         foreach ( (array) $files as $file ) {
21
-            FrmXMLHelper::import_xml($file);
22
-            unset($file);
21
+            FrmXMLHelper::import_xml( $file );
22
+            unset( $file );
23 23
         }
24 24
         /*
25 25
         if(is_wp_error($result))
@@ -71,41 +71,41 @@  discard block
 block discarded – undo
71 71
         $errors = array();
72 72
         $message = '';
73 73
 
74
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce');
74
+        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'import-xml', 'import-xml-nonce' );
75 75
         if ( $permission_error !== false ) {
76 76
             $errors[] = $permission_error;
77
-            self::form($errors);
77
+            self::form( $errors );
78 78
             return;
79 79
         }
80 80
 
81
-        if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
81
+        if ( ! isset( $_FILES ) || ! isset( $_FILES['frm_import_file'] ) || empty( $_FILES['frm_import_file']['name'] ) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
82 82
             $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' );
83
-            self::form($errors);
83
+            self::form( $errors );
84 84
             return;
85 85
         }
86 86
 
87 87
         $file = $_FILES['frm_import_file']['tmp_name'];
88 88
 
89 89
         if ( ! is_uploaded_file( $file ) ) {
90
-            unset($file);
90
+            unset( $file );
91 91
             $errors[] = __( 'The file does not exist, please try again.', 'formidable' );
92
-            self::form($errors);
92
+            self::form( $errors );
93 93
             return;
94 94
         }
95 95
 
96 96
         //add_filter('upload_mimes', 'FrmXMLController::allow_mime');
97 97
 
98
-        $export_format = apply_filters('frm_export_formats', array(
98
+        $export_format = apply_filters( 'frm_export_formats', array(
99 99
 			'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ),
100 100
 		) );
101 101
 
102
-        $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION));
103
-        if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) {
102
+        $file_type = strtolower( pathinfo( $_FILES['frm_import_file']['name'], PATHINFO_EXTENSION ) );
103
+        if ( $file_type != 'xml' && isset( $export_format[$file_type] ) ) {
104 104
             // allow other file types to be imported
105 105
 			do_action( 'frm_before_import_' . $file_type );
106 106
             return;
107 107
         }
108
-        unset($file_type);
108
+        unset( $file_type );
109 109
 
110 110
 		if ( ! function_exists( 'libxml_disable_entity_loader' ) ) {
111 111
 			$errors[] = __( 'XML import is not enabled on your server.', 'formidable' );
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
 		libxml_use_internal_errors( $set_err );
125 125
 		libxml_disable_entity_loader( $loader );
126 126
 
127
-        self::form($errors, $message);
127
+        self::form( $errors, $message );
128 128
     }
129 129
 
130 130
     public static function export_xml() {
131 131
         $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' );
132
-        if ( ! empty($error) ) {
132
+        if ( ! empty( $error ) ) {
133 133
             wp_die( $error );
134 134
         }
135 135
 
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
         }
144 144
 
145 145
         if ( $format == 'xml' ) {
146
-            self::generate_xml($type, compact('ids'));
146
+            self::generate_xml( $type, compact( 'ids' ) );
147 147
 		} if ( $format == 'csv' ) {
148
-			self::generate_csv( compact('ids') );
148
+			self::generate_csv( compact( 'ids' ) );
149 149
         } else {
150
-			do_action( 'frm_export_format_' . $format, compact('ids') );
150
+			do_action( 'frm_export_format_' . $format, compact( 'ids' ) );
151 151
         }
152 152
 
153 153
         wp_die();
@@ -157,12 +157,12 @@  discard block
 block discarded – undo
157 157
     	global $wpdb;
158 158
 
159 159
 	    $type = (array) $type;
160
-        if ( in_array( 'items', $type) && ! in_array( 'forms', $type) ) {
160
+        if ( in_array( 'items', $type ) && ! in_array( 'forms', $type ) ) {
161 161
             // make sure the form is included if there are entries
162 162
             $type[] = 'forms';
163 163
         }
164 164
 
165
-	    if ( in_array( 'forms', $type) ) {
165
+	    if ( in_array( 'forms', $type ) ) {
166 166
             // include actions with forms
167 167
 	        $type[] = 'actions';
168 168
 	    }
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 		foreach ( $type as $tb_type ) {
200 200
             $where = array();
201 201
 			$join = '';
202
-            $table = $tables[ $tb_type ];
202
+            $table = $tables[$tb_type];
203 203
 
204 204
 			$select = $table . '.id';
205 205
             $query_vars = array();
@@ -210,20 +210,20 @@  discard block
 block discarded – undo
210 210
                     if ( $args['ids'] ) {
211 211
 						$where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table . '.parent_form_id' => $args['ids'] );
212 212
                 	} else {
213
-						$where[ $table . '.status !' ] = 'draft';
213
+						$where[$table . '.status !'] = 'draft';
214 214
                 	}
215 215
                 break;
216 216
                 case 'actions':
217 217
 					$select = $table . '.ID';
218 218
 					$where['post_type'] = FrmFormActionsController::$action_post_type;
219
-                    if ( ! empty($args['ids']) ) {
219
+                    if ( ! empty( $args['ids'] ) ) {
220 220
 						$where['menu_order'] = $args['ids'];
221 221
                     }
222 222
                 break;
223 223
                 case 'items':
224 224
                     //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)";
225 225
                     if ( $args['ids'] ) {
226
-						$where[ $table . '.form_id' ] = $args['ids'];
226
+						$where[$table . '.form_id'] = $args['ids'];
227 227
                     }
228 228
                 break;
229 229
                 case 'styles':
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
                     $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)';
252 252
                     $where['pm.meta_key'] = 'frm_form_id';
253 253
 
254
-                    if ( empty($args['ids']) ) {
254
+                    if ( empty( $args['ids'] ) ) {
255 255
                         $where['pm.meta_value >'] = 1;
256 256
                     } else {
257 257
                         $where['pm.meta_value'] = $args['ids'];
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
                 break;
260 260
             }
261 261
 
262
-			$records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select );
263
-            unset($tb_type);
262
+			$records[$tb_type] = FrmDb::get_col( $table . $join, $where, $select );
263
+            unset( $tb_type );
264 264
         }
265 265
 
266
-		echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo('charset') ) . "\" ?>\n";
266
+		echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo( 'charset' ) ) . "\" ?>\n";
267 267
 		include( FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php' );
268 268
     }
269 269
 
@@ -289,11 +289,11 @@  discard block
 block discarded – undo
289 289
 			$fid = FrmAppHelper::get_param( 'fid', '', 'get', 'sanitize_text_field' );
290 290
 		}
291 291
 
292
-		if ( ! ini_get('safe_mode') ) {
293
-			set_time_limit(0); //Remove time limit to execute this function
294
-			$mem_limit = str_replace('M', '', ini_get('memory_limit'));
292
+		if ( ! ini_get( 'safe_mode' ) ) {
293
+			set_time_limit( 0 ); //Remove time limit to execute this function
294
+			$mem_limit = str_replace( 'M', '', ini_get( 'memory_limit' ) );
295 295
 			if ( (int) $mem_limit < 256 ) {
296
-				ini_set('memory_limit', '256M');
296
+				ini_set( 'memory_limit', '256M' );
297 297
 			}
298 298
 		}
299 299
 
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 			$no_export_fields = FrmField::no_save_fields();
365 365
 			foreach ( $csv_fields as $k => $f ) {
366 366
 				if ( in_array( $f->type, $no_export_fields ) ) {
367
-					unset( $csv_fields[ $k ] );
367
+					unset( $csv_fields[$k] );
368 368
 				}
369 369
 			}
370 370
 		}
Please login to merge, or discard this patch.