Completed
Push — master ( fd7552...ca3d95 )
by Stephanie
02:56
created
classes/helpers/FrmEntriesHelper.php 2 patches
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -5,19 +5,19 @@  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() ) {
8
+	public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9 9
 		$values = array(
10 10
 			'name'        => '',
11 11
 			'description' => '',
12 12
 			'item_key'    => '',
13 13
 		);
14 14
 
15
-        $values['fields'] = array();
15
+		$values['fields'] = array();
16 16
 		if ( empty( $fields ) ) {
17 17
 			return apply_filters( 'frm_setup_new_entry', $values );
18 18
 		}
19 19
 
20
-        foreach ( (array) $fields as $field ) {
20
+		foreach ( (array) $fields as $field ) {
21 21
 			$original_default = $field->default_value;
22 22
 			self::prepare_field_default_value( $field );
23 23
 			$new_value = self::get_field_value_for_new_entry( $field, $reset, $args );
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
 
33 33
 			FrmFieldsHelper::prepare_new_front_field( $field_array, $field, $args );
34 34
 
35
-            $field_array = array_merge( $field->field_options, $field_array );
35
+			$field_array = array_merge( $field->field_options, $field_array );
36 36
 
37
-            $values['fields'][] = $field_array;
37
+			$values['fields'][] = $field_array;
38 38
 
39 39
 			if ( ! $form || ! isset( $form->id ) ) {
40 40
 				$form = FrmForm::getOne( $field->form_id );
41 41
 			}
42
-        }
42
+		}
43 43
 
44 44
 		$form->options = maybe_unserialize( $form->options );
45 45
 		if ( is_array( $form->options ) ) {
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		$values = array_merge( $form_defaults, $values );
55 55
 
56 56
 		return apply_filters( 'frm_setup_new_entry', $values );
57
-    }
57
+	}
58 58
 
59 59
 	/**
60 60
 	 * @since 2.05
@@ -71,16 +71,16 @@  discard block
 block discarded – undo
71 71
 	}
72 72
 
73 73
 	/**
74
-	* Set the value for each field
75
-	* This function is used when the form is first loaded and on all page turns *for a new entry*
76
-	*
77
-	* @since 2.0.13
78
-	*
79
-	* @param object $field - this is passed by reference since it is an object
80
-	* @param boolean $reset
81
-	* @param array $args
82
-	* @return string|array $new_value
83
-	*/
74
+	 * Set the value for each field
75
+	 * This function is used when the form is first loaded and on all page turns *for a new entry*
76
+	 *
77
+	 * @since 2.0.13
78
+	 *
79
+	 * @param object $field - this is passed by reference since it is an object
80
+	 * @param boolean $reset
81
+	 * @param array $args
82
+	 * @return string|array $new_value
83
+	 */
84 84
 	private static function get_field_value_for_new_entry( $field, $reset, $args ) {
85 85
 		$new_value = $field->default_value;
86 86
 
@@ -105,13 +105,13 @@  discard block
 block discarded – undo
105 105
 	}
106 106
 
107 107
 	/**
108
-	* Check if a field has a posted value
109
-	*
110
-	* @since 2.01.0
111
-	* @param object $field
112
-	* @param array $args
113
-	* @return boolean $value_is_posted
114
-	*/
108
+	 * Check if a field has a posted value
109
+	 *
110
+	 * @since 2.01.0
111
+	 * @param object $field
112
+	 * @param array $args
113
+	 * @return boolean $value_is_posted
114
+	 */
115 115
 	public static function value_is_posted( $field, $args ) {
116 116
 		$value_is_posted = false;
117 117
 		if ( $_POST ) {
@@ -129,93 +129,93 @@  discard block
 block discarded – undo
129 129
 
130 130
 	public static function setup_edit_vars( $values, $record ) {
131 131
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
132
-        $values['form_id'] = $record->form_id;
133
-        $values['is_draft'] = $record->is_draft;
132
+		$values['form_id'] = $record->form_id;
133
+		$values['is_draft'] = $record->is_draft;
134 134
 		return apply_filters( 'frm_setup_edit_entry_vars', $values, $record );
135
-    }
135
+	}
136 136
 
137 137
 	public static function replace_default_message( $message, $atts ) {
138 138
 		if ( strpos( $message, '[default-message' ) === false &&
139 139
 			strpos( $message, '[default_message' ) === false &&
140
-            ! empty( $message ) ) {
141
-            return $message;
142
-        }
140
+			! empty( $message ) ) {
141
+			return $message;
142
+		}
143 143
 
144 144
 		if ( empty( $message ) ) {
145
-            $message = '[default-message]';
146
-        }
145
+			$message = '[default-message]';
146
+		}
147 147
 
148 148
 		preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
149 149
 
150
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
150
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
151 151
 			$add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
152 152
 			if ( ! empty( $add_atts ) ) {
153 153
 				$this_atts = array_merge( $atts, $add_atts );
154
-            } else {
155
-                $this_atts = $atts;
156
-            }
154
+			} else {
155
+				$this_atts = $atts;
156
+			}
157 157
 
158 158
 			$default = FrmEntriesController::show_entry_shortcode( $this_atts );
159 159
 
160
-            // Add the default message
161
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
162
-        }
160
+			// Add the default message
161
+			$message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
162
+		}
163 163
 
164
-        return $message;
165
-    }
164
+		return $message;
165
+	}
166 166
 
167 167
 	public static function prepare_display_value( $entry, $field, $atts ) {
168 168
 		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
169 169
 
170
-        if ( FrmAppHelper::pro_is_installed() ) {
170
+		if ( FrmAppHelper::pro_is_installed() ) {
171 171
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
172
-        }
172
+		}
173 173
 
174 174
 		if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) {
175 175
 			return self::display_value( $field_value, $field, $atts );
176 176
 		}
177 177
 
178
-        // this is an embeded form
179
-        $val = '';
178
+		// this is an embeded form
179
+		$val = '';
180 180
 
181 181
 		if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) {
182
-            //this is a repeating section
182
+			//this is a repeating section
183 183
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
184
-        } else {
185
-            // get all values for this field
186
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
184
+		} else {
185
+			// get all values for this field
186
+			$child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
187 187
 
188
-            if ( $child_values ) {
189
-	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
190
-	        }
191
-	    }
188
+			if ( $child_values ) {
189
+				$child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
190
+			}
191
+		}
192 192
 
193
-	    $field_value = array();
193
+		$field_value = array();
194 194
 
195 195
 		if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
196
-            return $val;
197
-        }
196
+			return $val;
197
+		}
198 198
 
199
-        foreach ( $child_entries as $child_entry ) {
200
-            $atts['item_id'] = $child_entry->id;
201
-            $atts['post_id'] = $child_entry->post_id;
199
+		foreach ( $child_entries as $child_entry ) {
200
+			$atts['item_id'] = $child_entry->id;
201
+			$atts['post_id'] = $child_entry->post_id;
202 202
 
203
-            // get the value for this field -- check for post values as well
203
+			// get the value for this field -- check for post values as well
204 204
 			$entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field );
205 205
 
206
-            if ( $entry_val ) {
207
-                // foreach entry get display_value
206
+			if ( $entry_val ) {
207
+				// foreach entry get display_value
208 208
 				$field_value[] = self::display_value( $entry_val, $field, $atts );
209
-            }
209
+			}
210 210
 
211 211
 			unset( $child_entry );
212
-        }
212
+		}
213 213
 
214 214
 		$val = implode( ', ', (array) $field_value );
215 215
 		return FrmAppHelper::kses( $val, 'all' );
216
-    }
216
+	}
217 217
 
218
-    /**
218
+	/**
219 219
 	 * Prepare the saved value for display
220 220
 	 *
221 221
 	 * @param array|string $value
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 			'return_array' => false,
240 240
 		);
241 241
 
242
-        $atts = wp_parse_args( $atts, $defaults );
242
+		$atts = wp_parse_args( $atts, $defaults );
243 243
 
244 244
 		if ( FrmField::is_image( $field ) || $field->type == 'star' ) {
245 245
 			$atts['truncate'] = false;
@@ -249,25 +249,25 @@  discard block
 block discarded – undo
249 249
 		$atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value );
250 250
 
251 251
 		if ( ! isset( $field->field_options['post_field'] ) ) {
252
-            $field->field_options['post_field'] = '';
253
-        }
252
+			$field->field_options['post_field'] = '';
253
+		}
254 254
 
255 255
 		if ( ! isset( $field->field_options['custom_field'] ) ) {
256
-            $field->field_options['custom_field'] = '';
257
-        }
256
+			$field->field_options['custom_field'] = '';
257
+		}
258 258
 
259
-        if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
260
-            $atts['pre_truncate'] = $atts['truncate'];
261
-            $atts['truncate'] = true;
259
+		if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
260
+			$atts['pre_truncate'] = $atts['truncate'];
261
+			$atts['truncate'] = true;
262 262
 			$atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0;
263 263
 
264 264
 			$value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts );
265
-            $atts['truncate'] = $atts['pre_truncate'];
266
-        }
265
+			$atts['truncate'] = $atts['pre_truncate'];
266
+		}
267 267
 
268
-        if ( $value == '' ) {
269
-            return $value;
270
-        }
268
+		if ( $value == '' ) {
269
+			return $value;
270
+		}
271 271
 
272 272
 		$unfiltered_value = maybe_unserialize( $value );
273 273
 		$value = apply_filters( 'frm_display_value_custom', $unfiltered_value, $field, $atts );
@@ -277,130 +277,130 @@  discard block
 block discarded – undo
277 277
 			$value = FrmFieldsHelper::get_unfiltered_display_value( compact( 'value', 'field', 'atts' ) );
278 278
 		}
279 279
 
280
-        if ( $atts['truncate'] && $atts['type'] != 'url' ) {
280
+		if ( $atts['truncate'] && $atts['type'] != 'url' ) {
281 281
 			$value = FrmAppHelper::truncate( $value, 50 );
282
-        }
282
+		}
283 283
 
284 284
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
285 285
 			$value = FrmAppHelper::kses( $value, 'all' );
286 286
 		}
287 287
 
288 288
 		return apply_filters( 'frm_display_value', $value, $field, $atts );
289
-    }
289
+	}
290 290
 
291 291
 	public static function set_posted_value( $field, $value, $args ) {
292
-        // If validating a field with "other" opt, set back to prev value now
293
-        if ( isset( $args['other'] ) && $args['other'] ) {
294
-            $value = $args['temp_value'];
295
-        }
292
+		// If validating a field with "other" opt, set back to prev value now
293
+		if ( isset( $args['other'] ) && $args['other'] ) {
294
+			$value = $args['temp_value'];
295
+		}
296 296
 		if ( empty( $args['parent_field_id'] ) ) {
297
-            $_POST['item_meta'][ $field->id ] = $value;
298
-        } else {
299
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
300
-        }
301
-    }
297
+			$_POST['item_meta'][ $field->id ] = $value;
298
+		} else {
299
+			$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
300
+		}
301
+	}
302 302
 
303 303
 	public static function get_posted_value( $field, &$value, $args ) {
304 304
 		$field_id = is_object( $field ) ? $field->id : $field;
305 305
 
306 306
 		if ( empty( $args['parent_field_id'] ) ) {
307
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
308
-        } else {
309
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
310
-        }
307
+			$value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
308
+		} else {
309
+			$value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
310
+		}
311 311
 		FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
312 312
 		$value = stripslashes_deep( $value );
313
-    }
314
-
315
-    /**
316
-    * Check if field has an "Other" option and if any other values are posted
317
-    *
318
-    * @since 2.0
319
-    *
320
-    * @param object $field
321
-    * @param string|array $value
322
-    * @param array $args
323
-    */
324
-    public static function maybe_set_other_validation( $field, &$value, &$args ) {
325
-        $args['other'] = false;
326
-        if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
327
-            return;
328
-        }
329
-
330
-        // Get other value for fields in repeating section
331
-        self::set_other_repeating_vals( $field, $value, $args );
332
-
333
-        // Check if there are any posted "Other" values
313
+	}
314
+
315
+	/**
316
+	 * Check if field has an "Other" option and if any other values are posted
317
+	 *
318
+	 * @since 2.0
319
+	 *
320
+	 * @param object $field
321
+	 * @param string|array $value
322
+	 * @param array $args
323
+	 */
324
+	public static function maybe_set_other_validation( $field, &$value, &$args ) {
325
+		$args['other'] = false;
326
+		if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
327
+			return;
328
+		}
329
+
330
+		// Get other value for fields in repeating section
331
+		self::set_other_repeating_vals( $field, $value, $args );
332
+
333
+		// Check if there are any posted "Other" values
334 334
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
335 335
 
336
-            // Save original value
337
-            $args['temp_value'] = $value;
338
-            $args['other'] = true;
339
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
340
-
341
-            // Set the validation value now
342
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
343
-        }
344
-    }
345
-
346
-    /**
347
-    * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
348
-    *
349
-    * @since 2.0
350
-    *
351
-    * @param object $field
352
-    * @param string|array $value
353
-    * @param array $args
354
-    */
355
-    public static function set_other_repeating_vals( $field, &$value, &$args ) {
356
-        if ( ! $args['parent_field_id'] ) {
357
-            return;
358
-        }
359
-
360
-        // Check if there are any other posted "other" values for this field
336
+			// Save original value
337
+			$args['temp_value'] = $value;
338
+			$args['other'] = true;
339
+			$other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
340
+
341
+			// Set the validation value now
342
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
343
+		}
344
+	}
345
+
346
+	/**
347
+	 * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
348
+	 *
349
+	 * @since 2.0
350
+	 *
351
+	 * @param object $field
352
+	 * @param string|array $value
353
+	 * @param array $args
354
+	 */
355
+	public static function set_other_repeating_vals( $field, &$value, &$args ) {
356
+		if ( ! $args['parent_field_id'] ) {
357
+			return;
358
+		}
359
+
360
+		// Check if there are any other posted "other" values for this field
361 361
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
362
-            // Save original value
363
-            $args['temp_value'] = $value;
364
-            $args['other'] = true;
365
-
366
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
367
-
368
-            // Set the validation value now
369
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
370
-        }
371
-    }
372
-
373
-    /**
374
-    * Modify value used for validation
375
-    * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
376
-    * It also adds any text from the free text fields to the value
377
-    *
378
-    * Needs to accommodate for times when other opt is selected, but no other free text is entered
379
-    *
380
-    * @since 2.0
381
-    *
382
-    * @param string|array $value
383
-    * @param string|array $other_vals (usually of posted values)
384
-    * @param object $field
385
-    * @param array $args
386
-    */
387
-    public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
388
-        // Checkboxes and multi-select dropdowns
389
-        if ( is_array( $value ) && $field->type == 'checkbox' ) {
390
-            // Combine "Other" values with checked values. "Other" values will override checked box values.
391
-            $value = array_merge( $value, $other_vals );
392
-            $value = array_filter( $value );
393
-            if ( count( $value ) == 0 ) {
394
-                $value = '';
395
-            }
396
-        } else {
362
+			// Save original value
363
+			$args['temp_value'] = $value;
364
+			$args['other'] = true;
365
+
366
+			$other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
367
+
368
+			// Set the validation value now
369
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
370
+		}
371
+	}
372
+
373
+	/**
374
+	 * Modify value used for validation
375
+	 * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
376
+	 * It also adds any text from the free text fields to the value
377
+	 *
378
+	 * Needs to accommodate for times when other opt is selected, but no other free text is entered
379
+	 *
380
+	 * @since 2.0
381
+	 *
382
+	 * @param string|array $value
383
+	 * @param string|array $other_vals (usually of posted values)
384
+	 * @param object $field
385
+	 * @param array $args
386
+	 */
387
+	public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
388
+		// Checkboxes and multi-select dropdowns
389
+		if ( is_array( $value ) && $field->type == 'checkbox' ) {
390
+			// Combine "Other" values with checked values. "Other" values will override checked box values.
391
+			$value = array_merge( $value, $other_vals );
392
+			$value = array_filter( $value );
393
+			if ( count( $value ) == 0 ) {
394
+				$value = '';
395
+			}
396
+		} else {
397 397
 			// Radio and dropdowns
398 398
 			$other_key = array_filter( array_keys( $field->options ), 'is_string' );
399
-            $other_key = reset( $other_key );
399
+			$other_key = reset( $other_key );
400 400
 
401
-            // Multi-select dropdown
402
-            if ( is_array( $value ) ) {
403
-                $o_key = array_search( $field->options[ $other_key ], $value );
401
+			// Multi-select dropdown
402
+			if ( is_array( $value ) ) {
403
+				$o_key = array_search( $field->options[ $other_key ], $value );
404 404
 
405 405
 				if ( $o_key !== false ) {
406 406
 					// Modify the original value so other key will be preserved
@@ -418,15 +418,15 @@  discard block
 block discarded – undo
418 418
 						unset( $value[ $other_key ] );
419 419
 					}
420 420
 				}
421
-            } else if ( $field->options[ $other_key ] == $value ) {
422
-                $value = $other_vals;
423
-            }
424
-        }
425
-    }
421
+			} else if ( $field->options[ $other_key ] == $value ) {
422
+				$value = $other_vals;
423
+			}
424
+		}
425
+	}
426 426
 
427
-    // Add submitted values to a string for spam checking
427
+	// Add submitted values to a string for spam checking
428 428
 	public static function entry_array_to_string( $values ) {
429
-        $content = '';
429
+		$content = '';
430 430
 		foreach ( $values['item_meta'] as $val ) {
431 431
 			if ( $content != '' ) {
432 432
 				$content .= "\n\n";
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 		}
442 442
 
443 443
 		return $content;
444
-    }
444
+	}
445 445
 
446 446
 	/**
447 447
 	 * Get the browser from the user agent
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 		$form_defaults = FrmFormsHelper::get_default_opts();
50 50
 
51 51
 		$frm_settings = FrmAppHelper::get_settings();
52
-		$form_defaults['custom_style']  = ( $frm_settings->load_style != 'none' );
52
+		$form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' );
53 53
 
54 54
 		$values = array_merge( $form_defaults, $values );
55 55
 
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
 		if ( $_POST ) {
118 118
 			$repeating = isset( $args['repeating'] ) && $args['repeating'];
119 119
 			if ( $repeating ) {
120
-				if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) {
120
+				if ( isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] ) ) {
121 121
 					$value_is_posted = true;
122 122
 				}
123
-			} else if ( isset( $_POST['item_meta'][ $field->id ] ) ) {
123
+			} else if ( isset( $_POST['item_meta'][$field->id] ) ) {
124 124
 				$value_is_posted = true;
125 125
 			}
126 126
 		}
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
149 149
 
150 150
         foreach ( $shortcodes[0] as $short_key => $tag ) {
151
-			$add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
151
+			$add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] );
152 152
 			if ( ! empty( $add_atts ) ) {
153 153
 				$this_atts = array_merge( $atts, $add_atts );
154 154
             } else {
@@ -158,14 +158,14 @@  discard block
 block discarded – undo
158 158
 			$default = FrmEntriesController::show_entry_shortcode( $this_atts );
159 159
 
160 160
             // Add the default message
161
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
161
+            $message = str_replace( $shortcodes[0][$short_key], $default, $message );
162 162
         }
163 163
 
164 164
         return $message;
165 165
     }
166 166
 
167 167
 	public static function prepare_display_value( $entry, $field, $atts ) {
168
-		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
168
+		$field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false;
169 169
 
170 170
         if ( FrmAppHelper::pro_is_installed() ) {
171 171
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
184 184
         } else {
185 185
             // get all values for this field
186
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
186
+	        $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false;
187 187
 
188 188
             if ( $child_values ) {
189 189
 	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
             $value = $args['temp_value'];
295 295
         }
296 296
 		if ( empty( $args['parent_field_id'] ) ) {
297
-            $_POST['item_meta'][ $field->id ] = $value;
297
+            $_POST['item_meta'][$field->id] = $value;
298 298
         } else {
299
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
299
+            $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value;
300 300
         }
301 301
     }
302 302
 
@@ -304,9 +304,9 @@  discard block
 block discarded – undo
304 304
 		$field_id = is_object( $field ) ? $field->id : $field;
305 305
 
306 306
 		if ( empty( $args['parent_field_id'] ) ) {
307
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
307
+            $value = isset( $_POST['item_meta'][$field_id] ) ? $_POST['item_meta'][$field_id] : '';
308 308
         } else {
309
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
309
+            $value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] : '';
310 310
         }
311 311
 		FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
312 312
 		$value = stripslashes_deep( $value );
@@ -331,12 +331,12 @@  discard block
 block discarded – undo
331 331
         self::set_other_repeating_vals( $field, $value, $args );
332 332
 
333 333
         // Check if there are any posted "Other" values
334
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
334
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) {
335 335
 
336 336
             // Save original value
337 337
             $args['temp_value'] = $value;
338 338
             $args['other'] = true;
339
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
339
+            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][$field->id] );
340 340
 
341 341
             // Set the validation value now
342 342
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -358,12 +358,12 @@  discard block
 block discarded – undo
358 358
         }
359 359
 
360 360
         // Check if there are any other posted "other" values for this field
361
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
361
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) {
362 362
             // Save original value
363 363
             $args['temp_value'] = $value;
364 364
             $args['other'] = true;
365 365
 
366
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
366
+            $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id];
367 367
 
368 368
             // Set the validation value now
369 369
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -400,25 +400,25 @@  discard block
 block discarded – undo
400 400
 
401 401
             // Multi-select dropdown
402 402
             if ( is_array( $value ) ) {
403
-                $o_key = array_search( $field->options[ $other_key ], $value );
403
+                $o_key = array_search( $field->options[$other_key], $value );
404 404
 
405 405
 				if ( $o_key !== false ) {
406 406
 					// Modify the original value so other key will be preserved
407
-					$value[ $other_key ] = $value[ $o_key ];
407
+					$value[$other_key] = $value[$o_key];
408 408
 
409 409
 					// By default, the array keys will be numeric for multi-select dropdowns
410 410
 					// If going backwards and forwards between pages, the array key will match the other key
411 411
 					if ( $o_key !== $other_key ) {
412
-						unset( $value[ $o_key ] );
412
+						unset( $value[$o_key] );
413 413
 					}
414 414
 
415 415
 					$args['temp_value'] = $value;
416
-					$value[ $other_key ] = reset( $other_vals );
417
-					if ( FrmAppHelper::is_empty_value( $value[ $other_key ] ) ) {
418
-						unset( $value[ $other_key ] );
416
+					$value[$other_key] = reset( $other_vals );
417
+					if ( FrmAppHelper::is_empty_value( $value[$other_key] ) ) {
418
+						unset( $value[$other_key] );
419 419
 					}
420 420
 				}
421
-            } else if ( $field->options[ $other_key ] == $value ) {
421
+            } else if ( $field->options[$other_key] == $value ) {
422 422
                 $value = $other_vals;
423 423
             }
424 424
         }
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesListHelper.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@
 block discarded – undo
141 141
 
142 142
 		$r = "<tr id='item-action-{$item->id}'$style>";
143 143
 
144
-		list( $columns, $hidden, , $primary ) = $this->get_column_info();
144
+		list( $columns, $hidden,, $primary ) = $this->get_column_info();
145 145
         $action_col = false;
146 146
 
147 147
 		foreach ( $columns as $column_name => $column_display_name ) {
Please login to merge, or discard this patch.
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -6,10 +6,10 @@  discard block
 block discarded – undo
6 6
 	protected $field;
7 7
 
8 8
 	public function prepare_items() {
9
-        global $per_page;
9
+		global $per_page;
10 10
 
11 11
 		$per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' );
12
-        $form_id = $this->params['form'];
12
+		$form_id = $this->params['form'];
13 13
 
14 14
 		$s_query = array();
15 15
 
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
 		);
89 89
 		if ( ! empty( $s ) ) {
90 90
 			esc_html_e( 'No Entries Found', 'formidable' );
91
-            return;
92
-        }
91
+			return;
92
+		}
93 93
 
94 94
 		$form_id = $this->params['form'];
95 95
 		$form = $this->params['form'];
96 96
 
97
-        if ( $form_id ) {
97
+		if ( $form_id ) {
98 98
 			$form = FrmForm::getOne( $form_id );
99
-        }
100
-        $colspan = $this->get_column_count();
99
+		}
100
+		$colspan = $this->get_column_count();
101 101
 
102 102
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' );
103 103
 	}
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
 	}
118 118
 
119 119
 	/**
120
-	* Gets the name of the primary column in the Entries screen
121
-	*
122
-	* @since 2.0.14
123
-	*
124
-	* @return string $primary_column
125
-	*/
120
+	 * Gets the name of the primary column in the Entries screen
121
+	 *
122
+	 * @since 2.0.14
123
+	 *
124
+	 * @return string $primary_column
125
+	 */
126 126
 	protected function get_primary_column_name() {
127 127
 		$columns = get_column_headers( $this->screen );
128 128
 		$hidden = get_hidden_columns( $this->screen );
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
 		$this->get_actions( $actions, $item, $view_link );
148 148
 
149
-        $action_links = $this->row_actions( $actions );
149
+		$action_links = $this->row_actions( $actions );
150 150
 
151 151
 		// Set up the checkbox ( because the user is editable, otherwise its empty )
152 152
 		$checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />";
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 		$r = "<tr id='item-action-{$item->id}'$style>";
155 155
 
156 156
 		list( $columns, $hidden, , $primary ) = $this->get_column_info();
157
-        $action_col = false;
157
+		$action_col = false;
158 158
 
159 159
 		foreach ( $columns as $column_name => $column_display_name ) {
160 160
 			$class = $column_name . ' column-' . $column_name;
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 			if ( in_array( $column_name, $hidden ) ) {
167 167
 				$class .= ' frm_hidden';
168 168
 			} else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) {
169
-			    $action_col = $column_name;
170
-            }
169
+				$action_col = $column_name;
170
+			}
171 171
 
172 172
 			$attributes = 'class="' . esc_attr( $class ) . '"';
173 173
 			unset( $class );
@@ -185,15 +185,15 @@  discard block
 block discarded – undo
185 185
 					$val = $this->column_value( $item );
186 186
 				}
187 187
 
188
-			    $r .= "<td $attributes>";
188
+				$r .= "<td $attributes>";
189 189
 				if ( $column_name == $action_col ) {
190 190
 					$edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id;
191 191
 					$r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
192
-			        $r .= $action_links;
192
+					$r .= $action_links;
193 193
 				} else {
194
-			        $r .= $val;
195
-			    }
196
-			    $r .= '</td>';
194
+					$r .= $val;
195
+				}
196
+				$r .= '</td>';
197 197
 			}
198 198
 			unset( $val );
199 199
 		}
@@ -246,19 +246,19 @@  discard block
 block discarded – undo
246 246
 		return $val;
247 247
 	}
248 248
 
249
-    /**
250
-     * @param string $view_link
251
-     */
252
-    private function get_actions( &$actions, $item, $view_link ) {
249
+	/**
250
+	 * @param string $view_link
251
+	 */
252
+	private function get_actions( &$actions, $item, $view_link ) {
253 253
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
254 254
 
255 255
 		if ( current_user_can( 'frm_delete_entries' ) ) {
256 256
 			$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
257 257
 			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" data-frmverify="' . esc_attr__( 'Are you sure?', 'formidable' ) . '">' . __( 'Delete' ) . '</a>';
258
-	    }
258
+		}
259 259
 
260 260
 		$actions = apply_filters( 'frm_row_actions', $actions, $item );
261
-    }
261
+	}
262 262
 
263 263
 	private function get_column_value( $item, &$val ) {
264 264
 		$col_name = $this->column_name;
Please login to merge, or discard this patch.
classes/models/FrmSettings.php 3 patches
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -1,38 +1,38 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmSettings {
4
-    public $option_name = 'frm_options';
5
-    public $menu;
6
-    public $mu_menu;
7
-    public $use_html;
8
-    public $jquery_css;
9
-    public $accordion_js;
4
+	public $option_name = 'frm_options';
5
+	public $menu;
6
+	public $mu_menu;
7
+	public $use_html;
8
+	public $jquery_css;
9
+	public $accordion_js;
10 10
 	public $fade_form;
11 11
 	public $old_css;
12 12
 
13
-    public $success_msg;
14
-    public $blank_msg;
15
-    public $unique_msg;
16
-    public $invalid_msg;
17
-    public $failed_msg;
18
-    public $submit_value;
19
-    public $login_msg;
20
-    public $admin_permission;
21
-
22
-    public $email_to;
23
-    public $load_style;
24
-    public $custom_style;
25
-
26
-    public $pubkey;
27
-    public $privkey;
28
-    public $re_lang;
13
+	public $success_msg;
14
+	public $blank_msg;
15
+	public $unique_msg;
16
+	public $invalid_msg;
17
+	public $failed_msg;
18
+	public $submit_value;
19
+	public $login_msg;
20
+	public $admin_permission;
21
+
22
+	public $email_to;
23
+	public $load_style;
24
+	public $custom_style;
25
+
26
+	public $pubkey;
27
+	public $privkey;
28
+	public $re_lang;
29 29
 	public $re_type;
30
-    public $re_msg;
30
+	public $re_msg;
31 31
 	public $re_multi;
32 32
 
33 33
 	public $no_ips;
34 34
 
35
-    public function __construct() {
35
+	public function __construct() {
36 36
 		if ( ! defined( 'ABSPATH' ) ) {
37 37
 			die( 'You are not allowed to call this page directly.' );
38 38
 		}
@@ -43,18 +43,18 @@  discard block
 block discarded – undo
43 43
 			$settings = $this->translate_settings( $settings );
44 44
 		}
45 45
 
46
-        foreach ( $settings as $setting_name => $setting ) {
47
-            $this->{$setting_name} = $setting;
46
+		foreach ( $settings as $setting_name => $setting ) {
47
+			$this->{$setting_name} = $setting;
48 48
 			unset( $setting_name, $setting );
49
-        }
49
+		}
50 50
 
51
-        $this->set_default_options();
52
-    }
51
+		$this->set_default_options();
52
+	}
53 53
 
54 54
 	private function translate_settings( $settings ) {
55
-        if ( $settings ) { //workaround for W3 total cache conflict
55
+		if ( $settings ) { //workaround for W3 total cache conflict
56 56
 			return unserialize( serialize( $settings ) );
57
-        }
57
+		}
58 58
 
59 59
 		$settings = get_option( $this->option_name );
60 60
 		if ( is_object( $settings ) ) {
@@ -62,97 +62,97 @@  discard block
 block discarded – undo
62 62
 			return $settings;
63 63
 		}
64 64
 
65
-        // If unserializing didn't work
66
-        if ( $settings ) { //workaround for W3 total cache conflict
65
+		// If unserializing didn't work
66
+		if ( $settings ) { //workaround for W3 total cache conflict
67 67
 			$settings = unserialize( serialize( $settings ) );
68
-        } else {
69
-            $settings = $this;
70
-        }
68
+		} else {
69
+			$settings = $this;
70
+		}
71 71
 
72 72
 		update_option( $this->option_name, $settings );
73 73
 		set_transient( $this->option_name, $settings );
74 74
 
75
-        return $settings;
76
-    }
75
+		return $settings;
76
+	}
77 77
 
78
-    /**
79
-     * @return array
80
-     */
78
+	/**
79
+	 * @return array
80
+	 */
81 81
 	public function default_options() {
82
-        return array(
83
-            'menu'      => apply_filters( 'frm_default_menu', 'Formidable' ),
84
-            'mu_menu'   => 0,
85
-            'use_html'  => true,
86
-            'jquery_css' => false,
87
-            'accordion_js' => false,
82
+		return array(
83
+			'menu'      => apply_filters( 'frm_default_menu', 'Formidable' ),
84
+			'mu_menu'   => 0,
85
+			'use_html'  => true,
86
+			'jquery_css' => false,
87
+			'accordion_js' => false,
88 88
 			'fade_form' => false,
89 89
 			'old_css'   => true,
90 90
 
91 91
 			're_multi'  => 0,
92 92
 
93
-            'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ),
94
-            'blank_msg' => __( 'This field cannot be blank.', 'formidable' ),
95
-            'unique_msg' => __( 'This value must be unique.', 'formidable' ),
96
-            'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ),
97
-            'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ),
98
-            'submit_value' => __( 'Submit', 'formidable' ),
99
-            'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ),
100
-            'admin_permission' => __( 'You do not have permission to do that', 'formidable' ),
93
+			'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ),
94
+			'blank_msg' => __( 'This field cannot be blank.', 'formidable' ),
95
+			'unique_msg' => __( 'This value must be unique.', 'formidable' ),
96
+			'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ),
97
+			'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ),
98
+			'submit_value' => __( 'Submit', 'formidable' ),
99
+			'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ),
100
+			'admin_permission' => __( 'You do not have permission to do that', 'formidable' ),
101 101
 
102
-            'email_to' => '[admin_email]',
102
+			'email_to' => '[admin_email]',
103 103
 			'no_ips'   => 0,
104
-        );
105
-    }
104
+		);
105
+	}
106 106
 
107 107
 	private function set_default_options() {
108
-        $this->fill_recaptcha_settings();
108
+		$this->fill_recaptcha_settings();
109 109
 
110 110
 		if ( ! isset( $this->load_style ) ) {
111 111
 			if ( ! isset( $this->custom_style ) ) {
112
-                $this->custom_style = true;
113
-            }
112
+				$this->custom_style = true;
113
+			}
114 114
 
115
-            $this->load_style = 'all';
116
-        }
115
+			$this->load_style = 'all';
116
+		}
117 117
 
118
-        $this->fill_with_defaults();
118
+		$this->fill_with_defaults();
119 119
 
120
-        if ( is_multisite() && is_admin() ) {
120
+		if ( is_multisite() && is_admin() ) {
121 121
 			$mu_menu = get_site_option( 'frm_admin_menu_name' );
122 122
 			if ( $mu_menu && ! empty( $mu_menu ) ) {
123
-                $this->menu = $mu_menu;
124
-                $this->mu_menu = 1;
125
-            }
126
-        }
123
+				$this->menu = $mu_menu;
124
+				$this->mu_menu = 1;
125
+			}
126
+		}
127 127
 
128 128
 		$frm_roles = FrmAppHelper::frm_capabilities( 'pro' );
129 129
 		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
130 130
 			if ( ! isset( $this->$frm_role ) ) {
131
-                $this->$frm_role = 'administrator';
132
-            }
133
-        }
134
-    }
131
+				$this->$frm_role = 'administrator';
132
+			}
133
+		}
134
+	}
135 135
 
136 136
 	public function fill_with_defaults( $params = array() ) {
137
-        $settings = $this->default_options();
137
+		$settings = $this->default_options();
138 138
 
139
-        foreach ( $settings as $setting => $default ) {
139
+		foreach ( $settings as $setting => $default ) {
140 140
 			if ( isset( $params[ 'frm_' . $setting ] ) ) {
141 141
 				$this->{$setting} = $params[ 'frm_' . $setting ];
142 142
 			} elseif ( ! isset( $this->{$setting} ) ) {
143
-                $this->{$setting} = $default;
144
-            }
143
+				$this->{$setting} = $default;
144
+			}
145 145
 
146 146
 			if ( $setting == 'menu' && empty( $this->{$setting} ) ) {
147 147
 				$this->{$setting} = $default;
148 148
 			}
149 149
 
150 150
 			unset( $setting, $default );
151
-        }
152
-    }
151
+		}
152
+	}
153 153
 
154
-    private function fill_recaptcha_settings() {
155
-        $privkey = '';
154
+	private function fill_recaptcha_settings() {
155
+		$privkey = '';
156 156
 		$re_lang = '';
157 157
 
158 158
 		if ( ! isset( $this->pubkey ) ) {
@@ -164,25 +164,25 @@  discard block
 block discarded – undo
164 164
 		}
165 165
 
166 166
 		if ( ! isset( $this->re_msg ) || empty( $this->re_msg ) ) {
167
-            $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' );
168
-        }
167
+			$this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' );
168
+		}
169 169
 
170 170
 		if ( ! isset( $this->privkey ) ) {
171
-            $this->privkey = $privkey;
172
-        }
171
+			$this->privkey = $privkey;
172
+		}
173 173
 
174 174
 		if ( ! isset( $this->re_lang ) ) {
175
-            $this->re_lang = $re_lang;
176
-        }
175
+			$this->re_lang = $re_lang;
176
+		}
177 177
 
178 178
 		if ( ! isset( $this->re_type ) ) {
179 179
 			$this->re_type = '';
180 180
 		}
181
-    }
181
+	}
182 182
 
183
-    public function validate( $params, $errors ) {
184
-        return apply_filters( 'frm_validate_settings', $errors, $params );
185
-    }
183
+	public function validate( $params, $errors ) {
184
+		return apply_filters( 'frm_validate_settings', $errors, $params );
185
+	}
186 186
 
187 187
 	public function update( $params ) {
188 188
 		$this->fill_with_defaults( $params );
@@ -196,25 +196,25 @@  discard block
 block discarded – undo
196 196
 
197 197
 		$this->update_roles( $params );
198 198
 
199
-        do_action( 'frm_update_settings', $params );
199
+		do_action( 'frm_update_settings', $params );
200 200
 
201 201
 		if ( function_exists( 'get_filesystem_method' ) ) {
202 202
 			// save styling settings in case fallback setting changes
203 203
 			$frm_style = new FrmStyle();
204 204
 			$frm_style->update( 'default' );
205 205
 		}
206
-    }
206
+	}
207 207
 
208 208
 	private function update_settings( $params ) {
209 209
 		$this->mu_menu = isset( $params['frm_mu_menu'] ) ? $params['frm_mu_menu'] : 0;
210 210
 
211 211
 		$this->pubkey = trim( $params['frm_pubkey'] );
212
-        $this->privkey = $params['frm_privkey'];
212
+		$this->privkey = $params['frm_privkey'];
213 213
 		$this->re_type = $params['frm_re_type'];
214
-        $this->re_lang = $params['frm_re_lang'];
214
+		$this->re_lang = $params['frm_re_lang'];
215 215
 		$this->re_multi = isset( $params['frm_re_multi'] ) ? $params['frm_re_multi'] : 0;
216 216
 
217
-        $this->load_style = $params['frm_load_style'];
217
+		$this->load_style = $params['frm_load_style'];
218 218
 
219 219
 		$this->use_html = isset( $params['frm_use_html'] ) ? $params['frm_use_html'] : 0;
220 220
 		$this->jquery_css = isset( $params['frm_jquery_css'] ) ? absint( $params['frm_jquery_css'] ) : 0;
@@ -222,30 +222,30 @@  discard block
 block discarded – undo
222 222
 		$this->fade_form = isset( $params['frm_fade_form'] ) ? absint( $params['frm_fade_form'] ) : 0;
223 223
 		$this->old_css   = isset( $params['frm_old_css'] ) ? absint( $params['frm_old_css'] ) : 0;
224 224
 		$this->no_ips = isset( $params['frm_no_ips'] ) ? absint( $params['frm_no_ips'] ) : 0;
225
-    }
225
+	}
226 226
 
227 227
 	private function update_roles( $params ) {
228
-        global $wp_roles;
228
+		global $wp_roles;
229 229
 
230
-        $frm_roles = FrmAppHelper::frm_capabilities();
231
-        $roles = get_editable_roles();
232
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
233
-            $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
230
+		$frm_roles = FrmAppHelper::frm_capabilities();
231
+		$roles = get_editable_roles();
232
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
233
+			$this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
234 234
 
235
-            // Make sure administrators always have permissions
236
-            if ( ! in_array( 'administrator', $this->$frm_role ) ) {
235
+			// Make sure administrators always have permissions
236
+			if ( ! in_array( 'administrator', $this->$frm_role ) ) {
237 237
 				array_push( $this->$frm_role, 'administrator' );
238
-            }
238
+			}
239 239
 
240
-            foreach ( $roles as $role => $details ) {
240
+			foreach ( $roles as $role => $details ) {
241 241
 				if ( in_array( $role, $this->$frm_role ) ) {
242
-    			    $wp_roles->add_cap( $role, $frm_role );
243
-    			} else {
244
-    			    $wp_roles->remove_cap( $role, $frm_role );
245
-    			}
246
-    		}
242
+					$wp_roles->add_cap( $role, $frm_role );
243
+				} else {
244
+					$wp_roles->remove_cap( $role, $frm_role );
245
+				}
246
+			}
247 247
 		}
248
-    }
248
+	}
249 249
 
250 250
 	public function store() {
251 251
 		// Save the posted value in the database
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
         $settings = $this->default_options();
138 138
 
139 139
         foreach ( $settings as $setting => $default ) {
140
-			if ( isset( $params[ 'frm_' . $setting ] ) ) {
141
-				$this->{$setting} = $params[ 'frm_' . $setting ];
140
+			if ( isset( $params['frm_' . $setting] ) ) {
141
+				$this->{$setting} = $params['frm_' . $setting];
142 142
 			} elseif ( ! isset( $this->{$setting} ) ) {
143 143
                 $this->{$setting} = $default;
144 144
             }
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
         $frm_roles = FrmAppHelper::frm_capabilities();
231 231
         $roles = get_editable_roles();
232 232
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
233
-            $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
233
+            $this->$frm_role = (array) ( isset( $params[$frm_role] ) ? $params[$frm_role] : 'administrator' );
234 234
 
235 235
             // Make sure administrators always have permissions
236 236
             if ( ! in_array( 'administrator', $this->$frm_role ) ) {
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -52,7 +52,8 @@  discard block
 block discarded – undo
52 52
     }
53 53
 
54 54
 	private function translate_settings( $settings ) {
55
-        if ( $settings ) { //workaround for W3 total cache conflict
55
+        if ( $settings ) {
56
+//workaround for W3 total cache conflict
56 57
 			return unserialize( serialize( $settings ) );
57 58
         }
58 59
 
@@ -63,7 +64,8 @@  discard block
 block discarded – undo
63 64
 		}
64 65
 
65 66
         // If unserializing didn't work
66
-        if ( $settings ) { //workaround for W3 total cache conflict
67
+        if ( $settings ) {
68
+//workaround for W3 total cache conflict
67 69
 			$settings = unserialize( serialize( $settings ) );
68 70
         } else {
69 71
             $settings = $this;
Please login to merge, or discard this patch.
classes/models/FrmMigrate.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 				continue;
327 327
 			}
328 328
 
329
-			$this->maybe_convert_migrated_size( $widgets[ $k ]['size'] );
329
+			$this->maybe_convert_migrated_size( $widgets[$k]['size'] );
330 330
 		}
331 331
 		update_option( 'widget_frm_show_form', $widgets );
332 332
 	}
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 			if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) {
423 423
 				continue;
424 424
 			}
425
-			$this->convert_character_to_px( $widgets[ $k ]['size'] );
425
+			$this->convert_character_to_px( $widgets[$k]['size'] );
426 426
 		}
427 427
 		update_option( 'widget_frm_show_form', $widgets );
428 428
 	}
Please login to merge, or discard this patch.
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
 		return $wpdb->get_charset_collate();
78 78
 	}
79 79
 
80
-    private function create_tables() {
81
-        $charset_collate = $this->collation();
82
-        $sql = array();
80
+	private function create_tables() {
81
+		$charset_collate = $this->collation();
82
+		$sql = array();
83 83
 
84
-        /* Create/Upgrade Fields Table */
84
+		/* Create/Upgrade Fields Table */
85 85
 		$sql[] = 'CREATE TABLE ' . $this->fields . ' (
86 86
 				id BIGINT(20) NOT NULL auto_increment,
87 87
 				field_key varchar(100) default NULL,
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
                 UNIQUE KEY field_key (field_key)
101 101
         )';
102 102
 
103
-        /* Create/Upgrade Forms Table */
103
+		/* Create/Upgrade Forms Table */
104 104
 		$sql[] = 'CREATE TABLE ' . $this->forms . ' (
105 105
                 id int(11) NOT NULL auto_increment,
106 106
 				form_key varchar(100) default NULL,
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
                 UNIQUE KEY form_key (form_key)
119 119
         )';
120 120
 
121
-        /* Create/Upgrade Items Table */
121
+		/* Create/Upgrade Items Table */
122 122
 		$sql[] = 'CREATE TABLE ' . $this->entries . ' (
123 123
 				id BIGINT(20) NOT NULL auto_increment,
124 124
 				item_key varchar(100) default NULL,
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
                 UNIQUE KEY item_key (item_key)
142 142
         )';
143 143
 
144
-        /* Create/Upgrade Meta Table */
144
+		/* Create/Upgrade Meta Table */
145 145
 		$sql[] = 'CREATE TABLE ' . $this->entry_metas . ' (
146 146
 				id BIGINT(20) NOT NULL auto_increment,
147 147
 				meta_value longtext default NULL,
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
                 KEY item_id (item_id)
154 154
         )';
155 155
 
156
-        foreach ( $sql as $q ) {
156
+		foreach ( $sql as $q ) {
157 157
 			if ( function_exists( 'dbDelta' ) ) {
158 158
 				dbDelta( $q . $charset_collate . ';' );
159 159
 			} else {
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 				$wpdb->query( $q . $charset_collate ); // WPCS: unprepared SQL ok.
162 162
 			}
163 163
 			unset( $q );
164
-        }
165
-    }
164
+		}
165
+	}
166 166
 
167 167
 	private function maybe_create_contact_form() {
168 168
 		$template_id = FrmForm::get_id_by_key( 'contact' );
@@ -209,13 +209,13 @@  discard block
 block discarded – undo
209 209
 		}
210 210
 	}
211 211
 
212
-    public function uninstall() {
212
+	public function uninstall() {
213 213
 		if ( ! current_user_can( 'administrator' ) ) {
214
-            $frm_settings = FrmAppHelper::get_settings();
214
+			$frm_settings = FrmAppHelper::get_settings();
215 215
 			wp_die( esc_html( $frm_settings->admin_permission ) );
216
-        }
216
+		}
217 217
 
218
-        global $wpdb, $wp_roles;
218
+		global $wpdb, $wp_roles;
219 219
 
220 220
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->fields ); // WPCS: unprepared SQL ok.
221 221
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->forms ); // WPCS: unprepared SQL ok.
@@ -227,12 +227,12 @@  discard block
 block discarded – undo
227 227
 		delete_option( 'frm_install_running' );
228 228
 		delete_option( 'frm_lite_settings_upgrade' );
229 229
 
230
-        //delete roles
231
-        $frm_roles = FrmAppHelper::frm_capabilities();
232
-        $roles = get_editable_roles();
233
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
234
-            foreach ( $roles as $role => $details ) {
235
-                $wp_roles->remove_cap( $role, $frm_role );
230
+		//delete roles
231
+		$frm_roles = FrmAppHelper::frm_capabilities();
232
+		$roles = get_editable_roles();
233
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
234
+			foreach ( $roles as $role => $details ) {
235
+				$wp_roles->remove_cap( $role, $frm_role );
236 236
 				unset( $role, $details );
237 237
 			}
238 238
 			unset( $frm_role, $frm_role_description );
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) );
261 261
 
262 262
 		do_action( 'frm_after_uninstall' );
263
-        return true;
264
-    }
263
+		return true;
264
+	}
265 265
 
266 266
 	/**
267 267
 	 * Reverse migration 17 -- Divide by 9
@@ -428,44 +428,44 @@  discard block
 block discarded – undo
428 428
 		$size .= 'px';
429 429
 	}
430 430
 
431
-    /**
432
-     * Migrate post and email notification settings into actions
433
-     */
434
-    private function migrate_to_16() {
435
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' );
436
-
437
-        /**
438
-        * Old email settings format:
439
-        * email_to: Email or field id
440
-        * also_email_to: array of fields ids
441
-        * reply_to: Email, field id, 'custom'
442
-        * cust_reply_to: string
443
-        * reply_to_name: field id, 'custom'
444
-        * cust_reply_to_name: string
445
-        * plain_text: 0|1
446
-        * email_message: string or ''
447
-        * email_subject: string or ''
448
-        * inc_user_info: 0|1
449
-        * update_email: 0, 1, 2
450
-        *
451
-        * Old autoresponder settings format:
452
-        * auto_responder: 0|1
453
-        * ar_email_message: string or ''
454
-        * ar_email_to: field id
455
-        * ar_plain_text: 0|1
456
-        * ar_reply_to_name: string
457
-        * ar_reply_to: string
458
-        * ar_email_subject: string
459
-        * ar_update_email: 0, 1, 2
460
-        *
461
-        * New email settings:
462
-        * post_content: json settings
463
-        * post_title: form id
464
-        * post_excerpt: message
465
-        *
466
-        */
467
-
468
-        foreach ( $forms as $form ) {
431
+	/**
432
+	 * Migrate post and email notification settings into actions
433
+	 */
434
+	private function migrate_to_16() {
435
+		$forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' );
436
+
437
+		/**
438
+		 * Old email settings format:
439
+		 * email_to: Email or field id
440
+		 * also_email_to: array of fields ids
441
+		 * reply_to: Email, field id, 'custom'
442
+		 * cust_reply_to: string
443
+		 * reply_to_name: field id, 'custom'
444
+		 * cust_reply_to_name: string
445
+		 * plain_text: 0|1
446
+		 * email_message: string or ''
447
+		 * email_subject: string or ''
448
+		 * inc_user_info: 0|1
449
+		 * update_email: 0, 1, 2
450
+		 *
451
+		 * Old autoresponder settings format:
452
+		 * auto_responder: 0|1
453
+		 * ar_email_message: string or ''
454
+		 * ar_email_to: field id
455
+		 * ar_plain_text: 0|1
456
+		 * ar_reply_to_name: string
457
+		 * ar_reply_to: string
458
+		 * ar_email_subject: string
459
+		 * ar_update_email: 0, 1, 2
460
+		 *
461
+		 * New email settings:
462
+		 * post_content: json settings
463
+		 * post_title: form id
464
+		 * post_excerpt: message
465
+		 *
466
+		 */
467
+
468
+		foreach ( $forms as $form ) {
469 469
 			if ( $form->is_template && $form->default_template ) {
470 470
 				// don't migrate the default templates since the email will be added anyway
471 471
 				continue;
@@ -474,19 +474,19 @@  discard block
 block discarded – undo
474 474
 			// Format form options
475 475
 			$form_options = maybe_unserialize( $form->options );
476 476
 
477
-            // Migrate settings to actions
478
-            FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
479
-        }
480
-    }
477
+			// Migrate settings to actions
478
+			FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
479
+		}
480
+	}
481 481
 
482
-    private function migrate_to_11() {
483
-        global $wpdb;
482
+	private function migrate_to_11() {
483
+		global $wpdb;
484 484
 
485 485
 		$forms = FrmDb::get_results( $this->forms, array(), 'id, options' );
486 486
 
487
-        $sending = __( 'Sending', 'formidable' );
487
+		$sending = __( 'Sending', 'formidable' );
488 488
 		$img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
489
-        $old_default_html = <<<DEFAULT_HTML
489
+		$old_default_html = <<<DEFAULT_HTML
490 490
 <div class="frm_submit">
491 491
 [if back_button]<input type="submit" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" [back_hook] />[/if back_button]
492 492
 <input type="submit" value="[button_label]" [button_action] />
@@ -496,21 +496,21 @@  discard block
 block discarded – undo
496 496
 		unset( $sending, $img );
497 497
 
498 498
 		$new_default_html = FrmFormsHelper::get_default_html( 'submit' );
499
-        $draft_link = FrmFormsHelper::get_draft_link();
499
+		$draft_link = FrmFormsHelper::get_draft_link();
500 500
 		foreach ( $forms as $form ) {
501 501
 			$form->options = maybe_unserialize( $form->options );
502 502
 			if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) {
503
-                continue;
504
-            }
503
+				continue;
504
+			}
505 505
 
506
-            if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
507
-                $form->options['submit_html'] = $new_default_html;
506
+			if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
507
+				$form->options['submit_html'] = $new_default_html;
508 508
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
509 509
 			} else if ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) {
510 510
 				$form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
511 511
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
512
-            }
512
+			}
513 513
 			unset( $form );
514
-        }
515
-    }
514
+		}
515
+	}
516 516
 }
Please login to merge, or discard this patch.
formidable.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
 function load_formidable_forms() {
26 26
 	global $frm_vars;
27 27
 	$frm_vars = array(
28
-    	'load_css'     => false,
28
+		'load_css'     => false,
29 29
 		'forms_loaded' => array(),
30
-    	'created_entries'   => array(),
31
-    	'pro_is_authorized' => false,
30
+		'created_entries'   => array(),
31
+		'pro_is_authorized' => false,
32 32
 	);
33 33
 
34 34
 	$frm_path = dirname( __FILE__ );
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
 spl_autoload_register( 'frm_forms_autoloader' );
49 49
 
50 50
 function frm_forms_autoloader( $class_name ) {
51
-    // Only load Frm classes here
51
+	// Only load Frm classes here
52 52
 	if ( ! preg_match( '/^Frm.+$/', $class_name ) || preg_match( '/^FrmPro.+$/', $class_name ) ) {
53
-        return;
54
-    }
53
+		return;
54
+	}
55 55
 
56 56
 	frm_class_autoloader( $class_name, dirname( __FILE__ ) );
57 57
 }
Please login to merge, or discard this patch.
classes/models/FrmForm.php 3 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -732,7 +732,8 @@
 block discarded – undo
732 732
 			}
733 733
 		}
734 734
 
735
-		if ( in_array( $values['action'], array( 'create', 'update' ) ) && ( ! $_POST || ( ! isset( $_POST['action'] ) && ! isset( $_POST['frm_action'] ) ) ) ) { // WPCS: CSRF ok.
735
+		if ( in_array( $values['action'], array( 'create', 'update' ) ) && ( ! $_POST || ( ! isset( $_POST['action'] ) && ! isset( $_POST['frm_action'] ) ) ) ) {
736
+// WPCS: CSRF ok.
736 737
 			$values['action'] = 'new';
737 738
 		}
738 739
 
Please login to merge, or discard this patch.
Indentation   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-    die( 'You are not allowed to call this page directly.' );
3
+	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
6 6
 class FrmForm {
7 7
 
8
-    /**
9
-     * @return int|boolean id on success or false on failure
10
-     */
11
-    public static function create( $values ) {
12
-        global $wpdb;
8
+	/**
9
+	 * @return int|boolean id on success or false on failure
10
+	 */
11
+	public static function create( $values ) {
12
+		global $wpdb;
13 13
 
14 14
 		$new_values = array(
15 15
 			'form_key'      => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ),
@@ -34,52 +34,52 @@  discard block
 block discarded – undo
34 34
 		$options = apply_filters( 'frm_form_options_before_update', $options, $values );
35 35
 		$new_values['options'] = serialize( $options );
36 36
 
37
-        //if(isset($values['id']) && is_numeric($values['id']))
38
-        //    $new_values['id'] = $values['id'];
37
+		//if(isset($values['id']) && is_numeric($values['id']))
38
+		//    $new_values['id'] = $values['id'];
39 39
 
40 40
 		$wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
41 41
 
42
-        $id = $wpdb->insert_id;
42
+		$id = $wpdb->insert_id;
43 43
 
44 44
 		// Clear form caching
45 45
 		self::clear_form_cache();
46 46
 
47
-        return $id;
48
-    }
47
+		return $id;
48
+	}
49 49
 
50
-    /**
51
-     * @return int|boolean ID on success or false on failure
52
-     */
53
-    public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) {
54
-        global $wpdb;
50
+	/**
51
+	 * @return int|boolean ID on success or false on failure
52
+	 */
53
+	public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) {
54
+		global $wpdb;
55 55
 
56
-        $values = self::getOne( $id, $blog_id );
57
-        if ( ! $values ) {
58
-            return false;
59
-        }
56
+		$values = self::getOne( $id, $blog_id );
57
+		if ( ! $values ) {
58
+			return false;
59
+		}
60 60
 
61
-        $new_key = $copy_keys ? $values->form_key : '';
61
+		$new_key = $copy_keys ? $values->form_key : '';
62 62
 
63
-        $new_values = array(
63
+		$new_values = array(
64 64
 			'form_key'      => FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_forms', 'form_key' ),
65
-            'name'          => $values->name,
66
-            'description'   => $values->description,
67
-            'status'        => $template ? 'published' : 'draft',
68
-            'logged_in'     => $values->logged_in ? $values->logged_in : 0,
69
-            'editable'      => $values->editable ? $values->editable : 0,
65
+			'name'          => $values->name,
66
+			'description'   => $values->description,
67
+			'status'        => $template ? 'published' : 'draft',
68
+			'logged_in'     => $values->logged_in ? $values->logged_in : 0,
69
+			'editable'      => $values->editable ? $values->editable : 0,
70 70
 			'created_at'    => current_time( 'mysql', 1 ),
71
-            'is_template'   => $template ? 1 : 0,
72
-        );
71
+			'is_template'   => $template ? 1 : 0,
72
+		);
73 73
 
74
-        if ( $blog_id ) {
75
-            $new_values['status'] = 'published';
74
+		if ( $blog_id ) {
75
+			$new_values['status'] = 'published';
76 76
 			$new_options = maybe_unserialize( $values->options );
77 77
 			$new_options['email_to'] = get_option( 'admin_email' );
78
-            $new_options['copy'] = false;
79
-            $new_values['options'] = $new_options;
80
-        } else {
81
-            $new_values['options'] = $values->options;
82
-        }
78
+			$new_options['copy'] = false;
79
+			$new_values['options'] = $new_options;
80
+		} else {
81
+			$new_values['options'] = $values->options;
82
+		}
83 83
 
84 84
 		if ( is_array( $new_values['options'] ) ) {
85 85
 			$new_values['options'] = serialize( $new_values['options'] );
@@ -87,20 +87,20 @@  discard block
 block discarded – undo
87 87
 
88 88
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
89 89
 
90
-        if ( $query_results ) {
90
+		if ( $query_results ) {
91 91
 			// Clear form caching
92 92
 			self::clear_form_cache();
93 93
 
94
-            $form_id = $wpdb->insert_id;
94
+			$form_id = $wpdb->insert_id;
95 95
 			FrmField::duplicate( $id, $form_id, $copy_keys, $blog_id );
96 96
 
97
-            // update form settings after fields are created
97
+			// update form settings after fields are created
98 98
 			do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) );
99
-            return $form_id;
100
-        }
99
+			return $form_id;
100
+		}
101 101
 
102
-        return false;
103
-    }
102
+		return false;
103
+	}
104 104
 
105 105
 	public static function after_duplicate( $form_id, $values ) {
106 106
 		$new_opts = maybe_unserialize( $values['options'] );
@@ -112,48 +112,48 @@  discard block
 block discarded – undo
112 112
 
113 113
 		$new_opts = apply_filters( 'frm_after_duplicate_form_values', $new_opts, $form_id );
114 114
 
115
-        if ( $new_opts != $values['options'] ) {
116
-            global $wpdb;
115
+		if ( $new_opts != $values['options'] ) {
116
+			global $wpdb;
117 117
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $new_opts ) ), array( 'id' => $form_id ) );
118
-        }
119
-    }
118
+		}
119
+	}
120 120
 
121
-    /**
122
-     * @return int|boolean
123
-     */
124
-    public static function update( $id, $values, $create_link = false ) {
125
-        global $wpdb;
121
+	/**
122
+	 * @return int|boolean
123
+	 */
124
+	public static function update( $id, $values, $create_link = false ) {
125
+		global $wpdb;
126 126
 
127
-        if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) {
128
-            $values['status'] = 'published';
129
-        }
127
+		if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) {
128
+			$values['status'] = 'published';
129
+		}
130 130
 
131 131
 		if ( isset( $values['form_key'] ) ) {
132 132
 			$values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id );
133
-        }
133
+		}
134 134
 
135 135
 		$form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
136 136
 
137 137
 		$new_values = self::set_update_options( array(), $values );
138 138
 
139
-        foreach ( $values as $value_key => $value ) {
139
+		foreach ( $values as $value_key => $value ) {
140 140
 			if ( $value_key && in_array( $value_key, $form_fields ) ) {
141 141
 				$new_values[ $value_key ] = $value;
142
-            }
143
-        }
142
+			}
143
+		}
144 144
 
145
-        if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) {
146
-            $new_values['status'] = $values['new_status'];
147
-        }
145
+		if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) {
146
+			$new_values['status'] = $values['new_status'];
147
+		}
148 148
 
149
-        if ( ! empty( $new_values ) ) {
149
+		if ( ! empty( $new_values ) ) {
150 150
 			$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $id ) );
151
-            if ( $query_results ) {
151
+			if ( $query_results ) {
152 152
 				self::clear_form_cache();
153
-            }
154
-        } else {
155
-            $query_results = true;
156
-        }
153
+			}
154
+		} else {
155
+			$query_results = true;
156
+		}
157 157
 		unset( $new_values );
158 158
 
159 159
 		$values = self::update_fields( $id, $values );
@@ -161,16 +161,16 @@  discard block
 block discarded – undo
161 161
 		do_action( 'frm_update_form', $id, $values );
162 162
 		do_action( 'frm_update_form_' . $id, $values );
163 163
 
164
-        return $query_results;
165
-    }
164
+		return $query_results;
165
+	}
166 166
 
167
-    /**
168
-     * @return array
169
-     */
167
+	/**
168
+	 * @return array
169
+	 */
170 170
 	public static function set_update_options( $new_values, $values ) {
171 171
 		if ( ! isset( $values['options'] ) ) {
172
-            return $new_values;
173
-        }
172
+			return $new_values;
173
+		}
174 174
 
175 175
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
176 176
 		FrmFormsHelper::fill_form_options( $options, $values );
@@ -184,17 +184,17 @@  discard block
 block discarded – undo
184 184
 		$new_values['options'] = serialize( $options );
185 185
 
186 186
 		return $new_values;
187
-    }
187
+	}
188 188
 
189 189
 
190
-    /**
191
-     * @return array
192
-     */
190
+	/**
191
+	 * @return array
192
+	 */
193 193
 	public static function update_fields( $id, $values ) {
194 194
 
195 195
 		if ( ! isset( $values['item_meta'] ) && ! isset( $values['field_options'] ) ) {
196
-            return $values;
197
-        }
196
+			return $values;
197
+		}
198 198
 
199 199
 		$all_fields = FrmField::get_all_for_form( $id );
200 200
 		if ( empty( $all_fields ) ) {
@@ -205,26 +205,26 @@  discard block
 block discarded – undo
205 205
 			$values['item_meta'] = array();
206 206
 		}
207 207
 
208
-        $field_array = array();
209
-        $existing_keys = array_keys( $values['item_meta'] );
210
-        foreach ( $all_fields as $fid ) {
208
+		$field_array = array();
209
+		$existing_keys = array_keys( $values['item_meta'] );
210
+		foreach ( $all_fields as $fid ) {
211 211
 			if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) {
212 212
 				$values['item_meta'][ $fid->id ] = '';
213
-            }
213
+			}
214 214
 			$field_array[ $fid->id ] = $fid;
215
-        }
215
+		}
216 216
 		unset( $all_fields );
217 217
 
218
-        foreach ( $values['item_meta'] as $field_id => $default_value ) {
218
+		foreach ( $values['item_meta'] as $field_id => $default_value ) {
219 219
 			if ( isset( $field_array[ $field_id ] ) ) {
220 220
 				$field = $field_array[ $field_id ];
221
-            } else {
221
+			} else {
222 222
 				$field = FrmField::getOne( $field_id );
223
-            }
223
+			}
224 224
 
225
-            if ( ! $field ) {
226
-                continue;
227
-            }
225
+			if ( ! $field ) {
226
+				continue;
227
+			}
228 228
 
229 229
 			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) );
230 230
 			if ( $is_settings_page ) {
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 			foreach ( $update_options as $opt => $default ) {
244 244
 				$field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? $values['field_options'][ $opt . '_' . $field_id ] : $default;
245 245
 				self::sanitize_field_opt( $opt, $field->field_options[ $opt ] );
246
-            }
246
+			}
247 247
 
248 248
 			$field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values );
249 249
 			$default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
@@ -258,11 +258,11 @@  discard block
 block discarded – undo
258 258
 			FrmField::update( $field_id, $new_field );
259 259
 
260 260
 			FrmField::delete_form_transient( $field->form_id );
261
-        }
261
+		}
262 262
 		self::clear_form_cache();
263 263
 
264
-        return $values;
265
-    }
264
+		return $values;
265
+	}
266 266
 
267 267
 	private static function sanitize_field_opt( $opt, &$value ) {
268 268
 		if ( is_string( $value ) ) {
@@ -310,21 +310,21 @@  discard block
 block discarded – undo
310 310
 		}
311 311
 	}
312 312
 
313
-    /**
314
-     * @param string $status
315
-     * @return int|boolean
316
-     */
313
+	/**
314
+	 * @param string $status
315
+	 * @return int|boolean
316
+	 */
317 317
 	public static function set_status( $id, $status ) {
318
-        if ( 'trash' == $status ) {
318
+		if ( 'trash' == $status ) {
319 319
 			return self::trash( $id );
320
-        }
320
+		}
321 321
 
322 322
 		$statuses  = array( 'published', 'draft', 'trash' );
323
-        if ( ! in_array( $status, $statuses ) ) {
324
-            return false;
325
-        }
323
+		if ( ! in_array( $status, $statuses ) ) {
324
+			return false;
325
+		}
326 326
 
327
-        global $wpdb;
327
+		global $wpdb;
328 328
 
329 329
 		if ( is_array( $id ) ) {
330 330
 			$where = array(
@@ -336,33 +336,33 @@  discard block
 block discarded – undo
336 336
 			array_unshift( $where['values'], $status );
337 337
 
338 338
 			$query_results = $wpdb->query( $wpdb->prepare( 'UPDATE ' . $wpdb->prefix . 'frm_forms SET status = %s ' . $where['where'], $where['values'] ) ); // WPCS: unprepared SQL ok.
339
-        } else {
339
+		} else {
340 340
 			$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'id' => $id ) );
341 341
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'parent_form_id' => $id ) );
342
-        }
342
+		}
343 343
 
344
-        if ( $query_results ) {
344
+		if ( $query_results ) {
345 345
 			self::clear_form_cache();
346
-        }
346
+		}
347 347
 
348
-        return $query_results;
349
-    }
348
+		return $query_results;
349
+	}
350 350
 
351
-    /**
352
-     * @return int|boolean
353
-     */
351
+	/**
352
+	 * @return int|boolean
353
+	 */
354 354
 	public static function trash( $id ) {
355
-        if ( ! EMPTY_TRASH_DAYS ) {
356
-            return self::destroy( $id );
357
-        }
355
+		if ( ! EMPTY_TRASH_DAYS ) {
356
+			return self::destroy( $id );
357
+		}
358 358
 
359 359
 		$form = self::getOne( $id );
360
-        if ( ! $form ) {
361
-            return false;
362
-        }
360
+		if ( ! $form ) {
361
+			return false;
362
+		}
363 363
 
364
-        $options = $form->options;
365
-        $options['trash_time'] = time();
364
+		$options = $form->options;
365
+		$options['trash_time'] = time();
366 366
 
367 367
 		global $wpdb;
368 368
 		$query_results = $wpdb->update(
@@ -387,39 +387,39 @@  discard block
 block discarded – undo
387 387
 			)
388 388
 		);
389 389
 
390
-        if ( $query_results ) {
390
+		if ( $query_results ) {
391 391
 			self::clear_form_cache();
392
-        }
392
+		}
393 393
 
394
-        return $query_results;
395
-    }
394
+		return $query_results;
395
+	}
396 396
 
397
-    /**
398
-     * @return int|boolean
399
-     */
397
+	/**
398
+	 * @return int|boolean
399
+	 */
400 400
 	public static function destroy( $id ) {
401
-        global $wpdb;
401
+		global $wpdb;
402 402
 
403 403
 		$form = self::getOne( $id );
404
-        if ( ! $form ) {
405
-            return false;
406
-        }
404
+		if ( ! $form ) {
405
+			return false;
406
+		}
407 407
 		$id = $form->id;
408 408
 
409
-        // Disconnect the entries from this form
409
+		// Disconnect the entries from this form
410 410
 		$entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) );
411 411
 		foreach ( $entries as $entry_id ) {
412 412
 			FrmEntry::destroy( $entry_id );
413 413
 			unset( $entry_id );
414 414
 		}
415 415
 
416
-        // Disconnect the fields from this form
416
+		// Disconnect the fields from this form
417 417
 		$wpdb->query( $wpdb->prepare( 'DELETE fi FROM ' . $wpdb->prefix . 'frm_fields AS fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id) WHERE fi.form_id=%d OR parent_form_id=%d', $id, $id ) );
418 418
 
419 419
 		$query_results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id ) );
420
-        if ( $query_results ) {
421
-            // Delete all form actions linked to this form
422
-            $action_control = FrmFormActionsController::get_form_actions( 'email' );
420
+		if ( $query_results ) {
421
+			// Delete all form actions linked to this form
422
+			$action_control = FrmFormActionsController::get_form_actions( 'email' );
423 423
 			$action_control->destroy( $id, 'all' );
424 424
 
425 425
 			// Clear form caching
@@ -427,10 +427,10 @@  discard block
 block discarded – undo
427 427
 
428 428
 			do_action( 'frm_destroy_form', $id );
429 429
 			do_action( 'frm_destroy_form_' . $id );
430
-        }
430
+		}
431 431
 
432
-        return $query_results;
433
-    }
432
+		return $query_results;
433
+	}
434 434
 
435 435
 	/**
436 436
 	 * Delete trashed forms based on how long they have been trashed
@@ -462,48 +462,48 @@  discard block
 block discarded – undo
462 462
 		return $count;
463 463
 	}
464 464
 
465
-    /**
466
-     * @return string form name
467
-     */
468
-    public static function getName( $id ) {
465
+	/**
466
+	 * @return string form name
467
+	 */
468
+	public static function getName( $id ) {
469 469
 		$form = FrmDb::check_cache( $id, 'frm_form' );
470
-        if ( $form ) {
470
+		if ( $form ) {
471 471
 			$r = stripslashes( $form->name );
472
-            return $r;
473
-        }
472
+			return $r;
473
+		}
474 474
 
475
-        $query_key = is_numeric( $id ) ? 'id' : 'form_key';
476
-        $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
475
+		$query_key = is_numeric( $id ) ? 'id' : 'form_key';
476
+		$r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
477 477
 		$r = stripslashes( $r );
478 478
 
479
-        return $r;
480
-    }
479
+		return $r;
480
+	}
481 481
 
482
-    /**
482
+	/**
483 483
 	 * @since 3.0
484
-     * @param string $key
485
-     * @return int form id
486
-     */
484
+	 * @param string $key
485
+	 * @return int form id
486
+	 */
487 487
 	public static function get_id_by_key( $key ) {
488 488
 		return (int) FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) );
489
-    }
489
+	}
490 490
 
491
-    /**
491
+	/**
492 492
 	 * @since 3.0
493
-     * @param int $id
494
-     * @return string form key
495
-     */
493
+	 * @param int $id
494
+	 * @return string form key
495
+	 */
496 496
 	public static function get_key_by_id( $id ) {
497
-        $id = (int) $id;
497
+		$id = (int) $id;
498 498
 		$cache = FrmDb::check_cache( $id, 'frm_form' );
499
-        if ( $cache ) {
500
-            return $cache->form_key;
501
-        }
499
+		if ( $cache ) {
500
+			return $cache->form_key;
501
+		}
502 502
 
503
-        $key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' );
503
+		$key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' );
504 504
 
505
-        return $key;
506
-    }
505
+		return $key;
506
+	}
507 507
 
508 508
 	/**
509 509
 	 * If $form is numeric, get the form object
@@ -516,47 +516,47 @@  discard block
 block discarded – undo
516 516
 		}
517 517
 	}
518 518
 
519
-    /**
520
-     * @return object form
521
-     */
522
-    public static function getOne( $id, $blog_id = false ) {
523
-        global $wpdb;
519
+	/**
520
+	 * @return object form
521
+	 */
522
+	public static function getOne( $id, $blog_id = false ) {
523
+		global $wpdb;
524 524
 
525
-        if ( $blog_id && is_multisite() ) {
526
-            global $wpmuBaseTablePrefix;
525
+		if ( $blog_id && is_multisite() ) {
526
+			global $wpmuBaseTablePrefix;
527 527
 			$prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix . $blog_id . '_' : $wpdb->get_blog_prefix( $blog_id );
528 528
 
529 529
 			$table_name = $prefix . 'frm_forms';
530
-        } else {
530
+		} else {
531 531
 			$table_name = $wpdb->prefix . 'frm_forms';
532 532
 			$cache = wp_cache_get( $id, 'frm_form' );
533
-            if ( $cache ) {
533
+			if ( $cache ) {
534 534
 				if ( isset( $cache->options ) ) {
535 535
 					$cache->options = maybe_unserialize( $cache->options );
536
-                }
536
+				}
537 537
 
538 538
 				return stripslashes_deep( $cache );
539
-            }
540
-        }
539
+			}
540
+		}
541 541
 
542 542
 		if ( is_numeric( $id ) ) {
543
-            $where = array( 'id' => $id );
544
-        } else {
545
-            $where = array( 'form_key' => $id );
546
-        }
543
+			$where = array( 'id' => $id );
544
+		} else {
545
+			$where = array( 'form_key' => $id );
546
+		}
547 547
 
548
-        $results = FrmDb::get_row( $table_name, $where );
548
+		$results = FrmDb::get_row( $table_name, $where );
549 549
 
550 550
 		if ( isset( $results->options ) ) {
551 551
 			FrmDb::set_cache( $results->id, $results, 'frm_form' );
552 552
 			$results->options = maybe_unserialize( $results->options );
553
-        }
553
+		}
554 554
 		return stripslashes_deep( $results );
555
-    }
555
+	}
556 556
 
557
-    /**
558
-     * @return object|array of objects
559
-     */
557
+	/**
558
+	 * @return object|array of objects
559
+	 */
560 560
 	public static function getAll( $where = array(), $order_by = '', $limit = '' ) {
561 561
 		if ( is_array( $where ) && ! empty( $where ) ) {
562 562
 			if ( isset( $where['is_template'] ) && $where['is_template'] && ! isset( $where['status'] ) ) {
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 		}
587 587
 
588 588
 		return stripslashes_deep( $results );
589
-    }
589
+	}
590 590
 
591 591
 	/**
592 592
 	 * Get all published forms
@@ -604,18 +604,18 @@  discard block
 block discarded – undo
604 604
 		return $forms;
605 605
 	}
606 606
 
607
-    /**
608
-     * @return int count of forms
609
-     */
610
-    public static function get_count() {
611
-    	global $wpdb;
607
+	/**
608
+	 * @return int count of forms
609
+	 */
610
+	public static function get_count() {
611
+		global $wpdb;
612 612
 
613
-    	$cache_key = 'frm_form_counts';
613
+		$cache_key = 'frm_form_counts';
614 614
 
615
-    	$counts = wp_cache_get( $cache_key, 'frm_form' );
616
-    	if ( false !== $counts ) {
617
-    	    return $counts;
618
-    	}
615
+		$counts = wp_cache_get( $cache_key, 'frm_form' );
616
+		if ( false !== $counts ) {
617
+			return $counts;
618
+		}
619 619
 
620 620
 		$results = (array) FrmDb::get_results(
621 621
 			'frm_forms',
@@ -628,31 +628,31 @@  discard block
 block discarded – undo
628 628
 		);
629 629
 
630 630
 		$statuses = array( 'published', 'draft', 'template', 'trash' );
631
-    	$counts = array_fill_keys( $statuses, 0 );
631
+		$counts = array_fill_keys( $statuses, 0 );
632 632
 
633
-    	foreach ( $results as $row ) {
634
-            if ( 'trash' != $row->status ) {
635
-    	        if ( $row->is_template ) {
633
+		foreach ( $results as $row ) {
634
+			if ( 'trash' != $row->status ) {
635
+				if ( $row->is_template ) {
636 636
 					$counts['template']++;
637
-    	        } else {
637
+				} else {
638 638
 					$counts['published']++;
639
-    	        }
640
-    	    } else {
639
+				}
640
+			} else {
641 641
 				$counts['trash']++;
642
-        	}
642
+			}
643 643
 
644
-    	    if ( 'draft' == $row->status ) {
644
+			if ( 'draft' == $row->status ) {
645 645
 				$counts['draft']++;
646
-    	    }
646
+			}
647 647
 
648 648
 			unset( $row );
649
-    	}
649
+		}
650 650
 
651
-    	$counts = (object) $counts;
651
+		$counts = (object) $counts;
652 652
 		FrmDb::set_cache( $cache_key, $counts, 'frm_form' );
653 653
 
654
-    	return $counts;
655
-    }
654
+		return $counts;
655
+	}
656 656
 
657 657
 	/**
658 658
 	 * Clear form caching
@@ -665,14 +665,14 @@  discard block
 block discarded – undo
665 665
 		FrmDb::cache_delete_group( 'frm_form' );
666 666
 	}
667 667
 
668
-    /**
669
-     * @return array of errors
670
-     */
668
+	/**
669
+	 * @return array of errors
670
+	 */
671 671
 	public static function validate( $values ) {
672
-        $errors = array();
672
+		$errors = array();
673 673
 
674 674
 		return apply_filters( 'frm_validate_form', $errors, $values );
675
-    }
675
+	}
676 676
 
677 677
 	public static function get_params( $form = null ) {
678 678
 		global $frm_vars;
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 
139 139
         foreach ( $values as $value_key => $value ) {
140 140
 			if ( $value_key && in_array( $value_key, $form_fields ) ) {
141
-				$new_values[ $value_key ] = $value;
141
+				$new_values[$value_key] = $value;
142 142
             }
143 143
         }
144 144
 
@@ -209,15 +209,15 @@  discard block
 block discarded – undo
209 209
         $existing_keys = array_keys( $values['item_meta'] );
210 210
         foreach ( $all_fields as $fid ) {
211 211
 			if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) {
212
-				$values['item_meta'][ $fid->id ] = '';
212
+				$values['item_meta'][$fid->id] = '';
213 213
             }
214
-			$field_array[ $fid->id ] = $fid;
214
+			$field_array[$fid->id] = $fid;
215 215
         }
216 216
 		unset( $all_fields );
217 217
 
218 218
         foreach ( $values['item_meta'] as $field_id => $default_value ) {
219
-			if ( isset( $field_array[ $field_id ] ) ) {
220
-				$field = $field_array[ $field_id ];
219
+			if ( isset( $field_array[$field_id] ) ) {
220
+				$field = $field_array[$field_id];
221 221
             } else {
222 222
 				$field = FrmField::getOne( $field_id );
223 223
             }
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
                 continue;
227 227
             }
228 228
 
229
-			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) );
229
+			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) );
230 230
 			if ( $is_settings_page ) {
231 231
 				self::get_settings_page_html( $values, $field );
232 232
 
@@ -241,12 +241,12 @@  discard block
 block discarded – undo
241 241
 			$update_options = apply_filters( 'frm_field_options_to_update', $update_options );
242 242
 
243 243
 			foreach ( $update_options as $opt => $default ) {
244
-				$field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? $values['field_options'][ $opt . '_' . $field_id ] : $default;
245
-				self::sanitize_field_opt( $opt, $field->field_options[ $opt ] );
244
+				$field->field_options[$opt] = isset( $values['field_options'][$opt . '_' . $field_id] ) ? $values['field_options'][$opt . '_' . $field_id] : $default;
245
+				self::sanitize_field_opt( $opt, $field->field_options[$opt] );
246 246
             }
247 247
 
248 248
 			$field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values );
249
-			$default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
249
+			$default_value = maybe_serialize( $values['item_meta'][$field_id] );
250 250
 
251 251
 			$new_field = array(
252 252
 				'field_options' => $field->field_options,
@@ -279,10 +279,10 @@  discard block
 block discarded – undo
279 279
 	 * updating the settings page
280 280
 	 */
281 281
 	private static function get_settings_page_html( $values, &$field ) {
282
-		if ( isset( $values['field_options'][ 'custom_html_' . $field->id ] ) ) {
282
+		if ( isset( $values['field_options']['custom_html_' . $field->id] ) ) {
283 283
 			$prev_opts = array();
284 284
 			$fallback_html = isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type );
285
-			$field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field->id ] ) ? $values['field_options'][ 'custom_html_' . $field->id ] : $fallback_html;
285
+			$field->field_options['custom_html'] = isset( $values['field_options']['custom_html_' . $field->id] ) ? $values['field_options']['custom_html_' . $field->id] : $fallback_html;
286 286
 		} elseif ( $field->type == 'hidden' || $field->type == 'user_id' ) {
287 287
 			$prev_opts = $field->field_options;
288 288
 		}
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 		);
307 307
 		foreach ( $field_cols as $col => $default ) {
308 308
 			$default = ( $default === '' ) ? $field->{$col} : $default;
309
-			$new_field[ $col ] = isset( $values['field_options'][ $col . '_' . $field->id ] ) ? $values['field_options'][ $col . '_' . $field->id ] : $default;
309
+			$new_field[$col] = isset( $values['field_options'][$col . '_' . $field->id] ) ? $values['field_options'][$col . '_' . $field->id] : $default;
310 310
 		}
311 311
 	}
312 312
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 			return self::trash( $id );
320 320
         }
321 321
 
322
-		$statuses  = array( 'published', 'draft', 'trash' );
322
+		$statuses = array( 'published', 'draft', 'trash' );
323 323
         if ( ! in_array( $status, $statuses ) ) {
324 324
             return false;
325 325
         }
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 			$form->options = maybe_unserialize( $form->options );
455 455
 			if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) {
456 456
 				self::destroy( $form->id );
457
-				$count++;
457
+				$count ++;
458 458
 			}
459 459
 
460 460
 			unset( $form );
@@ -633,16 +633,16 @@  discard block
 block discarded – undo
633 633
     	foreach ( $results as $row ) {
634 634
             if ( 'trash' != $row->status ) {
635 635
     	        if ( $row->is_template ) {
636
-					$counts['template']++;
636
+					$counts['template'] ++;
637 637
     	        } else {
638
-					$counts['published']++;
638
+					$counts['published'] ++;
639 639
     	        }
640 640
     	    } else {
641
-				$counts['trash']++;
641
+				$counts['trash'] ++;
642 642
         	}
643 643
 
644 644
     	    if ( 'draft' == $row->status ) {
645
-				$counts['draft']++;
645
+				$counts['draft'] ++;
646 646
     	    }
647 647
 
648 648
 			unset( $row );
@@ -683,8 +683,8 @@  discard block
 block discarded – undo
683 683
 			self::maybe_get_form( $form );
684 684
 		}
685 685
 
686
-		if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) {
687
-			return $frm_vars['form_params'][ $form->id ];
686
+		if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][$form->id] ) ) {
687
+			return $frm_vars['form_params'][$form->id];
688 688
 		}
689 689
 
690 690
 		$action_var = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; // WPCS: CSRF ok.
@@ -713,15 +713,15 @@  discard block
 block discarded – undo
713 713
 			//if there are two forms on the same page, make sure not to submit both
714 714
 			foreach ( $default_values as $var => $default ) {
715 715
 				if ( $var == 'action' ) {
716
-					$values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
716
+					$values[$var] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
717 717
 				} else {
718
-					$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
718
+					$values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
719 719
 				}
720 720
 				unset( $var, $default );
721 721
 			}
722 722
 		} else {
723 723
 			foreach ( $default_values as $var => $default ) {
724
-				$values[ $var ] = $default;
724
+				$values[$var] = $default;
725 725
 				unset( $var, $default );
726 726
 			}
727 727
 		}
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 			'sdir'   => '',
746 746
 		);
747 747
 		foreach ( $defaults as $var => $default ) {
748
-			$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
748
+			$values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
749 749
 		}
750 750
 
751 751
 		return $values;
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
 			'keep_post' => '',
774 774
 		);
775 775
 		foreach ( $defaults as $var => $default ) {
776
-			$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
776
+			$values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
777 777
 		}
778 778
 
779 779
 		return $values;
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
 	 */
855 855
 	public static function get_option( $atts ) {
856 856
 		$form = $atts['form'];
857
-		return isset( $form->options[ $atts['option'] ] ) ? $form->options[ $atts['option'] ] : $atts['default'];
857
+		return isset( $form->options[$atts['option']] ) ? $form->options[$atts['option']] : $atts['default'];
858 858
 	}
859 859
 
860 860
 	/**
Please login to merge, or discard this patch.
classes/models/fields/FrmFieldUserID.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 
42 42
 		$user_ID = get_current_user_id();
43 43
 		$user_ID = ( $user_ID ? $user_ID : '' );
44
-		$posted_value = ( FrmAppHelper::is_admin() && $_POST && isset( $_POST['item_meta'][ $this->field['id'] ] ) ); // WPCS: CSRF ok.
44
+		$posted_value = ( FrmAppHelper::is_admin() && $_POST && isset( $_POST['item_meta'][$this->field['id']] ) ); // WPCS: CSRF ok.
45 45
 		$updating = ( isset( $args['action'] ) && $args['action'] == 'update' );
46 46
 		$value = ( is_numeric( $this->field['value'] ) || $posted_value || $updating ) ? $this->field['value'] : $user_ID;
47 47
 
Please login to merge, or discard this patch.
classes/helpers/FrmStylesHelper.php 3 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 				'-' => 'down',
198 198
 				'+' => 'up',
199 199
 			);
200
-			$class = 'frm_arrow' . $arrow[ $icon ];
200
+			$class = 'frm_arrow' . $arrow[$icon];
201 201
 		} else {
202 202
 			//frm_minus1_icon
203 203
 			$key = str_replace( 'p', '', $key );
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 				'-' => 'minus',
206 206
 				'+' => 'plus',
207 207
 			);
208
-			$class = 'frm_' . $plus[ $icon ];
208
+			$class = 'frm_' . $plus[$icon];
209 209
 		}
210 210
 
211 211
         if ( $key ) {
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 ?>
226 226
     	<select name="<?php echo esc_attr( $frm_style->get_field_name( $name ) ); ?>" id="frm_<?php echo esc_attr( $name ); ?>" class="frm_icon_font frm_multiselect hide-if-js">
227 227
             <?php foreach ( $icons as $key => $icon ) { ?>
228
-			<option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[ $name ], $key ) ?>>
228
+			<option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[$name], $key ) ?>>
229 229
 				<?php echo '&#xe' . esc_html( $icon['+'] ) . '; &#xe' . esc_html( $icon['-'] ) . ';'; ?>
230 230
             </option>
231 231
             <?php } ?>
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
 
234 234
         <div class="btn-group hide-if-no-js" id="frm_<?php echo esc_attr( $name ) ?>_select">
235 235
             <button class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" type="button">
236
-				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '+', $type ) ) ?>"></i>
237
-				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '-', $type ) ) ?>"></i>
236
+				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '+', $type ) ) ?>"></i>
237
+				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '-', $type ) ) ?>"></i>
238 238
                 <b class="caret"></b>
239 239
             </button>
240 240
             <ul class="multiselect-container frm-dropdown-menu">
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 * @since 2.3
272 272
 	 */
273 273
 	public static function adjust_brightness( $hex, $steps ) {
274
-		$steps = max( -255, min( 255, $steps ) );
274
+		$steps = max( - 255, min( 255, $steps ) );
275 275
 
276 276
 		// Normalize into a six character long hex string
277 277
 		$hex = str_replace( '#', '', $hex );
@@ -322,8 +322,8 @@  discard block
 block discarded – undo
322 322
 
323 323
 		$checkbox_opts = array( 'important_style', 'auto_width', 'submit_style', 'collapse_icon', 'center_form' );
324 324
 		foreach ( $checkbox_opts as $opt ) {
325
-			if ( ! isset( $settings[ $opt ] ) ) {
326
-				$settings[ $opt ] = 0;
325
+			if ( ! isset( $settings[$opt] ) ) {
326
+				$settings[$opt] = 0;
327 327
 			}
328 328
 		}
329 329
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 				$css = '';
343 343
 			}
344 344
 			foreach ( $opts as $opt ) {
345
-				self::get_color_output( $css, $settings[ $opt ] );
345
+				self::get_color_output( $css, $settings[$opt] );
346 346
 			}
347 347
 		}
348 348
 	}
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
     /**
114 114
      * @since 2.0
115
-     * @return The class for this icon
115
+     * @return string class for this icon
116 116
      */
117 117
 	public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) {
118 118
 		if ( 'arrow' == $type && is_numeric( $key ) ) {
@@ -288,6 +288,7 @@  discard block
 block discarded – undo
288 288
 
289 289
 	/**
290 290
 	 * @since 2.3
291
+	 * @param string $default
291 292
 	 */
292 293
 	private static function get_color_output( $default, &$color ) {
293 294
 		$color = trim( $color );
Please login to merge, or discard this patch.
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 			<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=custom_css' ) ); ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Custom CSS', 'formidable' ); ?></a>
19 19
         </h2>
20 20
 <?php
21
-    }
21
+	}
22 22
 
23 23
 	/**
24 24
 	 * @since 2.05
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
110 110
 		);
111 111
 	}
112 112
 
113
-    /**
114
-     * @since 2.0
115
-     * @return The class for this icon
116
-     */
113
+	/**
114
+	 * @since 2.0
115
+	 * @return The class for this icon
116
+	 */
117 117
 	public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) {
118 118
 		if ( 'arrow' == $type && is_numeric( $key ) ) {
119 119
 			//frm_arrowup6_icon
@@ -132,20 +132,20 @@  discard block
 block discarded – undo
132 132
 			$class = 'frm_' . $plus[ $icon ];
133 133
 		}
134 134
 
135
-        if ( $key ) {
136
-            $class .= $key;
137
-        }
138
-        $class .= '_icon';
135
+		if ( $key ) {
136
+			$class .= $key;
137
+		}
138
+		$class .= '_icon';
139 139
 
140
-        return $class;
141
-    }
140
+		return $class;
141
+	}
142 142
 
143 143
 	public static function bs_icon_select( $style, $frm_style, $type = 'arrow' ) {
144 144
 		$function_name = $type . '_icons';
145 145
 		$icons = self::$function_name();
146 146
 		unset( $function_name );
147 147
 
148
-        $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
148
+		$name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
149 149
 ?>
150 150
     	<select name="<?php echo esc_attr( $frm_style->get_field_name( $name ) ); ?>" id="frm_<?php echo esc_attr( $name ); ?>" class="frm_icon_font frm_multiselect hide-if-js">
151 151
             <?php foreach ( $icons as $key => $icon ) { ?>
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
             </ul>
179 179
         </div>
180 180
 <?php
181
-    }
181
+	}
182 182
 
183 183
 	public static function hex2rgb( $hex ) {
184 184
 		$hex = str_replace( '#', '', $hex );
Please login to merge, or discard this patch.
classes/views/frm-entries/sidebar-shared.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -83,18 +83,18 @@
 block discarded – undo
83 83
         <?php } ?>
84 84
 
85 85
         <?php
86
-        foreach ( (array) $data as $k => $d ) {
86
+		foreach ( (array) $data as $k => $d ) {
87 87
 			if ( in_array( $k, array( 'browser', 'referrer' ) ) ) {
88
-                continue;
89
-            }
90
-        ?>
88
+				continue;
89
+			}
90
+		?>
91 91
         <div class="misc-pub-section">
92 92
 			<b><?php echo esc_html( ucfirst( str_replace( '-', ' ', $k ) ) ); ?></b>:
93 93
 			<?php echo wp_kses_post( implode( ', ', (array) $d ) ); ?>
94 94
         </div>
95 95
         <?php
96 96
 			unset( $k, $d );
97
-        }
98
-        ?>
97
+		}
98
+		?>
99 99
     </div>
100 100
 </div>
Please login to merge, or discard this patch.