Completed
Push — master ( e696cb...79f1e4 )
by Stephanie
03:36
created
classes/helpers/FrmEntriesHelper.php 2 patches
Indentation   +297 added lines, -297 removed lines patch added patch discarded remove patch
@@ -5,69 +5,69 @@  discard block
 block discarded – undo
5 5
 
6 6
 class FrmEntriesHelper {
7 7
 
8
-    public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9
-        $values = array();
8
+	public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9
+		$values = array();
10 10
 		foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) {
11 11
 			$values[ $var ] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' );
12
-        }
13
-
14
-        $values['fields'] = array();
15
-        if ( empty($fields) ) {
16
-            return apply_filters('frm_setup_new_entry', $values);
17
-        }
18
-
19
-        foreach ( (array) $fields as $field ) {
20
-            $new_value = self::get_field_value_for_new_entry( $field, $reset, $args );
21
-
22
-            $field_array = array(
23
-                'id' => $field->id,
24
-                'value' => $new_value,
25
-                'default_value' => $field->default_value,
26
-                'name' => $field->name,
27
-                'description' => $field->description,
28
-                'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
29
-                'options' => $field->options,
30
-                'required' => $field->required,
31
-                'field_key' => $field->field_key,
32
-                'field_order' => $field->field_order,
33
-                'form_id' => $field->form_id,
12
+		}
13
+
14
+		$values['fields'] = array();
15
+		if ( empty($fields) ) {
16
+			return apply_filters('frm_setup_new_entry', $values);
17
+		}
18
+
19
+		foreach ( (array) $fields as $field ) {
20
+			$new_value = self::get_field_value_for_new_entry( $field, $reset, $args );
21
+
22
+			$field_array = array(
23
+				'id' => $field->id,
24
+				'value' => $new_value,
25
+				'default_value' => $field->default_value,
26
+				'name' => $field->name,
27
+				'description' => $field->description,
28
+				'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
29
+				'options' => $field->options,
30
+				'required' => $field->required,
31
+				'field_key' => $field->field_key,
32
+				'field_order' => $field->field_order,
33
+				'form_id' => $field->form_id,
34 34
 				'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id,
35
-	            'reset_value' => $reset,
35
+				'reset_value' => $reset,
36 36
 				'in_embed_form' => isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0',
37
-            );
37
+			);
38 38
 
39
-            $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
40
-            $opt_defaults['required_indicator'] = '';
39
+			$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
40
+			$opt_defaults['required_indicator'] = '';
41 41
 			$opt_defaults['original_type'] = $field->type;
42 42
 
43 43
 			foreach ( $opt_defaults as $opt => $default_opt ) {
44
-                $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
45
-                unset($opt, $default_opt);
46
-            }
44
+				$field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
45
+				unset($opt, $default_opt);
46
+			}
47 47
 
48
-            unset($opt_defaults);
48
+			unset($opt_defaults);
49 49
 
50
-            if ( $field_array['custom_html'] == '' ) {
51
-                $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
52
-            }
50
+			if ( $field_array['custom_html'] == '' ) {
51
+				$field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
52
+			}
53 53
 
54
-            $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args );
55
-            $field_array = array_merge( $field->field_options, $field_array );
54
+			$field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args );
55
+			$field_array = array_merge( $field->field_options, $field_array );
56 56
 
57
-            $values['fields'][] = $field_array;
57
+			$values['fields'][] = $field_array;
58 58
 
59
-            if ( ! $form || ! isset($form->id) ) {
60
-                $form = FrmForm::getOne($field->form_id);
61
-            }
62
-        }
59
+			if ( ! $form || ! isset($form->id) ) {
60
+				$form = FrmForm::getOne($field->form_id);
61
+			}
62
+		}
63 63
 
64
-        $form->options = maybe_unserialize($form->options);
65
-        if ( is_array($form->options) ) {
66
-            foreach ( $form->options as $opt => $value ) {
67
-                $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
68
-                unset($opt, $value);
69
-            }
70
-        }
64
+		$form->options = maybe_unserialize($form->options);
65
+		if ( is_array($form->options) ) {
66
+			foreach ( $form->options as $opt => $value ) {
67
+				$values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
68
+				unset($opt, $value);
69
+			}
70
+		}
71 71
 
72 72
 		$form_defaults = FrmFormsHelper::get_default_opts();
73 73
 
@@ -77,19 +77,19 @@  discard block
 block discarded – undo
77 77
 		$values = array_merge( $form_defaults, $values );
78 78
 
79 79
 		return apply_filters( 'frm_setup_new_entry', $values );
80
-    }
80
+	}
81 81
 
82 82
 	/**
83
-	* Set the value for each field
84
-	* This function is used when the form is first loaded and on all page turns *for a new entry*
85
-	*
86
-	* @since 2.0.13
87
-	*
88
-	* @param object $field - this is passed by reference since it is an object
89
-	* @param boolean $reset
90
-	* @param array $args
91
-	* @return string|array $new_value
92
-	*/
83
+	 * Set the value for each field
84
+	 * This function is used when the form is first loaded and on all page turns *for a new entry*
85
+	 *
86
+	 * @since 2.0.13
87
+	 *
88
+	 * @param object $field - this is passed by reference since it is an object
89
+	 * @param boolean $reset
90
+	 * @param array $args
91
+	 * @return string|array $new_value
92
+	 */
93 93
 	private static function get_field_value_for_new_entry( $field, $reset, $args ) {
94 94
 		//If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array
95 95
 		$return_array = FrmField::is_field_with_multiple_values( $field );
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
 	}
116 116
 
117 117
 	/**
118
-	* Check if a field has a posted value
119
-	*
120
-	* @since 2.01.0
121
-	* @param object $field
122
-	* @param array $args
123
-	* @return boolean $value_is_posted
124
-	*/
118
+	 * Check if a field has a posted value
119
+	 *
120
+	 * @since 2.01.0
121
+	 * @param object $field
122
+	 * @param array $args
123
+	 * @return boolean $value_is_posted
124
+	 */
125 125
 	public static function value_is_posted( $field, $args ) {
126 126
 		$value_is_posted = false;
127 127
 		if ( $_POST ) {
@@ -139,15 +139,15 @@  discard block
 block discarded – undo
139 139
 
140 140
 	public static function setup_edit_vars( $values, $record ) {
141 141
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
142
-        $values['form_id'] = $record->form_id;
143
-        $values['is_draft'] = $record->is_draft;
144
-        return apply_filters('frm_setup_edit_entry_vars', $values, $record);
145
-    }
142
+		$values['form_id'] = $record->form_id;
143
+		$values['is_draft'] = $record->is_draft;
144
+		return apply_filters('frm_setup_edit_entry_vars', $values, $record);
145
+	}
146 146
 
147
-    public static function get_admin_params( $form = null ) {
147
+	public static function get_admin_params( $form = null ) {
148 148
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_admin_params' );
149 149
 		return FrmForm::set_current_form( $form );
150
-    }
150
+	}
151 151
 
152 152
 	public static function set_current_form( $form_id ) {
153 153
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::set_current_form' );
@@ -159,283 +159,283 @@  discard block
 block discarded – undo
159 159
 		return FrmForm::get_current_form( $form_id );
160 160
 	}
161 161
 
162
-    public static function get_current_form_id() {
162
+	public static function get_current_form_id() {
163 163
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_current_form_id' );
164 164
 		return FrmForm::get_current_form_id();
165
-    }
165
+	}
166 166
 
167
-    public static function maybe_get_entry( &$entry ) {
167
+	public static function maybe_get_entry( &$entry ) {
168 168
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntry::maybe_get_entry' );
169 169
 		FrmEntry::maybe_get_entry( $entry );
170
-    }
170
+	}
171 171
 
172 172
 	public static function replace_default_message( $message, $atts ) {
173
-        if ( strpos($message, '[default-message') === false &&
174
-            strpos($message, '[default_message') === false &&
175
-            ! empty( $message ) ) {
176
-            return $message;
177
-        }
178
-
179
-        if ( empty($message) ) {
180
-            $message = '[default-message]';
181
-        }
182
-
183
-        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
184
-
185
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
186
-            $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
187
-            if ( $add_atts ) {
188
-                $this_atts = array_merge($atts, $add_atts);
189
-            } else {
190
-                $this_atts = $atts;
191
-            }
173
+		if ( strpos($message, '[default-message') === false &&
174
+			strpos($message, '[default_message') === false &&
175
+			! empty( $message ) ) {
176
+			return $message;
177
+		}
178
+
179
+		if ( empty($message) ) {
180
+			$message = '[default-message]';
181
+		}
182
+
183
+		preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
184
+
185
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
186
+			$add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
187
+			if ( $add_atts ) {
188
+				$this_atts = array_merge($atts, $add_atts);
189
+			} else {
190
+				$this_atts = $atts;
191
+			}
192 192
 
193 193
 			$default = FrmEntryFormat::show_entry( $this_atts );
194 194
 
195
-            // Add the default message
196
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
197
-        }
195
+			// Add the default message
196
+			$message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
197
+		}
198 198
 
199
-        return $message;
200
-    }
199
+		return $message;
200
+	}
201 201
 
202 202
 	public static function prepare_display_value( $entry, $field, $atts ) {
203 203
 		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
204 204
 
205
-        if ( FrmAppHelper::pro_is_installed() ) {
205
+		if ( FrmAppHelper::pro_is_installed() ) {
206 206
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
207
-        }
207
+		}
208 208
 
209
-        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
210
-            return self::display_value($field_value, $field, $atts);
211
-        }
209
+		if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
210
+			return self::display_value($field_value, $field, $atts);
211
+		}
212 212
 
213
-        // this is an embeded form
214
-        $val = '';
213
+		// this is an embeded form
214
+		$val = '';
215 215
 
216
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
217
-            //this is a repeating section
216
+		if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
217
+			//this is a repeating section
218 218
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
219
-        } else {
220
-            // get all values for this field
221
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
219
+		} else {
220
+			// get all values for this field
221
+			$child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
222 222
 
223
-            if ( $child_values ) {
224
-	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
225
-	        }
226
-	    }
223
+			if ( $child_values ) {
224
+				$child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
225
+			}
226
+		}
227 227
 
228
-	    $field_value = array();
228
+		$field_value = array();
229 229
 
230
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
231
-            return $val;
232
-        }
230
+		if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
231
+			return $val;
232
+		}
233 233
 
234
-        foreach ( $child_entries as $child_entry ) {
235
-            $atts['item_id'] = $child_entry->id;
236
-            $atts['post_id'] = $child_entry->post_id;
234
+		foreach ( $child_entries as $child_entry ) {
235
+			$atts['item_id'] = $child_entry->id;
236
+			$atts['post_id'] = $child_entry->post_id;
237 237
 
238
-            // get the value for this field -- check for post values as well
239
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
238
+			// get the value for this field -- check for post values as well
239
+			$entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
240 240
 
241
-            if ( $entry_val ) {
242
-                // foreach entry get display_value
243
-                $field_value[] = self::display_value($entry_val, $field, $atts);
244
-            }
241
+			if ( $entry_val ) {
242
+				// foreach entry get display_value
243
+				$field_value[] = self::display_value($entry_val, $field, $atts);
244
+			}
245 245
 
246
-            unset($child_entry);
247
-        }
246
+			unset($child_entry);
247
+		}
248 248
 
249
-        $val = implode(', ', (array) $field_value );
249
+		$val = implode(', ', (array) $field_value );
250 250
 		$val = wp_kses_post( $val );
251 251
 
252
-        return $val;
253
-    }
252
+		return $val;
253
+	}
254 254
 
255
-    /**
256
-     * Prepare the saved value for display
257
-     * @return string
258
-     */
255
+	/**
256
+	 * Prepare the saved value for display
257
+	 * @return string
258
+	 */
259 259
 	public static function display_value( $value, $field, $atts = array() ) {
260 260
 
261
-        $defaults = array(
262
-            'type' => '', 'html' => false, 'show_filename' => true,
263
-            'truncate' => false, 'sep' => ', ', 'post_id' => 0,
264
-            'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0,
261
+		$defaults = array(
262
+			'type' => '', 'html' => false, 'show_filename' => true,
263
+			'truncate' => false, 'sep' => ', ', 'post_id' => 0,
264
+			'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0,
265 265
 			'return_array' => false,
266
-        );
266
+		);
267 267
 
268
-        $atts = wp_parse_args( $atts, $defaults );
269
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
268
+		$atts = wp_parse_args( $atts, $defaults );
269
+		$atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
270 270
 
271
-        if ( ! isset($field->field_options['post_field']) ) {
272
-            $field->field_options['post_field'] = '';
273
-        }
271
+		if ( ! isset($field->field_options['post_field']) ) {
272
+			$field->field_options['post_field'] = '';
273
+		}
274 274
 
275
-        if ( ! isset($field->field_options['custom_field']) ) {
276
-            $field->field_options['custom_field'] = '';
277
-        }
275
+		if ( ! isset($field->field_options['custom_field']) ) {
276
+			$field->field_options['custom_field'] = '';
277
+		}
278 278
 
279
-        if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
280
-            $atts['pre_truncate'] = $atts['truncate'];
281
-            $atts['truncate'] = true;
282
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
279
+		if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
280
+			$atts['pre_truncate'] = $atts['truncate'];
281
+			$atts['truncate'] = true;
282
+			$atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
283 283
 
284
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
285
-            $atts['truncate'] = $atts['pre_truncate'];
286
-        }
284
+			$value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
285
+			$atts['truncate'] = $atts['pre_truncate'];
286
+		}
287 287
 
288
-        if ( $value == '' ) {
289
-            return $value;
290
-        }
288
+		if ( $value == '' ) {
289
+			return $value;
290
+		}
291 291
 
292
-        $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
292
+		$value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
293 293
 		$value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) );
294 294
 
295
-        $new_value = '';
295
+		$new_value = '';
296 296
 
297
-        if ( is_array($value) && $atts['type'] != 'file' ) {
298
-            foreach ( $value as $val ) {
299
-                if ( is_array($val) ) {
297
+		if ( is_array($value) && $atts['type'] != 'file' ) {
298
+			foreach ( $value as $val ) {
299
+				if ( is_array($val) ) {
300 300
 					//TODO: add options for display (li or ,)
301
-                    $new_value .= implode($atts['sep'], $val);
302
-                    if ( $atts['type'] != 'data' ) {
303
-                        $new_value .= '<br/>';
304
-                    }
305
-                }
306
-                unset($val);
307
-            }
308
-        }
309
-
310
-        if ( ! empty($new_value) ) {
311
-            $value = $new_value;
312
-        } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
313
-            $value = implode($atts['sep'], $value);
314
-        }
315
-
316
-        if ( $atts['truncate'] && $atts['type'] != 'image' ) {
317
-            $value = FrmAppHelper::truncate($value, 50);
318
-        }
301
+					$new_value .= implode($atts['sep'], $val);
302
+					if ( $atts['type'] != 'data' ) {
303
+						$new_value .= '<br/>';
304
+					}
305
+				}
306
+				unset($val);
307
+			}
308
+		}
309
+
310
+		if ( ! empty($new_value) ) {
311
+			$value = $new_value;
312
+		} else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
313
+			$value = implode($atts['sep'], $value);
314
+		}
315
+
316
+		if ( $atts['truncate'] && $atts['type'] != 'image' ) {
317
+			$value = FrmAppHelper::truncate($value, 50);
318
+		}
319 319
 
320 320
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
321 321
 			$value = wp_kses_post( $value );
322 322
 		}
323 323
 
324
-        return apply_filters('frm_display_value', $value, $field, $atts);
325
-    }
324
+		return apply_filters('frm_display_value', $value, $field, $atts);
325
+	}
326 326
 
327 327
 	public static function set_posted_value( $field, $value, $args ) {
328
-        // If validating a field with "other" opt, set back to prev value now
329
-        if ( isset( $args['other'] ) && $args['other'] ) {
330
-            $value = $args['temp_value'];
331
-        }
332
-        if ( empty($args['parent_field_id']) ) {
333
-            $_POST['item_meta'][ $field->id ] = $value;
334
-        } else {
335
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
336
-        }
337
-    }
328
+		// If validating a field with "other" opt, set back to prev value now
329
+		if ( isset( $args['other'] ) && $args['other'] ) {
330
+			$value = $args['temp_value'];
331
+		}
332
+		if ( empty($args['parent_field_id']) ) {
333
+			$_POST['item_meta'][ $field->id ] = $value;
334
+		} else {
335
+			$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
336
+		}
337
+	}
338 338
 
339 339
 	public static function get_posted_value( $field, &$value, $args ) {
340 340
 		$field_id = is_object( $field ) ? $field->id : $field;
341 341
 
342
-        if ( empty($args['parent_field_id']) ) {
343
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? wp_kses_post( $_POST['item_meta'][ $field_id ] ) : '';
344
-        } else {
345
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? wp_kses_post( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) : '';
346
-        }
342
+		if ( empty($args['parent_field_id']) ) {
343
+			$value = isset( $_POST['item_meta'][ $field_id ] ) ? wp_kses_post( $_POST['item_meta'][ $field_id ] ) : '';
344
+		} else {
345
+			$value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? wp_kses_post( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) : '';
346
+		}
347 347
 		$value = stripslashes_deep( $value );
348
-    }
349
-
350
-    /**
351
-    * Check if field has an "Other" option and if any other values are posted
352
-    *
353
-    * @since 2.0
354
-    *
355
-    * @param object $field
356
-    * @param string|array $value
357
-    * @param array $args
358
-    */
359
-    public static function maybe_set_other_validation( $field, &$value, &$args ) {
360
-        $args['other'] = false;
361
-        if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
362
-            return;
363
-        }
364
-
365
-        // Get other value for fields in repeating section
366
-        self::set_other_repeating_vals( $field, $value, $args );
367
-
368
-        // Check if there are any posted "Other" values
348
+	}
349
+
350
+	/**
351
+	 * Check if field has an "Other" option and if any other values are posted
352
+	 *
353
+	 * @since 2.0
354
+	 *
355
+	 * @param object $field
356
+	 * @param string|array $value
357
+	 * @param array $args
358
+	 */
359
+	public static function maybe_set_other_validation( $field, &$value, &$args ) {
360
+		$args['other'] = false;
361
+		if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
362
+			return;
363
+		}
364
+
365
+		// Get other value for fields in repeating section
366
+		self::set_other_repeating_vals( $field, $value, $args );
367
+
368
+		// Check if there are any posted "Other" values
369 369
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
370 370
 
371
-            // Save original value
372
-            $args['temp_value'] = $value;
373
-            $args['other'] = true;
374
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
375
-
376
-            // Set the validation value now
377
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
378
-        }
379
-    }
380
-
381
-    /**
382
-    * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
383
-    *
384
-    * @since 2.0
385
-    *
386
-    * @param object $field
387
-    * @param string|array $value
388
-    * @param array $args
389
-    */
390
-    public static function set_other_repeating_vals( $field, &$value, &$args ) {
391
-        if ( ! $args['parent_field_id'] ) {
392
-            return;
393
-        }
394
-
395
-        // Check if there are any other posted "other" values for this field
371
+			// Save original value
372
+			$args['temp_value'] = $value;
373
+			$args['other'] = true;
374
+			$other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
375
+
376
+			// Set the validation value now
377
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
378
+		}
379
+	}
380
+
381
+	/**
382
+	 * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
383
+	 *
384
+	 * @since 2.0
385
+	 *
386
+	 * @param object $field
387
+	 * @param string|array $value
388
+	 * @param array $args
389
+	 */
390
+	public static function set_other_repeating_vals( $field, &$value, &$args ) {
391
+		if ( ! $args['parent_field_id'] ) {
392
+			return;
393
+		}
394
+
395
+		// Check if there are any other posted "other" values for this field
396 396
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
397
-            // Save original value
398
-            $args['temp_value'] = $value;
399
-            $args['other'] = true;
400
-
401
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
402
-
403
-            // Set the validation value now
404
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
405
-        }
406
-    }
407
-
408
-    /**
409
-    * Modify value used for validation
410
-    * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
411
-    * It also adds any text from the free text fields to the value
412
-    *
413
-    * Needs to accommodate for times when other opt is selected, but no other free text is entered
414
-    *
415
-    * @since 2.0
416
-    *
417
-    * @param string|array $value
418
-    * @param string|array $other_vals (usually of posted values)
419
-    * @param object $field
420
-    * @param array $args
421
-    */
422
-    public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
423
-        // Checkboxes and multi-select dropdowns
424
-        if ( is_array( $value ) && $field->type == 'checkbox' ) {
425
-            // Combine "Other" values with checked values. "Other" values will override checked box values.
426
-            $value = array_merge( $value, $other_vals );
427
-            $value = array_filter( $value );
428
-            if ( count( $value ) == 0 ) {
429
-                $value = '';
430
-            }
431
-        } else {
397
+			// Save original value
398
+			$args['temp_value'] = $value;
399
+			$args['other'] = true;
400
+
401
+			$other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
402
+
403
+			// Set the validation value now
404
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
405
+		}
406
+	}
407
+
408
+	/**
409
+	 * Modify value used for validation
410
+	 * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
411
+	 * It also adds any text from the free text fields to the value
412
+	 *
413
+	 * Needs to accommodate for times when other opt is selected, but no other free text is entered
414
+	 *
415
+	 * @since 2.0
416
+	 *
417
+	 * @param string|array $value
418
+	 * @param string|array $other_vals (usually of posted values)
419
+	 * @param object $field
420
+	 * @param array $args
421
+	 */
422
+	public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
423
+		// Checkboxes and multi-select dropdowns
424
+		if ( is_array( $value ) && $field->type == 'checkbox' ) {
425
+			// Combine "Other" values with checked values. "Other" values will override checked box values.
426
+			$value = array_merge( $value, $other_vals );
427
+			$value = array_filter( $value );
428
+			if ( count( $value ) == 0 ) {
429
+				$value = '';
430
+			}
431
+		} else {
432 432
 			// Radio and dropdowns
433
-            $other_key = array_filter( array_keys($field->options), 'is_string');
434
-            $other_key = reset( $other_key );
433
+			$other_key = array_filter( array_keys($field->options), 'is_string');
434
+			$other_key = reset( $other_key );
435 435
 
436
-            // Multi-select dropdown
437
-            if ( is_array( $value ) ) {
438
-                $o_key = array_search( $field->options[ $other_key ], $value );
436
+			// Multi-select dropdown
437
+			if ( is_array( $value ) ) {
438
+				$o_key = array_search( $field->options[ $other_key ], $value );
439 439
 
440 440
 				if ( $o_key !== false ) {
441 441
 					// Modify the original value so other key will be preserved
@@ -450,20 +450,20 @@  discard block
 block discarded – undo
450 450
 					$args['temp_value'] = $value;
451 451
 					$value[ $other_key ] = reset( $other_vals );
452 452
 				}
453
-            } else if ( $field->options[ $other_key ] == $value ) {
454
-                $value = $other_vals;
455
-            }
456
-        }
457
-    }
453
+			} else if ( $field->options[ $other_key ] == $value ) {
454
+				$value = $other_vals;
455
+			}
456
+		}
457
+	}
458 458
 
459 459
 	public static function enqueue_scripts( $params ) {
460 460
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormsController::enqueue_scripts' );
461 461
 		FrmFormsController::enqueue_scripts( $params );
462 462
 	}
463 463
 
464
-    // Add submitted values to a string for spam checking
464
+	// Add submitted values to a string for spam checking
465 465
 	public static function entry_array_to_string( $values ) {
466
-        $content = '';
466
+		$content = '';
467 467
 		foreach ( $values['item_meta'] as $val ) {
468 468
 			if ( $content != '' ) {
469 469
 				$content .= "\n\n";
@@ -471,14 +471,14 @@  discard block
 block discarded – undo
471 471
 
472 472
 			if ( is_array($val) ) {
473 473
 				$val = FrmAppHelper::array_flatten( $val );
474
-			    $val = implode(',', $val);
474
+				$val = implode(',', $val);
475 475
 			}
476 476
 
477 477
 			$content .= $val;
478 478
 		}
479 479
 
480 480
 		return $content;
481
-    }
481
+	}
482 482
 
483 483
 	public static function fill_entry_values( $atts, $f, array &$values ) {
484 484
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::fill_entry_values' );
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -8,12 +8,12 @@  discard block
 block discarded – undo
8 8
     public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9 9
         $values = array();
10 10
 		foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) {
11
-			$values[ $var ] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' );
11
+			$values[$var] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' );
12 12
         }
13 13
 
14 14
         $values['fields'] = array();
15
-        if ( empty($fields) ) {
16
-            return apply_filters('frm_setup_new_entry', $values);
15
+        if ( empty( $fields ) ) {
16
+            return apply_filters( 'frm_setup_new_entry', $values );
17 17
         }
18 18
 
19 19
         foreach ( (array) $fields as $field ) {
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
                 'default_value' => $field->default_value,
26 26
                 'name' => $field->name,
27 27
                 'description' => $field->description,
28
-                'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
28
+                'type' => apply_filters( 'frm_field_type', $field->type, $field, $new_value ),
29 29
                 'options' => $field->options,
30 30
                 'required' => $field->required,
31 31
                 'field_key' => $field->field_key,
@@ -36,43 +36,43 @@  discard block
 block discarded – undo
36 36
 				'in_embed_form' => isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0',
37 37
             );
38 38
 
39
-            $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
39
+            $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
40 40
             $opt_defaults['required_indicator'] = '';
41 41
 			$opt_defaults['original_type'] = $field->type;
42 42
 
43 43
 			foreach ( $opt_defaults as $opt => $default_opt ) {
44
-                $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
45
-                unset($opt, $default_opt);
44
+                $field_array[$opt] = ( isset( $field->field_options[$opt] ) && $field->field_options[$opt] != '' ) ? $field->field_options[$opt] : $default_opt;
45
+                unset( $opt, $default_opt );
46 46
             }
47 47
 
48
-            unset($opt_defaults);
48
+            unset( $opt_defaults );
49 49
 
50 50
             if ( $field_array['custom_html'] == '' ) {
51
-                $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
51
+                $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $field->type );
52 52
             }
53 53
 
54
-            $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args );
54
+            $field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field, $args );
55 55
             $field_array = array_merge( $field->field_options, $field_array );
56 56
 
57 57
             $values['fields'][] = $field_array;
58 58
 
59
-            if ( ! $form || ! isset($form->id) ) {
60
-                $form = FrmForm::getOne($field->form_id);
59
+            if ( ! $form || ! isset( $form->id ) ) {
60
+                $form = FrmForm::getOne( $field->form_id );
61 61
             }
62 62
         }
63 63
 
64
-        $form->options = maybe_unserialize($form->options);
65
-        if ( is_array($form->options) ) {
64
+        $form->options = maybe_unserialize( $form->options );
65
+        if ( is_array( $form->options ) ) {
66 66
             foreach ( $form->options as $opt => $value ) {
67
-                $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
68
-                unset($opt, $value);
67
+                $values[$opt] = FrmAppHelper::get_post_param( $opt, $value );
68
+                unset( $opt, $value );
69 69
             }
70 70
         }
71 71
 
72 72
 		$form_defaults = FrmFormsHelper::get_default_opts();
73 73
 
74 74
 		$frm_settings = FrmAppHelper::get_settings();
75
-		$form_defaults['custom_style']  = ( $frm_settings->load_style != 'none' );
75
+		$form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' );
76 76
 
77 77
 		$values = array_merge( $form_defaults, $values );
78 78
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		$return_array = FrmField::is_field_with_multiple_values( $field );
96 96
 
97 97
 		// Do any shortcodes in default value and allow customization of default value
98
-		$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array);
98
+		$field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true, $return_array );
99 99
 		// Calls FrmProFieldsHelper::get_default_value
100 100
 
101 101
 		$new_value = $field->default_value;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		}
109 109
 
110 110
 		if ( ! is_array( $new_value ) ) {
111
-			$new_value = str_replace('"', '&quot;', $new_value);
111
+			$new_value = str_replace( '"', '&quot;', $new_value );
112 112
 		}
113 113
 
114 114
 		return $new_value;
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 		if ( $_POST ) {
128 128
 			$repeating = isset( $args['repeating'] ) && $args['repeating'];
129 129
 			if ( $repeating ) {
130
-				if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) {
130
+				if ( isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] ) ) {
131 131
 					$value_is_posted = true;
132 132
 				}
133
-			} else if ( isset( $_POST['item_meta'][ $field->id ] ) ) {
133
+			} else if ( isset( $_POST['item_meta'][$field->id] ) ) {
134 134
 				$value_is_posted = true;
135 135
 			}
136 136
 		}
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
142 142
         $values['form_id'] = $record->form_id;
143 143
         $values['is_draft'] = $record->is_draft;
144
-        return apply_filters('frm_setup_edit_entry_vars', $values, $record);
144
+        return apply_filters( 'frm_setup_edit_entry_vars', $values, $record );
145 145
     }
146 146
 
147 147
     public static function get_admin_params( $form = null ) {
@@ -170,22 +170,22 @@  discard block
 block discarded – undo
170 170
     }
171 171
 
172 172
 	public static function replace_default_message( $message, $atts ) {
173
-        if ( strpos($message, '[default-message') === false &&
174
-            strpos($message, '[default_message') === false &&
173
+        if ( strpos( $message, '[default-message' ) === false &&
174
+            strpos( $message, '[default_message' ) === false &&
175 175
             ! empty( $message ) ) {
176 176
             return $message;
177 177
         }
178 178
 
179
-        if ( empty($message) ) {
179
+        if ( empty( $message ) ) {
180 180
             $message = '[default-message]';
181 181
         }
182 182
 
183
-        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
183
+        preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
184 184
 
185 185
         foreach ( $shortcodes[0] as $short_key => $tag ) {
186
-            $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
186
+            $add_atts = shortcode_parse_atts( $shortcodes[2][$short_key] );
187 187
             if ( $add_atts ) {
188
-                $this_atts = array_merge($atts, $add_atts);
188
+                $this_atts = array_merge( $atts, $add_atts );
189 189
             } else {
190 190
                 $this_atts = $atts;
191 191
             }
@@ -193,32 +193,32 @@  discard block
 block discarded – undo
193 193
 			$default = FrmEntryFormat::show_entry( $this_atts );
194 194
 
195 195
             // Add the default message
196
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
196
+            $message = str_replace( $shortcodes[0][$short_key], $default, $message );
197 197
         }
198 198
 
199 199
         return $message;
200 200
     }
201 201
 
202 202
 	public static function prepare_display_value( $entry, $field, $atts ) {
203
-		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
203
+		$field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false;
204 204
 
205 205
         if ( FrmAppHelper::pro_is_installed() ) {
206 206
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
207 207
         }
208 208
 
209
-        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
210
-            return self::display_value($field_value, $field, $atts);
209
+        if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) {
210
+            return self::display_value( $field_value, $field, $atts );
211 211
         }
212 212
 
213 213
         // this is an embeded form
214 214
         $val = '';
215 215
 
216
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
216
+	    if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) {
217 217
             //this is a repeating section
218 218
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
219 219
         } else {
220 220
             // get all values for this field
221
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
221
+	        $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false;
222 222
 
223 223
             if ( $child_values ) {
224 224
 	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 
228 228
 	    $field_value = array();
229 229
 
230
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
230
+        if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
231 231
             return $val;
232 232
         }
233 233
 
@@ -236,17 +236,17 @@  discard block
 block discarded – undo
236 236
             $atts['post_id'] = $child_entry->post_id;
237 237
 
238 238
             // get the value for this field -- check for post values as well
239
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
239
+            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field );
240 240
 
241 241
             if ( $entry_val ) {
242 242
                 // foreach entry get display_value
243
-                $field_value[] = self::display_value($entry_val, $field, $atts);
243
+                $field_value[] = self::display_value( $entry_val, $field, $atts );
244 244
             }
245 245
 
246
-            unset($child_entry);
246
+            unset( $child_entry );
247 247
         }
248 248
 
249
-        $val = implode(', ', (array) $field_value );
249
+        $val = implode( ', ', (array) $field_value );
250 250
 		$val = wp_kses_post( $val );
251 251
 
252 252
         return $val;
@@ -266,22 +266,22 @@  discard block
 block discarded – undo
266 266
         );
267 267
 
268 268
         $atts = wp_parse_args( $atts, $defaults );
269
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
269
+        $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value );
270 270
 
271
-        if ( ! isset($field->field_options['post_field']) ) {
271
+        if ( ! isset( $field->field_options['post_field'] ) ) {
272 272
             $field->field_options['post_field'] = '';
273 273
         }
274 274
 
275
-        if ( ! isset($field->field_options['custom_field']) ) {
275
+        if ( ! isset( $field->field_options['custom_field'] ) ) {
276 276
             $field->field_options['custom_field'] = '';
277 277
         }
278 278
 
279 279
         if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
280 280
             $atts['pre_truncate'] = $atts['truncate'];
281 281
             $atts['truncate'] = true;
282
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
282
+            $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0;
283 283
 
284
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
284
+            $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts );
285 285
             $atts['truncate'] = $atts['pre_truncate'];
286 286
         }
287 287
 
@@ -289,39 +289,39 @@  discard block
 block discarded – undo
289 289
             return $value;
290 290
         }
291 291
 
292
-        $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
292
+        $value = apply_filters( 'frm_display_value_custom', maybe_unserialize( $value ), $field, $atts );
293 293
 		$value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) );
294 294
 
295 295
         $new_value = '';
296 296
 
297
-        if ( is_array($value) && $atts['type'] != 'file' ) {
297
+        if ( is_array( $value ) && $atts['type'] != 'file' ) {
298 298
             foreach ( $value as $val ) {
299
-                if ( is_array($val) ) {
299
+                if ( is_array( $val ) ) {
300 300
 					//TODO: add options for display (li or ,)
301
-                    $new_value .= implode($atts['sep'], $val);
301
+                    $new_value .= implode( $atts['sep'], $val );
302 302
                     if ( $atts['type'] != 'data' ) {
303 303
                         $new_value .= '<br/>';
304 304
                     }
305 305
                 }
306
-                unset($val);
306
+                unset( $val );
307 307
             }
308 308
         }
309 309
 
310
-        if ( ! empty($new_value) ) {
310
+        if ( ! empty( $new_value ) ) {
311 311
             $value = $new_value;
312
-        } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
313
-            $value = implode($atts['sep'], $value);
312
+        } else if ( is_array( $value ) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
313
+            $value = implode( $atts['sep'], $value );
314 314
         }
315 315
 
316 316
         if ( $atts['truncate'] && $atts['type'] != 'image' ) {
317
-            $value = FrmAppHelper::truncate($value, 50);
317
+            $value = FrmAppHelper::truncate( $value, 50 );
318 318
         }
319 319
 
320 320
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
321 321
 			$value = wp_kses_post( $value );
322 322
 		}
323 323
 
324
-        return apply_filters('frm_display_value', $value, $field, $atts);
324
+        return apply_filters( 'frm_display_value', $value, $field, $atts );
325 325
     }
326 326
 
327 327
 	public static function set_posted_value( $field, $value, $args ) {
@@ -329,20 +329,20 @@  discard block
 block discarded – undo
329 329
         if ( isset( $args['other'] ) && $args['other'] ) {
330 330
             $value = $args['temp_value'];
331 331
         }
332
-        if ( empty($args['parent_field_id']) ) {
333
-            $_POST['item_meta'][ $field->id ] = $value;
332
+        if ( empty( $args['parent_field_id'] ) ) {
333
+            $_POST['item_meta'][$field->id] = $value;
334 334
         } else {
335
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
335
+            $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value;
336 336
         }
337 337
     }
338 338
 
339 339
 	public static function get_posted_value( $field, &$value, $args ) {
340 340
 		$field_id = is_object( $field ) ? $field->id : $field;
341 341
 
342
-        if ( empty($args['parent_field_id']) ) {
343
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? wp_kses_post( $_POST['item_meta'][ $field_id ] ) : '';
342
+        if ( empty( $args['parent_field_id'] ) ) {
343
+            $value = isset( $_POST['item_meta'][$field_id] ) ? wp_kses_post( $_POST['item_meta'][$field_id] ) : '';
344 344
         } else {
345
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? wp_kses_post( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) : '';
345
+            $value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? wp_kses_post( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) : '';
346 346
         }
347 347
 		$value = stripslashes_deep( $value );
348 348
     }
@@ -366,12 +366,12 @@  discard block
 block discarded – undo
366 366
         self::set_other_repeating_vals( $field, $value, $args );
367 367
 
368 368
         // Check if there are any posted "Other" values
369
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
369
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) {
370 370
 
371 371
             // Save original value
372 372
             $args['temp_value'] = $value;
373 373
             $args['other'] = true;
374
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
374
+            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][$field->id] );
375 375
 
376 376
             // Set the validation value now
377 377
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -393,12 +393,12 @@  discard block
 block discarded – undo
393 393
         }
394 394
 
395 395
         // Check if there are any other posted "other" values for this field
396
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
396
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) {
397 397
             // Save original value
398 398
             $args['temp_value'] = $value;
399 399
             $args['other'] = true;
400 400
 
401
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
401
+            $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id];
402 402
 
403 403
             // Set the validation value now
404 404
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -430,27 +430,27 @@  discard block
 block discarded – undo
430 430
             }
431 431
         } else {
432 432
 			// Radio and dropdowns
433
-            $other_key = array_filter( array_keys($field->options), 'is_string');
433
+            $other_key = array_filter( array_keys( $field->options ), 'is_string' );
434 434
             $other_key = reset( $other_key );
435 435
 
436 436
             // Multi-select dropdown
437 437
             if ( is_array( $value ) ) {
438
-                $o_key = array_search( $field->options[ $other_key ], $value );
438
+                $o_key = array_search( $field->options[$other_key], $value );
439 439
 
440 440
 				if ( $o_key !== false ) {
441 441
 					// Modify the original value so other key will be preserved
442
-					$value[ $other_key ] = $value[ $o_key ];
442
+					$value[$other_key] = $value[$o_key];
443 443
 
444 444
 					// By default, the array keys will be numeric for multi-select dropdowns
445 445
 					// If going backwards and forwards between pages, the array key will match the other key
446 446
 					if ( $o_key != $other_key ) {
447
-						unset( $value[ $o_key ] );
447
+						unset( $value[$o_key] );
448 448
 					}
449 449
 
450 450
 					$args['temp_value'] = $value;
451
-					$value[ $other_key ] = reset( $other_vals );
451
+					$value[$other_key] = reset( $other_vals );
452 452
 				}
453
-            } else if ( $field->options[ $other_key ] == $value ) {
453
+            } else if ( $field->options[$other_key] == $value ) {
454 454
                 $value = $other_vals;
455 455
             }
456 456
         }
@@ -469,9 +469,9 @@  discard block
 block discarded – undo
469 469
 				$content .= "\n\n";
470 470
 			}
471 471
 
472
-			if ( is_array($val) ) {
472
+			if ( is_array( $val ) ) {
473 473
 				$val = FrmAppHelper::array_flatten( $val );
474
-			    $val = implode(',', $val);
474
+			    $val = implode( ',', $val );
475 475
 			}
476 476
 
477 477
 			$content .= $val;
@@ -516,6 +516,6 @@  discard block
 block discarded – undo
516 516
 	}
517 517
 
518 518
 	public static function entries_dropdown() {
519
-		_deprecated_function( __FUNCTION__, '1.07.09');
519
+		_deprecated_function( __FUNCTION__, '1.07.09' );
520 520
 	}
521 521
 }
Please login to merge, or discard this patch.