Completed
Push — master ( 2b4c19...598a1e )
by Stephanie
04:18
created
classes/helpers/FrmFieldsHelper.php 2 patches
Indentation   +691 added lines, -691 removed lines patch added patch discarded remove patch
@@ -7,71 +7,71 @@  discard block
 block discarded – undo
7 7
 
8 8
 	public static function setup_new_vars( $type = '', $form_id = '' ) {
9 9
 
10
-        if ( strpos($type, '|') ) {
11
-            list($type, $setting) = explode('|', $type);
12
-        }
13
-
14
-        $defaults = self::get_default_field_opts($type, $form_id);
15
-        $defaults['field_options']['custom_html'] = self::get_default_html($type);
16
-
17
-        $values = array();
18
-
19
-        foreach ( $defaults as $var => $default ) {
20
-            if ( $var == 'field_options' ) {
21
-                $values['field_options'] = array();
22
-                foreach ( $default as $opt_var => $opt_default ) {
23
-                    $values['field_options'][ $opt_var ] = $opt_default;
24
-                    unset($opt_var, $opt_default);
25
-                }
26
-            } else {
27
-                $values[ $var ] = $default;
28
-            }
29
-            unset($var, $default);
30
-        }
31
-
32
-        if ( isset( $setting ) && ! empty( $setting ) ) {
33
-            if ( 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
-        } else if ( 'url' == $type ) {
55
-            $values['name'] = __( 'Website', 'formidable' );
56
-        }
10
+		if ( strpos($type, '|') ) {
11
+			list($type, $setting) = explode('|', $type);
12
+		}
13
+
14
+		$defaults = self::get_default_field_opts($type, $form_id);
15
+		$defaults['field_options']['custom_html'] = self::get_default_html($type);
16
+
17
+		$values = array();
18
+
19
+		foreach ( $defaults as $var => $default ) {
20
+			if ( $var == 'field_options' ) {
21
+				$values['field_options'] = array();
22
+				foreach ( $default as $opt_var => $opt_default ) {
23
+					$values['field_options'][ $opt_var ] = $opt_default;
24
+					unset($opt_var, $opt_default);
25
+				}
26
+			} else {
27
+				$values[ $var ] = $default;
28
+			}
29
+			unset($var, $default);
30
+		}
31
+
32
+		if ( isset( $setting ) && ! empty( $setting ) ) {
33
+			if ( 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
+		} else if ( 'url' == $type ) {
55
+			$values['name'] = __( 'Website', 'formidable' );
56
+		}
57 57
 
58 58
 		$fields = FrmField::field_selection();
59
-        $fields = array_merge($fields, FrmField::pro_field_selection());
59
+		$fields = array_merge($fields, FrmField::pro_field_selection());
60 60
 
61
-        if ( isset( $fields[ $type ] ) ) {
62
-            $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
63
-        }
61
+		if ( isset( $fields[ $type ] ) ) {
62
+			$values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
63
+		}
64 64
 
65
-        unset($fields);
65
+		unset($fields);
66 66
 
67
-        return $values;
68
-    }
67
+		return $values;
68
+	}
69 69
 
70 70
 	public static function get_html_id( $field, $plus = '' ) {
71 71
 		return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field );
72
-    }
72
+	}
73 73
 
74
-    public static function setup_edit_vars( $record, $doing_ajax = false ) {
74
+	public static function setup_edit_vars( $record, $doing_ajax = false ) {
75 75
 		$values = array( 'id' => $record->id, 'form_id' => $record->form_id );
76 76
 		$defaults = array(
77 77
 			'name'          => $record->name,
@@ -84,86 +84,86 @@  discard block
 block discarded – undo
84 84
 		);
85 85
 
86 86
 		if ( $doing_ajax ) {
87
-            $values = $values + $defaults;
88
-            $values['form_name'] = '';
87
+			$values = $values + $defaults;
88
+			$values['form_name'] = '';
89 89
 		} else {
90 90
 			foreach ( $defaults as $var => $default ) {
91
-                $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
-                unset($var, $default);
93
-            }
91
+				$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
+				unset($var, $default);
93
+			}
94 94
 
95 95
 			$values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : '';
96
-        }
96
+		}
97 97
 
98 98
 		unset( $defaults );
99 99
 
100
-        $values['options'] = $record->options;
101
-        $values['field_options'] = $record->field_options;
100
+		$values['options'] = $record->options;
101
+		$values['field_options'] = $record->field_options;
102 102
 
103
-        $defaults = self::get_default_field_opts($values['type'], $record, true);
103
+		$defaults = self::get_default_field_opts($values['type'], $record, true);
104 104
 
105 105
 		if ( $values['type'] == 'captcha' ) {
106
-            $frm_settings = FrmAppHelper::get_settings();
107
-            $defaults['invalid'] = $frm_settings->re_msg;
108
-        }
106
+			$frm_settings = FrmAppHelper::get_settings();
107
+			$defaults['invalid'] = $frm_settings->re_msg;
108
+		}
109 109
 
110 110
 		foreach ( $defaults as $opt => $default ) {
111
-            $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
112
-            unset($opt, $default);
113
-        }
111
+			$values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
112
+			unset($opt, $default);
113
+		}
114 114
 
115
-        $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
115
+		$values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
116 116
 
117 117
 		return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) );
118
-    }
118
+	}
119 119
 
120
-    public static function get_default_field_opts( $type, $field, $limit = false ) {
121
-        $field_options = array(
122
-            'size' => '', 'max' => '', 'label' => '', 'blank' => '',
123
-            'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0,
124
-            'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '',
120
+	public static function get_default_field_opts( $type, $field, $limit = false ) {
121
+		$field_options = array(
122
+			'size' => '', 'max' => '', 'label' => '', 'blank' => '',
123
+			'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0,
124
+			'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '',
125 125
 			'custom_html' => '', 'captcha_size' => 'normal', 'captcha_theme' => 'light',
126
-        );
126
+		);
127 127
 
128 128
 		if ( $limit ) {
129
-            return $field_options;
129
+			return $field_options;
130 130
 		}
131 131
 
132
-        global $wpdb;
132
+		global $wpdb;
133 133
 
134
-        $form_id = (is_numeric($field)) ? $field : $field->form_id;
134
+		$form_id = (is_numeric($field)) ? $field : $field->form_id;
135 135
 
136 136
 		$key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key;
137 137
 
138
-        $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) );
138
+		$field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) );
139 139
 
140
-        $frm_settings = FrmAppHelper::get_settings();
141
-        return array(
142
-            'name' => __( 'Untitled', 'formidable' ), 'description' => '',
140
+		$frm_settings = FrmAppHelper::get_settings();
141
+		return array(
142
+			'name' => __( 'Untitled', 'formidable' ), 'description' => '',
143 143
 			'field_key' => $key, 'type' => $type, 'options' => '', 'default_value' => '',
144 144
 			'field_order' => $field_count + 1, 'required' => false,
145
-            'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg,
146
-            'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id,
145
+			'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg,
146
+			'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id,
147 147
 			'field_options' => $field_options,
148
-        );
149
-    }
148
+		);
149
+	}
150 150
 
151
-    public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
152
-        global $wpdb;
151
+	public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
152
+		global $wpdb;
153 153
 
154 154
 		$values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
155
-        $values['form_id'] = $form_id;
156
-        $values['options'] = maybe_serialize($field->options);
157
-        $values['default_value'] = maybe_serialize($field->default_value);
158
-
159
-        foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
160
-            $values[ $col ] = $field->{$col};
161
-        }
162
-    }
163
-
164
-    /**
165
-     * @since 2.0
166
-     */
155
+		$values['form_id'] = $form_id;
156
+		$values['options'] = maybe_serialize($field->options);
157
+		$values['default_value'] = maybe_serialize($field->default_value);
158
+
159
+		foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
160
+			$values[ $col ] = $field->{$col};
161
+		}
162
+	}
163
+
164
+	/**
165
+	 * @since 2.0
166
+	 */
167 167
 	public static function get_error_msg( $field, $error ) {
168 168
 		$frm_settings = FrmAppHelper::get_settings();
169 169
 		$default_settings = $frm_settings->default_options();
@@ -192,12 +192,12 @@  discard block
 block discarded – undo
192 192
 	public static function get_default_html( $type = 'text' ) {
193 193
 		if ( apply_filters( 'frm_normal_field_type_html', true, $type ) ) {
194 194
 			$input = ( in_array( $type, array( 'radio', 'checkbox', 'data' ) ) ) ? '<div class="frm_opt_container">[input]</div>' : '[input]';
195
-            $for = '';
195
+			$for = '';
196 196
 			if ( ! in_array( $type, array( 'radio', 'checkbox', 'data', 'scale' ) ) ) {
197
-                $for = 'for="field_[key]"';
198
-            }
197
+				$for = 'for="field_[key]"';
198
+			}
199 199
 
200
-            $default_html = <<<DEFAULT_HTML
200
+			$default_html = <<<DEFAULT_HTML
201 201
 <div id="frm_field_[id]_container" class="frm_form_field form-field [required_class][error_class]">
202 202
     <label $for class="frm_primary_label">[field_name]
203 203
         <span class="frm_required">[required_label]</span>
@@ -207,82 +207,82 @@  discard block
 block discarded – undo
207 207
     [if error]<div class="frm_error">[error]</div>[/if error]
208 208
 </div>
209 209
 DEFAULT_HTML;
210
-        } else {
210
+		} else {
211 211
 			$default_html = apply_filters('frm_other_custom_html', '', $type);
212
-        }
212
+		}
213 213
 
214
-        return apply_filters('frm_custom_html', $default_html, $type);
215
-    }
214
+		return apply_filters('frm_custom_html', $default_html, $type);
215
+	}
216 216
 
217 217
 	public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) {
218
-        $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
218
+		$html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
219 219
 
220
-        $defaults = array(
220
+		$defaults = array(
221 221
 			'field_name'    => 'item_meta[' . $field['id'] . ']',
222 222
 			'field_id'      => $field['id'],
223
-            'field_plus_id' => '',
224
-            'section_id'    => '',
225
-        );
226
-        $args = wp_parse_args($args, $defaults);
227
-        $field_name = $args['field_name'];
228
-        $field_id = $args['field_id'];
229
-        $html_id = self::get_html_id($field, $args['field_plus_id']);
223
+			'field_plus_id' => '',
224
+			'section_id'    => '',
225
+		);
226
+		$args = wp_parse_args($args, $defaults);
227
+		$field_name = $args['field_name'];
228
+		$field_id = $args['field_id'];
229
+		$html_id = self::get_html_id($field, $args['field_plus_id']);
230 230
 
231
-        if ( FrmField::is_multiple_select($field) ) {
232
-            $field_name .= '[]';
233
-        }
231
+		if ( FrmField::is_multiple_select($field) ) {
232
+			$field_name .= '[]';
233
+		}
234 234
 
235
-        //replace [id]
236
-        $html = str_replace('[id]', $field_id, $html);
235
+		//replace [id]
236
+		$html = str_replace('[id]', $field_id, $html);
237 237
 
238
-        // Remove the for attribute for captcha
239
-        if ( $field['type'] == 'captcha' ) {
240
-            $html = str_replace(' for="field_[key]"', '', $html);
241
-        }
238
+		// Remove the for attribute for captcha
239
+		if ( $field['type'] == 'captcha' ) {
240
+			$html = str_replace(' for="field_[key]"', '', $html);
241
+		}
242 242
 
243
-        // set the label for
244
-        $html = str_replace('field_[key]', $html_id, $html);
243
+		// set the label for
244
+		$html = str_replace('field_[key]', $html_id, $html);
245 245
 
246
-        //replace [key]
247
-        $html = str_replace('[key]', $field['field_key'], $html);
246
+		//replace [key]
247
+		$html = str_replace('[key]', $field['field_key'], $html);
248 248
 
249
-        //replace [description] and [required_label] and [error]
249
+		//replace [description] and [required_label] and [error]
250 250
 		$required = FrmField::is_required( $field ) ? $field['required_indicator'] : '';
251
-        if ( ! is_array( $errors ) ) {
252
-            $errors = array();
253
-        }
251
+		if ( ! is_array( $errors ) ) {
252
+			$errors = array();
253
+		}
254 254
 		$error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false;
255 255
 
256
-        //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
257
-        if ( $field['type'] == 'divider' ) {
258
-            if ( FrmField::is_option_true( $field, 'description' ) ) {
259
-                $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
260
-            } else {
261
-                $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
262
-            }
263
-        }
256
+		//If field type is section heading, add class so a bottom margin can be added to either the h3 or description
257
+		if ( $field['type'] == 'divider' ) {
258
+			if ( FrmField::is_option_true( $field, 'description' ) ) {
259
+				$html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
260
+			} else {
261
+				$html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
262
+			}
263
+		}
264 264
 
265 265
 		foreach ( array( 'description' => $field['description'], 'required_label' => $required, 'error' => $error ) as $code => $value ) {
266
-            self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html );
267
-        }
266
+			self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html );
267
+		}
268 268
 
269
-        //replace [required_class]
269
+		//replace [required_class]
270 270
 		$required_class = FrmField::is_required( $field ) ? ' frm_required_field' : '';
271
-        $html = str_replace('[required_class]', $required_class, $html);
271
+		$html = str_replace('[required_class]', $required_class, $html);
272 272
 
273
-        //replace [label_position]
274
-        $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
275
-        $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
273
+		//replace [label_position]
274
+		$field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
275
+		$field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
276 276
 		$html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html );
277 277
 
278
-        //replace [field_name]
279
-        $html = str_replace('[field_name]', $field['name'], $html);
278
+		//replace [field_name]
279
+		$html = str_replace('[field_name]', $field['name'], $html);
280 280
 
281 281
 		self::add_field_div_classes( $field_id, $field, $errors, $html );
282 282
 
283
-        //replace [entry_key]
284
-        $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
285
-        $html = str_replace('[entry_key]', $entry_key, $html);
283
+		//replace [entry_key]
284
+		$entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
285
+		$html = str_replace('[entry_key]', $entry_key, $html);
286 286
 
287 287
 		if ( $form ) {
288 288
 			$form = (array) $form;
@@ -296,57 +296,57 @@  discard block
 block discarded – undo
296 296
 
297 297
 		self::process_wp_shortcodes( $html );
298 298
 
299
-        //replace [input]
300
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
301
-        global $frm_vars;
302
-        $frm_settings = FrmAppHelper::get_settings();
299
+		//replace [input]
300
+		preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
301
+		global $frm_vars;
302
+		$frm_settings = FrmAppHelper::get_settings();
303 303
 
304
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
305
-            $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
304
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
305
+			$atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
306 306
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
307 307
 
308
-            $replace_with = '';
308
+			$replace_with = '';
309 309
 
310
-            if ( $tag == 'input' ) {
311
-                if ( isset($atts['opt']) ) {
312
-                    $atts['opt']--;
313
-                }
310
+			if ( $tag == 'input' ) {
311
+				if ( isset($atts['opt']) ) {
312
+					$atts['opt']--;
313
+				}
314 314
 
315
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
316
-                if ( isset($atts['class']) ) {
317
-                    unset($atts['class']);
318
-                }
315
+				$field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
316
+				if ( isset($atts['class']) ) {
317
+					unset($atts['class']);
318
+				}
319 319
 
320
-                $field['shortcodes'] = $atts;
321
-                ob_start();
320
+				$field['shortcodes'] = $atts;
321
+				ob_start();
322 322
 				include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' );
323
-                $replace_with = ob_get_contents();
324
-                ob_end_clean();
325
-            } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
326
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
327
-            }
323
+				$replace_with = ob_get_contents();
324
+				ob_end_clean();
325
+			} else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
326
+				$replace_with = FrmProEntriesController::entry_delete_link($atts);
327
+			}
328 328
 
329
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
330
-        }
329
+			$html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
330
+		}
331 331
 
332
-        $html .= "\n";
332
+		$html .= "\n";
333 333
 
334
-        //Return html if conf_field to prevent loop
335
-        if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
336
-            return $html;
337
-        }
334
+		//Return html if conf_field to prevent loop
335
+		if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
336
+			return $html;
337
+		}
338 338
 
339
-        //If field is in repeating section
340
-        if ( $args['section_id'] ) {
341
-            $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
-        } else {
343
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
344
-        }
339
+		//If field is in repeating section
340
+		if ( $args['section_id'] ) {
341
+			$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
+		} else {
343
+			$html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
344
+		}
345 345
 
346 346
 		self::remove_collapse_shortcode( $html );
347 347
 
348
-        return $html;
349
-    }
348
+		return $html;
349
+	}
350 350
 
351 351
 	/**
352 352
 	 * This filters shortcodes in the field HTML
@@ -411,46 +411,46 @@  discard block
 block discarded – undo
411 411
 		return $classes;
412 412
 	}
413 413
 
414
-    public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
415
-        if ( $no_vars ) {
414
+	public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
415
+		if ( $no_vars ) {
416 416
 			$html = str_replace( '[if ' . $code . ']', '', $html );
417 417
 			$html = str_replace( '[/if ' . $code . ']', '', $html );
418
-        } else {
418
+		} else {
419 419
 			$html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html );
420
-        }
420
+		}
421 421
 
422 422
 		$html = str_replace( '[' . $code . ']', $replace_with, $html );
423
-    }
423
+	}
424 424
 
425 425
 	public static function get_shortcode_tag( $shortcodes, $short_key, $args ) {
426 426
 		$args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) );
427
-        if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
428
-            $args['conditional_check'] = true;
429
-        }
430
-
431
-        $prefix = '';
432
-        if ( $args['conditional_check'] ) {
433
-            if ( $args['conditional'] ) {
434
-                $prefix = 'if ';
435
-            } else if ( $args['foreach'] ) {
436
-                $prefix = 'foreach ';
437
-            }
438
-        }
439
-
440
-        $with_tags = $args['conditional_check'] ? 3 : 2;
441
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
442
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
443
-            $tag = str_replace(']', '', $tag);
444
-            $tags = explode(' ', $tag);
445
-            if ( is_array($tags) ) {
446
-                $tag = $tags[0];
447
-            }
448
-        } else {
449
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
450
-        }
451
-
452
-        return $tag;
453
-    }
427
+		if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
428
+			$args['conditional_check'] = true;
429
+		}
430
+
431
+		$prefix = '';
432
+		if ( $args['conditional_check'] ) {
433
+			if ( $args['conditional'] ) {
434
+				$prefix = 'if ';
435
+			} else if ( $args['foreach'] ) {
436
+				$prefix = 'foreach ';
437
+			}
438
+		}
439
+
440
+		$with_tags = $args['conditional_check'] ? 3 : 2;
441
+		if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
442
+			$tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
443
+			$tag = str_replace(']', '', $tag);
444
+			$tags = explode(' ', $tag);
445
+			if ( is_array($tags) ) {
446
+				$tag = $tags[0];
447
+			}
448
+		} else {
449
+			$tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
450
+		}
451
+
452
+		return $tag;
453
+	}
454 454
 
455 455
 	/**
456 456
 	 * Remove [collapse_this] if it's still included after all processing
@@ -488,8 +488,8 @@  discard block
 block discarded – undo
488 488
 		}
489 489
 		$api_js_url = apply_filters( 'frm_recaptcha_js_url', $api_js_url );
490 490
 
491
-        wp_register_script( 'recaptcha-api', $api_js_url, '', true );
492
-        wp_enqueue_script( 'recaptcha-api' );
491
+		wp_register_script( 'recaptcha-api', $api_js_url, '', true );
492
+		wp_enqueue_script( 'recaptcha-api' );
493 493
 
494 494
 		// for reverse compatability
495 495
 		$field['captcha_size'] = ( $field['captcha_size'] == 'default' ) ? 'normal' : $field['captcha_size'];
@@ -497,40 +497,40 @@  discard block
 block discarded – undo
497 497
 ?>
498 498
 <div id="field_<?php echo esc_attr( $field['field_key'] ) ?>" class="<?php echo esc_attr( $class_prefix ) ?>g-recaptcha" data-sitekey="<?php echo esc_attr( $frm_settings->pubkey ) ?>" data-size="<?php echo esc_attr( $field['captcha_size'] ) ?>" data-theme="<?php echo esc_attr( $field['captcha_theme'] ) ?>"></div>
499 499
 <?php
500
-    }
500
+	}
501 501
 
502 502
 	public static function show_single_option( $field ) {
503
-        $field_name = $field['name'];
504
-        $html_id = self::get_html_id($field);
505
-        foreach ( $field['options'] as $opt_key => $opt ) {
506
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
507
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
503
+		$field_name = $field['name'];
504
+		$html_id = self::get_html_id($field);
505
+		foreach ( $field['options'] as $opt_key => $opt ) {
506
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
507
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
508 508
 
509
-            // If this is an "Other" option, get the HTML for it
509
+			// If this is an "Other" option, get the HTML for it
510 510
 			if ( self::is_other_opt( $opt_key ) ) {
511
-                // Get string for Other text field, if needed
511
+				// Get string for Other text field, if needed
512 512
 				$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
513 513
 				require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
514
-            } else {
514
+			} else {
515 515
 				require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
516
-            }
517
-        }
518
-    }
516
+			}
517
+		}
518
+	}
519 519
 
520 520
 	public static function get_term_link( $tax_id ) {
521
-        $tax = get_taxonomy($tax_id);
522
-        if ( ! $tax ) {
523
-            return;
524
-        }
521
+		$tax = get_taxonomy($tax_id);
522
+		if ( ! $tax ) {
523
+			return;
524
+		}
525 525
 
526
-        $link = sprintf(
527
-            __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
526
+		$link = sprintf(
527
+			__( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
528 528
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
529
-        );
530
-        unset($tax);
529
+		);
530
+		unset($tax);
531 531
 
532
-        return $link;
533
-    }
532
+		return $link;
533
+	}
534 534
 
535 535
 	public static function value_meets_condition( $observed_value, $cond, $hide_opt ) {
536 536
 		// Remove white space from hide_opt
@@ -541,199 +541,199 @@  discard block
 block discarded – undo
541 541
 		$observed_value = wp_kses_post( $observed_value );
542 542
 		$hide_opt = wp_kses_post( $hide_opt );
543 543
 
544
-        if ( is_array($observed_value) ) {
545
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
546
-        }
547
-
548
-        $m = false;
549
-        if ( $cond == '==' ) {
550
-            $m = $observed_value == $hide_opt;
551
-        } else if ( $cond == '!=' ) {
552
-            $m = $observed_value != $hide_opt;
553
-        } else if ( $cond == '>' ) {
554
-            $m = $observed_value > $hide_opt;
555
-        } else if ( $cond == '<' ) {
556
-            $m = $observed_value < $hide_opt;
557
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
558
-            $m = stripos($observed_value, $hide_opt);
559
-            if ( $cond == 'not LIKE' ) {
560
-                $m = ( $m === false ) ? true : false;
561
-            } else {
562
-                $m = ( $m === false ) ? false : true;
563
-            }
564
-        }
565
-        return $m;
566
-    }
544
+		if ( is_array($observed_value) ) {
545
+			return self::array_value_condition($observed_value, $cond, $hide_opt);
546
+		}
547
+
548
+		$m = false;
549
+		if ( $cond == '==' ) {
550
+			$m = $observed_value == $hide_opt;
551
+		} else if ( $cond == '!=' ) {
552
+			$m = $observed_value != $hide_opt;
553
+		} else if ( $cond == '>' ) {
554
+			$m = $observed_value > $hide_opt;
555
+		} else if ( $cond == '<' ) {
556
+			$m = $observed_value < $hide_opt;
557
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
558
+			$m = stripos($observed_value, $hide_opt);
559
+			if ( $cond == 'not LIKE' ) {
560
+				$m = ( $m === false ) ? true : false;
561
+			} else {
562
+				$m = ( $m === false ) ? false : true;
563
+			}
564
+		}
565
+		return $m;
566
+	}
567 567
 
568 568
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
569
-        $m = false;
570
-        if ( $cond == '==' ) {
571
-            if ( is_array($hide_opt) ) {
572
-                $m = array_intersect($hide_opt, $observed_value);
573
-                $m = empty($m) ? false : true;
574
-            } else {
575
-                $m = in_array($hide_opt, $observed_value);
576
-            }
577
-        } else if ( $cond == '!=' ) {
578
-            $m = ! in_array($hide_opt, $observed_value);
579
-        } else if ( $cond == '>' ) {
580
-            $min = min($observed_value);
581
-            $m = $min > $hide_opt;
582
-        } else if ( $cond == '<' ) {
583
-            $max = max($observed_value);
584
-            $m = $max < $hide_opt;
585
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
586
-            foreach ( $observed_value as $ob ) {
587
-                $m = strpos($ob, $hide_opt);
588
-                if ( $m !== false ) {
589
-                    $m = true;
590
-                    break;
591
-                }
592
-            }
593
-
594
-            if ( $cond == 'not LIKE' ) {
595
-                $m = ( $m === false ) ? true : false;
596
-            }
597
-        }
598
-
599
-        return $m;
600
-    }
601
-
602
-    /**
603
-     * Replace a few basic shortcodes and field ids
604
-     * @since 2.0
605
-     * @return string
606
-     */
569
+		$m = false;
570
+		if ( $cond == '==' ) {
571
+			if ( is_array($hide_opt) ) {
572
+				$m = array_intersect($hide_opt, $observed_value);
573
+				$m = empty($m) ? false : true;
574
+			} else {
575
+				$m = in_array($hide_opt, $observed_value);
576
+			}
577
+		} else if ( $cond == '!=' ) {
578
+			$m = ! in_array($hide_opt, $observed_value);
579
+		} else if ( $cond == '>' ) {
580
+			$min = min($observed_value);
581
+			$m = $min > $hide_opt;
582
+		} else if ( $cond == '<' ) {
583
+			$max = max($observed_value);
584
+			$m = $max < $hide_opt;
585
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
586
+			foreach ( $observed_value as $ob ) {
587
+				$m = strpos($ob, $hide_opt);
588
+				if ( $m !== false ) {
589
+					$m = true;
590
+					break;
591
+				}
592
+			}
593
+
594
+			if ( $cond == 'not LIKE' ) {
595
+				$m = ( $m === false ) ? true : false;
596
+			}
597
+		}
598
+
599
+		return $m;
600
+	}
601
+
602
+	/**
603
+	 * Replace a few basic shortcodes and field ids
604
+	 * @since 2.0
605
+	 * @return string
606
+	 */
607 607
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
608
-        if ( strpos($value, '[sitename]') !== false ) {
609
-            $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
610
-            $value = str_replace('[sitename]', $new_value, $value);
611
-        }
608
+		if ( strpos($value, '[sitename]') !== false ) {
609
+			$new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
610
+			$value = str_replace('[sitename]', $new_value, $value);
611
+		}
612 612
 
613
-        $value = apply_filters('frm_content', $value, $form, $entry);
614
-        $value = do_shortcode($value);
613
+		$value = apply_filters('frm_content', $value, $form, $entry);
614
+		$value = do_shortcode($value);
615 615
 
616
-        return $value;
617
-    }
616
+		return $value;
617
+	}
618 618
 
619 619
 	public static function get_shortcodes( $content, $form_id ) {
620
-        if ( FrmAppHelper::pro_is_installed() ) {
621
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
622
-        }
620
+		if ( FrmAppHelper::pro_is_installed() ) {
621
+			return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
622
+		}
623 623
 
624
-        $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
624
+		$fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
625 625
 
626
-        $tagregexp = self::allowed_shortcodes($fields);
626
+		$tagregexp = self::allowed_shortcodes($fields);
627 627
 
628
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
628
+		preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
629 629
 
630
-        return $matches;
631
-    }
630
+		return $matches;
631
+	}
632 632
 
633 633
 	public static function allowed_shortcodes( $fields = array() ) {
634
-        $tagregexp = array(
635
-            'editlink', 'id', 'key', 'ip',
636
-            'siteurl', 'sitename', 'admin_email',
637
-            'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
634
+		$tagregexp = array(
635
+			'editlink', 'id', 'key', 'ip',
636
+			'siteurl', 'sitename', 'admin_email',
637
+			'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
638 638
 			'parent[-|_]id',
639
-        );
639
+		);
640 640
 
641
-        foreach ( $fields as $field ) {
642
-            $tagregexp[] = $field->id;
643
-            $tagregexp[] = $field->field_key;
644
-        }
641
+		foreach ( $fields as $field ) {
642
+			$tagregexp[] = $field->id;
643
+			$tagregexp[] = $field->field_key;
644
+		}
645 645
 
646
-        $tagregexp = implode('|', $tagregexp);
647
-        return $tagregexp;
648
-    }
646
+		$tagregexp = implode('|', $tagregexp);
647
+		return $tagregexp;
648
+	}
649 649
 
650 650
 	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
651
-        $shortcode_values = array(
652
-           'id'     => $entry->id,
653
-           'key'    => $entry->item_key,
654
-           'ip'     => $entry->ip,
655
-        );
651
+		$shortcode_values = array(
652
+		   'id'     => $entry->id,
653
+		   'key'    => $entry->item_key,
654
+		   'ip'     => $entry->ip,
655
+		);
656 656
 
657
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
657
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
658 658
 			if ( empty( $tag ) ) {
659 659
 				continue;
660 660
 			}
661 661
 
662
-            $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] );
662
+			$atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] );
663 663
 
664
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
664
+			if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
665 665
 				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
666
-                $tags = explode(' ', $tag);
667
-                if ( is_array($tags) ) {
668
-                    $tag = $tags[0];
669
-                }
670
-            } else {
671
-                $tag = $shortcodes[2][ $short_key ];
672
-            }
673
-
674
-            switch ( $tag ) {
675
-                case 'id':
676
-                case 'key':
677
-                case 'ip':
678
-                    $replace_with = $shortcode_values[ $tag ];
679
-                break;
680
-
681
-                case 'user_agent':
682
-                case 'user-agent':
683
-                    $entry->description = maybe_unserialize($entry->description);
666
+				$tags = explode(' ', $tag);
667
+				if ( is_array($tags) ) {
668
+					$tag = $tags[0];
669
+				}
670
+			} else {
671
+				$tag = $shortcodes[2][ $short_key ];
672
+			}
673
+
674
+			switch ( $tag ) {
675
+				case 'id':
676
+				case 'key':
677
+				case 'ip':
678
+					$replace_with = $shortcode_values[ $tag ];
679
+				break;
680
+
681
+				case 'user_agent':
682
+				case 'user-agent':
683
+					$entry->description = maybe_unserialize($entry->description);
684 684
 					$replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] );
685
-                break;
686
-
687
-                case 'created_at':
688
-                case 'created-at':
689
-                case 'updated_at':
690
-                case 'updated-at':
691
-                    if ( isset($atts['format']) ) {
692
-                        $time_format = ' ';
693
-                    } else {
694
-                        $atts['format'] = get_option('date_format');
695
-                        $time_format = '';
696
-                    }
697
-
698
-                    $this_tag = str_replace('-', '_', $tag);
699
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
700
-                    unset($this_tag);
701
-                break;
702
-
703
-                case 'created_by':
704
-                case 'created-by':
705
-                case 'updated_by':
706
-                case 'updated-by':
707
-                    $this_tag = str_replace('-', '_', $tag);
685
+				break;
686
+
687
+				case 'created_at':
688
+				case 'created-at':
689
+				case 'updated_at':
690
+				case 'updated-at':
691
+					if ( isset($atts['format']) ) {
692
+						$time_format = ' ';
693
+					} else {
694
+						$atts['format'] = get_option('date_format');
695
+						$time_format = '';
696
+					}
697
+
698
+					$this_tag = str_replace('-', '_', $tag);
699
+					$replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
700
+					unset($this_tag);
701
+				break;
702
+
703
+				case 'created_by':
704
+				case 'created-by':
705
+				case 'updated_by':
706
+				case 'updated-by':
707
+					$this_tag = str_replace('-', '_', $tag);
708 708
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
709
-                    unset($this_tag);
710
-                break;
711
-
712
-                case 'admin_email':
713
-                case 'siteurl':
714
-                case 'frmurl':
715
-                case 'sitename':
716
-                case 'get':
717
-                    $replace_with = self::dynamic_default_values( $tag, $atts );
718
-                break;
719
-
720
-                default:
721
-                    $field = FrmField::getOne( $tag );
722
-                    if ( ! $field ) {
723
-                        break;
724
-                    }
725
-
726
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
727
-
728
-                    $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
729
-
730
-                    $atts['entry_id'] = $entry->id;
731
-                    $atts['entry_key'] = $entry->item_key;
732
-
733
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
734
-                        $replace_with = $field->name;
735
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
736
-                        $replace_with = $field->description;
709
+					unset($this_tag);
710
+				break;
711
+
712
+				case 'admin_email':
713
+				case 'siteurl':
714
+				case 'frmurl':
715
+				case 'sitename':
716
+				case 'get':
717
+					$replace_with = self::dynamic_default_values( $tag, $atts );
718
+				break;
719
+
720
+				default:
721
+					$field = FrmField::getOne( $tag );
722
+					if ( ! $field ) {
723
+						break;
724
+					}
725
+
726
+					$sep = isset($atts['sep']) ? $atts['sep'] : ', ';
727
+
728
+					$replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
729
+
730
+					$atts['entry_id'] = $entry->id;
731
+					$atts['entry_key'] = $entry->item_key;
732
+
733
+					if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
734
+						$replace_with = $field->name;
735
+					} else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
736
+						$replace_with = $field->description;
737 737
 					} else {
738 738
 						$string_value = $replace_with;
739 739
 						if ( is_array( $replace_with ) ) {
@@ -747,82 +747,82 @@  discard block
 block discarded – undo
747 747
 						}
748 748
 					}
749 749
 
750
-                    unset($field);
751
-                break;
752
-            }
750
+					unset($field);
751
+				break;
752
+			}
753 753
 
754
-            if ( isset($replace_with) ) {
755
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
756
-            }
754
+			if ( isset($replace_with) ) {
755
+				$content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
756
+			}
757 757
 
758
-            unset($atts, $conditional, $replace_with);
758
+			unset($atts, $conditional, $replace_with);
759 759
 		}
760 760
 
761 761
 		return $content;
762
-    }
763
-
764
-    /**
765
-     * Get the value to replace a few standard shortcodes
766
-     *
767
-     * @since 2.0
768
-     * @return string
769
-     */
770
-    public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
771
-        $new_value = '';
772
-        switch ( $tag ) {
773
-            case 'admin_email':
774
-                $new_value = get_option('admin_email');
775
-                break;
776
-            case 'siteurl':
777
-                $new_value = FrmAppHelper::site_url();
778
-                break;
779
-            case 'frmurl':
780
-                $new_value = FrmAppHelper::plugin_url();
781
-                break;
782
-            case 'sitename':
783
-                $new_value = FrmAppHelper::site_name();
784
-                break;
785
-            case 'get':
786
-                $new_value = self::process_get_shortcode( $atts, $return_array );
787
-                break;
788
-        }
789
-
790
-        return $new_value;
791
-    }
792
-
793
-    /**
794
-     * Process the [get] shortcode
795
-     *
796
-     * @since 2.0
797
-     * @return string|array
798
-     */
799
-    public static function process_get_shortcode( $atts, $return_array = false ) {
800
-        if ( ! isset($atts['param']) ) {
801
-            return '';
802
-        }
803
-
804
-        if ( strpos($atts['param'], '&#91;') ) {
805
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
806
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
807
-        }
808
-
809
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
810
-        $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
811
-
812
-        if ( $new_value == '' ) {
813
-            if ( ! isset($atts['prev_val']) ) {
814
-                $atts['prev_val'] = '';
815
-            }
816
-
817
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
818
-        }
819
-
820
-        if ( is_array($new_value) && ! $return_array ) {
821
-            $new_value = implode(', ', $new_value);
822
-        }
823
-
824
-        return $new_value;
825
-    }
762
+	}
763
+
764
+	/**
765
+	 * Get the value to replace a few standard shortcodes
766
+	 *
767
+	 * @since 2.0
768
+	 * @return string
769
+	 */
770
+	public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
771
+		$new_value = '';
772
+		switch ( $tag ) {
773
+			case 'admin_email':
774
+				$new_value = get_option('admin_email');
775
+				break;
776
+			case 'siteurl':
777
+				$new_value = FrmAppHelper::site_url();
778
+				break;
779
+			case 'frmurl':
780
+				$new_value = FrmAppHelper::plugin_url();
781
+				break;
782
+			case 'sitename':
783
+				$new_value = FrmAppHelper::site_name();
784
+				break;
785
+			case 'get':
786
+				$new_value = self::process_get_shortcode( $atts, $return_array );
787
+				break;
788
+		}
789
+
790
+		return $new_value;
791
+	}
792
+
793
+	/**
794
+	 * Process the [get] shortcode
795
+	 *
796
+	 * @since 2.0
797
+	 * @return string|array
798
+	 */
799
+	public static function process_get_shortcode( $atts, $return_array = false ) {
800
+		if ( ! isset($atts['param']) ) {
801
+			return '';
802
+		}
803
+
804
+		if ( strpos($atts['param'], '&#91;') ) {
805
+			$atts['param'] = str_replace('&#91;', '[', $atts['param']);
806
+			$atts['param'] = str_replace('&#93;', ']', $atts['param']);
807
+		}
808
+
809
+		$new_value = FrmAppHelper::get_param($atts['param'], '');
810
+		$new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
811
+
812
+		if ( $new_value == '' ) {
813
+			if ( ! isset($atts['prev_val']) ) {
814
+				$atts['prev_val'] = '';
815
+			}
816
+
817
+			$new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
818
+		}
819
+
820
+		if ( is_array($new_value) && ! $return_array ) {
821
+			$new_value = implode(', ', $new_value);
822
+		}
823
+
824
+		return $new_value;
825
+	}
826 826
 
827 827
 	public static function get_display_value( $replace_with, $field, $atts = array() ) {
828 828
 		$sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
@@ -830,14 +830,14 @@  discard block
 block discarded – undo
830 830
 		$replace_with = apply_filters( 'frm_get_' . $field->type . '_display_value', $replace_with, $field, $atts );
831 831
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
832 832
 
833
-        if ( $field->type == 'textarea' || $field->type == 'rte' ) {
834
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
835
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
836
-                if ( is_array($replace_with) ) {
837
-                    $replace_with = implode("\n", $replace_with);
838
-                }
839
-                $replace_with = wpautop($replace_with);
840
-            }
833
+		if ( $field->type == 'textarea' || $field->type == 'rte' ) {
834
+			$autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
835
+			if ( apply_filters('frm_use_wpautop', $autop) ) {
836
+				if ( is_array($replace_with) ) {
837
+					$replace_with = implode("\n", $replace_with);
838
+				}
839
+				$replace_with = wpautop($replace_with);
840
+			}
841 841
 			unset( $autop );
842 842
 		} else if ( is_array( $replace_with ) ) {
843 843
 			$replace_with = implode( $sep, $replace_with );
@@ -847,37 +847,37 @@  discard block
 block discarded – undo
847 847
 	}
848 848
 
849 849
 	public static function get_field_types( $type ) {
850
-        $single_input = array(
851
-            'text', 'textarea', 'rte', 'number', 'email', 'url',
852
-            'image', 'file', 'date', 'phone', 'hidden', 'time',
853
-            'user_id', 'tag', 'password',
854
-        );
850
+		$single_input = array(
851
+			'text', 'textarea', 'rte', 'number', 'email', 'url',
852
+			'image', 'file', 'date', 'phone', 'hidden', 'time',
853
+			'user_id', 'tag', 'password',
854
+		);
855 855
 		$multiple_input = array( 'radio', 'checkbox', 'select', 'scale', 'lookup' );
856 856
 		$other_type = array( 'html', 'break' );
857 857
 
858 858
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
859 859
 
860
-        $field_types = array();
861
-        if ( in_array($type, $single_input) ) {
862
-            self::field_types_for_input( $single_input, $field_selection, $field_types );
863
-        } else if ( in_array($type, $multiple_input) ) {
864
-            self::field_types_for_input( $multiple_input, $field_selection, $field_types );
865
-        } else if ( in_array($type, $other_type) ) {
866
-            self::field_types_for_input( $other_type, $field_selection, $field_types );
860
+		$field_types = array();
861
+		if ( in_array($type, $single_input) ) {
862
+			self::field_types_for_input( $single_input, $field_selection, $field_types );
863
+		} else if ( in_array($type, $multiple_input) ) {
864
+			self::field_types_for_input( $multiple_input, $field_selection, $field_types );
865
+		} else if ( in_array($type, $other_type) ) {
866
+			self::field_types_for_input( $other_type, $field_selection, $field_types );
867 867
 		} else if ( isset( $field_selection[ $type ] ) ) {
868
-            $field_types[ $type ] = $field_selection[ $type ];
869
-        }
868
+			$field_types[ $type ] = $field_selection[ $type ];
869
+		}
870 870
 
871 871
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
872
-        return $field_types;
873
-    }
872
+		return $field_types;
873
+	}
874 874
 
875
-    private static function field_types_for_input( $inputs, $fields, &$field_types ) {
876
-        foreach ( $inputs as $input ) {
877
-            $field_types[ $input ] = $fields[ $input ];
878
-            unset($input);
879
-        }
880
-    }
875
+	private static function field_types_for_input( $inputs, $fields, &$field_types ) {
876
+		foreach ( $inputs as $input ) {
877
+			$field_types[ $input ] = $fields[ $input ];
878
+			unset($input);
879
+		}
880
+	}
881 881
 
882 882
 	/**
883 883
 	 * Check if current field option is an "other" option
@@ -891,14 +891,14 @@  discard block
 block discarded – undo
891 891
 		return $opt_key && strpos( $opt_key, 'other_' ) === 0;
892 892
 	}
893 893
 
894
-    /**
895
-    * Get value that belongs in "Other" text box
896
-    *
897
-    * @since 2.0.6
898
-    *
899
-    * @param array $args
900
-    */
901
-    public static function get_other_val( $args ) {
894
+	/**
895
+	 * Get value that belongs in "Other" text box
896
+	 *
897
+	 * @since 2.0.6
898
+	 *
899
+	 * @param array $args
900
+	 */
901
+	public static function get_other_val( $args ) {
902 902
 		$defaults = array(
903 903
 			'opt_key' => 0, 'field' => array(),
904 904
 			'parent' => false, 'pointer' => false,
@@ -974,20 +974,20 @@  discard block
 block discarded – undo
974 974
 		}
975 975
 
976 976
 		return $other_val;
977
-    }
978
-
979
-    /**
980
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
981
-    * Intended for front-end use
982
-    *
983
-    * @since 2.0.6
984
-    *
985
-    * @param array $args should include field, opt_key and field name
986
-    * @param boolean $other_opt
987
-    * @param string $checked
988
-    * @return string $other_val
989
-    */
990
-    public static function prepare_other_input( $args, &$other_opt, &$checked ) {
977
+	}
978
+
979
+	/**
980
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
981
+	 * Intended for front-end use
982
+	 *
983
+	 * @since 2.0.6
984
+	 *
985
+	 * @param array $args should include field, opt_key and field name
986
+	 * @param boolean $other_opt
987
+	 * @param string $checked
988
+	 * @return string $other_val
989
+	 */
990
+	public static function prepare_other_input( $args, &$other_opt, &$checked ) {
991 991
 		//Check if this is an "Other" option
992 992
 		if ( ! self::is_other_opt( $args['opt_key'] ) ) {
993 993
 			return;
@@ -1003,8 +1003,8 @@  discard block
 block discarded – undo
1003 1003
 			$checked = 'checked="checked" ';
1004 1004
 		}
1005 1005
 
1006
-        return $other_args;
1007
-    }
1006
+		return $other_args;
1007
+	}
1008 1008
 
1009 1009
 	/**
1010 1010
 	 * @param array $args
@@ -1054,8 +1054,8 @@  discard block
 block discarded – undo
1054 1054
 	 * @since 2.0.6
1055 1055
 	 */
1056 1056
 	public static function include_other_input( $args ) {
1057
-        if ( ! $args['other_opt'] ) {
1058
-        	return;
1057
+		if ( ! $args['other_opt'] ) {
1058
+			return;
1059 1059
 		}
1060 1060
 
1061 1061
 		$classes = array( 'frm_other_input' );
@@ -1076,15 +1076,15 @@  discard block
 block discarded – undo
1076 1076
 	}
1077 1077
 
1078 1078
 	/**
1079
-	* Get the HTML id for an "Other" text field
1080
-	* Note: This does not affect fields in repeating sections
1081
-	*
1082
-	* @since 2.0.08
1083
-	* @param string $type - field type
1084
-	* @param string $html_id
1085
-	* @param string|boolean $opt_key
1086
-	* @return string $other_id
1087
-	*/
1079
+	 * Get the HTML id for an "Other" text field
1080
+	 * Note: This does not affect fields in repeating sections
1081
+	 *
1082
+	 * @since 2.0.08
1083
+	 * @param string $type - field type
1084
+	 * @param string $html_id
1085
+	 * @param string|boolean $opt_key
1086
+	 * @return string $other_id
1087
+	 */
1088 1088
 	public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) {
1089 1089
 		$other_id = $html_id;
1090 1090
 
@@ -1142,10 +1142,10 @@  discard block
 block discarded – undo
1142 1142
 	}
1143 1143
 
1144 1144
 	public static function switch_field_ids( $val ) {
1145
-        global $frm_duplicate_ids;
1146
-        $replace = array();
1147
-        $replace_with = array();
1148
-        foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1145
+		global $frm_duplicate_ids;
1146
+		$replace = array();
1147
+		$replace_with = array();
1148
+		foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1149 1149
 			$replace[] = '[if ' . $old . ']';
1150 1150
 			$replace_with[] = '[if ' . $new . ']';
1151 1151
 			$replace[] = '[if ' . $old . ' ';
@@ -1160,153 +1160,153 @@  discard block
 block discarded – undo
1160 1160
 			$replace_with[] = '[' . $new . ']';
1161 1161
 			$replace[] = '[' . $old . ' ';
1162 1162
 			$replace_with[] = '[' . $new . ' ';
1163
-            unset($old, $new);
1164
-        }
1163
+			unset($old, $new);
1164
+		}
1165 1165
 		if ( is_array( $val ) ) {
1166 1166
 			foreach ( $val as $k => $v ) {
1167
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1168
-                unset($k, $v);
1169
-            }
1170
-        } else {
1171
-            $val = str_replace($replace, $replace_with, $val);
1172
-        }
1173
-
1174
-        return $val;
1175
-    }
1176
-
1177
-    public static function get_us_states() {
1178
-        return apply_filters( 'frm_us_states', array(
1179
-            'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1180
-            'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1181
-            'DC' => 'District of Columbia',
1182
-            'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1183
-            'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1184
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1185
-            'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1186
-            'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1187
-            'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1188
-            'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1189
-            'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1190
-            'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1191
-            'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1192
-            'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1193
-        ) );
1194
-    }
1195
-
1196
-    public static function get_countries() {
1197
-        return apply_filters( 'frm_countries', array(
1198
-            __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1199
-            __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1200
-            __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1201
-            __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1202
-            __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1203
-            __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1204
-            __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1205
-            __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1206
-            __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1207
-            __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1208
-            __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1209
-            __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1210
-            __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1211
-            __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1212
-            __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1213
-            __( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1214
-            __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1215
-            __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1216
-            __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1217
-            __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1218
-            __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1219
-            __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1220
-            __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1221
-            __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1222
-            __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1223
-            __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1224
-            __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1225
-            __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1226
-            __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1227
-            __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1228
-            __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1229
-            __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1230
-            __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1231
-            __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1232
-            __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1233
-            __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1234
-            __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1235
-            __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1236
-            __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1237
-            __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1238
-            __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1239
-            __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1240
-            __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1241
-            __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1242
-            __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1243
-            __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1244
-            __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1245
-            __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1246
-            __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1247
-            __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1248
-            __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1249
-            __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1250
-            __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1251
-            __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1252
-            __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1253
-            __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1254
-            __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1255
-            __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1256
-            __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1257
-            __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1258
-            __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1259
-            __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1260
-            __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1261
-            __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1262
-            __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1263
-            __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1264
-            __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1265
-            __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1266
-            __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1267
-            __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1268
-            __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1269
-            __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1270
-            __( 'Zimbabwe', 'formidable' ),
1271
-        ) );
1272
-    }
1167
+				$val[ $k ] = str_replace( $replace, $replace_with, $v );
1168
+				unset($k, $v);
1169
+			}
1170
+		} else {
1171
+			$val = str_replace($replace, $replace_with, $val);
1172
+		}
1173
+
1174
+		return $val;
1175
+	}
1176
+
1177
+	public static function get_us_states() {
1178
+		return apply_filters( 'frm_us_states', array(
1179
+			'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1180
+			'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1181
+			'DC' => 'District of Columbia',
1182
+			'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1183
+			'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1184
+			'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1185
+			'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1186
+			'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1187
+			'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1188
+			'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1189
+			'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1190
+			'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1191
+			'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1192
+			'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1193
+		) );
1194
+	}
1195
+
1196
+	public static function get_countries() {
1197
+		return apply_filters( 'frm_countries', array(
1198
+			__( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1199
+			__( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1200
+			__( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1201
+			__( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1202
+			__( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1203
+			__( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1204
+			__( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1205
+			__( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1206
+			__( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1207
+			__( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1208
+			__( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1209
+			__( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1210
+			__( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1211
+			__( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1212
+			__( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1213
+			__( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1214
+			__( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1215
+			__( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1216
+			__( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1217
+			__( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1218
+			__( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1219
+			__( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1220
+			__( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1221
+			__( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1222
+			__( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1223
+			__( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1224
+			__( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1225
+			__( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1226
+			__( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1227
+			__( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1228
+			__( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1229
+			__( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1230
+			__( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1231
+			__( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1232
+			__( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1233
+			__( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1234
+			__( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1235
+			__( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1236
+			__( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1237
+			__( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1238
+			__( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1239
+			__( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1240
+			__( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1241
+			__( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1242
+			__( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1243
+			__( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1244
+			__( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1245
+			__( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1246
+			__( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1247
+			__( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1248
+			__( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1249
+			__( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1250
+			__( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1251
+			__( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1252
+			__( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1253
+			__( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1254
+			__( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1255
+			__( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1256
+			__( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1257
+			__( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1258
+			__( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1259
+			__( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1260
+			__( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1261
+			__( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1262
+			__( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1263
+			__( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1264
+			__( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1265
+			__( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1266
+			__( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1267
+			__( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1268
+			__( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1269
+			__( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1270
+			__( 'Zimbabwe', 'formidable' ),
1271
+		) );
1272
+	}
1273 1273
 
1274 1274
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1275 1275
 		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1276 1276
 
1277
-        $states = FrmFieldsHelper::get_us_states();
1278
-        $state_abv = array_keys($states);
1279
-        sort($state_abv);
1277
+		$states = FrmFieldsHelper::get_us_states();
1278
+		$state_abv = array_keys($states);
1279
+		sort($state_abv);
1280 1280
 		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1281 1281
 
1282
-        $states = array_values($states);
1283
-        sort($states);
1282
+		$states = array_values($states);
1283
+		sort($states);
1284 1284
 		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1285
-        unset($state_abv, $states);
1285
+		unset($state_abv, $states);
1286 1286
 
1287 1287
 		$prepop[ __( 'Age', 'formidable' ) ] = array(
1288
-            __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1289
-            __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1290
-            __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1291
-        );
1288
+			__( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1289
+			__( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1290
+			__( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1291
+		);
1292 1292
 
1293 1293
 		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1294
-            __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1295
-            __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1296
-        );
1294
+			__( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1295
+			__( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1296
+		);
1297 1297
 
1298 1298
 		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1299
-            __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1300
-            __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1301
-        );
1299
+			__( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1300
+			__( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1301
+		);
1302 1302
 
1303 1303
 		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1304
-            __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1305
-            __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1306
-        );
1304
+			__( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1305
+			__( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1306
+		);
1307 1307
 
1308 1308
 		$prepop = apply_filters( 'frm_bulk_field_choices', $prepop );
1309
-    }
1309
+	}
1310 1310
 
1311 1311
 	/**
1312 1312
 	 * Display a field value selector
@@ -1316,10 +1316,10 @@  discard block
 block discarded – undo
1316 1316
 	 * @param int $selector_field_id
1317 1317
 	 * @param array $selector_args
1318 1318
 	 */
1319
-    public static function display_field_value_selector( $selector_field_id, $selector_args ) {
1320
-	    $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args );
1321
-	    $field_value_selector->display();
1322
-    }
1319
+	public static function display_field_value_selector( $selector_field_id, $selector_args ) {
1320
+		$field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args );
1321
+		$field_value_selector->display();
1322
+	}
1323 1323
 
1324 1324
 	/**
1325 1325
 	 * Convert a field object to a flat array
@@ -1372,10 +1372,10 @@  discard block
 block discarded – undo
1372 1372
 		return FrmField::is_required( $field );
1373 1373
 	}
1374 1374
 
1375
-    public static function maybe_get_field( &$field ) {
1375
+	public static function maybe_get_field( &$field ) {
1376 1376
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' );
1377 1377
 		FrmField::maybe_get_field( $field );
1378
-    }
1378
+	}
1379 1379
 
1380 1380
 	public static function dropdown_categories( $args ) {
1381 1381
 		_deprecated_function( __FUNCTION__, '2.02.07', 'FrmProPost::get_category_dropdown' );
Please login to merge, or discard this patch.
Spacing   +162 added lines, -162 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
 
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
         }
57 57
 
58 58
 		$fields = FrmField::field_selection();
59
-        $fields = array_merge($fields, FrmField::pro_field_selection());
59
+        $fields = array_merge( $fields, FrmField::pro_field_selection() );
60 60
 
61
-        if ( isset( $fields[ $type ] ) ) {
62
-            $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
61
+        if ( isset( $fields[$type] ) ) {
62
+            $values['name'] = is_array( $fields[$type] ) ? $fields[$type]['name'] : $fields[$type];
63 63
         }
64 64
 
65
-        unset($fields);
65
+        unset( $fields );
66 66
 
67 67
         return $values;
68 68
     }
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
             $values['form_name'] = '';
89 89
 		} else {
90 90
 			foreach ( $defaults as $var => $default ) {
91
-                $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
-                unset($var, $default);
91
+                $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
+                unset( $var, $default );
93 93
             }
94 94
 
95 95
 			$values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : '';
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         $values['options'] = $record->options;
101 101
         $values['field_options'] = $record->field_options;
102 102
 
103
-        $defaults = self::get_default_field_opts($values['type'], $record, true);
103
+        $defaults = self::get_default_field_opts( $values['type'], $record, true );
104 104
 
105 105
 		if ( $values['type'] == 'captcha' ) {
106 106
             $frm_settings = FrmAppHelper::get_settings();
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
         }
109 109
 
110 110
 		foreach ( $defaults as $opt => $default ) {
111
-            $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
112
-            unset($opt, $default);
111
+            $values[$opt] = isset( $record->field_options[$opt] ) ? $record->field_options[$opt] : $default;
112
+            unset( $opt, $default );
113 113
         }
114 114
 
115
-        $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
115
+        $values['custom_html'] = ( isset( $record->field_options['custom_html'] ) ) ? $record->field_options['custom_html'] : self::get_default_html( $record->type );
116 116
 
117 117
 		return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) );
118 118
     }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 
132 132
         global $wpdb;
133 133
 
134
-        $form_id = (is_numeric($field)) ? $field : $field->form_id;
134
+        $form_id = ( is_numeric( $field ) ) ? $field : $field->form_id;
135 135
 
136 136
 		$key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key;
137 137
 
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
 
154 154
 		$values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
155 155
         $values['form_id'] = $form_id;
156
-        $values['options'] = maybe_serialize($field->options);
157
-        $values['default_value'] = maybe_serialize($field->default_value);
156
+        $values['options'] = maybe_serialize( $field->options );
157
+        $values['default_value'] = maybe_serialize( $field->default_value );
158 158
 
159 159
         foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
160
-            $values[ $col ] = $field->{$col};
160
+            $values[$col] = $field->{$col};
161 161
         }
162 162
     }
163 163
 
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
 
172 172
 		$conf_msg = __( 'The entered values do not match', 'formidable' );
173 173
 		$defaults = array(
174
-			'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __('%s must be unique', 'formidable' ), $field_name ) ),
175
-			'invalid'   => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __('%s is invalid', 'formidable' ), $field_name ) ),
174
+			'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __( '%s must be unique', 'formidable' ), $field_name ) ),
175
+			'invalid'   => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __( '%s is invalid', 'formidable' ), $field_name ) ),
176 176
 			'blank'     => array( 'full' => $frm_settings->blank_msg, 'part' => $frm_settings->blank_msg ),
177 177
 			'conf_msg'  => array( 'full' => $conf_msg, 'part' => $conf_msg ),
178 178
 		);
179 179
 
180 180
 		$msg = FrmField::get_option( $field, $error );
181
-		$msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg;
181
+		$msg = empty( $msg ) ? $defaults[$error]['part'] : $msg;
182 182
 		$msg = do_shortcode( $msg );
183 183
 		return $msg;
184 184
 	}
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
 </div>
209 209
 DEFAULT_HTML;
210 210
         } else {
211
-			$default_html = apply_filters('frm_other_custom_html', '', $type);
211
+			$default_html = apply_filters( 'frm_other_custom_html', '', $type );
212 212
         }
213 213
 
214
-        return apply_filters('frm_custom_html', $default_html, $type);
214
+        return apply_filters( 'frm_custom_html', $default_html, $type );
215 215
     }
216 216
 
217 217
 	public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) {
218
-        $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
218
+        $html = apply_filters( 'frm_before_replace_shortcodes', $html, $field, $errors, $form );
219 219
 
220 220
         $defaults = array(
221 221
 			'field_name'    => 'item_meta[' . $field['id'] . ']',
@@ -223,42 +223,42 @@  discard block
 block discarded – undo
223 223
             'field_plus_id' => '',
224 224
             'section_id'    => '',
225 225
         );
226
-        $args = wp_parse_args($args, $defaults);
226
+        $args = wp_parse_args( $args, $defaults );
227 227
         $field_name = $args['field_name'];
228 228
         $field_id = $args['field_id'];
229
-        $html_id = self::get_html_id($field, $args['field_plus_id']);
229
+        $html_id = self::get_html_id( $field, $args['field_plus_id'] );
230 230
 
231
-        if ( FrmField::is_multiple_select($field) ) {
231
+        if ( FrmField::is_multiple_select( $field ) ) {
232 232
             $field_name .= '[]';
233 233
         }
234 234
 
235 235
         //replace [id]
236
-        $html = str_replace('[id]', $field_id, $html);
236
+        $html = str_replace( '[id]', $field_id, $html );
237 237
 
238 238
         // Remove the for attribute for captcha
239 239
         if ( $field['type'] == 'captcha' ) {
240
-            $html = str_replace(' for="field_[key]"', '', $html);
240
+            $html = str_replace( ' for="field_[key]"', '', $html );
241 241
         }
242 242
 
243 243
         // set the label for
244
-        $html = str_replace('field_[key]', $html_id, $html);
244
+        $html = str_replace( 'field_[key]', $html_id, $html );
245 245
 
246 246
         //replace [key]
247
-        $html = str_replace('[key]', $field['field_key'], $html);
247
+        $html = str_replace( '[key]', $field['field_key'], $html );
248 248
 
249 249
         //replace [description] and [required_label] and [error]
250 250
 		$required = FrmField::is_required( $field ) ? $field['required_indicator'] : '';
251 251
         if ( ! is_array( $errors ) ) {
252 252
             $errors = array();
253 253
         }
254
-		$error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false;
254
+		$error = isset( $errors['field' . $field_id] ) ? $errors['field' . $field_id] : false;
255 255
 
256 256
         //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
257 257
         if ( $field['type'] == 'divider' ) {
258 258
             if ( FrmField::is_option_true( $field, 'description' ) ) {
259 259
                 $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
260 260
             } else {
261
-                $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
261
+                $html = str_replace( '[label_position]', '[label_position] frm_section_spacing', $html );
262 262
             }
263 263
         }
264 264
 
@@ -268,53 +268,53 @@  discard block
 block discarded – undo
268 268
 
269 269
         //replace [required_class]
270 270
 		$required_class = FrmField::is_required( $field ) ? ' frm_required_field' : '';
271
-        $html = str_replace('[required_class]', $required_class, $html);
271
+        $html = str_replace( '[required_class]', $required_class, $html );
272 272
 
273 273
         //replace [label_position]
274
-        $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
274
+        $field['label'] = apply_filters( 'frm_html_label_position', $field['label'], $field, $form );
275 275
         $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
276 276
 		$html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html );
277 277
 
278 278
         //replace [field_name]
279
-        $html = str_replace('[field_name]', $field['name'], $html);
279
+        $html = str_replace( '[field_name]', $field['name'], $html );
280 280
 
281 281
 		self::add_field_div_classes( $field_id, $field, $errors, $html );
282 282
 
283 283
         //replace [entry_key]
284 284
         $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
285
-        $html = str_replace('[entry_key]', $entry_key, $html);
285
+        $html = str_replace( '[entry_key]', $entry_key, $html );
286 286
 
287 287
 		if ( $form ) {
288 288
 			$form = (array) $form;
289 289
 
290 290
 			//replace [form_key]
291
-			$html = str_replace('[form_key]', $form['form_key'], $html);
291
+			$html = str_replace( '[form_key]', $form['form_key'], $html );
292 292
 
293 293
 			//replace [form_name]
294
-			$html = str_replace('[form_name]', $form['name'], $html);
294
+			$html = str_replace( '[form_name]', $form['name'], $html );
295 295
 		}
296 296
 
297 297
 		self::process_wp_shortcodes( $html );
298 298
 
299 299
         //replace [input]
300
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
300
+        preg_match_all( "/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER );
301 301
         global $frm_vars;
302 302
         $frm_settings = FrmAppHelper::get_settings();
303 303
 
304 304
         foreach ( $shortcodes[0] as $short_key => $tag ) {
305
-            $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
305
+            $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] );
306 306
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
307 307
 
308 308
             $replace_with = '';
309 309
 
310 310
             if ( $tag == 'input' ) {
311
-                if ( isset($atts['opt']) ) {
312
-                    $atts['opt']--;
311
+                if ( isset( $atts['opt'] ) ) {
312
+                    $atts['opt'] --;
313 313
                 }
314 314
 
315
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
316
-                if ( isset($atts['class']) ) {
317
-                    unset($atts['class']);
315
+                $field['input_class'] = isset( $atts['class'] ) ? $atts['class'] : '';
316
+                if ( isset( $atts['class'] ) ) {
317
+                    unset( $atts['class'] );
318 318
                 }
319 319
 
320 320
                 $field['shortcodes'] = $atts;
@@ -323,24 +323,24 @@  discard block
 block discarded – undo
323 323
                 $replace_with = ob_get_contents();
324 324
                 ob_end_clean();
325 325
             } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
326
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
326
+                $replace_with = FrmProEntriesController::entry_delete_link( $atts );
327 327
             }
328 328
 
329
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
329
+            $html = str_replace( $shortcodes[0][$short_key], $replace_with, $html );
330 330
         }
331 331
 
332 332
         $html .= "\n";
333 333
 
334 334
         //Return html if conf_field to prevent loop
335
-        if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
335
+        if ( isset( $field['conf_field'] ) && $field['conf_field'] == 'stop' ) {
336 336
             return $html;
337 337
         }
338 338
 
339 339
         //If field is in repeating section
340 340
         if ( $args['section_id'] ) {
341
-            $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'] ));
341
+            $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 342
         } else {
343
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
343
+            $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ) );
344 344
         }
345 345
 
346 346
 		self::remove_collapse_shortcode( $html );
@@ -392,14 +392,14 @@  discard block
 block discarded – undo
392 392
 	 */
393 393
 	private static function get_field_div_classes( $field_id, $field, $errors, $html ) {
394 394
 		// Add error class
395
-		$classes = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : '';
395
+		$classes = isset( $errors['field' . $field_id] ) ? ' frm_blank_field' : '';
396 396
 
397 397
 		// Add label position class
398 398
 		$classes .= ' frm_' . $field['label'] . '_container';
399 399
 
400 400
 		// Add CSS layout classes
401 401
 		if ( ! empty( $field['classes'] ) ) {
402
-			if ( ! strpos( $html, 'frm_form_field ') ) {
402
+			if ( ! strpos( $html, 'frm_form_field ' ) ) {
403 403
 				$classes .= ' frm_form_field';
404 404
 			}
405 405
 			$classes .= ' ' . $field['classes'];
@@ -438,15 +438,15 @@  discard block
 block discarded – undo
438 438
         }
439 439
 
440 440
         $with_tags = $args['conditional_check'] ? 3 : 2;
441
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
442
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
443
-            $tag = str_replace(']', '', $tag);
444
-            $tags = explode(' ', $tag);
445
-            if ( is_array($tags) ) {
441
+        if ( ! empty( $shortcodes[$with_tags][$short_key] ) ) {
442
+            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][$short_key] );
443
+            $tag = str_replace( ']', '', $tag );
444
+            $tags = explode( ' ', $tag );
445
+            if ( is_array( $tags ) ) {
446 446
                 $tag = $tags[0];
447 447
             }
448 448
         } else {
449
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
449
+            $tag = $shortcodes[$with_tags - 1][$short_key];
450 450
         }
451 451
 
452 452
         return $tag;
@@ -501,10 +501,10 @@  discard block
 block discarded – undo
501 501
 
502 502
 	public static function show_single_option( $field ) {
503 503
         $field_name = $field['name'];
504
-        $html_id = self::get_html_id($field);
504
+        $html_id = self::get_html_id( $field );
505 505
         foreach ( $field['options'] as $opt_key => $opt ) {
506
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
507
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
506
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
507
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
508 508
 
509 509
             // If this is an "Other" option, get the HTML for it
510 510
 			if ( self::is_other_opt( $opt_key ) ) {
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
     }
519 519
 
520 520
 	public static function get_term_link( $tax_id ) {
521
-        $tax = get_taxonomy($tax_id);
521
+        $tax = get_taxonomy( $tax_id );
522 522
         if ( ! $tax ) {
523 523
             return;
524 524
         }
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
             __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
528 528
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
529 529
         );
530
-        unset($tax);
530
+        unset( $tax );
531 531
 
532 532
         return $link;
533 533
     }
@@ -541,8 +541,8 @@  discard block
 block discarded – undo
541 541
 		$observed_value = wp_kses_post( $observed_value );
542 542
 		$hide_opt = wp_kses_post( $hide_opt );
543 543
 
544
-        if ( is_array($observed_value) ) {
545
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
544
+        if ( is_array( $observed_value ) ) {
545
+            return self::array_value_condition( $observed_value, $cond, $hide_opt );
546 546
         }
547 547
 
548 548
         $m = false;
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
         } else if ( $cond == '<' ) {
556 556
             $m = $observed_value < $hide_opt;
557 557
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
558
-            $m = stripos($observed_value, $hide_opt);
558
+            $m = stripos( $observed_value, $hide_opt );
559 559
             if ( $cond == 'not LIKE' ) {
560 560
                 $m = ( $m === false ) ? true : false;
561 561
             } else {
@@ -568,23 +568,23 @@  discard block
 block discarded – undo
568 568
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
569 569
         $m = false;
570 570
         if ( $cond == '==' ) {
571
-            if ( is_array($hide_opt) ) {
572
-                $m = array_intersect($hide_opt, $observed_value);
573
-                $m = empty($m) ? false : true;
571
+            if ( is_array( $hide_opt ) ) {
572
+                $m = array_intersect( $hide_opt, $observed_value );
573
+                $m = empty( $m ) ? false : true;
574 574
             } else {
575
-                $m = in_array($hide_opt, $observed_value);
575
+                $m = in_array( $hide_opt, $observed_value );
576 576
             }
577 577
         } else if ( $cond == '!=' ) {
578
-            $m = ! in_array($hide_opt, $observed_value);
578
+            $m = ! in_array( $hide_opt, $observed_value );
579 579
         } else if ( $cond == '>' ) {
580
-            $min = min($observed_value);
580
+            $min = min( $observed_value );
581 581
             $m = $min > $hide_opt;
582 582
         } else if ( $cond == '<' ) {
583
-            $max = max($observed_value);
583
+            $max = max( $observed_value );
584 584
             $m = $max < $hide_opt;
585 585
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
586 586
             foreach ( $observed_value as $ob ) {
587
-                $m = strpos($ob, $hide_opt);
587
+                $m = strpos( $ob, $hide_opt );
588 588
                 if ( $m !== false ) {
589 589
                     $m = true;
590 590
                     break;
@@ -605,27 +605,27 @@  discard block
 block discarded – undo
605 605
      * @return string
606 606
      */
607 607
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
608
-        if ( strpos($value, '[sitename]') !== false ) {
608
+        if ( strpos( $value, '[sitename]' ) !== false ) {
609 609
             $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
610
-            $value = str_replace('[sitename]', $new_value, $value);
610
+            $value = str_replace( '[sitename]', $new_value, $value );
611 611
         }
612 612
 
613
-        $value = apply_filters('frm_content', $value, $form, $entry);
614
-        $value = do_shortcode($value);
613
+        $value = apply_filters( 'frm_content', $value, $form, $entry );
614
+        $value = do_shortcode( $value );
615 615
 
616 616
         return $value;
617 617
     }
618 618
 
619 619
 	public static function get_shortcodes( $content, $form_id ) {
620 620
         if ( FrmAppHelper::pro_is_installed() ) {
621
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
621
+            return FrmProDisplaysHelper::get_shortcodes( $content, $form_id );
622 622
         }
623 623
 
624 624
         $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
625 625
 
626
-        $tagregexp = self::allowed_shortcodes($fields);
626
+        $tagregexp = self::allowed_shortcodes( $fields );
627 627
 
628
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
628
+        preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER );
629 629
 
630 630
         return $matches;
631 631
     }
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
             $tagregexp[] = $field->field_key;
644 644
         }
645 645
 
646
-        $tagregexp = implode('|', $tagregexp);
646
+        $tagregexp = implode( '|', $tagregexp );
647 647
         return $tagregexp;
648 648
     }
649 649
 
@@ -659,28 +659,28 @@  discard block
 block discarded – undo
659 659
 				continue;
660 660
 			}
661 661
 
662
-            $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] );
662
+            $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][$short_key] );
663 663
 
664
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
665
-				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
666
-                $tags = explode(' ', $tag);
667
-                if ( is_array($tags) ) {
664
+            if ( ! empty( $shortcodes[3][$short_key] ) ) {
665
+				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][$short_key] );
666
+                $tags = explode( ' ', $tag );
667
+                if ( is_array( $tags ) ) {
668 668
                     $tag = $tags[0];
669 669
                 }
670 670
             } else {
671
-                $tag = $shortcodes[2][ $short_key ];
671
+                $tag = $shortcodes[2][$short_key];
672 672
             }
673 673
 
674 674
             switch ( $tag ) {
675 675
                 case 'id':
676 676
                 case 'key':
677 677
                 case 'ip':
678
-                    $replace_with = $shortcode_values[ $tag ];
678
+                    $replace_with = $shortcode_values[$tag];
679 679
                 break;
680 680
 
681 681
                 case 'user_agent':
682 682
                 case 'user-agent':
683
-                    $entry->description = maybe_unserialize($entry->description);
683
+                    $entry->description = maybe_unserialize( $entry->description );
684 684
 					$replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] );
685 685
                 break;
686 686
 
@@ -688,25 +688,25 @@  discard block
 block discarded – undo
688 688
                 case 'created-at':
689 689
                 case 'updated_at':
690 690
                 case 'updated-at':
691
-                    if ( isset($atts['format']) ) {
691
+                    if ( isset( $atts['format'] ) ) {
692 692
                         $time_format = ' ';
693 693
                     } else {
694
-                        $atts['format'] = get_option('date_format');
694
+                        $atts['format'] = get_option( 'date_format' );
695 695
                         $time_format = '';
696 696
                     }
697 697
 
698
-                    $this_tag = str_replace('-', '_', $tag);
699
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
700
-                    unset($this_tag);
698
+                    $this_tag = str_replace( '-', '_', $tag );
699
+                    $replace_with = FrmAppHelper::get_formatted_time( $entry->{$this_tag}, $atts['format'], $time_format );
700
+                    unset( $this_tag );
701 701
                 break;
702 702
 
703 703
                 case 'created_by':
704 704
                 case 'created-by':
705 705
                 case 'updated_by':
706 706
                 case 'updated-by':
707
-                    $this_tag = str_replace('-', '_', $tag);
707
+                    $this_tag = str_replace( '-', '_', $tag );
708 708
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
709
-                    unset($this_tag);
709
+                    unset( $this_tag );
710 710
                 break;
711 711
 
712 712
                 case 'admin_email':
@@ -723,16 +723,16 @@  discard block
 block discarded – undo
723 723
                         break;
724 724
                     }
725 725
 
726
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
726
+                    $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
727 727
 
728 728
                     $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
729 729
 
730 730
                     $atts['entry_id'] = $entry->id;
731 731
                     $atts['entry_key'] = $entry->item_key;
732 732
 
733
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
733
+                    if ( isset( $atts['show'] ) && $atts['show'] == 'field_label' ) {
734 734
                         $replace_with = $field->name;
735
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
735
+                    } else if ( isset( $atts['show'] ) && $atts['show'] == 'description' ) {
736 736
                         $replace_with = $field->description;
737 737
 					} else {
738 738
 						$string_value = $replace_with;
@@ -747,15 +747,15 @@  discard block
 block discarded – undo
747 747
 						}
748 748
 					}
749 749
 
750
-                    unset($field);
750
+                    unset( $field );
751 751
                 break;
752 752
             }
753 753
 
754
-            if ( isset($replace_with) ) {
755
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
754
+            if ( isset( $replace_with ) ) {
755
+                $content = str_replace( $shortcodes[0][$short_key], $replace_with, $content );
756 756
             }
757 757
 
758
-            unset($atts, $conditional, $replace_with);
758
+            unset( $atts, $conditional, $replace_with );
759 759
 		}
760 760
 
761 761
 		return $content;
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
         $new_value = '';
772 772
         switch ( $tag ) {
773 773
             case 'admin_email':
774
-                $new_value = get_option('admin_email');
774
+                $new_value = get_option( 'admin_email' );
775 775
                 break;
776 776
             case 'siteurl':
777 777
                 $new_value = FrmAppHelper::site_url();
@@ -797,28 +797,28 @@  discard block
 block discarded – undo
797 797
      * @return string|array
798 798
      */
799 799
     public static function process_get_shortcode( $atts, $return_array = false ) {
800
-        if ( ! isset($atts['param']) ) {
800
+        if ( ! isset( $atts['param'] ) ) {
801 801
             return '';
802 802
         }
803 803
 
804
-        if ( strpos($atts['param'], '&#91;') ) {
805
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
806
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
804
+        if ( strpos( $atts['param'], '&#91;' ) ) {
805
+            $atts['param'] = str_replace( '&#91;', '[', $atts['param'] );
806
+            $atts['param'] = str_replace( '&#93;', ']', $atts['param'] );
807 807
         }
808 808
 
809
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
809
+        $new_value = FrmAppHelper::get_param( $atts['param'], '' );
810 810
         $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
811 811
 
812 812
         if ( $new_value == '' ) {
813
-            if ( ! isset($atts['prev_val']) ) {
813
+            if ( ! isset( $atts['prev_val'] ) ) {
814 814
                 $atts['prev_val'] = '';
815 815
             }
816 816
 
817
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
817
+            $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val'];
818 818
         }
819 819
 
820
-        if ( is_array($new_value) && ! $return_array ) {
821
-            $new_value = implode(', ', $new_value);
820
+        if ( is_array( $new_value ) && ! $return_array ) {
821
+            $new_value = implode( ', ', $new_value );
822 822
         }
823 823
 
824 824
         return $new_value;
@@ -831,12 +831,12 @@  discard block
 block discarded – undo
831 831
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
832 832
 
833 833
         if ( $field->type == 'textarea' || $field->type == 'rte' ) {
834
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
835
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
836
-                if ( is_array($replace_with) ) {
837
-                    $replace_with = implode("\n", $replace_with);
834
+            $autop = isset( $atts['wpautop'] ) ? $atts['wpautop'] : true;
835
+            if ( apply_filters( 'frm_use_wpautop', $autop ) ) {
836
+                if ( is_array( $replace_with ) ) {
837
+                    $replace_with = implode( "\n", $replace_with );
838 838
                 }
839
-                $replace_with = wpautop($replace_with);
839
+                $replace_with = wpautop( $replace_with );
840 840
             }
841 841
 			unset( $autop );
842 842
 		} else if ( is_array( $replace_with ) ) {
@@ -858,14 +858,14 @@  discard block
 block discarded – undo
858 858
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
859 859
 
860 860
         $field_types = array();
861
-        if ( in_array($type, $single_input) ) {
861
+        if ( in_array( $type, $single_input ) ) {
862 862
             self::field_types_for_input( $single_input, $field_selection, $field_types );
863
-        } else if ( in_array($type, $multiple_input) ) {
863
+        } else if ( in_array( $type, $multiple_input ) ) {
864 864
             self::field_types_for_input( $multiple_input, $field_selection, $field_types );
865
-        } else if ( in_array($type, $other_type) ) {
865
+        } else if ( in_array( $type, $other_type ) ) {
866 866
             self::field_types_for_input( $other_type, $field_selection, $field_types );
867
-		} else if ( isset( $field_selection[ $type ] ) ) {
868
-            $field_types[ $type ] = $field_selection[ $type ];
867
+		} else if ( isset( $field_selection[$type] ) ) {
868
+            $field_types[$type] = $field_selection[$type];
869 869
         }
870 870
 
871 871
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
@@ -874,8 +874,8 @@  discard block
 block discarded – undo
874 874
 
875 875
     private static function field_types_for_input( $inputs, $fields, &$field_types ) {
876 876
         foreach ( $inputs as $input ) {
877
-            $field_types[ $input ] = $fields[ $input ];
878
-            unset($input);
877
+            $field_types[$input] = $fields[$input];
878
+            unset( $input );
879 879
         }
880 880
     }
881 881
 
@@ -920,21 +920,21 @@  discard block
 block discarded – undo
920 920
 		// Check posted vals before checking saved values
921 921
 
922 922
 		// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
923
-		if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) {
923
+		if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) {
924 924
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
925
-				$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 ] ) : '';
925
+				$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] ) : '';
926 926
 			} else {
927
-				$other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] );
927
+				$other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] );
928 928
 			}
929 929
 			return $other_val;
930 930
 
931
-		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) {
931
+		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) {
932 932
 			// For normal fields
933 933
 
934 934
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
935
-				$other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : '';
935
+				$other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : '';
936 936
 			} else {
937
-				$other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] );
937
+				$other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] );
938 938
 			}
939 939
 			return $other_val;
940 940
 		}
@@ -943,8 +943,8 @@  discard block
 block discarded – undo
943 943
 		if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) {
944 944
 			// Check if there is an "other" val in saved value and make sure the
945 945
 			// "other" val is not equal to the Other checkbox option
946
-			if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
947
-				$other_val = $field['value'][ $opt_key ];
946
+			if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) {
947
+				$other_val = $field['value'][$opt_key];
948 948
 			}
949 949
 		} else {
950 950
 			/**
@@ -956,8 +956,8 @@  discard block
 block discarded – undo
956 956
 				// Multi-select dropdowns - key is not preserved
957 957
 				if ( is_array( $field['value'] ) ) {
958 958
 					$o_key = array_search( $temp_val, $field['value'] );
959
-					if ( isset( $field['value'][ $o_key ] ) ) {
960
-						unset( $field['value'][ $o_key ], $o_key );
959
+					if ( isset( $field['value'][$o_key] ) ) {
960
+						unset( $field['value'][$o_key], $o_key );
961 961
 					}
962 962
 				} else if ( $temp_val == $field['value'] ) {
963 963
 					// For radio and regular dropdowns
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
 	private static function set_other_name( $args, &$other_args ) {
1015 1015
 		//Set up name for other field
1016 1016
 		$other_args['name'] = str_replace( '[]', '', $args['field_name'] );
1017
-		$other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']);
1017
+		$other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] );
1018 1018
 		$other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']';
1019 1019
 
1020 1020
 		//Converts item_meta[field_id] => item_meta[other][field_id] and
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
 		// Count should only be greater than 3 if inside of a repeating section
1042 1042
 		if ( count( $temp_array ) > 3 ) {
1043 1043
 			$parent = str_replace( ']', '', $temp_array[1] );
1044
-			$pointer = str_replace( ']', '', $temp_array[2]);
1044
+			$pointer = str_replace( ']', '', $temp_array[2] );
1045 1045
 		}
1046 1046
 
1047 1047
 		// Get text for "other" text field
@@ -1160,15 +1160,15 @@  discard block
 block discarded – undo
1160 1160
 			$replace_with[] = '[' . $new . ']';
1161 1161
 			$replace[] = '[' . $old . ' ';
1162 1162
 			$replace_with[] = '[' . $new . ' ';
1163
-            unset($old, $new);
1163
+            unset( $old, $new );
1164 1164
         }
1165 1165
 		if ( is_array( $val ) ) {
1166 1166
 			foreach ( $val as $k => $v ) {
1167
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1168
-                unset($k, $v);
1167
+                $val[$k] = str_replace( $replace, $replace_with, $v );
1168
+                unset( $k, $v );
1169 1169
             }
1170 1170
         } else {
1171
-            $val = str_replace($replace, $replace_with, $val);
1171
+            $val = str_replace( $replace, $replace_with, $val );
1172 1172
         }
1173 1173
 
1174 1174
         return $val;
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
             'DC' => 'District of Columbia',
1182 1182
             'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1183 1183
             'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1184
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1184
+            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland',
1185 1185
             'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1186 1186
             'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1187 1187
             'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
@@ -1272,35 +1272,35 @@  discard block
 block discarded – undo
1272 1272
     }
1273 1273
 
1274 1274
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1275
-		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1275
+		$prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries();
1276 1276
 
1277 1277
         $states = FrmFieldsHelper::get_us_states();
1278
-        $state_abv = array_keys($states);
1279
-        sort($state_abv);
1280
-		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1278
+        $state_abv = array_keys( $states );
1279
+        sort( $state_abv );
1280
+		$prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv;
1281 1281
 
1282
-        $states = array_values($states);
1283
-        sort($states);
1284
-		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1285
-        unset($state_abv, $states);
1282
+        $states = array_values( $states );
1283
+        sort( $states );
1284
+		$prepop[__( 'U.S. States', 'formidable' )] = $states;
1285
+        unset( $state_abv, $states );
1286 1286
 
1287
-		$prepop[ __( 'Age', 'formidable' ) ] = array(
1287
+		$prepop[__( 'Age', 'formidable' )] = array(
1288 1288
             __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1289 1289
             __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1290 1290
             __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1291 1291
         );
1292 1292
 
1293
-		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1293
+		$prepop[__( 'Satisfaction', 'formidable' )] = array(
1294 1294
             __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1295 1295
             __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1296 1296
         );
1297 1297
 
1298
-		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1298
+		$prepop[__( 'Importance', 'formidable' )] = array(
1299 1299
             __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1300 1300
             __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1301 1301
         );
1302 1302
 
1303
-		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1303
+		$prepop[__( 'Agreement', 'formidable' )] = array(
1304 1304
             __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1305 1305
             __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1306 1306
         );
Please login to merge, or discard this patch.