Completed
Branch uploads (d47ab8)
by Stephanie
05:54 queued 01:03
created
classes/models/FrmField.php 2 patches
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 }
5 5
 
6 6
 class FrmField {
7
-    static $use_cache = true;
7
+	static $use_cache = true;
8 8
 	static $transient_size = 200;
9 9
 
10 10
 	public static function field_selection() {
@@ -51,39 +51,39 @@  discard block
 block discarded – undo
51 51
 		));
52 52
 	}
53 53
 
54
-    public static function create( $values, $return = true ) {
55
-        global $wpdb, $frm_duplicate_ids;
54
+	public static function create( $values, $return = true ) {
55
+		global $wpdb, $frm_duplicate_ids;
56 56
 
57
-        $new_values = array();
58
-        $key = isset($values['field_key']) ? $values['field_key'] : $values['name'];
57
+		$new_values = array();
58
+		$key = isset($values['field_key']) ? $values['field_key'] : $values['name'];
59 59
 		$new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' );
60 60
 
61 61
 		foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) {
62 62
 			$new_values[ $col ] = $values[ $col ];
63
-        }
63
+		}
64 64
 
65
-        $new_values['options'] = $values['options'];
65
+		$new_values['options'] = $values['options'];
66 66
 
67
-        $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null;
68
-        $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0;
69
-        $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null;
70
-        $new_values['field_options'] = $values['field_options'];
71
-        $new_values['created_at'] = current_time('mysql', 1);
67
+		$new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null;
68
+		$new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0;
69
+		$new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null;
70
+		$new_values['field_options'] = $values['field_options'];
71
+		$new_values['created_at'] = current_time('mysql', 1);
72 72
 
73 73
 		if ( isset( $values['id'] ) ) {
74 74
 			$frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key'];
75
-            $new_values = apply_filters('frm_duplicated_field', $new_values);
76
-        }
75
+			$new_values = apply_filters('frm_duplicated_field', $new_values);
76
+		}
77 77
 
78 78
 		foreach ( $new_values as $k => $v ) {
79
-            if ( is_array( $v ) ) {
79
+			if ( is_array( $v ) ) {
80 80
 				$new_values[ $k ] = serialize( $v );
81 81
 			}
82
-            unset( $k, $v );
83
-        }
82
+			unset( $k, $v );
83
+		}
84 84
 
85
-        //if(isset($values['id']) and is_numeric($values['id']))
86
-        //    $new_values['id'] = $values['id'];
85
+		//if(isset($values['id']) and is_numeric($values['id']))
86
+		//    $new_values['id'] = $values['id'];
87 87
 
88 88
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_fields', $new_values );
89 89
 		$new_id = 0;
@@ -104,22 +104,22 @@  discard block
 block discarded – undo
104 104
 		} else {
105 105
 			return false;
106 106
 		}
107
-    }
107
+	}
108 108
 
109
-    public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) {
110
-        global $frm_duplicate_ids;
109
+	public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) {
110
+		global $frm_duplicate_ids;
111 111
 
112 112
 		$where = array( array( 'or' => 1, 'fi.form_id' => $old_form_id, 'fr.parent_form_id' => $old_form_id ) );
113 113
 		$fields = self::getAll( $where, 'field_order', '', $blog_id );
114 114
 
115
-        foreach ( (array) $fields as $field ) {
116
-            $new_key = ($copy_keys) ? $field->field_key : '';
117
-            if ( $copy_keys && substr($field->field_key, -1) == 2 ) {
118
-                $new_key = rtrim($new_key, 2);
119
-            }
115
+		foreach ( (array) $fields as $field ) {
116
+			$new_key = ($copy_keys) ? $field->field_key : '';
117
+			if ( $copy_keys && substr($field->field_key, -1) == 2 ) {
118
+				$new_key = rtrim($new_key, 2);
119
+			}
120 120
 
121
-            $values = array();
122
-            FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key );
121
+			$values = array();
122
+			FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key );
123 123
 
124 124
 			// If this is a repeating section, create new form
125 125
 			if ( self::is_repeating_field( $field ) ) {
@@ -138,16 +138,16 @@  discard block
 block discarded – undo
138 138
 				$values['form_id'] = $new_repeat_form_id;
139 139
 			}
140 140
 
141
-            $values = apply_filters('frm_duplicated_field', $values);
142
-            $new_id = self::create($values);
143
-            $frm_duplicate_ids[ $field->id ] = $new_id;
144
-            $frm_duplicate_ids[ $field->field_key ] = $new_id;
145
-            unset($field);
146
-        }
147
-    }
141
+			$values = apply_filters('frm_duplicated_field', $values);
142
+			$new_id = self::create($values);
143
+			$frm_duplicate_ids[ $field->id ] = $new_id;
144
+			$frm_duplicate_ids[ $field->field_key ] = $new_id;
145
+			unset($field);
146
+		}
147
+	}
148 148
 
149 149
 	public static function update( $id, $values ) {
150
-        global $wpdb;
150
+		global $wpdb;
151 151
 
152 152
 		$id = absint( $id );
153 153
 
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 			$values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id );
156 156
 		}
157 157
 
158
-        if ( isset($values['required']) ) {
159
-            $values['required'] = (int) $values['required'];
160
-        }
158
+		if ( isset($values['required']) ) {
159
+			$values['required'] = (int) $values['required'];
160
+		}
161 161
 
162 162
 		self::preserve_format_option_backslashes( $values );
163 163
 
@@ -174,41 +174,41 @@  discard block
 block discarded – undo
174 174
 
175 175
 		$query_results = $wpdb->update( $wpdb->prefix . 'frm_fields', $values, array( 'id' => $id ) );
176 176
 
177
-        $form_id = 0;
177
+		$form_id = 0;
178 178
 		if ( isset( $values['form_id'] ) ) {
179
-            $form_id = absint( $values['form_id'] );
179
+			$form_id = absint( $values['form_id'] );
180 180
 		} else {
181
-            $field = self::getOne($id);
182
-            if ( $field ) {
183
-                $form_id = $field->form_id;
184
-            }
185
-            unset($field);
186
-        }
187
-        unset($values);
181
+			$field = self::getOne($id);
182
+			if ( $field ) {
183
+				$form_id = $field->form_id;
184
+			}
185
+			unset($field);
186
+		}
187
+		unset($values);
188 188
 
189 189
 		if ( $query_results ) {
190
-            wp_cache_delete( $id, 'frm_field' );
191
-            if ( $form_id ) {
192
-                self::delete_form_transient( $form_id );
193
-            }
194
-        }
190
+			wp_cache_delete( $id, 'frm_field' );
191
+			if ( $form_id ) {
192
+				self::delete_form_transient( $form_id );
193
+			}
194
+		}
195 195
 
196
-        return $query_results;
197
-    }
196
+		return $query_results;
197
+	}
198 198
 
199 199
 	/**
200
-	* Keep backslashes in the phone format option
201
-	*
202
-	* @since 2.0.8
203
-	* @param $values array - pass by reference
204
-	*/
200
+	 * Keep backslashes in the phone format option
201
+	 *
202
+	 * @since 2.0.8
203
+	 * @param $values array - pass by reference
204
+	 */
205 205
 	private static function preserve_format_option_backslashes( &$values ) {
206 206
 		if ( isset( $values['field_options']['format'] ) ) {
207 207
 			$values['field_options']['format'] = FrmAppHelper::preserve_backslashes( $values['field_options']['format'] );
208 208
 		}
209 209
 	}
210 210
 
211
-    public static function destroy( $id ) {
211
+	public static function destroy( $id ) {
212 212
 		global $wpdb;
213 213
 
214 214
 		do_action( 'frm_before_destroy_field', $id );
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 
224 224
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id=%d', $id ) );
225 225
 		return $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_fields WHERE id=%d', $id ) );
226
-    }
226
+	}
227 227
 
228 228
 	public static function delete_form_transient( $form_id ) {
229 229
 		$form_id = absint( $form_id );
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
 
238 238
 		FrmAppHelper::cache_delete_group( 'frm_field' );
239 239
 
240
-        $form = FrmForm::getOne($form_id);
241
-        if ( $form && $form->parent_form_id ) {
242
-            self::delete_form_transient( $form->parent_form_id );
243
-        }
244
-    }
240
+		$form = FrmForm::getOne($form_id);
241
+		if ( $form && $form->parent_form_id ) {
242
+			self::delete_form_transient( $form->parent_form_id );
243
+		}
244
+	}
245 245
 
246 246
 	/**
247 247
 	 * If $field is numeric, get the field object
@@ -257,131 +257,131 @@  discard block
 block discarded – undo
257 257
 			return;
258 258
 		}
259 259
 
260
-        global $wpdb;
260
+		global $wpdb;
261 261
 
262
-        $where = is_numeric($id) ? 'id=%d' : 'field_key=%s';
262
+		$where = is_numeric($id) ? 'id=%d' : 'field_key=%s';
263 263
 		$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id );
264 264
 
265
-        $results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
265
+		$results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
266 266
 
267
-        if ( empty($results) ) {
268
-            return $results;
269
-        }
267
+		if ( empty($results) ) {
268
+			return $results;
269
+		}
270 270
 
271
-        if ( is_numeric($id) ) {
271
+		if ( is_numeric($id) ) {
272 272
 			FrmAppHelper::set_cache( $results->field_key, $results, 'frm_field' );
273
-        } else if ( $results ) {
273
+		} else if ( $results ) {
274 274
 			FrmAppHelper::set_cache( $results->id, $results, 'frm_field' );
275
-        }
275
+		}
276 276
 
277 277
 		self::prepare_options( $results );
278 278
 
279
-        return stripslashes_deep($results);
280
-    }
279
+		return stripslashes_deep($results);
280
+	}
281 281
 
282
-    /**
283
-     * Get the field type by key or id
284
-     * @param int|string The field id or key
282
+	/**
283
+	 * Get the field type by key or id
284
+	 * @param int|string The field id or key
285 285
 	 * @param mixed $col The name of the column in the fields database table
286
-     */
287
-    public static function &get_type( $id, $col = 'type' ) {
288
-        $field = FrmAppHelper::check_cache( $id, 'frm_field' );
289
-        if ( $field ) {
290
-            $type = $field->{$col};
291
-        } else {
292
-            $type = FrmDb::get_var( 'frm_fields', array( 'or' => 1, 'id' => $id, 'field_key' => $id ), $col );
293
-        }
294
-
295
-        return $type;
296
-    }
286
+	 */
287
+	public static function &get_type( $id, $col = 'type' ) {
288
+		$field = FrmAppHelper::check_cache( $id, 'frm_field' );
289
+		if ( $field ) {
290
+			$type = $field->{$col};
291
+		} else {
292
+			$type = FrmDb::get_var( 'frm_fields', array( 'or' => 1, 'id' => $id, 'field_key' => $id ), $col );
293
+		}
294
+
295
+		return $type;
296
+	}
297 297
 
298 298
 	public static function get_all_types_in_form( $form_id, $type, $limit = '', $inc_sub = 'exclude' ) {
299
-        if ( ! $form_id ) {
300
-            return array();
301
-        }
299
+		if ( ! $form_id ) {
300
+			return array();
301
+		}
302 302
 
303 303
 		$results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_sub, 'inc_repeat' => $inc_sub ) );
304 304
 		if ( ! empty( $results ) ) {
305
-            $fields = array();
306
-            $count = 0;
307
-            foreach ( $results as $result ) {
308
-                if ( $type != $result->type ) {
309
-                    continue;
310
-                }
305
+			$fields = array();
306
+			$count = 0;
307
+			foreach ( $results as $result ) {
308
+				if ( $type != $result->type ) {
309
+					continue;
310
+				}
311 311
 
312 312
 				$fields[ $result->id ] = $result;
313
-                $count++;
314
-                if ( $limit == 1 ) {
315
-                    $fields = $result;
316
-                    break;
317
-                }
313
+				$count++;
314
+				if ( $limit == 1 ) {
315
+					$fields = $result;
316
+					break;
317
+				}
318 318
 
319
-                if ( ! empty($limit) && $count >= $limit ) {
320
-                    break;
321
-                }
319
+				if ( ! empty($limit) && $count >= $limit ) {
320
+					break;
321
+				}
322 322
 
323
-                unset($result);
324
-            }
325
-            return stripslashes_deep($fields);
326
-        }
323
+				unset($result);
324
+			}
325
+			return stripslashes_deep($fields);
326
+		}
327 327
 
328
-        self::$use_cache = false;
328
+		self::$use_cache = false;
329 329
 
330 330
 		$where = array( 'fi.form_id' => (int) $form_id, 'fi.type' => $type );
331 331
 		self::maybe_include_repeating_fields( $inc_sub, $where );
332 332
 		$results = self::getAll( $where, 'field_order', $limit );
333
-        self::$use_cache = true;
334
-        self::include_sub_fields($results, $inc_sub, $type);
333
+		self::$use_cache = true;
334
+		self::include_sub_fields($results, $inc_sub, $type);
335 335
 
336
-        return $results;
337
-    }
336
+		return $results;
337
+	}
338 338
 
339 339
 	public static function get_all_for_form( $form_id, $limit = '', $inc_embed = 'exclude', $inc_repeat = 'include' ) {
340
-        if ( ! (int) $form_id ) {
341
-            return array();
342
-        }
340
+		if ( ! (int) $form_id ) {
341
+			return array();
342
+		}
343 343
 
344 344
 		$results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) );
345 345
 		if ( ! empty( $results ) ) {
346
-            if ( empty($limit) ) {
346
+			if ( empty($limit) ) {
347 347
 				return $results;
348
-            }
348
+			}
349 349
 
350
-            $fields = array();
351
-            $count = 0;
352
-            foreach ( $results as $result ) {
350
+			$fields = array();
351
+			$count = 0;
352
+			foreach ( $results as $result ) {
353 353
 				$fields[ $result->id ] = $result;
354
-                if ( ! empty($limit) && $count >= $limit ) {
355
-                    break;
356
-                }
357
-            }
354
+				if ( ! empty($limit) && $count >= $limit ) {
355
+					break;
356
+				}
357
+			}
358 358
 
359 359
 			return $fields;
360
-        }
360
+		}
361 361
 
362
-        self::$use_cache = false;
362
+		self::$use_cache = false;
363 363
 
364 364
 		$where = array( 'fi.form_id' => absint( $form_id ) );
365 365
 		self::maybe_include_repeating_fields( $inc_repeat, $where );
366 366
 		$results = self::getAll( $where, 'field_order', $limit );
367 367
 
368
-        self::$use_cache = true;
368
+		self::$use_cache = true;
369 369
 
370 370
 		self::include_sub_fields( $results, $inc_embed, 'all' );
371 371
 
372
-        if ( empty($limit) ) {
372
+		if ( empty($limit) ) {
373 373
 			self::set_field_transient( $results, $form_id, 0, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) );
374
-        }
374
+		}
375 375
 
376 376
 		return $results;
377
-    }
377
+	}
378 378
 
379 379
 	/**
380
-	* If repeating fields should be included, adjust $where accordingly
381
-	*
382
-	* @param string $inc_repeat
383
-	* @param array $where - pass by reference
384
-	*/
380
+	 * If repeating fields should be included, adjust $where accordingly
381
+	 *
382
+	 * @param string $inc_repeat
383
+	 * @param array $where - pass by reference
384
+	 */
385 385
 	private static function maybe_include_repeating_fields( $inc_repeat, &$where ) {
386 386
 		if ( $inc_repeat == 'include' ) {
387 387
 			$form_id = $where['fi.form_id'];
@@ -392,77 +392,77 @@  discard block
 block discarded – undo
392 392
 
393 393
 	public static function include_sub_fields( &$results, $inc_embed, $type = 'all' ) {
394 394
 		if ( 'include' != $inc_embed || empty( $results ) ) {
395
-            return;
396
-        }
395
+			return;
396
+		}
397 397
 
398
-        $form_fields = $results;
398
+		$form_fields = $results;
399 399
 		$index_offset = 1;
400
-        foreach ( $form_fields as $k => $field ) {
401
-            if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) {
402
-                continue;
403
-            }
404
-
405
-            if ( $type == 'all' ) {
406
-                $sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
407
-            } else {
408
-                $sub_fields = self::get_all_types_in_form($field->form_id, $type);
409
-            }
410
-
411
-            if ( ! empty($sub_fields) ) {
400
+		foreach ( $form_fields as $k => $field ) {
401
+			if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) {
402
+				continue;
403
+			}
404
+
405
+			if ( $type == 'all' ) {
406
+				$sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
407
+			} else {
408
+				$sub_fields = self::get_all_types_in_form($field->form_id, $type);
409
+			}
410
+
411
+			if ( ! empty($sub_fields) ) {
412 412
 				$index = $k + $index_offset;
413 413
 				$index_offset += count( $sub_fields );
414 414
 				array_splice($results, $index, 0, $sub_fields);
415
-            }
416
-            unset($field, $sub_fields);
417
-        }
418
-    }
415
+			}
416
+			unset($field, $sub_fields);
417
+		}
418
+	}
419 419
 
420 420
 	public static function getAll( $where = array(), $order_by = '', $limit = '', $blog_id = false ) {
421 421
 		$cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id;
422
-        if ( self::$use_cache ) {
423
-            // make sure old cache doesn't get saved as a transient
424
-            $results = wp_cache_get($cache_key, 'frm_field');
425
-            if ( false !== $results ) {
426
-                return stripslashes_deep($results);
427
-            }
428
-        }
429
-
430
-        global $wpdb;
431
-
432
-        if ( $blog_id && is_multisite() ) {
433
-            global $wpmuBaseTablePrefix;
434
-            if ( $wpmuBaseTablePrefix ) {
422
+		if ( self::$use_cache ) {
423
+			// make sure old cache doesn't get saved as a transient
424
+			$results = wp_cache_get($cache_key, 'frm_field');
425
+			if ( false !== $results ) {
426
+				return stripslashes_deep($results);
427
+			}
428
+		}
429
+
430
+		global $wpdb;
431
+
432
+		if ( $blog_id && is_multisite() ) {
433
+			global $wpmuBaseTablePrefix;
434
+			if ( $wpmuBaseTablePrefix ) {
435 435
 				$prefix = $wpmuBaseTablePrefix . $blog_id . '_';
436
-            } else {
437
-                $prefix = $wpdb->get_blog_prefix( $blog_id );
438
-            }
436
+			} else {
437
+				$prefix = $wpdb->get_blog_prefix( $blog_id );
438
+			}
439 439
 
440 440
 			$table_name = $prefix . 'frm_fields';
441 441
 			$form_table_name = $prefix . 'frm_forms';
442 442
 		} else {
443 443
 			$table_name = $wpdb->prefix . 'frm_fields';
444 444
 			$form_table_name = $wpdb->prefix . 'frm_forms';
445
-        }
445
+		}
446 446
 
447 447
 		if ( ! empty( $order_by ) && strpos( $order_by, 'ORDER BY' ) === false ) {
448 448
 			$order_by = ' ORDER BY ' . $order_by;
449 449
 		}
450 450
 
451
-        $limit = FrmAppHelper::esc_limit($limit);
451
+		$limit = FrmAppHelper::esc_limit($limit);
452 452
 
453
-        $query = "SELECT fi.*, fr.name as form_name  FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
454
-        $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results';
453
+		$query = "SELECT fi.*, fr.name as form_name  FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
454
+		$query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results';
455 455
 
456
-        if ( is_array($where) ) {
457
-            $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type );
456
+		if ( is_array($where) ) {
457
+			$results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type );
458 458
 		} else {
459 459
 			// if the query is not an array, then it has already been prepared
460
-            $query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
460
+			$query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
461 461
 
462 462
 			$function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results';
463 463
 			$results = $wpdb->$function_name( $query );
464
-        }
465
-        unset( $where );
464
+		}
465
+		unset( $where );
466 466
 
467 467
 		self::format_field_results( $results );
468 468
 
@@ -561,21 +561,21 @@  discard block
 block discarded – undo
561 561
 
562 562
 	public static function getIds( $where = '', $order_by = '', $limit = '' ) {
563 563
 		_deprecated_function( __FUNCTION__, '2.0' );
564
-        global $wpdb;
565
-        if ( ! empty($order_by) && ! strpos($order_by, 'ORDER BY') !== false ) {
564
+		global $wpdb;
565
+		if ( ! empty($order_by) && ! strpos($order_by, 'ORDER BY') !== false ) {
566 566
 			$order_by = ' ORDER BY ' . $order_by;
567
-        }
567
+		}
568 568
 
569 569
 		$query = 'SELECT fi.id  FROM ' . $wpdb->prefix . 'frm_fields fi ' .
570 570
 			'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON fi.form_id=fr.id' .
571 571
 			FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
572 572
 
573
-        $method = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'get_var' : 'get_col';
573
+		$method = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'get_var' : 'get_col';
574 574
 		$cache_key = 'getIds_' . maybe_serialize( $where ) . $order_by . $limit;
575
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_field', $query, $method);
575
+		$results = FrmAppHelper::check_cache($cache_key, 'frm_field', $query, $method);
576 576
 
577
-        return $results;
578
-    }
577
+		return $results;
578
+	}
579 579
 
580 580
 	public static function is_no_save_field( $type ) {
581 581
 		return in_array( $type, self::no_save_fields() );
@@ -718,8 +718,8 @@  discard block
 block discarded – undo
718 718
 	}
719 719
 
720 720
 	/**
721
-	* @since 2.0.09
722
-	*/
721
+	 * @since 2.0.09
722
+	 */
723 723
 	public static function is_repeating_field( $field ) {
724 724
 		if ( is_array( $field ) ) {
725 725
 			$is_repeating_field = ( 'divider' == $field['type'] );
@@ -729,14 +729,14 @@  discard block
 block discarded – undo
729 729
 		return ( $is_repeating_field && self::is_option_true( $field, 'repeat' ) );
730 730
 	}
731 731
 
732
-    /**
733
-     * @param string $key
734
-     * @return int field id
735
-     */
732
+	/**
733
+	 * @param string $key
734
+	 * @return int field id
735
+	 */
736 736
 	public static function get_id_by_key( $key ) {
737
-        $id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) );
738
-        return $id;
739
-    }
737
+		$id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) );
738
+		return $id;
739
+	}
740 740
 
741 741
 	/**
742 742
 	 * @param string $id
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 	static $transient_size = 200;
9 9
 
10 10
 	public static function field_selection() {
11
-		$fields = apply_filters('frm_available_fields', array(
11
+		$fields = apply_filters( 'frm_available_fields', array(
12 12
 			'text'      => __( 'Single Line Text', 'formidable' ),
13 13
 			'textarea'  => __( 'Paragraph Text', 'formidable' ),
14 14
 			'checkbox'  => __( 'Checkboxes', 'formidable' ),
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
 			'email'     => __( 'Email Address', 'formidable' ),
18 18
 			'url'       => __( 'Website/URL', 'formidable' ),
19 19
 			'captcha'   => __( 'reCAPTCHA', 'formidable' ),
20
-		));
20
+		) );
21 21
 
22 22
 		return $fields;
23 23
 	}
24 24
 
25 25
 	public static function pro_field_selection() {
26
-		return apply_filters('frm_pro_available_fields', array(
26
+		return apply_filters( 'frm_pro_available_fields', array(
27 27
 			'end_divider' => array(
28 28
 				'name'  => __( 'End Section', 'formidable' ),
29 29
 				'switch_from' => 'divider',
@@ -48,36 +48,36 @@  discard block
 block discarded – undo
48 48
 			'tag'       => __( 'Tags', 'formidable' ),
49 49
 			'credit_card' => __( 'Credit Card', 'formidable' ),
50 50
 			'address'   => __( 'Address', 'formidable' ),
51
-		));
51
+		) );
52 52
 	}
53 53
 
54 54
     public static function create( $values, $return = true ) {
55 55
         global $wpdb, $frm_duplicate_ids;
56 56
 
57 57
         $new_values = array();
58
-        $key = isset($values['field_key']) ? $values['field_key'] : $values['name'];
58
+        $key = isset( $values['field_key'] ) ? $values['field_key'] : $values['name'];
59 59
 		$new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' );
60 60
 
61 61
 		foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) {
62
-			$new_values[ $col ] = $values[ $col ];
62
+			$new_values[$col] = $values[$col];
63 63
         }
64 64
 
65 65
         $new_values['options'] = $values['options'];
66 66
 
67
-        $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null;
68
-        $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0;
69
-        $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null;
67
+        $new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null;
68
+        $new_values['required'] = isset( $values['required'] ) ? (int) $values['required'] : 0;
69
+        $new_values['form_id'] = isset( $values['form_id'] ) ? (int) $values['form_id'] : null;
70 70
         $new_values['field_options'] = $values['field_options'];
71
-        $new_values['created_at'] = current_time('mysql', 1);
71
+        $new_values['created_at'] = current_time( 'mysql', 1 );
72 72
 
73 73
 		if ( isset( $values['id'] ) ) {
74
-			$frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key'];
75
-            $new_values = apply_filters('frm_duplicated_field', $new_values);
74
+			$frm_duplicate_ids[$values['field_key']] = $new_values['field_key'];
75
+            $new_values = apply_filters( 'frm_duplicated_field', $new_values );
76 76
         }
77 77
 
78 78
 		foreach ( $new_values as $k => $v ) {
79 79
             if ( is_array( $v ) ) {
80
-				$new_values[ $k ] = serialize( $v );
80
+				$new_values[$k] = serialize( $v );
81 81
 			}
82 82
             unset( $k, $v );
83 83
         }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
 		if ( $query_results ) {
100 100
 			if ( isset( $values['id'] ) ) {
101
-				$frm_duplicate_ids[ $values['id'] ] = $new_id;
101
+				$frm_duplicate_ids[$values['id']] = $new_id;
102 102
 			}
103 103
 			return $new_id;
104 104
 		} else {
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 		$fields = self::getAll( $where, 'field_order', '', $blog_id );
114 114
 
115 115
         foreach ( (array) $fields as $field ) {
116
-            $new_key = ($copy_keys) ? $field->field_key : '';
117
-            if ( $copy_keys && substr($field->field_key, -1) == 2 ) {
118
-                $new_key = rtrim($new_key, 2);
116
+            $new_key = ( $copy_keys ) ? $field->field_key : '';
117
+            if ( $copy_keys && substr( $field->field_key, -1 ) == 2 ) {
118
+                $new_key = rtrim( $new_key, 2 );
119 119
             }
120 120
 
121 121
             $values = array();
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
 				$values['form_id'] = $new_repeat_form_id;
139 139
 			}
140 140
 
141
-            $values = apply_filters('frm_duplicated_field', $values);
142
-            $new_id = self::create($values);
143
-            $frm_duplicate_ids[ $field->id ] = $new_id;
144
-            $frm_duplicate_ids[ $field->field_key ] = $new_id;
145
-            unset($field);
141
+            $values = apply_filters( 'frm_duplicated_field', $values );
142
+            $new_id = self::create( $values );
143
+            $frm_duplicate_ids[$field->id] = $new_id;
144
+            $frm_duplicate_ids[$field->field_key] = $new_id;
145
+            unset( $field );
146 146
         }
147 147
     }
148 148
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 			$values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id );
156 156
 		}
157 157
 
158
-        if ( isset($values['required']) ) {
158
+        if ( isset( $values['required'] ) ) {
159 159
             $values['required'] = (int) $values['required'];
160 160
         }
161 161
 
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 
168 168
 		// serialize array values
169 169
 		foreach ( array( 'default_value', 'field_options', 'options' ) as $opt ) {
170
-			if ( isset( $values[ $opt ] ) && is_array( $values[ $opt ] ) ) {
171
-				$values[ $opt ] = serialize( $values[ $opt ] );
170
+			if ( isset( $values[$opt] ) && is_array( $values[$opt] ) ) {
171
+				$values[$opt] = serialize( $values[$opt] );
172 172
 			}
173 173
 		}
174 174
 
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
 		if ( isset( $values['form_id'] ) ) {
179 179
             $form_id = absint( $values['form_id'] );
180 180
 		} else {
181
-            $field = self::getOne($id);
181
+            $field = self::getOne( $id );
182 182
             if ( $field ) {
183 183
                 $form_id = $field->form_id;
184 184
             }
185
-            unset($field);
185
+            unset( $field );
186 186
         }
187
-        unset($values);
187
+        unset( $values );
188 188
 
189 189
 		if ( $query_results ) {
190 190
             wp_cache_delete( $id, 'frm_field' );
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 
238 238
 		FrmAppHelper::cache_delete_group( 'frm_field' );
239 239
 
240
-        $form = FrmForm::getOne($form_id);
240
+        $form = FrmForm::getOne( $form_id );
241 241
         if ( $form && $form->parent_form_id ) {
242 242
             self::delete_form_transient( $form->parent_form_id );
243 243
         }
@@ -259,16 +259,16 @@  discard block
 block discarded – undo
259 259
 
260 260
         global $wpdb;
261 261
 
262
-        $where = is_numeric($id) ? 'id=%d' : 'field_key=%s';
262
+        $where = is_numeric( $id ) ? 'id=%d' : 'field_key=%s';
263 263
 		$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id );
264 264
 
265 265
         $results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
266 266
 
267
-        if ( empty($results) ) {
267
+        if ( empty( $results ) ) {
268 268
             return $results;
269 269
         }
270 270
 
271
-        if ( is_numeric($id) ) {
271
+        if ( is_numeric( $id ) ) {
272 272
 			FrmAppHelper::set_cache( $results->field_key, $results, 'frm_field' );
273 273
         } else if ( $results ) {
274 274
 			FrmAppHelper::set_cache( $results->id, $results, 'frm_field' );
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 
277 277
 		self::prepare_options( $results );
278 278
 
279
-        return stripslashes_deep($results);
279
+        return stripslashes_deep( $results );
280 280
     }
281 281
 
282 282
     /**
@@ -309,20 +309,20 @@  discard block
 block discarded – undo
309 309
                     continue;
310 310
                 }
311 311
 
312
-				$fields[ $result->id ] = $result;
313
-                $count++;
312
+				$fields[$result->id] = $result;
313
+                $count ++;
314 314
                 if ( $limit == 1 ) {
315 315
                     $fields = $result;
316 316
                     break;
317 317
                 }
318 318
 
319
-                if ( ! empty($limit) && $count >= $limit ) {
319
+                if ( ! empty( $limit ) && $count >= $limit ) {
320 320
                     break;
321 321
                 }
322 322
 
323
-                unset($result);
323
+                unset( $result );
324 324
             }
325
-            return stripslashes_deep($fields);
325
+            return stripslashes_deep( $fields );
326 326
         }
327 327
 
328 328
         self::$use_cache = false;
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 		self::maybe_include_repeating_fields( $inc_sub, $where );
332 332
 		$results = self::getAll( $where, 'field_order', $limit );
333 333
         self::$use_cache = true;
334
-        self::include_sub_fields($results, $inc_sub, $type);
334
+        self::include_sub_fields( $results, $inc_sub, $type );
335 335
 
336 336
         return $results;
337 337
     }
@@ -343,15 +343,15 @@  discard block
 block discarded – undo
343 343
 
344 344
 		$results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) );
345 345
 		if ( ! empty( $results ) ) {
346
-            if ( empty($limit) ) {
346
+            if ( empty( $limit ) ) {
347 347
 				return $results;
348 348
             }
349 349
 
350 350
             $fields = array();
351 351
             $count = 0;
352 352
             foreach ( $results as $result ) {
353
-				$fields[ $result->id ] = $result;
354
-                if ( ! empty($limit) && $count >= $limit ) {
353
+				$fields[$result->id] = $result;
354
+                if ( ! empty( $limit ) && $count >= $limit ) {
355 355
                     break;
356 356
                 }
357 357
             }
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 
370 370
 		self::include_sub_fields( $results, $inc_embed, 'all' );
371 371
 
372
-        if ( empty($limit) ) {
372
+        if ( empty( $limit ) ) {
373 373
 			self::set_field_transient( $results, $form_id, 0, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) );
374 374
         }
375 375
 
@@ -398,22 +398,22 @@  discard block
 block discarded – undo
398 398
         $form_fields = $results;
399 399
 		$index_offset = 1;
400 400
         foreach ( $form_fields as $k => $field ) {
401
-            if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) {
401
+            if ( 'form' != $field->type || ! isset( $field->field_options['form_select'] ) ) {
402 402
                 continue;
403 403
             }
404 404
 
405 405
             if ( $type == 'all' ) {
406 406
                 $sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
407 407
             } else {
408
-                $sub_fields = self::get_all_types_in_form($field->form_id, $type);
408
+                $sub_fields = self::get_all_types_in_form( $field->form_id, $type );
409 409
             }
410 410
 
411
-            if ( ! empty($sub_fields) ) {
411
+            if ( ! empty( $sub_fields ) ) {
412 412
 				$index = $k + $index_offset;
413 413
 				$index_offset += count( $sub_fields );
414
-				array_splice($results, $index, 0, $sub_fields);
414
+				array_splice( $results, $index, 0, $sub_fields );
415 415
             }
416
-            unset($field, $sub_fields);
416
+            unset( $field, $sub_fields );
417 417
         }
418 418
     }
419 419
 
@@ -421,9 +421,9 @@  discard block
 block discarded – undo
421 421
 		$cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id;
422 422
         if ( self::$use_cache ) {
423 423
             // make sure old cache doesn't get saved as a transient
424
-            $results = wp_cache_get($cache_key, 'frm_field');
424
+            $results = wp_cache_get( $cache_key, 'frm_field' );
425 425
             if ( false !== $results ) {
426
-                return stripslashes_deep($results);
426
+                return stripslashes_deep( $results );
427 427
             }
428 428
         }
429 429
 
@@ -448,16 +448,16 @@  discard block
 block discarded – undo
448 448
 			$order_by = ' ORDER BY ' . $order_by;
449 449
 		}
450 450
 
451
-        $limit = FrmAppHelper::esc_limit($limit);
451
+        $limit = FrmAppHelper::esc_limit( $limit );
452 452
 
453 453
         $query = "SELECT fi.*, fr.name as form_name  FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
454 454
         $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results';
455 455
 
456
-        if ( is_array($where) ) {
456
+        if ( is_array( $where ) ) {
457 457
             $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type );
458 458
 		} else {
459 459
 			// if the query is not an array, then it has already been prepared
460
-            $query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
460
+            $query .= FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
461 461
 
462 462
 			$function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results';
463 463
 			$results = $wpdb->$function_name( $query );
@@ -480,9 +480,9 @@  discard block
 block discarded – undo
480 480
 				FrmAppHelper::set_cache( $result->id, $result, 'frm_field' );
481 481
 				FrmAppHelper::set_cache( $result->field_key, $result, 'frm_field' );
482 482
 
483
-				$results[ $r_key ]->field_options = maybe_unserialize( $result->field_options );
484
-				$results[ $r_key ]->options = maybe_unserialize( $result->options );
485
-				$results[ $r_key ]->default_value = maybe_unserialize( $result->default_value );
483
+				$results[$r_key]->field_options = maybe_unserialize( $result->field_options );
484
+				$results[$r_key]->options = maybe_unserialize( $result->options );
485
+				$results[$r_key]->default_value = maybe_unserialize( $result->default_value );
486 486
 
487 487
 				unset( $r_key, $result );
488 488
 			}
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
 	private static function prepare_options( &$results ) {
502 502
 		$results->field_options = maybe_unserialize( $results->field_options );
503 503
 
504
-		$results->options = maybe_unserialize($results->options);
505
-		$results->default_value = maybe_unserialize($results->default_value);
504
+		$results->options = maybe_unserialize( $results->options );
505
+		$results->default_value = maybe_unserialize( $results->default_value );
506 506
 	}
507 507
 
508 508
 	/**
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 
530 530
 			if ( count( $next_fields ) >= self::$transient_size ) {
531 531
 				// if this transient is full, check for another
532
-				$next++;
532
+				$next ++;
533 533
 				self::get_next_transient( $fields, $base_name, $next );
534 534
 			}
535 535
 		}
@@ -555,14 +555,14 @@  discard block
 block discarded – undo
555 555
 				return;
556 556
 			}
557 557
 
558
-			$next++;
558
+			$next ++;
559 559
 		}
560 560
 	}
561 561
 
562 562
 	public static function getIds( $where = '', $order_by = '', $limit = '' ) {
563 563
 		_deprecated_function( __FUNCTION__, '2.0' );
564 564
         global $wpdb;
565
-        if ( ! empty($order_by) && ! strpos($order_by, 'ORDER BY') !== false ) {
565
+        if ( ! empty( $order_by ) && ! strpos( $order_by, 'ORDER BY' ) !== false ) {
566 566
 			$order_by = ' ORDER BY ' . $order_by;
567 567
         }
568 568
 
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 
573 573
         $method = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'get_var' : 'get_col';
574 574
 		$cache_key = 'getIds_' . maybe_serialize( $where ) . $order_by . $limit;
575
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_field', $query, $method);
575
+        $results = FrmAppHelper::check_cache( $cache_key, 'frm_field', $query, $method );
576 576
 
577 577
         return $results;
578 578
     }
@@ -603,8 +603,8 @@  discard block
 block discarded – undo
603 603
 			$is_multi_value_field = (
604 604
 				$field['type'] == 'checkbox' ||
605 605
 				$field['type'] == 'address' ||
606
-				( $field['type'] == 'data' && isset($field['data_type']) && $field['data_type'] == 'checkbox' ) ||
607
-				( $field['type'] == 'lookup' && isset($field['data_type']) && $field['data_type'] == 'checkbox' ) ||
606
+				( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'checkbox' ) ||
607
+				( $field['type'] == 'lookup' && isset( $field['data_type'] ) && $field['data_type'] == 'checkbox' ) ||
608 608
 				self::is_multiple_select( $field )
609 609
 			);
610 610
 
@@ -629,9 +629,9 @@  discard block
 block discarded – undo
629 629
 	 */
630 630
 	public static function is_multiple_select( $field ) {
631 631
 		if ( is_array( $field ) ) {
632
-			return self::is_option_true( $field, 'multiple' ) && ( ( $field['type'] == 'select' || ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'select') ) );
632
+			return self::is_option_true( $field, 'multiple' ) && ( ( $field['type'] == 'select' || ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'select' ) ) );
633 633
 		} else {
634
-			return self::is_option_true( $field, 'multiple' ) && ( ( $field->type == 'select' || ( $field->type == 'data' && isset($field->field_options['data_type'] ) && $field->field_options['data_type'] == 'select') ) );
634
+			return self::is_option_true( $field, 'multiple' ) && ( ( $field->type == 'select' || ( $field->type == 'data' && isset( $field->field_options['data_type'] ) && $field->field_options['data_type'] == 'select' ) ) );
635 635
 		}
636 636
 	}
637 637
 
@@ -678,23 +678,23 @@  discard block
 block discarded – undo
678 678
 	}
679 679
 
680 680
 	public static function is_option_true_in_array( $field, $option ) {
681
-		return isset( $field[ $option ] ) && $field[ $option ];
681
+		return isset( $field[$option] ) && $field[$option];
682 682
 	}
683 683
 
684 684
 	public static function is_option_true_in_object( $field, $option ) {
685
-		return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ];
685
+		return isset( $field->field_options[$option] ) && $field->field_options[$option];
686 686
 	}
687 687
 
688 688
 	public static function is_option_empty_in_array( $field, $option ) {
689
-		return ! isset( $field[ $option ] ) || empty( $field[ $option ] );
689
+		return ! isset( $field[$option] ) || empty( $field[$option] );
690 690
 	}
691 691
 
692 692
 	public static function is_option_empty_in_object( $field, $option ) {
693
-		return ! isset( $field->field_options[ $option ] ) || empty( $field->field_options[ $option ] );
693
+		return ! isset( $field->field_options[$option] ) || empty( $field->field_options[$option] );
694 694
 	}
695 695
 
696 696
 	public static function is_option_value_in_object( $field, $option ) {
697
-		return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ] != '';
697
+		return isset( $field->field_options[$option] ) && $field->field_options[$option] != '';
698 698
 	}
699 699
 
700 700
 	/**
@@ -710,11 +710,11 @@  discard block
 block discarded – undo
710 710
 	}
711 711
 
712 712
 	public static function get_option_in_array( $field, $option ) {
713
-		return $field[ $option ];
713
+		return $field[$option];
714 714
 	}
715 715
 
716 716
 	public static function get_option_in_object( $field, $option ) {
717
-		return isset( $field->field_options[ $option ] ) ? $field->field_options[ $option ] : '';
717
+		return isset( $field->field_options[$option] ) ? $field->field_options[$option] : '';
718 718
 	}
719 719
 
720 720
 	/**
Please login to merge, or discard this patch.
classes/views/addons/upgrade_to_pro.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -58,9 +58,9 @@
 block discarded – undo
58 58
 			<tr>
59 59
 				<th>Included AddOns</th>
60 60
 				<td>None</td>
61
-				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidablepro.com/pricing/#addon-lists') ) ?>" target="_blank">Premium Addons</a></td>
62
-				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidablepro.com/pricing/#addon-lists') ) ?>" target="_blank">Advanced Addons</a></td>
63
-				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidablepro.com/pricing/#addon-lists') ) ?>" target="_blank">Enterprise Addons</a></td>
61
+				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidablepro.com/pricing/#addon-lists' ) ) ?>" target="_blank">Premium Addons</a></td>
62
+				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidablepro.com/pricing/#addon-lists' ) ) ?>" target="_blank">Advanced Addons</a></td>
63
+				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidablepro.com/pricing/#addon-lists' ) ) ?>" target="_blank">Enterprise Addons</a></td>
64 64
 			</tr>
65 65
 		</tbody>
66 66
 	</table>
Please login to merge, or discard this patch.
classes/controllers/FrmAddonsController.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
 		$keyed_addons = array();
44 44
 		foreach ( $addons as $addon ) {
45
-			$keyed_addons[ $addon['info']['slug'] ] = $addon;
45
+			$keyed_addons[$addon['info']['slug']] = $addon;
46 46
 		}
47 47
 
48 48
 		$plugin_order = array(
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 		);
54 54
 		$ordered_addons = array();
55 55
 		foreach ( $plugin_order as $plugin ) {
56
-			if ( isset( $keyed_addons[ $plugin ] ) ) {
57
-				$ordered_addons[] = $keyed_addons[ $plugin ];
58
-				unset( $keyed_addons[ $plugin ] );
56
+			if ( isset( $keyed_addons[$plugin] ) ) {
57
+				$ordered_addons[] = $keyed_addons[$plugin];
58
+				unset( $keyed_addons[$plugin] );
59 59
 			}
60 60
 		}
61 61
 		$addons = $ordered_addons + $keyed_addons;
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
 	}
91 91
 
92 92
 	public static function get_licenses() {
93
-		FrmAppHelper::permission_check('frm_change_settings');
93
+		FrmAppHelper::permission_check( 'frm_change_settings' );
94 94
 		check_ajax_referer( 'frm_ajax', 'nonce' );
95 95
 
96
-		$license = get_option('frmpro-credentials');
96
+		$license = get_option( 'frmpro-credentials' );
97 97
 		if ( $license && is_array( $license ) && isset( $license['license'] ) ) {
98 98
 			$url = 'http://formidablepro.com/frm-edd-api/licenses?l=' . urlencode( base64_encode( $license['license'] ) );
99 99
 			$licenses = self::send_api_request( $url, array( 'name' => 'frm_api_licence', 'expires' => 60 * 60 * 5 ) );
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 		);
147 147
 
148 148
 		foreach ( $pro['pricing'] as $name => $price ) {
149
-			if ( isset( $pro_pricing[ $name ] ) ) {
150
-				$pro_pricing[ $name ]['price'] = $price;
149
+			if ( isset( $pro_pricing[$name] ) ) {
150
+				$pro_pricing[$name]['price'] = $price;
151 151
 			}
152 152
 		}
153 153
 	}
Please login to merge, or discard this patch.
classes/models/FrmSettings.php 3 patches
Indentation   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -1,243 +1,243 @@
 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 $preview_page_id;
8
-    public $use_html;
9
-    public $jquery_css;
10
-    public $accordion_js;
11
-
12
-    public $success_msg;
13
-    public $blank_msg;
14
-    public $unique_msg;
15
-    public $invalid_msg;
16
-    public $failed_msg;
17
-    public $submit_value;
18
-    public $login_msg;
19
-    public $admin_permission;
20
-
21
-    public $email_to;
22
-    public $load_style;
23
-    public $custom_style;
24
-
25
-    public $pubkey;
26
-    public $privkey;
27
-    public $re_lang;
28
-    public $re_msg;
4
+	public $option_name = 'frm_options';
5
+	public $menu;
6
+	public $mu_menu;
7
+	public $preview_page_id;
8
+	public $use_html;
9
+	public $jquery_css;
10
+	public $accordion_js;
11
+
12
+	public $success_msg;
13
+	public $blank_msg;
14
+	public $unique_msg;
15
+	public $invalid_msg;
16
+	public $failed_msg;
17
+	public $submit_value;
18
+	public $login_msg;
19
+	public $admin_permission;
20
+
21
+	public $email_to;
22
+	public $load_style;
23
+	public $custom_style;
24
+
25
+	public $pubkey;
26
+	public $privkey;
27
+	public $re_lang;
28
+	public $re_msg;
29 29
 	public $re_multi;
30 30
 
31
-    public function __construct() {
32
-        if ( ! defined('ABSPATH') ) {
33
-            die('You are not allowed to call this page directly.');
34
-        }
31
+	public function __construct() {
32
+		if ( ! defined('ABSPATH') ) {
33
+			die('You are not allowed to call this page directly.');
34
+		}
35 35
 
36
-        $settings = get_transient($this->option_name);
36
+		$settings = get_transient($this->option_name);
37 37
 
38
-        if ( ! is_object($settings) ) {
39
-            $settings = $this->translate_settings($settings);
40
-        }
38
+		if ( ! is_object($settings) ) {
39
+			$settings = $this->translate_settings($settings);
40
+		}
41 41
 
42
-        foreach ( $settings as $setting_name => $setting ) {
43
-            $this->{$setting_name} = $setting;
44
-            unset($setting_name, $setting);
45
-        }
42
+		foreach ( $settings as $setting_name => $setting ) {
43
+			$this->{$setting_name} = $setting;
44
+			unset($setting_name, $setting);
45
+		}
46 46
 
47
-        $this->set_default_options();
48
-    }
47
+		$this->set_default_options();
48
+	}
49 49
 
50 50
 	private function translate_settings( $settings ) {
51
-        if ( $settings ) { //workaround for W3 total cache conflict
52
-            return unserialize(serialize($settings));
53
-        }
54
-
55
-        $settings = get_option($this->option_name);
56
-        if ( is_object($settings) ) {
57
-            set_transient($this->option_name, $settings);
58
-            return $settings;
59
-        }
60
-
61
-        // If unserializing didn't work
62
-        if ( $settings ) { //workaround for W3 total cache conflict
63
-            $settings = unserialize(serialize($settings));
64
-        } else {
65
-            $settings = $this;
66
-        }
67
-
68
-        update_option($this->option_name, $settings);
69
-        set_transient($this->option_name, $settings);
70
-
71
-        return $settings;
72
-    }
73
-
74
-    /**
75
-     * @return array
76
-     */
51
+		if ( $settings ) { //workaround for W3 total cache conflict
52
+			return unserialize(serialize($settings));
53
+		}
54
+
55
+		$settings = get_option($this->option_name);
56
+		if ( is_object($settings) ) {
57
+			set_transient($this->option_name, $settings);
58
+			return $settings;
59
+		}
60
+
61
+		// If unserializing didn't work
62
+		if ( $settings ) { //workaround for W3 total cache conflict
63
+			$settings = unserialize(serialize($settings));
64
+		} else {
65
+			$settings = $this;
66
+		}
67
+
68
+		update_option($this->option_name, $settings);
69
+		set_transient($this->option_name, $settings);
70
+
71
+		return $settings;
72
+	}
73
+
74
+	/**
75
+	 * @return array
76
+	 */
77 77
 	public function default_options() {
78
-        return array(
79
-            'menu'      => apply_filters( 'frm_default_menu', __( 'Forms', 'formidable' ) ),
80
-            'mu_menu'   => 0,
81
-            'preview_page_id' => 0,
82
-            'use_html'  => true,
83
-            'jquery_css' => false,
84
-            'accordion_js' => false,
78
+		return array(
79
+			'menu'      => apply_filters( 'frm_default_menu', __( 'Forms', 'formidable' ) ),
80
+			'mu_menu'   => 0,
81
+			'preview_page_id' => 0,
82
+			'use_html'  => true,
83
+			'jquery_css' => false,
84
+			'accordion_js' => false,
85 85
 
86 86
 			're_multi'  => 0,
87 87
 
88
-            'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ),
89
-            'blank_msg' => __( 'This field cannot be blank.', 'formidable' ),
90
-            'unique_msg' => __( 'This value must be unique.', 'formidable' ),
91
-            'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ),
92
-            'failed_msg' => __( 'We\'re sorry. It looks like you\'ve  already submitted that.', 'formidable' ),
93
-            'submit_value' => __( 'Submit', 'formidable' ),
94
-            'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ),
95
-            'admin_permission' => __( 'You do not have permission to do that', 'formidable' ),
88
+			'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ),
89
+			'blank_msg' => __( 'This field cannot be blank.', 'formidable' ),
90
+			'unique_msg' => __( 'This value must be unique.', 'formidable' ),
91
+			'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ),
92
+			'failed_msg' => __( 'We\'re sorry. It looks like you\'ve  already submitted that.', 'formidable' ),
93
+			'submit_value' => __( 'Submit', 'formidable' ),
94
+			'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ),
95
+			'admin_permission' => __( 'You do not have permission to do that', 'formidable' ),
96 96
 
97
-            'email_to' => '[admin_email]',
98
-        );
99
-    }
97
+			'email_to' => '[admin_email]',
98
+		);
99
+	}
100 100
 
101 101
 	private function set_default_options() {
102
-        $this->fill_recaptcha_settings();
103
-
104
-        if ( ! isset($this->load_style) ) {
105
-            if ( ! isset($this->custom_style) ) {
106
-                $this->custom_style = true;
107
-            }
108
-
109
-            $this->load_style = 'all';
110
-        }
111
-
112
-        $this->fill_with_defaults();
113
-
114
-        if ( is_multisite() && is_admin() ) {
115
-            $mu_menu = get_site_option('frm_admin_menu_name');
116
-            if ( $mu_menu && ! empty($mu_menu) ) {
117
-                $this->menu = $mu_menu;
118
-                $this->mu_menu = 1;
119
-            }
120
-        }
121
-
122
-        $frm_roles = FrmAppHelper::frm_capabilities('pro');
123
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
124
-            if ( ! isset($this->$frm_role) ) {
125
-                $this->$frm_role = 'administrator';
126
-            }
127
-        }
128
-    }
102
+		$this->fill_recaptcha_settings();
103
+
104
+		if ( ! isset($this->load_style) ) {
105
+			if ( ! isset($this->custom_style) ) {
106
+				$this->custom_style = true;
107
+			}
108
+
109
+			$this->load_style = 'all';
110
+		}
111
+
112
+		$this->fill_with_defaults();
113
+
114
+		if ( is_multisite() && is_admin() ) {
115
+			$mu_menu = get_site_option('frm_admin_menu_name');
116
+			if ( $mu_menu && ! empty($mu_menu) ) {
117
+				$this->menu = $mu_menu;
118
+				$this->mu_menu = 1;
119
+			}
120
+		}
121
+
122
+		$frm_roles = FrmAppHelper::frm_capabilities('pro');
123
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
124
+			if ( ! isset($this->$frm_role) ) {
125
+				$this->$frm_role = 'administrator';
126
+			}
127
+		}
128
+	}
129 129
 
130 130
 	public function fill_with_defaults( $params = array() ) {
131
-        $settings = $this->default_options();
131
+		$settings = $this->default_options();
132 132
 
133
-        foreach ( $settings as $setting => $default ) {
133
+		foreach ( $settings as $setting => $default ) {
134 134
 			if ( isset( $params[ 'frm_' . $setting ] ) ) {
135 135
 				$this->{$setting} = $params[ 'frm_' . $setting ];
136
-            } else if ( ! isset($this->{$setting}) ) {
137
-                $this->{$setting} = $default;
138
-            }
136
+			} else if ( ! isset($this->{$setting}) ) {
137
+				$this->{$setting} = $default;
138
+			}
139 139
 
140 140
 			if ( $setting == 'menu' && empty( $this->{$setting} ) ) {
141 141
 				$this->{$setting} = $default;
142 142
 			}
143 143
 
144
-            unset($setting, $default);
145
-        }
146
-    }
144
+			unset($setting, $default);
145
+		}
146
+	}
147 147
 
148
-    private function fill_recaptcha_settings() {
149
-        $privkey = '';
148
+	private function fill_recaptcha_settings() {
149
+		$privkey = '';
150 150
 		$re_lang = '';
151 151
 
152
-        if ( ! isset($this->pubkey) ) {
153
-            // get the options from the database
154
-            $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha');
155
-            $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : '';
156
-            $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey;
157
-            $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang;
158
-        }
152
+		if ( ! isset($this->pubkey) ) {
153
+			// get the options from the database
154
+			$recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha');
155
+			$this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : '';
156
+			$privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey;
157
+			$re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang;
158
+		}
159 159
 
160
-        if ( ! isset($this->re_msg) || empty($this->re_msg) ) {
161
-            $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' );
162
-        }
160
+		if ( ! isset($this->re_msg) || empty($this->re_msg) ) {
161
+			$this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' );
162
+		}
163 163
 
164
-        if ( ! isset($this->privkey) ) {
165
-            $this->privkey = $privkey;
166
-        }
164
+		if ( ! isset($this->privkey) ) {
165
+			$this->privkey = $privkey;
166
+		}
167 167
 
168
-        if ( ! isset($this->re_lang) ) {
169
-            $this->re_lang = $re_lang;
170
-        }
171
-    }
168
+		if ( ! isset($this->re_lang) ) {
169
+			$this->re_lang = $re_lang;
170
+		}
171
+	}
172 172
 
173
-    public function validate( $params, $errors ) {
174
-        $errors = apply_filters( 'frm_validate_settings', $errors, $params );
175
-        return $errors;
176
-    }
173
+	public function validate( $params, $errors ) {
174
+		$errors = apply_filters( 'frm_validate_settings', $errors, $params );
175
+		return $errors;
176
+	}
177 177
 
178 178
 	public function update( $params ) {
179
-        $this->fill_with_defaults($params);
180
-        $this->update_settings($params);
179
+		$this->fill_with_defaults($params);
180
+		$this->update_settings($params);
181 181
 
182
-        if ( $this->mu_menu ) {
183
-            update_site_option('frm_admin_menu_name', $this->menu);
184
-        } else if ( current_user_can('administrator') ) {
185
-            update_site_option('frm_admin_menu_name', false);
186
-        }
182
+		if ( $this->mu_menu ) {
183
+			update_site_option('frm_admin_menu_name', $this->menu);
184
+		} else if ( current_user_can('administrator') ) {
185
+			update_site_option('frm_admin_menu_name', false);
186
+		}
187 187
 
188
-        $this->update_roles($params);
188
+		$this->update_roles($params);
189 189
 
190
-        do_action( 'frm_update_settings', $params );
191
-    }
190
+		do_action( 'frm_update_settings', $params );
191
+	}
192 192
 
193 193
 	private function update_settings( $params ) {
194
-        $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0;
194
+		$this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0;
195 195
 
196
-        $this->pubkey = trim($params['frm_pubkey']);
197
-        $this->privkey = $params['frm_privkey'];
198
-        $this->re_lang = $params['frm_re_lang'];
196
+		$this->pubkey = trim($params['frm_pubkey']);
197
+		$this->privkey = $params['frm_privkey'];
198
+		$this->re_lang = $params['frm_re_lang'];
199 199
 		$this->re_multi = isset( $params['frm_re_multi'] ) ? $params['frm_re_multi'] : 0;
200 200
 
201
-        $this->load_style = $params['frm_load_style'];
202
-        $this->preview_page_id = (int) $params['frm-preview-page-id'];
201
+		$this->load_style = $params['frm_load_style'];
202
+		$this->preview_page_id = (int) $params['frm-preview-page-id'];
203 203
 
204
-        $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0;
205
-        //$this->custom_style = isset($params['frm_custom_style']) ? $params['frm_custom_style'] : 0;
204
+		$this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0;
205
+		//$this->custom_style = isset($params['frm_custom_style']) ? $params['frm_custom_style'] : 0;
206 206
 		$this->jquery_css = isset( $params['frm_jquery_css'] ) ? absint( $params['frm_jquery_css'] ) : 0;
207 207
 		$this->accordion_js = isset( $params['frm_accordion_js'] ) ? absint( $params['frm_accordion_js'] ) : 0;
208
-    }
208
+	}
209 209
 
210 210
 	private function update_roles( $params ) {
211
-        global $wp_roles;
211
+		global $wp_roles;
212 212
 
213
-        $frm_roles = FrmAppHelper::frm_capabilities();
214
-        $roles = get_editable_roles();
215
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
216
-            $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
213
+		$frm_roles = FrmAppHelper::frm_capabilities();
214
+		$roles = get_editable_roles();
215
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
216
+			$this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
217 217
 
218
-            // Make sure administrators always have permissions
219
-            if ( ! in_array( 'administrator', $this->$frm_role ) ) {
218
+			// Make sure administrators always have permissions
219
+			if ( ! in_array( 'administrator', $this->$frm_role ) ) {
220 220
 				array_push( $this->$frm_role, 'administrator' );
221
-            }
221
+			}
222 222
 
223
-            foreach ( $roles as $role => $details ) {
224
-                if ( in_array($role, $this->$frm_role) ) {
225
-    			    $wp_roles->add_cap( $role, $frm_role );
226
-    			} else {
227
-    			    $wp_roles->remove_cap( $role, $frm_role );
228
-    			}
229
-    		}
223
+			foreach ( $roles as $role => $details ) {
224
+				if ( in_array($role, $this->$frm_role) ) {
225
+					$wp_roles->add_cap( $role, $frm_role );
226
+				} else {
227
+					$wp_roles->remove_cap( $role, $frm_role );
228
+				}
229
+			}
230 230
 		}
231
-    }
231
+	}
232 232
 
233 233
 	public function store() {
234
-        // Save the posted value in the database
234
+		// Save the posted value in the database
235 235
 
236
-        update_option('frm_options', $this);
236
+		update_option('frm_options', $this);
237 237
 
238
-        delete_transient('frm_options');
239
-        set_transient('frm_options', $this);
238
+		delete_transient('frm_options');
239
+		set_transient('frm_options', $this);
240 240
 
241
-        do_action( 'frm_store_settings' );
242
-    }
241
+		do_action( 'frm_store_settings' );
242
+	}
243 243
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -29,19 +29,19 @@  discard block
 block discarded – undo
29 29
 	public $re_multi;
30 30
 
31 31
     public function __construct() {
32
-        if ( ! defined('ABSPATH') ) {
33
-            die('You are not allowed to call this page directly.');
32
+        if ( ! defined( 'ABSPATH' ) ) {
33
+            die( 'You are not allowed to call this page directly.' );
34 34
         }
35 35
 
36
-        $settings = get_transient($this->option_name);
36
+        $settings = get_transient( $this->option_name );
37 37
 
38
-        if ( ! is_object($settings) ) {
39
-            $settings = $this->translate_settings($settings);
38
+        if ( ! is_object( $settings ) ) {
39
+            $settings = $this->translate_settings( $settings );
40 40
         }
41 41
 
42 42
         foreach ( $settings as $setting_name => $setting ) {
43 43
             $this->{$setting_name} = $setting;
44
-            unset($setting_name, $setting);
44
+            unset( $setting_name, $setting );
45 45
         }
46 46
 
47 47
         $this->set_default_options();
@@ -49,24 +49,24 @@  discard block
 block discarded – undo
49 49
 
50 50
 	private function translate_settings( $settings ) {
51 51
         if ( $settings ) { //workaround for W3 total cache conflict
52
-            return unserialize(serialize($settings));
52
+            return unserialize( serialize( $settings ) );
53 53
         }
54 54
 
55
-        $settings = get_option($this->option_name);
56
-        if ( is_object($settings) ) {
57
-            set_transient($this->option_name, $settings);
55
+        $settings = get_option( $this->option_name );
56
+        if ( is_object( $settings ) ) {
57
+            set_transient( $this->option_name, $settings );
58 58
             return $settings;
59 59
         }
60 60
 
61 61
         // If unserializing didn't work
62 62
         if ( $settings ) { //workaround for W3 total cache conflict
63
-            $settings = unserialize(serialize($settings));
63
+            $settings = unserialize( serialize( $settings ) );
64 64
         } else {
65 65
             $settings = $this;
66 66
         }
67 67
 
68
-        update_option($this->option_name, $settings);
69
-        set_transient($this->option_name, $settings);
68
+        update_option( $this->option_name, $settings );
69
+        set_transient( $this->option_name, $settings );
70 70
 
71 71
         return $settings;
72 72
     }
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 	private function set_default_options() {
102 102
         $this->fill_recaptcha_settings();
103 103
 
104
-        if ( ! isset($this->load_style) ) {
105
-            if ( ! isset($this->custom_style) ) {
104
+        if ( ! isset( $this->load_style ) ) {
105
+            if ( ! isset( $this->custom_style ) ) {
106 106
                 $this->custom_style = true;
107 107
             }
108 108
 
@@ -112,16 +112,16 @@  discard block
 block discarded – undo
112 112
         $this->fill_with_defaults();
113 113
 
114 114
         if ( is_multisite() && is_admin() ) {
115
-            $mu_menu = get_site_option('frm_admin_menu_name');
116
-            if ( $mu_menu && ! empty($mu_menu) ) {
115
+            $mu_menu = get_site_option( 'frm_admin_menu_name' );
116
+            if ( $mu_menu && ! empty( $mu_menu ) ) {
117 117
                 $this->menu = $mu_menu;
118 118
                 $this->mu_menu = 1;
119 119
             }
120 120
         }
121 121
 
122
-        $frm_roles = FrmAppHelper::frm_capabilities('pro');
122
+        $frm_roles = FrmAppHelper::frm_capabilities( 'pro' );
123 123
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
124
-            if ( ! isset($this->$frm_role) ) {
124
+            if ( ! isset( $this->$frm_role ) ) {
125 125
                 $this->$frm_role = 'administrator';
126 126
             }
127 127
         }
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
         $settings = $this->default_options();
132 132
 
133 133
         foreach ( $settings as $setting => $default ) {
134
-			if ( isset( $params[ 'frm_' . $setting ] ) ) {
135
-				$this->{$setting} = $params[ 'frm_' . $setting ];
136
-            } else if ( ! isset($this->{$setting}) ) {
134
+			if ( isset( $params['frm_' . $setting] ) ) {
135
+				$this->{$setting} = $params['frm_' . $setting];
136
+            } else if ( ! isset( $this->{$setting}) ) {
137 137
                 $this->{$setting} = $default;
138 138
             }
139 139
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 				$this->{$setting} = $default;
142 142
 			}
143 143
 
144
-            unset($setting, $default);
144
+            unset( $setting, $default );
145 145
         }
146 146
     }
147 147
 
@@ -149,23 +149,23 @@  discard block
 block discarded – undo
149 149
         $privkey = '';
150 150
 		$re_lang = '';
151 151
 
152
-        if ( ! isset($this->pubkey) ) {
152
+        if ( ! isset( $this->pubkey ) ) {
153 153
             // get the options from the database
154
-            $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha');
155
-            $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : '';
156
-            $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey;
157
-            $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang;
154
+            $recaptcha_opt = is_multisite() ? get_site_option( 'recaptcha' ) : get_option( 'recaptcha' );
155
+            $this->pubkey = isset( $recaptcha_opt['pubkey'] ) ? $recaptcha_opt['pubkey'] : '';
156
+            $privkey = isset( $recaptcha_opt['privkey'] ) ? $recaptcha_opt['privkey'] : $privkey;
157
+            $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang;
158 158
         }
159 159
 
160
-        if ( ! isset($this->re_msg) || empty($this->re_msg) ) {
160
+        if ( ! isset( $this->re_msg ) || empty( $this->re_msg ) ) {
161 161
             $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' );
162 162
         }
163 163
 
164
-        if ( ! isset($this->privkey) ) {
164
+        if ( ! isset( $this->privkey ) ) {
165 165
             $this->privkey = $privkey;
166 166
         }
167 167
 
168
-        if ( ! isset($this->re_lang) ) {
168
+        if ( ! isset( $this->re_lang ) ) {
169 169
             $this->re_lang = $re_lang;
170 170
         }
171 171
     }
@@ -176,24 +176,24 @@  discard block
 block discarded – undo
176 176
     }
177 177
 
178 178
 	public function update( $params ) {
179
-        $this->fill_with_defaults($params);
180
-        $this->update_settings($params);
179
+        $this->fill_with_defaults( $params );
180
+        $this->update_settings( $params );
181 181
 
182 182
         if ( $this->mu_menu ) {
183
-            update_site_option('frm_admin_menu_name', $this->menu);
184
-        } else if ( current_user_can('administrator') ) {
185
-            update_site_option('frm_admin_menu_name', false);
183
+            update_site_option( 'frm_admin_menu_name', $this->menu );
184
+        } else if ( current_user_can( 'administrator' ) ) {
185
+            update_site_option( 'frm_admin_menu_name', false );
186 186
         }
187 187
 
188
-        $this->update_roles($params);
188
+        $this->update_roles( $params );
189 189
 
190 190
         do_action( 'frm_update_settings', $params );
191 191
     }
192 192
 
193 193
 	private function update_settings( $params ) {
194
-        $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0;
194
+        $this->mu_menu = isset( $params['frm_mu_menu'] ) ? $params['frm_mu_menu'] : 0;
195 195
 
196
-        $this->pubkey = trim($params['frm_pubkey']);
196
+        $this->pubkey = trim( $params['frm_pubkey'] );
197 197
         $this->privkey = $params['frm_privkey'];
198 198
         $this->re_lang = $params['frm_re_lang'];
199 199
 		$this->re_multi = isset( $params['frm_re_multi'] ) ? $params['frm_re_multi'] : 0;
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
         $this->load_style = $params['frm_load_style'];
202 202
         $this->preview_page_id = (int) $params['frm-preview-page-id'];
203 203
 
204
-        $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0;
204
+        $this->use_html = isset( $params['frm_use_html'] ) ? $params['frm_use_html'] : 0;
205 205
         //$this->custom_style = isset($params['frm_custom_style']) ? $params['frm_custom_style'] : 0;
206 206
 		$this->jquery_css = isset( $params['frm_jquery_css'] ) ? absint( $params['frm_jquery_css'] ) : 0;
207 207
 		$this->accordion_js = isset( $params['frm_accordion_js'] ) ? absint( $params['frm_accordion_js'] ) : 0;
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
         $frm_roles = FrmAppHelper::frm_capabilities();
214 214
         $roles = get_editable_roles();
215 215
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
216
-            $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
216
+            $this->$frm_role = (array) ( isset( $params[$frm_role] ) ? $params[$frm_role] : 'administrator' );
217 217
 
218 218
             // Make sure administrators always have permissions
219 219
             if ( ! in_array( 'administrator', $this->$frm_role ) ) {
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
             }
222 222
 
223 223
             foreach ( $roles as $role => $details ) {
224
-                if ( in_array($role, $this->$frm_role) ) {
224
+                if ( in_array( $role, $this->$frm_role ) ) {
225 225
     			    $wp_roles->add_cap( $role, $frm_role );
226 226
     			} else {
227 227
     			    $wp_roles->remove_cap( $role, $frm_role );
@@ -233,10 +233,10 @@  discard block
 block discarded – undo
233 233
 	public function store() {
234 234
         // Save the posted value in the database
235 235
 
236
-        update_option('frm_options', $this);
236
+        update_option( 'frm_options', $this );
237 237
 
238
-        delete_transient('frm_options');
239
-        set_transient('frm_options', $this);
238
+        delete_transient( 'frm_options' );
239
+        set_transient( 'frm_options', $this );
240 240
 
241 241
         do_action( 'frm_store_settings' );
242 242
     }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,7 +48,8 @@  discard block
 block discarded – undo
48 48
     }
49 49
 
50 50
 	private function translate_settings( $settings ) {
51
-        if ( $settings ) { //workaround for W3 total cache conflict
51
+        if ( $settings ) {
52
+//workaround for W3 total cache conflict
52 53
             return unserialize(serialize($settings));
53 54
         }
54 55
 
@@ -59,7 +60,8 @@  discard block
 block discarded – undo
59 60
         }
60 61
 
61 62
         // If unserializing didn't work
62
-        if ( $settings ) { //workaround for W3 total cache conflict
63
+        if ( $settings ) {
64
+//workaround for W3 total cache conflict
63 65
             $settings = unserialize(serialize($settings));
64 66
         } else {
65 67
             $settings = $this;
Please login to merge, or discard this patch.
classes/models/FrmEDD_SL_Plugin_Updater.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
70 70
 	 * @uses api_request()
71 71
 	 *
72 72
 	 * @param array   $_transient_data Update array build by WordPress.
73
-	 * @return array Modified update array with custom plugin data.
73
+	 * @return stdClass Modified update array with custom plugin data.
74 74
 	 */
75 75
 	public function check_update( $_transient_data ) {
76 76
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 		$this->version     = $_api_data['version'];
44 44
 		$this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;
45 45
 
46
-		$frm_edd_plugin_data[ $this->slug ] = $this->api_data;
46
+		$frm_edd_plugin_data[$this->slug] = $this->api_data;
47 47
 
48 48
 		// Set up hooks.
49 49
 		$this->init();
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 			$_transient_data = new stdClass;
84 84
 		}
85 85
 
86
-		if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
86
+		if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[$this->name] ) && false === $this->wp_override ) {
87 87
 			return $_transient_data;
88 88
 		}
89 89
 
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
 					$version_info->plugin = $this->name;
98 98
 				}
99 99
 
100
-				$_transient_data->response[ $this->name ] = $version_info;
100
+				$_transient_data->response[$this->name] = $version_info;
101 101
 
102 102
 			}
103 103
 
104 104
 			$_transient_data->last_checked = time();
105
-			$_transient_data->checked[ $this->name ] = $this->version;
105
+			$_transient_data->checked[$this->name] = $this->version;
106 106
 
107 107
 		}
108 108
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 			wp_die( __( 'You do not have permission to install plugin updates', 'formidable' ), __( 'Error', 'formidable' ), array( 'response' => 403 ) );
246 246
 		}
247 247
 
248
-		$data         = $frm_edd_plugin_data[ $_REQUEST['slug'] ];
248
+		$data         = $frm_edd_plugin_data[$_REQUEST['slug']];
249 249
 		$cache_key    = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_version_info' );
250 250
 		$version_info = get_transient( $cache_key );
251 251
 
Please login to merge, or discard this patch.
classes/helpers/FrmXMLHelper.php 2 patches
Indentation   +571 added lines, -571 removed lines patch added patch discarded remove patch
@@ -23,30 +23,30 @@  discard block
 block discarded – undo
23 23
 	}
24 24
 
25 25
 	public static function import_xml( $file ) {
26
-        $defaults = array(
27
-            'forms' => 0, 'fields' => 0, 'terms' => 0,
28
-            'posts' => 0, 'views' => 0, 'actions' => 0,
29
-            'styles' => 0,
30
-        );
31
-
32
-        $imported = array(
33
-            'imported' => $defaults,
26
+		$defaults = array(
27
+			'forms' => 0, 'fields' => 0, 'terms' => 0,
28
+			'posts' => 0, 'views' => 0, 'actions' => 0,
29
+			'styles' => 0,
30
+		);
31
+
32
+		$imported = array(
33
+			'imported' => $defaults,
34 34
 			'updated'  => $defaults,
35 35
 			'forms'    => array(),
36 36
 			'terms'    => array(),
37
-        );
37
+		);
38 38
 
39
-        unset($defaults);
39
+		unset($defaults);
40 40
 
41 41
 		if ( ! defined( 'WP_IMPORTING' ) ) {
42
-            define('WP_IMPORTING', true);
43
-        }
42
+			define('WP_IMPORTING', true);
43
+		}
44 44
 
45 45
 		if ( ! class_exists( 'DOMDocument' ) ) {
46
-            return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
47
-        }
46
+			return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
47
+		}
48 48
 
49
-        $dom = new DOMDocument;
49
+		$dom = new DOMDocument;
50 50
 		$success = $dom->loadXML( file_get_contents( $file ) );
51 51
 		if ( ! $success ) {
52 52
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
@@ -64,45 +64,45 @@  discard block
 block discarded – undo
64 64
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
65 65
 		}
66 66
 
67
-        // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
67
+		// add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
68 68
 		foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
69
-            // grab cats, tags, and terms, or forms or posts
70
-            if ( isset($xml->{$item_type} ) ) {
69
+			// grab cats, tags, and terms, or forms or posts
70
+			if ( isset($xml->{$item_type} ) ) {
71 71
 				$function_name = 'import_xml_' . $item_type . 's';
72 72
 				$imported = self::$function_name( $xml->{$item_type}, $imported );
73 73
 				unset( $function_name, $xml->{$item_type} );
74
-            }
75
-        }
74
+			}
75
+		}
76 76
 
77
-	    $return = apply_filters('frm_importing_xml', $imported, $xml );
77
+		$return = apply_filters('frm_importing_xml', $imported, $xml );
78 78
 
79
-	    return $return;
80
-    }
79
+		return $return;
80
+	}
81 81
 
82 82
 	public static function import_xml_terms( $terms, $imported ) {
83
-        foreach ( $terms as $t ) {
83
+		foreach ( $terms as $t ) {
84 84
 			if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) {
85
-			    continue;
85
+				continue;
86 86
 			}
87 87
 
88 88
 			$parent = self::get_term_parent_id( $t );
89 89
 
90 90
 			$term = wp_insert_term( (string) $t->term_name, (string) $t->term_taxonomy, array(
91
-                'slug'          => (string) $t->term_slug,
92
-                'description'   => (string) $t->term_description,
91
+				'slug'          => (string) $t->term_slug,
92
+				'description'   => (string) $t->term_description,
93 93
 				'parent'        => empty( $parent ) ? 0 : $parent,
94
-            ));
94
+			));
95 95
 
96 96
 			if ( $term && is_array( $term ) ) {
97
-                $imported['imported']['terms']++;
97
+				$imported['imported']['terms']++;
98 98
 				$imported['terms'][ (int) $t->term_id ] = $term['term_id'];
99
-            }
99
+			}
100 100
 
101 101
 			unset( $term, $t );
102 102
 		}
103 103
 
104 104
 		return $imported;
105
-    }
105
+	}
106 106
 
107 107
 	/**
108 108
 	 * @since 2.0.8
@@ -127,99 +127,99 @@  discard block
 block discarded – undo
127 127
 		self::put_child_forms_first( $forms );
128 128
 
129 129
 		foreach ( $forms as $item ) {
130
-            $form = array(
131
-                'id'            => (int) $item->id,
132
-                'form_key'      => (string) $item->form_key,
133
-                'name'          => (string) $item->name,
134
-                'description'   => (string) $item->description,
135
-                'options'       => (string) $item->options,
136
-                'logged_in'     => (int) $item->logged_in,
137
-                'is_template'   => (int) $item->is_template,
138
-                'default_template' => (int) $item->default_template,
139
-                'editable'      => (int) $item->editable,
140
-                'status'        => (string) $item->status,
141
-                'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0,
142
-                'created_at'    => date( 'Y-m-d H:i:s', strtotime( (string) $item->created_at ) ),
143
-            );
144
-
145
-            $form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
130
+			$form = array(
131
+				'id'            => (int) $item->id,
132
+				'form_key'      => (string) $item->form_key,
133
+				'name'          => (string) $item->name,
134
+				'description'   => (string) $item->description,
135
+				'options'       => (string) $item->options,
136
+				'logged_in'     => (int) $item->logged_in,
137
+				'is_template'   => (int) $item->is_template,
138
+				'default_template' => (int) $item->default_template,
139
+				'editable'      => (int) $item->editable,
140
+				'status'        => (string) $item->status,
141
+				'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0,
142
+				'created_at'    => date( 'Y-m-d H:i:s', strtotime( (string) $item->created_at ) ),
143
+			);
144
+
145
+			$form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
146 146
 
147 147
 			self::update_custom_style_setting_on_import( $form );
148 148
 
149
-            // if template, allow to edit if form keys match, otherwise, creation date must also match
149
+			// if template, allow to edit if form keys match, otherwise, creation date must also match
150 150
 			$edit_query = array( 'form_key' => $form['form_key'], 'is_template' => $form['is_template'] );
151
-            if ( ! $form['is_template'] ) {
152
-                $edit_query['created_at'] = $form['created_at'];
153
-            }
151
+			if ( ! $form['is_template'] ) {
152
+				$edit_query['created_at'] = $form['created_at'];
153
+			}
154 154
 
155
-            $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
155
+			$edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
156 156
 
157
-            $this_form = FrmForm::getAll($edit_query, '', 1);
158
-            unset($edit_query);
157
+			$this_form = FrmForm::getAll($edit_query, '', 1);
158
+			unset($edit_query);
159 159
 
160
-            if ( ! empty( $this_form ) ) {
161
-                $old_id = $form_id = $this_form->id;
162
-                FrmForm::update($form_id, $form );
163
-                $imported['updated']['forms']++;
164
-                // Keep track of whether this specific form was updated or not
160
+			if ( ! empty( $this_form ) ) {
161
+				$old_id = $form_id = $this_form->id;
162
+				FrmForm::update($form_id, $form );
163
+				$imported['updated']['forms']++;
164
+				// Keep track of whether this specific form was updated or not
165 165
 				$imported['form_status'][ $form_id ] = 'updated';
166 166
 
167 167
 				$form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' );
168
-                $old_fields = array();
169
-                foreach ( $form_fields as $f ) {
168
+				$old_fields = array();
169
+				foreach ( $form_fields as $f ) {
170 170
 					$old_fields[ $f->id ] = $f;
171 171
 					$old_fields[ $f->field_key ] = $f->id;
172
-                    unset($f);
173
-                }
174
-                $form_fields = $old_fields;
175
-                unset($old_fields);
176
-            } else {
177
-                $old_id = false;
178
-                //form does not exist, so create it
172
+					unset($f);
173
+				}
174
+				$form_fields = $old_fields;
175
+				unset($old_fields);
176
+			} else {
177
+				$old_id = false;
178
+				//form does not exist, so create it
179 179
 				$form_id = FrmForm::create( $form );
180
-                if ( $form_id ) {
181
-                    $imported['imported']['forms']++;
182
-                    // Keep track of whether this specific form was updated or not
180
+				if ( $form_id ) {
181
+					$imported['imported']['forms']++;
182
+					// Keep track of whether this specific form was updated or not
183 183
 					$imported['form_status'][ $form_id ] = 'imported';
184 184
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
185
-                }
186
-            }
185
+				}
186
+			}
187 187
 
188
-    		self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported );
188
+			self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported );
189 189
 
190
-    		// Delete any fields attached to this form that were not included in the template
191
-    		if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
190
+			// Delete any fields attached to this form that were not included in the template
191
+			if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
192 192
 				foreach ( $form_fields as $field ) {
193
-                    if ( is_object($field) ) {
194
-                        FrmField::destroy($field->id);
195
-                    }
196
-                    unset($field);
197
-                }
198
-                unset($form_fields);
199
-            }
200
-
201
-		    // Update field ids/keys to new ones
193
+					if ( is_object($field) ) {
194
+						FrmField::destroy($field->id);
195
+					}
196
+					unset($field);
197
+				}
198
+				unset($form_fields);
199
+			}
200
+
201
+			// Update field ids/keys to new ones
202 202
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
203 203
 
204 204
 			$imported['forms'][ (int) $item->id ] = $form_id;
205 205
 
206
-            // Send pre 2.0 form options through function that creates actions
207
-            self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
206
+			// Send pre 2.0 form options through function that creates actions
207
+			self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
208 208
 
209
-		    unset($form, $item);
209
+			unset($form, $item);
210 210
 		}
211 211
 
212 212
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
213 213
 
214 214
 		return $imported;
215
-    }
215
+	}
216 216
 
217 217
 	/**
218
-	* Put child forms first so they will be imported before parents
219
-	*
220
-	* @since 2.0.16
221
-	* @param array $forms
222
-	*/
218
+	 * Put child forms first so they will be imported before parents
219
+	 *
220
+	 * @since 2.0.16
221
+	 * @param array $forms
222
+	 */
223 223
 	private static function put_child_forms_first( &$forms ) {
224 224
 		$child_forms = array();
225 225
 		$regular_forms = array();
@@ -238,13 +238,13 @@  discard block
 block discarded – undo
238 238
 	}
239 239
 
240 240
 	/**
241
-	* Keep track of all imported child forms
242
-	*
243
-	* @since 2.0.16
244
-	* @param int $form_id
245
-	* @param int $parent_form_id
246
-	* @param array $child_forms
247
-	*/
241
+	 * Keep track of all imported child forms
242
+	 *
243
+	 * @since 2.0.16
244
+	 * @param int $form_id
245
+	 * @param int $parent_form_id
246
+	 * @param array $child_forms
247
+	 */
248 248
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
249 249
 		if ( $parent_form_id ) {
250 250
 			$child_forms[ $form_id ] = $parent_form_id;
@@ -252,13 +252,13 @@  discard block
 block discarded – undo
252 252
 	}
253 253
 
254 254
 	/**
255
-	* Update the parent_form_id on imported child forms
256
-	* Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
257
-	*
258
-	* @since 2.0.6
259
-	* @param array $imported_forms
260
-	* @param array $child_forms
261
-	*/
255
+	 * Update the parent_form_id on imported child forms
256
+	 * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
257
+	 *
258
+	 * @since 2.0.6
259
+	 * @param array $imported_forms
260
+	 * @param array $child_forms
261
+	 */
262 262
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
263 263
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
264 264
 
@@ -272,40 +272,40 @@  discard block
 block discarded – undo
272 272
 	}
273 273
 
274 274
 	/**
275
-	* Import all fields for a form
276
-	* @since 2.0.13
277
-	*
278
-	* TODO: Cut down on params
279
-	*/
275
+	 * Import all fields for a form
276
+	 * @since 2.0.13
277
+	 *
278
+	 * TODO: Cut down on params
279
+	 */
280 280
 	private static function import_xml_fields( $xml_fields, $form_id, $this_form, &$form_fields, &$imported ) {
281 281
 		$in_section = 0;
282 282
 
283 283
 		foreach ( $xml_fields as $field ) {
284
-		    $f = array(
285
-		        'id'            => (int) $field->id,
286
-		        'field_key'     => (string) $field->field_key,
287
-		        'name'          => (string) $field->name,
288
-		        'description'   => (string) $field->description,
289
-		        'type'          => (string) $field->type,
290
-		        'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
291
-		        'field_order'   => (int) $field->field_order,
292
-		        'form_id'       => (int) $form_id,
293
-		        'required'      => (int) $field->required,
294
-		        'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
284
+			$f = array(
285
+				'id'            => (int) $field->id,
286
+				'field_key'     => (string) $field->field_key,
287
+				'name'          => (string) $field->name,
288
+				'description'   => (string) $field->description,
289
+				'type'          => (string) $field->type,
290
+				'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
291
+				'field_order'   => (int) $field->field_order,
292
+				'form_id'       => (int) $form_id,
293
+				'required'      => (int) $field->required,
294
+				'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
295 295
 				'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
296
-		    );
297
-
298
-		    if ( is_array($f['default_value']) && in_array($f['type'], array(
299
-		        'text', 'email', 'url', 'textarea',
300
-		        'number','phone', 'date', 'time',
301
-		        'hidden', 'password', 'tag', 'image',
302
-		    )) ) {
303
-		        if ( count($f['default_value']) === 1 ) {
296
+			);
297
+
298
+			if ( is_array($f['default_value']) && in_array($f['type'], array(
299
+				'text', 'email', 'url', 'textarea',
300
+				'number','phone', 'date', 'time',
301
+				'hidden', 'password', 'tag', 'image',
302
+			)) ) {
303
+				if ( count($f['default_value']) === 1 ) {
304 304
 					$f['default_value'] = '[' . reset( $f['default_value'] ) . ']';
305
-		        } else {
306
-		            $f['default_value'] = reset($f['default_value']);
307
-		        }
308
-		    }
305
+				} else {
306
+					$f['default_value'] = reset($f['default_value']);
307
+				}
308
+			}
309 309
 
310 310
 			self::maybe_update_in_section_variable( $in_section, $f );
311 311
 			self::maybe_update_form_select( $f, $imported );
@@ -368,12 +368,12 @@  discard block
 block discarded – undo
368 368
 	}
369 369
 
370 370
 	/**
371
-	* Switch the form_select on a repeating field or embedded form if it needs to be switched
372
-	*
373
-	* @since 2.0.16
374
-	* @param array $f
375
-	* @param array $imported
376
-	*/
371
+	 * Switch the form_select on a repeating field or embedded form if it needs to be switched
372
+	 *
373
+	 * @since 2.0.16
374
+	 * @param array $f
375
+	 * @param array $imported
376
+	 */
377 377
 	private static function maybe_update_form_select( &$f, $imported ) {
378 378
 		if ( ! isset( $imported['forms'] ) ) {
379 379
 			return;
@@ -425,13 +425,13 @@  discard block
 block discarded – undo
425 425
 	}
426 426
 
427 427
 	/**
428
-	* Updates the custom style setting on import
429
-	* Convert the post slug to an ID
430
-	*
431
-	* @since 2.0.19
432
-	* @param array $form
433
-	*
434
-	*/
428
+	 * Updates the custom style setting on import
429
+	 * Convert the post slug to an ID
430
+	 *
431
+	 * @since 2.0.19
432
+	 * @param array $form
433
+	 *
434
+	 */
435 435
 	private static function update_custom_style_setting_on_import( &$form ) {
436 436
 		if ( ! isset( $form['options']['custom_style'] ) ) {
437 437
 			return;
@@ -485,16 +485,16 @@  discard block
 block discarded – undo
485 485
 	}
486 486
 
487 487
 	public static function import_xml_views( $views, $imported ) {
488
-        $imported['posts'] = array();
489
-        $form_action_type = FrmFormActionsController::$action_post_type;
488
+		$imported['posts'] = array();
489
+		$form_action_type = FrmFormActionsController::$action_post_type;
490 490
 
491
-        $post_types = array(
492
-            'frm_display' => 'views',
493
-            $form_action_type => 'actions',
494
-            'frm_styles'    => 'styles',
495
-        );
491
+		$post_types = array(
492
+			'frm_display' => 'views',
493
+			$form_action_type => 'actions',
494
+			'frm_styles'    => 'styles',
495
+		);
496 496
 
497
-        foreach ( $views as $item ) {
497
+		foreach ( $views as $item ) {
498 498
 			$post = array(
499 499
 				'post_title'    => (string) $item->title,
500 500
 				'post_name'     => (string) $item->post_name,
@@ -513,52 +513,52 @@  discard block
 block discarded – undo
513 513
 				'post_date'     => (string) $item->post_date,
514 514
 				'post_date_gmt' => (string) $item->post_date_gmt,
515 515
 				'ping_status'   => (string) $item->ping_status,
516
-                'postmeta'      => array(),
517
-                'tax_input'     => array(),
516
+				'postmeta'      => array(),
517
+				'tax_input'     => array(),
518 518
 			);
519 519
 
520
-            $old_id = $post['post_id'];
521
-            self::populate_post($post, $item, $imported);
520
+			$old_id = $post['post_id'];
521
+			self::populate_post($post, $item, $imported);
522 522
 
523 523
 			unset($item);
524 524
 
525 525
 			$post_id = false;
526
-            if ( $post['post_type'] == $form_action_type ) {
527
-                $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
526
+			if ( $post['post_type'] == $form_action_type ) {
527
+				$action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
528 528
 				if ( $action_control && is_object( $action_control ) ) {
529 529
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
530 530
 				}
531
-                unset($action_control);
532
-            } else if ( $post['post_type'] == 'frm_styles' ) {
533
-                // Properly encode post content before inserting the post
534
-                $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
535
-                $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
536
-
537
-                // Create/update post now
538
-                $post_id = wp_insert_post( $post );
539
-            } else {
540
-                // Create/update post now
541
-                $post_id = wp_insert_post( $post );
542
-            }
543
-
544
-            if ( ! is_numeric($post_id) ) {
545
-                continue;
546
-            }
547
-
548
-            self::update_postmeta($post, $post_id);
549
-
550
-            $this_type = 'posts';
531
+				unset($action_control);
532
+			} else if ( $post['post_type'] == 'frm_styles' ) {
533
+				// Properly encode post content before inserting the post
534
+				$post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
535
+				$post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
536
+
537
+				// Create/update post now
538
+				$post_id = wp_insert_post( $post );
539
+			} else {
540
+				// Create/update post now
541
+				$post_id = wp_insert_post( $post );
542
+			}
543
+
544
+			if ( ! is_numeric($post_id) ) {
545
+				continue;
546
+			}
547
+
548
+			self::update_postmeta($post, $post_id);
549
+
550
+			$this_type = 'posts';
551 551
 			if ( isset( $post_types[ $post['post_type'] ] ) ) {
552 552
 				$this_type = $post_types[ $post['post_type'] ];
553
-            }
553
+			}
554 554
 
555
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
556
-                $imported['updated'][ $this_type ]++;
557
-            } else {
558
-                $imported['imported'][ $this_type ]++;
559
-            }
555
+			if ( isset($post['ID']) && $post_id == $post['ID'] ) {
556
+				$imported['updated'][ $this_type ]++;
557
+			} else {
558
+				$imported['imported'][ $this_type ]++;
559
+			}
560 560
 
561
-            unset($post);
561
+			unset($post);
562 562
 
563 563
 			$imported['posts'][ (int) $old_id ] = $post_id;
564 564
 		}
@@ -566,16 +566,16 @@  discard block
 block discarded – undo
566 566
 		self::maybe_update_stylesheet( $imported );
567 567
 
568 568
 		return $imported;
569
-    }
569
+	}
570 570
 
571
-    private static function populate_post( &$post, $item, $imported ) {
571
+	private static function populate_post( &$post, $item, $imported ) {
572 572
 		if ( isset($item->attachment_url) ) {
573 573
 			$post['attachment_url'] = (string) $item->attachment_url;
574 574
 		}
575 575
 
576 576
 		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
577
-		    // update to new form id
578
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
577
+			// update to new form id
578
+			$post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
579 579
 		}
580 580
 
581 581
 		// Don't allow default styles to take over a site's default style
@@ -584,144 +584,144 @@  discard block
 block discarded – undo
584 584
 		}
585 585
 
586 586
 		foreach ( $item->postmeta as $meta ) {
587
-		    self::populate_postmeta($post, $meta, $imported);
587
+			self::populate_postmeta($post, $meta, $imported);
588 588
 			unset($meta);
589 589
 		}
590 590
 
591
-        self::populate_taxonomies($post, $item);
591
+		self::populate_taxonomies($post, $item);
592 592
 
593
-        self::maybe_editing_post($post);
594
-    }
593
+		self::maybe_editing_post($post);
594
+	}
595 595
 
596
-    private static function populate_postmeta( &$post, $meta, $imported ) {
597
-        global $frm_duplicate_ids;
596
+	private static function populate_postmeta( &$post, $meta, $imported ) {
597
+		global $frm_duplicate_ids;
598 598
 
599
-	    $m = array(
599
+		$m = array(
600 600
 			'key'   => (string) $meta->meta_key,
601 601
 			'value' => (string) $meta->meta_value,
602 602
 		);
603 603
 
604 604
 		//switch old form and field ids to new ones
605 605
 		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
606
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
606
+			$m['value'] = $imported['forms'][ (int) $m['value'] ];
607 607
 		} else {
608
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
608
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
609 609
 
610
-		    if ( ! empty($frm_duplicate_ids) ) {
610
+			if ( ! empty($frm_duplicate_ids) ) {
611 611
 
612
-		        if ( $m['key'] == 'frm_dyncontent' ) {
613
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
614
-    		    } else if ( $m['key'] == 'frm_options' ) {
612
+				if ( $m['key'] == 'frm_dyncontent' ) {
613
+					$m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
614
+				} else if ( $m['key'] == 'frm_options' ) {
615 615
 
616 616
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
617 617
 						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
618 618
 							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
619
-    		            }
620
-    		        }
621
-
622
-                    $check_dup_array = array();
623
-    		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
624
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
625
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
626
-    		            } else if ( is_array( $m['value']['order_by'] ) ) {
627
-                            $check_dup_array[] = 'order_by';
628
-    		            }
629
-    		        }
630
-
631
-    		        if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
632
-    		            $check_dup_array[] = 'where';
633
-    		        }
634
-
635
-                    foreach ( $check_dup_array as $check_k ) {
619
+						}
620
+					}
621
+
622
+					$check_dup_array = array();
623
+					if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
624
+						if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
625
+							$m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
626
+						} else if ( is_array( $m['value']['order_by'] ) ) {
627
+							$check_dup_array[] = 'order_by';
628
+						}
629
+					}
630
+
631
+					if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
632
+						$check_dup_array[] = 'where';
633
+					}
634
+
635
+					foreach ( $check_dup_array as $check_k ) {
636 636
 						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
637 637
 							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
638 638
 								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
639
-		                    }
640
-		                    unset($mk, $mv);
641
-		                }
642
-                    }
643
-    		    }
644
-		    }
639
+							}
640
+							unset($mk, $mv);
641
+						}
642
+					}
643
+				}
644
+			}
645 645
 		}
646 646
 
647 647
 		if ( ! is_array($m['value']) ) {
648
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
648
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
649 649
 		}
650 650
 
651 651
 		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
652
-    }
653
-
654
-    /**
655
-     * Add terms to post
656
-     * @param array $post by reference
657
-     * @param object $item The XML object data
658
-     */
659
-    private static function populate_taxonomies( &$post, $item ) {
652
+	}
653
+
654
+	/**
655
+	 * Add terms to post
656
+	 * @param array $post by reference
657
+	 * @param object $item The XML object data
658
+	 */
659
+	private static function populate_taxonomies( &$post, $item ) {
660 660
 		foreach ( $item->category as $c ) {
661 661
 			$att = $c->attributes();
662 662
 			if ( ! isset( $att['nicename'] ) ) {
663
-                continue;
664
-            }
665
-
666
-		    $taxonomy = (string) $att['domain'];
667
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
668
-		        $name = (string) $att['nicename'];
669
-		        $h_term = get_term_by('slug', $name, $taxonomy);
670
-		        if ( $h_term ) {
671
-		            $name = $h_term->term_id;
672
-		        }
673
-		        unset($h_term);
674
-		    } else {
675
-		        $name = (string) $c;
676
-		    }
663
+				continue;
664
+			}
665
+
666
+			$taxonomy = (string) $att['domain'];
667
+			if ( is_taxonomy_hierarchical($taxonomy) ) {
668
+				$name = (string) $att['nicename'];
669
+				$h_term = get_term_by('slug', $name, $taxonomy);
670
+				if ( $h_term ) {
671
+					$name = $h_term->term_id;
672
+				}
673
+				unset($h_term);
674
+			} else {
675
+				$name = (string) $c;
676
+			}
677 677
 
678 678
 			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
679 679
 				$post['tax_input'][ $taxonomy ] = array();
680 680
 			}
681 681
 
682 682
 			$post['tax_input'][ $taxonomy ][] = $name;
683
-		    unset($name);
683
+			unset($name);
684 684
 		}
685
-    }
685
+	}
686 686
 
687
-    /**
688
-     * Edit post if the key and created time match
689
-     */
690
-    private static function maybe_editing_post( &$post ) {
687
+	/**
688
+	 * Edit post if the key and created time match
689
+	 */
690
+	private static function maybe_editing_post( &$post ) {
691 691
 		$match_by = array(
692
-		    'post_type'     => $post['post_type'],
693
-		    'name'          => $post['post_name'],
694
-		    'post_status'   => $post['post_status'],
695
-		    'posts_per_page' => 1,
692
+			'post_type'     => $post['post_type'],
693
+			'name'          => $post['post_name'],
694
+			'post_status'   => $post['post_status'],
695
+			'posts_per_page' => 1,
696 696
 		);
697 697
 
698 698
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
699
-		    $match_by['include'] = $post['post_id'];
700
-		    unset($match_by['name']);
699
+			$match_by['include'] = $post['post_id'];
700
+			unset($match_by['name']);
701 701
 		}
702 702
 
703 703
 		$editing = get_posts($match_by);
704 704
 
705
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
706
-            // set the id of the post to edit
707
-            $post['ID'] = current($editing)->ID;
708
-        }
709
-    }
705
+		if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
706
+			// set the id of the post to edit
707
+			$post['ID'] = current($editing)->ID;
708
+		}
709
+	}
710 710
 
711
-    private static function update_postmeta( &$post, $post_id ) {
712
-        foreach ( $post['postmeta'] as $k => $v ) {
713
-            if ( '_edit_last' == $k ) {
714
-                $v = FrmAppHelper::get_user_id_param($v);
715
-            } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
716
-                //change the attachment ID
717
-                $v = FrmProXMLHelper::get_file_id($v);
718
-            }
711
+	private static function update_postmeta( &$post, $post_id ) {
712
+		foreach ( $post['postmeta'] as $k => $v ) {
713
+			if ( '_edit_last' == $k ) {
714
+				$v = FrmAppHelper::get_user_id_param($v);
715
+			} else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
716
+				//change the attachment ID
717
+				$v = FrmProXMLHelper::get_file_id($v);
718
+			}
719 719
 
720
-            update_post_meta($post_id, $k, $v);
720
+			update_post_meta($post_id, $k, $v);
721 721
 
722
-            unset($k, $v);
723
-        }
724
-    }
722
+			unset($k, $v);
723
+		}
724
+	}
725 725
 
726 726
 	private static function maybe_update_stylesheet( $imported ) {
727 727
 		$new_styles = isset( $imported['imported']['styles'] ) && ! empty( $imported['imported']['styles'] );
@@ -737,72 +737,72 @@  discard block
 block discarded – undo
737 737
 		}
738 738
 	}
739 739
 
740
-    /**
741
-     * @param string $message
742
-     */
740
+	/**
741
+	 * @param string $message
742
+	 */
743 743
 	public static function parse_message( $result, &$message, &$errors ) {
744
-        if ( is_wp_error($result) ) {
745
-            $errors[] = $result->get_error_message();
746
-        } else if ( ! $result ) {
747
-            return;
748
-        }
749
-
750
-        if ( ! is_array($result) ) {
751
-            $message = is_string( $result ) ? $result : print_r( $result, 1 );
752
-            return;
753
-        }
754
-
755
-        $t_strings = array(
756
-            'imported'  => __( 'Imported', 'formidable' ),
757
-            'updated'   => __( 'Updated', 'formidable' ),
758
-        );
759
-
760
-        $message = '<ul>';
761
-        foreach ( $result as $type => $results ) {
744
+		if ( is_wp_error($result) ) {
745
+			$errors[] = $result->get_error_message();
746
+		} else if ( ! $result ) {
747
+			return;
748
+		}
749
+
750
+		if ( ! is_array($result) ) {
751
+			$message = is_string( $result ) ? $result : print_r( $result, 1 );
752
+			return;
753
+		}
754
+
755
+		$t_strings = array(
756
+			'imported'  => __( 'Imported', 'formidable' ),
757
+			'updated'   => __( 'Updated', 'formidable' ),
758
+		);
759
+
760
+		$message = '<ul>';
761
+		foreach ( $result as $type => $results ) {
762 762
 			if ( ! isset( $t_strings[ $type ] ) ) {
763
-                // only print imported and updated
764
-                continue;
765
-            }
763
+				// only print imported and updated
764
+				continue;
765
+			}
766 766
 
767
-            $s_message = array();
768
-            foreach ( $results as $k => $m ) {
769
-                self::item_count_message($m, $k, $s_message);
770
-                unset($k, $m);
771
-            }
767
+			$s_message = array();
768
+			foreach ( $results as $k => $m ) {
769
+				self::item_count_message($m, $k, $s_message);
770
+				unset($k, $m);
771
+			}
772 772
 
773
-            if ( ! empty($s_message) ) {
773
+			if ( ! empty($s_message) ) {
774 774
 				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
775
-                $message .= implode(', ', $s_message);
776
-                $message .= '</li>';
777
-            }
778
-        }
779
-
780
-        if ( $message == '<ul>' ) {
781
-            $message = '';
782
-            $errors[] = __( 'Nothing was imported or updated', 'formidable' );
783
-        } else {
784
-            $message .= '</ul>';
785
-        }
786
-    }
775
+				$message .= implode(', ', $s_message);
776
+				$message .= '</li>';
777
+			}
778
+		}
779
+
780
+		if ( $message == '<ul>' ) {
781
+			$message = '';
782
+			$errors[] = __( 'Nothing was imported or updated', 'formidable' );
783
+		} else {
784
+			$message .= '</ul>';
785
+		}
786
+	}
787 787
 
788 788
 	public static function item_count_message( $m, $type, &$s_message ) {
789
-        if ( ! $m ) {
790
-            return;
791
-        }
792
-
793
-        $strings = array(
794
-            'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
795
-            'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
796
-            'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
797
-            'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
798
-            'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
799
-            'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
800
-            'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
801
-            'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
802
-        );
789
+		if ( ! $m ) {
790
+			return;
791
+		}
792
+
793
+		$strings = array(
794
+			'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
795
+			'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
796
+			'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
797
+			'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
798
+			'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
799
+			'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
800
+			'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
801
+			'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
802
+		);
803 803
 
804 804
 		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
805
-    }
805
+	}
806 806
 
807 807
 	/**
808 808
 	 * Prepare the form options for export
@@ -833,16 +833,16 @@  discard block
 block discarded – undo
833 833
 	}
834 834
 
835 835
 	public static function cdata( $str ) {
836
-	    $str = maybe_unserialize($str);
837
-	    if ( is_array($str) ) {
838
-	        $str = json_encode($str);
836
+		$str = maybe_unserialize($str);
837
+		if ( is_array($str) ) {
838
+			$str = json_encode($str);
839 839
 		} else if ( seems_utf8( $str ) == false ) {
840 840
 			$str = utf8_encode( $str );
841 841
 		}
842 842
 
843
-        if ( is_numeric($str) ) {
844
-            return $str;
845
-        }
843
+		if ( is_numeric($str) ) {
844
+			return $str;
845
+		}
846 846
 
847 847
 		self::remove_invalid_characters_from_xml( $str );
848 848
 
@@ -863,58 +863,58 @@  discard block
 block discarded – undo
863 863
 		$str = str_replace( '\x1F', '', $str );
864 864
 	}
865 865
 
866
-    public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
867
-        // Get post type
868
-        $post_type = FrmFormActionsController::$action_post_type;
869
-
870
-        // Set up imported index, if not set up yet
871
-        if ( ! isset( $imported['imported']['actions'] ) ) {
872
-            $imported['imported']['actions'] = 0;
873
-        }
874
-
875
-        // Migrate post settings to action
876
-        self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
877
-
878
-        // Migrate email settings to action
879
-        self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
880
-    }
881
-
882
-    /**
883
-    * Migrate post settings to form action
884
-    *
885
-    * @param string $post_type
886
-    */
887
-    private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
888
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
889
-            return;
890
-        }
891
-
892
-        $new_action = array(
893
-            'post_type'     => $post_type,
894
-            'post_excerpt'  => 'wppost',
866
+	public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
867
+		// Get post type
868
+		$post_type = FrmFormActionsController::$action_post_type;
869
+
870
+		// Set up imported index, if not set up yet
871
+		if ( ! isset( $imported['imported']['actions'] ) ) {
872
+			$imported['imported']['actions'] = 0;
873
+		}
874
+
875
+		// Migrate post settings to action
876
+		self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
877
+
878
+		// Migrate email settings to action
879
+		self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
880
+	}
881
+
882
+	/**
883
+	 * Migrate post settings to form action
884
+	 *
885
+	 * @param string $post_type
886
+	 */
887
+	private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
888
+		if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
889
+			return;
890
+		}
891
+
892
+		$new_action = array(
893
+			'post_type'     => $post_type,
894
+			'post_excerpt'  => 'wppost',
895 895
 			'post_title'    => __( 'Create Posts', 'formidable' ),
896
-            'menu_order'    => $form_id,
897
-            'post_status'   => 'publish',
898
-            'post_content'  => array(),
896
+			'menu_order'    => $form_id,
897
+			'post_status'   => 'publish',
898
+			'post_content'  => array(),
899 899
 			'post_name'     => $form_id . '_wppost_1',
900
-        );
900
+		);
901 901
 
902
-        $post_settings = array(
903
-            'post_type', 'post_category', 'post_content',
904
-            'post_excerpt', 'post_title', 'post_name', 'post_date',
902
+		$post_settings = array(
903
+			'post_type', 'post_category', 'post_content',
904
+			'post_excerpt', 'post_title', 'post_name', 'post_date',
905 905
 			'post_status', 'post_custom_fields', 'post_password',
906
-        );
906
+		);
907 907
 
908
-        foreach ( $post_settings as $post_setting ) {
908
+		foreach ( $post_settings as $post_setting ) {
909 909
 			if ( isset( $form_options[ $post_setting ] ) ) {
910 910
 				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
911
-            }
912
-            unset($post_setting);
913
-        }
911
+			}
912
+			unset($post_setting);
913
+		}
914 914
 
915 915
 		$new_action['event'] = array( 'create', 'update' );
916 916
 
917
-        if ( $switch ) {
917
+		if ( $switch ) {
918 918
 			// Fields with string or int saved
919 919
 			$basic_fields = array( 'post_title', 'post_content', 'post_excerpt', 'post_password', 'post_date', 'post_status' );
920 920
 
@@ -922,22 +922,22 @@  discard block
 block discarded – undo
922 922
 			$array_fields = array( 'post_category', 'post_custom_fields' );
923 923
 
924 924
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
925
-        }
926
-        $new_action['post_content'] = json_encode($new_action['post_content']);
925
+		}
926
+		$new_action['post_content'] = json_encode($new_action['post_content']);
927 927
 
928
-        $exists = get_posts( array(
929
-            'name'          => $new_action['post_name'],
930
-            'post_type'     => $new_action['post_type'],
931
-            'post_status'   => $new_action['post_status'],
932
-            'numberposts'   => 1,
933
-        ) );
928
+		$exists = get_posts( array(
929
+			'name'          => $new_action['post_name'],
930
+			'post_type'     => $new_action['post_type'],
931
+			'post_status'   => $new_action['post_status'],
932
+			'numberposts'   => 1,
933
+		) );
934 934
 
935
-        if ( ! $exists ) {
935
+		if ( ! $exists ) {
936 936
 			// this isn't an email, but we need to use a class that will always be included
937 937
 			FrmAppHelper::save_json_post( $new_action );
938
-            $imported['imported']['actions']++;
939
-        }
940
-    }
938
+			$imported['imported']['actions']++;
939
+		}
940
+	}
941 941
 
942 942
 	/**
943 943
 	 * Switch old field IDs for new field IDs in emails and post
@@ -950,211 +950,211 @@  discard block
 block discarded – undo
950 950
 	 * @return string $post_content - new field IDs
951 951
 	 */
952 952
 	private static function switch_action_field_ids( $post_content, $basic_fields, $array_fields = array() ) {
953
-        global $frm_duplicate_ids;
953
+		global $frm_duplicate_ids;
954 954
 
955
-        // If there aren't IDs that were switched, end now
956
-        if ( ! $frm_duplicate_ids ) {
957
-            return;
958
-        }
955
+		// If there aren't IDs that were switched, end now
956
+		if ( ! $frm_duplicate_ids ) {
957
+			return;
958
+		}
959 959
 
960
-        // Get old IDs
961
-        $old = array_keys( $frm_duplicate_ids );
960
+		// Get old IDs
961
+		$old = array_keys( $frm_duplicate_ids );
962 962
 
963
-        // Get new IDs
964
-        $new = array_values( $frm_duplicate_ids );
963
+		// Get new IDs
964
+		$new = array_values( $frm_duplicate_ids );
965 965
 
966
-        // Do a str_replace with each item to set the new IDs
967
-        foreach ( $post_content as $key => $setting ) {
968
-            if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
969
-                // Replace old IDs with new IDs
966
+		// Do a str_replace with each item to set the new IDs
967
+		foreach ( $post_content as $key => $setting ) {
968
+			if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
969
+				// Replace old IDs with new IDs
970 970
 				$post_content[ $key ] = str_replace( $old, $new, $setting );
971
-            } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
972
-                foreach ( $setting as $k => $val ) {
973
-                    // Replace old IDs with new IDs
971
+			} else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
972
+				foreach ( $setting as $k => $val ) {
973
+					// Replace old IDs with new IDs
974 974
 					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
975
-                }
976
-            }
977
-            unset( $key, $setting );
978
-        }
979
-        return $post_content;
980
-    }
981
-
982
-    private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
983
-        // No old notifications or autoresponders to carry over
975
+				}
976
+			}
977
+			unset( $key, $setting );
978
+		}
979
+		return $post_content;
980
+	}
981
+
982
+	private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
983
+		// No old notifications or autoresponders to carry over
984 984
 		if ( ! isset( $form_options['auto_responder'] ) && ! isset( $form_options['notification'] ) && ! isset( $form_options['email_to'] ) ) {
985
-            return;
986
-        }
985
+			return;
986
+		}
987 987
 
988
-        // Initialize notifications array
989
-        $notifications = array();
988
+		// Initialize notifications array
989
+		$notifications = array();
990 990
 
991
-        // Migrate regular notifications
992
-        self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
991
+		// Migrate regular notifications
992
+		self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
993 993
 
994
-        // Migrate autoresponders
995
-        self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
994
+		// Migrate autoresponders
995
+		self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
996 996
 
997
-        if (  empty( $notifications ) ) {
998
-            return;
999
-        }
997
+		if (  empty( $notifications ) ) {
998
+			return;
999
+		}
1000 1000
 
1001
-        foreach ( $notifications as $new_notification ) {
1002
-            $new_notification['post_type']      = $post_type;
1003
-            $new_notification['post_excerpt']   = 'email';
1001
+		foreach ( $notifications as $new_notification ) {
1002
+			$new_notification['post_type']      = $post_type;
1003
+			$new_notification['post_excerpt']   = 'email';
1004 1004
 			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
1005
-            $new_notification['menu_order']     = $form_id;
1006
-            $new_notification['post_status']    = 'publish';
1005
+			$new_notification['menu_order']     = $form_id;
1006
+			$new_notification['post_status']    = 'publish';
1007 1007
 
1008
-            // Switch field IDs and keys, if needed
1009
-            if ( $switch ) {
1008
+			// Switch field IDs and keys, if needed
1009
+			if ( $switch ) {
1010 1010
 
1011 1011
 				// Switch field IDs in email conditional logic
1012 1012
 				self::switch_email_contition_field_ids( $new_notification['post_content'] );
1013 1013
 
1014 1014
 				// Switch all other field IDs in email
1015
-                $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1016
-            }
1017
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1018
-
1019
-            $exists = get_posts( array(
1020
-                'name'          => $new_notification['post_name'],
1021
-                'post_type'     => $new_notification['post_type'],
1022
-                'post_status'   => $new_notification['post_status'],
1023
-                'numberposts'   => 1,
1024
-            ) );
1025
-
1026
-            if ( empty($exists) ) {
1015
+				$new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1016
+			}
1017
+			$new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1018
+
1019
+			$exists = get_posts( array(
1020
+				'name'          => $new_notification['post_name'],
1021
+				'post_type'     => $new_notification['post_type'],
1022
+				'post_status'   => $new_notification['post_status'],
1023
+				'numberposts'   => 1,
1024
+			) );
1025
+
1026
+			if ( empty($exists) ) {
1027 1027
 				FrmAppHelper::save_json_post( $new_notification );
1028
-                $imported['imported']['actions']++;
1029
-            }
1030
-            unset($new_notification);
1031
-        }
1032
-    }
1033
-
1034
-    private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
1035
-        if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
1036
-            // add old settings into notification array
1028
+				$imported['imported']['actions']++;
1029
+			}
1030
+			unset($new_notification);
1031
+		}
1032
+	}
1033
+
1034
+	private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
1035
+		if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
1036
+			// add old settings into notification array
1037 1037
 			$form_options['notification'] = array( 0 => $form_options );
1038
-        } else if ( isset( $form_options['notification']['email_to'] ) ) {
1039
-            // make sure it's in the correct format
1038
+		} else if ( isset( $form_options['notification']['email_to'] ) ) {
1039
+			// make sure it's in the correct format
1040 1040
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
1041
-        }
1041
+		}
1042 1042
 
1043
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1044
-            foreach ( $form_options['notification'] as $email_key => $notification ) {
1043
+		if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1044
+			foreach ( $form_options['notification'] as $email_key => $notification ) {
1045 1045
 
1046
-                $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
1046
+				$atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
1047 1047
 
1048
-                // Format the email data
1049
-                self::format_email_data( $atts, $notification );
1048
+				// Format the email data
1049
+				self::format_email_data( $atts, $notification );
1050 1050
 
1051 1051
 				if ( isset( $notification['twilio'] ) && $notification['twilio'] ) {
1052 1052
 					do_action( 'frm_create_twilio_action', $atts, $notification );
1053 1053
 				}
1054 1054
 
1055
-                // Setup the new notification
1056
-                $new_notification = array();
1057
-                self::setup_new_notification( $new_notification, $notification, $atts );
1055
+				// Setup the new notification
1056
+				$new_notification = array();
1057
+				self::setup_new_notification( $new_notification, $notification, $atts );
1058 1058
 
1059
-                $notifications[] = $new_notification;
1060
-            }
1061
-        }
1062
-    }
1059
+				$notifications[] = $new_notification;
1060
+			}
1061
+		}
1062
+	}
1063 1063
 
1064
-    private static function format_email_data( &$atts, $notification ) {
1065
-        // Format email_to
1066
-        self::format_email_to_data( $atts, $notification );
1064
+	private static function format_email_data( &$atts, $notification ) {
1065
+		// Format email_to
1066
+		self::format_email_to_data( $atts, $notification );
1067 1067
 
1068
-        // Format the reply to email and name
1069
-        $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
1070
-        foreach ( $reply_fields as $f => $val ) {
1068
+		// Format the reply to email and name
1069
+		$reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
1070
+		foreach ( $reply_fields as $f => $val ) {
1071 1071
 			if ( isset( $notification[ $f ] ) ) {
1072 1072
 				$atts[ $f ] = $notification[ $f ];
1073 1073
 				if ( 'custom' == $notification[ $f ] ) {
1074 1074
 					$atts[ $f ] = $notification[ 'cust_' . $f ];
1075 1075
 				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
1076 1076
 					$atts[ $f ] = '[' . $atts[ $f ] . ']';
1077
-                }
1078
-            }
1079
-            unset( $f, $val );
1080
-        }
1077
+				}
1078
+			}
1079
+			unset( $f, $val );
1080
+		}
1081 1081
 
1082
-        // Format event
1082
+		// Format event
1083 1083
 		$atts['event'] = array( 'create' );
1084
-        if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1085
-            $atts['event'][] = 'update';
1086
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1084
+		if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1085
+			$atts['event'][] = 'update';
1086
+		} else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1087 1087
 			$atts['event'] = array( 'update' );
1088
-        }
1089
-    }
1088
+		}
1089
+	}
1090 1090
 
1091
-    private static function format_email_to_data( &$atts, $notification ) {
1092
-        if ( isset( $notification['email_to'] ) ) {
1091
+	private static function format_email_to_data( &$atts, $notification ) {
1092
+		if ( isset( $notification['email_to'] ) ) {
1093 1093
 			$atts['email_to'] = preg_split( '/ (,|;) /', $notification['email_to'] );
1094
-        } else {
1095
-            $atts['email_to'] = array();
1096
-        }
1094
+		} else {
1095
+			$atts['email_to'] = array();
1096
+		}
1097 1097
 
1098
-        if ( isset( $notification['also_email_to'] ) ) {
1099
-            $email_fields = (array) $notification['also_email_to'];
1100
-            $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1101
-            unset( $email_fields );
1102
-        }
1098
+		if ( isset( $notification['also_email_to'] ) ) {
1099
+			$email_fields = (array) $notification['also_email_to'];
1100
+			$atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1101
+			unset( $email_fields );
1102
+		}
1103 1103
 
1104
-        foreach ( $atts['email_to'] as $key => $email_field ) {
1104
+		foreach ( $atts['email_to'] as $key => $email_field ) {
1105 1105
 
1106
-            if ( is_numeric( $email_field ) ) {
1106
+			if ( is_numeric( $email_field ) ) {
1107 1107
 				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1108
-            }
1108
+			}
1109 1109
 
1110
-            if ( strpos( $email_field, '|') ) {
1111
-                $email_opt = explode( '|', $email_field );
1112
-                if ( isset( $email_opt[0] ) ) {
1110
+			if ( strpos( $email_field, '|') ) {
1111
+				$email_opt = explode( '|', $email_field );
1112
+				if ( isset( $email_opt[0] ) ) {
1113 1113
 					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1114
-                }
1115
-                unset( $email_opt );
1116
-            }
1117
-        }
1118
-        $atts['email_to'] = implode(', ', $atts['email_to']);
1119
-    }
1120
-
1121
-    private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1122
-        // Set up new notification
1123
-        $new_notification = array(
1124
-            'post_content'  => array(
1125
-                'email_to'      => $atts['email_to'],
1126
-                'event'         => $atts['event'],
1127
-            ),
1114
+				}
1115
+				unset( $email_opt );
1116
+			}
1117
+		}
1118
+		$atts['email_to'] = implode(', ', $atts['email_to']);
1119
+	}
1120
+
1121
+	private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1122
+		// Set up new notification
1123
+		$new_notification = array(
1124
+			'post_content'  => array(
1125
+				'email_to'      => $atts['email_to'],
1126
+				'event'         => $atts['event'],
1127
+			),
1128 1128
 			'post_name'         => $atts['form_id'] . '_email_' . $atts['email_key'],
1129
-        );
1129
+		);
1130 1130
 
1131
-        // Add more fields to the new notification
1132
-        $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1133
-        foreach ( $add_fields as $add_field ) {
1131
+		// Add more fields to the new notification
1132
+		$add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1133
+		foreach ( $add_fields as $add_field ) {
1134 1134
 			if ( isset( $notification[ $add_field ] ) ) {
1135 1135
 				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1136
-            } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1136
+			} else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1137 1137
 				$new_notification['post_content'][ $add_field ] = 0;
1138
-            } else {
1138
+			} else {
1139 1139
 				$new_notification['post_content'][ $add_field ] = '';
1140
-            }
1141
-            unset( $add_field );
1142
-        }
1140
+			}
1141
+			unset( $add_field );
1142
+		}
1143 1143
 
1144 1144
 		// Set reply to
1145 1145
 		$new_notification['post_content']['reply_to'] = $atts['reply_to'];
1146 1146
 
1147
-        // Set from
1147
+		// Set from
1148 1148
 		if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) {
1149 1149
 			$new_notification['post_content']['from'] = ( empty( $atts['reply_to_name'] ) ? '[sitename]' : $atts['reply_to_name'] ) . ' <' . ( empty( $atts['reply_to'] ) ? '[admin_email]' : $atts['reply_to'] ) . '>';
1150
-        }
1151
-    }
1150
+		}
1151
+	}
1152 1152
 
1153 1153
 	/**
1154
-	* Switch field IDs in pre-2.0 email conditional logic
1155
-	*
1156
-	* @param $post_content array, pass by reference
1157
-	*/
1154
+	 * Switch field IDs in pre-2.0 email conditional logic
1155
+	 *
1156
+	 * @param $post_content array, pass by reference
1157
+	 */
1158 1158
 	private static function switch_email_contition_field_ids( &$post_content ) {
1159 1159
 		// Switch field IDs in conditional logic
1160 1160
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
@@ -1167,36 +1167,36 @@  discard block
 block discarded – undo
1167 1167
 		}
1168 1168
 	}
1169 1169
 
1170
-    private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1171
-        if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1172
-            // migrate autoresponder
1173
-
1174
-            $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1175
-            if ( strpos($email_field, '|') ) {
1176
-                // data from entries field
1177
-                $email_field = explode('|', $email_field);
1178
-                if ( isset($email_field[1]) ) {
1179
-                    $email_field = $email_field[1];
1180
-                }
1181
-            }
1182
-            if ( is_numeric($email_field) && ! empty($email_field) ) {
1170
+	private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1171
+		if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1172
+			// migrate autoresponder
1173
+
1174
+			$email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1175
+			if ( strpos($email_field, '|') ) {
1176
+				// data from entries field
1177
+				$email_field = explode('|', $email_field);
1178
+				if ( isset($email_field[1]) ) {
1179
+					$email_field = $email_field[1];
1180
+				}
1181
+			}
1182
+			if ( is_numeric($email_field) && ! empty($email_field) ) {
1183 1183
 				$email_field = '[' . $email_field . ']';
1184
-            }
1185
-
1186
-            $notification = $form_options;
1187
-            $new_notification2 = array(
1188
-                'post_content'  => array(
1189
-                    'email_message' => $notification['ar_email_message'],
1190
-                    'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1191
-                    'email_to'      => $email_field,
1192
-                    'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1193
-                    'inc_user_info' => 0,
1194
-                ),
1184
+			}
1185
+
1186
+			$notification = $form_options;
1187
+			$new_notification2 = array(
1188
+				'post_content'  => array(
1189
+					'email_message' => $notification['ar_email_message'],
1190
+					'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1191
+					'email_to'      => $email_field,
1192
+					'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1193
+					'inc_user_info' => 0,
1194
+				),
1195 1195
 				'post_name'     => $form_id . '_email_' . count( $notifications ),
1196
-            );
1196
+			);
1197 1197
 
1198
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1199
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1198
+			$reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1199
+			$reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1200 1200
 
1201 1201
 			if ( ! empty( $reply_to ) ) {
1202 1202
 				$new_notification2['post_content']['reply_to'] = $reply_to;
@@ -1206,9 +1206,9 @@  discard block
 block discarded – undo
1206 1206
 				$new_notification2['post_content']['from'] = ( empty( $reply_to_name ) ? '[sitename]' : $reply_to_name ) . ' <' . ( empty( $reply_to ) ? '[admin_email]' : $reply_to ) . '>';
1207 1207
 			}
1208 1208
 
1209
-            $notifications[] = $new_notification2;
1210
-            unset( $new_notification2 );
1211
-        }
1212
-    }
1209
+			$notifications[] = $new_notification2;
1210
+			unset( $new_notification2 );
1211
+		}
1212
+	}
1213 1213
 }
1214 1214
 
Please login to merge, or discard this patch.
Spacing   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 			'terms'    => array(),
37 37
         );
38 38
 
39
-        unset($defaults);
39
+        unset( $defaults );
40 40
 
41 41
 		if ( ! defined( 'WP_IMPORTING' ) ) {
42
-            define('WP_IMPORTING', true);
42
+            define( 'WP_IMPORTING', true );
43 43
         }
44 44
 
45 45
 		if ( ! class_exists( 'DOMDocument' ) ) {
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
53 53
 		}
54 54
 
55
-		if ( ! function_exists('simplexml_import_dom') ) {
55
+		if ( ! function_exists( 'simplexml_import_dom' ) ) {
56 56
 			return new WP_Error( 'SimpleXML_parse_error', __( 'Your server is missing the simplexml_import_dom function', 'formidable' ), libxml_get_errors() );
57 57
 		}
58 58
 
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
         // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
68 68
 		foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
69 69
             // grab cats, tags, and terms, or forms or posts
70
-            if ( isset($xml->{$item_type} ) ) {
70
+            if ( isset( $xml->{$item_type} ) ) {
71 71
 				$function_name = 'import_xml_' . $item_type . 's';
72 72
 				$imported = self::$function_name( $xml->{$item_type}, $imported );
73 73
 				unset( $function_name, $xml->{$item_type} );
74 74
             }
75 75
         }
76 76
 
77
-	    $return = apply_filters('frm_importing_xml', $imported, $xml );
77
+	    $return = apply_filters( 'frm_importing_xml', $imported, $xml );
78 78
 
79 79
 	    return $return;
80 80
     }
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
                 'slug'          => (string) $t->term_slug,
92 92
                 'description'   => (string) $t->term_description,
93 93
 				'parent'        => empty( $parent ) ? 0 : $parent,
94
-            ));
94
+            ) );
95 95
 
96 96
 			if ( $term && is_array( $term ) ) {
97
-                $imported['imported']['terms']++;
98
-				$imported['terms'][ (int) $t->term_id ] = $term['term_id'];
97
+                $imported['imported']['terms'] ++;
98
+				$imported['terms'][(int) $t->term_id] = $term['term_id'];
99 99
             }
100 100
 
101 101
 			unset( $term, $t );
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
                 'default_template' => (int) $item->default_template,
139 139
                 'editable'      => (int) $item->editable,
140 140
                 'status'        => (string) $item->status,
141
-                'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0,
141
+                'parent_form_id' => isset( $item->parent_form_id ) ? (int) $item->parent_form_id : 0,
142 142
                 'created_at'    => date( 'Y-m-d H:i:s', strtotime( (string) $item->created_at ) ),
143 143
             );
144 144
 
145
-            $form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
145
+            $form['options'] = FrmAppHelper::maybe_json_decode( $form['options'] );
146 146
 
147 147
 			self::update_custom_style_setting_on_import( $form );
148 148
 
@@ -152,35 +152,35 @@  discard block
 block discarded – undo
152 152
                 $edit_query['created_at'] = $form['created_at'];
153 153
             }
154 154
 
155
-            $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
155
+            $edit_query = apply_filters( 'frm_match_xml_form', $edit_query, $form );
156 156
 
157
-            $this_form = FrmForm::getAll($edit_query, '', 1);
158
-            unset($edit_query);
157
+            $this_form = FrmForm::getAll( $edit_query, '', 1 );
158
+            unset( $edit_query );
159 159
 
160 160
             if ( ! empty( $this_form ) ) {
161 161
                 $old_id = $form_id = $this_form->id;
162
-                FrmForm::update($form_id, $form );
163
-                $imported['updated']['forms']++;
162
+                FrmForm::update( $form_id, $form );
163
+                $imported['updated']['forms'] ++;
164 164
                 // Keep track of whether this specific form was updated or not
165
-				$imported['form_status'][ $form_id ] = 'updated';
165
+				$imported['form_status'][$form_id] = 'updated';
166 166
 
167 167
 				$form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' );
168 168
                 $old_fields = array();
169 169
                 foreach ( $form_fields as $f ) {
170
-					$old_fields[ $f->id ] = $f;
171
-					$old_fields[ $f->field_key ] = $f->id;
172
-                    unset($f);
170
+					$old_fields[$f->id] = $f;
171
+					$old_fields[$f->field_key] = $f->id;
172
+                    unset( $f );
173 173
                 }
174 174
                 $form_fields = $old_fields;
175
-                unset($old_fields);
175
+                unset( $old_fields );
176 176
             } else {
177 177
                 $old_id = false;
178 178
                 //form does not exist, so create it
179 179
 				$form_id = FrmForm::create( $form );
180 180
                 if ( $form_id ) {
181
-                    $imported['imported']['forms']++;
181
+                    $imported['imported']['forms'] ++;
182 182
                     // Keep track of whether this specific form was updated or not
183
-					$imported['form_status'][ $form_id ] = 'imported';
183
+					$imported['form_status'][$form_id] = 'imported';
184 184
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
185 185
                 }
186 186
             }
@@ -190,23 +190,23 @@  discard block
 block discarded – undo
190 190
     		// Delete any fields attached to this form that were not included in the template
191 191
     		if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
192 192
 				foreach ( $form_fields as $field ) {
193
-                    if ( is_object($field) ) {
194
-                        FrmField::destroy($field->id);
193
+                    if ( is_object( $field ) ) {
194
+                        FrmField::destroy( $field->id );
195 195
                     }
196
-                    unset($field);
196
+                    unset( $field );
197 197
                 }
198
-                unset($form_fields);
198
+                unset( $form_fields );
199 199
             }
200 200
 
201 201
 		    // Update field ids/keys to new ones
202 202
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
203 203
 
204
-			$imported['forms'][ (int) $item->id ] = $form_id;
204
+			$imported['forms'][(int) $item->id] = $form_id;
205 205
 
206 206
             // Send pre 2.0 form options through function that creates actions
207 207
             self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
208 208
 
209
-		    unset($form, $item);
209
+		    unset( $form, $item );
210 210
 		}
211 211
 
212 212
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 		$regular_forms = array();
226 226
 
227 227
 		foreach ( $forms as $form ) {
228
-			$parent_form_id = isset( $form->parent_form_id) ? (int) $form->parent_form_id : 0;
228
+			$parent_form_id = isset( $form->parent_form_id ) ? (int) $form->parent_form_id : 0;
229 229
 
230 230
 			if ( $parent_form_id ) {
231 231
 				$child_forms[] = $form;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	*/
248 248
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
249 249
 		if ( $parent_form_id ) {
250
-			$child_forms[ $form_id ] = $parent_form_id;
250
+			$child_forms[$form_id] = $parent_form_id;
251 251
 		}
252 252
 	}
253 253
 
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
263 263
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
264 264
 
265
-			if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) {
265
+			if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) {
266 266
 				// Update all children with this old parent_form_id
267
-				$new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ];
267
+				$new_parent_form_id = (int) $imported_forms[$old_parent_form_id];
268 268
 
269 269
 				FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) );
270 270
 			}
@@ -287,23 +287,23 @@  discard block
 block discarded – undo
287 287
 		        'name'          => (string) $field->name,
288 288
 		        'description'   => (string) $field->description,
289 289
 		        'type'          => (string) $field->type,
290
-		        'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
290
+		        'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value ),
291 291
 		        'field_order'   => (int) $field->field_order,
292 292
 		        'form_id'       => (int) $form_id,
293 293
 		        'required'      => (int) $field->required,
294
-		        'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
294
+		        'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options ),
295 295
 				'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
296 296
 		    );
297 297
 
298
-		    if ( is_array($f['default_value']) && in_array($f['type'], array(
298
+		    if ( is_array( $f['default_value'] ) && in_array( $f['type'], array(
299 299
 		        'text', 'email', 'url', 'textarea',
300
-		        'number','phone', 'date', 'time',
300
+		        'number', 'phone', 'date', 'time',
301 301
 		        'hidden', 'password', 'tag', 'image',
302
-		    )) ) {
303
-		        if ( count($f['default_value']) === 1 ) {
302
+		    ) ) ) {
303
+		        if ( count( $f['default_value'] ) === 1 ) {
304 304
 					$f['default_value'] = '[' . reset( $f['default_value'] ) . ']';
305 305
 		        } else {
306
-		            $f['default_value'] = reset($f['default_value']);
306
+		            $f['default_value'] = reset( $f['default_value'] );
307 307
 		        }
308 308
 		    }
309 309
 
@@ -311,27 +311,27 @@  discard block
 block discarded – undo
311 311
 			self::maybe_update_form_select( $f, $imported );
312 312
 			self::maybe_update_get_values_form_setting( $imported, $f );
313 313
 
314
-			if ( ! empty($this_form) ) {
314
+			if ( ! empty( $this_form ) ) {
315 315
 				// check for field to edit by field id
316
-				if ( isset( $form_fields[ $f['id'] ] ) ) {
316
+				if ( isset( $form_fields[$f['id']] ) ) {
317 317
 					FrmField::update( $f['id'], $f );
318
-					$imported['updated']['fields']++;
318
+					$imported['updated']['fields'] ++;
319 319
 
320
-					unset( $form_fields[ $f['id'] ] );
320
+					unset( $form_fields[$f['id']] );
321 321
 
322 322
 					//unset old field key
323
-					if ( isset( $form_fields[ $f['field_key'] ] ) ) {
324
-						unset( $form_fields[ $f['field_key'] ] );
323
+					if ( isset( $form_fields[$f['field_key']] ) ) {
324
+						unset( $form_fields[$f['field_key']] );
325 325
 					}
326
-				} else if ( isset( $form_fields[ $f['field_key'] ] ) ) {
326
+				} else if ( isset( $form_fields[$f['field_key']] ) ) {
327 327
 					// check for field to edit by field key
328
-					unset($f['id']);
328
+					unset( $f['id'] );
329 329
 
330
-					FrmField::update( $form_fields[ $f['field_key'] ], $f );
331
-					$imported['updated']['fields']++;
330
+					FrmField::update( $form_fields[$f['field_key']], $f );
331
+					$imported['updated']['fields'] ++;
332 332
 
333
-					unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id
334
-					unset( $form_fields[ $f['field_key'] ] ); //unset old field key
333
+					unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id
334
+					unset( $form_fields[$f['field_key']] ); //unset old field key
335 335
 				} else {
336 336
 					// if no matching field id or key in this form, create the field
337 337
 					self::create_imported_field( $f, $imported );
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 		if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) {
383 383
 			if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) {
384 384
 				$form_select = $f['field_options']['form_select'];
385
-				if ( isset( $imported['forms'][ $form_select ] ) ) {
386
-					$f['field_options']['form_select'] = $imported['forms'][ $form_select ];
385
+				if ( isset( $imported['forms'][$form_select] ) ) {
386
+					$f['field_options']['form_select'] = $imported['forms'][$form_select];
387 387
 				}
388 388
 			}
389 389
 		}
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 
404 404
 		if ( FrmField::is_option_true_in_array( $f['field_options'], 'get_values_form' ) ) {
405 405
 			$old_form = $f['field_options']['get_values_form'];
406
-			if ( isset( $imported['forms'][ $old_form ] ) ) {
407
-				$f['field_options']['get_values_form'] = $imported['forms'][ $old_form ];
406
+			if ( isset( $imported['forms'][$old_form] ) ) {
407
+				$f['field_options']['get_values_form'] = $imported['forms'][$old_form];
408 408
 			}
409 409
 		}
410 410
 	}
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	private static function create_imported_field( $f, &$imported ) {
420 420
 		$new_id = FrmField::create( $f );
421 421
 		if ( $new_id != false ) {
422
-			$imported['imported']['fields']++;
422
+			$imported['imported']['fields'] ++;
423 423
 			do_action( 'frm_after_field_is_imported', $f, $new_id );
424 424
 		}
425 425
 	}
@@ -518,9 +518,9 @@  discard block
 block discarded – undo
518 518
 			);
519 519
 
520 520
             $old_id = $post['post_id'];
521
-            self::populate_post($post, $item, $imported);
521
+            self::populate_post( $post, $item, $imported );
522 522
 
523
-			unset($item);
523
+			unset( $item );
524 524
 
525 525
 			$post_id = false;
526 526
             if ( $post['post_type'] == $form_action_type ) {
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 				if ( $action_control && is_object( $action_control ) ) {
529 529
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
530 530
 				}
531
-                unset($action_control);
531
+                unset( $action_control );
532 532
             } else if ( $post['post_type'] == 'frm_styles' ) {
533 533
                 // Properly encode post content before inserting the post
534 534
                 $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
@@ -541,26 +541,26 @@  discard block
 block discarded – undo
541 541
                 $post_id = wp_insert_post( $post );
542 542
             }
543 543
 
544
-            if ( ! is_numeric($post_id) ) {
544
+            if ( ! is_numeric( $post_id ) ) {
545 545
                 continue;
546 546
             }
547 547
 
548
-            self::update_postmeta($post, $post_id);
548
+            self::update_postmeta( $post, $post_id );
549 549
 
550 550
             $this_type = 'posts';
551
-			if ( isset( $post_types[ $post['post_type'] ] ) ) {
552
-				$this_type = $post_types[ $post['post_type'] ];
551
+			if ( isset( $post_types[$post['post_type']] ) ) {
552
+				$this_type = $post_types[$post['post_type']];
553 553
             }
554 554
 
555
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
556
-                $imported['updated'][ $this_type ]++;
555
+            if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) {
556
+                $imported['updated'][$this_type] ++;
557 557
             } else {
558
-                $imported['imported'][ $this_type ]++;
558
+                $imported['imported'][$this_type] ++;
559 559
             }
560 560
 
561
-            unset($post);
561
+            unset( $post );
562 562
 
563
-			$imported['posts'][ (int) $old_id ] = $post_id;
563
+			$imported['posts'][(int) $old_id] = $post_id;
564 564
 		}
565 565
 
566 566
 		self::maybe_update_stylesheet( $imported );
@@ -569,13 +569,13 @@  discard block
 block discarded – undo
569 569
     }
570 570
 
571 571
     private static function populate_post( &$post, $item, $imported ) {
572
-		if ( isset($item->attachment_url) ) {
572
+		if ( isset( $item->attachment_url ) ) {
573 573
 			$post['attachment_url'] = (string) $item->attachment_url;
574 574
 		}
575 575
 
576
-		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
576
+		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) {
577 577
 		    // update to new form id
578
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
578
+		    $post['menu_order'] = $imported['forms'][(int) $post['menu_order']];
579 579
 		}
580 580
 
581 581
 		// Don't allow default styles to take over a site's default style
@@ -584,13 +584,13 @@  discard block
 block discarded – undo
584 584
 		}
585 585
 
586 586
 		foreach ( $item->postmeta as $meta ) {
587
-		    self::populate_postmeta($post, $meta, $imported);
588
-			unset($meta);
587
+		    self::populate_postmeta( $post, $meta, $imported );
588
+			unset( $meta );
589 589
 		}
590 590
 
591
-        self::populate_taxonomies($post, $item);
591
+        self::populate_taxonomies( $post, $item );
592 592
 
593
-        self::maybe_editing_post($post);
593
+        self::maybe_editing_post( $post );
594 594
     }
595 595
 
596 596
     private static function populate_postmeta( &$post, $meta, $imported ) {
@@ -602,27 +602,27 @@  discard block
 block discarded – undo
602 602
 		);
603 603
 
604 604
 		//switch old form and field ids to new ones
605
-		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
606
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
605
+		if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) {
606
+		    $m['value'] = $imported['forms'][(int) $m['value']];
607 607
 		} else {
608
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
608
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
609 609
 
610
-		    if ( ! empty($frm_duplicate_ids) ) {
610
+		    if ( ! empty( $frm_duplicate_ids ) ) {
611 611
 
612 612
 		        if ( $m['key'] == 'frm_dyncontent' ) {
613
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
613
+		            $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] );
614 614
     		    } else if ( $m['key'] == 'frm_options' ) {
615 615
 
616 616
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
617
-						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
618
-							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
617
+						if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) {
618
+							$m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]];
619 619
     		            }
620 620
     		        }
621 621
 
622 622
                     $check_dup_array = array();
623 623
     		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
624
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
625
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
624
+    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) {
625
+    		                $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']];
626 626
     		            } else if ( is_array( $m['value']['order_by'] ) ) {
627 627
                             $check_dup_array[] = 'order_by';
628 628
     		            }
@@ -633,22 +633,22 @@  discard block
 block discarded – undo
633 633
     		        }
634 634
 
635 635
                     foreach ( $check_dup_array as $check_k ) {
636
-						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
637
-							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
638
-								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
636
+						foreach ( (array) $m['value'][$check_k] as $mk => $mv ) {
637
+							if ( isset( $frm_duplicate_ids[$mv] ) ) {
638
+								$m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv];
639 639
 		                    }
640
-		                    unset($mk, $mv);
640
+		                    unset( $mk, $mv );
641 641
 		                }
642 642
                     }
643 643
     		    }
644 644
 		    }
645 645
 		}
646 646
 
647
-		if ( ! is_array($m['value']) ) {
648
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
647
+		if ( ! is_array( $m['value'] ) ) {
648
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
649 649
 		}
650 650
 
651
-		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
651
+		$post['postmeta'][(string) $meta->meta_key] = $m['value'];
652 652
     }
653 653
 
654 654
     /**
@@ -664,23 +664,23 @@  discard block
 block discarded – undo
664 664
             }
665 665
 
666 666
 		    $taxonomy = (string) $att['domain'];
667
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
667
+		    if ( is_taxonomy_hierarchical( $taxonomy ) ) {
668 668
 		        $name = (string) $att['nicename'];
669
-		        $h_term = get_term_by('slug', $name, $taxonomy);
669
+		        $h_term = get_term_by( 'slug', $name, $taxonomy );
670 670
 		        if ( $h_term ) {
671 671
 		            $name = $h_term->term_id;
672 672
 		        }
673
-		        unset($h_term);
673
+		        unset( $h_term );
674 674
 		    } else {
675 675
 		        $name = (string) $c;
676 676
 		    }
677 677
 
678
-			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
679
-				$post['tax_input'][ $taxonomy ] = array();
678
+			if ( ! isset( $post['tax_input'][$taxonomy] ) ) {
679
+				$post['tax_input'][$taxonomy] = array();
680 680
 			}
681 681
 
682
-			$post['tax_input'][ $taxonomy ][] = $name;
683
-		    unset($name);
682
+			$post['tax_input'][$taxonomy][] = $name;
683
+		    unset( $name );
684 684
 		}
685 685
     }
686 686
 
@@ -697,29 +697,29 @@  discard block
 block discarded – undo
697 697
 
698 698
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
699 699
 		    $match_by['include'] = $post['post_id'];
700
-		    unset($match_by['name']);
700
+		    unset( $match_by['name'] );
701 701
 		}
702 702
 
703
-		$editing = get_posts($match_by);
703
+		$editing = get_posts( $match_by );
704 704
 
705
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
705
+        if ( ! empty( $editing ) && current( $editing )->post_date == $post['post_date'] ) {
706 706
             // set the id of the post to edit
707
-            $post['ID'] = current($editing)->ID;
707
+            $post['ID'] = current( $editing )->ID;
708 708
         }
709 709
     }
710 710
 
711 711
     private static function update_postmeta( &$post, $post_id ) {
712 712
         foreach ( $post['postmeta'] as $k => $v ) {
713 713
             if ( '_edit_last' == $k ) {
714
-                $v = FrmAppHelper::get_user_id_param($v);
714
+                $v = FrmAppHelper::get_user_id_param( $v );
715 715
             } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
716 716
                 //change the attachment ID
717
-                $v = FrmProXMLHelper::get_file_id($v);
717
+                $v = FrmProXMLHelper::get_file_id( $v );
718 718
             }
719 719
 
720
-            update_post_meta($post_id, $k, $v);
720
+            update_post_meta( $post_id, $k, $v );
721 721
 
722
-            unset($k, $v);
722
+            unset( $k, $v );
723 723
         }
724 724
     }
725 725
 
@@ -741,13 +741,13 @@  discard block
 block discarded – undo
741 741
      * @param string $message
742 742
      */
743 743
 	public static function parse_message( $result, &$message, &$errors ) {
744
-        if ( is_wp_error($result) ) {
744
+        if ( is_wp_error( $result ) ) {
745 745
             $errors[] = $result->get_error_message();
746 746
         } else if ( ! $result ) {
747 747
             return;
748 748
         }
749 749
 
750
-        if ( ! is_array($result) ) {
750
+        if ( ! is_array( $result ) ) {
751 751
             $message = is_string( $result ) ? $result : print_r( $result, 1 );
752 752
             return;
753 753
         }
@@ -759,20 +759,20 @@  discard block
 block discarded – undo
759 759
 
760 760
         $message = '<ul>';
761 761
         foreach ( $result as $type => $results ) {
762
-			if ( ! isset( $t_strings[ $type ] ) ) {
762
+			if ( ! isset( $t_strings[$type] ) ) {
763 763
                 // only print imported and updated
764 764
                 continue;
765 765
             }
766 766
 
767 767
             $s_message = array();
768 768
             foreach ( $results as $k => $m ) {
769
-                self::item_count_message($m, $k, $s_message);
770
-                unset($k, $m);
769
+                self::item_count_message( $m, $k, $s_message );
770
+                unset( $k, $m );
771 771
             }
772 772
 
773
-            if ( ! empty($s_message) ) {
774
-				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
775
-                $message .= implode(', ', $s_message);
773
+            if ( ! empty( $s_message ) ) {
774
+				$message .= '<li><strong>' . $t_strings[$type] . ':</strong> ';
775
+                $message .= implode( ', ', $s_message );
776 776
                 $message .= '</li>';
777 777
             }
778 778
         }
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
             'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
802 802
         );
803 803
 
804
-		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
804
+		$s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type );
805 805
     }
806 806
 
807 807
 	/**
@@ -833,14 +833,14 @@  discard block
 block discarded – undo
833 833
 	}
834 834
 
835 835
 	public static function cdata( $str ) {
836
-	    $str = maybe_unserialize($str);
837
-	    if ( is_array($str) ) {
838
-	        $str = json_encode($str);
836
+	    $str = maybe_unserialize( $str );
837
+	    if ( is_array( $str ) ) {
838
+	        $str = json_encode( $str );
839 839
 		} else if ( seems_utf8( $str ) == false ) {
840 840
 			$str = utf8_encode( $str );
841 841
 		}
842 842
 
843
-        if ( is_numeric($str) ) {
843
+        if ( is_numeric( $str ) ) {
844 844
             return $str;
845 845
         }
846 846
 
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
     * @param string $post_type
886 886
     */
887 887
     private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
888
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
888
+        if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) {
889 889
             return;
890 890
         }
891 891
 
@@ -906,10 +906,10 @@  discard block
 block discarded – undo
906 906
         );
907 907
 
908 908
         foreach ( $post_settings as $post_setting ) {
909
-			if ( isset( $form_options[ $post_setting ] ) ) {
910
-				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
909
+			if ( isset( $form_options[$post_setting] ) ) {
910
+				$new_action['post_content'][$post_setting] = $form_options[$post_setting];
911 911
             }
912
-            unset($post_setting);
912
+            unset( $post_setting );
913 913
         }
914 914
 
915 915
 		$new_action['event'] = array( 'create', 'update' );
@@ -923,7 +923,7 @@  discard block
 block discarded – undo
923 923
 
924 924
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
925 925
         }
926
-        $new_action['post_content'] = json_encode($new_action['post_content']);
926
+        $new_action['post_content'] = json_encode( $new_action['post_content'] );
927 927
 
928 928
         $exists = get_posts( array(
929 929
             'name'          => $new_action['post_name'],
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
         if ( ! $exists ) {
936 936
 			// this isn't an email, but we need to use a class that will always be included
937 937
 			FrmAppHelper::save_json_post( $new_action );
938
-            $imported['imported']['actions']++;
938
+            $imported['imported']['actions'] ++;
939 939
         }
940 940
     }
941 941
 
@@ -967,11 +967,11 @@  discard block
 block discarded – undo
967 967
         foreach ( $post_content as $key => $setting ) {
968 968
             if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
969 969
                 // Replace old IDs with new IDs
970
-				$post_content[ $key ] = str_replace( $old, $new, $setting );
970
+				$post_content[$key] = str_replace( $old, $new, $setting );
971 971
             } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
972 972
                 foreach ( $setting as $k => $val ) {
973 973
                     // Replace old IDs with new IDs
974
-					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
974
+					$post_content[$key][$k] = str_replace( $old, $new, $val );
975 975
                 }
976 976
             }
977 977
             unset( $key, $setting );
@@ -994,14 +994,14 @@  discard block
 block discarded – undo
994 994
         // Migrate autoresponders
995 995
         self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
996 996
 
997
-        if (  empty( $notifications ) ) {
997
+        if ( empty( $notifications ) ) {
998 998
             return;
999 999
         }
1000 1000
 
1001 1001
         foreach ( $notifications as $new_notification ) {
1002 1002
             $new_notification['post_type']      = $post_type;
1003 1003
             $new_notification['post_excerpt']   = 'email';
1004
-			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
1004
+			$new_notification['post_title'] = __( 'Email Notification', 'formidable' );
1005 1005
             $new_notification['menu_order']     = $form_id;
1006 1006
             $new_notification['post_status']    = 'publish';
1007 1007
 
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
 				// Switch all other field IDs in email
1015 1015
                 $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1016 1016
             }
1017
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1017
+            $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1018 1018
 
1019 1019
             $exists = get_posts( array(
1020 1020
                 'name'          => $new_notification['post_name'],
@@ -1023,11 +1023,11 @@  discard block
 block discarded – undo
1023 1023
                 'numberposts'   => 1,
1024 1024
             ) );
1025 1025
 
1026
-            if ( empty($exists) ) {
1026
+            if ( empty( $exists ) ) {
1027 1027
 				FrmAppHelper::save_json_post( $new_notification );
1028
-                $imported['imported']['actions']++;
1028
+                $imported['imported']['actions'] ++;
1029 1029
             }
1030
-            unset($new_notification);
1030
+            unset( $new_notification );
1031 1031
         }
1032 1032
     }
1033 1033
 
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
1041 1041
         }
1042 1042
 
1043
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1043
+        if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) {
1044 1044
             foreach ( $form_options['notification'] as $email_key => $notification ) {
1045 1045
 
1046 1046
                 $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
@@ -1068,12 +1068,12 @@  discard block
 block discarded – undo
1068 1068
         // Format the reply to email and name
1069 1069
         $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
1070 1070
         foreach ( $reply_fields as $f => $val ) {
1071
-			if ( isset( $notification[ $f ] ) ) {
1072
-				$atts[ $f ] = $notification[ $f ];
1073
-				if ( 'custom' == $notification[ $f ] ) {
1074
-					$atts[ $f ] = $notification[ 'cust_' . $f ];
1075
-				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
1076
-					$atts[ $f ] = '[' . $atts[ $f ] . ']';
1071
+			if ( isset( $notification[$f] ) ) {
1072
+				$atts[$f] = $notification[$f];
1073
+				if ( 'custom' == $notification[$f] ) {
1074
+					$atts[$f] = $notification['cust_' . $f];
1075
+				} else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) {
1076
+					$atts[$f] = '[' . $atts[$f] . ']';
1077 1077
                 }
1078 1078
             }
1079 1079
             unset( $f, $val );
@@ -1083,7 +1083,7 @@  discard block
 block discarded – undo
1083 1083
 		$atts['event'] = array( 'create' );
1084 1084
         if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1085 1085
             $atts['event'][] = 'update';
1086
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1086
+        } else if ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) {
1087 1087
 			$atts['event'] = array( 'update' );
1088 1088
         }
1089 1089
     }
@@ -1104,18 +1104,18 @@  discard block
 block discarded – undo
1104 1104
         foreach ( $atts['email_to'] as $key => $email_field ) {
1105 1105
 
1106 1106
             if ( is_numeric( $email_field ) ) {
1107
-				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1107
+				$atts['email_to'][$key] = '[' . $email_field . ']';
1108 1108
             }
1109 1109
 
1110
-            if ( strpos( $email_field, '|') ) {
1110
+            if ( strpos( $email_field, '|' ) ) {
1111 1111
                 $email_opt = explode( '|', $email_field );
1112 1112
                 if ( isset( $email_opt[0] ) ) {
1113
-					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1113
+					$atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1114 1114
                 }
1115 1115
                 unset( $email_opt );
1116 1116
             }
1117 1117
         }
1118
-        $atts['email_to'] = implode(', ', $atts['email_to']);
1118
+        $atts['email_to'] = implode( ', ', $atts['email_to'] );
1119 1119
     }
1120 1120
 
1121 1121
     private static function setup_new_notification( &$new_notification, $notification, $atts ) {
@@ -1131,12 +1131,12 @@  discard block
 block discarded – undo
1131 1131
         // Add more fields to the new notification
1132 1132
         $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1133 1133
         foreach ( $add_fields as $add_field ) {
1134
-			if ( isset( $notification[ $add_field ] ) ) {
1135
-				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1134
+			if ( isset( $notification[$add_field] ) ) {
1135
+				$new_notification['post_content'][$add_field] = $notification[$add_field];
1136 1136
             } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1137
-				$new_notification['post_content'][ $add_field ] = 0;
1137
+				$new_notification['post_content'][$add_field] = 0;
1138 1138
             } else {
1139
-				$new_notification['post_content'][ $add_field ] = '';
1139
+				$new_notification['post_content'][$add_field] = '';
1140 1140
             }
1141 1141
             unset( $add_field );
1142 1142
         }
@@ -1160,26 +1160,26 @@  discard block
 block discarded – undo
1160 1160
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
1161 1161
 			foreach ( $post_content['conditions'] as $email_key => $val ) {
1162 1162
 				if ( is_numeric( $email_key ) ) {
1163
-					$post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1163
+					$post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1164 1164
 				}
1165
-				unset( $email_key, $val);
1165
+				unset( $email_key, $val );
1166 1166
 			}
1167 1167
 		}
1168 1168
 	}
1169 1169
 
1170 1170
     private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1171
-        if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1171
+        if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) {
1172 1172
             // migrate autoresponder
1173 1173
 
1174
-            $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1175
-            if ( strpos($email_field, '|') ) {
1174
+            $email_field = isset( $form_options['ar_email_to'] ) ? $form_options['ar_email_to'] : 0;
1175
+            if ( strpos( $email_field, '|' ) ) {
1176 1176
                 // data from entries field
1177
-                $email_field = explode('|', $email_field);
1178
-                if ( isset($email_field[1]) ) {
1177
+                $email_field = explode( '|', $email_field );
1178
+                if ( isset( $email_field[1] ) ) {
1179 1179
                     $email_field = $email_field[1];
1180 1180
                 }
1181 1181
             }
1182
-            if ( is_numeric($email_field) && ! empty($email_field) ) {
1182
+            if ( is_numeric( $email_field ) && ! empty( $email_field ) ) {
1183 1183
 				$email_field = '[' . $email_field . ']';
1184 1184
             }
1185 1185
 
@@ -1187,16 +1187,16 @@  discard block
 block discarded – undo
1187 1187
             $new_notification2 = array(
1188 1188
                 'post_content'  => array(
1189 1189
                     'email_message' => $notification['ar_email_message'],
1190
-                    'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1190
+                    'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '',
1191 1191
                     'email_to'      => $email_field,
1192
-                    'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1192
+                    'plain_text'    => isset( $notification['ar_plain_text'] ) ? $notification['ar_plain_text'] : 0,
1193 1193
                     'inc_user_info' => 0,
1194 1194
                 ),
1195 1195
 				'post_name'     => $form_id . '_email_' . count( $notifications ),
1196 1196
             );
1197 1197
 
1198
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1199
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1198
+            $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : '';
1199
+            $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : '';
1200 1200
 
1201 1201
 			if ( ! empty( $reply_to ) ) {
1202 1202
 				$new_notification2['post_content']['reply_to'] = $reply_to;
Please login to merge, or discard this patch.
classes/models/FrmFormAction.php 2 patches
Indentation   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 	public $action_options;     // Option array passed to wp_register_sidebar_widget()
9 9
 	public $control_options;	// Option array passed to wp_register_widget_control()
10 10
 
11
-    public $form_id;        // The ID of the form to evaluate
11
+	public $form_id;        // The ID of the form to evaluate
12 12
 	public $number = false;	// Unique ID number of the current instance.
13 13
 	public $id = '';		// Unique ID string of the current instance (id_base-number)
14 14
 	public $updated = false;	// Set true when we update the data after a POST submit - makes sure we don't do it twice.
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	}
30 30
 
31 31
 	/**
32
-     * Echo the settings update form
32
+	 * Echo the settings update form
33 33
 	 *
34 34
 	 * @param array $instance Current settings
35 35
 	 */
@@ -42,15 +42,15 @@  discard block
 block discarded – undo
42 42
 	 * @return array of the default options
43 43
 	 */
44 44
 	public function get_defaults() {
45
-	    return array();
45
+		return array();
46 46
 	}
47 47
 
48 48
 	public function get_switch_fields() {
49
-	    return array();
49
+		return array();
50 50
 	}
51 51
 
52 52
 	public function migrate_values( $action, $form ) {
53
-	    return $action;
53
+		return $action;
54 54
 	}
55 55
 
56 56
 	// Functions you'll need to call.
@@ -69,24 +69,24 @@  discard block
 block discarded – undo
69 69
 	 *	 - height: currently not used but may be needed in the future
70 70
 	 */
71 71
 	public function __construct( $id_base, $name, $action_options = array(), $control_options = array() ) {
72
-	    if ( ! defined('ABSPATH') ) {
73
-            die('You are not allowed to call this page directly.');
74
-        }
72
+		if ( ! defined('ABSPATH') ) {
73
+			die('You are not allowed to call this page directly.');
74
+		}
75 75
 
76 76
 		$this->id_base = strtolower($id_base);
77 77
 		$this->name = $name;
78 78
 		$this->option_name = 'frm_' . $this->id_base . '_action';
79 79
 
80
-        $default_options = array(
81
-            'classes'   => '',
82
-            'active'    => true,
80
+		$default_options = array(
81
+			'classes'   => '',
82
+			'active'    => true,
83 83
 			'event'     => array( 'create' ),
84
-            'limit'     => 1,
85
-            'force_event' => false,
86
-            'priority'  => 20,
87
-            'ajax_load' => true,
88
-            'tooltip'   => $name,
89
-        );
84
+			'limit'     => 1,
85
+			'force_event' => false,
86
+			'priority'  => 20,
87
+			'ajax_load' => true,
88
+			'tooltip'   => $name,
89
+		);
90 90
 
91 91
 		$action_options = apply_filters( 'frm_' . $id_base . '_action_options', $action_options );
92 92
 		$this->action_options = wp_parse_args( $action_options, $default_options );
@@ -135,132 +135,132 @@  discard block
 block discarded – undo
135 135
 	}
136 136
 
137 137
 	public function prepare_new( $form_id = false ) {
138
-        if ( $form_id ) {
139
-            $this->form_id = $form_id;
140
-        }
141
-
142
-        $post_content = array();
143
-        $default_values = $this->get_global_defaults();
144
-
145
-        // fill default values
146
-        $post_content = wp_parse_args( $post_content, $default_values);
147
-
148
-        if ( ! isset($post_content['event']) && ! $this->action_options['force_event'] ) {
149
-            $post_content['event'] = array( reset($this->action_options['event']) );
150
-        }
151
-
152
-        $form_action = array(
153
-            'post_title'    => $this->name,
154
-            'post_content'  => $post_content,
155
-            'post_excerpt'  => $this->id_base,
156
-            'ID'            => '',
157
-            'post_status'   => 'publish',
158
-            'post_type'     => FrmFormActionsController::$action_post_type,
138
+		if ( $form_id ) {
139
+			$this->form_id = $form_id;
140
+		}
141
+
142
+		$post_content = array();
143
+		$default_values = $this->get_global_defaults();
144
+
145
+		// fill default values
146
+		$post_content = wp_parse_args( $post_content, $default_values);
147
+
148
+		if ( ! isset($post_content['event']) && ! $this->action_options['force_event'] ) {
149
+			$post_content['event'] = array( reset($this->action_options['event']) );
150
+		}
151
+
152
+		$form_action = array(
153
+			'post_title'    => $this->name,
154
+			'post_content'  => $post_content,
155
+			'post_excerpt'  => $this->id_base,
156
+			'ID'            => '',
157
+			'post_status'   => 'publish',
158
+			'post_type'     => FrmFormActionsController::$action_post_type,
159 159
 			'post_name'     => $this->form_id . '_' . $this->id_base . '_' . $this->number,
160
-            'menu_order'    => $this->form_id,
161
-        );
162
-        unset($post_content);
160
+			'menu_order'    => $this->form_id,
161
+		);
162
+		unset($post_content);
163 163
 
164
-        return (object) $form_action;
165
-    }
164
+		return (object) $form_action;
165
+	}
166 166
 
167 167
 	public function create( $form_id ) {
168
-        $this->form_id = $form_id;
168
+		$this->form_id = $form_id;
169 169
 
170
-        $action = $this->prepare_new();
170
+		$action = $this->prepare_new();
171 171
 
172
-        return $this->save_settings($action);
173
-    }
172
+		return $this->save_settings($action);
173
+	}
174 174
 
175 175
 	public function duplicate_form_actions( $form_id, $old_id ) {
176
-        if ( $form_id == $old_id ) {
177
-            // don't duplicate the actions if this is a template getting updated
178
-            return;
179
-        }
180
-
181
-        $this->form_id = $old_id;
182
-        $actions = $this->get_all( $old_id );
183
-
184
-        $this->form_id = $form_id;
185
-        foreach ( $actions as $action ) {
186
-            $this->duplicate_one($action, $form_id);
187
-            unset($action);
188
-        }
189
-    }
190
-
191
-    /* Check if imported action should be created or updated
176
+		if ( $form_id == $old_id ) {
177
+			// don't duplicate the actions if this is a template getting updated
178
+			return;
179
+		}
180
+
181
+		$this->form_id = $old_id;
182
+		$actions = $this->get_all( $old_id );
183
+
184
+		$this->form_id = $form_id;
185
+		foreach ( $actions as $action ) {
186
+			$this->duplicate_one($action, $form_id);
187
+			unset($action);
188
+		}
189
+	}
190
+
191
+	/* Check if imported action should be created or updated
192 192
     *
193 193
     * Since 2.0
194 194
     *
195 195
     * @param array $action
196 196
     * @return integer $post_id
197 197
     */
198
-    public function maybe_create_action( $action, $forms ) {
198
+	public function maybe_create_action( $action, $forms ) {
199 199
 		if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && $forms[ $action['menu_order'] ] == 'updated' ) {
200
-            // Update action only
201
-            $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
202
-            $post_id = $this->save_settings( $action );
203
-        } else {
204
-            // Create action
205
-            $action['post_content'] = FrmAppHelper::maybe_json_decode($action['post_content']);
206
-            $post_id = $this->duplicate_one( (object) $action, $action['menu_order']);
207
-        }
208
-        return $post_id;
209
-    }
200
+			// Update action only
201
+			$action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
202
+			$post_id = $this->save_settings( $action );
203
+		} else {
204
+			// Create action
205
+			$action['post_content'] = FrmAppHelper::maybe_json_decode($action['post_content']);
206
+			$post_id = $this->duplicate_one( (object) $action, $action['menu_order']);
207
+		}
208
+		return $post_id;
209
+	}
210 210
 
211 211
 	public function duplicate_one( $action, $form_id ) {
212
-        global $frm_duplicate_ids;
212
+		global $frm_duplicate_ids;
213 213
 
214
-        $action->menu_order = $form_id;
215
-        $switch = $this->get_global_switch_fields();
216
-        foreach ( (array) $action->post_content as $key => $val ) {
214
+		$action->menu_order = $form_id;
215
+		$switch = $this->get_global_switch_fields();
216
+		foreach ( (array) $action->post_content as $key => $val ) {
217 217
 			if ( is_numeric( $val ) && isset( $frm_duplicate_ids[ $val ] ) ) {
218 218
 				$action->post_content[ $key ] = $frm_duplicate_ids[ $val ];
219
-            } else if ( ! is_array( $val ) ) {
219
+			} else if ( ! is_array( $val ) ) {
220 220
 				$action->post_content[ $key ] = FrmFieldsHelper::switch_field_ids( $val );
221 221
 			} else if ( isset( $switch[ $key ] ) && is_array( $switch[ $key ] ) ) {
222
-                // loop through each value if empty
222
+				// loop through each value if empty
223 223
 				if ( empty( $switch[ $key ] ) ) {
224 224
 					$switch[ $key ] = array_keys( $val );
225 225
 				}
226 226
 
227 227
 				foreach ( $switch[ $key ] as $subkey ) {
228 228
 					$action->post_content[ $key ] = $this->duplicate_array_walk( $action->post_content[ $key ], $subkey, $val );
229
-                }
230
-            }
229
+				}
230
+			}
231 231
 
232
-            unset($key, $val);
233
-        }
234
-        unset($action->ID);
232
+			unset($key, $val);
233
+		}
234
+		unset($action->ID);
235 235
 
236
-        return $this->save_settings($action);
237
-    }
236
+		return $this->save_settings($action);
237
+	}
238 238
 
239 239
 	private function duplicate_array_walk( $action, $subkey, $val ) {
240
-        global $frm_duplicate_ids;
240
+		global $frm_duplicate_ids;
241 241
 
242
-        if ( is_array($subkey) ) {
243
-            foreach ( $subkey as $subkey2 ) {
244
-                foreach ( (array) $val as $ck => $cv ) {
245
-                    if ( is_array($cv) ) {
242
+		if ( is_array($subkey) ) {
243
+			foreach ( $subkey as $subkey2 ) {
244
+				foreach ( (array) $val as $ck => $cv ) {
245
+					if ( is_array($cv) ) {
246 246
 						$action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey2, $cv );
247 247
 					} else if ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) {
248 248
 						$action[ $ck ][ $subkey ] = $frm_duplicate_ids[ $cv[ $subkey ] ];
249
-                    }
250
-                }
251
-            }
252
-        } else {
253
-            foreach ( (array) $val as $ck => $cv ) {
254
-                if ( is_array($cv) ) {
249
+					}
250
+				}
251
+			}
252
+		} else {
253
+			foreach ( (array) $val as $ck => $cv ) {
254
+				if ( is_array($cv) ) {
255 255
 					$action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv );
256 256
 				} else if ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) {
257 257
 					$action[ $ck ] = $frm_duplicate_ids[ $cv ];
258
-                }
259
-            }
260
-        }
258
+				}
259
+			}
260
+		}
261 261
 
262
-        return $action;
263
-    }
262
+		return $action;
263
+	}
264 264
 
265 265
 	/**
266 266
 	 * Deal with changed settings.
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 *
270 270
 	 */
271 271
  	public function update_callback( $form_id ) {
272
-        $this->form_id = $form_id;
272
+		$this->form_id = $form_id;
273 273
 
274 274
  		$all_instances = $this->get_settings();
275 275
 
@@ -284,25 +284,25 @@  discard block
 block discarded – undo
284 284
  			return;
285 285
  		}
286 286
 
287
-        $action_ids = array();
287
+		$action_ids = array();
288 288
 
289 289
  		foreach ( $settings as $number => $new_instance ) {
290 290
  			$this->_set($number);
291 291
 
292 292
  			if ( ! isset($new_instance['post_title']) ) {
293
- 			    // settings were never opened, so don't update
294
- 			    $action_ids[] = $new_instance['ID'];
295
-         		$this->updated = true;
296
-         		continue;
293
+ 				// settings were never opened, so don't update
294
+ 				$action_ids[] = $new_instance['ID'];
295
+		 		$this->updated = true;
296
+		 		continue;
297 297
  			}
298 298
 
299 299
 			$old_instance = isset( $all_instances[ $number ] ) ? $all_instances[ $number ] : array();
300 300
 
301 301
  			$new_instance['post_type']  = FrmFormActionsController::$action_post_type;
302 302
 			$new_instance['post_name']  = $this->form_id . '_' . $this->id_base . '_' . $this->number;
303
-            $new_instance['menu_order']   = $this->form_id;
304
-            $new_instance['post_status']  = 'publish';
305
-            $new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : '';
303
+			$new_instance['menu_order']   = $this->form_id;
304
+			$new_instance['post_status']  = 'publish';
305
+			$new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : '';
306 306
 
307 307
  			$instance = $this->update( $new_instance, $old_instance );
308 308
 
@@ -328,9 +328,9 @@  discard block
 block discarded – undo
328 328
 				$all_instances[ $number ] = $instance;
329 329
 			}
330 330
 
331
-            $action_ids[] = $this->save_settings($instance);
331
+			$action_ids[] = $this->save_settings($instance);
332 332
 
333
-     		$this->updated = true;
333
+	 		$this->updated = true;
334 334
  		}
335 335
 
336 336
  		return $action_ids;
@@ -342,59 +342,59 @@  discard block
 block discarded – undo
342 342
 	}
343 343
 
344 344
 	public function get_single_action( $id ) {
345
-	    $action = get_post($id);
345
+		$action = get_post($id);
346 346
 		if ( $action ) {
347 347
 			$action = $this->prepare_action( $action );
348 348
 			$this->_set( $id );
349 349
 		}
350
-	    return $action;
350
+		return $action;
351 351
 	}
352 352
 
353 353
 	public function get_one( $form_id ) {
354
-	    return $this->get_all($form_id, 1);
354
+		return $this->get_all($form_id, 1);
355 355
 	}
356 356
 
357
-    public static function get_action_for_form( $form_id, $type = 'all', $limit = 99 ) {
358
-        $action_controls = FrmFormActionsController::get_form_actions( $type );
359
-        if ( empty($action_controls) ) {
360
-            // don't continue if there are no available actions
361
-            return array();
362
-        }
357
+	public static function get_action_for_form( $form_id, $type = 'all', $limit = 99 ) {
358
+		$action_controls = FrmFormActionsController::get_form_actions( $type );
359
+		if ( empty($action_controls) ) {
360
+			// don't continue if there are no available actions
361
+			return array();
362
+		}
363 363
 
364
-        if ( 'all' != $type ) {
365
-            return $action_controls->get_all( $form_id, $limit );
366
-        }
364
+		if ( 'all' != $type ) {
365
+			return $action_controls->get_all( $form_id, $limit );
366
+		}
367 367
 
368 368
 		$args = self::action_args( $form_id, $limit );
369 369
 		$actions = FrmAppHelper::check_cache( serialize( $args ), 'frm_actions', $args, 'get_posts' );
370 370
 
371
-        if ( ! $actions ) {
372
-            return array();
373
-        }
371
+		if ( ! $actions ) {
372
+			return array();
373
+		}
374 374
 
375
-        $settings = array();
376
-        foreach ( $actions as $action ) {
375
+		$settings = array();
376
+		foreach ( $actions as $action ) {
377 377
 			// some plugins/themes are formatting the post_excerpt
378 378
 			$action->post_excerpt = sanitize_title( $action->post_excerpt );
379 379
 
380 380
 			if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) {
381
-                continue;
382
-            }
381
+				continue;
382
+			}
383 383
 
384
-            $action = $action_controls[ $action->post_excerpt ]->prepare_action( $action );
384
+			$action = $action_controls[ $action->post_excerpt ]->prepare_action( $action );
385 385
 			$settings[ $action->ID ] = $action;
386 386
 
387 387
 			if ( count( $settings ) >= $limit ) {
388 388
 				break;
389 389
 			}
390
-        }
390
+		}
391 391
 
392
-        if ( 1 === $limit ) {
393
-            $settings = reset($settings);
394
-        }
392
+		if ( 1 === $limit ) {
393
+			$settings = reset($settings);
394
+		}
395 395
 
396
-        return $settings;
397
-    }
396
+		return $settings;
397
+	}
398 398
 
399 399
 	/**
400 400
 	 * @param int $action_id
@@ -414,45 +414,45 @@  discard block
 block discarded – undo
414 414
 	}
415 415
 
416 416
 	public function get_all( $form_id = false, $limit = 99 ) {
417
-	    if ( $form_id ) {
418
-	        $this->form_id = $form_id;
419
-	    }
417
+		if ( $form_id ) {
418
+			$this->form_id = $form_id;
419
+		}
420 420
 
421
-	    $type = $this->id_base;
421
+		$type = $this->id_base;
422 422
 
423
-	    global $frm_vars;
424
-	    $frm_vars['action_type'] = $type;
423
+		global $frm_vars;
424
+		$frm_vars['action_type'] = $type;
425 425
 
426
-	    add_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' );
426
+		add_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' );
427 427
 		$query = self::action_args( $form_id, $limit );
428
-        $query['post_status']      = 'any';
429
-        $query['suppress_filters'] = false;
428
+		$query['post_status']      = 'any';
429
+		$query['suppress_filters'] = false;
430 430
 
431 431
 		$actions = FrmAppHelper::check_cache( serialize( $query ) . '_type_' . $type, 'frm_actions', $query, 'get_posts' );
432
-        unset($query);
432
+		unset($query);
433 433
 
434
-        remove_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' );
434
+		remove_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' );
435 435
 
436
-        if ( empty($actions) ) {
437
-            return array();
438
-        }
436
+		if ( empty($actions) ) {
437
+			return array();
438
+		}
439 439
 
440
-        $settings = array();
441
-        foreach ( $actions as $action ) {
442
-            if ( count($settings) >= $limit ) {
443
-                continue;
444
-            }
440
+		$settings = array();
441
+		foreach ( $actions as $action ) {
442
+			if ( count($settings) >= $limit ) {
443
+				continue;
444
+			}
445 445
 
446
-            $action = $this->prepare_action($action);
446
+			$action = $this->prepare_action($action);
447 447
 
448 448
 			$settings[ $action->ID ] = $action;
449
-        }
449
+		}
450 450
 
451
-        if ( 1 === $limit ) {
452
-            $settings = reset($settings);
453
-        }
451
+		if ( 1 === $limit ) {
452
+			$settings = reset($settings);
453
+		}
454 454
 
455
-        return $settings;
455
+		return $settings;
456 456
 	}
457 457
 
458 458
 	public static function action_args( $form_id = 0, $limit = 99 ) {
@@ -475,45 +475,45 @@  discard block
 block discarded – undo
475 475
 		$action->post_content = (array) FrmAppHelper::maybe_json_decode($action->post_content);
476 476
 		$action->post_excerpt = sanitize_title( $action->post_excerpt );
477 477
 
478
-        $default_values = $this->get_global_defaults();
478
+		$default_values = $this->get_global_defaults();
479 479
 
480
-        // fill default values
481
-        $action->post_content += $default_values;
480
+		// fill default values
481
+		$action->post_content += $default_values;
482 482
 
483
-        foreach ( $default_values as $k => $vals ) {
484
-            if ( is_array($vals) && ! empty($vals) ) {
483
+		foreach ( $default_values as $k => $vals ) {
484
+			if ( is_array($vals) && ! empty($vals) ) {
485 485
 				if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) {
486
-                    continue;
487
-                }
486
+					continue;
487
+				}
488 488
 				$action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals );
489
-            }
490
-        }
489
+			}
490
+		}
491 491
 
492
-        if ( ! is_array($action->post_content['event']) ) {
493
-            $action->post_content['event'] = explode(',', $action->post_content['event']);
494
-        }
492
+		if ( ! is_array($action->post_content['event']) ) {
493
+			$action->post_content['event'] = explode(',', $action->post_content['event']);
494
+		}
495 495
 
496
-        return $action;
496
+		return $action;
497 497
 	}
498 498
 
499 499
 	public function destroy( $form_id = false, $type = 'default' ) {
500
-	    global $wpdb;
500
+		global $wpdb;
501 501
 
502
-	    $this->form_id = $form_id;
502
+		$this->form_id = $form_id;
503 503
 
504
-	    $query = array( 'post_type' => FrmFormActionsController::$action_post_type );
505
-	    if ( $form_id ) {
506
-	        $query['menu_order'] = $form_id;
507
-	    }
508
-	    if ( 'all' != $type ) {
509
-	        $query['post_excerpt'] = $this->id_base;
510
-	    }
504
+		$query = array( 'post_type' => FrmFormActionsController::$action_post_type );
505
+		if ( $form_id ) {
506
+			$query['menu_order'] = $form_id;
507
+		}
508
+		if ( 'all' != $type ) {
509
+			$query['post_excerpt'] = $this->id_base;
510
+		}
511 511
 
512
-        $post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' );
512
+		$post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' );
513 513
 
514
-        foreach ( $post_ids as $id ) {
515
-            wp_delete_post($id);
516
-        }
514
+		foreach ( $post_ids as $id ) {
515
+			wp_delete_post($id);
516
+		}
517 517
 		self::clear_cache();
518 518
 	}
519 519
 
@@ -531,69 +531,69 @@  discard block
 block discarded – undo
531 531
 	}
532 532
 
533 533
 	public function get_global_defaults() {
534
-	    $defaults = $this->get_defaults();
534
+		$defaults = $this->get_defaults();
535 535
 
536
-	    if ( ! isset($defaults['event']) ) {
536
+		if ( ! isset($defaults['event']) ) {
537 537
 			$defaults['event'] = array( 'create' );
538
-	    }
538
+		}
539 539
 
540
-	    if ( ! isset($defaults['conditions']) ) {
541
-	        $defaults['conditions'] = array(
542
-                'send_stop' => '',
543
-                'any_all'   => '',
544
-            );
545
-        }
540
+		if ( ! isset($defaults['conditions']) ) {
541
+			$defaults['conditions'] = array(
542
+				'send_stop' => '',
543
+				'any_all'   => '',
544
+			);
545
+		}
546 546
 
547
-        return $defaults;
547
+		return $defaults;
548 548
 	}
549 549
 
550 550
 	public function get_global_switch_fields() {
551
-	    $switch = $this->get_switch_fields();
551
+		$switch = $this->get_switch_fields();
552 552
 		$switch['conditions'] = array( 'hide_field' );
553
-	    return $switch;
553
+		return $switch;
554 554
 	}
555 555
 
556 556
 	/**
557 557
 	 * Migrate settings from form->options into new action.
558 558
 	 */
559 559
 	public function migrate_to_2( $form, $update = 'update' ) {
560
-        $action = $this->prepare_new($form->id);
561
-        $form->options = maybe_unserialize($form->options);
560
+		$action = $this->prepare_new($form->id);
561
+		$form->options = maybe_unserialize($form->options);
562 562
 
563
-        // fill with existing options
564
-        foreach ( $action->post_content as $name => $val ) {
563
+		// fill with existing options
564
+		foreach ( $action->post_content as $name => $val ) {
565 565
 			if ( isset( $form->options[ $name ] ) ) {
566 566
 				$action->post_content[ $name ] = $form->options[ $name ];
567 567
 				unset( $form->options[ $name ] );
568
-            }
569
-        }
568
+			}
569
+		}
570 570
 
571
-        $action = $this->migrate_values($action, $form);
571
+		$action = $this->migrate_values($action, $form);
572 572
 
573
-        // check if action already exists
574
-        $post_id = get_posts( array(
575
-            'name'          => $action->post_name,
576
-            'post_type'     => FrmFormActionsController::$action_post_type,
577
-            'post_status'   => $action->post_status,
578
-            'numberposts'   => 1,
579
-        ) );
573
+		// check if action already exists
574
+		$post_id = get_posts( array(
575
+			'name'          => $action->post_name,
576
+			'post_type'     => FrmFormActionsController::$action_post_type,
577
+			'post_status'   => $action->post_status,
578
+			'numberposts'   => 1,
579
+		) );
580 580
 
581
-        if ( empty($post_id) ) {
582
-            // create action now
583
-            $post_id = $this->save_settings($action);
584
-        }
581
+		if ( empty($post_id) ) {
582
+			// create action now
583
+			$post_id = $this->save_settings($action);
584
+		}
585 585
 
586
-        if ( $post_id && 'update' == $update ) {
587
-            global $wpdb;
588
-            $form->options = maybe_serialize($form->options);
586
+		if ( $post_id && 'update' == $update ) {
587
+			global $wpdb;
588
+			$form->options = maybe_serialize($form->options);
589 589
 
590
-            // update form options
590
+			// update form options
591 591
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => $form->options ), array( 'id' => $form->id ) );
592
-	        FrmForm::clear_form_cache();
593
-        }
592
+			FrmForm::clear_form_cache();
593
+		}
594 594
 
595
-        return $post_id;
596
-    }
595
+		return $post_id;
596
+	}
597 597
 
598 598
 	public static function action_conditions_met( $action, $entry ) {
599 599
 		$notification = $action->post_content;
Please login to merge, or discard this patch.
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -2,16 +2,16 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmFormAction {
4 4
 
5
-	public $id_base;			// Root id for all actions of this type.
6
-	public $name;				// Name for this action type.
5
+	public $id_base; // Root id for all actions of this type.
6
+	public $name; // Name for this action type.
7 7
 	public $option_name;
8
-	public $action_options;     // Option array passed to wp_register_sidebar_widget()
9
-	public $control_options;	// Option array passed to wp_register_widget_control()
8
+	public $action_options; // Option array passed to wp_register_sidebar_widget()
9
+	public $control_options; // Option array passed to wp_register_widget_control()
10 10
 
11
-    public $form_id;        // The ID of the form to evaluate
12
-	public $number = false;	// Unique ID number of the current instance.
13
-	public $id = '';		// Unique ID string of the current instance (id_base-number)
14
-	public $updated = false;	// Set true when we update the data after a POST submit - makes sure we don't do it twice.
11
+    public $form_id; // The ID of the form to evaluate
12
+	public $number = false; // Unique ID number of the current instance.
13
+	public $id = ''; // Unique ID string of the current instance (id_base-number)
14
+	public $updated = false; // Set true when we update the data after a POST submit - makes sure we don't do it twice.
15 15
 
16 16
 	// Member functions that you must over-ride.
17 17
 
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
 	 *	 - height: currently not used but may be needed in the future
70 70
 	 */
71 71
 	public function __construct( $id_base, $name, $action_options = array(), $control_options = array() ) {
72
-	    if ( ! defined('ABSPATH') ) {
73
-            die('You are not allowed to call this page directly.');
72
+	    if ( ! defined( 'ABSPATH' ) ) {
73
+            die( 'You are not allowed to call this page directly.' );
74 74
         }
75 75
 
76
-		$this->id_base = strtolower($id_base);
76
+		$this->id_base = strtolower( $id_base );
77 77
 		$this->name = $name;
78 78
 		$this->option_name = 'frm_' . $this->id_base . '_action';
79 79
 
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
         $default_values = $this->get_global_defaults();
144 144
 
145 145
         // fill default values
146
-        $post_content = wp_parse_args( $post_content, $default_values);
146
+        $post_content = wp_parse_args( $post_content, $default_values );
147 147
 
148
-        if ( ! isset($post_content['event']) && ! $this->action_options['force_event'] ) {
149
-            $post_content['event'] = array( reset($this->action_options['event']) );
148
+        if ( ! isset( $post_content['event'] ) && ! $this->action_options['force_event'] ) {
149
+            $post_content['event'] = array( reset( $this->action_options['event'] ) );
150 150
         }
151 151
 
152 152
         $form_action = array(
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 			'post_name'     => $this->form_id . '_' . $this->id_base . '_' . $this->number,
160 160
             'menu_order'    => $this->form_id,
161 161
         );
162
-        unset($post_content);
162
+        unset( $post_content );
163 163
 
164 164
         return (object) $form_action;
165 165
     }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 
170 170
         $action = $this->prepare_new();
171 171
 
172
-        return $this->save_settings($action);
172
+        return $this->save_settings( $action );
173 173
     }
174 174
 
175 175
 	public function duplicate_form_actions( $form_id, $old_id ) {
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
 
184 184
         $this->form_id = $form_id;
185 185
         foreach ( $actions as $action ) {
186
-            $this->duplicate_one($action, $form_id);
187
-            unset($action);
186
+            $this->duplicate_one( $action, $form_id );
187
+            unset( $action );
188 188
         }
189 189
     }
190 190
 
@@ -196,14 +196,14 @@  discard block
 block discarded – undo
196 196
     * @return integer $post_id
197 197
     */
198 198
     public function maybe_create_action( $action, $forms ) {
199
-		if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && $forms[ $action['menu_order'] ] == 'updated' ) {
199
+		if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && $forms[$action['menu_order']] == 'updated' ) {
200 200
             // Update action only
201 201
             $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
202 202
             $post_id = $this->save_settings( $action );
203 203
         } else {
204 204
             // Create action
205
-            $action['post_content'] = FrmAppHelper::maybe_json_decode($action['post_content']);
206
-            $post_id = $this->duplicate_one( (object) $action, $action['menu_order']);
205
+            $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
206
+            $post_id = $this->duplicate_one( (object) $action, $action['menu_order'] );
207 207
         }
208 208
         return $post_id;
209 209
     }
@@ -214,47 +214,47 @@  discard block
 block discarded – undo
214 214
         $action->menu_order = $form_id;
215 215
         $switch = $this->get_global_switch_fields();
216 216
         foreach ( (array) $action->post_content as $key => $val ) {
217
-			if ( is_numeric( $val ) && isset( $frm_duplicate_ids[ $val ] ) ) {
218
-				$action->post_content[ $key ] = $frm_duplicate_ids[ $val ];
217
+			if ( is_numeric( $val ) && isset( $frm_duplicate_ids[$val] ) ) {
218
+				$action->post_content[$key] = $frm_duplicate_ids[$val];
219 219
             } else if ( ! is_array( $val ) ) {
220
-				$action->post_content[ $key ] = FrmFieldsHelper::switch_field_ids( $val );
221
-			} else if ( isset( $switch[ $key ] ) && is_array( $switch[ $key ] ) ) {
220
+				$action->post_content[$key] = FrmFieldsHelper::switch_field_ids( $val );
221
+			} else if ( isset( $switch[$key] ) && is_array( $switch[$key] ) ) {
222 222
                 // loop through each value if empty
223
-				if ( empty( $switch[ $key ] ) ) {
224
-					$switch[ $key ] = array_keys( $val );
223
+				if ( empty( $switch[$key] ) ) {
224
+					$switch[$key] = array_keys( $val );
225 225
 				}
226 226
 
227
-				foreach ( $switch[ $key ] as $subkey ) {
228
-					$action->post_content[ $key ] = $this->duplicate_array_walk( $action->post_content[ $key ], $subkey, $val );
227
+				foreach ( $switch[$key] as $subkey ) {
228
+					$action->post_content[$key] = $this->duplicate_array_walk( $action->post_content[$key], $subkey, $val );
229 229
                 }
230 230
             }
231 231
 
232
-            unset($key, $val);
232
+            unset( $key, $val );
233 233
         }
234
-        unset($action->ID);
234
+        unset( $action->ID );
235 235
 
236
-        return $this->save_settings($action);
236
+        return $this->save_settings( $action );
237 237
     }
238 238
 
239 239
 	private function duplicate_array_walk( $action, $subkey, $val ) {
240 240
         global $frm_duplicate_ids;
241 241
 
242
-        if ( is_array($subkey) ) {
242
+        if ( is_array( $subkey ) ) {
243 243
             foreach ( $subkey as $subkey2 ) {
244 244
                 foreach ( (array) $val as $ck => $cv ) {
245
-                    if ( is_array($cv) ) {
246
-						$action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey2, $cv );
247
-					} else if ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) {
248
-						$action[ $ck ][ $subkey ] = $frm_duplicate_ids[ $cv[ $subkey ] ];
245
+                    if ( is_array( $cv ) ) {
246
+						$action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey2, $cv );
247
+					} else if ( isset( $cv[$subkey] ) && is_numeric( $cv[$subkey] ) && isset( $frm_duplicate_ids[$cv[$subkey]] ) ) {
248
+						$action[$ck][$subkey] = $frm_duplicate_ids[$cv[$subkey]];
249 249
                     }
250 250
                 }
251 251
             }
252 252
         } else {
253 253
             foreach ( (array) $val as $ck => $cv ) {
254
-                if ( is_array($cv) ) {
255
-					$action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv );
256
-				} else if ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) {
257
-					$action[ $ck ] = $frm_duplicate_ids[ $cv ];
254
+                if ( is_array( $cv ) ) {
255
+					$action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey, $cv );
256
+				} else if ( $ck == $subkey && isset( $frm_duplicate_ids[$cv] ) ) {
257
+					$action[$ck] = $frm_duplicate_ids[$cv];
258 258
                 }
259 259
             }
260 260
         }
@@ -278,8 +278,8 @@  discard block
 block discarded – undo
278 278
  			return;
279 279
  		}
280 280
 
281
-		if ( isset( $_POST[ $this->option_name ] ) && is_array( $_POST[ $this->option_name ] ) ) {
282
-			$settings = $_POST[ $this->option_name ];
281
+		if ( isset( $_POST[$this->option_name] ) && is_array( $_POST[$this->option_name] ) ) {
282
+			$settings = $_POST[$this->option_name];
283 283
  		} else {
284 284
  			return;
285 285
  		}
@@ -287,19 +287,19 @@  discard block
 block discarded – undo
287 287
         $action_ids = array();
288 288
 
289 289
  		foreach ( $settings as $number => $new_instance ) {
290
- 			$this->_set($number);
290
+ 			$this->_set( $number );
291 291
 
292
- 			if ( ! isset($new_instance['post_title']) ) {
292
+ 			if ( ! isset( $new_instance['post_title'] ) ) {
293 293
  			    // settings were never opened, so don't update
294 294
  			    $action_ids[] = $new_instance['ID'];
295 295
          		$this->updated = true;
296 296
          		continue;
297 297
  			}
298 298
 
299
-			$old_instance = isset( $all_instances[ $number ] ) ? $all_instances[ $number ] : array();
299
+			$old_instance = isset( $all_instances[$number] ) ? $all_instances[$number] : array();
300 300
 
301
- 			$new_instance['post_type']  = FrmFormActionsController::$action_post_type;
302
-			$new_instance['post_name']  = $this->form_id . '_' . $this->id_base . '_' . $this->number;
301
+ 			$new_instance['post_type'] = FrmFormActionsController::$action_post_type;
302
+			$new_instance['post_name'] = $this->form_id . '_' . $this->id_base . '_' . $this->number;
303 303
             $new_instance['menu_order']   = $this->form_id;
304 304
             $new_instance['post_status']  = 'publish';
305 305
             $new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : '';
@@ -321,14 +321,14 @@  discard block
 block discarded – undo
321 321
 			 */
322 322
 			$instance = apply_filters( 'frm_action_update_callback', $instance, $new_instance, $old_instance, $this );
323 323
 
324
-			$instance['post_content'] = apply_filters('frm_before_save_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this);
324
+			$instance['post_content'] = apply_filters( 'frm_before_save_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this );
325 325
 			$instance['post_content'] = apply_filters( 'frm_before_save_' . $this->id_base . '_action', $new_instance['post_content'], $instance, $new_instance, $old_instance, $this );
326 326
 
327 327
 			if ( false !== $instance ) {
328
-				$all_instances[ $number ] = $instance;
328
+				$all_instances[$number] = $instance;
329 329
 			}
330 330
 
331
-            $action_ids[] = $this->save_settings($instance);
331
+            $action_ids[] = $this->save_settings( $instance );
332 332
 
333 333
      		$this->updated = true;
334 334
  		}
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 	}
343 343
 
344 344
 	public function get_single_action( $id ) {
345
-	    $action = get_post($id);
345
+	    $action = get_post( $id );
346 346
 		if ( $action ) {
347 347
 			$action = $this->prepare_action( $action );
348 348
 			$this->_set( $id );
@@ -351,12 +351,12 @@  discard block
 block discarded – undo
351 351
 	}
352 352
 
353 353
 	public function get_one( $form_id ) {
354
-	    return $this->get_all($form_id, 1);
354
+	    return $this->get_all( $form_id, 1 );
355 355
 	}
356 356
 
357 357
     public static function get_action_for_form( $form_id, $type = 'all', $limit = 99 ) {
358 358
         $action_controls = FrmFormActionsController::get_form_actions( $type );
359
-        if ( empty($action_controls) ) {
359
+        if ( empty( $action_controls ) ) {
360 360
             // don't continue if there are no available actions
361 361
             return array();
362 362
         }
@@ -377,12 +377,12 @@  discard block
 block discarded – undo
377 377
 			// some plugins/themes are formatting the post_excerpt
378 378
 			$action->post_excerpt = sanitize_title( $action->post_excerpt );
379 379
 
380
-			if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) {
380
+			if ( ! isset( $action_controls[$action->post_excerpt] ) ) {
381 381
                 continue;
382 382
             }
383 383
 
384
-            $action = $action_controls[ $action->post_excerpt ]->prepare_action( $action );
385
-			$settings[ $action->ID ] = $action;
384
+            $action = $action_controls[$action->post_excerpt]->prepare_action( $action );
385
+			$settings[$action->ID] = $action;
386 386
 
387 387
 			if ( count( $settings ) >= $limit ) {
388 388
 				break;
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
         }
391 391
 
392 392
         if ( 1 === $limit ) {
393
-            $settings = reset($settings);
393
+            $settings = reset( $settings );
394 394
         }
395 395
 
396 396
         return $settings;
@@ -423,33 +423,33 @@  discard block
 block discarded – undo
423 423
 	    global $frm_vars;
424 424
 	    $frm_vars['action_type'] = $type;
425 425
 
426
-	    add_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' );
426
+	    add_filter( 'posts_where', 'FrmFormActionsController::limit_by_type' );
427 427
 		$query = self::action_args( $form_id, $limit );
428 428
         $query['post_status']      = 'any';
429 429
         $query['suppress_filters'] = false;
430 430
 
431 431
 		$actions = FrmAppHelper::check_cache( serialize( $query ) . '_type_' . $type, 'frm_actions', $query, 'get_posts' );
432
-        unset($query);
432
+        unset( $query );
433 433
 
434
-        remove_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' );
434
+        remove_filter( 'posts_where', 'FrmFormActionsController::limit_by_type' );
435 435
 
436
-        if ( empty($actions) ) {
436
+        if ( empty( $actions ) ) {
437 437
             return array();
438 438
         }
439 439
 
440 440
         $settings = array();
441 441
         foreach ( $actions as $action ) {
442
-            if ( count($settings) >= $limit ) {
442
+            if ( count( $settings ) >= $limit ) {
443 443
                 continue;
444 444
             }
445 445
 
446
-            $action = $this->prepare_action($action);
446
+            $action = $this->prepare_action( $action );
447 447
 
448
-			$settings[ $action->ID ] = $action;
448
+			$settings[$action->ID] = $action;
449 449
         }
450 450
 
451 451
         if ( 1 === $limit ) {
452
-            $settings = reset($settings);
452
+            $settings = reset( $settings );
453 453
         }
454 454
 
455 455
         return $settings;
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 	}
473 473
 
474 474
 	public function prepare_action( $action ) {
475
-		$action->post_content = (array) FrmAppHelper::maybe_json_decode($action->post_content);
475
+		$action->post_content = (array) FrmAppHelper::maybe_json_decode( $action->post_content );
476 476
 		$action->post_excerpt = sanitize_title( $action->post_excerpt );
477 477
 
478 478
         $default_values = $this->get_global_defaults();
@@ -481,16 +481,16 @@  discard block
 block discarded – undo
481 481
         $action->post_content += $default_values;
482 482
 
483 483
         foreach ( $default_values as $k => $vals ) {
484
-            if ( is_array($vals) && ! empty($vals) ) {
485
-				if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) {
484
+            if ( is_array( $vals ) && ! empty( $vals ) ) {
485
+				if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[$k] ) ) {
486 486
                     continue;
487 487
                 }
488
-				$action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals );
488
+				$action->post_content[$k] = wp_parse_args( $action->post_content[$k], $vals );
489 489
             }
490 490
         }
491 491
 
492
-        if ( ! is_array($action->post_content['event']) ) {
493
-            $action->post_content['event'] = explode(',', $action->post_content['event']);
492
+        if ( ! is_array( $action->post_content['event'] ) ) {
493
+            $action->post_content['event'] = explode( ',', $action->post_content['event'] );
494 494
         }
495 495
 
496 496
         return $action;
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
         $post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' );
513 513
 
514 514
         foreach ( $post_ids as $id ) {
515
-            wp_delete_post($id);
515
+            wp_delete_post( $id );
516 516
         }
517 517
 		self::clear_cache();
518 518
 	}
@@ -533,11 +533,11 @@  discard block
 block discarded – undo
533 533
 	public function get_global_defaults() {
534 534
 	    $defaults = $this->get_defaults();
535 535
 
536
-	    if ( ! isset($defaults['event']) ) {
536
+	    if ( ! isset( $defaults['event'] ) ) {
537 537
 			$defaults['event'] = array( 'create' );
538 538
 	    }
539 539
 
540
-	    if ( ! isset($defaults['conditions']) ) {
540
+	    if ( ! isset( $defaults['conditions'] ) ) {
541 541
 	        $defaults['conditions'] = array(
542 542
                 'send_stop' => '',
543 543
                 'any_all'   => '',
@@ -557,18 +557,18 @@  discard block
 block discarded – undo
557 557
 	 * Migrate settings from form->options into new action.
558 558
 	 */
559 559
 	public function migrate_to_2( $form, $update = 'update' ) {
560
-        $action = $this->prepare_new($form->id);
561
-        $form->options = maybe_unserialize($form->options);
560
+        $action = $this->prepare_new( $form->id );
561
+        $form->options = maybe_unserialize( $form->options );
562 562
 
563 563
         // fill with existing options
564 564
         foreach ( $action->post_content as $name => $val ) {
565
-			if ( isset( $form->options[ $name ] ) ) {
566
-				$action->post_content[ $name ] = $form->options[ $name ];
567
-				unset( $form->options[ $name ] );
565
+			if ( isset( $form->options[$name] ) ) {
566
+				$action->post_content[$name] = $form->options[$name];
567
+				unset( $form->options[$name] );
568 568
             }
569 569
         }
570 570
 
571
-        $action = $this->migrate_values($action, $form);
571
+        $action = $this->migrate_values( $action, $form );
572 572
 
573 573
         // check if action already exists
574 574
         $post_id = get_posts( array(
@@ -578,14 +578,14 @@  discard block
 block discarded – undo
578 578
             'numberposts'   => 1,
579 579
         ) );
580 580
 
581
-        if ( empty($post_id) ) {
581
+        if ( empty( $post_id ) ) {
582 582
             // create action now
583
-            $post_id = $this->save_settings($action);
583
+            $post_id = $this->save_settings( $action );
584 584
         }
585 585
 
586 586
         if ( $post_id && 'update' == $update ) {
587 587
             global $wpdb;
588
-            $form->options = maybe_serialize($form->options);
588
+            $form->options = maybe_serialize( $form->options );
589 589
 
590 590
             // update form options
591 591
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => $form->options ), array( 'id' => $form->id ) );
@@ -617,18 +617,18 @@  discard block
 block discarded – undo
617 617
 
618 618
 			$observed_value = self::get_value_from_entry( $entry, $condition['hide_field'] );
619 619
 
620
-			$stop = FrmFieldsHelper::value_meets_condition($observed_value, $condition['hide_field_cond'], $condition['hide_opt']);
620
+			$stop = FrmFieldsHelper::value_meets_condition( $observed_value, $condition['hide_field_cond'], $condition['hide_opt'] );
621 621
 
622 622
 			if ( $notification['conditions']['send_stop'] == 'send' ) {
623 623
 				$stop = $stop ? false : true;
624 624
 			}
625 625
 
626
-			$met[ $stop ] = $stop;
626
+			$met[$stop] = $stop;
627 627
 		}
628 628
 
629 629
 		if ( $notification['conditions']['any_all'] == 'all' && ! empty( $met ) && isset( $met[0] ) && isset( $met[1] ) ) {
630
-			$stop = ($notification['conditions']['send_stop'] == 'send');
631
-		} else if ( $notification['conditions']['any_all'] == 'any' && $notification['conditions']['send_stop'] == 'send' && isset($met[0]) ) {
630
+			$stop = ( $notification['conditions']['send_stop'] == 'send' );
631
+		} else if ( $notification['conditions']['any_all'] == 'any' && $notification['conditions']['send_stop'] == 'send' && isset( $met[0] ) ) {
632 632
 			$stop = false;
633 633
 		}
634 634
 
@@ -663,8 +663,8 @@  discard block
 block discarded – undo
663 663
 	private static function get_value_from_entry( $entry, $field_id ) {
664 664
 		$observed_value = '';
665 665
 
666
-		if ( isset( $entry->metas[ $field_id ] ) ) {
667
-			$observed_value = $entry->metas[ $field_id ];
666
+		if ( isset( $entry->metas[$field_id] ) ) {
667
+			$observed_value = $entry->metas[$field_id];
668 668
 		} else if ( $entry->post_id && FrmAppHelper::pro_is_installed() ) {
669 669
 			$field = FrmField::getOne( $field_id );
670 670
 			$observed_value = FrmProEntryMetaHelper::get_post_or_meta_value( $entry, $field, array( 'links' => false, 'truncate' => false ) );
Please login to merge, or discard this patch.
classes/views/frm-fields/single-option.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <li id="frm_delete_field_<?php echo esc_attr( $field['id'] ); ?>-<?php echo esc_attr( $opt_key ) ?>_container" class="frm_single_option">
2 2
     <a href="javascript:void(0)" class="frm_single_visible_hover frm_icon_font frm_delete_icon" data-fid="<?php echo esc_attr( $field['id'] ); ?>"> </a>
3 3
     <?php if ( $field['type'] != 'select' ) { ?>
4
-        <input type="<?php echo esc_attr( $field['type'] ) ?>" name="<?php echo esc_attr( $field_name . ( $field['type'] == 'checkbox' ? '[]' : '' ) ); ?>" value="<?php echo esc_attr($field_val) ?>"<?php echo isset( $checked ) ? $checked : ''; ?>/>
4
+        <input type="<?php echo esc_attr( $field['type'] ) ?>" name="<?php echo esc_attr( $field_name . ( $field['type'] == 'checkbox' ? '[]' : '' ) ); ?>" value="<?php echo esc_attr( $field_val ) ?>"<?php echo isset( $checked ) ? $checked : ''; ?>/>
5 5
     <?php } ?>
6 6
 
7
-	<label class="frm_ipe_field_option field_<?php echo esc_attr( $field['id'] ) ?>_option <?php echo esc_attr( $field['separate_value'] ? 'frm_with_key' : '' ); ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>"><?php echo ($opt == '') ? __( '(Blank)', 'formidable' ) : $opt ?></label>
7
+	<label class="frm_ipe_field_option field_<?php echo esc_attr( $field['id'] ) ?>_option <?php echo esc_attr( $field['separate_value'] ? 'frm_with_key' : '' ); ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>"><?php echo ( $opt == '' ) ? __( '(Blank)', 'formidable' ) : $opt ?></label>
8 8
 	<input type="hidden" name="field_options[options_<?php echo esc_attr( $field['id'] ) ?>][<?php echo esc_attr( $opt_key ) ?>][label]" value="<?php echo esc_attr( $opt ) ?>" />
9 9
 
10 10
     <span class="frm_option_key field_<?php echo esc_attr( $field['id'] ) ?>_option_key<?php echo esc_attr( $field['separate_value'] ? '' : ' frm_hidden' ); ?>">
@@ -13,4 +13,4 @@  discard block
 block discarded – undo
13 13
     </span>
14 14
 </li>
15 15
 <?php
16
-unset($field_val, $opt, $opt_key);
16
+unset( $field_val, $opt, $opt_key );
Please login to merge, or discard this patch.
classes/models/FrmForm.php 2 patches
Indentation   +328 added lines, -328 removed lines patch added patch discarded remove patch
@@ -1,261 +1,261 @@  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
-        $new_values = array(
14
+		$new_values = array(
15 15
 			'form_key'      => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ),
16
-            'name'          => $values['name'],
17
-            'description'   => $values['description'],
18
-            'status'        => isset($values['status']) ? $values['status'] : 'draft',
19
-            'logged_in'     => isset($values['logged_in']) ? $values['logged_in'] : 0,
20
-            'is_template'   => isset($values['is_template']) ? (int) $values['is_template'] : 0,
16
+			'name'          => $values['name'],
17
+			'description'   => $values['description'],
18
+			'status'        => isset($values['status']) ? $values['status'] : 'draft',
19
+			'logged_in'     => isset($values['logged_in']) ? $values['logged_in'] : 0,
20
+			'is_template'   => isset($values['is_template']) ? (int) $values['is_template'] : 0,
21 21
 			'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0,
22
-            'editable'      => isset($values['editable']) ? (int) $values['editable'] : 0,
23
-            'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0,
24
-            'created_at'    => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1),
25
-        );
22
+			'editable'      => isset($values['editable']) ? (int) $values['editable'] : 0,
23
+			'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0,
24
+			'created_at'    => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1),
25
+		);
26 26
 
27 27
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
28 28
 		FrmFormsHelper::fill_form_options( $options, $values );
29 29
 
30
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
31
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
32
-        $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
30
+		$options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
31
+		$options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
32
+		$options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
33 33
 
34
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
35
-        $new_values['options'] = serialize($options);
34
+		$options = apply_filters('frm_form_options_before_update', $options, $values);
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,
70
-            'created_at'    => current_time('mysql', 1),
71
-            'is_template'   => $template ? 1 : 0,
72
-        );
73
-
74
-        if ( $blog_id ) {
75
-            $new_values['status'] = 'published';
76
-            $new_options = maybe_unserialize($values->options);
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
-        }
83
-
84
-        if ( is_array($new_values['options']) ) {
85
-            $new_values['options'] = serialize($new_values['options']);
86
-        }
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
+			'created_at'    => current_time('mysql', 1),
71
+			'is_template'   => $template ? 1 : 0,
72
+		);
73
+
74
+		if ( $blog_id ) {
75
+			$new_values['status'] = 'published';
76
+			$new_options = maybe_unserialize($values->options);
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
+		}
83
+
84
+		if ( is_array($new_values['options']) ) {
85
+			$new_values['options'] = serialize($new_values['options']);
86
+		}
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;
95
-            FrmField::duplicate($id, $form_id, $copy_keys, $blog_id);
94
+			$form_id = $wpdb->insert_id;
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
-        $new_opts = $values['options'] = maybe_unserialize($values['options']);
106
+		$new_opts = $values['options'] = maybe_unserialize($values['options']);
107 107
 
108
-        if ( isset($new_opts['success_msg']) ) {
109
-            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
110
-        }
108
+		if ( isset($new_opts['success_msg']) ) {
109
+			$new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
110
+		}
111 111
 
112
-        $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
112
+		$new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
113 113
 
114
-        if ( $new_opts != $values['options'] ) {
115
-            global $wpdb;
114
+		if ( $new_opts != $values['options'] ) {
115
+			global $wpdb;
116 116
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $new_opts ) ), array( 'id' => $form_id ) );
117
-        }
118
-    }
117
+		}
118
+	}
119 119
 
120
-    /**
121
-     * @return int|boolean
122
-     */
123
-    public static function update( $id, $values, $create_link = false ) {
124
-        global $wpdb;
120
+	/**
121
+	 * @return int|boolean
122
+	 */
123
+	public static function update( $id, $values, $create_link = false ) {
124
+		global $wpdb;
125 125
 
126
-        if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) {
127
-            $values['status'] = 'published';
128
-        }
126
+		if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) {
127
+			$values['status'] = 'published';
128
+		}
129 129
 
130
-        if ( isset($values['form_key']) ) {
130
+		if ( isset($values['form_key']) ) {
131 131
 			$values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id );
132
-        }
132
+		}
133 133
 
134 134
 		$form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
135 135
 
136
-        $new_values = self::set_update_options( array(), $values);
136
+		$new_values = self::set_update_options( array(), $values);
137 137
 
138
-        foreach ( $values as $value_key => $value ) {
139
-            if ( in_array($value_key, $form_fields) ) {
138
+		foreach ( $values as $value_key => $value ) {
139
+			if ( in_array($value_key, $form_fields) ) {
140 140
 				$new_values[ $value_key ] = $value;
141
-            }
142
-        }
141
+			}
142
+		}
143 143
 
144
-        if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) {
145
-            $new_values['status'] = $values['new_status'];
146
-        }
144
+		if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) {
145
+			$new_values['status'] = $values['new_status'];
146
+		}
147 147
 
148
-        if ( ! empty( $new_values ) ) {
148
+		if ( ! empty( $new_values ) ) {
149 149
 			$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $id ) );
150
-            if ( $query_results ) {
150
+			if ( $query_results ) {
151 151
 				self::clear_form_cache();
152
-            }
153
-        } else {
154
-            $query_results = true;
155
-        }
156
-        unset($new_values);
152
+			}
153
+		} else {
154
+			$query_results = true;
155
+		}
156
+		unset($new_values);
157 157
 
158
-        $values = self::update_fields($id, $values);
158
+		$values = self::update_fields($id, $values);
159 159
 
160 160
 		do_action( 'frm_update_form', $id, $values );
161 161
 		do_action( 'frm_update_form_' . $id, $values );
162 162
 
163
-        return $query_results;
164
-    }
163
+		return $query_results;
164
+	}
165 165
 
166
-    /**
167
-     * @return array
168
-     */
166
+	/**
167
+	 * @return array
168
+	 */
169 169
 	public static function set_update_options( $new_values, $values ) {
170
-        if ( ! isset($values['options']) ) {
171
-            return $new_values;
172
-        }
170
+		if ( ! isset($values['options']) ) {
171
+			return $new_values;
172
+		}
173 173
 
174 174
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
175 175
 		FrmFormsHelper::fill_form_options( $options, $values );
176 176
 
177
-        $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
178
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
179
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
180
-        $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
177
+		$options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
178
+		$options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
179
+		$options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
180
+		$options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
181 181
 
182
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
183
-        $new_values['options'] = serialize($options);
182
+		$options = apply_filters('frm_form_options_before_update', $options, $values);
183
+		$new_values['options'] = serialize($options);
184 184
 
185
-        return $new_values;
186
-    }
185
+		return $new_values;
186
+	}
187 187
 
188 188
 
189
-    /**
190
-     * @return array
191
-     */
189
+	/**
190
+	 * @return array
191
+	 */
192 192
 	public static function update_fields( $id, $values ) {
193 193
 
194
-        if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
195
-            return $values;
196
-        }
194
+		if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
195
+			return $values;
196
+		}
197 197
 
198
-        $all_fields = FrmField::get_all_for_form($id);
199
-        if ( empty($all_fields) ) {
200
-            return $values;
201
-        }
198
+		$all_fields = FrmField::get_all_for_form($id);
199
+		if ( empty($all_fields) ) {
200
+			return $values;
201
+		}
202 202
 
203
-        if ( ! isset($values['item_meta']) ) {
204
-            $values['item_meta'] = array();
205
-        }
203
+		if ( ! isset($values['item_meta']) ) {
204
+			$values['item_meta'] = array();
205
+		}
206 206
 
207
-        $field_array = array();
208
-        $existing_keys = array_keys($values['item_meta']);
209
-        foreach ( $all_fields as $fid ) {
210
-            if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
207
+		$field_array = array();
208
+		$existing_keys = array_keys($values['item_meta']);
209
+		foreach ( $all_fields as $fid ) {
210
+			if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
211 211
 				$values['item_meta'][ $fid->id ] = '';
212
-            }
212
+			}
213 213
 			$field_array[ $fid->id ] = $fid;
214
-        }
215
-        unset($all_fields);
214
+		}
215
+		unset($all_fields);
216 216
 
217
-        foreach ( $values['item_meta'] as $field_id => $default_value ) {
217
+		foreach ( $values['item_meta'] as $field_id => $default_value ) {
218 218
 			if ( isset( $field_array[ $field_id ] ) ) {
219 219
 				$field = $field_array[ $field_id ];
220
-            } else {
221
-                $field = FrmField::getOne($field_id);
222
-            }
220
+			} else {
221
+				$field = FrmField::getOne($field_id);
222
+			}
223 223
 
224
-            if ( ! $field ) {
225
-                continue;
226
-            }
224
+			if ( ! $field ) {
225
+				continue;
226
+			}
227 227
 
228 228
 			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) );
229 229
 			if ( $is_settings_page ) {
230
-                //updating the settings page
230
+				//updating the settings page
231 231
 				if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) {
232 232
 					$field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) );
233
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
233
+					$field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
234 234
 					FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
235
-                } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
236
-                    $prev_opts = $field->field_options;
237
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
238
-                    if ( $prev_opts != $field->field_options ) {
235
+				} else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
236
+					$prev_opts = $field->field_options;
237
+					$field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
238
+					if ( $prev_opts != $field->field_options ) {
239 239
 						FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
240
-                    }
241
-                    unset($prev_opts);
242
-                }
243
-            }
240
+					}
241
+					unset($prev_opts);
242
+				}
243
+			}
244 244
 
245 245
 			if ( $is_settings_page && ! defined( 'WP_IMPORTING' ) ) {
246
-                continue;
247
-            }
246
+				continue;
247
+			}
248 248
 
249
-            //updating the form
249
+			//updating the form
250 250
 			$update_options = FrmFieldsHelper::get_default_field_opts( $field->type, $field, true );
251 251
 			unset( $update_options['custom_html'] ); // don't check for POST html
252 252
 			$update_options = apply_filters( 'frm_field_options_to_update', $update_options );
253 253
 
254 254
 			foreach ( $update_options as $opt => $default ) {
255 255
 				$field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default;
256
-            }
256
+			}
257 257
 
258
-            $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
258
+			$field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
259 259
 			$default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
260 260
 
261 261
 			$new_field = array(
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
 
268 268
 			FrmField::update( $field_id, $new_field );
269 269
 
270
-            FrmField::delete_form_transient($field->form_id);
271
-        }
270
+			FrmField::delete_form_transient($field->form_id);
271
+		}
272 272
 		self::clear_form_cache();
273 273
 
274
-        return $values;
275
-    }
274
+		return $values;
275
+	}
276 276
 
277 277
 	private static function prepare_field_update_values( $field, $values, &$new_field ) {
278 278
 		$field_cols = array(
@@ -285,113 +285,113 @@  discard block
 block discarded – undo
285 285
 		}
286 286
 	}
287 287
 
288
-    /**
289
-     * @param string $status
290
-     * @return int|boolean
291
-     */
288
+	/**
289
+	 * @param string $status
290
+	 * @return int|boolean
291
+	 */
292 292
 	public static function set_status( $id, $status ) {
293
-        if ( 'trash' == $status ) {
294
-            return self::trash($id);
295
-        }
293
+		if ( 'trash' == $status ) {
294
+			return self::trash($id);
295
+		}
296 296
 
297 297
 		$statuses  = array( 'published', 'draft', 'trash' );
298
-        if ( ! in_array( $status, $statuses ) ) {
299
-            return false;
300
-        }
298
+		if ( ! in_array( $status, $statuses ) ) {
299
+			return false;
300
+		}
301 301
 
302
-        global $wpdb;
302
+		global $wpdb;
303 303
 
304
-        if ( is_array($id) ) {
304
+		if ( is_array($id) ) {
305 305
 			$where = array( 'id' => $id, 'parent_form_id' => $id, 'or' => 1 );
306 306
 			FrmDb::get_where_clause_and_values( $where );
307 307
 			array_unshift( $where['values'], $status );
308 308
 
309 309
 			$query_results = $wpdb->query( $wpdb->prepare( 'UPDATE ' . $wpdb->prefix . 'frm_forms SET status = %s ' . $where['where'], $where['values'] ) );
310
-        } else {
310
+		} else {
311 311
 			$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'id' => $id ) );
312 312
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'parent_form_id' => $id ) );
313
-        }
313
+		}
314 314
 
315
-        if ( $query_results ) {
315
+		if ( $query_results ) {
316 316
 			self::clear_form_cache();
317
-        }
317
+		}
318 318
 
319
-        return $query_results;
320
-    }
319
+		return $query_results;
320
+	}
321 321
 
322
-    /**
323
-     * @return int|boolean
324
-     */
322
+	/**
323
+	 * @return int|boolean
324
+	 */
325 325
 	public static function trash( $id ) {
326
-        if ( ! EMPTY_TRASH_DAYS ) {
327
-            return self::destroy( $id );
328
-        }
326
+		if ( ! EMPTY_TRASH_DAYS ) {
327
+			return self::destroy( $id );
328
+		}
329 329
 
330
-        $form = self::getOne($id);
331
-        if ( ! $form ) {
332
-            return false;
333
-        }
330
+		$form = self::getOne($id);
331
+		if ( ! $form ) {
332
+			return false;
333
+		}
334 334
 
335
-        $options = $form->options;
336
-        $options['trash_time'] = time();
335
+		$options = $form->options;
336
+		$options['trash_time'] = time();
337 337
 
338
-        global $wpdb;
339
-        $query_results = $wpdb->update(
338
+		global $wpdb;
339
+		$query_results = $wpdb->update(
340 340
 			$wpdb->prefix . 'frm_forms',
341 341
 			array( 'status' => 'trash', 'options' => serialize( $options ) ),
342 342
 			array( 'id' => $id )
343
-        );
343
+		);
344 344
 
345
-        $wpdb->update(
345
+		$wpdb->update(
346 346
 			$wpdb->prefix . 'frm_forms',
347 347
 			array( 'status' => 'trash', 'options' => serialize( $options ) ),
348 348
 			array( 'parent_form_id' => $id )
349
-        );
349
+		);
350 350
 
351
-        if ( $query_results ) {
351
+		if ( $query_results ) {
352 352
 			self::clear_form_cache();
353
-        }
353
+		}
354 354
 
355
-        return $query_results;
356
-    }
355
+		return $query_results;
356
+	}
357 357
 
358
-    /**
359
-     * @return int|boolean
360
-     */
358
+	/**
359
+	 * @return int|boolean
360
+	 */
361 361
 	public static function destroy( $id ) {
362
-        global $wpdb;
362
+		global $wpdb;
363 363
 
364
-        $form = self::getOne($id);
365
-        if ( ! $form ) {
366
-            return false;
367
-        }
364
+		$form = self::getOne($id);
365
+		if ( ! $form ) {
366
+			return false;
367
+		}
368 368
 		$id = $form->id;
369 369
 
370
-        // Disconnect the entries from this form
370
+		// Disconnect the entries from this form
371 371
 		$entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) );
372
-        foreach ( $entries as $entry_id ) {
373
-            FrmEntry::destroy($entry_id);
374
-            unset($entry_id);
375
-        }
372
+		foreach ( $entries as $entry_id ) {
373
+			FrmEntry::destroy($entry_id);
374
+			unset($entry_id);
375
+		}
376 376
 
377
-        // Disconnect the fields from this form
377
+		// Disconnect the fields from this form
378 378
 		$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 ) );
379 379
 
380 380
 		$query_results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id ) );
381
-        if ( $query_results ) {
382
-            // Delete all form actions linked to this form
383
-            $action_control = FrmFormActionsController::get_form_actions( 'email' );
384
-            $action_control->destroy($id, 'all');
381
+		if ( $query_results ) {
382
+			// Delete all form actions linked to this form
383
+			$action_control = FrmFormActionsController::get_form_actions( 'email' );
384
+			$action_control->destroy($id, 'all');
385 385
 
386 386
 			// Clear form caching
387 387
 			self::clear_form_cache();
388 388
 
389 389
 			do_action( 'frm_destroy_form', $id );
390 390
 			do_action( 'frm_destroy_form_' . $id );
391
-        }
391
+		}
392 392
 
393
-        return $query_results;
394
-    }
393
+		return $query_results;
394
+	}
395 395
 
396 396
 	/**
397 397
 	 * Delete trashed forms based on how long they have been trashed
@@ -423,49 +423,49 @@  discard block
 block discarded – undo
423 423
 		return $count;
424 424
 	}
425 425
 
426
-    /**
427
-     * @return string form name
428
-     */
429
-    public static function &getName( $id ) {
430
-        global $wpdb;
431
-
432
-        $form = FrmAppHelper::check_cache($id, 'frm_form');
433
-        if ( $form ) {
434
-            $r = stripslashes($form->name);
435
-            return $r;
436
-        }
437
-
438
-        $query_key = is_numeric( $id ) ? 'id' : 'form_key';
439
-        $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
440
-        $r = stripslashes($r);
441
-
442
-        return $r;
443
-    }
444
-
445
-    /**
446
-     * @param string $key
447
-     * @return int form id
448
-     */
426
+	/**
427
+	 * @return string form name
428
+	 */
429
+	public static function &getName( $id ) {
430
+		global $wpdb;
431
+
432
+		$form = FrmAppHelper::check_cache($id, 'frm_form');
433
+		if ( $form ) {
434
+			$r = stripslashes($form->name);
435
+			return $r;
436
+		}
437
+
438
+		$query_key = is_numeric( $id ) ? 'id' : 'form_key';
439
+		$r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
440
+		$r = stripslashes($r);
441
+
442
+		return $r;
443
+	}
444
+
445
+	/**
446
+	 * @param string $key
447
+	 * @return int form id
448
+	 */
449 449
 	public static function &getIdByKey( $key ) {
450
-        $id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) );
451
-        return $id;
452
-    }
453
-
454
-    /**
455
-     * @param int $id
456
-     * @return string form key
457
-     */
450
+		$id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) );
451
+		return $id;
452
+	}
453
+
454
+	/**
455
+	 * @param int $id
456
+	 * @return string form key
457
+	 */
458 458
 	public static function &getKeyById( $id ) {
459
-        $id = (int) $id;
460
-        $cache = FrmAppHelper::check_cache($id, 'frm_form');
461
-        if ( $cache ) {
462
-            return $cache->form_key;
463
-        }
459
+		$id = (int) $id;
460
+		$cache = FrmAppHelper::check_cache($id, 'frm_form');
461
+		if ( $cache ) {
462
+			return $cache->form_key;
463
+		}
464 464
 
465
-        $key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' );
465
+		$key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' );
466 466
 
467
-        return $key;
468
-    }
467
+		return $key;
468
+	}
469 469
 
470 470
 	/**
471 471
 	 * If $form is numeric, get the form object
@@ -478,47 +478,47 @@  discard block
 block discarded – undo
478 478
 		}
479 479
 	}
480 480
 
481
-    /**
482
-     * @return object form
483
-     */
484
-    public static function getOne( $id, $blog_id = false ) {
485
-        global $wpdb;
481
+	/**
482
+	 * @return object form
483
+	 */
484
+	public static function getOne( $id, $blog_id = false ) {
485
+		global $wpdb;
486 486
 
487
-        if ( $blog_id && is_multisite() ) {
488
-            global $wpmuBaseTablePrefix;
487
+		if ( $blog_id && is_multisite() ) {
488
+			global $wpmuBaseTablePrefix;
489 489
 			$prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix . $blog_id . '_' : $wpdb->get_blog_prefix( $blog_id );
490 490
 
491 491
 			$table_name = $prefix . 'frm_forms';
492
-        } else {
492
+		} else {
493 493
 			$table_name = $wpdb->prefix . 'frm_forms';
494
-            $cache = wp_cache_get($id, 'frm_form');
495
-            if ( $cache ) {
496
-                if ( isset($cache->options) ) {
497
-                    $cache->options = maybe_unserialize($cache->options);
498
-                }
494
+			$cache = wp_cache_get($id, 'frm_form');
495
+			if ( $cache ) {
496
+				if ( isset($cache->options) ) {
497
+					$cache->options = maybe_unserialize($cache->options);
498
+				}
499 499
 
500
-                return stripslashes_deep($cache);
501
-            }
502
-        }
500
+				return stripslashes_deep($cache);
501
+			}
502
+		}
503 503
 
504
-        if ( is_numeric($id) ) {
505
-            $where = array( 'id' => $id );
506
-        } else {
507
-            $where = array( 'form_key' => $id );
508
-        }
504
+		if ( is_numeric($id) ) {
505
+			$where = array( 'id' => $id );
506
+		} else {
507
+			$where = array( 'form_key' => $id );
508
+		}
509 509
 
510
-        $results = FrmDb::get_row( $table_name, $where );
510
+		$results = FrmDb::get_row( $table_name, $where );
511 511
 
512
-        if ( isset($results->options) ) {
512
+		if ( isset($results->options) ) {
513 513
 			FrmAppHelper::set_cache( $results->id, $results, 'frm_form' );
514
-            $results->options = maybe_unserialize($results->options);
515
-        }
516
-        return stripslashes_deep($results);
517
-    }
518
-
519
-    /**
520
-     * @return object|array of objects
521
-     */
514
+			$results->options = maybe_unserialize($results->options);
515
+		}
516
+		return stripslashes_deep($results);
517
+	}
518
+
519
+	/**
520
+	 * @return object|array of objects
521
+	 */
522 522
 	public static function getAll( $where = array(), $order_by = '', $limit = '' ) {
523 523
 		if ( is_array( $where ) && ! empty( $where ) ) {
524 524
 			$results = FrmDb::get_results( 'frm_forms', $where, '*', array( 'order_by' => $order_by, 'limit' => $limit ) );
@@ -542,8 +542,8 @@  discard block
 block discarded – undo
542 542
 			$results = reset( $results );
543 543
 		}
544 544
 
545
-        return stripslashes_deep($results);
546
-    }
545
+		return stripslashes_deep($results);
546
+	}
547 547
 
548 548
 	/**
549 549
 	 * Get all published forms
@@ -561,47 +561,47 @@  discard block
 block discarded – undo
561 561
 		return $forms;
562 562
 	}
563 563
 
564
-    /**
565
-     * @return int count of forms
566
-     */
567
-    public static function &get_count() {
568
-    	global $wpdb;
564
+	/**
565
+	 * @return int count of forms
566
+	 */
567
+	public static function &get_count() {
568
+		global $wpdb;
569 569
 
570
-    	$cache_key = 'frm_form_counts';
570
+		$cache_key = 'frm_form_counts';
571 571
 
572
-    	$counts = wp_cache_get( $cache_key, 'frm_form' );
573
-    	if ( false !== $counts ) {
574
-    	    return $counts;
575
-    	}
572
+		$counts = wp_cache_get( $cache_key, 'frm_form' );
573
+		if ( false !== $counts ) {
574
+			return $counts;
575
+		}
576 576
 
577
-        $results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' );
577
+		$results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' );
578 578
 
579 579
 		$statuses = array( 'published', 'draft', 'template', 'trash' );
580
-    	$counts = array_fill_keys( $statuses, 0 );
580
+		$counts = array_fill_keys( $statuses, 0 );
581 581
 
582
-    	foreach ( $results as $row ) {
583
-            if ( 'trash' != $row->status ) {
584
-    	        if ( $row->is_template ) {
582
+		foreach ( $results as $row ) {
583
+			if ( 'trash' != $row->status ) {
584
+				if ( $row->is_template ) {
585 585
 					$counts['template']++;
586
-    	        } else {
586
+				} else {
587 587
 					$counts['published']++;
588
-    	        }
589
-    	    } else {
588
+				}
589
+			} else {
590 590
 				$counts['trash']++;
591
-        	}
591
+			}
592 592
 
593
-    	    if ( 'draft' == $row->status ) {
593
+			if ( 'draft' == $row->status ) {
594 594
 				$counts['draft']++;
595
-    	    }
595
+			}
596 596
 
597
-    		unset($row);
598
-    	}
597
+			unset($row);
598
+		}
599 599
 
600
-    	$counts = (object) $counts;
600
+		$counts = (object) $counts;
601 601
 		FrmAppHelper::set_cache( $cache_key, $counts, 'frm_form' );
602 602
 
603
-    	return $counts;
604
-    }
603
+		return $counts;
604
+	}
605 605
 
606 606
 	/**
607 607
 	 * Clear form caching
@@ -614,14 +614,14 @@  discard block
 block discarded – undo
614 614
 		FrmAppHelper::cache_delete_group( 'frm_form' );
615 615
 	}
616 616
 
617
-    /**
618
-     * @return array of errors
619
-     */
617
+	/**
618
+	 * @return array of errors
619
+	 */
620 620
 	public static function validate( $values ) {
621
-        $errors = array();
621
+		$errors = array();
622 622
 
623
-        return apply_filters('frm_validate_form', $errors, $values);
624
-    }
623
+		return apply_filters('frm_validate_form', $errors, $values);
624
+	}
625 625
 
626 626
 	public static function get_params( $form = null ) {
627 627
 		global $frm_vars;
Please login to merge, or discard this patch.
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
3
-    die('You are not allowed to call this page directly.');
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+    die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
6 6
 class FrmForm {
@@ -15,24 +15,24 @@  discard block
 block discarded – undo
15 15
 			'form_key'      => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ),
16 16
             'name'          => $values['name'],
17 17
             'description'   => $values['description'],
18
-            'status'        => isset($values['status']) ? $values['status'] : 'draft',
19
-            'logged_in'     => isset($values['logged_in']) ? $values['logged_in'] : 0,
20
-            'is_template'   => isset($values['is_template']) ? (int) $values['is_template'] : 0,
18
+            'status'        => isset( $values['status'] ) ? $values['status'] : 'draft',
19
+            'logged_in'     => isset( $values['logged_in'] ) ? $values['logged_in'] : 0,
20
+            'is_template'   => isset( $values['is_template'] ) ? (int) $values['is_template'] : 0,
21 21
 			'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0,
22
-            'editable'      => isset($values['editable']) ? (int) $values['editable'] : 0,
23
-            'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0,
24
-            'created_at'    => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1),
22
+            'editable'      => isset( $values['editable'] ) ? (int) $values['editable'] : 0,
23
+            'default_template' => isset( $values['default_template'] ) ? (int) $values['default_template'] : 0,
24
+            'created_at'    => isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ),
25 25
         );
26 26
 
27 27
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
28 28
 		FrmFormsHelper::fill_form_options( $options, $values );
29 29
 
30
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
31
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
32
-        $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
30
+        $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' );
31
+        $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' );
32
+        $options['submit_html'] = isset( $values['options']['submit_html'] ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' );
33 33
 
34
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
35
-        $new_values['options'] = serialize($options);
34
+        $options = apply_filters( 'frm_form_options_before_update', $options, $values );
35
+        $new_values['options'] = serialize( $options );
36 36
 
37 37
         //if(isset($values['id']) && is_numeric($values['id']))
38 38
         //    $new_values['id'] = $values['id'];
@@ -67,22 +67,22 @@  discard block
 block discarded – undo
67 67
             'status'        => $template ? 'published' : 'draft',
68 68
             'logged_in'     => $values->logged_in ? $values->logged_in : 0,
69 69
             'editable'      => $values->editable ? $values->editable : 0,
70
-            'created_at'    => current_time('mysql', 1),
70
+            'created_at'    => current_time( 'mysql', 1 ),
71 71
             'is_template'   => $template ? 1 : 0,
72 72
         );
73 73
 
74 74
         if ( $blog_id ) {
75 75
             $new_values['status'] = 'published';
76
-            $new_options = maybe_unserialize($values->options);
77
-            $new_options['email_to'] = get_option('admin_email');
76
+            $new_options = maybe_unserialize( $values->options );
77
+            $new_options['email_to'] = get_option( 'admin_email' );
78 78
             $new_options['copy'] = false;
79 79
             $new_values['options'] = $new_options;
80 80
         } else {
81 81
             $new_values['options'] = $values->options;
82 82
         }
83 83
 
84
-        if ( is_array($new_values['options']) ) {
85
-            $new_values['options'] = serialize($new_values['options']);
84
+        if ( is_array( $new_values['options'] ) ) {
85
+            $new_values['options'] = serialize( $new_values['options'] );
86 86
         }
87 87
 
88 88
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 			self::clear_form_cache();
93 93
 
94 94
             $form_id = $wpdb->insert_id;
95
-            FrmField::duplicate($id, $form_id, $copy_keys, $blog_id);
95
+            FrmField::duplicate( $id, $form_id, $copy_keys, $blog_id );
96 96
 
97 97
             // update form settings after fields are created
98 98
 			do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) );
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
     }
104 104
 
105 105
 	public static function after_duplicate( $form_id, $values ) {
106
-        $new_opts = $values['options'] = maybe_unserialize($values['options']);
106
+        $new_opts = $values['options'] = maybe_unserialize( $values['options'] );
107 107
 
108
-        if ( isset($new_opts['success_msg']) ) {
109
-            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
108
+        if ( isset( $new_opts['success_msg'] ) ) {
109
+            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids( $new_opts['success_msg'] );
110 110
         }
111 111
 
112
-        $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
112
+        $new_opts = apply_filters( 'frm_after_duplicate_form_values', $new_opts, $form_id );
113 113
 
114 114
         if ( $new_opts != $values['options'] ) {
115 115
             global $wpdb;
@@ -127,17 +127,17 @@  discard block
 block discarded – undo
127 127
             $values['status'] = 'published';
128 128
         }
129 129
 
130
-        if ( isset($values['form_key']) ) {
130
+        if ( isset( $values['form_key'] ) ) {
131 131
 			$values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id );
132 132
         }
133 133
 
134 134
 		$form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
135 135
 
136
-        $new_values = self::set_update_options( array(), $values);
136
+        $new_values = self::set_update_options( array(), $values );
137 137
 
138 138
         foreach ( $values as $value_key => $value ) {
139
-            if ( in_array($value_key, $form_fields) ) {
140
-				$new_values[ $value_key ] = $value;
139
+            if ( in_array( $value_key, $form_fields ) ) {
140
+				$new_values[$value_key] = $value;
141 141
             }
142 142
         }
143 143
 
@@ -153,9 +153,9 @@  discard block
 block discarded – undo
153 153
         } else {
154 154
             $query_results = true;
155 155
         }
156
-        unset($new_values);
156
+        unset( $new_values );
157 157
 
158
-        $values = self::update_fields($id, $values);
158
+        $values = self::update_fields( $id, $values );
159 159
 
160 160
 		do_action( 'frm_update_form', $id, $values );
161 161
 		do_action( 'frm_update_form_' . $id, $values );
@@ -167,20 +167,20 @@  discard block
 block discarded – undo
167 167
      * @return array
168 168
      */
169 169
 	public static function set_update_options( $new_values, $values ) {
170
-        if ( ! isset($values['options']) ) {
170
+        if ( ! isset( $values['options'] ) ) {
171 171
             return $new_values;
172 172
         }
173 173
 
174 174
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
175 175
 		FrmFormsHelper::fill_form_options( $options, $values );
176 176
 
177
-        $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
178
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
179
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
180
-        $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
177
+        $options['custom_style'] = isset( $values['options']['custom_style'] ) ? $values['options']['custom_style'] : 0;
178
+        $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' );
179
+        $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' );
180
+        $options['submit_html'] = ( isset( $values['options']['submit_html'] ) && $values['options']['submit_html'] != '' ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' );
181 181
 
182
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
183
-        $new_values['options'] = serialize($options);
182
+        $options = apply_filters( 'frm_form_options_before_update', $options, $values );
183
+        $new_values['options'] = serialize( $options );
184 184
 
185 185
         return $new_values;
186 186
     }
@@ -191,54 +191,54 @@  discard block
 block discarded – undo
191 191
      */
192 192
 	public static function update_fields( $id, $values ) {
193 193
 
194
-        if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
194
+        if ( ! isset( $values['options'] ) && ! isset( $values['item_meta'] ) && ! isset( $values['field_options'] ) ) {
195 195
             return $values;
196 196
         }
197 197
 
198
-        $all_fields = FrmField::get_all_for_form($id);
199
-        if ( empty($all_fields) ) {
198
+        $all_fields = FrmField::get_all_for_form( $id );
199
+        if ( empty( $all_fields ) ) {
200 200
             return $values;
201 201
         }
202 202
 
203
-        if ( ! isset($values['item_meta']) ) {
203
+        if ( ! isset( $values['item_meta'] ) ) {
204 204
             $values['item_meta'] = array();
205 205
         }
206 206
 
207 207
         $field_array = array();
208
-        $existing_keys = array_keys($values['item_meta']);
208
+        $existing_keys = array_keys( $values['item_meta'] );
209 209
         foreach ( $all_fields as $fid ) {
210
-            if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
211
-				$values['item_meta'][ $fid->id ] = '';
210
+            if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) {
211
+				$values['item_meta'][$fid->id] = '';
212 212
             }
213
-			$field_array[ $fid->id ] = $fid;
213
+			$field_array[$fid->id] = $fid;
214 214
         }
215
-        unset($all_fields);
215
+        unset( $all_fields );
216 216
 
217 217
         foreach ( $values['item_meta'] as $field_id => $default_value ) {
218
-			if ( isset( $field_array[ $field_id ] ) ) {
219
-				$field = $field_array[ $field_id ];
218
+			if ( isset( $field_array[$field_id] ) ) {
219
+				$field = $field_array[$field_id];
220 220
             } else {
221
-                $field = FrmField::getOne($field_id);
221
+                $field = FrmField::getOne( $field_id );
222 222
             }
223 223
 
224 224
             if ( ! $field ) {
225 225
                 continue;
226 226
             }
227 227
 
228
-			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) );
228
+			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) );
229 229
 			if ( $is_settings_page ) {
230 230
                 //updating the settings page
231
-				if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) {
232
-					$field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) );
233
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
231
+				if ( isset( $values['field_options']['custom_html_' . $field_id] ) ) {
232
+					$field->field_options['custom_html'] = isset( $values['field_options']['custom_html_' . $field_id] ) ? $values['field_options']['custom_html_' . $field_id] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) );
233
+                    $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values );
234 234
 					FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
235 235
                 } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
236 236
                     $prev_opts = $field->field_options;
237
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
237
+                    $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values );
238 238
                     if ( $prev_opts != $field->field_options ) {
239 239
 						FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
240 240
                     }
241
-                    unset($prev_opts);
241
+                    unset( $prev_opts );
242 242
                 }
243 243
             }
244 244
 
@@ -252,11 +252,11 @@  discard block
 block discarded – undo
252 252
 			$update_options = apply_filters( 'frm_field_options_to_update', $update_options );
253 253
 
254 254
 			foreach ( $update_options as $opt => $default ) {
255
-				$field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default;
255
+				$field->field_options[$opt] = isset( $values['field_options'][$opt . '_' . $field_id] ) ? trim( sanitize_text_field( $values['field_options'][$opt . '_' . $field_id] ) ) : $default;
256 256
             }
257 257
 
258
-            $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
259
-			$default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
258
+            $field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values );
259
+			$default_value = maybe_serialize( $values['item_meta'][$field_id] );
260 260
 
261 261
 			$new_field = array(
262 262
 				'field_options' => $field->field_options,
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 
268 268
 			FrmField::update( $field_id, $new_field );
269 269
 
270
-            FrmField::delete_form_transient($field->form_id);
270
+            FrmField::delete_form_transient( $field->form_id );
271 271
         }
272 272
 		self::clear_form_cache();
273 273
 
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 		);
282 282
 		foreach ( $field_cols as $col => $default ) {
283 283
 			$default = ( $default == '' ) ? $field->{$col} : $default;
284
-			$new_field[ $col ] = isset( $values['field_options'][ $col . '_' . $field->id ] ) ? $values['field_options'][ $col . '_' . $field->id ] : $default;
284
+			$new_field[$col] = isset( $values['field_options'][$col . '_' . $field->id] ) ? $values['field_options'][$col . '_' . $field->id] : $default;
285 285
 		}
286 286
 	}
287 287
 
@@ -291,17 +291,17 @@  discard block
 block discarded – undo
291 291
      */
292 292
 	public static function set_status( $id, $status ) {
293 293
         if ( 'trash' == $status ) {
294
-            return self::trash($id);
294
+            return self::trash( $id );
295 295
         }
296 296
 
297
-		$statuses  = array( 'published', 'draft', 'trash' );
297
+		$statuses = array( 'published', 'draft', 'trash' );
298 298
         if ( ! in_array( $status, $statuses ) ) {
299 299
             return false;
300 300
         }
301 301
 
302 302
         global $wpdb;
303 303
 
304
-        if ( is_array($id) ) {
304
+        if ( is_array( $id ) ) {
305 305
 			$where = array( 'id' => $id, 'parent_form_id' => $id, 'or' => 1 );
306 306
 			FrmDb::get_where_clause_and_values( $where );
307 307
 			array_unshift( $where['values'], $status );
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
             return self::destroy( $id );
328 328
         }
329 329
 
330
-        $form = self::getOne($id);
330
+        $form = self::getOne( $id );
331 331
         if ( ! $form ) {
332 332
             return false;
333 333
         }
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	public static function destroy( $id ) {
362 362
         global $wpdb;
363 363
 
364
-        $form = self::getOne($id);
364
+        $form = self::getOne( $id );
365 365
         if ( ! $form ) {
366 366
             return false;
367 367
         }
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
         // Disconnect the entries from this form
371 371
 		$entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) );
372 372
         foreach ( $entries as $entry_id ) {
373
-            FrmEntry::destroy($entry_id);
374
-            unset($entry_id);
373
+            FrmEntry::destroy( $entry_id );
374
+            unset( $entry_id );
375 375
         }
376 376
 
377 377
         // Disconnect the fields from this form
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
         if ( $query_results ) {
382 382
             // Delete all form actions linked to this form
383 383
             $action_control = FrmFormActionsController::get_form_actions( 'email' );
384
-            $action_control->destroy($id, 'all');
384
+            $action_control->destroy( $id, 'all' );
385 385
 
386 386
 			// Clear form caching
387 387
 			self::clear_form_cache();
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 			$form->options = maybe_unserialize( $form->options );
416 416
 			if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) {
417 417
 				self::destroy( $form->id );
418
-				$count++;
418
+				$count ++;
419 419
 			}
420 420
 
421 421
 			unset( $form );
@@ -429,15 +429,15 @@  discard block
 block discarded – undo
429 429
     public static function &getName( $id ) {
430 430
         global $wpdb;
431 431
 
432
-        $form = FrmAppHelper::check_cache($id, 'frm_form');
432
+        $form = FrmAppHelper::check_cache( $id, 'frm_form' );
433 433
         if ( $form ) {
434
-            $r = stripslashes($form->name);
434
+            $r = stripslashes( $form->name );
435 435
             return $r;
436 436
         }
437 437
 
438 438
         $query_key = is_numeric( $id ) ? 'id' : 'form_key';
439 439
         $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
440
-        $r = stripslashes($r);
440
+        $r = stripslashes( $r );
441 441
 
442 442
         return $r;
443 443
     }
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
      */
458 458
 	public static function &getKeyById( $id ) {
459 459
         $id = (int) $id;
460
-        $cache = FrmAppHelper::check_cache($id, 'frm_form');
460
+        $cache = FrmAppHelper::check_cache( $id, 'frm_form' );
461 461
         if ( $cache ) {
462 462
             return $cache->form_key;
463 463
         }
@@ -491,17 +491,17 @@  discard block
 block discarded – undo
491 491
 			$table_name = $prefix . 'frm_forms';
492 492
         } else {
493 493
 			$table_name = $wpdb->prefix . 'frm_forms';
494
-            $cache = wp_cache_get($id, 'frm_form');
494
+            $cache = wp_cache_get( $id, 'frm_form' );
495 495
             if ( $cache ) {
496
-                if ( isset($cache->options) ) {
497
-                    $cache->options = maybe_unserialize($cache->options);
496
+                if ( isset( $cache->options ) ) {
497
+                    $cache->options = maybe_unserialize( $cache->options );
498 498
                 }
499 499
 
500
-                return stripslashes_deep($cache);
500
+                return stripslashes_deep( $cache );
501 501
             }
502 502
         }
503 503
 
504
-        if ( is_numeric($id) ) {
504
+        if ( is_numeric( $id ) ) {
505 505
             $where = array( 'id' => $id );
506 506
         } else {
507 507
             $where = array( 'form_key' => $id );
@@ -509,11 +509,11 @@  discard block
 block discarded – undo
509 509
 
510 510
         $results = FrmDb::get_row( $table_name, $where );
511 511
 
512
-        if ( isset($results->options) ) {
512
+        if ( isset( $results->options ) ) {
513 513
 			FrmAppHelper::set_cache( $results->id, $results, 'frm_form' );
514
-            $results->options = maybe_unserialize($results->options);
514
+            $results->options = maybe_unserialize( $results->options );
515 515
         }
516
-        return stripslashes_deep($results);
516
+        return stripslashes_deep( $results );
517 517
     }
518 518
 
519 519
     /**
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 			$results = reset( $results );
543 543
 		}
544 544
 
545
-        return stripslashes_deep($results);
545
+        return stripslashes_deep( $results );
546 546
     }
547 547
 
548 548
 	/**
@@ -582,19 +582,19 @@  discard block
 block discarded – undo
582 582
     	foreach ( $results as $row ) {
583 583
             if ( 'trash' != $row->status ) {
584 584
     	        if ( $row->is_template ) {
585
-					$counts['template']++;
585
+					$counts['template'] ++;
586 586
     	        } else {
587
-					$counts['published']++;
587
+					$counts['published'] ++;
588 588
     	        }
589 589
     	    } else {
590
-				$counts['trash']++;
590
+				$counts['trash'] ++;
591 591
         	}
592 592
 
593 593
     	    if ( 'draft' == $row->status ) {
594
-				$counts['draft']++;
594
+				$counts['draft'] ++;
595 595
     	    }
596 596
 
597
-    		unset($row);
597
+    		unset( $row );
598 598
     	}
599 599
 
600 600
     	$counts = (object) $counts;
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 	public static function validate( $values ) {
621 621
         $errors = array();
622 622
 
623
-        return apply_filters('frm_validate_form', $errors, $values);
623
+        return apply_filters( 'frm_validate_form', $errors, $values );
624 624
     }
625 625
 
626 626
 	public static function get_params( $form = null ) {
@@ -632,11 +632,11 @@  discard block
 block discarded – undo
632 632
 			self::maybe_get_form( $form );
633 633
 		}
634 634
 
635
-		if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) {
636
-			return $frm_vars['form_params'][ $form->id ];
635
+		if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][$form->id] ) ) {
636
+			return $frm_vars['form_params'][$form->id];
637 637
 		}
638 638
 
639
-		$action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
639
+		$action_var = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
640 640
 		$action = apply_filters( 'frm_show_new_entry_page', FrmAppHelper::get_param( $action_var, 'new', 'get', 'sanitize_title' ), $form );
641 641
 
642 642
 		$default_values = array(
@@ -654,15 +654,15 @@  discard block
 block discarded – undo
654 654
 			//if there are two forms on the same page, make sure not to submit both
655 655
 			foreach ( $default_values as $var => $default ) {
656 656
 				if ( $var == 'action' ) {
657
-					$values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
657
+					$values[$var] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
658 658
 				} else {
659
-					$values[ $var ] = FrmAppHelper::get_param( $var, $default );
659
+					$values[$var] = FrmAppHelper::get_param( $var, $default );
660 660
 				}
661 661
 				unset( $var, $default );
662 662
 			}
663 663
 		} else {
664 664
 			foreach ( $default_values as $var => $default ) {
665
-				$values[ $var ] = $default;
665
+				$values[$var] = $default;
666 666
 				unset( $var, $default );
667 667
 			}
668 668
 		}
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
 	public static function list_page_params() {
678 678
 		$values = array();
679 679
 		foreach ( array( 'template' => 0, 'id' => '', 'paged' => 1, 'form' => '', 'search' => '', 'sort' => '', 'sdir' => '' ) as $var => $default ) {
680
-			$values[ $var ] = FrmAppHelper::get_param( $var, $default );
680
+			$values[$var] = FrmAppHelper::get_param( $var, $default );
681 681
 		}
682 682
 
683 683
 		return $values;
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
 			'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'fid' => '',
698 698
 			'keep_post' => '',
699 699
 		) as $var => $default ) {
700
-			$values[ $var ] = FrmAppHelper::get_param( $var, $default );
700
+			$values[$var] = FrmAppHelper::get_param( $var, $default );
701 701
 		}
702 702
 
703 703
 		return $values;
@@ -739,16 +739,16 @@  discard block
 block discarded – undo
739 739
 		$small_form = new stdClass();
740 740
 		foreach ( array( 'id', 'form_key', 'name' ) as $var ) {
741 741
 			$small_form->{$var} = $form->{$var};
742
-			unset($var);
742
+			unset( $var );
743 743
 		}
744 744
 
745 745
 		$frm_vars['forms_loaded'][] = $small_form;
746 746
 
747
-		if ( $this_load && empty($global_load) ) {
747
+		if ( $this_load && empty( $global_load ) ) {
748 748
 			$global_load = $frm_vars['load_css'] = true;
749 749
 		}
750 750
 
751
-		return ( ( ! isset($frm_vars['css_loaded']) || ! $frm_vars['css_loaded'] ) && $global_load );
751
+		return ( ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) && $global_load );
752 752
 	}
753 753
 
754 754
 	public static function show_submit( $form ) {
@@ -762,6 +762,6 @@  discard block
 block discarded – undo
762 762
 	 */
763 763
 	public static function get_option( $atts ) {
764 764
 		$form = $atts['form'];
765
-		return isset( $form->options[ $atts['option'] ] ) ? $form->options[ $atts['option'] ] : $atts['default'];
765
+		return isset( $form->options[$atts['option']] ) ? $form->options[$atts['option']] : $atts['default'];
766 766
 	}
767 767
 }
Please login to merge, or discard this patch.