Completed
Push — master ( 32bd8b...e17273 )
by Jamie
03:15
created
classes/helpers/FrmFieldsHelper.php 1 patch
Indentation   +714 added lines, -714 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' => 'default', '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();
@@ -183,21 +183,21 @@  discard block
 block discarded – undo
183 183
 		return $msg;
184 184
 	}
185 185
 
186
-    public static function get_form_fields( $form_id, $error = false ) {
187
-        $fields = FrmField::get_all_for_form($form_id);
188
-        $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error);
189
-        return $fields;
190
-    }
186
+	public static function get_form_fields( $form_id, $error = false ) {
187
+		$fields = FrmField::get_all_for_form($form_id);
188
+		$fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error);
189
+		return $fields;
190
+	}
191 191
 
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,138 +207,138 @@  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
-        //replace [input]
288
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
289
-        global $frm_vars;
290
-        $frm_settings = FrmAppHelper::get_settings();
287
+		//replace [input]
288
+		preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
289
+		global $frm_vars;
290
+		$frm_settings = FrmAppHelper::get_settings();
291 291
 
292
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
293
-            $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
292
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
293
+			$atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
294 294
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
295 295
 
296
-            $replace_with = '';
296
+			$replace_with = '';
297 297
 
298
-            if ( $tag == 'input' ) {
299
-                if ( isset($atts['opt']) ) {
300
-                    $atts['opt']--;
301
-                }
298
+			if ( $tag == 'input' ) {
299
+				if ( isset($atts['opt']) ) {
300
+					$atts['opt']--;
301
+				}
302 302
 
303
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
304
-                if ( isset($atts['class']) ) {
305
-                    unset($atts['class']);
306
-                }
303
+				$field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
304
+				if ( isset($atts['class']) ) {
305
+					unset($atts['class']);
306
+				}
307 307
 
308
-                $field['shortcodes'] = $atts;
309
-                ob_start();
308
+				$field['shortcodes'] = $atts;
309
+				ob_start();
310 310
 				include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' );
311
-                $replace_with = ob_get_contents();
312
-                ob_end_clean();
313
-            } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
314
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
315
-            }
311
+				$replace_with = ob_get_contents();
312
+				ob_end_clean();
313
+			} else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
314
+				$replace_with = FrmProEntriesController::entry_delete_link($atts);
315
+			}
316 316
 
317
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
318
-        }
317
+			$html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
318
+		}
319 319
 
320 320
 		if ( $form ) {
321
-            $form = (array) $form;
321
+			$form = (array) $form;
322 322
 
323
-            //replace [form_key]
324
-            $html = str_replace('[form_key]', $form['form_key'], $html);
323
+			//replace [form_key]
324
+			$html = str_replace('[form_key]', $form['form_key'], $html);
325 325
 
326
-            //replace [form_name]
327
-            $html = str_replace('[form_name]', $form['name'], $html);
328
-        }
329
-        $html .= "\n";
326
+			//replace [form_name]
327
+			$html = str_replace('[form_name]', $form['name'], $html);
328
+		}
329
+		$html .= "\n";
330 330
 
331
-        //Return html if conf_field to prevent loop
332
-        if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
333
-            return $html;
334
-        }
331
+		//Return html if conf_field to prevent loop
332
+		if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
333
+			return $html;
334
+		}
335 335
 
336
-        //If field is in repeating section
337
-        if ( $args['section_id'] ) {
338
-            $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'] ));
339
-        } else {
340
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
341
-        }
336
+		//If field is in repeating section
337
+		if ( $args['section_id'] ) {
338
+			$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'] ));
339
+		} else {
340
+			$html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
341
+		}
342 342
 
343 343
 		self::remove_collapse_shortcode( $html );
344 344
 
@@ -346,8 +346,8 @@  discard block
 block discarded – undo
346 346
 			$html = do_shortcode( $html );
347 347
 		}
348 348
 
349
-        return $html;
350
-    }
349
+		return $html;
350
+	}
351 351
 
352 352
 	/**
353 353
 	 * Add classes to a field div
@@ -401,46 +401,46 @@  discard block
 block discarded – undo
401 401
 		return $classes;
402 402
 	}
403 403
 
404
-    public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
405
-        if ( $no_vars ) {
404
+	public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
405
+		if ( $no_vars ) {
406 406
 			$html = str_replace( '[if ' . $code . ']', '', $html );
407 407
 			$html = str_replace( '[/if ' . $code . ']', '', $html );
408
-        } else {
408
+		} else {
409 409
 			$html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html );
410
-        }
410
+		}
411 411
 
412 412
 		$html = str_replace( '[' . $code . ']', $replace_with, $html );
413
-    }
413
+	}
414 414
 
415 415
 	public static function get_shortcode_tag( $shortcodes, $short_key, $args ) {
416 416
 		$args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) );
417
-        if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
418
-            $args['conditional_check'] = true;
419
-        }
420
-
421
-        $prefix = '';
422
-        if ( $args['conditional_check'] ) {
423
-            if ( $args['conditional'] ) {
424
-                $prefix = 'if ';
425
-            } else if ( $args['foreach'] ) {
426
-                $prefix = 'foreach ';
427
-            }
428
-        }
429
-
430
-        $with_tags = $args['conditional_check'] ? 3 : 2;
431
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
432
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
433
-            $tag = str_replace(']', '', $tag);
434
-            $tags = explode(' ', $tag);
435
-            if ( is_array($tags) ) {
436
-                $tag = $tags[0];
437
-            }
438
-        } else {
439
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
440
-        }
441
-
442
-        return $tag;
443
-    }
417
+		if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
418
+			$args['conditional_check'] = true;
419
+		}
420
+
421
+		$prefix = '';
422
+		if ( $args['conditional_check'] ) {
423
+			if ( $args['conditional'] ) {
424
+				$prefix = 'if ';
425
+			} else if ( $args['foreach'] ) {
426
+				$prefix = 'foreach ';
427
+			}
428
+		}
429
+
430
+		$with_tags = $args['conditional_check'] ? 3 : 2;
431
+		if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
432
+			$tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
433
+			$tag = str_replace(']', '', $tag);
434
+			$tags = explode(' ', $tag);
435
+			if ( is_array($tags) ) {
436
+				$tag = $tags[0];
437
+			}
438
+		} else {
439
+			$tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
440
+		}
441
+
442
+		return $tag;
443
+	}
444 444
 
445 445
 	/**
446 446
 	 * Remove [collapse_this] if it's still included after all processing
@@ -465,51 +465,51 @@  discard block
 block discarded – undo
465 465
 			$class_prefix = 'frm-';
466 466
 		}
467 467
 
468
-        if ( $lang != 'en' ) {
468
+		if ( $lang != 'en' ) {
469 469
 			$api_js_url .= '&hl=' . $lang;
470
-        }
470
+		}
471 471
 		$api_js_url = apply_filters( 'frm_recaptcha_js_url', $api_js_url );
472 472
 
473
-        wp_register_script( 'recaptcha-api', $api_js_url, '', true );
474
-        wp_enqueue_script( 'recaptcha-api' );
473
+		wp_register_script( 'recaptcha-api', $api_js_url, '', true );
474
+		wp_enqueue_script( 'recaptcha-api' );
475 475
 
476 476
 ?>
477 477
 <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>
478 478
 <?php
479
-    }
479
+	}
480 480
 
481 481
 	public static function show_single_option( $field ) {
482
-        $field_name = $field['name'];
483
-        $html_id = self::get_html_id($field);
484
-        foreach ( $field['options'] as $opt_key => $opt ) {
485
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
486
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
482
+		$field_name = $field['name'];
483
+		$html_id = self::get_html_id($field);
484
+		foreach ( $field['options'] as $opt_key => $opt ) {
485
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
486
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
487 487
 
488
-            // If this is an "Other" option, get the HTML for it
488
+			// If this is an "Other" option, get the HTML for it
489 489
 			if ( self::is_other_opt( $opt_key ) ) {
490
-                // Get string for Other text field, if needed
490
+				// Get string for Other text field, if needed
491 491
 				$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
492 492
 				require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
493
-            } else {
493
+			} else {
494 494
 				require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
495
-            }
496
-        }
497
-    }
495
+			}
496
+		}
497
+	}
498 498
 
499 499
 	public static function get_term_link( $tax_id ) {
500
-        $tax = get_taxonomy($tax_id);
501
-        if ( ! $tax ) {
502
-            return;
503
-        }
500
+		$tax = get_taxonomy($tax_id);
501
+		if ( ! $tax ) {
502
+			return;
503
+		}
504 504
 
505
-        $link = sprintf(
506
-            __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
505
+		$link = sprintf(
506
+			__( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
507 507
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
508
-        );
509
-        unset($tax);
508
+		);
509
+		unset($tax);
510 510
 
511
-        return $link;
512
-    }
511
+		return $link;
512
+	}
513 513
 
514 514
 	public static function value_meets_condition( $observed_value, $cond, $hide_opt ) {
515 515
 		// Remove white space from hide_opt
@@ -520,195 +520,195 @@  discard block
 block discarded – undo
520 520
 		$observed_value = wp_kses_post( $observed_value );
521 521
 		$hide_opt = wp_kses_post( $hide_opt );
522 522
 
523
-        if ( is_array($observed_value) ) {
524
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
525
-        }
526
-
527
-        $m = false;
528
-        if ( $cond == '==' ) {
529
-            $m = $observed_value == $hide_opt;
530
-        } else if ( $cond == '!=' ) {
531
-            $m = $observed_value != $hide_opt;
532
-        } else if ( $cond == '>' ) {
533
-            $m = $observed_value > $hide_opt;
534
-        } else if ( $cond == '<' ) {
535
-            $m = $observed_value < $hide_opt;
536
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
537
-            $m = stripos($observed_value, $hide_opt);
538
-            if ( $cond == 'not LIKE' ) {
539
-                $m = ( $m === false ) ? true : false;
540
-            } else {
541
-                $m = ( $m === false ) ? false : true;
542
-            }
543
-        }
544
-        return $m;
545
-    }
523
+		if ( is_array($observed_value) ) {
524
+			return self::array_value_condition($observed_value, $cond, $hide_opt);
525
+		}
526
+
527
+		$m = false;
528
+		if ( $cond == '==' ) {
529
+			$m = $observed_value == $hide_opt;
530
+		} else if ( $cond == '!=' ) {
531
+			$m = $observed_value != $hide_opt;
532
+		} else if ( $cond == '>' ) {
533
+			$m = $observed_value > $hide_opt;
534
+		} else if ( $cond == '<' ) {
535
+			$m = $observed_value < $hide_opt;
536
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
537
+			$m = stripos($observed_value, $hide_opt);
538
+			if ( $cond == 'not LIKE' ) {
539
+				$m = ( $m === false ) ? true : false;
540
+			} else {
541
+				$m = ( $m === false ) ? false : true;
542
+			}
543
+		}
544
+		return $m;
545
+	}
546 546
 
547 547
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
548
-        $m = false;
549
-        if ( $cond == '==' ) {
550
-            if ( is_array($hide_opt) ) {
551
-                $m = array_intersect($hide_opt, $observed_value);
552
-                $m = empty($m) ? false : true;
553
-            } else {
554
-                $m = in_array($hide_opt, $observed_value);
555
-            }
556
-        } else if ( $cond == '!=' ) {
557
-            $m = ! in_array($hide_opt, $observed_value);
558
-        } else if ( $cond == '>' ) {
559
-            $min = min($observed_value);
560
-            $m = $min > $hide_opt;
561
-        } else if ( $cond == '<' ) {
562
-            $max = max($observed_value);
563
-            $m = $max < $hide_opt;
564
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
565
-            foreach ( $observed_value as $ob ) {
566
-                $m = strpos($ob, $hide_opt);
567
-                if ( $m !== false ) {
568
-                    $m = true;
569
-                    break;
570
-                }
571
-            }
572
-
573
-            if ( $cond == 'not LIKE' ) {
574
-                $m = ( $m === false ) ? true : false;
575
-            }
576
-        }
577
-
578
-        return $m;
579
-    }
580
-
581
-    /**
582
-     * Replace a few basic shortcodes and field ids
583
-     * @since 2.0
584
-     * @return string
585
-     */
548
+		$m = false;
549
+		if ( $cond == '==' ) {
550
+			if ( is_array($hide_opt) ) {
551
+				$m = array_intersect($hide_opt, $observed_value);
552
+				$m = empty($m) ? false : true;
553
+			} else {
554
+				$m = in_array($hide_opt, $observed_value);
555
+			}
556
+		} else if ( $cond == '!=' ) {
557
+			$m = ! in_array($hide_opt, $observed_value);
558
+		} else if ( $cond == '>' ) {
559
+			$min = min($observed_value);
560
+			$m = $min > $hide_opt;
561
+		} else if ( $cond == '<' ) {
562
+			$max = max($observed_value);
563
+			$m = $max < $hide_opt;
564
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
565
+			foreach ( $observed_value as $ob ) {
566
+				$m = strpos($ob, $hide_opt);
567
+				if ( $m !== false ) {
568
+					$m = true;
569
+					break;
570
+				}
571
+			}
572
+
573
+			if ( $cond == 'not LIKE' ) {
574
+				$m = ( $m === false ) ? true : false;
575
+			}
576
+		}
577
+
578
+		return $m;
579
+	}
580
+
581
+	/**
582
+	 * Replace a few basic shortcodes and field ids
583
+	 * @since 2.0
584
+	 * @return string
585
+	 */
586 586
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
587
-        if ( strpos($value, '[sitename]') !== false ) {
588
-            $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
589
-            $value = str_replace('[sitename]', $new_value, $value);
590
-        }
587
+		if ( strpos($value, '[sitename]') !== false ) {
588
+			$new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
589
+			$value = str_replace('[sitename]', $new_value, $value);
590
+		}
591 591
 
592
-        $value = apply_filters('frm_content', $value, $form, $entry);
593
-        $value = do_shortcode($value);
592
+		$value = apply_filters('frm_content', $value, $form, $entry);
593
+		$value = do_shortcode($value);
594 594
 
595
-        return $value;
596
-    }
595
+		return $value;
596
+	}
597 597
 
598 598
 	public static function get_shortcodes( $content, $form_id ) {
599
-        if ( FrmAppHelper::pro_is_installed() ) {
600
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
601
-        }
599
+		if ( FrmAppHelper::pro_is_installed() ) {
600
+			return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
601
+		}
602 602
 
603
-        $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
603
+		$fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
604 604
 
605
-        $tagregexp = self::allowed_shortcodes($fields);
605
+		$tagregexp = self::allowed_shortcodes($fields);
606 606
 
607
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
607
+		preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
608 608
 
609
-        return $matches;
610
-    }
609
+		return $matches;
610
+	}
611 611
 
612 612
 	public static function allowed_shortcodes( $fields = array() ) {
613
-        $tagregexp = array(
614
-            'editlink', 'id', 'key', 'ip',
615
-            'siteurl', 'sitename', 'admin_email',
616
-            'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
613
+		$tagregexp = array(
614
+			'editlink', 'id', 'key', 'ip',
615
+			'siteurl', 'sitename', 'admin_email',
616
+			'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
617 617
 			'parent[-|_]id',
618
-        );
618
+		);
619 619
 
620
-        foreach ( $fields as $field ) {
621
-            $tagregexp[] = $field->id;
622
-            $tagregexp[] = $field->field_key;
623
-        }
620
+		foreach ( $fields as $field ) {
621
+			$tagregexp[] = $field->id;
622
+			$tagregexp[] = $field->field_key;
623
+		}
624 624
 
625
-        $tagregexp = implode('|', $tagregexp);
626
-        return $tagregexp;
627
-    }
625
+		$tagregexp = implode('|', $tagregexp);
626
+		return $tagregexp;
627
+	}
628 628
 
629 629
 	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
630
-        $shortcode_values = array(
631
-           'id'     => $entry->id,
632
-           'key'    => $entry->item_key,
633
-           'ip'     => $entry->ip,
634
-        );
630
+		$shortcode_values = array(
631
+		   'id'     => $entry->id,
632
+		   'key'    => $entry->item_key,
633
+		   'ip'     => $entry->ip,
634
+		);
635 635
 
636
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
637
-            $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
636
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
637
+			$atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
638 638
 
639
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
639
+			if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
640 640
 				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
641
-                $tags = explode(' ', $tag);
642
-                if ( is_array($tags) ) {
643
-                    $tag = $tags[0];
644
-                }
645
-            } else {
646
-                $tag = $shortcodes[2][ $short_key ];
647
-            }
648
-
649
-            switch ( $tag ) {
650
-                case 'id':
651
-                case 'key':
652
-                case 'ip':
653
-                    $replace_with = $shortcode_values[ $tag ];
654
-                break;
655
-
656
-                case 'user_agent':
657
-                case 'user-agent':
658
-                    $entry->description = maybe_unserialize($entry->description);
641
+				$tags = explode(' ', $tag);
642
+				if ( is_array($tags) ) {
643
+					$tag = $tags[0];
644
+				}
645
+			} else {
646
+				$tag = $shortcodes[2][ $short_key ];
647
+			}
648
+
649
+			switch ( $tag ) {
650
+				case 'id':
651
+				case 'key':
652
+				case 'ip':
653
+					$replace_with = $shortcode_values[ $tag ];
654
+				break;
655
+
656
+				case 'user_agent':
657
+				case 'user-agent':
658
+					$entry->description = maybe_unserialize($entry->description);
659 659
 					$replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] );
660
-                break;
661
-
662
-                case 'created_at':
663
-                case 'created-at':
664
-                case 'updated_at':
665
-                case 'updated-at':
666
-                    if ( isset($atts['format']) ) {
667
-                        $time_format = ' ';
668
-                    } else {
669
-                        $atts['format'] = get_option('date_format');
670
-                        $time_format = '';
671
-                    }
672
-
673
-                    $this_tag = str_replace('-', '_', $tag);
674
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
675
-                    unset($this_tag);
676
-                break;
677
-
678
-                case 'created_by':
679
-                case 'created-by':
680
-                case 'updated_by':
681
-                case 'updated-by':
682
-                    $this_tag = str_replace('-', '_', $tag);
660
+				break;
661
+
662
+				case 'created_at':
663
+				case 'created-at':
664
+				case 'updated_at':
665
+				case 'updated-at':
666
+					if ( isset($atts['format']) ) {
667
+						$time_format = ' ';
668
+					} else {
669
+						$atts['format'] = get_option('date_format');
670
+						$time_format = '';
671
+					}
672
+
673
+					$this_tag = str_replace('-', '_', $tag);
674
+					$replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
675
+					unset($this_tag);
676
+				break;
677
+
678
+				case 'created_by':
679
+				case 'created-by':
680
+				case 'updated_by':
681
+				case 'updated-by':
682
+					$this_tag = str_replace('-', '_', $tag);
683 683
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
684
-                    unset($this_tag);
685
-                break;
686
-
687
-                case 'admin_email':
688
-                case 'siteurl':
689
-                case 'frmurl':
690
-                case 'sitename':
691
-                case 'get':
692
-                    $replace_with = self::dynamic_default_values( $tag, $atts );
693
-                break;
694
-
695
-                default:
696
-                    $field = FrmField::getOne( $tag );
697
-                    if ( ! $field ) {
698
-                        break;
699
-                    }
700
-
701
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
702
-
703
-                    $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
704
-
705
-                    $atts['entry_id'] = $entry->id;
706
-                    $atts['entry_key'] = $entry->item_key;
707
-
708
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
709
-                        $replace_with = $field->name;
710
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
711
-                        $replace_with = $field->description;
684
+					unset($this_tag);
685
+				break;
686
+
687
+				case 'admin_email':
688
+				case 'siteurl':
689
+				case 'frmurl':
690
+				case 'sitename':
691
+				case 'get':
692
+					$replace_with = self::dynamic_default_values( $tag, $atts );
693
+				break;
694
+
695
+				default:
696
+					$field = FrmField::getOne( $tag );
697
+					if ( ! $field ) {
698
+						break;
699
+					}
700
+
701
+					$sep = isset($atts['sep']) ? $atts['sep'] : ', ';
702
+
703
+					$replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
704
+
705
+					$atts['entry_id'] = $entry->id;
706
+					$atts['entry_key'] = $entry->item_key;
707
+
708
+					if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
709
+						$replace_with = $field->name;
710
+					} else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
711
+						$replace_with = $field->description;
712 712
 					} else {
713 713
 						$string_value = $replace_with;
714 714
 						if ( is_array( $replace_with ) ) {
@@ -722,82 +722,82 @@  discard block
 block discarded – undo
722 722
 						}
723 723
 					}
724 724
 
725
-                    unset($field);
726
-                break;
727
-            }
725
+					unset($field);
726
+				break;
727
+			}
728 728
 
729
-            if ( isset($replace_with) ) {
730
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
731
-            }
729
+			if ( isset($replace_with) ) {
730
+				$content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
731
+			}
732 732
 
733
-            unset($atts, $conditional, $replace_with);
733
+			unset($atts, $conditional, $replace_with);
734 734
 		}
735 735
 
736 736
 		return $content;
737
-    }
738
-
739
-    /**
740
-     * Get the value to replace a few standard shortcodes
741
-     *
742
-     * @since 2.0
743
-     * @return string
744
-     */
745
-    public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
746
-        $new_value = '';
747
-        switch ( $tag ) {
748
-            case 'admin_email':
749
-                $new_value = get_option('admin_email');
750
-                break;
751
-            case 'siteurl':
752
-                $new_value = FrmAppHelper::site_url();
753
-                break;
754
-            case 'frmurl':
755
-                $new_value = FrmAppHelper::plugin_url();
756
-                break;
757
-            case 'sitename':
758
-                $new_value = FrmAppHelper::site_name();
759
-                break;
760
-            case 'get':
761
-                $new_value = self::process_get_shortcode( $atts, $return_array );
762
-                break;
763
-        }
764
-
765
-        return $new_value;
766
-    }
767
-
768
-    /**
769
-     * Process the [get] shortcode
770
-     *
771
-     * @since 2.0
772
-     * @return string|array
773
-     */
774
-    public static function process_get_shortcode( $atts, $return_array = false ) {
775
-        if ( ! isset($atts['param']) ) {
776
-            return '';
777
-        }
778
-
779
-        if ( strpos($atts['param'], '&#91;') ) {
780
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
781
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
782
-        }
783
-
784
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
785
-        $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
786
-
787
-        if ( $new_value == '' ) {
788
-            if ( ! isset($atts['prev_val']) ) {
789
-                $atts['prev_val'] = '';
790
-            }
791
-
792
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
793
-        }
794
-
795
-        if ( is_array($new_value) && ! $return_array ) {
796
-            $new_value = implode(', ', $new_value);
797
-        }
798
-
799
-        return $new_value;
800
-    }
737
+	}
738
+
739
+	/**
740
+	 * Get the value to replace a few standard shortcodes
741
+	 *
742
+	 * @since 2.0
743
+	 * @return string
744
+	 */
745
+	public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
746
+		$new_value = '';
747
+		switch ( $tag ) {
748
+			case 'admin_email':
749
+				$new_value = get_option('admin_email');
750
+				break;
751
+			case 'siteurl':
752
+				$new_value = FrmAppHelper::site_url();
753
+				break;
754
+			case 'frmurl':
755
+				$new_value = FrmAppHelper::plugin_url();
756
+				break;
757
+			case 'sitename':
758
+				$new_value = FrmAppHelper::site_name();
759
+				break;
760
+			case 'get':
761
+				$new_value = self::process_get_shortcode( $atts, $return_array );
762
+				break;
763
+		}
764
+
765
+		return $new_value;
766
+	}
767
+
768
+	/**
769
+	 * Process the [get] shortcode
770
+	 *
771
+	 * @since 2.0
772
+	 * @return string|array
773
+	 */
774
+	public static function process_get_shortcode( $atts, $return_array = false ) {
775
+		if ( ! isset($atts['param']) ) {
776
+			return '';
777
+		}
778
+
779
+		if ( strpos($atts['param'], '&#91;') ) {
780
+			$atts['param'] = str_replace('&#91;', '[', $atts['param']);
781
+			$atts['param'] = str_replace('&#93;', ']', $atts['param']);
782
+		}
783
+
784
+		$new_value = FrmAppHelper::get_param($atts['param'], '');
785
+		$new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
786
+
787
+		if ( $new_value == '' ) {
788
+			if ( ! isset($atts['prev_val']) ) {
789
+				$atts['prev_val'] = '';
790
+			}
791
+
792
+			$new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
793
+		}
794
+
795
+		if ( is_array($new_value) && ! $return_array ) {
796
+			$new_value = implode(', ', $new_value);
797
+		}
798
+
799
+		return $new_value;
800
+	}
801 801
 
802 802
 	public static function get_display_value( $replace_with, $field, $atts = array() ) {
803 803
 		$sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
@@ -805,14 +805,14 @@  discard block
 block discarded – undo
805 805
 		$replace_with = apply_filters( 'frm_get_' . $field->type . '_display_value', $replace_with, $field, $atts );
806 806
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
807 807
 
808
-        if ( $field->type == 'textarea' || $field->type == 'rte' ) {
809
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
810
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
811
-                if ( is_array($replace_with) ) {
812
-                    $replace_with = implode("\n", $replace_with);
813
-                }
814
-                $replace_with = wpautop($replace_with);
815
-            }
808
+		if ( $field->type == 'textarea' || $field->type == 'rte' ) {
809
+			$autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
810
+			if ( apply_filters('frm_use_wpautop', $autop) ) {
811
+				if ( is_array($replace_with) ) {
812
+					$replace_with = implode("\n", $replace_with);
813
+				}
814
+				$replace_with = wpautop($replace_with);
815
+			}
816 816
 			unset( $autop );
817 817
 		} else if ( is_array( $replace_with ) ) {
818 818
 			$replace_with = implode( $sep, $replace_with );
@@ -822,58 +822,58 @@  discard block
 block discarded – undo
822 822
 	}
823 823
 
824 824
 	public static function get_field_types( $type ) {
825
-        $single_input = array(
826
-            'text', 'textarea', 'rte', 'number', 'email', 'url',
827
-            'image', 'file', 'date', 'phone', 'hidden', 'time',
828
-            'user_id', 'tag', 'password',
829
-        );
825
+		$single_input = array(
826
+			'text', 'textarea', 'rte', 'number', 'email', 'url',
827
+			'image', 'file', 'date', 'phone', 'hidden', 'time',
828
+			'user_id', 'tag', 'password',
829
+		);
830 830
 		$multiple_input = array( 'radio', 'checkbox', 'select', 'scale', 'lookup' );
831 831
 		$other_type = array( 'html', 'break' );
832 832
 
833 833
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
834 834
 
835
-        $field_types = array();
836
-        if ( in_array($type, $single_input) ) {
837
-            self::field_types_for_input( $single_input, $field_selection, $field_types );
838
-        } else if ( in_array($type, $multiple_input) ) {
839
-            self::field_types_for_input( $multiple_input, $field_selection, $field_types );
840
-        } else if ( in_array($type, $other_type) ) {
841
-            self::field_types_for_input( $other_type, $field_selection, $field_types );
835
+		$field_types = array();
836
+		if ( in_array($type, $single_input) ) {
837
+			self::field_types_for_input( $single_input, $field_selection, $field_types );
838
+		} else if ( in_array($type, $multiple_input) ) {
839
+			self::field_types_for_input( $multiple_input, $field_selection, $field_types );
840
+		} else if ( in_array($type, $other_type) ) {
841
+			self::field_types_for_input( $other_type, $field_selection, $field_types );
842 842
 		} else if ( isset( $field_selection[ $type ] ) ) {
843
-            $field_types[ $type ] = $field_selection[ $type ];
844
-        }
843
+			$field_types[ $type ] = $field_selection[ $type ];
844
+		}
845 845
 
846 846
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
847
-        return $field_types;
848
-    }
849
-
850
-    private static function field_types_for_input( $inputs, $fields, &$field_types ) {
851
-        foreach ( $inputs as $input ) {
852
-            $field_types[ $input ] = $fields[ $input ];
853
-            unset($input);
854
-        }
855
-    }
856
-
857
-    /**
858
-    * Check if current field option is an "other" option
859
-    *
860
-    * @since 2.0.6
861
-    *
862
-    * @param string $opt_key
863
-    * @return boolean Returns true if current field option is an "Other" option
864
-    */
865
-    public static function is_other_opt( $opt_key ) {
866
-        return $opt_key && strpos( $opt_key, 'other' ) !== false;
867
-    }
868
-
869
-    /**
870
-    * Get value that belongs in "Other" text box
871
-    *
872
-    * @since 2.0.6
873
-    *
874
-    * @param array $args
875
-    */
876
-    public static function get_other_val( $args ) {
847
+		return $field_types;
848
+	}
849
+
850
+	private static function field_types_for_input( $inputs, $fields, &$field_types ) {
851
+		foreach ( $inputs as $input ) {
852
+			$field_types[ $input ] = $fields[ $input ];
853
+			unset($input);
854
+		}
855
+	}
856
+
857
+	/**
858
+	 * Check if current field option is an "other" option
859
+	 *
860
+	 * @since 2.0.6
861
+	 *
862
+	 * @param string $opt_key
863
+	 * @return boolean Returns true if current field option is an "Other" option
864
+	 */
865
+	public static function is_other_opt( $opt_key ) {
866
+		return $opt_key && strpos( $opt_key, 'other' ) !== false;
867
+	}
868
+
869
+	/**
870
+	 * Get value that belongs in "Other" text box
871
+	 *
872
+	 * @since 2.0.6
873
+	 *
874
+	 * @param array $args
875
+	 */
876
+	public static function get_other_val( $args ) {
877 877
 		$defaults = array(
878 878
 			'opt_key' => 0, 'field' => array(),
879 879
 			'parent' => false, 'pointer' => false,
@@ -949,20 +949,20 @@  discard block
 block discarded – undo
949 949
 		}
950 950
 
951 951
 		return $other_val;
952
-    }
953
-
954
-    /**
955
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
956
-    * Intended for front-end use
957
-    *
958
-    * @since 2.0.6
959
-    *
960
-    * @param array $args should include field, opt_key and field name
961
-    * @param boolean $other_opt
962
-    * @param string $checked
963
-    * @return string $other_val
964
-    */
965
-    public static function prepare_other_input( $args, &$other_opt, &$checked ) {
952
+	}
953
+
954
+	/**
955
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
956
+	 * Intended for front-end use
957
+	 *
958
+	 * @since 2.0.6
959
+	 *
960
+	 * @param array $args should include field, opt_key and field name
961
+	 * @param boolean $other_opt
962
+	 * @param string $checked
963
+	 * @return string $other_val
964
+	 */
965
+	public static function prepare_other_input( $args, &$other_opt, &$checked ) {
966 966
 		//Check if this is an "Other" option
967 967
 		if ( ! self::is_other_opt( $args['opt_key'] ) ) {
968 968
 			return;
@@ -978,8 +978,8 @@  discard block
 block discarded – undo
978 978
 			$checked = 'checked="checked" ';
979 979
 		}
980 980
 
981
-        return $other_args;
982
-    }
981
+		return $other_args;
982
+	}
983 983
 
984 984
 	/**
985 985
 	 * @param array $args
@@ -1028,8 +1028,8 @@  discard block
 block discarded – undo
1028 1028
 	 * @since 2.0.6
1029 1029
 	 */
1030 1030
 	public static function include_other_input( $args ) {
1031
-        if ( ! $args['other_opt'] ) {
1032
-        	return;
1031
+		if ( ! $args['other_opt'] ) {
1032
+			return;
1033 1033
 		}
1034 1034
 
1035 1035
 		$classes = array( 'frm_other_input' );
@@ -1050,15 +1050,15 @@  discard block
 block discarded – undo
1050 1050
 	}
1051 1051
 
1052 1052
 	/**
1053
-	* Get the HTML id for an "Other" text field
1054
-	* Note: This does not affect fields in repeating sections
1055
-	*
1056
-	* @since 2.0.08
1057
-	* @param string $type - field type
1058
-	* @param string $html_id
1059
-	* @param string|boolean $opt_key
1060
-	* @return string $other_id
1061
-	*/
1053
+	 * Get the HTML id for an "Other" text field
1054
+	 * Note: This does not affect fields in repeating sections
1055
+	 *
1056
+	 * @since 2.0.08
1057
+	 * @param string $type - field type
1058
+	 * @param string $html_id
1059
+	 * @param string|boolean $opt_key
1060
+	 * @return string $other_id
1061
+	 */
1062 1062
 	public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) {
1063 1063
 		$other_id = $html_id;
1064 1064
 
@@ -1116,10 +1116,10 @@  discard block
 block discarded – undo
1116 1116
 	}
1117 1117
 
1118 1118
 	public static function switch_field_ids( $val ) {
1119
-        global $frm_duplicate_ids;
1120
-        $replace = array();
1121
-        $replace_with = array();
1122
-        foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1119
+		global $frm_duplicate_ids;
1120
+		$replace = array();
1121
+		$replace_with = array();
1122
+		foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1123 1123
 			$replace[] = '[if ' . $old . ']';
1124 1124
 			$replace_with[] = '[if ' . $new . ']';
1125 1125
 			$replace[] = '[if ' . $old . ' ';
@@ -1134,153 +1134,153 @@  discard block
 block discarded – undo
1134 1134
 			$replace_with[] = '[' . $new . ']';
1135 1135
 			$replace[] = '[' . $old . ' ';
1136 1136
 			$replace_with[] = '[' . $new . ' ';
1137
-            unset($old, $new);
1138
-        }
1137
+			unset($old, $new);
1138
+		}
1139 1139
 		if ( is_array( $val ) ) {
1140 1140
 			foreach ( $val as $k => $v ) {
1141
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1142
-                unset($k, $v);
1143
-            }
1144
-        } else {
1145
-            $val = str_replace($replace, $replace_with, $val);
1146
-        }
1147
-
1148
-        return $val;
1149
-    }
1150
-
1151
-    public static function get_us_states() {
1152
-        return apply_filters( 'frm_us_states', array(
1153
-            'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1154
-            'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1155
-            'DC' => 'District of Columbia',
1156
-            'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1157
-            'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1158
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1159
-            'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1160
-            'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1161
-            'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1162
-            'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1163
-            'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1164
-            'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1165
-            'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1166
-            'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1167
-        ) );
1168
-    }
1169
-
1170
-    public static function get_countries() {
1171
-        return apply_filters( 'frm_countries', array(
1172
-            __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1173
-            __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1174
-            __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1175
-            __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1176
-            __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1177
-            __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1178
-            __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1179
-            __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1180
-            __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1181
-            __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1182
-            __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1183
-            __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1184
-            __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1185
-            __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1186
-            __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1187
-            __( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1188
-            __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1189
-            __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1190
-            __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1191
-            __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1192
-            __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1193
-            __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1194
-            __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1195
-            __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1196
-            __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1197
-            __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1198
-            __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1199
-            __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1200
-            __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1201
-            __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1202
-            __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1203
-            __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1204
-            __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1205
-            __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1206
-            __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1207
-            __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1208
-            __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1209
-            __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1210
-            __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1211
-            __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1212
-            __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1213
-            __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1214
-            __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1215
-            __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1216
-            __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1217
-            __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1218
-            __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1219
-            __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1220
-            __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1221
-            __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1222
-            __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1223
-            __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1224
-            __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1225
-            __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1226
-            __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1227
-            __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1228
-            __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1229
-            __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1230
-            __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1231
-            __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1232
-            __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1233
-            __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1234
-            __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1235
-            __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1236
-            __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1237
-            __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1238
-            __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1239
-            __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1240
-            __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1241
-            __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1242
-            __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1243
-            __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1244
-            __( 'Zimbabwe', 'formidable' ),
1245
-        ) );
1246
-    }
1141
+				$val[ $k ] = str_replace( $replace, $replace_with, $v );
1142
+				unset($k, $v);
1143
+			}
1144
+		} else {
1145
+			$val = str_replace($replace, $replace_with, $val);
1146
+		}
1147
+
1148
+		return $val;
1149
+	}
1150
+
1151
+	public static function get_us_states() {
1152
+		return apply_filters( 'frm_us_states', array(
1153
+			'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1154
+			'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1155
+			'DC' => 'District of Columbia',
1156
+			'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1157
+			'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1158
+			'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1159
+			'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1160
+			'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1161
+			'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1162
+			'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1163
+			'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1164
+			'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1165
+			'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1166
+			'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1167
+		) );
1168
+	}
1169
+
1170
+	public static function get_countries() {
1171
+		return apply_filters( 'frm_countries', array(
1172
+			__( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1173
+			__( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1174
+			__( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1175
+			__( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1176
+			__( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1177
+			__( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1178
+			__( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1179
+			__( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1180
+			__( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1181
+			__( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1182
+			__( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1183
+			__( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1184
+			__( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1185
+			__( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1186
+			__( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1187
+			__( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1188
+			__( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1189
+			__( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1190
+			__( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1191
+			__( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1192
+			__( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1193
+			__( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1194
+			__( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1195
+			__( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1196
+			__( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1197
+			__( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1198
+			__( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1199
+			__( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1200
+			__( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1201
+			__( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1202
+			__( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1203
+			__( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1204
+			__( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1205
+			__( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1206
+			__( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1207
+			__( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1208
+			__( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1209
+			__( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1210
+			__( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1211
+			__( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1212
+			__( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1213
+			__( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1214
+			__( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1215
+			__( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1216
+			__( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1217
+			__( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1218
+			__( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1219
+			__( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1220
+			__( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1221
+			__( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1222
+			__( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1223
+			__( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1224
+			__( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1225
+			__( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1226
+			__( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1227
+			__( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1228
+			__( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1229
+			__( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1230
+			__( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1231
+			__( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1232
+			__( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1233
+			__( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1234
+			__( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1235
+			__( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1236
+			__( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1237
+			__( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1238
+			__( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1239
+			__( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1240
+			__( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1241
+			__( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1242
+			__( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1243
+			__( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1244
+			__( 'Zimbabwe', 'formidable' ),
1245
+		) );
1246
+	}
1247 1247
 
1248 1248
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1249 1249
 		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1250 1250
 
1251
-        $states = FrmFieldsHelper::get_us_states();
1252
-        $state_abv = array_keys($states);
1253
-        sort($state_abv);
1251
+		$states = FrmFieldsHelper::get_us_states();
1252
+		$state_abv = array_keys($states);
1253
+		sort($state_abv);
1254 1254
 		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1255 1255
 
1256
-        $states = array_values($states);
1257
-        sort($states);
1256
+		$states = array_values($states);
1257
+		sort($states);
1258 1258
 		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1259
-        unset($state_abv, $states);
1259
+		unset($state_abv, $states);
1260 1260
 
1261 1261
 		$prepop[ __( 'Age', 'formidable' ) ] = array(
1262
-            __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1263
-            __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1264
-            __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1265
-        );
1262
+			__( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1263
+			__( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1264
+			__( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1265
+		);
1266 1266
 
1267 1267
 		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1268
-            __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1269
-            __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1270
-        );
1268
+			__( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1269
+			__( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1270
+		);
1271 1271
 
1272 1272
 		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1273
-            __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1274
-            __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1275
-        );
1273
+			__( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1274
+			__( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1275
+		);
1276 1276
 
1277 1277
 		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1278
-            __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1279
-            __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1280
-        );
1278
+			__( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1279
+			__( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1280
+		);
1281 1281
 
1282 1282
 		$prepop = apply_filters( 'frm_bulk_field_choices', $prepop );
1283
-    }
1283
+	}
1284 1284
 
1285 1285
 	public static function field_selection() {
1286 1286
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::field_selection' );
@@ -1317,10 +1317,10 @@  discard block
 block discarded – undo
1317 1317
 		return FrmField::is_required( $field );
1318 1318
 	}
1319 1319
 
1320
-    public static function maybe_get_field( &$field ) {
1320
+	public static function maybe_get_field( &$field ) {
1321 1321
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' );
1322 1322
 		FrmField::maybe_get_field( $field );
1323
-    }
1323
+	}
1324 1324
 
1325 1325
 	public static function dropdown_categories( $args ) {
1326 1326
 		_deprecated_function( __FUNCTION__, '2.02.07', 'FrmProPost::get_category_dropdown' );
Please login to merge, or discard this patch.
classes/views/frm-fields/input.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -10,41 +10,41 @@  discard block
 block discarded – undo
10 10
 <?php
11 11
 
12 12
 } else if ( $field['type'] == 'radio' ) {
13
-    $read_only = false;
13
+	$read_only = false;
14 14
 	if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
15
-        $read_only = true; ?>
15
+		$read_only = true; ?>
16 16
 <input type="hidden" value="<?php echo esc_attr( $field['value'] ) ?>" name="<?php echo esc_attr( $field_name ) ?>" />
17 17
 <?php
18
-    }
18
+	}
19 19
 
20
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
20
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
21 21
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
22
-    } else if ( is_array($field['options']) ) {
23
-        foreach ( $field['options'] as $opt_key => $opt ) {
22
+	} else if ( is_array($field['options']) ) {
23
+		foreach ( $field['options'] as $opt_key => $opt ) {
24 24
 			if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
25
-                continue;
26
-            }
25
+				continue;
26
+			}
27 27
 
28
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
28
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
30 30
 			<div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php
31 31
 
32 32
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
33 33
 				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
34
-            }
35
-            $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
34
+			}
35
+			$checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
36 36
 
37
-            $other_opt = false;
38
-            $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39
-            ?>
37
+			$other_opt = false;
38
+			$other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39
+			?>
40 40
             <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php
41
-            echo $checked;
42
-            do_action('frm_field_input_html', $field);
41
+			echo $checked;
42
+			do_action('frm_field_input_html', $field);
43 43
 ?>/><?php
44 44
 
45 45
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
46 46
 				echo ' ' . $opt . '</label>';
47
-            }
47
+			}
48 48
 
49 49
 			FrmFieldsHelper::include_other_input( array(
50 50
 				'other_opt' => $other_opt, 'read_only' => $read_only,
@@ -53,58 +53,58 @@  discard block
 block discarded – undo
53 53
 				'html_id' => $html_id, 'opt_key' => $opt_key,
54 54
 			) );
55 55
 
56
-            unset( $other_opt, $other_args );
56
+			unset( $other_opt, $other_args );
57 57
 ?></div>
58 58
 <?php
59
-        }
60
-    }
59
+		}
60
+	}
61 61
 } else if ( $field['type'] == 'select' ) {
62 62
 	include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/front-end/dropdown-field.php' );
63 63
 } else if ( $field['type'] == 'checkbox' ) {
64
-    $checked_values = $field['value'];
65
-    $read_only = false;
64
+	$checked_values = $field['value'];
65
+	$read_only = false;
66 66
 
67 67
 	if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
68
-        $read_only = true;
69
-        if ( $checked_values ) {
70
-            foreach ( (array) $checked_values as $checked_value ) { ?>
68
+		$read_only = true;
69
+		if ( $checked_values ) {
70
+			foreach ( (array) $checked_values as $checked_value ) { ?>
71 71
 <input type="hidden" value="<?php echo esc_attr( $checked_value ) ?>" name="<?php echo esc_attr( $field_name ) ?>[]" />
72 72
 <?php
73
-            }
74
-        } else { ?>
73
+			}
74
+		} else { ?>
75 75
 <input type="hidden" value="" name="<?php echo esc_attr( $field_name ) ?>[]" />
76 76
 <?php
77
-        }
78
-    }
77
+		}
78
+	}
79 79
 
80
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
80
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
81 81
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
82
-    } else if ( $field['options'] ) {
83
-        foreach ( $field['options'] as $opt_key => $opt ) {
84
-            if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
85
-                continue;
86
-            }
87
-
88
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
89
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
90
-            $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
91
-
92
-            // Check if other opt, and get values for other field if needed
93
-            $other_opt = false;
82
+	} else if ( $field['options'] ) {
83
+		foreach ( $field['options'] as $opt_key => $opt ) {
84
+			if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
85
+				continue;
86
+			}
87
+
88
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
89
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
90
+			$checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
91
+
92
+			// Check if other opt, and get values for other field if needed
93
+			$other_opt = false;
94 94
 			$other_args = FrmFieldsHelper::prepare_other_input( compact( 'field', 'field_name', 'opt_key' ), $other_opt, $checked );
95 95
 
96
-            ?>
96
+			?>
97 97
 			<div class="<?php echo esc_attr( apply_filters( 'frm_checkbox_class', 'frm_checkbox', $field, $field_val ) ) ?>" id="frm_checkbox_<?php echo esc_attr( $field['id'] ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
98 98
 
99
-            if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
100
-                ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
101
-            }
99
+			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
100
+				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
101
+			}
102 102
 
103
-            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
103
+			?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
104 104
 
105
-            if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
105
+			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
106 106
 				echo ' ' . $opt . '</label>';
107
-            }
107
+			}
108 108
 
109 109
 			FrmFieldsHelper::include_other_input( array(
110 110
 				'other_opt' => $other_opt, 'read_only' => $read_only,
@@ -113,17 +113,17 @@  discard block
 block discarded – undo
113 113
 				'html_id' => $html_id, 'opt_key' => $opt_key,
114 114
 			) );
115 115
 
116
-            unset( $other_opt, $other_args, $checked );
116
+			unset( $other_opt, $other_args, $checked );
117 117
 
118
-            ?></div>
118
+			?></div>
119 119
 <?php
120
-        }
121
-    }
120
+		}
121
+	}
122 122
 } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) {
123
-    $frm_settings = FrmAppHelper::get_settings();
124
-    if ( ! empty($frm_settings->pubkey) ) {
125
-        FrmFieldsHelper::display_recaptcha($field);
126
-    }
123
+	$frm_settings = FrmAppHelper::get_settings();
124
+	if ( ! empty($frm_settings->pubkey) ) {
125
+		FrmFieldsHelper::display_recaptcha($field);
126
+	}
127 127
 } else {
128 128
 	do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) );
129 129
 	do_action( 'frm_form_field_' . $field['type'], $field, $field_name, compact( 'errors', 'html_id' ) );
Please login to merge, or discard this patch.
classes/views/frm-fields/show-build.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -3,32 +3,32 @@
 block discarded – undo
3 3
 <?php } else if ( $field['type'] == 'textarea' ) { ?>
4 4
     <textarea name="<?php echo esc_attr( $field_name ) ?>" <?php
5 5
 		echo ( FrmField::is_option_true( $field, 'size' ) ) ? esc_attr( 'style="width:' . $field['size'] . ( is_numeric( $field['size'] ) ? 'px' : '' ) . ';"' ) : '';
6
-    ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea(force_balance_tags($field['default_value'])); ?></textarea>
6
+	?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea(force_balance_tags($field['default_value'])); ?></textarea>
7 7
 
8 8
 <?php
9 9
 
10 10
 } else if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
11
-    $field['default_value'] = maybe_unserialize($field['default_value']);
12
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
11
+	$field['default_value'] = maybe_unserialize($field['default_value']);
12
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
13 13
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
14
-    } else {
15
-        do_action('frm_add_multiple_opts_labels', $field); ?>
14
+	} else {
15
+		do_action('frm_add_multiple_opts_labels', $field); ?>
16 16
         <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts frm_clear<?php echo (count($field['options']) > 10) ? ' frm_field_opts_list' : ''; ?>">
17 17
 			<?php include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); ?>
18 18
         </ul>
19 19
     <?php
20
-    }
20
+	}
21 21
 } else if ( $field['type'] == 'select' ) {
22 22
 	include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/dropdown-field.php' );
23 23
 } else if ( $field['type'] == 'captcha' ) {
24 24
 	if ( empty($frm_settings->pubkey) ) { ?>
25 25
     <div class="howto frm_no_captcha_text"><?php printf(__( 'Your captcha will not appear on your form until you %1$sset up%2$s the Site and Secret Keys', 'formidable' ), '<a href="?page=formidable-settings">', '</a>') ?></div>
26 26
     <?php
27
-    } ?>
27
+	} ?>
28 28
 	<img src="<?php echo esc_url( FrmAppHelper::plugin_url() . '/images/recaptcha.png' ) ?>" class="recaptcha_placeholder" alt="reCaptcha"/>
29 29
     <input type="hidden" name="<?php echo esc_attr( $field_name ) ?>" value="1" />
30 30
 <?php
31 31
 } else {
32
-    do_action( 'frm_display_added_fields', $field );
32
+	do_action( 'frm_display_added_fields', $field );
33 33
 	do_action( 'frm_display_added_' . $field['type'] . '_field', $field );
34 34
 }
Please login to merge, or discard this patch.