Completed
Push — master ( 836330...f46f0b )
by Jamie
02:43
created
classes/models/FrmEntryShortcodeFormatter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -219,7 +219,7 @@
 block discarded – undo
219 219
 			'type'  => $field->type,
220 220
 		);
221 221
 
222
-		$this->array_content[ $field->id ] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $array, $field );
222
+		$this->array_content[$field->id] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $array, $field );
223 223
 
224 224
 		return $array;
225 225
 	}
Please login to merge, or discard this patch.
classes/models/FrmFieldValue.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
 	 * @since 2.03.11
81 81
 	 */
82 82
 	protected function init_saved_value() {
83
-		if ( isset( $this->entry->metas[ $this->field->id ] ) ) {
84
-			$this->saved_value = $this->entry->metas[ $this->field->id ];
83
+		if ( isset( $this->entry->metas[$this->field->id] ) ) {
84
+			$this->saved_value = $this->entry->metas[$this->field->id];
85 85
 		} else {
86 86
 			$this->saved_value = '';
87 87
 		}
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 
155 155
 		if ( $this->source === 'entry_formatter' ) {
156 156
 			// Deprecated frm_email_value hook
157
-			$meta                  = array(
157
+			$meta = array(
158 158
 				'item_id'    => $this->entry->id,
159 159
 				'field_id'   => $this->field->id,
160 160
 				'meta_value' => $this->saved_value,
Please login to merge, or discard this patch.
classes/controllers/FrmEntriesController.php 2 patches
Indentation   +252 added lines, -252 removed lines patch added patch discarded remove patch
@@ -2,70 +2,70 @@  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( 'https://formidableforms.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( 'https://formidableforms.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;
68
+		global $frm_vars;
69 69
 		$form_id = FrmForm::get_current_form_id();
70 70
 
71 71
 		$columns[ $form_id . '_id' ] = 'ID';
@@ -83,15 +83,15 @@  discard block
 block discarded – undo
83 83
 		$columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
84 84
 		$columns[ $form_id . '_ip' ] = 'IP';
85 85
 
86
-        $frm_vars['cols'] = $columns;
86
+		$frm_vars['cols'] = $columns;
87 87
 
88 88
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
89 89
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
90 90
 			add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) );
91
-        }
91
+		}
92 92
 
93
-        return $columns;
94
-    }
93
+		return $columns;
94
+	}
95 95
 
96 96
 	private static function get_columns_for_form( $form_id, &$columns ) {
97 97
 		$form_cols = FrmField::get_all_for_form( $form_id, '', 'include' );
@@ -135,76 +135,76 @@  discard block
 block discarded – undo
135 135
 		$menu_name = FrmAppHelper::get_menu_name();
136 136
 		$this_page_name = 'manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden';
137 137
 		if ( $meta_key != $this_page_name || $meta_value == $prev_value ) {
138
-            return $check;
139
-        }
138
+			return $check;
139
+		}
140 140
 
141 141
 		if ( empty( $prev_value ) ) {
142 142
 			$prev_value = get_metadata( 'user', $object_id, $meta_key, true );
143 143
 		}
144 144
 
145
-        global $frm_vars;
146
-        //add a check so we don't create a loop
147
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
145
+		global $frm_vars;
146
+		//add a check so we don't create a loop
147
+		$frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
148 148
 
149
-        return $check;
150
-    }
149
+		return $check;
150
+	}
151 151
 
152
-    //add hidden columns back from other forms
152
+	//add hidden columns back from other forms
153 153
 	public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
154 154
 		$menu_name = FrmAppHelper::get_menu_name();
155 155
 		$sanitized = sanitize_title( $menu_name );
156 156
 		$this_page_name = 'manage' . $sanitized . '_page_formidable-entriescolumnshidden';
157 157
 		if ( $meta_key != $this_page_name ) {
158
-            return;
159
-        }
160
-
161
-        global $frm_vars;
162
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
163
-            return; //don't continue if there's no previous value
164
-        }
165
-
166
-        foreach ( $meta_value as $mk => $mv ) {
167
-            //remove blank values
168
-            if ( empty( $mv ) ) {
169
-                unset( $meta_value[ $mk ] );
170
-            }
171
-        }
172
-
173
-        $cur_form_prefix = reset($meta_value);
174
-        $cur_form_prefix = explode('_', $cur_form_prefix);
175
-        $cur_form_prefix = $cur_form_prefix[0];
176
-        $save = false;
177
-
178
-        foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
158
+			return;
159
+		}
160
+
161
+		global $frm_vars;
162
+		if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
163
+			return; //don't continue if there's no previous value
164
+		}
165
+
166
+		foreach ( $meta_value as $mk => $mv ) {
167
+			//remove blank values
168
+			if ( empty( $mv ) ) {
169
+				unset( $meta_value[ $mk ] );
170
+			}
171
+		}
172
+
173
+		$cur_form_prefix = reset($meta_value);
174
+		$cur_form_prefix = explode('_', $cur_form_prefix);
175
+		$cur_form_prefix = $cur_form_prefix[0];
176
+		$save = false;
177
+
178
+		foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
179 179
 			if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) {
180
-                //don't add blank cols or process included cols
181
-                continue;
182
-            }
180
+				//don't add blank cols or process included cols
181
+				continue;
182
+			}
183 183
 
184 184
 			$form_prefix = explode( '_', $prev_hidden );
185
-            $form_prefix = $form_prefix[0];
186
-            if ( $form_prefix == $cur_form_prefix ) {
187
-                //don't add back columns that are meant to be hidden
188
-                continue;
189
-            }
185
+			$form_prefix = $form_prefix[0];
186
+			if ( $form_prefix == $cur_form_prefix ) {
187
+				//don't add back columns that are meant to be hidden
188
+				continue;
189
+			}
190 190
 
191
-            $meta_value[] = $prev_hidden;
192
-            $save = true;
193
-            unset($form_prefix);
194
-        }
191
+			$meta_value[] = $prev_hidden;
192
+			$save = true;
193
+			unset($form_prefix);
194
+		}
195 195
 
196 196
 		if ( $save ) {
197
-            $user = wp_get_current_user();
197
+			$user = wp_get_current_user();
198 198
 			update_user_option( $user->ID, $this_page_name, $meta_value, true );
199
-        }
200
-    }
199
+		}
200
+	}
201 201
 
202 202
 	public static function save_per_page( $save, $option, $value ) {
203
-        if ( $option == 'formidable_page_formidable_entries_per_page' ) {
204
-            $save = (int) $value;
205
-        }
206
-        return $save;
207
-    }
203
+		if ( $option == 'formidable_page_formidable_entries_per_page' ) {
204
+			$save = (int) $value;
205
+		}
206
+		return $save;
207
+	}
208 208
 
209 209
 	public static function sortable_columns() {
210 210
 		$form_id = FrmForm::get_current_form_id();
@@ -230,46 +230,46 @@  discard block
 block discarded – undo
230 230
 	}
231 231
 
232 232
 	public static function hidden_columns( $result ) {
233
-        global $frm_vars;
233
+		global $frm_vars;
234 234
 
235 235
 		$form_id = FrmForm::get_current_form_id();
236 236
 
237
-        $return = false;
238
-        foreach ( (array) $result as $r ) {
239
-            if ( ! empty( $r ) ) {
240
-                $form_prefix = explode( '_', $r );
241
-                $form_prefix = $form_prefix[0];
237
+		$return = false;
238
+		foreach ( (array) $result as $r ) {
239
+			if ( ! empty( $r ) ) {
240
+				$form_prefix = explode( '_', $r );
241
+				$form_prefix = $form_prefix[0];
242 242
 
243
-                if ( (int) $form_prefix == (int) $form_id ) {
244
-                    $return = true;
245
-                    break;
246
-                }
243
+				if ( (int) $form_prefix == (int) $form_id ) {
244
+					$return = true;
245
+					break;
246
+				}
247 247
 
248
-                unset($form_prefix);
249
-            }
250
-        }
248
+				unset($form_prefix);
249
+			}
250
+		}
251 251
 
252
-        if ( $return ) {
252
+		if ( $return ) {
253 253
 			return $result;
254 254
 		}
255 255
 
256
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
257
-        $max_columns = 8;
258
-        if ( $i <= $max_columns ) {
256
+		$i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
257
+		$max_columns = 8;
258
+		if ( $i <= $max_columns ) {
259 259
 			return $result;
260 260
 		}
261 261
 
262
-        global $frm_vars;
263
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
264
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
265
-        }
262
+		global $frm_vars;
263
+		if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
264
+			$frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
265
+		}
266 266
 
267 267
 		$has_custom_hidden_columns = ( 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'] ) );
268 268
 		if ( $has_custom_hidden_columns ) {
269
-            $result = $frm_vars['current_form']->options['hidden_cols'];
270
-        } else {
271
-            $cols = $frm_vars['cols'];
272
-            $cols = array_reverse($cols, true);
269
+			$result = $frm_vars['current_form']->options['hidden_cols'];
270
+		} else {
271
+			$cols = $frm_vars['cols'];
272
+			$cols = array_reverse($cols, true);
273 273
 
274 274
 			if ( $form_id ) {
275 275
 				$result[] = $form_id . '_id';
@@ -277,59 +277,59 @@  discard block
 block discarded – undo
277 277
 			}
278 278
 
279 279
 			$result[] = $form_id . '_item_key';
280
-            $i--;
280
+			$i--;
281 281
 
282 282
 			foreach ( $cols as $col_key => $col ) {
283
-                if ( $i > $max_columns ) {
283
+				if ( $i > $max_columns ) {
284 284
 					$result[] = $col_key;
285 285
 				}
286
-                //remove some columns by default
287
-                $i--;
288
-                unset($col_key, $col);
289
-            }
290
-        }
286
+				//remove some columns by default
287
+				$i--;
288
+				unset($col_key, $col);
289
+			}
290
+		}
291 291
 
292
-        return $result;
293
-    }
292
+		return $result;
293
+	}
294 294
 
295 295
 	public static function display_list( $message = '', $errors = array() ) {
296
-        global $wpdb, $frm_vars;
296
+		global $wpdb, $frm_vars;
297 297
 
298 298
 		$form = FrmForm::maybe_get_current_form();
299 299
 		$params = FrmForm::get_admin_params( $form );
300 300
 
301
-        if ( $form ) {
302
-            $params['form'] = $form->id;
303
-            $frm_vars['current_form'] = $form;
301
+		if ( $form ) {
302
+			$params['form'] = $form->id;
303
+			$frm_vars['current_form'] = $form;
304 304
 
305 305
 			self::get_delete_form_time( $form, $errors );
306 306
 		}
307 307
 
308
-        $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
308
+		$table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
309 309
 
310
-        $wp_list_table = new $table_class( array( 'params' => $params ) );
310
+		$wp_list_table = new $table_class( array( 'params' => $params ) );
311 311
 
312
-        $pagenum = $wp_list_table->get_pagenum();
312
+		$pagenum = $wp_list_table->get_pagenum();
313 313
 
314
-        $wp_list_table->prepare_items();
314
+		$wp_list_table->prepare_items();
315 315
 
316
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
317
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
316
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
317
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
318 318
 			$url = add_query_arg( 'paged', $total_pages );
319
-            if ( headers_sent() ) {
320
-                echo FrmAppHelper::js_redirect($url);
321
-            } else {
322
-                wp_redirect( esc_url_raw( $url ) );
323
-            }
324
-            die();
325
-        }
326
-
327
-        if ( empty($message) && isset($_GET['import-message']) ) {
328
-            $message = __( 'Your import is complete', 'formidable' );
329
-        }
319
+			if ( headers_sent() ) {
320
+				echo FrmAppHelper::js_redirect($url);
321
+			} else {
322
+				wp_redirect( esc_url_raw( $url ) );
323
+			}
324
+			die();
325
+		}
326
+
327
+		if ( empty($message) && isset($_GET['import-message']) ) {
328
+			$message = __( 'Your import is complete', 'formidable' );
329
+		}
330 330
 
331 331
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' );
332
-    }
332
+	}
333 333
 
334 334
 	private static function get_delete_form_time( $form, &$errors ) {
335 335
 		if ( 'trash' == $form->status ) {
@@ -339,19 +339,19 @@  discard block
 block discarded – undo
339 339
 		}
340 340
 	}
341 341
 
342
-    /* Back End CRUD */
342
+	/* Back End CRUD */
343 343
 	public static function show( $id = 0 ) {
344
-        FrmAppHelper::permission_check('frm_view_entries');
344
+		FrmAppHelper::permission_check('frm_view_entries');
345 345
 
346
-        if ( ! $id ) {
346
+		if ( ! $id ) {
347 347
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
348 348
 
349
-            if ( ! $id ) {
349
+			if ( ! $id ) {
350 350
 				$id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' );
351
-            }
352
-        }
351
+			}
352
+		}
353 353
 
354
-        $entry = FrmEntry::getOne($id, true);
354
+		$entry = FrmEntry::getOne($id, true);
355 355
 		if ( ! $entry ) {
356 356
 			echo '<div id="form_show_entry_page" class="wrap">' .
357 357
 				__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
@@ -359,110 +359,110 @@  discard block
 block discarded – undo
359 359
 			return;
360 360
 		}
361 361
 
362
-        $data = maybe_unserialize($entry->description);
362
+		$data = maybe_unserialize($entry->description);
363 363
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
364 364
 			$data = array( 'referrer' => $data );
365 365
 		}
366 366
 
367 367
 		$fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
368
-        $to_emails = array();
368
+		$to_emails = array();
369 369
 
370 370
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' );
371
-    }
371
+	}
372 372
 
373
-    public static function destroy() {
374
-        FrmAppHelper::permission_check('frm_delete_entries');
373
+	public static function destroy() {
374
+		FrmAppHelper::permission_check('frm_delete_entries');
375 375
 
376 376
 		$params = FrmForm::get_admin_params();
377 377
 
378
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
379
-            //unlink entry from post
380
-            global $wpdb;
378
+		if ( isset($params['keep_post']) && $params['keep_post'] ) {
379
+			//unlink entry from post
380
+			global $wpdb;
381 381
 			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
382
-        }
382
+		}
383 383
 
384
-        $message = '';
385
-        if ( FrmEntry::destroy( $params['id'] ) ) {
386
-            $message = __( 'Entry was Successfully Destroyed', 'formidable' );
387
-        }
384
+		$message = '';
385
+		if ( FrmEntry::destroy( $params['id'] ) ) {
386
+			$message = __( 'Entry was Successfully Destroyed', 'formidable' );
387
+		}
388 388
 
389
-        self::display_list( $message );
390
-    }
389
+		self::display_list( $message );
390
+	}
391 391
 
392
-    public static function destroy_all() {
393
-        if ( ! current_user_can( 'frm_delete_entries' ) ) {
394
-            $frm_settings = FrmAppHelper::get_settings();
395
-            wp_die( $frm_settings->admin_permission );
396
-        }
392
+	public static function destroy_all() {
393
+		if ( ! current_user_can( 'frm_delete_entries' ) ) {
394
+			$frm_settings = FrmAppHelper::get_settings();
395
+			wp_die( $frm_settings->admin_permission );
396
+		}
397 397
 
398
-        global $wpdb;
398
+		global $wpdb;
399 399
 		$params = FrmForm::get_admin_params();
400
-        $message = '';
401
-        $errors = array();
402
-        $form_id = (int) $params['form'];
400
+		$message = '';
401
+		$errors = array();
402
+		$form_id = (int) $params['form'];
403 403
 
404
-        if ( $form_id ) {
405
-            $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
404
+		if ( $form_id ) {
405
+			$entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
406 406
 			$action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 );
407 407
 
408
-            if ( $action ) {
409
-                // this action takes a while, so only trigger it if there are posts to delete
410
-                foreach ( $entry_ids as $entry_id ) {
411
-                    do_action( 'frm_before_destroy_entry', $entry_id );
412
-                    unset( $entry_id );
413
-                }
414
-            }
415
-
416
-            $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 ) );
417
-            $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
418
-            if ( $results ) {
408
+			if ( $action ) {
409
+				// this action takes a while, so only trigger it if there are posts to delete
410
+				foreach ( $entry_ids as $entry_id ) {
411
+					do_action( 'frm_before_destroy_entry', $entry_id );
412
+					unset( $entry_id );
413
+				}
414
+			}
415
+
416
+			$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 ) );
417
+			$results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
418
+			if ( $results ) {
419 419
 				FrmEntry::clear_cache();
420
-                $message = __( 'Entries were Successfully Destroyed', 'formidable' );
421
-            }
422
-        } else {
423
-            $errors = __( 'No entries were specified', 'formidable' );
424
-        }
425
-
426
-        self::display_list( $message, $errors );
427
-    }
428
-
429
-    public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
430
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
431
-        return FrmFormsController::show_form( $id, $key, $title, $description );
432
-    }
433
-
434
-    public static function get_form( $filename, $form, $title, $description ) {
435
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
436
-        return FrmFormsController::get_form( $form, $title, $description );
437
-    }
438
-
439
-    public static function process_entry( $errors = '', $ajax = false ) {
420
+				$message = __( 'Entries were Successfully Destroyed', 'formidable' );
421
+			}
422
+		} else {
423
+			$errors = __( 'No entries were specified', 'formidable' );
424
+		}
425
+
426
+		self::display_list( $message, $errors );
427
+	}
428
+
429
+	public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
430
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
431
+		return FrmFormsController::show_form( $id, $key, $title, $description );
432
+	}
433
+
434
+	public static function get_form( $filename, $form, $title, $description ) {
435
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
436
+		return FrmFormsController::get_form( $form, $title, $description );
437
+	}
438
+
439
+	public static function process_entry( $errors = '', $ajax = false ) {
440 440
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
441 441
 		if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) {
442
-            return;
443
-        }
442
+			return;
443
+		}
444 444
 
445
-        global $frm_vars;
445
+		global $frm_vars;
446 446
 
447 447
 		$form = FrmForm::getOne( $form_id );
448
-        if ( ! $form ) {
449
-            return;
450
-        }
448
+		if ( ! $form ) {
449
+			return;
450
+		}
451 451
 
452 452
 		$params = FrmForm::get_params( $form );
453 453
 
454
-        if ( ! isset( $frm_vars['form_params'] ) ) {
455
-            $frm_vars['form_params'] = array();
456
-        }
454
+		if ( ! isset( $frm_vars['form_params'] ) ) {
455
+			$frm_vars['form_params'] = array();
456
+		}
457 457
 		$frm_vars['form_params'][ $form->id ] = $params;
458 458
 
459 459
 		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
460
-            return;
461
-        }
460
+			return;
461
+		}
462 462
 
463
-        if ( $errors == '' && ! $ajax ) {
463
+		if ( $errors == '' && ! $ajax ) {
464 464
 			$errors = FrmEntryValidate::validate( $_POST );
465
-        }
465
+		}
466 466
 
467 467
 		/**
468 468
 		 * Use this filter to add trigger actions and add errors after
@@ -473,39 +473,39 @@  discard block
 block discarded – undo
473 473
 
474 474
 		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
475 475
 
476
-        if ( empty( $errors ) ) {
476
+		if ( empty( $errors ) ) {
477 477
 			$_POST['frm_skip_cookie'] = 1;
478
-            if ( $params['action'] == 'create' ) {
478
+			if ( $params['action'] == 'create' ) {
479 479
 				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
480 480
 					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
481
-                }
482
-            }
481
+				}
482
+			}
483 483
 
484
-            do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
484
+			do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
485 485
 			unset( $_POST['frm_skip_cookie'] );
486
-        }
487
-    }
488
-
489
-    public static function delete_entry_before_redirect( $url, $form, $atts ) {
490
-        self::_delete_entry( $atts['id'], $form );
491
-        return $url;
492
-    }
493
-
494
-    //Delete entry if not redirected
495
-    public static function delete_entry_after_save( $atts ) {
496
-        self::_delete_entry( $atts['entry_id'], $atts['form'] );
497
-    }
498
-
499
-    private static function _delete_entry( $entry_id, $form ) {
500
-        if ( ! $form ) {
501
-            return;
502
-        }
503
-
504
-        $form->options = maybe_unserialize( $form->options );
505
-        if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
506
-            FrmEntry::destroy( $entry_id );
507
-        }
508
-    }
486
+		}
487
+	}
488
+
489
+	public static function delete_entry_before_redirect( $url, $form, $atts ) {
490
+		self::_delete_entry( $atts['id'], $form );
491
+		return $url;
492
+	}
493
+
494
+	//Delete entry if not redirected
495
+	public static function delete_entry_after_save( $atts ) {
496
+		self::_delete_entry( $atts['entry_id'], $atts['form'] );
497
+	}
498
+
499
+	private static function _delete_entry( $entry_id, $form ) {
500
+		if ( ! $form ) {
501
+			return;
502
+		}
503
+
504
+		$form->options = maybe_unserialize( $form->options );
505
+		if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
506
+			FrmEntry::destroy( $entry_id );
507
+		}
508
+	}
509 509
 
510 510
 	/**
511 511
 	 * @param $atts
@@ -560,15 +560,15 @@  discard block
 block discarded – undo
560 560
 	}
561 561
 
562 562
 	public static function entry_sidebar( $entry ) {
563
-        $data = maybe_unserialize($entry->description);
564
-        $date_format = get_option('date_format');
565
-        $time_format = get_option('time_format');
563
+		$data = maybe_unserialize($entry->description);
564
+		$date_format = get_option('date_format');
565
+		$time_format = get_option('time_format');
566 566
 		if ( isset( $data['browser'] ) ) {
567 567
 			$browser = FrmEntriesHelper::get_browser( $data['browser'] );
568 568
 		}
569 569
 
570 570
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
571
-    }
571
+	}
572 572
 
573 573
 	/***********************************************************************
574 574
 	 * Deprecated Functions
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 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,20 +68,20 @@  discard block
 block discarded – undo
68 68
         global $frm_vars;
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
 			self::get_columns_for_form( $form_id, $columns );
76 76
 		} else {
77
-			$columns[ $form_id . '_form_id' ] = __( 'Form', 'formidable' );
78
-			$columns[ $form_id . '_name' ] = __( 'Entry Name', 'formidable' );
79
-			$columns[ $form_id . '_user_id' ] = __( 'Created By', 'formidable' );
77
+			$columns[$form_id . '_form_id'] = __( 'Form', 'formidable' );
78
+			$columns[$form_id . '_name'] = __( 'Entry Name', 'formidable' );
79
+			$columns[$form_id . '_user_id'] = __( 'Created By', 'formidable' );
80 80
 		}
81 81
 
82
-		$columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' );
83
-		$columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
84
-		$columns[ $form_id . '_ip' ] = 'IP';
82
+		$columns[$form_id . '_created_at'] = __( 'Entry creation date', 'formidable' );
83
+		$columns[$form_id . '_updated_at'] = __( 'Entry update date', 'formidable' );
84
+		$columns[$form_id . '_ip'] = 'IP';
85 85
 
86 86
         $frm_vars['cols'] = $columns;
87 87
 
@@ -107,14 +107,14 @@  discard block
 block discarded – undo
107 107
 				if ( $sub_form_cols ) {
108 108
 					foreach ( $sub_form_cols as $k => $sub_form_col ) {
109 109
 						if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
110
-							unset( $sub_form_cols[ $k ] );
110
+							unset( $sub_form_cols[$k] );
111 111
 							continue;
112 112
 						}
113
-						$columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
114
-						unset($sub_form_col);
113
+						$columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
114
+						unset( $sub_form_col );
115 115
 					}
116 116
 				}
117
-				unset($sub_form_cols);
117
+				unset( $sub_form_cols );
118 118
 			} else {
119 119
 				$col_id = $form_col->field_key;
120 120
 				if ( $form_col->form_id != $form_id ) {
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 				$has_separate_value = ! FrmField::is_option_empty( $form_col, 'separate_value' );
125 125
 				$is_post_status     = FrmField::is_option_true( $form_col, 'post_field' ) && $form_col->field_options['post_field'] == 'post_status';
126 126
 				if ( $has_separate_value && ! $is_post_status ) {
127
-					$columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
127
+					$columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
128 128
 				}
129
-				$columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
129
+				$columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
130 130
 			}
131 131
 		}
132 132
 	}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 
145 145
         global $frm_vars;
146 146
         //add a check so we don't create a loop
147
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
147
+        $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
148 148
 
149 149
         return $check;
150 150
     }
@@ -159,19 +159,19 @@  discard block
 block discarded – undo
159 159
         }
160 160
 
161 161
         global $frm_vars;
162
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
162
+        if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
163 163
             return; //don't continue if there's no previous value
164 164
         }
165 165
 
166 166
         foreach ( $meta_value as $mk => $mv ) {
167 167
             //remove blank values
168 168
             if ( empty( $mv ) ) {
169
-                unset( $meta_value[ $mk ] );
169
+                unset( $meta_value[$mk] );
170 170
             }
171 171
         }
172 172
 
173
-        $cur_form_prefix = reset($meta_value);
174
-        $cur_form_prefix = explode('_', $cur_form_prefix);
173
+        $cur_form_prefix = reset( $meta_value );
174
+        $cur_form_prefix = explode( '_', $cur_form_prefix );
175 175
         $cur_form_prefix = $cur_form_prefix[0];
176 176
         $save = false;
177 177
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 
191 191
             $meta_value[] = $prev_hidden;
192 192
             $save = true;
193
-            unset($form_prefix);
193
+            unset( $form_prefix );
194 194
         }
195 195
 
196 196
 		if ( $save ) {
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		foreach ( $fields as $field ) {
223 223
 			if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) {
224 224
 				// Can't sort on checkboxes because they are stored serialized, or post fields
225
-				$columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
225
+				$columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id;
226 226
 			}
227 227
 		}
228 228
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
                     break;
246 246
                 }
247 247
 
248
-                unset($form_prefix);
248
+                unset( $form_prefix );
249 249
             }
250 250
         }
251 251
 
@@ -253,15 +253,15 @@  discard block
 block discarded – undo
253 253
 			return $result;
254 254
 		}
255 255
 
256
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
256
+        $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
257 257
         $max_columns = 8;
258 258
         if ( $i <= $max_columns ) {
259 259
 			return $result;
260 260
 		}
261 261
 
262 262
         global $frm_vars;
263
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
264
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
263
+        if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] ) {
264
+            $frm_vars['current_form']->options = maybe_unserialize( $frm_vars['current_form']->options );
265 265
         }
266 266
 
267 267
 		$has_custom_hidden_columns = ( 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'] ) );
@@ -269,23 +269,23 @@  discard block
 block discarded – undo
269 269
             $result = $frm_vars['current_form']->options['hidden_cols'];
270 270
         } else {
271 271
             $cols = $frm_vars['cols'];
272
-            $cols = array_reverse($cols, true);
272
+            $cols = array_reverse( $cols, true );
273 273
 
274 274
 			if ( $form_id ) {
275 275
 				$result[] = $form_id . '_id';
276
-				$i--;
276
+				$i --;
277 277
 			}
278 278
 
279 279
 			$result[] = $form_id . '_item_key';
280
-            $i--;
280
+            $i --;
281 281
 
282 282
 			foreach ( $cols as $col_key => $col ) {
283 283
                 if ( $i > $max_columns ) {
284 284
 					$result[] = $col_key;
285 285
 				}
286 286
                 //remove some columns by default
287
-                $i--;
288
-                unset($col_key, $col);
287
+                $i --;
288
+                unset( $col_key, $col );
289 289
             }
290 290
         }
291 291
 
@@ -317,14 +317,14 @@  discard block
 block discarded – undo
317 317
         if ( $pagenum > $total_pages && $total_pages > 0 ) {
318 318
 			$url = add_query_arg( 'paged', $total_pages );
319 319
             if ( headers_sent() ) {
320
-                echo FrmAppHelper::js_redirect($url);
320
+                echo FrmAppHelper::js_redirect( $url );
321 321
             } else {
322 322
                 wp_redirect( esc_url_raw( $url ) );
323 323
             }
324 324
             die();
325 325
         }
326 326
 
327
-        if ( empty($message) && isset($_GET['import-message']) ) {
327
+        if ( empty( $message ) && isset( $_GET['import-message'] ) ) {
328 328
             $message = __( 'Your import is complete', 'formidable' );
329 329
         }
330 330
 
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 
342 342
     /* Back End CRUD */
343 343
 	public static function show( $id = 0 ) {
344
-        FrmAppHelper::permission_check('frm_view_entries');
344
+        FrmAppHelper::permission_check( 'frm_view_entries' );
345 345
 
346 346
         if ( ! $id ) {
347 347
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
             }
352 352
         }
353 353
 
354
-        $entry = FrmEntry::getOne($id, true);
354
+        $entry = FrmEntry::getOne( $id, true );
355 355
 		if ( ! $entry ) {
356 356
 			echo '<div id="form_show_entry_page" class="wrap">' .
357 357
 				__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 			return;
360 360
 		}
361 361
 
362
-        $data = maybe_unserialize($entry->description);
362
+        $data = maybe_unserialize( $entry->description );
363 363
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
364 364
 			$data = array( 'referrer' => $data );
365 365
 		}
@@ -371,11 +371,11 @@  discard block
 block discarded – undo
371 371
     }
372 372
 
373 373
     public static function destroy() {
374
-        FrmAppHelper::permission_check('frm_delete_entries');
374
+        FrmAppHelper::permission_check( 'frm_delete_entries' );
375 375
 
376 376
 		$params = FrmForm::get_admin_params();
377 377
 
378
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
378
+        if ( isset( $params['keep_post'] ) && $params['keep_post'] ) {
379 379
             //unlink entry from post
380 380
             global $wpdb;
381 381
 			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
@@ -454,9 +454,9 @@  discard block
 block discarded – undo
454 454
         if ( ! isset( $frm_vars['form_params'] ) ) {
455 455
             $frm_vars['form_params'] = array();
456 456
         }
457
-		$frm_vars['form_params'][ $form->id ] = $params;
457
+		$frm_vars['form_params'][$form->id] = $params;
458 458
 
459
-		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
459
+		if ( isset( $frm_vars['created_entries'][$form_id] ) ) {
460 460
             return;
461 461
         }
462 462
 
@@ -471,13 +471,13 @@  discard block
 block discarded – undo
471 471
 		 */
472 472
 		$errors = apply_filters( 'frm_entries_before_create', $errors, $form );
473 473
 
474
-		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
474
+		$frm_vars['created_entries'][$form_id] = array( 'errors' => $errors );
475 475
 
476 476
         if ( empty( $errors ) ) {
477 477
 			$_POST['frm_skip_cookie'] = 1;
478 478
             if ( $params['action'] == 'create' ) {
479
-				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
480
-					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
479
+				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) {
480
+					$frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST );
481 481
                 }
482 482
             }
483 483
 
@@ -560,9 +560,9 @@  discard block
 block discarded – undo
560 560
 	}
561 561
 
562 562
 	public static function entry_sidebar( $entry ) {
563
-        $data = maybe_unserialize($entry->description);
564
-        $date_format = get_option('date_format');
565
-        $time_format = get_option('time_format');
563
+        $data = maybe_unserialize( $entry->description );
564
+        $date_format = get_option( 'date_format' );
565
+        $time_format = get_option( 'time_format' );
566 566
 		if ( isset( $data['browser'] ) ) {
567 567
 			$browser = FrmEntriesHelper::get_browser( $data['browser'] );
568 568
 		}
Please login to merge, or discard this patch.
classes/helpers/FrmFieldsHelper.php 2 patches
Indentation   +691 added lines, -691 removed lines patch added patch discarded remove patch
@@ -7,72 +7,72 @@  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 ( in_array( $type, array( 'data', 'lookup' ) ) ) {
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;
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 ( in_array( $type, array( 'data', 'lookup' ) ) ) {
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 54
 			$values['field_options']['label'] = 'none';
55
-        } else if ( 'url' == $type ) {
56
-            $values['name'] = __( 'Website', 'formidable' );
57
-        }
55
+		} else if ( 'url' == $type ) {
56
+			$values['name'] = __( 'Website', 'formidable' );
57
+		}
58 58
 
59 59
 		$fields = FrmField::field_selection();
60
-        $fields = array_merge($fields, FrmField::pro_field_selection());
60
+		$fields = array_merge($fields, FrmField::pro_field_selection());
61 61
 
62
-        if ( isset( $fields[ $type ] ) ) {
63
-            $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
64
-        }
62
+		if ( isset( $fields[ $type ] ) ) {
63
+			$values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
64
+		}
65 65
 
66
-        unset($fields);
66
+		unset($fields);
67 67
 
68
-        return $values;
69
-    }
68
+		return $values;
69
+	}
70 70
 
71 71
 	public static function get_html_id( $field, $plus = '' ) {
72 72
 		return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field );
73
-    }
73
+	}
74 74
 
75
-    public static function setup_edit_vars( $record, $doing_ajax = false ) {
75
+	public static function setup_edit_vars( $record, $doing_ajax = false ) {
76 76
 		$values = array( 'id' => $record->id, 'form_id' => $record->form_id );
77 77
 		$defaults = array(
78 78
 			'name'          => $record->name,
@@ -85,86 +85,86 @@  discard block
 block discarded – undo
85 85
 		);
86 86
 
87 87
 		if ( $doing_ajax ) {
88
-            $values = $values + $defaults;
89
-            $values['form_name'] = '';
88
+			$values = $values + $defaults;
89
+			$values['form_name'] = '';
90 90
 		} else {
91 91
 			foreach ( $defaults as $var => $default ) {
92
-                $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
93
-                unset($var, $default);
94
-            }
92
+				$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
93
+				unset($var, $default);
94
+			}
95 95
 
96 96
 			$values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : '';
97
-        }
97
+		}
98 98
 
99 99
 		unset( $defaults );
100 100
 
101
-        $values['options'] = $record->options;
102
-        $values['field_options'] = $record->field_options;
101
+		$values['options'] = $record->options;
102
+		$values['field_options'] = $record->field_options;
103 103
 
104
-        $defaults = self::get_default_field_opts($values['type'], $record, true);
104
+		$defaults = self::get_default_field_opts($values['type'], $record, true);
105 105
 
106 106
 		if ( $values['type'] == 'captcha' ) {
107
-            $frm_settings = FrmAppHelper::get_settings();
108
-            $defaults['invalid'] = $frm_settings->re_msg;
109
-        }
107
+			$frm_settings = FrmAppHelper::get_settings();
108
+			$defaults['invalid'] = $frm_settings->re_msg;
109
+		}
110 110
 
111 111
 		foreach ( $defaults as $opt => $default ) {
112
-            $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
113
-            unset($opt, $default);
114
-        }
112
+			$values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
113
+			unset($opt, $default);
114
+		}
115 115
 
116
-        $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
116
+		$values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
117 117
 
118 118
 		return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) );
119
-    }
119
+	}
120 120
 
121
-    public static function get_default_field_opts( $type, $field, $limit = false ) {
122
-        $field_options = array(
123
-            'size' => '', 'max' => '', 'label' => '', 'blank' => '',
124
-            'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0,
125
-            'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '',
121
+	public static function get_default_field_opts( $type, $field, $limit = false ) {
122
+		$field_options = array(
123
+			'size' => '', 'max' => '', 'label' => '', 'blank' => '',
124
+			'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0,
125
+			'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '',
126 126
 			'custom_html' => '', 'captcha_size' => 'normal', 'captcha_theme' => 'light',
127
-        );
127
+		);
128 128
 
129 129
 		if ( $limit ) {
130
-            return $field_options;
130
+			return $field_options;
131 131
 		}
132 132
 
133
-        global $wpdb;
133
+		global $wpdb;
134 134
 
135
-        $form_id = (is_numeric($field)) ? $field : $field->form_id;
135
+		$form_id = (is_numeric($field)) ? $field : $field->form_id;
136 136
 
137 137
 		$key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key;
138 138
 
139
-        $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) );
139
+		$field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) );
140 140
 
141
-        $frm_settings = FrmAppHelper::get_settings();
142
-        return array(
143
-            'name' => __( 'Untitled', 'formidable' ), 'description' => '',
141
+		$frm_settings = FrmAppHelper::get_settings();
142
+		return array(
143
+			'name' => __( 'Untitled', 'formidable' ), 'description' => '',
144 144
 			'field_key' => $key, 'type' => $type, 'options' => '', 'default_value' => '',
145 145
 			'field_order' => $field_count + 1, 'required' => false,
146
-            'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg,
147
-            'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id,
146
+			'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg,
147
+			'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id,
148 148
 			'field_options' => $field_options,
149
-        );
150
-    }
149
+		);
150
+	}
151 151
 
152
-    public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
153
-        global $wpdb;
152
+	public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
153
+		global $wpdb;
154 154
 
155 155
 		$values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
156
-        $values['form_id'] = $form_id;
157
-        $values['options'] = maybe_serialize($field->options);
158
-        $values['default_value'] = maybe_serialize($field->default_value);
159
-
160
-        foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
161
-            $values[ $col ] = $field->{$col};
162
-        }
163
-    }
164
-
165
-    /**
166
-     * @since 2.0
167
-     */
156
+		$values['form_id'] = $form_id;
157
+		$values['options'] = maybe_serialize($field->options);
158
+		$values['default_value'] = maybe_serialize($field->default_value);
159
+
160
+		foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
161
+			$values[ $col ] = $field->{$col};
162
+		}
163
+	}
164
+
165
+	/**
166
+	 * @since 2.0
167
+	 */
168 168
 	public static function get_error_msg( $field, $error ) {
169 169
 		$frm_settings = FrmAppHelper::get_settings();
170 170
 		$default_settings = $frm_settings->default_options();
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
 	public static function get_default_html( $type = 'text' ) {
194 194
 		if ( apply_filters( 'frm_normal_field_type_html', true, $type ) ) {
195 195
 			$input = ( in_array( $type, array( 'radio', 'checkbox', 'data' ) ) ) ? '<div class="frm_opt_container">[input]</div>' : '[input]';
196
-            $for = '';
196
+			$for = '';
197 197
 			if ( ! in_array( $type, array( 'radio', 'checkbox', 'data', 'scale' ) ) ) {
198
-                $for = 'for="field_[key]"';
199
-            }
198
+				$for = 'for="field_[key]"';
199
+			}
200 200
 
201
-            $default_html = <<<DEFAULT_HTML
201
+			$default_html = <<<DEFAULT_HTML
202 202
 <div id="frm_field_[id]_container" class="frm_form_field form-field [required_class][error_class]">
203 203
     <label $for class="frm_primary_label">[field_name]
204 204
         <span class="frm_required">[required_label]</span>
@@ -208,82 +208,82 @@  discard block
 block discarded – undo
208 208
     [if error]<div class="frm_error">[error]</div>[/if error]
209 209
 </div>
210 210
 DEFAULT_HTML;
211
-        } else {
211
+		} else {
212 212
 			$default_html = apply_filters('frm_other_custom_html', '', $type);
213
-        }
213
+		}
214 214
 
215
-        return apply_filters('frm_custom_html', $default_html, $type);
216
-    }
215
+		return apply_filters('frm_custom_html', $default_html, $type);
216
+	}
217 217
 
218 218
 	public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) {
219
-        $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
219
+		$html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
220 220
 
221
-        $defaults = array(
221
+		$defaults = array(
222 222
 			'field_name'    => 'item_meta[' . $field['id'] . ']',
223 223
 			'field_id'      => $field['id'],
224
-            'field_plus_id' => '',
225
-            'section_id'    => '',
226
-        );
227
-        $args = wp_parse_args($args, $defaults);
228
-        $field_name = $args['field_name'];
229
-        $field_id = $args['field_id'];
230
-        $html_id = self::get_html_id($field, $args['field_plus_id']);
224
+			'field_plus_id' => '',
225
+			'section_id'    => '',
226
+		);
227
+		$args = wp_parse_args($args, $defaults);
228
+		$field_name = $args['field_name'];
229
+		$field_id = $args['field_id'];
230
+		$html_id = self::get_html_id($field, $args['field_plus_id']);
231 231
 
232
-        if ( FrmField::is_multiple_select($field) ) {
233
-            $field_name .= '[]';
234
-        }
232
+		if ( FrmField::is_multiple_select($field) ) {
233
+			$field_name .= '[]';
234
+		}
235 235
 
236
-        //replace [id]
237
-        $html = str_replace('[id]', $field_id, $html);
236
+		//replace [id]
237
+		$html = str_replace('[id]', $field_id, $html);
238 238
 
239
-        // Remove the for attribute for captcha
240
-        if ( $field['type'] == 'captcha' ) {
241
-            $html = str_replace(' for="field_[key]"', '', $html);
242
-        }
239
+		// Remove the for attribute for captcha
240
+		if ( $field['type'] == 'captcha' ) {
241
+			$html = str_replace(' for="field_[key]"', '', $html);
242
+		}
243 243
 
244
-        // set the label for
245
-        $html = str_replace('field_[key]', $html_id, $html);
244
+		// set the label for
245
+		$html = str_replace('field_[key]', $html_id, $html);
246 246
 
247
-        //replace [key]
248
-        $html = str_replace('[key]', $field['field_key'], $html);
247
+		//replace [key]
248
+		$html = str_replace('[key]', $field['field_key'], $html);
249 249
 
250
-        //replace [description] and [required_label] and [error]
250
+		//replace [description] and [required_label] and [error]
251 251
 		$required = FrmField::is_required( $field ) ? $field['required_indicator'] : '';
252
-        if ( ! is_array( $errors ) ) {
253
-            $errors = array();
254
-        }
252
+		if ( ! is_array( $errors ) ) {
253
+			$errors = array();
254
+		}
255 255
 		$error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false;
256 256
 
257
-        //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
258
-        if ( $field['type'] == 'divider' ) {
259
-            if ( FrmField::is_option_true( $field, 'description' ) ) {
260
-                $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
261
-            } else {
262
-                $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
263
-            }
264
-        }
257
+		//If field type is section heading, add class so a bottom margin can be added to either the h3 or description
258
+		if ( $field['type'] == 'divider' ) {
259
+			if ( FrmField::is_option_true( $field, 'description' ) ) {
260
+				$html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
261
+			} else {
262
+				$html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
263
+			}
264
+		}
265 265
 
266 266
 		foreach ( array( 'description' => $field['description'], 'required_label' => $required, 'error' => $error ) as $code => $value ) {
267
-            self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html );
268
-        }
267
+			self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html );
268
+		}
269 269
 
270
-        //replace [required_class]
270
+		//replace [required_class]
271 271
 		$required_class = FrmField::is_required( $field ) ? ' frm_required_field' : '';
272
-        $html = str_replace('[required_class]', $required_class, $html);
272
+		$html = str_replace('[required_class]', $required_class, $html);
273 273
 
274
-        //replace [label_position]
275
-        $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
276
-        $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
274
+		//replace [label_position]
275
+		$field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
276
+		$field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
277 277
 		$html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html );
278 278
 
279
-        //replace [field_name]
280
-        $html = str_replace('[field_name]', $field['name'], $html);
279
+		//replace [field_name]
280
+		$html = str_replace('[field_name]', $field['name'], $html);
281 281
 
282 282
 		self::add_field_div_classes( $field_id, $field, $errors, $html );
283 283
 
284
-        //replace [entry_key]
285
-        $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
286
-        $html = str_replace('[entry_key]', $entry_key, $html);
284
+		//replace [entry_key]
285
+		$entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
286
+		$html = str_replace('[entry_key]', $entry_key, $html);
287 287
 
288 288
 		if ( $form ) {
289 289
 			$form = (array) $form;
@@ -297,57 +297,57 @@  discard block
 block discarded – undo
297 297
 
298 298
 		self::process_wp_shortcodes( $html );
299 299
 
300
-        //replace [input]
301
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
302
-        global $frm_vars;
303
-        $frm_settings = FrmAppHelper::get_settings();
300
+		//replace [input]
301
+		preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
302
+		global $frm_vars;
303
+		$frm_settings = FrmAppHelper::get_settings();
304 304
 
305
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
306
-            $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
305
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
306
+			$atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
307 307
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
308 308
 
309
-            $replace_with = '';
309
+			$replace_with = '';
310 310
 
311
-            if ( $tag == 'input' ) {
312
-                if ( isset($atts['opt']) ) {
313
-                    $atts['opt']--;
314
-                }
311
+			if ( $tag == 'input' ) {
312
+				if ( isset($atts['opt']) ) {
313
+					$atts['opt']--;
314
+				}
315 315
 
316
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
317
-                if ( isset($atts['class']) ) {
318
-                    unset($atts['class']);
319
-                }
316
+				$field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
317
+				if ( isset($atts['class']) ) {
318
+					unset($atts['class']);
319
+				}
320 320
 
321
-                $field['shortcodes'] = $atts;
322
-                ob_start();
321
+				$field['shortcodes'] = $atts;
322
+				ob_start();
323 323
 				include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' );
324
-                $replace_with = ob_get_contents();
325
-                ob_end_clean();
326
-            } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
327
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
328
-            }
324
+				$replace_with = ob_get_contents();
325
+				ob_end_clean();
326
+			} else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
327
+				$replace_with = FrmProEntriesController::entry_delete_link($atts);
328
+			}
329 329
 
330
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
331
-        }
330
+			$html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
331
+		}
332 332
 
333
-        $html .= "\n";
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
 
349
-        return $html;
350
-    }
349
+		return $html;
350
+	}
351 351
 
352 352
 	/**
353 353
 	 * This filters shortcodes in the field HTML
@@ -412,46 +412,46 @@  discard block
 block discarded – undo
412 412
 		return $classes;
413 413
 	}
414 414
 
415
-    public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
416
-        if ( $no_vars ) {
415
+	public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
416
+		if ( $no_vars ) {
417 417
 			$html = str_replace( '[if ' . $code . ']', '', $html );
418 418
 			$html = str_replace( '[/if ' . $code . ']', '', $html );
419
-        } else {
419
+		} else {
420 420
 			$html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html );
421
-        }
421
+		}
422 422
 
423 423
 		$html = str_replace( '[' . $code . ']', $replace_with, $html );
424
-    }
424
+	}
425 425
 
426 426
 	public static function get_shortcode_tag( $shortcodes, $short_key, $args ) {
427 427
 		$args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) );
428
-        if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
429
-            $args['conditional_check'] = true;
430
-        }
431
-
432
-        $prefix = '';
433
-        if ( $args['conditional_check'] ) {
434
-            if ( $args['conditional'] ) {
435
-                $prefix = 'if ';
436
-            } else if ( $args['foreach'] ) {
437
-                $prefix = 'foreach ';
438
-            }
439
-        }
440
-
441
-        $with_tags = $args['conditional_check'] ? 3 : 2;
442
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
443
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
444
-            $tag = str_replace(']', '', $tag);
445
-            $tags = explode(' ', $tag);
446
-            if ( is_array($tags) ) {
447
-                $tag = $tags[0];
448
-            }
449
-        } else {
450
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
451
-        }
452
-
453
-        return $tag;
454
-    }
428
+		if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
429
+			$args['conditional_check'] = true;
430
+		}
431
+
432
+		$prefix = '';
433
+		if ( $args['conditional_check'] ) {
434
+			if ( $args['conditional'] ) {
435
+				$prefix = 'if ';
436
+			} else if ( $args['foreach'] ) {
437
+				$prefix = 'foreach ';
438
+			}
439
+		}
440
+
441
+		$with_tags = $args['conditional_check'] ? 3 : 2;
442
+		if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
443
+			$tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
444
+			$tag = str_replace(']', '', $tag);
445
+			$tags = explode(' ', $tag);
446
+			if ( is_array($tags) ) {
447
+				$tag = $tags[0];
448
+			}
449
+		} else {
450
+			$tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
451
+		}
452
+
453
+		return $tag;
454
+	}
455 455
 
456 456
 	/**
457 457
 	 * Remove [collapse_this] if it's still included after all processing
@@ -489,8 +489,8 @@  discard block
 block discarded – undo
489 489
 		}
490 490
 		$api_js_url = apply_filters( 'frm_recaptcha_js_url', $api_js_url );
491 491
 
492
-        wp_register_script( 'recaptcha-api', $api_js_url, '', true );
493
-        wp_enqueue_script( 'recaptcha-api' );
492
+		wp_register_script( 'recaptcha-api', $api_js_url, '', true );
493
+		wp_enqueue_script( 'recaptcha-api' );
494 494
 
495 495
 		// for reverse compatibility
496 496
 		$field['captcha_size'] = ( $field['captcha_size'] == 'default' ) ? 'normal' : $field['captcha_size'];
@@ -503,40 +503,40 @@  discard block
 block discarded – undo
503 503
 	}
504 504
 ?>></div>
505 505
 <?php
506
-    }
506
+	}
507 507
 
508 508
 	public static function show_single_option( $field ) {
509
-        $field_name = $field['name'];
510
-        $html_id = self::get_html_id($field);
511
-        foreach ( $field['options'] as $opt_key => $opt ) {
512
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
513
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
509
+		$field_name = $field['name'];
510
+		$html_id = self::get_html_id($field);
511
+		foreach ( $field['options'] as $opt_key => $opt ) {
512
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
513
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
514 514
 
515
-            // If this is an "Other" option, get the HTML for it
515
+			// If this is an "Other" option, get the HTML for it
516 516
 			if ( self::is_other_opt( $opt_key ) ) {
517
-                // Get string for Other text field, if needed
517
+				// Get string for Other text field, if needed
518 518
 				$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
519 519
 				require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
520
-            } else {
520
+			} else {
521 521
 				require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
522
-            }
523
-        }
524
-    }
522
+			}
523
+		}
524
+	}
525 525
 
526 526
 	public static function get_term_link( $tax_id ) {
527
-        $tax = get_taxonomy($tax_id);
528
-        if ( ! $tax ) {
529
-            return;
530
-        }
527
+		$tax = get_taxonomy($tax_id);
528
+		if ( ! $tax ) {
529
+			return;
530
+		}
531 531
 
532
-        $link = sprintf(
533
-            __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
532
+		$link = sprintf(
533
+			__( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
534 534
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
535
-        );
536
-        unset($tax);
535
+		);
536
+		unset($tax);
537 537
 
538
-        return $link;
539
-    }
538
+		return $link;
539
+	}
540 540
 
541 541
 	public static function value_meets_condition( $observed_value, $cond, $hide_opt ) {
542 542
 		// Remove white space from hide_opt
@@ -547,199 +547,199 @@  discard block
 block discarded – undo
547 547
 		$observed_value = wp_kses_post( $observed_value );
548 548
 		$hide_opt = wp_kses_post( $hide_opt );
549 549
 
550
-        if ( is_array($observed_value) ) {
551
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
552
-        }
553
-
554
-        $m = false;
555
-        if ( $cond == '==' ) {
556
-            $m = $observed_value == $hide_opt;
557
-        } else if ( $cond == '!=' ) {
558
-            $m = $observed_value != $hide_opt;
559
-        } else if ( $cond == '>' ) {
560
-            $m = $observed_value > $hide_opt;
561
-        } else if ( $cond == '<' ) {
562
-            $m = $observed_value < $hide_opt;
563
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
564
-            $m = stripos($observed_value, $hide_opt);
565
-            if ( $cond == 'not LIKE' ) {
566
-                $m = ( $m === false ) ? true : false;
567
-            } else {
568
-                $m = ( $m === false ) ? false : true;
569
-            }
570
-        }
571
-        return $m;
572
-    }
550
+		if ( is_array($observed_value) ) {
551
+			return self::array_value_condition($observed_value, $cond, $hide_opt);
552
+		}
553
+
554
+		$m = false;
555
+		if ( $cond == '==' ) {
556
+			$m = $observed_value == $hide_opt;
557
+		} else if ( $cond == '!=' ) {
558
+			$m = $observed_value != $hide_opt;
559
+		} else if ( $cond == '>' ) {
560
+			$m = $observed_value > $hide_opt;
561
+		} else if ( $cond == '<' ) {
562
+			$m = $observed_value < $hide_opt;
563
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
564
+			$m = stripos($observed_value, $hide_opt);
565
+			if ( $cond == 'not LIKE' ) {
566
+				$m = ( $m === false ) ? true : false;
567
+			} else {
568
+				$m = ( $m === false ) ? false : true;
569
+			}
570
+		}
571
+		return $m;
572
+	}
573 573
 
574 574
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
575
-        $m = false;
576
-        if ( $cond == '==' ) {
577
-            if ( is_array($hide_opt) ) {
578
-                $m = array_intersect($hide_opt, $observed_value);
579
-                $m = empty($m) ? false : true;
580
-            } else {
581
-                $m = in_array($hide_opt, $observed_value);
582
-            }
583
-        } else if ( $cond == '!=' ) {
584
-            $m = ! in_array($hide_opt, $observed_value);
585
-        } else if ( $cond == '>' ) {
586
-            $min = min($observed_value);
587
-            $m = $min > $hide_opt;
588
-        } else if ( $cond == '<' ) {
589
-            $max = max($observed_value);
590
-            $m = $max < $hide_opt;
591
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
592
-            foreach ( $observed_value as $ob ) {
593
-                $m = strpos($ob, $hide_opt);
594
-                if ( $m !== false ) {
595
-                    $m = true;
596
-                    break;
597
-                }
598
-            }
599
-
600
-            if ( $cond == 'not LIKE' ) {
601
-                $m = ( $m === false ) ? true : false;
602
-            }
603
-        }
604
-
605
-        return $m;
606
-    }
607
-
608
-    /**
609
-     * Replace a few basic shortcodes and field ids
610
-     * @since 2.0
611
-     * @return string
612
-     */
575
+		$m = false;
576
+		if ( $cond == '==' ) {
577
+			if ( is_array($hide_opt) ) {
578
+				$m = array_intersect($hide_opt, $observed_value);
579
+				$m = empty($m) ? false : true;
580
+			} else {
581
+				$m = in_array($hide_opt, $observed_value);
582
+			}
583
+		} else if ( $cond == '!=' ) {
584
+			$m = ! in_array($hide_opt, $observed_value);
585
+		} else if ( $cond == '>' ) {
586
+			$min = min($observed_value);
587
+			$m = $min > $hide_opt;
588
+		} else if ( $cond == '<' ) {
589
+			$max = max($observed_value);
590
+			$m = $max < $hide_opt;
591
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
592
+			foreach ( $observed_value as $ob ) {
593
+				$m = strpos($ob, $hide_opt);
594
+				if ( $m !== false ) {
595
+					$m = true;
596
+					break;
597
+				}
598
+			}
599
+
600
+			if ( $cond == 'not LIKE' ) {
601
+				$m = ( $m === false ) ? true : false;
602
+			}
603
+		}
604
+
605
+		return $m;
606
+	}
607
+
608
+	/**
609
+	 * Replace a few basic shortcodes and field ids
610
+	 * @since 2.0
611
+	 * @return string
612
+	 */
613 613
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
614
-        if ( strpos($value, '[sitename]') !== false ) {
615
-            $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
616
-            $value = str_replace('[sitename]', $new_value, $value);
617
-        }
614
+		if ( strpos($value, '[sitename]') !== false ) {
615
+			$new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
616
+			$value = str_replace('[sitename]', $new_value, $value);
617
+		}
618 618
 
619
-        $value = apply_filters('frm_content', $value, $form, $entry);
620
-        $value = do_shortcode($value);
619
+		$value = apply_filters('frm_content', $value, $form, $entry);
620
+		$value = do_shortcode($value);
621 621
 
622
-        return $value;
623
-    }
622
+		return $value;
623
+	}
624 624
 
625 625
 	public static function get_shortcodes( $content, $form_id ) {
626
-        if ( FrmAppHelper::pro_is_installed() ) {
627
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
628
-        }
626
+		if ( FrmAppHelper::pro_is_installed() ) {
627
+			return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
628
+		}
629 629
 
630
-        $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
630
+		$fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
631 631
 
632
-        $tagregexp = self::allowed_shortcodes($fields);
632
+		$tagregexp = self::allowed_shortcodes($fields);
633 633
 
634
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
634
+		preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
635 635
 
636
-        return $matches;
637
-    }
636
+		return $matches;
637
+	}
638 638
 
639 639
 	public static function allowed_shortcodes( $fields = array() ) {
640
-        $tagregexp = array(
641
-            'editlink', 'id', 'key', 'ip',
642
-            'siteurl', 'sitename', 'admin_email',
643
-            'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
640
+		$tagregexp = array(
641
+			'editlink', 'id', 'key', 'ip',
642
+			'siteurl', 'sitename', 'admin_email',
643
+			'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
644 644
 			'parent[-|_]id',
645
-        );
645
+		);
646 646
 
647
-        foreach ( $fields as $field ) {
648
-            $tagregexp[] = $field->id;
649
-            $tagregexp[] = $field->field_key;
650
-        }
647
+		foreach ( $fields as $field ) {
648
+			$tagregexp[] = $field->id;
649
+			$tagregexp[] = $field->field_key;
650
+		}
651 651
 
652
-        $tagregexp = implode('|', $tagregexp);
653
-        return $tagregexp;
654
-    }
652
+		$tagregexp = implode('|', $tagregexp);
653
+		return $tagregexp;
654
+	}
655 655
 
656 656
 	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
657
-        $shortcode_values = array(
658
-           'id'     => $entry->id,
659
-           'key'    => $entry->item_key,
660
-           'ip'     => $entry->ip,
661
-        );
657
+		$shortcode_values = array(
658
+		   'id'     => $entry->id,
659
+		   'key'    => $entry->item_key,
660
+		   'ip'     => $entry->ip,
661
+		);
662 662
 
663
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
663
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
664 664
 			if ( empty( $tag ) ) {
665 665
 				continue;
666 666
 			}
667 667
 
668
-            $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] );
668
+			$atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] );
669 669
 
670
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
670
+			if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
671 671
 				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
672
-                $tags = explode(' ', $tag);
673
-                if ( is_array($tags) ) {
674
-                    $tag = $tags[0];
675
-                }
676
-            } else {
677
-                $tag = $shortcodes[2][ $short_key ];
678
-            }
679
-
680
-            switch ( $tag ) {
681
-                case 'id':
682
-                case 'key':
683
-                case 'ip':
684
-                    $replace_with = $shortcode_values[ $tag ];
685
-                break;
686
-
687
-                case 'user_agent':
688
-                case 'user-agent':
689
-                    $entry->description = maybe_unserialize($entry->description);
672
+				$tags = explode(' ', $tag);
673
+				if ( is_array($tags) ) {
674
+					$tag = $tags[0];
675
+				}
676
+			} else {
677
+				$tag = $shortcodes[2][ $short_key ];
678
+			}
679
+
680
+			switch ( $tag ) {
681
+				case 'id':
682
+				case 'key':
683
+				case 'ip':
684
+					$replace_with = $shortcode_values[ $tag ];
685
+				break;
686
+
687
+				case 'user_agent':
688
+				case 'user-agent':
689
+					$entry->description = maybe_unserialize($entry->description);
690 690
 					$replace_with = FrmEntriesHelper::get_browser( $entry->description['browser'] );
691
-                break;
692
-
693
-                case 'created_at':
694
-                case 'created-at':
695
-                case 'updated_at':
696
-                case 'updated-at':
697
-                    if ( isset($atts['format']) ) {
698
-                        $time_format = ' ';
699
-                    } else {
700
-                        $atts['format'] = get_option('date_format');
701
-                        $time_format = '';
702
-                    }
703
-
704
-                    $this_tag = str_replace('-', '_', $tag);
705
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
706
-                    unset($this_tag);
707
-                break;
708
-
709
-                case 'created_by':
710
-                case 'created-by':
711
-                case 'updated_by':
712
-                case 'updated-by':
713
-                    $this_tag = str_replace('-', '_', $tag);
691
+				break;
692
+
693
+				case 'created_at':
694
+				case 'created-at':
695
+				case 'updated_at':
696
+				case 'updated-at':
697
+					if ( isset($atts['format']) ) {
698
+						$time_format = ' ';
699
+					} else {
700
+						$atts['format'] = get_option('date_format');
701
+						$time_format = '';
702
+					}
703
+
704
+					$this_tag = str_replace('-', '_', $tag);
705
+					$replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
706
+					unset($this_tag);
707
+				break;
708
+
709
+				case 'created_by':
710
+				case 'created-by':
711
+				case 'updated_by':
712
+				case 'updated-by':
713
+					$this_tag = str_replace('-', '_', $tag);
714 714
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
715
-                    unset($this_tag);
716
-                break;
717
-
718
-                case 'admin_email':
719
-                case 'siteurl':
720
-                case 'frmurl':
721
-                case 'sitename':
722
-                case 'get':
723
-                    $replace_with = self::dynamic_default_values( $tag, $atts );
724
-                break;
725
-
726
-                default:
727
-                    $field = FrmField::getOne( $tag );
728
-                    if ( ! $field ) {
729
-                        break;
730
-                    }
731
-
732
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
733
-
734
-                    $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
735
-
736
-                    $atts['entry_id'] = $entry->id;
737
-                    $atts['entry_key'] = $entry->item_key;
738
-
739
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
740
-                        $replace_with = $field->name;
741
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
742
-                        $replace_with = $field->description;
715
+					unset($this_tag);
716
+				break;
717
+
718
+				case 'admin_email':
719
+				case 'siteurl':
720
+				case 'frmurl':
721
+				case 'sitename':
722
+				case 'get':
723
+					$replace_with = self::dynamic_default_values( $tag, $atts );
724
+				break;
725
+
726
+				default:
727
+					$field = FrmField::getOne( $tag );
728
+					if ( ! $field ) {
729
+						break;
730
+					}
731
+
732
+					$sep = isset($atts['sep']) ? $atts['sep'] : ', ';
733
+
734
+					$replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
735
+
736
+					$atts['entry_id'] = $entry->id;
737
+					$atts['entry_key'] = $entry->item_key;
738
+
739
+					if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
740
+						$replace_with = $field->name;
741
+					} else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
742
+						$replace_with = $field->description;
743 743
 					} else {
744 744
 						$string_value = $replace_with;
745 745
 						if ( is_array( $replace_with ) ) {
@@ -753,82 +753,82 @@  discard block
 block discarded – undo
753 753
 						}
754 754
 					}
755 755
 
756
-                    unset($field);
757
-                break;
758
-            }
756
+					unset($field);
757
+				break;
758
+			}
759 759
 
760
-            if ( isset($replace_with) ) {
761
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
762
-            }
760
+			if ( isset($replace_with) ) {
761
+				$content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
762
+			}
763 763
 
764
-            unset($atts, $conditional, $replace_with);
764
+			unset($atts, $conditional, $replace_with);
765 765
 		}
766 766
 
767 767
 		return $content;
768
-    }
769
-
770
-    /**
771
-     * Get the value to replace a few standard shortcodes
772
-     *
773
-     * @since 2.0
774
-     * @return string
775
-     */
776
-    public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
777
-        $new_value = '';
778
-        switch ( $tag ) {
779
-            case 'admin_email':
780
-                $new_value = get_option('admin_email');
781
-                break;
782
-            case 'siteurl':
783
-                $new_value = FrmAppHelper::site_url();
784
-                break;
785
-            case 'frmurl':
786
-                $new_value = FrmAppHelper::plugin_url();
787
-                break;
788
-            case 'sitename':
789
-                $new_value = FrmAppHelper::site_name();
790
-                break;
791
-            case 'get':
792
-                $new_value = self::process_get_shortcode( $atts, $return_array );
793
-                break;
794
-        }
795
-
796
-        return $new_value;
797
-    }
798
-
799
-    /**
800
-     * Process the [get] shortcode
801
-     *
802
-     * @since 2.0
803
-     * @return string|array
804
-     */
805
-    public static function process_get_shortcode( $atts, $return_array = false ) {
806
-        if ( ! isset($atts['param']) ) {
807
-            return '';
808
-        }
809
-
810
-        if ( strpos($atts['param'], '&#91;') ) {
811
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
812
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
813
-        }
814
-
815
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
816
-        $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
817
-
818
-        if ( $new_value == '' ) {
819
-            if ( ! isset($atts['prev_val']) ) {
820
-                $atts['prev_val'] = '';
821
-            }
822
-
823
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
824
-        }
825
-
826
-        if ( is_array($new_value) && ! $return_array ) {
827
-            $new_value = implode(', ', $new_value);
828
-        }
829
-
830
-        return $new_value;
831
-    }
768
+	}
769
+
770
+	/**
771
+	 * Get the value to replace a few standard shortcodes
772
+	 *
773
+	 * @since 2.0
774
+	 * @return string
775
+	 */
776
+	public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
777
+		$new_value = '';
778
+		switch ( $tag ) {
779
+			case 'admin_email':
780
+				$new_value = get_option('admin_email');
781
+				break;
782
+			case 'siteurl':
783
+				$new_value = FrmAppHelper::site_url();
784
+				break;
785
+			case 'frmurl':
786
+				$new_value = FrmAppHelper::plugin_url();
787
+				break;
788
+			case 'sitename':
789
+				$new_value = FrmAppHelper::site_name();
790
+				break;
791
+			case 'get':
792
+				$new_value = self::process_get_shortcode( $atts, $return_array );
793
+				break;
794
+		}
795
+
796
+		return $new_value;
797
+	}
798
+
799
+	/**
800
+	 * Process the [get] shortcode
801
+	 *
802
+	 * @since 2.0
803
+	 * @return string|array
804
+	 */
805
+	public static function process_get_shortcode( $atts, $return_array = false ) {
806
+		if ( ! isset($atts['param']) ) {
807
+			return '';
808
+		}
809
+
810
+		if ( strpos($atts['param'], '&#91;') ) {
811
+			$atts['param'] = str_replace('&#91;', '[', $atts['param']);
812
+			$atts['param'] = str_replace('&#93;', ']', $atts['param']);
813
+		}
814
+
815
+		$new_value = FrmAppHelper::get_param($atts['param'], '');
816
+		$new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
817
+
818
+		if ( $new_value == '' ) {
819
+			if ( ! isset($atts['prev_val']) ) {
820
+				$atts['prev_val'] = '';
821
+			}
822
+
823
+			$new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
824
+		}
825
+
826
+		if ( is_array($new_value) && ! $return_array ) {
827
+			$new_value = implode(', ', $new_value);
828
+		}
829
+
830
+		return $new_value;
831
+	}
832 832
 
833 833
 	public static function get_display_value( $replace_with, $field, $atts = array() ) {
834 834
 		$sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
@@ -836,14 +836,14 @@  discard block
 block discarded – undo
836 836
 		$replace_with = apply_filters( 'frm_get_' . $field->type . '_display_value', $replace_with, $field, $atts );
837 837
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
838 838
 
839
-        if ( $field->type == 'textarea' || $field->type == 'rte' ) {
840
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
841
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
842
-                if ( is_array($replace_with) ) {
843
-                    $replace_with = implode("\n", $replace_with);
844
-                }
845
-                $replace_with = wpautop($replace_with);
846
-            }
839
+		if ( $field->type == 'textarea' || $field->type == 'rte' ) {
840
+			$autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
841
+			if ( apply_filters('frm_use_wpautop', $autop) ) {
842
+				if ( is_array($replace_with) ) {
843
+					$replace_with = implode("\n", $replace_with);
844
+				}
845
+				$replace_with = wpautop($replace_with);
846
+			}
847 847
 			unset( $autop );
848 848
 		} else if ( is_array( $replace_with ) ) {
849 849
 			if ( $atts['show'] && isset( $replace_with[ $atts['show'] ] ) ) {
@@ -857,37 +857,37 @@  discard block
 block discarded – undo
857 857
 	}
858 858
 
859 859
 	public static function get_field_types( $type ) {
860
-        $single_input = array(
861
-            'text', 'textarea', 'rte', 'number', 'email', 'url',
862
-            'image', 'file', 'date', 'phone', 'hidden', 'time',
863
-            'user_id', 'tag', 'password',
864
-        );
860
+		$single_input = array(
861
+			'text', 'textarea', 'rte', 'number', 'email', 'url',
862
+			'image', 'file', 'date', 'phone', 'hidden', 'time',
863
+			'user_id', 'tag', 'password',
864
+		);
865 865
 		$multiple_input = array( 'radio', 'checkbox', 'select', 'scale', 'lookup' );
866 866
 		$other_type = array( 'html', 'break' );
867 867
 
868 868
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
869 869
 
870
-        $field_types = array();
871
-        if ( in_array($type, $single_input) ) {
872
-            self::field_types_for_input( $single_input, $field_selection, $field_types );
873
-        } else if ( in_array($type, $multiple_input) ) {
874
-            self::field_types_for_input( $multiple_input, $field_selection, $field_types );
875
-        } else if ( in_array($type, $other_type) ) {
876
-            self::field_types_for_input( $other_type, $field_selection, $field_types );
870
+		$field_types = array();
871
+		if ( in_array($type, $single_input) ) {
872
+			self::field_types_for_input( $single_input, $field_selection, $field_types );
873
+		} else if ( in_array($type, $multiple_input) ) {
874
+			self::field_types_for_input( $multiple_input, $field_selection, $field_types );
875
+		} else if ( in_array($type, $other_type) ) {
876
+			self::field_types_for_input( $other_type, $field_selection, $field_types );
877 877
 		} else if ( isset( $field_selection[ $type ] ) ) {
878
-            $field_types[ $type ] = $field_selection[ $type ];
879
-        }
878
+			$field_types[ $type ] = $field_selection[ $type ];
879
+		}
880 880
 
881 881
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
882
-        return $field_types;
883
-    }
882
+		return $field_types;
883
+	}
884 884
 
885
-    private static function field_types_for_input( $inputs, $fields, &$field_types ) {
886
-        foreach ( $inputs as $input ) {
887
-            $field_types[ $input ] = $fields[ $input ];
888
-            unset($input);
889
-        }
890
-    }
885
+	private static function field_types_for_input( $inputs, $fields, &$field_types ) {
886
+		foreach ( $inputs as $input ) {
887
+			$field_types[ $input ] = $fields[ $input ];
888
+			unset($input);
889
+		}
890
+	}
891 891
 
892 892
 	/**
893 893
 	 * Check if current field option is an "other" option
@@ -901,14 +901,14 @@  discard block
 block discarded – undo
901 901
 		return $opt_key && strpos( $opt_key, 'other_' ) === 0;
902 902
 	}
903 903
 
904
-    /**
905
-    * Get value that belongs in "Other" text box
906
-    *
907
-    * @since 2.0.6
908
-    *
909
-    * @param array $args
910
-    */
911
-    public static function get_other_val( $args ) {
904
+	/**
905
+	 * Get value that belongs in "Other" text box
906
+	 *
907
+	 * @since 2.0.6
908
+	 *
909
+	 * @param array $args
910
+	 */
911
+	public static function get_other_val( $args ) {
912 912
 		$defaults = array(
913 913
 			'opt_key' => 0, 'field' => array(),
914 914
 			'parent' => false, 'pointer' => false,
@@ -984,20 +984,20 @@  discard block
 block discarded – undo
984 984
 		}
985 985
 
986 986
 		return $other_val;
987
-    }
988
-
989
-    /**
990
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
991
-    * Intended for front-end use
992
-    *
993
-    * @since 2.0.6
994
-    *
995
-    * @param array $args should include field, opt_key and field name
996
-    * @param boolean $other_opt
997
-    * @param string $checked
998
-    * @return string $other_val
999
-    */
1000
-    public static function prepare_other_input( $args, &$other_opt, &$checked ) {
987
+	}
988
+
989
+	/**
990
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
991
+	 * Intended for front-end use
992
+	 *
993
+	 * @since 2.0.6
994
+	 *
995
+	 * @param array $args should include field, opt_key and field name
996
+	 * @param boolean $other_opt
997
+	 * @param string $checked
998
+	 * @return string $other_val
999
+	 */
1000
+	public static function prepare_other_input( $args, &$other_opt, &$checked ) {
1001 1001
 		//Check if this is an "Other" option
1002 1002
 		if ( ! self::is_other_opt( $args['opt_key'] ) ) {
1003 1003
 			return;
@@ -1013,8 +1013,8 @@  discard block
 block discarded – undo
1013 1013
 			$checked = 'checked="checked" ';
1014 1014
 		}
1015 1015
 
1016
-        return $other_args;
1017
-    }
1016
+		return $other_args;
1017
+	}
1018 1018
 
1019 1019
 	/**
1020 1020
 	 * @param array $args
@@ -1064,8 +1064,8 @@  discard block
 block discarded – undo
1064 1064
 	 * @since 2.0.6
1065 1065
 	 */
1066 1066
 	public static function include_other_input( $args ) {
1067
-        if ( ! $args['other_opt'] ) {
1068
-        	return;
1067
+		if ( ! $args['other_opt'] ) {
1068
+			return;
1069 1069
 		}
1070 1070
 
1071 1071
 		$classes = array( 'frm_other_input' );
@@ -1086,15 +1086,15 @@  discard block
 block discarded – undo
1086 1086
 	}
1087 1087
 
1088 1088
 	/**
1089
-	* Get the HTML id for an "Other" text field
1090
-	* Note: This does not affect fields in repeating sections
1091
-	*
1092
-	* @since 2.0.08
1093
-	* @param string $type - field type
1094
-	* @param string $html_id
1095
-	* @param string|boolean $opt_key
1096
-	* @return string $other_id
1097
-	*/
1089
+	 * Get the HTML id for an "Other" text field
1090
+	 * Note: This does not affect fields in repeating sections
1091
+	 *
1092
+	 * @since 2.0.08
1093
+	 * @param string $type - field type
1094
+	 * @param string $html_id
1095
+	 * @param string|boolean $opt_key
1096
+	 * @return string $other_id
1097
+	 */
1098 1098
 	public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) {
1099 1099
 		$other_id = $html_id;
1100 1100
 
@@ -1152,10 +1152,10 @@  discard block
 block discarded – undo
1152 1152
 	}
1153 1153
 
1154 1154
 	public static function switch_field_ids( $val ) {
1155
-        global $frm_duplicate_ids;
1156
-        $replace = array();
1157
-        $replace_with = array();
1158
-        foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1155
+		global $frm_duplicate_ids;
1156
+		$replace = array();
1157
+		$replace_with = array();
1158
+		foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1159 1159
 			$replace[] = '[if ' . $old . ']';
1160 1160
 			$replace_with[] = '[if ' . $new . ']';
1161 1161
 			$replace[] = '[if ' . $old . ' ';
@@ -1170,153 +1170,153 @@  discard block
 block discarded – undo
1170 1170
 			$replace_with[] = '[' . $new . ']';
1171 1171
 			$replace[] = '[' . $old . ' ';
1172 1172
 			$replace_with[] = '[' . $new . ' ';
1173
-            unset($old, $new);
1174
-        }
1173
+			unset($old, $new);
1174
+		}
1175 1175
 		if ( is_array( $val ) ) {
1176 1176
 			foreach ( $val as $k => $v ) {
1177
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1178
-                unset($k, $v);
1179
-            }
1180
-        } else {
1181
-            $val = str_replace($replace, $replace_with, $val);
1182
-        }
1183
-
1184
-        return $val;
1185
-    }
1186
-
1187
-    public static function get_us_states() {
1188
-        return apply_filters( 'frm_us_states', array(
1189
-            'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1190
-            'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1191
-            'DC' => 'District of Columbia',
1192
-            'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1193
-            'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1194
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1195
-            'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1196
-            'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1197
-            'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1198
-            'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1199
-            'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1200
-            'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1201
-            'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1202
-            'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1203
-        ) );
1204
-    }
1205
-
1206
-    public static function get_countries() {
1207
-        return apply_filters( 'frm_countries', array(
1208
-            __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1209
-            __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1210
-            __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1211
-            __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1212
-            __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1213
-            __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1214
-            __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1215
-            __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1216
-            __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1217
-            __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1218
-            __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1219
-            __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1220
-            __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1221
-            __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1222
-            __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1223
-            __( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1224
-            __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1225
-            __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1226
-            __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1227
-            __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1228
-            __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1229
-            __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1230
-            __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1231
-            __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1232
-            __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1233
-            __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1234
-            __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1235
-            __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1236
-            __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1237
-            __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1238
-            __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1239
-            __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1240
-            __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1241
-            __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1242
-            __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1243
-            __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1244
-            __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1245
-            __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1246
-            __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1247
-            __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1248
-            __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1249
-            __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1250
-            __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1251
-            __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1252
-            __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1253
-            __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1254
-            __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1255
-            __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1256
-            __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1257
-            __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1258
-            __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1259
-            __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1260
-            __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1261
-            __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1262
-            __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1263
-            __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1264
-            __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1265
-            __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1266
-            __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1267
-            __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1268
-            __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1269
-            __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1270
-            __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1271
-            __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1272
-            __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1273
-            __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1274
-            __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1275
-            __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1276
-            __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1277
-            __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1278
-            __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1279
-            __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1280
-            __( 'Zimbabwe', 'formidable' ),
1281
-        ) );
1282
-    }
1177
+				$val[ $k ] = str_replace( $replace, $replace_with, $v );
1178
+				unset($k, $v);
1179
+			}
1180
+		} else {
1181
+			$val = str_replace($replace, $replace_with, $val);
1182
+		}
1183
+
1184
+		return $val;
1185
+	}
1186
+
1187
+	public static function get_us_states() {
1188
+		return apply_filters( 'frm_us_states', array(
1189
+			'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1190
+			'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1191
+			'DC' => 'District of Columbia',
1192
+			'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1193
+			'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1194
+			'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1195
+			'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1196
+			'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1197
+			'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1198
+			'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1199
+			'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1200
+			'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1201
+			'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1202
+			'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1203
+		) );
1204
+	}
1205
+
1206
+	public static function get_countries() {
1207
+		return apply_filters( 'frm_countries', array(
1208
+			__( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1209
+			__( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1210
+			__( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1211
+			__( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1212
+			__( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1213
+			__( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1214
+			__( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1215
+			__( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1216
+			__( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1217
+			__( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1218
+			__( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1219
+			__( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1220
+			__( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1221
+			__( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1222
+			__( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1223
+			__( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1224
+			__( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1225
+			__( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1226
+			__( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1227
+			__( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1228
+			__( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1229
+			__( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1230
+			__( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1231
+			__( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1232
+			__( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1233
+			__( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1234
+			__( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1235
+			__( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1236
+			__( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1237
+			__( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1238
+			__( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1239
+			__( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1240
+			__( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1241
+			__( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1242
+			__( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1243
+			__( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1244
+			__( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1245
+			__( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1246
+			__( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1247
+			__( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1248
+			__( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1249
+			__( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1250
+			__( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1251
+			__( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1252
+			__( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1253
+			__( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1254
+			__( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1255
+			__( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1256
+			__( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1257
+			__( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1258
+			__( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1259
+			__( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1260
+			__( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1261
+			__( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1262
+			__( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1263
+			__( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1264
+			__( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1265
+			__( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1266
+			__( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1267
+			__( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1268
+			__( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1269
+			__( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1270
+			__( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1271
+			__( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1272
+			__( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1273
+			__( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1274
+			__( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1275
+			__( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1276
+			__( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1277
+			__( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1278
+			__( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1279
+			__( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1280
+			__( 'Zimbabwe', 'formidable' ),
1281
+		) );
1282
+	}
1283 1283
 
1284 1284
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1285 1285
 		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1286 1286
 
1287
-        $states = FrmFieldsHelper::get_us_states();
1288
-        $state_abv = array_keys($states);
1289
-        sort($state_abv);
1287
+		$states = FrmFieldsHelper::get_us_states();
1288
+		$state_abv = array_keys($states);
1289
+		sort($state_abv);
1290 1290
 		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1291 1291
 
1292
-        $states = array_values($states);
1293
-        sort($states);
1292
+		$states = array_values($states);
1293
+		sort($states);
1294 1294
 		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1295
-        unset($state_abv, $states);
1295
+		unset($state_abv, $states);
1296 1296
 
1297 1297
 		$prepop[ __( 'Age', 'formidable' ) ] = array(
1298
-            __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1299
-            __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1300
-            __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1301
-        );
1298
+			__( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1299
+			__( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1300
+			__( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1301
+		);
1302 1302
 
1303 1303
 		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1304
-            __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1305
-            __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1306
-        );
1304
+			__( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1305
+			__( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1306
+		);
1307 1307
 
1308 1308
 		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1309
-            __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1310
-            __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1311
-        );
1309
+			__( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1310
+			__( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1311
+		);
1312 1312
 
1313 1313
 		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1314
-            __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1315
-            __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1316
-        );
1314
+			__( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1315
+			__( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1316
+		);
1317 1317
 
1318 1318
 		$prepop = apply_filters( 'frm_bulk_field_choices', $prepop );
1319
-    }
1319
+	}
1320 1320
 
1321 1321
 	/**
1322 1322
 	 * Display a field value selector
@@ -1326,10 +1326,10 @@  discard block
 block discarded – undo
1326 1326
 	 * @param int $selector_field_id
1327 1327
 	 * @param array $selector_args
1328 1328
 	 */
1329
-    public static function display_field_value_selector( $selector_field_id, $selector_args ) {
1330
-	    $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args );
1331
-	    $field_value_selector->display();
1332
-    }
1329
+	public static function display_field_value_selector( $selector_field_id, $selector_args ) {
1330
+		$field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args );
1331
+		$field_value_selector->display();
1332
+	}
1333 1333
 
1334 1334
 	/**
1335 1335
 	 * Convert a field object to a flat array
@@ -1382,10 +1382,10 @@  discard block
 block discarded – undo
1382 1382
 		return FrmField::is_required( $field );
1383 1383
 	}
1384 1384
 
1385
-    public static function maybe_get_field( &$field ) {
1385
+	public static function maybe_get_field( &$field ) {
1386 1386
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' );
1387 1387
 		FrmField::maybe_get_field( $field );
1388
-    }
1388
+	}
1389 1389
 
1390 1390
 	public static function dropdown_categories( $args ) {
1391 1391
 		_deprecated_function( __FUNCTION__, '2.02.07', 'FrmProPost::get_category_dropdown' );
Please login to merge, or discard this patch.
Spacing   +164 added lines, -164 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 ( in_array( $type, array( 'data', 'lookup' ) ) ) {
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
 
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
         }
58 58
 
59 59
 		$fields = FrmField::field_selection();
60
-        $fields = array_merge($fields, FrmField::pro_field_selection());
60
+        $fields = array_merge( $fields, FrmField::pro_field_selection() );
61 61
 
62
-        if ( isset( $fields[ $type ] ) ) {
63
-            $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
62
+        if ( isset( $fields[$type] ) ) {
63
+            $values['name'] = is_array( $fields[$type] ) ? $fields[$type]['name'] : $fields[$type];
64 64
         }
65 65
 
66
-        unset($fields);
66
+        unset( $fields );
67 67
 
68 68
         return $values;
69 69
     }
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
             $values['form_name'] = '';
90 90
 		} else {
91 91
 			foreach ( $defaults as $var => $default ) {
92
-                $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
93
-                unset($var, $default);
92
+                $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
93
+                unset( $var, $default );
94 94
             }
95 95
 
96 96
 			$values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : '';
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         $values['options'] = $record->options;
102 102
         $values['field_options'] = $record->field_options;
103 103
 
104
-        $defaults = self::get_default_field_opts($values['type'], $record, true);
104
+        $defaults = self::get_default_field_opts( $values['type'], $record, true );
105 105
 
106 106
 		if ( $values['type'] == 'captcha' ) {
107 107
             $frm_settings = FrmAppHelper::get_settings();
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
         }
110 110
 
111 111
 		foreach ( $defaults as $opt => $default ) {
112
-            $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
113
-            unset($opt, $default);
112
+            $values[$opt] = isset( $record->field_options[$opt] ) ? $record->field_options[$opt] : $default;
113
+            unset( $opt, $default );
114 114
         }
115 115
 
116
-        $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
116
+        $values['custom_html'] = ( isset( $record->field_options['custom_html'] ) ) ? $record->field_options['custom_html'] : self::get_default_html( $record->type );
117 117
 
118 118
 		return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) );
119 119
     }
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 
133 133
         global $wpdb;
134 134
 
135
-        $form_id = (is_numeric($field)) ? $field : $field->form_id;
135
+        $form_id = ( is_numeric( $field ) ) ? $field : $field->form_id;
136 136
 
137 137
 		$key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key;
138 138
 
@@ -154,11 +154,11 @@  discard block
 block discarded – undo
154 154
 
155 155
 		$values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
156 156
         $values['form_id'] = $form_id;
157
-        $values['options'] = maybe_serialize($field->options);
158
-        $values['default_value'] = maybe_serialize($field->default_value);
157
+        $values['options'] = maybe_serialize( $field->options );
158
+        $values['default_value'] = maybe_serialize( $field->default_value );
159 159
 
160 160
         foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
161
-            $values[ $col ] = $field->{$col};
161
+            $values[$col] = $field->{$col};
162 162
         }
163 163
     }
164 164
 
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
 
173 173
 		$conf_msg = __( 'The entered values do not match', 'formidable' );
174 174
 		$defaults = array(
175
-			'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __('%s must be unique', 'formidable' ), $field_name ) ),
176
-			'invalid'   => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __('%s is invalid', 'formidable' ), $field_name ) ),
175
+			'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __( '%s must be unique', 'formidable' ), $field_name ) ),
176
+			'invalid'   => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __( '%s is invalid', 'formidable' ), $field_name ) ),
177 177
 			'blank'     => array( 'full' => $frm_settings->blank_msg, 'part' => $frm_settings->blank_msg ),
178 178
 			'conf_msg'  => array( 'full' => $conf_msg, 'part' => $conf_msg ),
179 179
 		);
180 180
 
181 181
 		$msg = FrmField::get_option( $field, $error );
182
-		$msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg;
182
+		$msg = empty( $msg ) ? $defaults[$error]['part'] : $msg;
183 183
 		$msg = do_shortcode( $msg );
184 184
 		return $msg;
185 185
 	}
@@ -209,14 +209,14 @@  discard block
 block discarded – undo
209 209
 </div>
210 210
 DEFAULT_HTML;
211 211
         } else {
212
-			$default_html = apply_filters('frm_other_custom_html', '', $type);
212
+			$default_html = apply_filters( 'frm_other_custom_html', '', $type );
213 213
         }
214 214
 
215
-        return apply_filters('frm_custom_html', $default_html, $type);
215
+        return apply_filters( 'frm_custom_html', $default_html, $type );
216 216
     }
217 217
 
218 218
 	public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) {
219
-        $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
219
+        $html = apply_filters( 'frm_before_replace_shortcodes', $html, $field, $errors, $form );
220 220
 
221 221
         $defaults = array(
222 222
 			'field_name'    => 'item_meta[' . $field['id'] . ']',
@@ -224,42 +224,42 @@  discard block
 block discarded – undo
224 224
             'field_plus_id' => '',
225 225
             'section_id'    => '',
226 226
         );
227
-        $args = wp_parse_args($args, $defaults);
227
+        $args = wp_parse_args( $args, $defaults );
228 228
         $field_name = $args['field_name'];
229 229
         $field_id = $args['field_id'];
230
-        $html_id = self::get_html_id($field, $args['field_plus_id']);
230
+        $html_id = self::get_html_id( $field, $args['field_plus_id'] );
231 231
 
232
-        if ( FrmField::is_multiple_select($field) ) {
232
+        if ( FrmField::is_multiple_select( $field ) ) {
233 233
             $field_name .= '[]';
234 234
         }
235 235
 
236 236
         //replace [id]
237
-        $html = str_replace('[id]', $field_id, $html);
237
+        $html = str_replace( '[id]', $field_id, $html );
238 238
 
239 239
         // Remove the for attribute for captcha
240 240
         if ( $field['type'] == 'captcha' ) {
241
-            $html = str_replace(' for="field_[key]"', '', $html);
241
+            $html = str_replace( ' for="field_[key]"', '', $html );
242 242
         }
243 243
 
244 244
         // set the label for
245
-        $html = str_replace('field_[key]', $html_id, $html);
245
+        $html = str_replace( 'field_[key]', $html_id, $html );
246 246
 
247 247
         //replace [key]
248
-        $html = str_replace('[key]', $field['field_key'], $html);
248
+        $html = str_replace( '[key]', $field['field_key'], $html );
249 249
 
250 250
         //replace [description] and [required_label] and [error]
251 251
 		$required = FrmField::is_required( $field ) ? $field['required_indicator'] : '';
252 252
         if ( ! is_array( $errors ) ) {
253 253
             $errors = array();
254 254
         }
255
-		$error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false;
255
+		$error = isset( $errors['field' . $field_id] ) ? $errors['field' . $field_id] : false;
256 256
 
257 257
         //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
258 258
         if ( $field['type'] == 'divider' ) {
259 259
             if ( FrmField::is_option_true( $field, 'description' ) ) {
260 260
                 $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
261 261
             } else {
262
-                $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
262
+                $html = str_replace( '[label_position]', '[label_position] frm_section_spacing', $html );
263 263
             }
264 264
         }
265 265
 
@@ -269,53 +269,53 @@  discard block
 block discarded – undo
269 269
 
270 270
         //replace [required_class]
271 271
 		$required_class = FrmField::is_required( $field ) ? ' frm_required_field' : '';
272
-        $html = str_replace('[required_class]', $required_class, $html);
272
+        $html = str_replace( '[required_class]', $required_class, $html );
273 273
 
274 274
         //replace [label_position]
275
-        $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
275
+        $field['label'] = apply_filters( 'frm_html_label_position', $field['label'], $field, $form );
276 276
         $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
277 277
 		$html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html );
278 278
 
279 279
         //replace [field_name]
280
-        $html = str_replace('[field_name]', $field['name'], $html);
280
+        $html = str_replace( '[field_name]', $field['name'], $html );
281 281
 
282 282
 		self::add_field_div_classes( $field_id, $field, $errors, $html );
283 283
 
284 284
         //replace [entry_key]
285 285
         $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
286
-        $html = str_replace('[entry_key]', $entry_key, $html);
286
+        $html = str_replace( '[entry_key]', $entry_key, $html );
287 287
 
288 288
 		if ( $form ) {
289 289
 			$form = (array) $form;
290 290
 
291 291
 			//replace [form_key]
292
-			$html = str_replace('[form_key]', $form['form_key'], $html);
292
+			$html = str_replace( '[form_key]', $form['form_key'], $html );
293 293
 
294 294
 			//replace [form_name]
295
-			$html = str_replace('[form_name]', $form['name'], $html);
295
+			$html = str_replace( '[form_name]', $form['name'], $html );
296 296
 		}
297 297
 
298 298
 		self::process_wp_shortcodes( $html );
299 299
 
300 300
         //replace [input]
301
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
301
+        preg_match_all( "/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER );
302 302
         global $frm_vars;
303 303
         $frm_settings = FrmAppHelper::get_settings();
304 304
 
305 305
         foreach ( $shortcodes[0] as $short_key => $tag ) {
306
-            $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
306
+            $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] );
307 307
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
308 308
 
309 309
             $replace_with = '';
310 310
 
311 311
             if ( $tag == 'input' ) {
312
-                if ( isset($atts['opt']) ) {
313
-                    $atts['opt']--;
312
+                if ( isset( $atts['opt'] ) ) {
313
+                    $atts['opt'] --;
314 314
                 }
315 315
 
316
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
317
-                if ( isset($atts['class']) ) {
318
-                    unset($atts['class']);
316
+                $field['input_class'] = isset( $atts['class'] ) ? $atts['class'] : '';
317
+                if ( isset( $atts['class'] ) ) {
318
+                    unset( $atts['class'] );
319 319
                 }
320 320
 
321 321
                 $field['shortcodes'] = $atts;
@@ -324,24 +324,24 @@  discard block
 block discarded – undo
324 324
                 $replace_with = ob_get_contents();
325 325
                 ob_end_clean();
326 326
             } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
327
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
327
+                $replace_with = FrmProEntriesController::entry_delete_link( $atts );
328 328
             }
329 329
 
330
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
330
+            $html = str_replace( $shortcodes[0][$short_key], $replace_with, $html );
331 331
         }
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 );
@@ -393,14 +393,14 @@  discard block
 block discarded – undo
393 393
 	 */
394 394
 	private static function get_field_div_classes( $field_id, $field, $errors, $html ) {
395 395
 		// Add error class
396
-		$classes = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : '';
396
+		$classes = isset( $errors['field' . $field_id] ) ? ' frm_blank_field' : '';
397 397
 
398 398
 		// Add label position class
399 399
 		$classes .= ' frm_' . $field['label'] . '_container';
400 400
 
401 401
 		// Add CSS layout classes
402 402
 		if ( ! empty( $field['classes'] ) ) {
403
-			if ( ! strpos( $html, 'frm_form_field ') ) {
403
+			if ( ! strpos( $html, 'frm_form_field ' ) ) {
404 404
 				$classes .= ' frm_form_field';
405 405
 			}
406 406
 			$classes .= ' ' . $field['classes'];
@@ -439,15 +439,15 @@  discard block
 block discarded – undo
439 439
         }
440 440
 
441 441
         $with_tags = $args['conditional_check'] ? 3 : 2;
442
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
443
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
444
-            $tag = str_replace(']', '', $tag);
445
-            $tags = explode(' ', $tag);
446
-            if ( is_array($tags) ) {
442
+        if ( ! empty( $shortcodes[$with_tags][$short_key] ) ) {
443
+            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][$short_key] );
444
+            $tag = str_replace( ']', '', $tag );
445
+            $tags = explode( ' ', $tag );
446
+            if ( is_array( $tags ) ) {
447 447
                 $tag = $tags[0];
448 448
             }
449 449
         } else {
450
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
450
+            $tag = $shortcodes[$with_tags - 1][$short_key];
451 451
         }
452 452
 
453 453
         return $tag;
@@ -507,10 +507,10 @@  discard block
 block discarded – undo
507 507
 
508 508
 	public static function show_single_option( $field ) {
509 509
         $field_name = $field['name'];
510
-        $html_id = self::get_html_id($field);
510
+        $html_id = self::get_html_id( $field );
511 511
         foreach ( $field['options'] as $opt_key => $opt ) {
512
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
513
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
512
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
513
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
514 514
 
515 515
             // If this is an "Other" option, get the HTML for it
516 516
 			if ( self::is_other_opt( $opt_key ) ) {
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
     }
525 525
 
526 526
 	public static function get_term_link( $tax_id ) {
527
-        $tax = get_taxonomy($tax_id);
527
+        $tax = get_taxonomy( $tax_id );
528 528
         if ( ! $tax ) {
529 529
             return;
530 530
         }
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
             __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
534 534
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
535 535
         );
536
-        unset($tax);
536
+        unset( $tax );
537 537
 
538 538
         return $link;
539 539
     }
@@ -547,8 +547,8 @@  discard block
 block discarded – undo
547 547
 		$observed_value = wp_kses_post( $observed_value );
548 548
 		$hide_opt = wp_kses_post( $hide_opt );
549 549
 
550
-        if ( is_array($observed_value) ) {
551
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
550
+        if ( is_array( $observed_value ) ) {
551
+            return self::array_value_condition( $observed_value, $cond, $hide_opt );
552 552
         }
553 553
 
554 554
         $m = false;
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
         } else if ( $cond == '<' ) {
562 562
             $m = $observed_value < $hide_opt;
563 563
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
564
-            $m = stripos($observed_value, $hide_opt);
564
+            $m = stripos( $observed_value, $hide_opt );
565 565
             if ( $cond == 'not LIKE' ) {
566 566
                 $m = ( $m === false ) ? true : false;
567 567
             } else {
@@ -574,23 +574,23 @@  discard block
 block discarded – undo
574 574
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
575 575
         $m = false;
576 576
         if ( $cond == '==' ) {
577
-            if ( is_array($hide_opt) ) {
578
-                $m = array_intersect($hide_opt, $observed_value);
579
-                $m = empty($m) ? false : true;
577
+            if ( is_array( $hide_opt ) ) {
578
+                $m = array_intersect( $hide_opt, $observed_value );
579
+                $m = empty( $m ) ? false : true;
580 580
             } else {
581
-                $m = in_array($hide_opt, $observed_value);
581
+                $m = in_array( $hide_opt, $observed_value );
582 582
             }
583 583
         } else if ( $cond == '!=' ) {
584
-            $m = ! in_array($hide_opt, $observed_value);
584
+            $m = ! in_array( $hide_opt, $observed_value );
585 585
         } else if ( $cond == '>' ) {
586
-            $min = min($observed_value);
586
+            $min = min( $observed_value );
587 587
             $m = $min > $hide_opt;
588 588
         } else if ( $cond == '<' ) {
589
-            $max = max($observed_value);
589
+            $max = max( $observed_value );
590 590
             $m = $max < $hide_opt;
591 591
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
592 592
             foreach ( $observed_value as $ob ) {
593
-                $m = strpos($ob, $hide_opt);
593
+                $m = strpos( $ob, $hide_opt );
594 594
                 if ( $m !== false ) {
595 595
                     $m = true;
596 596
                     break;
@@ -611,27 +611,27 @@  discard block
 block discarded – undo
611 611
      * @return string
612 612
      */
613 613
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
614
-        if ( strpos($value, '[sitename]') !== false ) {
614
+        if ( strpos( $value, '[sitename]' ) !== false ) {
615 615
             $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
616
-            $value = str_replace('[sitename]', $new_value, $value);
616
+            $value = str_replace( '[sitename]', $new_value, $value );
617 617
         }
618 618
 
619
-        $value = apply_filters('frm_content', $value, $form, $entry);
620
-        $value = do_shortcode($value);
619
+        $value = apply_filters( 'frm_content', $value, $form, $entry );
620
+        $value = do_shortcode( $value );
621 621
 
622 622
         return $value;
623 623
     }
624 624
 
625 625
 	public static function get_shortcodes( $content, $form_id ) {
626 626
         if ( FrmAppHelper::pro_is_installed() ) {
627
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
627
+            return FrmProDisplaysHelper::get_shortcodes( $content, $form_id );
628 628
         }
629 629
 
630 630
         $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
631 631
 
632
-        $tagregexp = self::allowed_shortcodes($fields);
632
+        $tagregexp = self::allowed_shortcodes( $fields );
633 633
 
634
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
634
+        preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER );
635 635
 
636 636
         return $matches;
637 637
     }
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
             $tagregexp[] = $field->field_key;
650 650
         }
651 651
 
652
-        $tagregexp = implode('|', $tagregexp);
652
+        $tagregexp = implode( '|', $tagregexp );
653 653
         return $tagregexp;
654 654
     }
655 655
 
@@ -665,28 +665,28 @@  discard block
 block discarded – undo
665 665
 				continue;
666 666
 			}
667 667
 
668
-            $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] );
668
+            $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][$short_key] );
669 669
 
670
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
671
-				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
672
-                $tags = explode(' ', $tag);
673
-                if ( is_array($tags) ) {
670
+            if ( ! empty( $shortcodes[3][$short_key] ) ) {
671
+				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][$short_key] );
672
+                $tags = explode( ' ', $tag );
673
+                if ( is_array( $tags ) ) {
674 674
                     $tag = $tags[0];
675 675
                 }
676 676
             } else {
677
-                $tag = $shortcodes[2][ $short_key ];
677
+                $tag = $shortcodes[2][$short_key];
678 678
             }
679 679
 
680 680
             switch ( $tag ) {
681 681
                 case 'id':
682 682
                 case 'key':
683 683
                 case 'ip':
684
-                    $replace_with = $shortcode_values[ $tag ];
684
+                    $replace_with = $shortcode_values[$tag];
685 685
                 break;
686 686
 
687 687
                 case 'user_agent':
688 688
                 case 'user-agent':
689
-                    $entry->description = maybe_unserialize($entry->description);
689
+                    $entry->description = maybe_unserialize( $entry->description );
690 690
 					$replace_with = FrmEntriesHelper::get_browser( $entry->description['browser'] );
691 691
                 break;
692 692
 
@@ -694,25 +694,25 @@  discard block
 block discarded – undo
694 694
                 case 'created-at':
695 695
                 case 'updated_at':
696 696
                 case 'updated-at':
697
-                    if ( isset($atts['format']) ) {
697
+                    if ( isset( $atts['format'] ) ) {
698 698
                         $time_format = ' ';
699 699
                     } else {
700
-                        $atts['format'] = get_option('date_format');
700
+                        $atts['format'] = get_option( 'date_format' );
701 701
                         $time_format = '';
702 702
                     }
703 703
 
704
-                    $this_tag = str_replace('-', '_', $tag);
705
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
706
-                    unset($this_tag);
704
+                    $this_tag = str_replace( '-', '_', $tag );
705
+                    $replace_with = FrmAppHelper::get_formatted_time( $entry->{$this_tag}, $atts['format'], $time_format );
706
+                    unset( $this_tag );
707 707
                 break;
708 708
 
709 709
                 case 'created_by':
710 710
                 case 'created-by':
711 711
                 case 'updated_by':
712 712
                 case 'updated-by':
713
-                    $this_tag = str_replace('-', '_', $tag);
713
+                    $this_tag = str_replace( '-', '_', $tag );
714 714
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
715
-                    unset($this_tag);
715
+                    unset( $this_tag );
716 716
                 break;
717 717
 
718 718
                 case 'admin_email':
@@ -729,16 +729,16 @@  discard block
 block discarded – undo
729 729
                         break;
730 730
                     }
731 731
 
732
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
732
+                    $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
733 733
 
734 734
                     $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
735 735
 
736 736
                     $atts['entry_id'] = $entry->id;
737 737
                     $atts['entry_key'] = $entry->item_key;
738 738
 
739
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
739
+                    if ( isset( $atts['show'] ) && $atts['show'] == 'field_label' ) {
740 740
                         $replace_with = $field->name;
741
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
741
+                    } else if ( isset( $atts['show'] ) && $atts['show'] == 'description' ) {
742 742
                         $replace_with = $field->description;
743 743
 					} else {
744 744
 						$string_value = $replace_with;
@@ -753,15 +753,15 @@  discard block
 block discarded – undo
753 753
 						}
754 754
 					}
755 755
 
756
-                    unset($field);
756
+                    unset( $field );
757 757
                 break;
758 758
             }
759 759
 
760
-            if ( isset($replace_with) ) {
761
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
760
+            if ( isset( $replace_with ) ) {
761
+                $content = str_replace( $shortcodes[0][$short_key], $replace_with, $content );
762 762
             }
763 763
 
764
-            unset($atts, $conditional, $replace_with);
764
+            unset( $atts, $conditional, $replace_with );
765 765
 		}
766 766
 
767 767
 		return $content;
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
         $new_value = '';
778 778
         switch ( $tag ) {
779 779
             case 'admin_email':
780
-                $new_value = get_option('admin_email');
780
+                $new_value = get_option( 'admin_email' );
781 781
                 break;
782 782
             case 'siteurl':
783 783
                 $new_value = FrmAppHelper::site_url();
@@ -803,28 +803,28 @@  discard block
 block discarded – undo
803 803
      * @return string|array
804 804
      */
805 805
     public static function process_get_shortcode( $atts, $return_array = false ) {
806
-        if ( ! isset($atts['param']) ) {
806
+        if ( ! isset( $atts['param'] ) ) {
807 807
             return '';
808 808
         }
809 809
 
810
-        if ( strpos($atts['param'], '&#91;') ) {
811
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
812
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
810
+        if ( strpos( $atts['param'], '&#91;' ) ) {
811
+            $atts['param'] = str_replace( '&#91;', '[', $atts['param'] );
812
+            $atts['param'] = str_replace( '&#93;', ']', $atts['param'] );
813 813
         }
814 814
 
815
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
815
+        $new_value = FrmAppHelper::get_param( $atts['param'], '' );
816 816
         $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
817 817
 
818 818
         if ( $new_value == '' ) {
819
-            if ( ! isset($atts['prev_val']) ) {
819
+            if ( ! isset( $atts['prev_val'] ) ) {
820 820
                 $atts['prev_val'] = '';
821 821
             }
822 822
 
823
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
823
+            $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val'];
824 824
         }
825 825
 
826
-        if ( is_array($new_value) && ! $return_array ) {
827
-            $new_value = implode(', ', $new_value);
826
+        if ( is_array( $new_value ) && ! $return_array ) {
827
+            $new_value = implode( ', ', $new_value );
828 828
         }
829 829
 
830 830
         return $new_value;
@@ -837,17 +837,17 @@  discard block
 block discarded – undo
837 837
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
838 838
 
839 839
         if ( $field->type == 'textarea' || $field->type == 'rte' ) {
840
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
841
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
842
-                if ( is_array($replace_with) ) {
843
-                    $replace_with = implode("\n", $replace_with);
840
+            $autop = isset( $atts['wpautop'] ) ? $atts['wpautop'] : true;
841
+            if ( apply_filters( 'frm_use_wpautop', $autop ) ) {
842
+                if ( is_array( $replace_with ) ) {
843
+                    $replace_with = implode( "\n", $replace_with );
844 844
                 }
845
-                $replace_with = wpautop($replace_with);
845
+                $replace_with = wpautop( $replace_with );
846 846
             }
847 847
 			unset( $autop );
848 848
 		} else if ( is_array( $replace_with ) ) {
849
-			if ( $atts['show'] && isset( $replace_with[ $atts['show'] ] ) ) {
850
-				$replace_with = $replace_with[ $atts['show'] ];
849
+			if ( $atts['show'] && isset( $replace_with[$atts['show']] ) ) {
850
+				$replace_with = $replace_with[$atts['show']];
851 851
 			} else {
852 852
 				$replace_with = implode( $sep, $replace_with );
853 853
 			}
@@ -868,14 +868,14 @@  discard block
 block discarded – undo
868 868
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
869 869
 
870 870
         $field_types = array();
871
-        if ( in_array($type, $single_input) ) {
871
+        if ( in_array( $type, $single_input ) ) {
872 872
             self::field_types_for_input( $single_input, $field_selection, $field_types );
873
-        } else if ( in_array($type, $multiple_input) ) {
873
+        } else if ( in_array( $type, $multiple_input ) ) {
874 874
             self::field_types_for_input( $multiple_input, $field_selection, $field_types );
875
-        } else if ( in_array($type, $other_type) ) {
875
+        } else if ( in_array( $type, $other_type ) ) {
876 876
             self::field_types_for_input( $other_type, $field_selection, $field_types );
877
-		} else if ( isset( $field_selection[ $type ] ) ) {
878
-            $field_types[ $type ] = $field_selection[ $type ];
877
+		} else if ( isset( $field_selection[$type] ) ) {
878
+            $field_types[$type] = $field_selection[$type];
879 879
         }
880 880
 
881 881
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
@@ -884,8 +884,8 @@  discard block
 block discarded – undo
884 884
 
885 885
     private static function field_types_for_input( $inputs, $fields, &$field_types ) {
886 886
         foreach ( $inputs as $input ) {
887
-            $field_types[ $input ] = $fields[ $input ];
888
-            unset($input);
887
+            $field_types[$input] = $fields[$input];
888
+            unset( $input );
889 889
         }
890 890
     }
891 891
 
@@ -930,21 +930,21 @@  discard block
 block discarded – undo
930 930
 		// Check posted vals before checking saved values
931 931
 
932 932
 		// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
933
-		if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) {
933
+		if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) {
934 934
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
935
-				$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 ] ) : '';
935
+				$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] ) : '';
936 936
 			} else {
937
-				$other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] );
937
+				$other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] );
938 938
 			}
939 939
 			return $other_val;
940 940
 
941
-		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) {
941
+		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) {
942 942
 			// For normal fields
943 943
 
944 944
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
945
-				$other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : '';
945
+				$other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : '';
946 946
 			} else {
947
-				$other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] );
947
+				$other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] );
948 948
 			}
949 949
 			return $other_val;
950 950
 		}
@@ -953,8 +953,8 @@  discard block
 block discarded – undo
953 953
 		if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) {
954 954
 			// Check if there is an "other" val in saved value and make sure the
955 955
 			// "other" val is not equal to the Other checkbox option
956
-			if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
957
-				$other_val = $field['value'][ $opt_key ];
956
+			if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) {
957
+				$other_val = $field['value'][$opt_key];
958 958
 			}
959 959
 		} else {
960 960
 			/**
@@ -966,8 +966,8 @@  discard block
 block discarded – undo
966 966
 				// Multi-select dropdowns - key is not preserved
967 967
 				if ( is_array( $field['value'] ) ) {
968 968
 					$o_key = array_search( $temp_val, $field['value'] );
969
-					if ( isset( $field['value'][ $o_key ] ) ) {
970
-						unset( $field['value'][ $o_key ], $o_key );
969
+					if ( isset( $field['value'][$o_key] ) ) {
970
+						unset( $field['value'][$o_key], $o_key );
971 971
 					}
972 972
 				} else if ( $temp_val == $field['value'] ) {
973 973
 					// For radio and regular dropdowns
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
 	private static function set_other_name( $args, &$other_args ) {
1025 1025
 		//Set up name for other field
1026 1026
 		$other_args['name'] = str_replace( '[]', '', $args['field_name'] );
1027
-		$other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']);
1027
+		$other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] );
1028 1028
 		$other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']';
1029 1029
 
1030 1030
 		//Converts item_meta[field_id] => item_meta[other][field_id] and
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
 		// Count should only be greater than 3 if inside of a repeating section
1052 1052
 		if ( count( $temp_array ) > 3 ) {
1053 1053
 			$parent = str_replace( ']', '', $temp_array[1] );
1054
-			$pointer = str_replace( ']', '', $temp_array[2]);
1054
+			$pointer = str_replace( ']', '', $temp_array[2] );
1055 1055
 		}
1056 1056
 
1057 1057
 		// Get text for "other" text field
@@ -1170,15 +1170,15 @@  discard block
 block discarded – undo
1170 1170
 			$replace_with[] = '[' . $new . ']';
1171 1171
 			$replace[] = '[' . $old . ' ';
1172 1172
 			$replace_with[] = '[' . $new . ' ';
1173
-            unset($old, $new);
1173
+            unset( $old, $new );
1174 1174
         }
1175 1175
 		if ( is_array( $val ) ) {
1176 1176
 			foreach ( $val as $k => $v ) {
1177
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1178
-                unset($k, $v);
1177
+                $val[$k] = str_replace( $replace, $replace_with, $v );
1178
+                unset( $k, $v );
1179 1179
             }
1180 1180
         } else {
1181
-            $val = str_replace($replace, $replace_with, $val);
1181
+            $val = str_replace( $replace, $replace_with, $val );
1182 1182
         }
1183 1183
 
1184 1184
         return $val;
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
             'DC' => 'District of Columbia',
1192 1192
             'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1193 1193
             'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1194
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1194
+            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland',
1195 1195
             'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1196 1196
             'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1197 1197
             'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
@@ -1282,35 +1282,35 @@  discard block
 block discarded – undo
1282 1282
     }
1283 1283
 
1284 1284
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1285
-		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1285
+		$prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries();
1286 1286
 
1287 1287
         $states = FrmFieldsHelper::get_us_states();
1288
-        $state_abv = array_keys($states);
1289
-        sort($state_abv);
1290
-		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1288
+        $state_abv = array_keys( $states );
1289
+        sort( $state_abv );
1290
+		$prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv;
1291 1291
 
1292
-        $states = array_values($states);
1293
-        sort($states);
1294
-		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1295
-        unset($state_abv, $states);
1292
+        $states = array_values( $states );
1293
+        sort( $states );
1294
+		$prepop[__( 'U.S. States', 'formidable' )] = $states;
1295
+        unset( $state_abv, $states );
1296 1296
 
1297
-		$prepop[ __( 'Age', 'formidable' ) ] = array(
1297
+		$prepop[__( 'Age', 'formidable' )] = array(
1298 1298
             __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1299 1299
             __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1300 1300
             __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1301 1301
         );
1302 1302
 
1303
-		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1303
+		$prepop[__( 'Satisfaction', 'formidable' )] = array(
1304 1304
             __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1305 1305
             __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1306 1306
         );
1307 1307
 
1308
-		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1308
+		$prepop[__( 'Importance', 'formidable' )] = array(
1309 1309
             __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1310 1310
             __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1311 1311
         );
1312 1312
 
1313
-		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1313
+		$prepop[__( 'Agreement', 'formidable' )] = array(
1314 1314
             __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1315 1315
             __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1316 1316
         );
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesHelper.php 2 patches
Indentation   +291 added lines, -291 removed lines patch added patch discarded remove patch
@@ -5,69 +5,69 @@  discard block
 block discarded – undo
5 5
 
6 6
 class FrmEntriesHelper {
7 7
 
8
-    public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9
-        $values = array();
8
+	public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9
+		$values = array();
10 10
 		foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) {
11 11
 			$values[ $var ] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' );
12
-        }
13
-
14
-        $values['fields'] = array();
15
-        if ( empty($fields) ) {
16
-            return apply_filters('frm_setup_new_entry', $values);
17
-        }
18
-
19
-        foreach ( (array) $fields as $field ) {
20
-            $new_value = self::get_field_value_for_new_entry( $field, $reset, $args );
21
-
22
-            $field_array = array(
23
-                'id' => $field->id,
24
-                'value' => $new_value,
25
-                'default_value' => $field->default_value,
26
-                'name' => $field->name,
27
-                'description' => $field->description,
28
-                'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
29
-                'options' => $field->options,
30
-                'required' => $field->required,
31
-                'field_key' => $field->field_key,
32
-                'field_order' => $field->field_order,
33
-                'form_id' => $field->form_id,
12
+		}
13
+
14
+		$values['fields'] = array();
15
+		if ( empty($fields) ) {
16
+			return apply_filters('frm_setup_new_entry', $values);
17
+		}
18
+
19
+		foreach ( (array) $fields as $field ) {
20
+			$new_value = self::get_field_value_for_new_entry( $field, $reset, $args );
21
+
22
+			$field_array = array(
23
+				'id' => $field->id,
24
+				'value' => $new_value,
25
+				'default_value' => $field->default_value,
26
+				'name' => $field->name,
27
+				'description' => $field->description,
28
+				'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
29
+				'options' => $field->options,
30
+				'required' => $field->required,
31
+				'field_key' => $field->field_key,
32
+				'field_order' => $field->field_order,
33
+				'form_id' => $field->form_id,
34 34
 				'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id,
35
-	            'reset_value' => $reset,
35
+				'reset_value' => $reset,
36 36
 				'in_embed_form' => isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0',
37
-            );
37
+			);
38 38
 
39
-            $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
40
-            $opt_defaults['required_indicator'] = '';
39
+			$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
40
+			$opt_defaults['required_indicator'] = '';
41 41
 			$opt_defaults['original_type'] = $field->type;
42 42
 
43 43
 			foreach ( $opt_defaults as $opt => $default_opt ) {
44
-                $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
45
-                unset($opt, $default_opt);
46
-            }
44
+				$field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
45
+				unset($opt, $default_opt);
46
+			}
47 47
 
48
-            unset($opt_defaults);
48
+			unset($opt_defaults);
49 49
 
50
-            if ( $field_array['custom_html'] == '' ) {
51
-                $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
52
-            }
50
+			if ( $field_array['custom_html'] == '' ) {
51
+				$field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
52
+			}
53 53
 
54
-            $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args );
55
-            $field_array = array_merge( $field->field_options, $field_array );
54
+			$field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args );
55
+			$field_array = array_merge( $field->field_options, $field_array );
56 56
 
57
-            $values['fields'][] = $field_array;
57
+			$values['fields'][] = $field_array;
58 58
 
59
-            if ( ! $form || ! isset($form->id) ) {
60
-                $form = FrmForm::getOne($field->form_id);
61
-            }
62
-        }
59
+			if ( ! $form || ! isset($form->id) ) {
60
+				$form = FrmForm::getOne($field->form_id);
61
+			}
62
+		}
63 63
 
64
-        $form->options = maybe_unserialize($form->options);
65
-        if ( is_array($form->options) ) {
66
-            foreach ( $form->options as $opt => $value ) {
67
-                $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
68
-                unset($opt, $value);
69
-            }
70
-        }
64
+		$form->options = maybe_unserialize($form->options);
65
+		if ( is_array($form->options) ) {
66
+			foreach ( $form->options as $opt => $value ) {
67
+				$values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
68
+				unset($opt, $value);
69
+			}
70
+		}
71 71
 
72 72
 		$form_defaults = FrmFormsHelper::get_default_opts();
73 73
 
@@ -77,19 +77,19 @@  discard block
 block discarded – undo
77 77
 		$values = array_merge( $form_defaults, $values );
78 78
 
79 79
 		return apply_filters( 'frm_setup_new_entry', $values );
80
-    }
80
+	}
81 81
 
82 82
 	/**
83
-	* Set the value for each field
84
-	* This function is used when the form is first loaded and on all page turns *for a new entry*
85
-	*
86
-	* @since 2.0.13
87
-	*
88
-	* @param object $field - this is passed by reference since it is an object
89
-	* @param boolean $reset
90
-	* @param array $args
91
-	* @return string|array $new_value
92
-	*/
83
+	 * Set the value for each field
84
+	 * This function is used when the form is first loaded and on all page turns *for a new entry*
85
+	 *
86
+	 * @since 2.0.13
87
+	 *
88
+	 * @param object $field - this is passed by reference since it is an object
89
+	 * @param boolean $reset
90
+	 * @param array $args
91
+	 * @return string|array $new_value
92
+	 */
93 93
 	private static function get_field_value_for_new_entry( $field, $reset, $args ) {
94 94
 		//If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array
95 95
 		$return_array = FrmField::is_field_with_multiple_values( $field );
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
 	}
122 122
 
123 123
 	/**
124
-	* Check if a field has a posted value
125
-	*
126
-	* @since 2.01.0
127
-	* @param object $field
128
-	* @param array $args
129
-	* @return boolean $value_is_posted
130
-	*/
124
+	 * Check if a field has a posted value
125
+	 *
126
+	 * @since 2.01.0
127
+	 * @param object $field
128
+	 * @param array $args
129
+	 * @return boolean $value_is_posted
130
+	 */
131 131
 	public static function value_is_posted( $field, $args ) {
132 132
 		$value_is_posted = false;
133 133
 		if ( $_POST ) {
@@ -145,15 +145,15 @@  discard block
 block discarded – undo
145 145
 
146 146
 	public static function setup_edit_vars( $values, $record ) {
147 147
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
148
-        $values['form_id'] = $record->form_id;
149
-        $values['is_draft'] = $record->is_draft;
150
-        return apply_filters('frm_setup_edit_entry_vars', $values, $record);
151
-    }
148
+		$values['form_id'] = $record->form_id;
149
+		$values['is_draft'] = $record->is_draft;
150
+		return apply_filters('frm_setup_edit_entry_vars', $values, $record);
151
+	}
152 152
 
153
-    public static function get_admin_params( $form = null ) {
153
+	public static function get_admin_params( $form = null ) {
154 154
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_admin_params' );
155 155
 		return FrmForm::set_current_form( $form );
156
-    }
156
+	}
157 157
 
158 158
 	public static function set_current_form( $form_id ) {
159 159
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::set_current_form' );
@@ -165,284 +165,284 @@  discard block
 block discarded – undo
165 165
 		return FrmForm::get_current_form( $form_id );
166 166
 	}
167 167
 
168
-    public static function get_current_form_id() {
168
+	public static function get_current_form_id() {
169 169
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_current_form_id' );
170 170
 		return FrmForm::get_current_form_id();
171
-    }
171
+	}
172 172
 
173
-    public static function maybe_get_entry( &$entry ) {
173
+	public static function maybe_get_entry( &$entry ) {
174 174
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntry::maybe_get_entry' );
175 175
 		FrmEntry::maybe_get_entry( $entry );
176
-    }
176
+	}
177 177
 
178 178
 	public static function replace_default_message( $message, $atts ) {
179
-        if ( strpos($message, '[default-message') === false &&
180
-            strpos($message, '[default_message') === false &&
181
-            ! empty( $message ) ) {
182
-            return $message;
183
-        }
179
+		if ( strpos($message, '[default-message') === false &&
180
+			strpos($message, '[default_message') === false &&
181
+			! empty( $message ) ) {
182
+			return $message;
183
+		}
184 184
 
185
-        if ( empty($message) ) {
186
-            $message = '[default-message]';
187
-        }
185
+		if ( empty($message) ) {
186
+			$message = '[default-message]';
187
+		}
188 188
 
189
-        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
189
+		preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
190 190
 
191
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
191
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
192 192
 			$add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
193 193
 			if ( ! empty( $add_atts ) ) {
194
-                $this_atts = array_merge($atts, $add_atts);
195
-            } else {
196
-                $this_atts = $atts;
197
-            }
194
+				$this_atts = array_merge($atts, $add_atts);
195
+			} else {
196
+				$this_atts = $atts;
197
+			}
198 198
 
199 199
 			$default = FrmEntriesController::show_entry_shortcode( $this_atts );
200 200
 
201
-            // Add the default message
202
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
203
-        }
201
+			// Add the default message
202
+			$message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
203
+		}
204 204
 
205
-        return $message;
206
-    }
205
+		return $message;
206
+	}
207 207
 
208 208
 	public static function prepare_display_value( $entry, $field, $atts ) {
209 209
 		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
210 210
 
211
-        if ( FrmAppHelper::pro_is_installed() ) {
211
+		if ( FrmAppHelper::pro_is_installed() ) {
212 212
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
213
-        }
213
+		}
214 214
 
215
-        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
216
-            return self::display_value($field_value, $field, $atts);
217
-        }
215
+		if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
216
+			return self::display_value($field_value, $field, $atts);
217
+		}
218 218
 
219
-        // this is an embeded form
220
-        $val = '';
219
+		// this is an embeded form
220
+		$val = '';
221 221
 
222
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
223
-            //this is a repeating section
222
+		if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
223
+			//this is a repeating section
224 224
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
225
-        } else {
226
-            // get all values for this field
227
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
225
+		} else {
226
+			// get all values for this field
227
+			$child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
228 228
 
229
-            if ( $child_values ) {
230
-	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
231
-	        }
232
-	    }
229
+			if ( $child_values ) {
230
+				$child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
231
+			}
232
+		}
233 233
 
234
-	    $field_value = array();
234
+		$field_value = array();
235 235
 
236
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
237
-            return $val;
238
-        }
236
+		if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
237
+			return $val;
238
+		}
239 239
 
240
-        foreach ( $child_entries as $child_entry ) {
241
-            $atts['item_id'] = $child_entry->id;
242
-            $atts['post_id'] = $child_entry->post_id;
240
+		foreach ( $child_entries as $child_entry ) {
241
+			$atts['item_id'] = $child_entry->id;
242
+			$atts['post_id'] = $child_entry->post_id;
243 243
 
244
-            // get the value for this field -- check for post values as well
245
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
244
+			// get the value for this field -- check for post values as well
245
+			$entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
246 246
 
247
-            if ( $entry_val ) {
248
-                // foreach entry get display_value
249
-                $field_value[] = self::display_value($entry_val, $field, $atts);
250
-            }
247
+			if ( $entry_val ) {
248
+				// foreach entry get display_value
249
+				$field_value[] = self::display_value($entry_val, $field, $atts);
250
+			}
251 251
 
252
-            unset($child_entry);
253
-        }
252
+			unset($child_entry);
253
+		}
254 254
 
255
-        $val = implode(', ', (array) $field_value );
255
+		$val = implode(', ', (array) $field_value );
256 256
 		$val = wp_kses_post( $val );
257 257
 
258
-        return $val;
259
-    }
258
+		return $val;
259
+	}
260 260
 
261
-    /**
262
-     * Prepare the saved value for display
263
-     * @return string
264
-     */
261
+	/**
262
+	 * Prepare the saved value for display
263
+	 * @return string
264
+	 */
265 265
 	public static function display_value( $value, $field, $atts = array() ) {
266 266
 
267
-        $defaults = array(
268
-            'type' => '', 'html' => false, 'show_filename' => true,
269
-            'truncate' => false, 'sep' => ', ', 'post_id' => 0,
270
-            'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0,
267
+		$defaults = array(
268
+			'type' => '', 'html' => false, 'show_filename' => true,
269
+			'truncate' => false, 'sep' => ', ', 'post_id' => 0,
270
+			'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0,
271 271
 			'return_array' => false,
272
-        );
272
+		);
273 273
 
274
-        $atts = wp_parse_args( $atts, $defaults );
275
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
274
+		$atts = wp_parse_args( $atts, $defaults );
275
+		$atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
276 276
 
277
-        if ( ! isset($field->field_options['post_field']) ) {
278
-            $field->field_options['post_field'] = '';
279
-        }
277
+		if ( ! isset($field->field_options['post_field']) ) {
278
+			$field->field_options['post_field'] = '';
279
+		}
280 280
 
281
-        if ( ! isset($field->field_options['custom_field']) ) {
282
-            $field->field_options['custom_field'] = '';
283
-        }
281
+		if ( ! isset($field->field_options['custom_field']) ) {
282
+			$field->field_options['custom_field'] = '';
283
+		}
284 284
 
285
-        if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
286
-            $atts['pre_truncate'] = $atts['truncate'];
287
-            $atts['truncate'] = true;
288
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
285
+		if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
286
+			$atts['pre_truncate'] = $atts['truncate'];
287
+			$atts['truncate'] = true;
288
+			$atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
289 289
 
290
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
291
-            $atts['truncate'] = $atts['pre_truncate'];
292
-        }
290
+			$value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
291
+			$atts['truncate'] = $atts['pre_truncate'];
292
+		}
293 293
 
294
-        if ( $value == '' ) {
295
-            return $value;
296
-        }
294
+		if ( $value == '' ) {
295
+			return $value;
296
+		}
297 297
 
298
-        $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
298
+		$value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
299 299
 		$value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) );
300 300
 
301
-        $new_value = '';
301
+		$new_value = '';
302 302
 
303
-        if ( is_array($value) && $atts['type'] != 'file' ) {
304
-            foreach ( $value as $val ) {
305
-                if ( is_array($val) ) {
303
+		if ( is_array($value) && $atts['type'] != 'file' ) {
304
+			foreach ( $value as $val ) {
305
+				if ( is_array($val) ) {
306 306
 					//TODO: add options for display (li or ,)
307
-                    $new_value .= implode($atts['sep'], $val);
308
-                    if ( $atts['type'] != 'data' ) {
309
-                        $new_value .= '<br/>';
310
-                    }
311
-                }
312
-                unset($val);
313
-            }
314
-        }
315
-
316
-        if ( ! empty($new_value) ) {
317
-            $value = $new_value;
318
-        } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
319
-            $value = implode($atts['sep'], $value);
320
-        }
321
-
322
-        if ( $atts['truncate'] && $atts['type'] != 'image' ) {
323
-            $value = FrmAppHelper::truncate($value, 50);
324
-        }
307
+					$new_value .= implode($atts['sep'], $val);
308
+					if ( $atts['type'] != 'data' ) {
309
+						$new_value .= '<br/>';
310
+					}
311
+				}
312
+				unset($val);
313
+			}
314
+		}
315
+
316
+		if ( ! empty($new_value) ) {
317
+			$value = $new_value;
318
+		} else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
319
+			$value = implode($atts['sep'], $value);
320
+		}
321
+
322
+		if ( $atts['truncate'] && $atts['type'] != 'image' ) {
323
+			$value = FrmAppHelper::truncate($value, 50);
324
+		}
325 325
 
326 326
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
327 327
 			$value = wp_kses_post( $value );
328 328
 		}
329 329
 
330
-        return apply_filters('frm_display_value', $value, $field, $atts);
331
-    }
330
+		return apply_filters('frm_display_value', $value, $field, $atts);
331
+	}
332 332
 
333 333
 	public static function set_posted_value( $field, $value, $args ) {
334
-        // If validating a field with "other" opt, set back to prev value now
335
-        if ( isset( $args['other'] ) && $args['other'] ) {
336
-            $value = $args['temp_value'];
337
-        }
338
-        if ( empty($args['parent_field_id']) ) {
339
-            $_POST['item_meta'][ $field->id ] = $value;
340
-        } else {
341
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
342
-        }
343
-    }
334
+		// If validating a field with "other" opt, set back to prev value now
335
+		if ( isset( $args['other'] ) && $args['other'] ) {
336
+			$value = $args['temp_value'];
337
+		}
338
+		if ( empty($args['parent_field_id']) ) {
339
+			$_POST['item_meta'][ $field->id ] = $value;
340
+		} else {
341
+			$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
342
+		}
343
+	}
344 344
 
345 345
 	public static function get_posted_value( $field, &$value, $args ) {
346 346
 		$field_id = is_object( $field ) ? $field->id : $field;
347 347
 
348
-        if ( empty($args['parent_field_id']) ) {
349
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
350
-        } else {
351
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
352
-        }
348
+		if ( empty($args['parent_field_id']) ) {
349
+			$value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
350
+		} else {
351
+			$value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
352
+		}
353 353
 		FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
354 354
 		$value = stripslashes_deep( $value );
355
-    }
356
-
357
-    /**
358
-    * Check if field has an "Other" option and if any other values are posted
359
-    *
360
-    * @since 2.0
361
-    *
362
-    * @param object $field
363
-    * @param string|array $value
364
-    * @param array $args
365
-    */
366
-    public static function maybe_set_other_validation( $field, &$value, &$args ) {
367
-        $args['other'] = false;
368
-        if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
369
-            return;
370
-        }
371
-
372
-        // Get other value for fields in repeating section
373
-        self::set_other_repeating_vals( $field, $value, $args );
374
-
375
-        // Check if there are any posted "Other" values
355
+	}
356
+
357
+	/**
358
+	 * Check if field has an "Other" option and if any other values are posted
359
+	 *
360
+	 * @since 2.0
361
+	 *
362
+	 * @param object $field
363
+	 * @param string|array $value
364
+	 * @param array $args
365
+	 */
366
+	public static function maybe_set_other_validation( $field, &$value, &$args ) {
367
+		$args['other'] = false;
368
+		if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
369
+			return;
370
+		}
371
+
372
+		// Get other value for fields in repeating section
373
+		self::set_other_repeating_vals( $field, $value, $args );
374
+
375
+		// Check if there are any posted "Other" values
376 376
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
377 377
 
378
-            // Save original value
379
-            $args['temp_value'] = $value;
380
-            $args['other'] = true;
381
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
382
-
383
-            // Set the validation value now
384
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
385
-        }
386
-    }
387
-
388
-    /**
389
-    * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
390
-    *
391
-    * @since 2.0
392
-    *
393
-    * @param object $field
394
-    * @param string|array $value
395
-    * @param array $args
396
-    */
397
-    public static function set_other_repeating_vals( $field, &$value, &$args ) {
398
-        if ( ! $args['parent_field_id'] ) {
399
-            return;
400
-        }
401
-
402
-        // Check if there are any other posted "other" values for this field
378
+			// Save original value
379
+			$args['temp_value'] = $value;
380
+			$args['other'] = true;
381
+			$other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
382
+
383
+			// Set the validation value now
384
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
385
+		}
386
+	}
387
+
388
+	/**
389
+	 * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
390
+	 *
391
+	 * @since 2.0
392
+	 *
393
+	 * @param object $field
394
+	 * @param string|array $value
395
+	 * @param array $args
396
+	 */
397
+	public static function set_other_repeating_vals( $field, &$value, &$args ) {
398
+		if ( ! $args['parent_field_id'] ) {
399
+			return;
400
+		}
401
+
402
+		// Check if there are any other posted "other" values for this field
403 403
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
404
-            // Save original value
405
-            $args['temp_value'] = $value;
406
-            $args['other'] = true;
407
-
408
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
409
-
410
-            // Set the validation value now
411
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
412
-        }
413
-    }
414
-
415
-    /**
416
-    * Modify value used for validation
417
-    * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
418
-    * It also adds any text from the free text fields to the value
419
-    *
420
-    * Needs to accommodate for times when other opt is selected, but no other free text is entered
421
-    *
422
-    * @since 2.0
423
-    *
424
-    * @param string|array $value
425
-    * @param string|array $other_vals (usually of posted values)
426
-    * @param object $field
427
-    * @param array $args
428
-    */
429
-    public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
430
-        // Checkboxes and multi-select dropdowns
431
-        if ( is_array( $value ) && $field->type == 'checkbox' ) {
432
-            // Combine "Other" values with checked values. "Other" values will override checked box values.
433
-            $value = array_merge( $value, $other_vals );
434
-            $value = array_filter( $value );
435
-            if ( count( $value ) == 0 ) {
436
-                $value = '';
437
-            }
438
-        } else {
404
+			// Save original value
405
+			$args['temp_value'] = $value;
406
+			$args['other'] = true;
407
+
408
+			$other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
409
+
410
+			// Set the validation value now
411
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
412
+		}
413
+	}
414
+
415
+	/**
416
+	 * Modify value used for validation
417
+	 * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
418
+	 * It also adds any text from the free text fields to the value
419
+	 *
420
+	 * Needs to accommodate for times when other opt is selected, but no other free text is entered
421
+	 *
422
+	 * @since 2.0
423
+	 *
424
+	 * @param string|array $value
425
+	 * @param string|array $other_vals (usually of posted values)
426
+	 * @param object $field
427
+	 * @param array $args
428
+	 */
429
+	public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
430
+		// Checkboxes and multi-select dropdowns
431
+		if ( is_array( $value ) && $field->type == 'checkbox' ) {
432
+			// Combine "Other" values with checked values. "Other" values will override checked box values.
433
+			$value = array_merge( $value, $other_vals );
434
+			$value = array_filter( $value );
435
+			if ( count( $value ) == 0 ) {
436
+				$value = '';
437
+			}
438
+		} else {
439 439
 			// Radio and dropdowns
440
-            $other_key = array_filter( array_keys($field->options), 'is_string');
441
-            $other_key = reset( $other_key );
440
+			$other_key = array_filter( array_keys($field->options), 'is_string');
441
+			$other_key = reset( $other_key );
442 442
 
443
-            // Multi-select dropdown
444
-            if ( is_array( $value ) ) {
445
-                $o_key = array_search( $field->options[ $other_key ], $value );
443
+			// Multi-select dropdown
444
+			if ( is_array( $value ) ) {
445
+				$o_key = array_search( $field->options[ $other_key ], $value );
446 446
 
447 447
 				if ( $o_key !== false ) {
448 448
 					// Modify the original value so other key will be preserved
@@ -457,20 +457,20 @@  discard block
 block discarded – undo
457 457
 					$args['temp_value'] = $value;
458 458
 					$value[ $other_key ] = reset( $other_vals );
459 459
 				}
460
-            } else if ( $field->options[ $other_key ] == $value ) {
461
-                $value = $other_vals;
462
-            }
463
-        }
464
-    }
460
+			} else if ( $field->options[ $other_key ] == $value ) {
461
+				$value = $other_vals;
462
+			}
463
+		}
464
+	}
465 465
 
466 466
 	public static function enqueue_scripts( $params ) {
467 467
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormsController::enqueue_scripts' );
468 468
 		FrmFormsController::enqueue_scripts( $params );
469 469
 	}
470 470
 
471
-    // Add submitted values to a string for spam checking
471
+	// Add submitted values to a string for spam checking
472 472
 	public static function entry_array_to_string( $values ) {
473
-        $content = '';
473
+		$content = '';
474 474
 		foreach ( $values['item_meta'] as $val ) {
475 475
 			if ( $content != '' ) {
476 476
 				$content .= "\n\n";
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 		}
486 486
 
487 487
 		return $content;
488
-    }
488
+	}
489 489
 
490 490
 	/**
491 491
 	 * Get the browser from the user agent
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -8,12 +8,12 @@  discard block
 block discarded – undo
8 8
     public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9 9
         $values = array();
10 10
 		foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) {
11
-			$values[ $var ] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' );
11
+			$values[$var] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' );
12 12
         }
13 13
 
14 14
         $values['fields'] = array();
15
-        if ( empty($fields) ) {
16
-            return apply_filters('frm_setup_new_entry', $values);
15
+        if ( empty( $fields ) ) {
16
+            return apply_filters( 'frm_setup_new_entry', $values );
17 17
         }
18 18
 
19 19
         foreach ( (array) $fields as $field ) {
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
                 'default_value' => $field->default_value,
26 26
                 'name' => $field->name,
27 27
                 'description' => $field->description,
28
-                'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
28
+                'type' => apply_filters( 'frm_field_type', $field->type, $field, $new_value ),
29 29
                 'options' => $field->options,
30 30
                 'required' => $field->required,
31 31
                 'field_key' => $field->field_key,
@@ -36,43 +36,43 @@  discard block
 block discarded – undo
36 36
 				'in_embed_form' => isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0',
37 37
             );
38 38
 
39
-            $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
39
+            $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
40 40
             $opt_defaults['required_indicator'] = '';
41 41
 			$opt_defaults['original_type'] = $field->type;
42 42
 
43 43
 			foreach ( $opt_defaults as $opt => $default_opt ) {
44
-                $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
45
-                unset($opt, $default_opt);
44
+                $field_array[$opt] = ( isset( $field->field_options[$opt] ) && $field->field_options[$opt] != '' ) ? $field->field_options[$opt] : $default_opt;
45
+                unset( $opt, $default_opt );
46 46
             }
47 47
 
48
-            unset($opt_defaults);
48
+            unset( $opt_defaults );
49 49
 
50 50
             if ( $field_array['custom_html'] == '' ) {
51
-                $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
51
+                $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $field->type );
52 52
             }
53 53
 
54
-            $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args );
54
+            $field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field, $args );
55 55
             $field_array = array_merge( $field->field_options, $field_array );
56 56
 
57 57
             $values['fields'][] = $field_array;
58 58
 
59
-            if ( ! $form || ! isset($form->id) ) {
60
-                $form = FrmForm::getOne($field->form_id);
59
+            if ( ! $form || ! isset( $form->id ) ) {
60
+                $form = FrmForm::getOne( $field->form_id );
61 61
             }
62 62
         }
63 63
 
64
-        $form->options = maybe_unserialize($form->options);
65
-        if ( is_array($form->options) ) {
64
+        $form->options = maybe_unserialize( $form->options );
65
+        if ( is_array( $form->options ) ) {
66 66
             foreach ( $form->options as $opt => $value ) {
67
-                $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
68
-                unset($opt, $value);
67
+                $values[$opt] = FrmAppHelper::get_post_param( $opt, $value );
68
+                unset( $opt, $value );
69 69
             }
70 70
         }
71 71
 
72 72
 		$form_defaults = FrmFormsHelper::get_default_opts();
73 73
 
74 74
 		$frm_settings = FrmAppHelper::get_settings();
75
-		$form_defaults['custom_style']  = ( $frm_settings->load_style != 'none' );
75
+		$form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' );
76 76
 
77 77
 		$values = array_merge( $form_defaults, $values );
78 78
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		$return_array = FrmField::is_field_with_multiple_values( $field );
96 96
 
97 97
 		// Do any shortcodes in default value and allow customization of default value
98
-		$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array);
98
+		$field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true, $return_array );
99 99
 		// Calls FrmProFieldsHelper::get_default_value
100 100
 
101 101
 		$new_value = $field->default_value;
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 		}
115 115
 
116 116
 		if ( ! is_array( $new_value ) ) {
117
-			$new_value = str_replace('"', '&quot;', $new_value);
117
+			$new_value = str_replace( '"', '&quot;', $new_value );
118 118
 		}
119 119
 
120 120
 		return $new_value;
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
 		if ( $_POST ) {
134 134
 			$repeating = isset( $args['repeating'] ) && $args['repeating'];
135 135
 			if ( $repeating ) {
136
-				if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) {
136
+				if ( isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] ) ) {
137 137
 					$value_is_posted = true;
138 138
 				}
139
-			} else if ( isset( $_POST['item_meta'][ $field->id ] ) ) {
139
+			} else if ( isset( $_POST['item_meta'][$field->id] ) ) {
140 140
 				$value_is_posted = true;
141 141
 			}
142 142
 		}
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
148 148
         $values['form_id'] = $record->form_id;
149 149
         $values['is_draft'] = $record->is_draft;
150
-        return apply_filters('frm_setup_edit_entry_vars', $values, $record);
150
+        return apply_filters( 'frm_setup_edit_entry_vars', $values, $record );
151 151
     }
152 152
 
153 153
     public static function get_admin_params( $form = null ) {
@@ -176,22 +176,22 @@  discard block
 block discarded – undo
176 176
     }
177 177
 
178 178
 	public static function replace_default_message( $message, $atts ) {
179
-        if ( strpos($message, '[default-message') === false &&
180
-            strpos($message, '[default_message') === false &&
179
+        if ( strpos( $message, '[default-message' ) === false &&
180
+            strpos( $message, '[default_message' ) === false &&
181 181
             ! empty( $message ) ) {
182 182
             return $message;
183 183
         }
184 184
 
185
-        if ( empty($message) ) {
185
+        if ( empty( $message ) ) {
186 186
             $message = '[default-message]';
187 187
         }
188 188
 
189
-        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
189
+        preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
190 190
 
191 191
         foreach ( $shortcodes[0] as $short_key => $tag ) {
192
-			$add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
192
+			$add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] );
193 193
 			if ( ! empty( $add_atts ) ) {
194
-                $this_atts = array_merge($atts, $add_atts);
194
+                $this_atts = array_merge( $atts, $add_atts );
195 195
             } else {
196 196
                 $this_atts = $atts;
197 197
             }
@@ -199,32 +199,32 @@  discard block
 block discarded – undo
199 199
 			$default = FrmEntriesController::show_entry_shortcode( $this_atts );
200 200
 
201 201
             // Add the default message
202
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
202
+            $message = str_replace( $shortcodes[0][$short_key], $default, $message );
203 203
         }
204 204
 
205 205
         return $message;
206 206
     }
207 207
 
208 208
 	public static function prepare_display_value( $entry, $field, $atts ) {
209
-		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
209
+		$field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false;
210 210
 
211 211
         if ( FrmAppHelper::pro_is_installed() ) {
212 212
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
213 213
         }
214 214
 
215
-        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
216
-            return self::display_value($field_value, $field, $atts);
215
+        if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) {
216
+            return self::display_value( $field_value, $field, $atts );
217 217
         }
218 218
 
219 219
         // this is an embeded form
220 220
         $val = '';
221 221
 
222
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
222
+	    if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) {
223 223
             //this is a repeating section
224 224
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
225 225
         } else {
226 226
             // get all values for this field
227
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
227
+	        $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false;
228 228
 
229 229
             if ( $child_values ) {
230 230
 	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
 	    $field_value = array();
235 235
 
236
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
236
+        if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
237 237
             return $val;
238 238
         }
239 239
 
@@ -242,17 +242,17 @@  discard block
 block discarded – undo
242 242
             $atts['post_id'] = $child_entry->post_id;
243 243
 
244 244
             // get the value for this field -- check for post values as well
245
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
245
+            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field );
246 246
 
247 247
             if ( $entry_val ) {
248 248
                 // foreach entry get display_value
249
-                $field_value[] = self::display_value($entry_val, $field, $atts);
249
+                $field_value[] = self::display_value( $entry_val, $field, $atts );
250 250
             }
251 251
 
252
-            unset($child_entry);
252
+            unset( $child_entry );
253 253
         }
254 254
 
255
-        $val = implode(', ', (array) $field_value );
255
+        $val = implode( ', ', (array) $field_value );
256 256
 		$val = wp_kses_post( $val );
257 257
 
258 258
         return $val;
@@ -272,22 +272,22 @@  discard block
 block discarded – undo
272 272
         );
273 273
 
274 274
         $atts = wp_parse_args( $atts, $defaults );
275
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
275
+        $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value );
276 276
 
277
-        if ( ! isset($field->field_options['post_field']) ) {
277
+        if ( ! isset( $field->field_options['post_field'] ) ) {
278 278
             $field->field_options['post_field'] = '';
279 279
         }
280 280
 
281
-        if ( ! isset($field->field_options['custom_field']) ) {
281
+        if ( ! isset( $field->field_options['custom_field'] ) ) {
282 282
             $field->field_options['custom_field'] = '';
283 283
         }
284 284
 
285 285
         if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
286 286
             $atts['pre_truncate'] = $atts['truncate'];
287 287
             $atts['truncate'] = true;
288
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
288
+            $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0;
289 289
 
290
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
290
+            $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts );
291 291
             $atts['truncate'] = $atts['pre_truncate'];
292 292
         }
293 293
 
@@ -295,39 +295,39 @@  discard block
 block discarded – undo
295 295
             return $value;
296 296
         }
297 297
 
298
-        $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
298
+        $value = apply_filters( 'frm_display_value_custom', maybe_unserialize( $value ), $field, $atts );
299 299
 		$value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) );
300 300
 
301 301
         $new_value = '';
302 302
 
303
-        if ( is_array($value) && $atts['type'] != 'file' ) {
303
+        if ( is_array( $value ) && $atts['type'] != 'file' ) {
304 304
             foreach ( $value as $val ) {
305
-                if ( is_array($val) ) {
305
+                if ( is_array( $val ) ) {
306 306
 					//TODO: add options for display (li or ,)
307
-                    $new_value .= implode($atts['sep'], $val);
307
+                    $new_value .= implode( $atts['sep'], $val );
308 308
                     if ( $atts['type'] != 'data' ) {
309 309
                         $new_value .= '<br/>';
310 310
                     }
311 311
                 }
312
-                unset($val);
312
+                unset( $val );
313 313
             }
314 314
         }
315 315
 
316
-        if ( ! empty($new_value) ) {
316
+        if ( ! empty( $new_value ) ) {
317 317
             $value = $new_value;
318
-        } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
319
-            $value = implode($atts['sep'], $value);
318
+        } else if ( is_array( $value ) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
319
+            $value = implode( $atts['sep'], $value );
320 320
         }
321 321
 
322 322
         if ( $atts['truncate'] && $atts['type'] != 'image' ) {
323
-            $value = FrmAppHelper::truncate($value, 50);
323
+            $value = FrmAppHelper::truncate( $value, 50 );
324 324
         }
325 325
 
326 326
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
327 327
 			$value = wp_kses_post( $value );
328 328
 		}
329 329
 
330
-        return apply_filters('frm_display_value', $value, $field, $atts);
330
+        return apply_filters( 'frm_display_value', $value, $field, $atts );
331 331
     }
332 332
 
333 333
 	public static function set_posted_value( $field, $value, $args ) {
@@ -335,20 +335,20 @@  discard block
 block discarded – undo
335 335
         if ( isset( $args['other'] ) && $args['other'] ) {
336 336
             $value = $args['temp_value'];
337 337
         }
338
-        if ( empty($args['parent_field_id']) ) {
339
-            $_POST['item_meta'][ $field->id ] = $value;
338
+        if ( empty( $args['parent_field_id'] ) ) {
339
+            $_POST['item_meta'][$field->id] = $value;
340 340
         } else {
341
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
341
+            $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value;
342 342
         }
343 343
     }
344 344
 
345 345
 	public static function get_posted_value( $field, &$value, $args ) {
346 346
 		$field_id = is_object( $field ) ? $field->id : $field;
347 347
 
348
-        if ( empty($args['parent_field_id']) ) {
349
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
348
+        if ( empty( $args['parent_field_id'] ) ) {
349
+            $value = isset( $_POST['item_meta'][$field_id] ) ? $_POST['item_meta'][$field_id] : '';
350 350
         } else {
351
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
351
+            $value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] : '';
352 352
         }
353 353
 		FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
354 354
 		$value = stripslashes_deep( $value );
@@ -373,12 +373,12 @@  discard block
 block discarded – undo
373 373
         self::set_other_repeating_vals( $field, $value, $args );
374 374
 
375 375
         // Check if there are any posted "Other" values
376
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
376
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) {
377 377
 
378 378
             // Save original value
379 379
             $args['temp_value'] = $value;
380 380
             $args['other'] = true;
381
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
381
+            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][$field->id] );
382 382
 
383 383
             // Set the validation value now
384 384
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -400,12 +400,12 @@  discard block
 block discarded – undo
400 400
         }
401 401
 
402 402
         // Check if there are any other posted "other" values for this field
403
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
403
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) {
404 404
             // Save original value
405 405
             $args['temp_value'] = $value;
406 406
             $args['other'] = true;
407 407
 
408
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
408
+            $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id];
409 409
 
410 410
             // Set the validation value now
411 411
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -437,27 +437,27 @@  discard block
 block discarded – undo
437 437
             }
438 438
         } else {
439 439
 			// Radio and dropdowns
440
-            $other_key = array_filter( array_keys($field->options), 'is_string');
440
+            $other_key = array_filter( array_keys( $field->options ), 'is_string' );
441 441
             $other_key = reset( $other_key );
442 442
 
443 443
             // Multi-select dropdown
444 444
             if ( is_array( $value ) ) {
445
-                $o_key = array_search( $field->options[ $other_key ], $value );
445
+                $o_key = array_search( $field->options[$other_key], $value );
446 446
 
447 447
 				if ( $o_key !== false ) {
448 448
 					// Modify the original value so other key will be preserved
449
-					$value[ $other_key ] = $value[ $o_key ];
449
+					$value[$other_key] = $value[$o_key];
450 450
 
451 451
 					// By default, the array keys will be numeric for multi-select dropdowns
452 452
 					// If going backwards and forwards between pages, the array key will match the other key
453 453
 					if ( $o_key != $other_key ) {
454
-						unset( $value[ $o_key ] );
454
+						unset( $value[$o_key] );
455 455
 					}
456 456
 
457 457
 					$args['temp_value'] = $value;
458
-					$value[ $other_key ] = reset( $other_vals );
458
+					$value[$other_key] = reset( $other_vals );
459 459
 				}
460
-            } else if ( $field->options[ $other_key ] == $value ) {
460
+            } else if ( $field->options[$other_key] == $value ) {
461 461
                 $value = $other_vals;
462 462
             }
463 463
         }
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 				$content .= "\n\n";
477 477
 			}
478 478
 
479
-			if ( is_array($val) ) {
479
+			if ( is_array( $val ) ) {
480 480
 				$val = FrmAppHelper::array_flatten( $val );
481 481
 				$val = implode( ', ', $val );
482 482
 			}
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 		preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers
541 541
 
542 542
 		// see how many we have
543
-		$i = count($matches['browser']);
543
+		$i = count( $matches['browser'] );
544 544
 
545 545
 		if ( $i > 1 ) {
546 546
 			//we will have two since we are not using 'other' argument yet
Please login to merge, or discard this patch.