Completed
Branch 3.0 (864fc8)
by Stephanie
02:53
created
classes/models/FrmEntry.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -180,6 +180,7 @@  discard block
 block discarded – undo
180 180
 	*
181 181
 	* @param int $id
182 182
 	* @param array $values
183
+	* @param string $update_type
183 184
 	* @return boolean|int $query_results
184 185
 	*/
185 186
 	private static function update_entry( $id, $values, $update_type ) {
@@ -563,6 +564,9 @@  discard block
 block discarded – undo
563 564
 		return $new_values;
564 565
 	}
565 566
 
567
+	/**
568
+	 * @param string $name
569
+	 */
566 570
 	private static function get_entry_value( $values, $name, $default ) {
567 571
 		return isset( $values[ $name ] ) ? $values[ $name ] : $default;
568 572
 	}
Please login to merge, or discard this patch.
Indentation   +354 added lines, -354 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@  discard block
 block discarded – undo
6 6
 class FrmEntry {
7 7
 
8 8
 	/**
9
-	* Create a new entry
10
-	*
11
-	* @param array $values
12
-	* @return int | boolean $entry_id
13
-	*/
9
+	 * Create a new entry
10
+	 *
11
+	 * @param array $values
12
+	 * @return int | boolean $entry_id
13
+	 */
14 14
 	public static function create( $values ) {
15 15
 		$entry_id = self::create_entry( $values, 'standard' );
16 16
 
@@ -18,12 +18,12 @@  discard block
 block discarded – undo
18 18
 	}
19 19
 
20 20
 	/**
21
-	* Create a new entry with some differences depending on type
22
-	*
23
-	* @param array $values
24
-	* @param string $type
25
-	* @return int | boolean $entry_id
26
-	*/
21
+	 * Create a new entry with some differences depending on type
22
+	 *
23
+	 * @param array $values
24
+	 * @param string $type
25
+	 * @return int | boolean $entry_id
26
+	 */
27 27
 	private static function create_entry( $values, $type ) {
28 28
 		$new_values = self::before_insert_entry_in_database( $values, $type );
29 29
 
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
 		return $entry_id;
38 38
 	}
39 39
 
40
-    /**
41
-     * check for duplicate entries created in the last minute
42
-     * @return boolean
43
-     */
40
+	/**
41
+	 * check for duplicate entries created in the last minute
42
+	 * @return boolean
43
+	 */
44 44
 	public static function is_duplicate( $new_values, $values ) {
45 45
 		$duplicate_entry_time = apply_filters( 'frm_time_to_check_duplicates', 60, $new_values );
46 46
 
@@ -48,55 +48,55 @@  discard block
 block discarded – undo
48 48
 			return false;
49 49
 		}
50 50
 
51
-        $check_val = $new_values;
51
+		$check_val = $new_values;
52 52
 		$check_val['created_at >'] = date( 'Y-m-d H:i:s', ( strtotime( $new_values['created_at'] ) - absint( $duplicate_entry_time ) ) );
53 53
 
54 54
 		unset( $check_val['created_at'], $check_val['updated_at'] );
55 55
 		unset( $check_val['is_draft'], $check_val['id'], $check_val['item_key'] );
56 56
 
57
-        if ( $new_values['item_key'] == $new_values['name'] ) {
58
-            unset($check_val['name']);
59
-        }
57
+		if ( $new_values['item_key'] == $new_values['name'] ) {
58
+			unset($check_val['name']);
59
+		}
60 60
 
61
-        global $wpdb;
61
+		global $wpdb;
62 62
 		$entry_exists = FrmDb::get_col( $wpdb->prefix . 'frm_items', $check_val, 'id', array( 'order_by' => 'created_at DESC' ) );
63 63
 
64
-        if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) {
65
-            return false;
66
-        }
64
+		if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) {
65
+			return false;
66
+		}
67 67
 
68
-        $is_duplicate = false;
69
-        foreach ( $entry_exists as $entry_exist ) {
70
-            $is_duplicate = true;
68
+		$is_duplicate = false;
69
+		foreach ( $entry_exists as $entry_exist ) {
70
+			$is_duplicate = true;
71 71
 
72
-            //add more checks here to make sure it's a duplicate
73
-            $metas = FrmEntryMeta::get_entry_meta_info($entry_exist);
74
-            $field_metas = array();
75
-            foreach ( $metas as $meta ) {
72
+			//add more checks here to make sure it's a duplicate
73
+			$metas = FrmEntryMeta::get_entry_meta_info($entry_exist);
74
+			$field_metas = array();
75
+			foreach ( $metas as $meta ) {
76 76
 				$field_metas[ $meta->field_id ] = $meta->meta_value;
77
-            }
78
-
79
-            // If prev entry is empty and current entry is not, they are not duplicates
80
-            $filtered_vals = array_filter( $values['item_meta'] );
81
-            if ( empty( $field_metas ) && ! empty( $filtered_vals ) ) {
82
-                return false;
83
-            }
84
-
85
-            $diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta']));
86
-            foreach ( $diff as $field_id => $meta_value ) {
87
-                if ( ! empty($meta_value) ) {
88
-                    $is_duplicate = false;
89
-                    continue;
90
-                }
91
-            }
92
-
93
-            if ( $is_duplicate ) {
77
+			}
78
+
79
+			// If prev entry is empty and current entry is not, they are not duplicates
80
+			$filtered_vals = array_filter( $values['item_meta'] );
81
+			if ( empty( $field_metas ) && ! empty( $filtered_vals ) ) {
82
+				return false;
83
+			}
84
+
85
+			$diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta']));
86
+			foreach ( $diff as $field_id => $meta_value ) {
87
+				if ( ! empty($meta_value) ) {
88
+					$is_duplicate = false;
89
+					continue;
90
+				}
91
+			}
92
+
93
+			if ( $is_duplicate ) {
94 94
 				break;
95
-            }
96
-        }
95
+			}
96
+		}
97 97
 
98
-        return $is_duplicate;
99
-    }
98
+		return $is_duplicate;
99
+	}
100 100
 
101 101
 	/**
102 102
 	 * Determine if an entry needs to be checked as a possible duplicate
@@ -125,48 +125,48 @@  discard block
 block discarded – undo
125 125
 		return true;
126 126
 	}
127 127
 
128
-    public static function duplicate( $id ) {
129
-        global $wpdb;
128
+	public static function duplicate( $id ) {
129
+		global $wpdb;
130 130
 
131
-        $values = self::getOne( $id );
131
+		$values = self::getOne( $id );
132 132
 
133
-        $new_values = array();
133
+		$new_values = array();
134 134
 		$new_values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' );
135
-        $new_values['name'] = $values->name;
136
-        $new_values['is_draft'] = $values->is_draft;
135
+		$new_values['name'] = $values->name;
136
+		$new_values['is_draft'] = $values->is_draft;
137 137
 		$new_values['user_id'] = (int) $values->user_id;
138 138
 		$new_values['updated_by'] = (int) $values->user_id;
139
-        $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null;
139
+		$new_values['form_id'] = $values->form_id ? (int) $values->form_id: null;
140 140
 		$new_values['created_at'] = current_time( 'mysql', 1 );
141 141
 		$new_values['updated_at'] = $new_values['created_at'];
142 142
 
143 143
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values );
144
-        if ( ! $query_results ) {
145
-            return false;
146
-        }
144
+		if ( ! $query_results ) {
145
+			return false;
146
+		}
147 147
 
148
-        $entry_id = $wpdb->insert_id;
148
+		$entry_id = $wpdb->insert_id;
149 149
 
150
-        global $frm_vars;
151
-        if ( ! isset($frm_vars['saved_entries']) ) {
152
-            $frm_vars['saved_entries'] = array();
153
-        }
154
-        $frm_vars['saved_entries'][] = (int) $entry_id;
150
+		global $frm_vars;
151
+		if ( ! isset($frm_vars['saved_entries']) ) {
152
+			$frm_vars['saved_entries'] = array();
153
+		}
154
+		$frm_vars['saved_entries'][] = (int) $entry_id;
155 155
 
156
-        FrmEntryMeta::duplicate_entry_metas($id, $entry_id);
156
+		FrmEntryMeta::duplicate_entry_metas($id, $entry_id);
157 157
 		self::clear_cache();
158 158
 
159 159
 		do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) );
160
-        return $entry_id;
161
-    }
160
+		return $entry_id;
161
+	}
162 162
 
163 163
 	/**
164
-	* Update an entry (not via XML)
165
-	*
166
-	* @param int $id
167
-	* @param array $values
168
-	* @return boolean|int $update_results
169
-	*/
164
+	 * Update an entry (not via XML)
165
+	 *
166
+	 * @param int $id
167
+	 * @param array $values
168
+	 * @return boolean|int $update_results
169
+	 */
170 170
 	public static function update( $id, $values ) {
171 171
 		$update_results = self::update_entry( $id, $values, 'standard' );
172 172
 
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 	}
175 175
 
176 176
 	/**
177
-	* Update an entry with some differences depending on the update type
178
-	*
179
-	* @since 2.0.16
180
-	*
181
-	* @param int $id
182
-	* @param array $values
183
-	* @return boolean|int $query_results
184
-	*/
177
+	 * Update an entry with some differences depending on the update type
178
+	 *
179
+	 * @since 2.0.16
180
+	 *
181
+	 * @param int $id
182
+	 * @param array $values
183
+	 * @return boolean|int $query_results
184
+	 */
185 185
 	private static function update_entry( $id, $values, $update_type ) {
186 186
 		global $wpdb;
187 187
 
@@ -200,34 +200,34 @@  discard block
 block discarded – undo
200 200
 	}
201 201
 
202 202
 	public static function destroy( $id ) {
203
-        global $wpdb;
204
-        $id = (int) $id;
203
+		global $wpdb;
204
+		$id = (int) $id;
205 205
 
206 206
 		$entry = self::getOne( $id );
207
-        if ( ! $entry ) {
208
-            $result = false;
209
-            return $result;
210
-        }
207
+		if ( ! $entry ) {
208
+			$result = false;
209
+			return $result;
210
+		}
211 211
 
212
-        do_action('frm_before_destroy_entry', $id, $entry);
212
+		do_action('frm_before_destroy_entry', $id, $entry);
213 213
 
214 214
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) );
215 215
 		$result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) );
216 216
 
217 217
 		self::clear_cache();
218 218
 
219
-        return $result;
220
-    }
219
+		return $result;
220
+	}
221 221
 
222 222
 	public static function update_form( $id, $value, $form_id ) {
223
-        global $wpdb;
224
-        $form_id = isset($value) ? $form_id : null;
223
+		global $wpdb;
224
+		$form_id = isset($value) ? $form_id : null;
225 225
 		$result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) );
226 226
 		if ( $result ) {
227 227
 			self::clear_cache();
228 228
 		}
229
-        return $result;
230
-    }
229
+		return $result;
230
+	}
231 231
 
232 232
 	/**
233 233
 	 * Clear entry caching
@@ -263,159 +263,159 @@  discard block
 block discarded – undo
263 263
 	}
264 264
 
265 265
 	public static function getOne( $id, $meta = false ) {
266
-        global $wpdb;
266
+		global $wpdb;
267 267
 
268
-        $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
268
+		$query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
269 269
                   LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE ";
270 270
 
271
-        $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s';
272
-        $query_args = array( $id );
273
-        $query = $wpdb->prepare( $query, $query_args );
271
+		$query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s';
272
+		$query_args = array( $id );
273
+		$query = $wpdb->prepare( $query, $query_args );
274 274
 
275
-        if ( ! $meta ) {
275
+		if ( ! $meta ) {
276 276
 			$entry = FrmAppHelper::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' );
277
-            return stripslashes_deep($entry);
278
-        }
277
+			return stripslashes_deep($entry);
278
+		}
279 279
 
280
-        $entry = FrmAppHelper::check_cache( $id, 'frm_entry' );
281
-        if ( $entry !== false ) {
282
-            return stripslashes_deep($entry);
283
-        }
280
+		$entry = FrmAppHelper::check_cache( $id, 'frm_entry' );
281
+		if ( $entry !== false ) {
282
+			return stripslashes_deep($entry);
283
+		}
284 284
 
285
-        $entry = $wpdb->get_row( $query );
286
-        $entry = self::get_meta($entry);
285
+		$entry = $wpdb->get_row( $query );
286
+		$entry = self::get_meta($entry);
287 287
 
288
-        return stripslashes_deep($entry);
289
-    }
288
+		return stripslashes_deep($entry);
289
+	}
290 290
 
291 291
 	public static function get_meta( $entry ) {
292
-        if ( ! $entry ) {
293
-            return $entry;
294
-        }
292
+		if ( ! $entry ) {
293
+			return $entry;
294
+		}
295 295
 
296
-        global $wpdb;
296
+		global $wpdb;
297 297
 		$metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas m LEFT JOIN ' . $wpdb->prefix . 'frm_fields f ON m.field_id=f.id', array( 'item_id' => $entry->id, 'field_id !' => 0 ), 'field_id, meta_value, field_key, item_id' );
298 298
 
299
-        $entry->metas = array();
299
+		$entry->metas = array();
300 300
 
301 301
 		$include_key = apply_filters( 'frm_include_meta_keys', false, array( 'form_id' => $entry->form_id ) );
302
-        foreach ( $metas as $meta_val ) {
303
-            if ( $meta_val->item_id == $entry->id ) {
302
+		foreach ( $metas as $meta_val ) {
303
+			if ( $meta_val->item_id == $entry->id ) {
304 304
 				$entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
305 305
 				if ( $include_key ) {
306 306
 					$entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ];
307 307
 				}
308
-                 continue;
309
-            }
308
+				 continue;
309
+			}
310 310
 
311
-            // include sub entries in an array
311
+			// include sub entries in an array
312 312
 			if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) {
313 313
 				$entry->metas[ $meta_val->field_id ] = array();
314
-            }
314
+			}
315 315
 
316 316
 			$entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value );
317 317
 
318
-            unset($meta_val);
319
-        }
320
-        unset($metas);
318
+			unset($meta_val);
319
+		}
320
+		unset($metas);
321 321
 
322 322
 		FrmAppHelper::set_cache( $entry->id, $entry, 'frm_entry' );
323 323
 
324
-        return $entry;
325
-    }
324
+		return $entry;
325
+	}
326 326
 
327
-    /**
328
-     * @param string $id
329
-     */
327
+	/**
328
+	 * @param string $id
329
+	 */
330 330
 	public static function exists( $id ) {
331
-        global $wpdb;
332
-
333
-        if ( FrmAppHelper::check_cache( $id, 'frm_entry' ) ) {
334
-            $exists = true;
335
-            return $exists;
336
-        }
337
-
338
-        if ( is_numeric($id) ) {
339
-            $where = array( 'id' => $id );
340
-        } else {
341
-            $where = array( 'item_key' => $id );
342
-        }
331
+		global $wpdb;
332
+
333
+		if ( FrmAppHelper::check_cache( $id, 'frm_entry' ) ) {
334
+			$exists = true;
335
+			return $exists;
336
+		}
337
+
338
+		if ( is_numeric($id) ) {
339
+			$where = array( 'id' => $id );
340
+		} else {
341
+			$where = array( 'item_key' => $id );
342
+		}
343 343
 		$id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where );
344 344
 
345
-        $exists = ($id && $id > 0) ? true : false;
346
-        return $exists;
347
-    }
345
+		$exists = ($id && $id > 0) ? true : false;
346
+		return $exists;
347
+	}
348 348
 
349
-    public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
349
+	public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
350 350
 		global $wpdb;
351 351
 
352
-        $limit = FrmAppHelper::esc_limit($limit);
352
+		$limit = FrmAppHelper::esc_limit($limit);
353 353
 
354
-        $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form;
355
-        $entries = wp_cache_get($cache_key, 'frm_entry');
354
+		$cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form;
355
+		$entries = wp_cache_get($cache_key, 'frm_entry');
356 356
 
357
-        if ( false === $entries ) {
358
-            $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft';
357
+		if ( false === $entries ) {
358
+			$fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft';
359 359
 			$table = $wpdb->prefix . 'frm_items it ';
360 360
 
361
-            if ( $inc_form ) {
362
-                $fields = 'it.*, fr.name as form_name,fr.form_key as form_key';
363
-                $table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id ';
364
-            }
361
+			if ( $inc_form ) {
362
+				$fields = 'it.*, fr.name as form_name,fr.form_key as form_key';
363
+				$table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id ';
364
+			}
365 365
 
366
-            if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) {
367
-    		    // sort by a requested field
368
-                $field_id = (int) $order_matches[1];
366
+			if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) {
367
+				// sort by a requested field
368
+				$field_id = (int) $order_matches[1];
369 369
 				$fields .= ', (SELECT meta_value FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id = ' . $field_id . ' AND item_id = it.id) as meta_' . $field_id;
370 370
 				unset( $order_matches, $field_id );
371
-		    }
371
+			}
372 372
 
373 373
 			// prepare the query
374 374
 			$query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
375 375
 
376
-            $entries = $wpdb->get_results($query, OBJECT_K);
377
-            unset($query);
376
+			$entries = $wpdb->get_results($query, OBJECT_K);
377
+			unset($query);
378 378
 
379 379
 			FrmAppHelper::set_cache( $cache_key, $entries, 'frm_entry' );
380
-        }
380
+		}
381 381
 
382
-        if ( ! $meta || ! $entries ) {
383
-            return stripslashes_deep($entries);
384
-        }
385
-        unset($meta);
382
+		if ( ! $meta || ! $entries ) {
383
+			return stripslashes_deep($entries);
384
+		}
385
+		unset($meta);
386 386
 
387
-        if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) {
387
+		if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) {
388 388
 			$where = array( 'it.form_id' => substr( $where, 11 ) );
389
-        }
389
+		}
390 390
 
391
-        $meta_where = array( 'field_id !' => 0 );
392
-        if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) {
393
-            $meta_where['fi.form_id'] = $where['it.form_id'];
394
-        } else {
395
-            $meta_where['item_id'] = array_keys( $entries );
396
-        }
391
+		$meta_where = array( 'field_id !' => 0 );
392
+		if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) {
393
+			$meta_where['fi.form_id'] = $where['it.form_id'];
394
+		} else {
395
+			$meta_where['item_id'] = array_keys( $entries );
396
+		}
397 397
 
398
-        $metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON (it.field_id = fi.id)', $meta_where, 'item_id, meta_value, field_id, field_key, form_id' );
398
+		$metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON (it.field_id = fi.id)', $meta_where, 'item_id, meta_value, field_id, field_key, form_id' );
399 399
 
400
-        unset( $meta_where );
400
+		unset( $meta_where );
401 401
 
402
-        if ( ! $metas ) {
403
-            return stripslashes_deep($entries);
404
-        }
402
+		if ( ! $metas ) {
403
+			return stripslashes_deep($entries);
404
+		}
405 405
 
406
-        foreach ( $metas as $m_key => $meta_val ) {
407
-            if ( ! isset( $entries[ $meta_val->item_id ] ) ) {
408
-                continue;
409
-            }
406
+		foreach ( $metas as $m_key => $meta_val ) {
407
+			if ( ! isset( $entries[ $meta_val->item_id ] ) ) {
408
+				continue;
409
+			}
410 410
 
411
-            if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
411
+			if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
412 412
 				$entries[ $meta_val->item_id ]->metas = array();
413
-            }
413
+			}
414 414
 
415 415
 			$entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
416 416
 
417
-            unset($m_key, $meta_val);
418
-        }
417
+			unset($m_key, $meta_val);
418
+		}
419 419
 
420 420
 		if ( ! FrmAppHelper::prevent_caching() ) {
421 421
 			foreach ( $entries as $entry ) {
@@ -424,31 +424,31 @@  discard block
 block discarded – undo
424 424
 			}
425 425
 		}
426 426
 
427
-        return stripslashes_deep($entries);
428
-    }
427
+		return stripslashes_deep($entries);
428
+	}
429 429
 
430
-    // Pagination Methods
431
-    public static function getRecordCount( $where = '' ) {
432
-        global $wpdb;
430
+	// Pagination Methods
431
+	public static function getRecordCount( $where = '' ) {
432
+		global $wpdb;
433 433
 		$table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id';
434 434
 
435
-        if ( is_numeric($where) ) {
436
-            $table_join = 'frm_items';
437
-            $where = array( 'form_id' => $where );
438
-        }
435
+		if ( is_numeric($where) ) {
436
+			$table_join = 'frm_items';
437
+			$where = array( 'form_id' => $where );
438
+		}
439 439
 
440
-        if ( is_array( $where ) ) {
441
-            $count = FrmDb::get_count( $table_join, $where );
442
-        } else {
440
+		if ( is_array( $where ) ) {
441
+			$count = FrmDb::get_count( $table_join, $where );
442
+		} else {
443 443
 			$cache_key = 'count_' . maybe_serialize( $where );
444 444
 			$query = 'SELECT COUNT(*) FROM ' . $table_join . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where );
445 445
 			$count = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, 'get_var' );
446
-        }
446
+		}
447 447
 
448
-        return $count;
449
-    }
448
+		return $count;
449
+	}
450 450
 
451
-    public static function getPageCount( $p_size, $where = '' ) {
451
+	public static function getPageCount( $p_size, $where = '' ) {
452 452
 		$p_size = (int) $p_size;
453 453
 		$count = 1;
454 454
 		if ( $p_size ) {
@@ -459,16 +459,16 @@  discard block
 block discarded – undo
459 459
 		}
460 460
 
461 461
 		return $count;
462
-    }
462
+	}
463 463
 
464 464
 	/**
465
-	* Prepare the data before inserting it into the database
466
-	*
467
-	* @since 2.0.16
468
-	* @param array $values
469
-	* @param string $type
470
-	* @return array $new_values
471
-	*/
465
+	 * Prepare the data before inserting it into the database
466
+	 *
467
+	 * @since 2.0.16
468
+	 * @param array $values
469
+	 * @param string $type
470
+	 * @return array $new_values
471
+	 */
472 472
 	private static function before_insert_entry_in_database( &$values, $type ) {
473 473
 
474 474
 		self::sanitize_entry_post( $values );
@@ -483,13 +483,13 @@  discard block
 block discarded – undo
483 483
 	}
484 484
 
485 485
 	/**
486
-	* Create an entry and perform after create actions
487
-	*
488
-	* @since 2.0.16
489
-	* @param array $values
490
-	* @param array $new_values
491
-	* @return boolean|int $entry_id
492
-	*/
486
+	 * Create an entry and perform after create actions
487
+	 *
488
+	 * @since 2.0.16
489
+	 * @param array $values
490
+	 * @param array $new_values
491
+	 * @return boolean|int $entry_id
492
+	 */
493 493
 	private static function continue_to_create_entry( $values, $new_values ) {
494 494
 		$entry_id = self::insert_entry_into_database( $new_values );
495 495
 		if ( ! $entry_id ) {
@@ -501,37 +501,37 @@  discard block
 block discarded – undo
501 501
 		return $entry_id;
502 502
 	}
503 503
 
504
-    /**
505
-     * Sanitize the POST values before we use them
506
-     *
507
-     * @since 2.0
508
-     * @param array $values The POST values by reference
509
-     */
510
-    public static function sanitize_entry_post( &$values ) {
511
-        $sanitize_method = array(
512
-            'form_id'       => 'absint',
513
-            'frm_action'    => 'sanitize_title',
514
-            'form_key'      => 'sanitize_title',
515
-            'item_key'      => 'sanitize_title',
516
-            'item_name'     => 'sanitize_text_field',
517
-            'frm_saving_draft' => 'absint',
518
-            'is_draft'      => 'absint',
519
-            'post_id'       => 'absint',
520
-            'parent_item_id' => 'absint',
521
-            'created_at'    => 'sanitize_text_field',
522
-            'updated_at'    => 'sanitize_text_field',
523
-        );
524
-
525
-        FrmAppHelper::sanitize_request( $sanitize_method, $values );
526
-    }
504
+	/**
505
+	 * Sanitize the POST values before we use them
506
+	 *
507
+	 * @since 2.0
508
+	 * @param array $values The POST values by reference
509
+	 */
510
+	public static function sanitize_entry_post( &$values ) {
511
+		$sanitize_method = array(
512
+			'form_id'       => 'absint',
513
+			'frm_action'    => 'sanitize_title',
514
+			'form_key'      => 'sanitize_title',
515
+			'item_key'      => 'sanitize_title',
516
+			'item_name'     => 'sanitize_text_field',
517
+			'frm_saving_draft' => 'absint',
518
+			'is_draft'      => 'absint',
519
+			'post_id'       => 'absint',
520
+			'parent_item_id' => 'absint',
521
+			'created_at'    => 'sanitize_text_field',
522
+			'updated_at'    => 'sanitize_text_field',
523
+		);
524
+
525
+		FrmAppHelper::sanitize_request( $sanitize_method, $values );
526
+	}
527 527
 
528 528
 	/**
529
-	* Prepare the new values for inserting into the database
530
-	*
531
-	* @since 2.0.16
532
-	* @param array $values
533
-	* @return array $new_values
534
-	*/
529
+	 * Prepare the new values for inserting into the database
530
+	 *
531
+	 * @since 2.0.16
532
+	 * @param array $values
533
+	 * @return array $new_values
534
+	 */
535 535
 	private static function package_entry_data( &$values ) {
536 536
 		global $wpdb;
537 537
 
@@ -584,34 +584,34 @@  discard block
 block discarded – undo
584 584
 	}
585 585
 
586 586
 	/**
587
-	* Get the is_draft value for a new entry
588
-	*
589
-	* @since 2.0.16
590
-	* @param array $values
591
-	* @return int
592
-	*/
587
+	 * Get the is_draft value for a new entry
588
+	 *
589
+	 * @since 2.0.16
590
+	 * @param array $values
591
+	 * @return int
592
+	 */
593 593
 	private static function get_is_draft_value( $values ) {
594 594
 		return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) || ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0;
595 595
 	}
596 596
 
597 597
 	/**
598
-	* Get the created_at value for a new entry
599
-	*
600
-	* @since 2.0.16
601
-	* @param array $values
602
-	* @return string
603
-	*/
598
+	 * Get the created_at value for a new entry
599
+	 *
600
+	 * @since 2.0.16
601
+	 * @param array $values
602
+	 * @return string
603
+	 */
604 604
 	private static function get_created_at( $values ) {
605 605
 		return self::get_entry_value( $values, 'created_at', current_time( 'mysql', 1 ) );
606 606
 	}
607 607
 
608 608
 	/**
609
-	* Get the updated_at value for a new entry
610
-	*
611
-	* @since 2.0.16
612
-	* @param array $values
613
-	* @return string
614
-	*/
609
+	 * Get the updated_at value for a new entry
610
+	 *
611
+	 * @since 2.0.16
612
+	 * @param array $values
613
+	 * @return string
614
+	 */
615 615
 	private static function get_updated_at( $values ) {
616 616
 		if ( isset( $values['updated_at'] ) ) {
617 617
 			$updated_at = $values['updated_at'];
@@ -623,12 +623,12 @@  discard block
 block discarded – undo
623 623
 	}
624 624
 
625 625
 	/**
626
-	* Get the description value for a new entry
627
-	*
628
-	* @since 2.0.16
629
-	* @param array $values
630
-	* @return string
631
-	*/
626
+	 * Get the description value for a new entry
627
+	 *
628
+	 * @since 2.0.16
629
+	 * @param array $values
630
+	 * @return string
631
+	 */
632 632
 	private static function get_entry_description( $values ) {
633 633
 		if ( isset( $values['description'] ) && ! empty( $values['description'] ) ) {
634 634
 			$description = maybe_serialize( $values['description'] );
@@ -643,12 +643,12 @@  discard block
 block discarded – undo
643 643
 	}
644 644
 
645 645
 	/**
646
-	* Get the user_id value for a new entry
647
-	*
648
-	* @since 2.0.16
649
-	* @param array $values
650
-	* @return int
651
-	*/
646
+	 * Get the user_id value for a new entry
647
+	 *
648
+	 * @since 2.0.16
649
+	 * @param array $values
650
+	 * @return int
651
+	 */
652 652
 	private static function get_entry_user_id( $values ) {
653 653
 		if ( isset( $values['frm_user_id'] ) && ( is_numeric( $values['frm_user_id'] ) || FrmAppHelper::is_admin() ) ) {
654 654
 			$user_id = $values['frm_user_id'];
@@ -661,12 +661,12 @@  discard block
 block discarded – undo
661 661
 	}
662 662
 
663 663
 	/**
664
-	* Insert new entry into the database
665
-	*
666
-	* @since 2.0.16
667
-	* @param array $new_values
668
-	* @return int | boolean $entry_id
669
-	*/
664
+	 * Insert new entry into the database
665
+	 *
666
+	 * @since 2.0.16
667
+	 * @param array $new_values
668
+	 * @return int | boolean $entry_id
669
+	 */
670 670
 	private static function insert_entry_into_database( $new_values ) {
671 671
 		global $wpdb;
672 672
 
@@ -682,11 +682,11 @@  discard block
 block discarded – undo
682 682
 	}
683 683
 
684 684
 	/**
685
-	* Add the new entry to global $frm_vars
686
-	*
687
-	* @since 2.0.16
688
-	* @param int $entry_id
689
-	*/
685
+	 * Add the new entry to global $frm_vars
686
+	 *
687
+	 * @since 2.0.16
688
+	 * @param int $entry_id
689
+	 */
690 690
 	private static function add_new_entry_to_frm_vars( $entry_id ) {
691 691
 		global $frm_vars;
692 692
 
@@ -698,12 +698,12 @@  discard block
 block discarded – undo
698 698
 	}
699 699
 
700 700
 	/**
701
-	* Add entry metas, if there are any
702
-	*
703
-	* @since 2.0.16
704
-	* @param array $values
705
-	* @param int $entry_id
706
-	*/
701
+	 * Add entry metas, if there are any
702
+	 *
703
+	 * @since 2.0.16
704
+	 * @param array $values
705
+	 * @param int $entry_id
706
+	 */
707 707
 	private static function maybe_add_entry_metas( $values, $entry_id ) {
708 708
 		if ( isset($values['item_meta']) ) {
709 709
 			FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] );
@@ -711,12 +711,12 @@  discard block
 block discarded – undo
711 711
 	}
712 712
 
713 713
 	/**
714
-	* Trigger frm_after_create_entry hooks
715
-	*
716
-	* @since 2.0.16
717
-	* @param int $entry_id
718
-	* @param array $new_values
719
-	*/
714
+	 * Trigger frm_after_create_entry hooks
715
+	 *
716
+	 * @since 2.0.16
717
+	 * @param int $entry_id
718
+	 * @param array $new_values
719
+	 */
720 720
 	private static function after_entry_created_actions( $entry_id, $values, $new_values ) {
721 721
 		// this is a child entry
722 722
 		$is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' );
@@ -726,13 +726,13 @@  discard block
 block discarded – undo
726 726
 	}
727 727
 
728 728
 	/**
729
-	* Actions to perform immediately after an entry is inserted in the frm_items database
730
-	*
731
-	* @since 2.0.16
732
-	* @param array $values
733
-	* @param array $new_values
734
-	* @param int $entry_id
735
-	*/
729
+	 * Actions to perform immediately after an entry is inserted in the frm_items database
730
+	 *
731
+	 * @since 2.0.16
732
+	 * @param array $values
733
+	 * @param array $new_values
734
+	 * @param int $entry_id
735
+	 */
736 736
 	private static function after_insert_entry_in_database( $values, $new_values, $entry_id ) {
737 737
 
738 738
 		self::add_new_entry_to_frm_vars( $entry_id );
@@ -745,14 +745,14 @@  discard block
 block discarded – undo
745 745
 	}
746 746
 
747 747
 	/**
748
-	* Perform some actions right before updating an entry
749
-	*
750
-	* @since 2.0.16
751
-	* @param int $id
752
-	* @param array $values
753
-	* @param string $update_type
754
-	* @return boolean $update
755
-	*/
748
+	 * Perform some actions right before updating an entry
749
+	 *
750
+	 * @since 2.0.16
751
+	 * @param int $id
752
+	 * @param array $values
753
+	 * @param string $update_type
754
+	 * @return boolean $update
755
+	 */
756 756
 	private static function before_update_entry( $id, &$values, $update_type ) {
757 757
 		$update = true;
758 758
 
@@ -770,13 +770,13 @@  discard block
 block discarded – undo
770 770
 	}
771 771
 
772 772
 	/**
773
-	* Package the entry data for updating
774
-	*
775
-	* @since 2.0.16
776
-	* @param int $id
777
-	* @param array $values
778
-	* @return array $new_values
779
-	*/
773
+	 * Package the entry data for updating
774
+	 *
775
+	 * @since 2.0.16
776
+	 * @param int $id
777
+	 * @param array $values
778
+	 * @return array $new_values
779
+	 */
780 780
 	private static function package_entry_to_update( $id, $values ) {
781 781
 		global $wpdb;
782 782
 
@@ -810,14 +810,14 @@  discard block
 block discarded – undo
810 810
 	}
811 811
 
812 812
 	/**
813
-	* Perform some actions right after updating an entry
814
-	*
815
-	* @since 2.0.16
816
-	* @param boolean|int $query_results
817
-	* @param int $id
818
-	* @param array $values
819
-	* @param array $new_values
820
-	*/
813
+	 * Perform some actions right after updating an entry
814
+	 *
815
+	 * @since 2.0.16
816
+	 * @param boolean|int $query_results
817
+	 * @param int $id
818
+	 * @param array $values
819
+	 * @param array $new_values
820
+	 */
821 821
 	private static function after_update_entry( $query_results, $id, $values, $new_values ) {
822 822
 		if ( $query_results ) {
823 823
 			self::clear_cache();
@@ -839,13 +839,13 @@  discard block
 block discarded – undo
839 839
 	}
840 840
 
841 841
 	/**
842
-	* Create entry from an XML import
843
-	* Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.)
844
-	*
845
-	* @since 2.0.16
846
-	* @param array $values
847
-	* @return int | boolean $entry_id
848
-	*/
842
+	 * Create entry from an XML import
843
+	 * Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.)
844
+	 *
845
+	 * @since 2.0.16
846
+	 * @param array $values
847
+	 * @return int | boolean $entry_id
848
+	 */
849 849
 	public static function create_entry_from_xml( $values ) {
850 850
 		$entry_id = self::create_entry( $values, 'xml' );
851 851
 
@@ -853,28 +853,28 @@  discard block
 block discarded – undo
853 853
 	}
854 854
 
855 855
 	/**
856
-	* Update entry from an XML import
857
-	* Certain actions aren't necessary when importing (like saving sub entries and modifying other vals)
858
-	*
859
-	* @since 2.0.16
860
-	* @param int $id
861
-	* @param array $values
862
-	* @return int | boolean $updated
863
-	*/
856
+	 * Update entry from an XML import
857
+	 * Certain actions aren't necessary when importing (like saving sub entries and modifying other vals)
858
+	 *
859
+	 * @since 2.0.16
860
+	 * @param int $id
861
+	 * @param array $values
862
+	 * @return int | boolean $updated
863
+	 */
864 864
 	public static function update_entry_from_xml( $id, $values ) {
865 865
 		$updated = self::update_entry( $id, $values, 'xml' );
866 866
 
867 867
 		return $updated;
868 868
 	}
869 869
 
870
-    /**
871
-     * @param string $key
872
-     * @return int entry_id
873
-     */
870
+	/**
871
+	 * @param string $key
872
+	 * @return int entry_id
873
+	 */
874 874
 	public static function get_id_by_key( $key ) {
875
-        $entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) );
876
-        return $entry_id;
877
-    }
875
+		$entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) );
876
+		return $entry_id;
877
+	}
878 878
 
879 879
 	public static function validate( $values, $exclude = false ) {
880 880
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryValidate::validate' );
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 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
 
@@ -55,13 +55,13 @@  discard block
 block discarded – undo
55 55
 		unset( $check_val['is_draft'], $check_val['id'], $check_val['item_key'] );
56 56
 
57 57
         if ( $new_values['item_key'] == $new_values['name'] ) {
58
-            unset($check_val['name']);
58
+            unset( $check_val['name'] );
59 59
         }
60 60
 
61 61
         global $wpdb;
62 62
 		$entry_exists = FrmDb::get_col( $wpdb->prefix . 'frm_items', $check_val, 'id', array( 'order_by' => 'created_at DESC' ) );
63 63
 
64
-        if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) {
64
+        if ( ! $entry_exists || empty( $entry_exists ) || ! isset( $values['item_meta'] ) ) {
65 65
             return false;
66 66
         }
67 67
 
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
             $is_duplicate = true;
71 71
 
72 72
             //add more checks here to make sure it's a duplicate
73
-            $metas = FrmEntryMeta::get_entry_meta_info($entry_exist);
73
+            $metas = FrmEntryMeta::get_entry_meta_info( $entry_exist );
74 74
             $field_metas = array();
75 75
             foreach ( $metas as $meta ) {
76
-				$field_metas[ $meta->field_id ] = $meta->meta_value;
76
+				$field_metas[$meta->field_id] = $meta->meta_value;
77 77
             }
78 78
 
79 79
             // If prev entry is empty and current entry is not, they are not duplicates
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
                 return false;
83 83
             }
84 84
 
85
-            $diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta']));
85
+            $diff = array_diff_assoc( $field_metas, array_map( 'maybe_serialize', $values['item_meta'] ) );
86 86
             foreach ( $diff as $field_id => $meta_value ) {
87
-                if ( ! empty($meta_value) ) {
87
+                if ( ! empty( $meta_value ) ) {
88 88
                     $is_duplicate = false;
89 89
                     continue;
90 90
                 }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		}
114 114
 
115 115
 		// If CSV is importing, don't check for duplicates
116
-		if ( defined('WP_IMPORTING') && WP_IMPORTING ) {
116
+		if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
117 117
 			return false;
118 118
 		}
119 119
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         $new_values['is_draft'] = $values->is_draft;
137 137
 		$new_values['user_id'] = (int) $values->user_id;
138 138
 		$new_values['updated_by'] = (int) $values->user_id;
139
-        $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null;
139
+        $new_values['form_id'] = $values->form_id ? (int) $values->form_id : null;
140 140
 		$new_values['created_at'] = current_time( 'mysql', 1 );
141 141
 		$new_values['updated_at'] = $new_values['created_at'];
142 142
 
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
         $entry_id = $wpdb->insert_id;
149 149
 
150 150
         global $frm_vars;
151
-        if ( ! isset($frm_vars['saved_entries']) ) {
151
+        if ( ! isset( $frm_vars['saved_entries'] ) ) {
152 152
             $frm_vars['saved_entries'] = array();
153 153
         }
154 154
         $frm_vars['saved_entries'][] = (int) $entry_id;
155 155
 
156
-        FrmEntryMeta::duplicate_entry_metas($id, $entry_id);
156
+        FrmEntryMeta::duplicate_entry_metas( $id, $entry_id );
157 157
 		self::clear_cache();
158 158
 
159 159
 		do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) );
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
 		$new_values = self::package_entry_to_update( $id, $values );
194 194
 
195
-		$query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact('id') );
195
+		$query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact( 'id' ) );
196 196
 
197 197
 		self::after_update_entry( $query_results, $id, $values, $new_values );
198 198
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
             return $result;
210 210
         }
211 211
 
212
-        do_action('frm_before_destroy_entry', $id, $entry);
212
+        do_action( 'frm_before_destroy_entry', $id, $entry );
213 213
 
214 214
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) );
215 215
 		$result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) );
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 
222 222
 	public static function update_form( $id, $value, $form_id ) {
223 223
         global $wpdb;
224
-        $form_id = isset($value) ? $form_id : null;
224
+        $form_id = isset( $value ) ? $form_id : null;
225 225
 		$result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) );
226 226
 		if ( $result ) {
227 227
 			self::clear_cache();
@@ -268,24 +268,24 @@  discard block
 block discarded – undo
268 268
         $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
269 269
                   LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE ";
270 270
 
271
-        $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s';
271
+        $query .= is_numeric( $id ) ? 'it.id=%d' : 'it.item_key=%s';
272 272
         $query_args = array( $id );
273 273
         $query = $wpdb->prepare( $query, $query_args );
274 274
 
275 275
         if ( ! $meta ) {
276 276
 			$entry = FrmAppHelper::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' );
277
-            return stripslashes_deep($entry);
277
+            return stripslashes_deep( $entry );
278 278
         }
279 279
 
280 280
         $entry = FrmAppHelper::check_cache( $id, 'frm_entry' );
281 281
         if ( $entry !== false ) {
282
-            return stripslashes_deep($entry);
282
+            return stripslashes_deep( $entry );
283 283
         }
284 284
 
285 285
         $entry = $wpdb->get_row( $query );
286
-        $entry = self::get_meta($entry);
286
+        $entry = self::get_meta( $entry );
287 287
 
288
-        return stripslashes_deep($entry);
288
+        return stripslashes_deep( $entry );
289 289
     }
290 290
 
291 291
 	public static function get_meta( $entry ) {
@@ -301,23 +301,23 @@  discard block
 block discarded – undo
301 301
 		$include_key = apply_filters( 'frm_include_meta_keys', false, array( 'form_id' => $entry->form_id ) );
302 302
         foreach ( $metas as $meta_val ) {
303 303
             if ( $meta_val->item_id == $entry->id ) {
304
-				$entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
304
+				$entry->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value );
305 305
 				if ( $include_key ) {
306
-					$entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ];
306
+					$entry->metas[$meta_val->field_key] = $entry->metas[$meta_val->field_id];
307 307
 				}
308 308
                  continue;
309 309
             }
310 310
 
311 311
             // include sub entries in an array
312
-			if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) {
313
-				$entry->metas[ $meta_val->field_id ] = array();
312
+			if ( ! isset( $entry_metas[$meta_val->field_id] ) ) {
313
+				$entry->metas[$meta_val->field_id] = array();
314 314
             }
315 315
 
316
-			$entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value );
316
+			$entry->metas[$meta_val->field_id][] = maybe_unserialize( $meta_val->meta_value );
317 317
 
318
-            unset($meta_val);
318
+            unset( $meta_val );
319 319
         }
320
-        unset($metas);
320
+        unset( $metas );
321 321
 
322 322
 		FrmAppHelper::set_cache( $entry->id, $entry, 'frm_entry' );
323 323
 
@@ -335,24 +335,24 @@  discard block
 block discarded – undo
335 335
             return $exists;
336 336
         }
337 337
 
338
-        if ( is_numeric($id) ) {
338
+        if ( is_numeric( $id ) ) {
339 339
             $where = array( 'id' => $id );
340 340
         } else {
341 341
             $where = array( 'item_key' => $id );
342 342
         }
343 343
 		$id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where );
344 344
 
345
-        $exists = ($id && $id > 0) ? true : false;
345
+        $exists = ( $id && $id > 0 ) ? true : false;
346 346
         return $exists;
347 347
     }
348 348
 
349 349
     public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
350 350
 		global $wpdb;
351 351
 
352
-        $limit = FrmAppHelper::esc_limit($limit);
352
+        $limit = FrmAppHelper::esc_limit( $limit );
353 353
 
354
-        $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form;
355
-        $entries = wp_cache_get($cache_key, 'frm_entry');
354
+        $cache_key = maybe_serialize( $where ) . $order_by . $limit . $inc_form;
355
+        $entries = wp_cache_get( $cache_key, 'frm_entry' );
356 356
 
357 357
         if ( false === $entries ) {
358 358
             $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft';
@@ -371,25 +371,25 @@  discard block
 block discarded – undo
371 371
 		    }
372 372
 
373 373
 			// prepare the query
374
-			$query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
374
+			$query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
375 375
 
376
-            $entries = $wpdb->get_results($query, OBJECT_K);
377
-            unset($query);
376
+            $entries = $wpdb->get_results( $query, OBJECT_K );
377
+            unset( $query );
378 378
 
379 379
 			FrmAppHelper::set_cache( $cache_key, $entries, 'frm_entry' );
380 380
         }
381 381
 
382 382
         if ( ! $meta || ! $entries ) {
383
-            return stripslashes_deep($entries);
383
+            return stripslashes_deep( $entries );
384 384
         }
385
-        unset($meta);
385
+        unset( $meta );
386 386
 
387
-        if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) {
387
+        if ( ! is_array( $where ) && preg_match( '/^it\.form_id=\d+$/', $where ) ) {
388 388
 			$where = array( 'it.form_id' => substr( $where, 11 ) );
389 389
         }
390 390
 
391 391
         $meta_where = array( 'field_id !' => 0 );
392
-        if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) {
392
+        if ( $limit == '' && is_array( $where ) && count( $where ) == 1 && isset( $where['it.form_id'] ) ) {
393 393
             $meta_where['fi.form_id'] = $where['it.form_id'];
394 394
         } else {
395 395
             $meta_where['item_id'] = array_keys( $entries );
@@ -400,21 +400,21 @@  discard block
 block discarded – undo
400 400
         unset( $meta_where );
401 401
 
402 402
         if ( ! $metas ) {
403
-            return stripslashes_deep($entries);
403
+            return stripslashes_deep( $entries );
404 404
         }
405 405
 
406 406
         foreach ( $metas as $m_key => $meta_val ) {
407
-            if ( ! isset( $entries[ $meta_val->item_id ] ) ) {
407
+            if ( ! isset( $entries[$meta_val->item_id] ) ) {
408 408
                 continue;
409 409
             }
410 410
 
411
-            if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
412
-				$entries[ $meta_val->item_id ]->metas = array();
411
+            if ( ! isset( $entries[$meta_val->item_id]->metas ) ) {
412
+				$entries[$meta_val->item_id]->metas = array();
413 413
             }
414 414
 
415
-			$entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
415
+			$entries[$meta_val->item_id]->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value );
416 416
 
417
-            unset($m_key, $meta_val);
417
+            unset( $m_key, $meta_val );
418 418
         }
419 419
 
420 420
 		if ( ! FrmAppHelper::prevent_caching() ) {
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 			}
425 425
 		}
426 426
 
427
-        return stripslashes_deep($entries);
427
+        return stripslashes_deep( $entries );
428 428
     }
429 429
 
430 430
     // Pagination Methods
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
         global $wpdb;
433 433
 		$table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id';
434 434
 
435
-        if ( is_numeric($where) ) {
435
+        if ( is_numeric( $where ) ) {
436 436
             $table_join = 'frm_items';
437 437
             $where = array( 'form_id' => $where );
438 438
         }
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 		self::sanitize_entry_post( $values );
475 475
 
476 476
 		if ( $type != 'xml' ) {
477
-			$values = apply_filters('frm_pre_create_entry', $values);
477
+			$values = apply_filters( 'frm_pre_create_entry', $values );
478 478
 		}
479 479
 
480 480
 		$new_values = self::package_entry_data( $values );
@@ -554,17 +554,17 @@  discard block
 block discarded – undo
554 554
 			'user_id' => self::get_entry_user_id( $values ),
555 555
 		);
556 556
 
557
-		if ( is_array($new_values['name']) ) {
558
-			$new_values['name'] = reset($new_values['name']);
557
+		if ( is_array( $new_values['name'] ) ) {
558
+			$new_values['name'] = reset( $new_values['name'] );
559 559
 		}
560 560
 
561
-		$new_values['updated_by'] = isset($values['updated_by']) ? $values['updated_by'] : $new_values['user_id'];
561
+		$new_values['updated_by'] = isset( $values['updated_by'] ) ? $values['updated_by'] : $new_values['user_id'];
562 562
 
563 563
 		return $new_values;
564 564
 	}
565 565
 
566 566
 	private static function get_entry_value( $values, $name, $default ) {
567
-		return isset( $values[ $name ] ) ? $values[ $name ] : $default;
567
+		return isset( $values[$name] ) ? $values[$name] : $default;
568 568
 	}
569 569
 
570 570
 	/**
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 	 */
578 578
 	private static function get_ip( $values ) {
579 579
 		$ip = FrmAppHelper::get_ip_address();
580
-		if ( defined('WP_IMPORTING') && WP_IMPORTING ) {
580
+		if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
581 581
 			$ip = self::get_entry_value( $values, 'ip', $ip );
582 582
 		}
583 583
 		return $ip;
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
 	private static function add_new_entry_to_frm_vars( $entry_id ) {
691 691
 		global $frm_vars;
692 692
 
693
-		if ( ! isset($frm_vars['saved_entries']) ) {
693
+		if ( ! isset( $frm_vars['saved_entries'] ) ) {
694 694
 			$frm_vars['saved_entries'] = array();
695 695
 		}
696 696
 
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 	* @param int $entry_id
706 706
 	*/
707 707
 	private static function maybe_add_entry_metas( $values, $entry_id ) {
708
-		if ( isset($values['item_meta']) ) {
708
+		if ( isset( $values['item_meta'] ) ) {
709 709
 			FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] );
710 710
 		}
711 711
 	}
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 		$is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' );
723 723
 
724 724
 		do_action( 'frm_after_create_entry', $entry_id, $new_values['form_id'], compact( 'is_child' ) );
725
-		do_action( 'frm_after_create_entry_' . $new_values['form_id'], $entry_id , compact( 'is_child' ) );
725
+		do_action( 'frm_after_create_entry_' . $new_values['form_id'], $entry_id, compact( 'is_child' ) );
726 726
 	}
727 727
 
728 728
 	/**
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
 		}
764 764
 
765 765
 		if ( $update && $update_type != 'xml' ) {
766
-			$values = apply_filters('frm_pre_update_entry', $values, $id);
766
+			$values = apply_filters( 'frm_pre_update_entry', $values, $id );
767 767
 		}
768 768
 
769 769
 		return $update;
@@ -784,27 +784,27 @@  discard block
 block discarded – undo
784 784
 			'name'      => self::get_new_entry_name( $values ),
785 785
 			'form_id'   => (int) self::get_entry_value( $values, 'form_id', null ),
786 786
 			'is_draft'  => self::get_is_draft_value( $values ),
787
-			'updated_at' => current_time('mysql', 1),
788
-			'updated_by' => isset($values['updated_by']) ? $values['updated_by'] : get_current_user_id(),
787
+			'updated_at' => current_time( 'mysql', 1 ),
788
+			'updated_by' => isset( $values['updated_by'] ) ? $values['updated_by'] : get_current_user_id(),
789 789
 		);
790 790
 
791
-		if ( isset($values['post_id']) ) {
791
+		if ( isset( $values['post_id'] ) ) {
792 792
 			$new_values['post_id'] = (int) $values['post_id'];
793 793
 		}
794 794
 
795
-		if ( isset($values['item_key']) ) {
795
+		if ( isset( $values['item_key'] ) ) {
796 796
 			$new_values['item_key'] = FrmAppHelper::get_unique_key( $values['item_key'], $wpdb->prefix . 'frm_items', 'item_key', $id );
797 797
 		}
798 798
 
799
-		if ( isset($values['parent_item_id']) ) {
799
+		if ( isset( $values['parent_item_id'] ) ) {
800 800
 			$new_values['parent_item_id'] = (int) $values['parent_item_id'];
801 801
 		}
802 802
 
803
-		if ( isset($values['frm_user_id']) && is_numeric($values['frm_user_id']) ) {
803
+		if ( isset( $values['frm_user_id'] ) && is_numeric( $values['frm_user_id'] ) ) {
804 804
 			$new_values['user_id'] = $values['frm_user_id'];
805 805
 		}
806 806
 
807
-		$new_values = apply_filters('frm_update_entry', $new_values, $id);
807
+		$new_values = apply_filters( 'frm_update_entry', $new_values, $id );
808 808
 
809 809
 		return $new_values;
810 810
 	}
Please login to merge, or discard this patch.
classes/views/frm-settings/license_box.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<div class="general_settings metabox-holder tabs-panel frm_license_box <?php echo ($a == 'general_settings') ? 'frm_block' : 'frm_hidden'; ?>">
1
+<div class="general_settings metabox-holder tabs-panel frm_license_box <?php echo ( $a == 'general_settings' ) ? 'frm_block' : 'frm_hidden'; ?>">
2 2
 <?php if ( ! is_multisite() || current_user_can( 'setup_network' ) ) { ?>
3 3
     <div class="postbox">
4 4
         <div class="inside">
Please login to merge, or discard this patch.
classes/helpers/FrmXMLHelper.php 2 patches
Indentation   +506 added lines, -506 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,11 +127,11 @@  discard block
 block discarded – undo
127 127
 		self::put_child_forms_first( $forms );
128 128
 
129 129
 		foreach ( $forms as $item ) {
130
-            $form = self::fill_form( $item );
130
+			$form = self::fill_form( $item );
131 131
 
132 132
 			self::update_custom_style_setting_on_import( $form );
133 133
 
134
-	        $this_form = self::maybe_get_form( $form );
134
+			$this_form = self::maybe_get_form( $form );
135 135
 
136 136
 			$old_id = false;
137 137
 			$form_fields = false;
@@ -143,35 +143,35 @@  discard block
 block discarded – undo
143 143
 				$form_fields = self::get_form_fields( $form_id );
144 144
 			} else {
145 145
 				$form_id = FrmForm::create( $form );
146
-		        if ( $form_id ) {
147
-		            $imported['imported']['forms']++;
148
-		            // Keep track of whether this specific form was updated or not
146
+				if ( $form_id ) {
147
+					$imported['imported']['forms']++;
148
+					// Keep track of whether this specific form was updated or not
149 149
 					$imported['form_status'][ $form_id ] = 'imported';
150 150
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
151
-		        }
151
+				}
152 152
 			}
153 153
 
154 154
 			self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported );
155 155
 
156 156
 			self::delete_removed_fields( $form_fields );
157 157
 
158
-		    // Update field ids/keys to new ones
158
+			// Update field ids/keys to new ones
159 159
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
160 160
 
161 161
 			$imported['forms'][ (int) $item->id ] = $form_id;
162 162
 
163
-            // Send pre 2.0 form options through function that creates actions
164
-            self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true );
163
+			// Send pre 2.0 form options through function that creates actions
164
+			self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true );
165 165
 
166 166
 			do_action( 'frm_after_import_form', $form_id, $form );
167 167
 
168
-		    unset($form, $item);
168
+			unset($form, $item);
169 169
 		}
170 170
 
171 171
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
172 172
 
173 173
 		return $imported;
174
-    }
174
+	}
175 175
 
176 176
 	private static function fill_form( $item ) {
177 177
 		$form = array(
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
 	}
240 240
 
241 241
 	/**
242
-	* Put child forms first so they will be imported before parents
243
-	*
244
-	* @since 2.0.16
245
-	* @param array $forms
246
-	*/
242
+	 * Put child forms first so they will be imported before parents
243
+	 *
244
+	 * @since 2.0.16
245
+	 * @param array $forms
246
+	 */
247 247
 	private static function put_child_forms_first( &$forms ) {
248 248
 		$child_forms = array();
249 249
 		$regular_forms = array();
@@ -262,13 +262,13 @@  discard block
 block discarded – undo
262 262
 	}
263 263
 
264 264
 	/**
265
-	* Keep track of all imported child forms
266
-	*
267
-	* @since 2.0.16
268
-	* @param int $form_id
269
-	* @param int $parent_form_id
270
-	* @param array $child_forms
271
-	*/
265
+	 * Keep track of all imported child forms
266
+	 *
267
+	 * @since 2.0.16
268
+	 * @param int $form_id
269
+	 * @param int $parent_form_id
270
+	 * @param array $child_forms
271
+	 */
272 272
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
273 273
 		if ( $parent_form_id ) {
274 274
 			$child_forms[ $form_id ] = $parent_form_id;
@@ -276,13 +276,13 @@  discard block
 block discarded – undo
276 276
 	}
277 277
 
278 278
 	/**
279
-	* Update the parent_form_id on imported child forms
280
-	* Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
281
-	*
282
-	* @since 2.0.6
283
-	* @param array $imported_forms
284
-	* @param array $child_forms
285
-	*/
279
+	 * Update the parent_form_id on imported child forms
280
+	 * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
281
+	 *
282
+	 * @since 2.0.6
283
+	 * @param array $imported_forms
284
+	 * @param array $child_forms
285
+	 */
286 286
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
287 287
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
288 288
 
@@ -296,28 +296,28 @@  discard block
 block discarded – undo
296 296
 	}
297 297
 
298 298
 	/**
299
-	* Import all fields for a form
300
-	* @since 2.0.13
301
-	*
302
-	* TODO: Cut down on params
303
-	*/
299
+	 * Import all fields for a form
300
+	 * @since 2.0.13
301
+	 *
302
+	 * TODO: Cut down on params
303
+	 */
304 304
 	private static function import_xml_fields( $xml_fields, $form_id, $this_form, &$form_fields, &$imported ) {
305 305
 		$in_section = 0;
306 306
 
307 307
 		foreach ( $xml_fields as $field ) {
308 308
 			$f = self::fill_field( $field, $form_id );
309 309
 
310
-		    if ( is_array($f['default_value']) && in_array($f['type'], array(
311
-		        'text', 'email', 'url', 'textarea',
312
-		        'number','phone', 'date',
313
-		        'hidden', 'password', 'tag', 'image',
314
-		    )) ) {
315
-		        if ( count($f['default_value']) === 1 ) {
310
+			if ( is_array($f['default_value']) && in_array($f['type'], array(
311
+				'text', 'email', 'url', 'textarea',
312
+				'number','phone', 'date',
313
+				'hidden', 'password', 'tag', 'image',
314
+			)) ) {
315
+				if ( count($f['default_value']) === 1 ) {
316 316
 					$f['default_value'] = '[' . reset( $f['default_value'] ) . ']';
317
-		        } else {
318
-		            $f['default_value'] = reset($f['default_value']);
319
-		        }
320
-		    }
317
+				} else {
318
+					$f['default_value'] = reset($f['default_value']);
319
+				}
320
+			}
321 321
 
322 322
 			self::maybe_update_in_section_variable( $in_section, $f );
323 323
 			self::maybe_update_form_select( $f, $imported );
@@ -396,12 +396,12 @@  discard block
 block discarded – undo
396 396
 	}
397 397
 
398 398
 	/**
399
-	* Switch the form_select on a repeating field or embedded form if it needs to be switched
400
-	*
401
-	* @since 2.0.16
402
-	* @param array $f
403
-	* @param array $imported
404
-	*/
399
+	 * Switch the form_select on a repeating field or embedded form if it needs to be switched
400
+	 *
401
+	 * @since 2.0.16
402
+	 * @param array $f
403
+	 * @param array $imported
404
+	 */
405 405
 	private static function maybe_update_form_select( &$f, $imported ) {
406 406
 		if ( ! isset( $imported['forms'] ) ) {
407 407
 			return;
@@ -453,13 +453,13 @@  discard block
 block discarded – undo
453 453
 	}
454 454
 
455 455
 	/**
456
-	* Updates the custom style setting on import
457
-	* Convert the post slug to an ID
458
-	*
459
-	* @since 2.0.19
460
-	* @param array $form
461
-	*
462
-	*/
456
+	 * Updates the custom style setting on import
457
+	 * Convert the post slug to an ID
458
+	 *
459
+	 * @since 2.0.19
460
+	 * @param array $form
461
+	 *
462
+	 */
463 463
 	private static function update_custom_style_setting_on_import( &$form ) {
464 464
 		if ( ! isset( $form['options']['custom_style'] ) ) {
465 465
 			return;
@@ -513,16 +513,16 @@  discard block
 block discarded – undo
513 513
 	}
514 514
 
515 515
 	public static function import_xml_views( $views, $imported ) {
516
-        $imported['posts'] = array();
517
-        $form_action_type = FrmFormActionsController::$action_post_type;
516
+		$imported['posts'] = array();
517
+		$form_action_type = FrmFormActionsController::$action_post_type;
518 518
 
519
-        $post_types = array(
520
-            'frm_display' => 'views',
521
-            $form_action_type => 'actions',
522
-            'frm_styles'    => 'styles',
523
-        );
519
+		$post_types = array(
520
+			'frm_display' => 'views',
521
+			$form_action_type => 'actions',
522
+			'frm_styles'    => 'styles',
523
+		);
524 524
 
525
-        foreach ( $views as $item ) {
525
+		foreach ( $views as $item ) {
526 526
 			$post = array(
527 527
 				'post_title'    => (string) $item->title,
528 528
 				'post_name'     => (string) $item->post_name,
@@ -541,52 +541,52 @@  discard block
 block discarded – undo
541 541
 				'post_date'     => (string) $item->post_date,
542 542
 				'post_date_gmt' => (string) $item->post_date_gmt,
543 543
 				'ping_status'   => (string) $item->ping_status,
544
-                'postmeta'      => array(),
545
-                'tax_input'     => array(),
544
+				'postmeta'      => array(),
545
+				'tax_input'     => array(),
546 546
 			);
547 547
 
548
-            $old_id = $post['post_id'];
549
-            self::populate_post($post, $item, $imported);
548
+			$old_id = $post['post_id'];
549
+			self::populate_post($post, $item, $imported);
550 550
 
551 551
 			unset($item);
552 552
 
553 553
 			$post_id = false;
554
-            if ( $post['post_type'] == $form_action_type ) {
555
-                $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
554
+			if ( $post['post_type'] == $form_action_type ) {
555
+				$action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
556 556
 				if ( $action_control && is_object( $action_control ) ) {
557 557
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
558 558
 				}
559
-                unset($action_control);
560
-            } else if ( $post['post_type'] == 'frm_styles' ) {
561
-                // Properly encode post content before inserting the post
562
-                $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
559
+				unset($action_control);
560
+			} else if ( $post['post_type'] == 'frm_styles' ) {
561
+				// Properly encode post content before inserting the post
562
+				$post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
563 563
 				$custom_css = isset( $post['post_content']['custom_css'] ) ? $post['post_content']['custom_css'] : '';
564
-                $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
564
+				$post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
565 565
 
566
-                // Create/update post now
567
-                $post_id = wp_insert_post( $post );
566
+				// Create/update post now
567
+				$post_id = wp_insert_post( $post );
568 568
 				self::maybe_update_custom_css( $custom_css );
569
-            } else {
570
-                // Create/update post now
571
-                $post_id = wp_insert_post( $post );
572
-            }
569
+			} else {
570
+				// Create/update post now
571
+				$post_id = wp_insert_post( $post );
572
+			}
573 573
 
574
-            if ( ! is_numeric($post_id) ) {
575
-                continue;
576
-            }
574
+			if ( ! is_numeric($post_id) ) {
575
+				continue;
576
+			}
577 577
 
578
-            self::update_postmeta($post, $post_id);
578
+			self::update_postmeta($post, $post_id);
579 579
 
580
-            $this_type = 'posts';
580
+			$this_type = 'posts';
581 581
 			if ( isset( $post_types[ $post['post_type'] ] ) ) {
582 582
 				$this_type = $post_types[ $post['post_type'] ];
583
-            }
583
+			}
584 584
 
585
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
586
-                $imported['updated'][ $this_type ]++;
587
-            } else {
588
-                $imported['imported'][ $this_type ]++;
589
-            }
585
+			if ( isset($post['ID']) && $post_id == $post['ID'] ) {
586
+				$imported['updated'][ $this_type ]++;
587
+			} else {
588
+				$imported['imported'][ $this_type ]++;
589
+			}
590 590
 
591 591
 			$imported['posts'][ (int) $old_id ] = $post_id;
592 592
 
@@ -598,16 +598,16 @@  discard block
 block discarded – undo
598 598
 		self::maybe_update_stylesheet( $imported );
599 599
 
600 600
 		return $imported;
601
-    }
601
+	}
602 602
 
603
-    private static function populate_post( &$post, $item, $imported ) {
603
+	private static function populate_post( &$post, $item, $imported ) {
604 604
 		if ( isset($item->attachment_url) ) {
605 605
 			$post['attachment_url'] = (string) $item->attachment_url;
606 606
 		}
607 607
 
608 608
 		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
609
-		    // update to new form id
610
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
609
+			// update to new form id
610
+			$post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
611 611
 		}
612 612
 
613 613
 		// Don't allow default styles to take over a site's default style
@@ -616,144 +616,144 @@  discard block
 block discarded – undo
616 616
 		}
617 617
 
618 618
 		foreach ( $item->postmeta as $meta ) {
619
-		    self::populate_postmeta($post, $meta, $imported);
619
+			self::populate_postmeta($post, $meta, $imported);
620 620
 			unset($meta);
621 621
 		}
622 622
 
623
-        self::populate_taxonomies($post, $item);
623
+		self::populate_taxonomies($post, $item);
624 624
 
625
-        self::maybe_editing_post($post);
626
-    }
625
+		self::maybe_editing_post($post);
626
+	}
627 627
 
628
-    private static function populate_postmeta( &$post, $meta, $imported ) {
629
-        global $frm_duplicate_ids;
628
+	private static function populate_postmeta( &$post, $meta, $imported ) {
629
+		global $frm_duplicate_ids;
630 630
 
631
-	    $m = array(
631
+		$m = array(
632 632
 			'key'   => (string) $meta->meta_key,
633 633
 			'value' => (string) $meta->meta_value,
634 634
 		);
635 635
 
636 636
 		//switch old form and field ids to new ones
637 637
 		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
638
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
638
+			$m['value'] = $imported['forms'][ (int) $m['value'] ];
639 639
 		} else {
640
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
640
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
641 641
 
642
-		    if ( ! empty($frm_duplicate_ids) ) {
642
+			if ( ! empty($frm_duplicate_ids) ) {
643 643
 
644
-		        if ( $m['key'] == 'frm_dyncontent' ) {
645
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
646
-    		    } else if ( $m['key'] == 'frm_options' ) {
644
+				if ( $m['key'] == 'frm_dyncontent' ) {
645
+					$m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
646
+				} else if ( $m['key'] == 'frm_options' ) {
647 647
 
648 648
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
649 649
 						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
650 650
 							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
651
-    		            }
652
-    		        }
653
-
654
-                    $check_dup_array = array();
655
-    		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
656
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
657
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
658
-    		            } else if ( is_array( $m['value']['order_by'] ) ) {
659
-                            $check_dup_array[] = 'order_by';
660
-    		            }
661
-    		        }
662
-
663
-    		        if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
664
-    		            $check_dup_array[] = 'where';
665
-    		        }
666
-
667
-                    foreach ( $check_dup_array as $check_k ) {
651
+						}
652
+					}
653
+
654
+					$check_dup_array = array();
655
+					if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
656
+						if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
657
+							$m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
658
+						} else if ( is_array( $m['value']['order_by'] ) ) {
659
+							$check_dup_array[] = 'order_by';
660
+						}
661
+					}
662
+
663
+					if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
664
+						$check_dup_array[] = 'where';
665
+					}
666
+
667
+					foreach ( $check_dup_array as $check_k ) {
668 668
 						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
669 669
 							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
670 670
 								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
671
-		                    }
672
-		                    unset($mk, $mv);
673
-		                }
674
-                    }
675
-    		    }
676
-		    }
671
+							}
672
+							unset($mk, $mv);
673
+						}
674
+					}
675
+				}
676
+			}
677 677
 		}
678 678
 
679 679
 		if ( ! is_array($m['value']) ) {
680
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
680
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
681 681
 		}
682 682
 
683 683
 		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
684
-    }
685
-
686
-    /**
687
-     * Add terms to post
688
-     * @param array $post by reference
689
-     * @param object $item The XML object data
690
-     */
691
-    private static function populate_taxonomies( &$post, $item ) {
684
+	}
685
+
686
+	/**
687
+	 * Add terms to post
688
+	 * @param array $post by reference
689
+	 * @param object $item The XML object data
690
+	 */
691
+	private static function populate_taxonomies( &$post, $item ) {
692 692
 		foreach ( $item->category as $c ) {
693 693
 			$att = $c->attributes();
694 694
 			if ( ! isset( $att['nicename'] ) ) {
695
-                continue;
696
-            }
697
-
698
-		    $taxonomy = (string) $att['domain'];
699
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
700
-		        $name = (string) $att['nicename'];
701
-		        $h_term = get_term_by('slug', $name, $taxonomy);
702
-		        if ( $h_term ) {
703
-		            $name = $h_term->term_id;
704
-		        }
705
-		        unset($h_term);
706
-		    } else {
707
-		        $name = (string) $c;
708
-		    }
695
+				continue;
696
+			}
697
+
698
+			$taxonomy = (string) $att['domain'];
699
+			if ( is_taxonomy_hierarchical($taxonomy) ) {
700
+				$name = (string) $att['nicename'];
701
+				$h_term = get_term_by('slug', $name, $taxonomy);
702
+				if ( $h_term ) {
703
+					$name = $h_term->term_id;
704
+				}
705
+				unset($h_term);
706
+			} else {
707
+				$name = (string) $c;
708
+			}
709 709
 
710 710
 			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
711 711
 				$post['tax_input'][ $taxonomy ] = array();
712 712
 			}
713 713
 
714 714
 			$post['tax_input'][ $taxonomy ][] = $name;
715
-		    unset($name);
715
+			unset($name);
716 716
 		}
717
-    }
717
+	}
718 718
 
719
-    /**
720
-     * Edit post if the key and created time match
721
-     */
722
-    private static function maybe_editing_post( &$post ) {
719
+	/**
720
+	 * Edit post if the key and created time match
721
+	 */
722
+	private static function maybe_editing_post( &$post ) {
723 723
 		$match_by = array(
724
-		    'post_type'     => $post['post_type'],
725
-		    'name'          => $post['post_name'],
726
-		    'post_status'   => $post['post_status'],
727
-		    'posts_per_page' => 1,
724
+			'post_type'     => $post['post_type'],
725
+			'name'          => $post['post_name'],
726
+			'post_status'   => $post['post_status'],
727
+			'posts_per_page' => 1,
728 728
 		);
729 729
 
730 730
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
731
-		    $match_by['include'] = $post['post_id'];
732
-		    unset($match_by['name']);
731
+			$match_by['include'] = $post['post_id'];
732
+			unset($match_by['name']);
733 733
 		}
734 734
 
735 735
 		$editing = get_posts($match_by);
736 736
 
737
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
738
-            // set the id of the post to edit
739
-            $post['ID'] = current($editing)->ID;
740
-        }
741
-    }
737
+		if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
738
+			// set the id of the post to edit
739
+			$post['ID'] = current($editing)->ID;
740
+		}
741
+	}
742 742
 
743
-    private static function update_postmeta( &$post, $post_id ) {
744
-        foreach ( $post['postmeta'] as $k => $v ) {
745
-            if ( '_edit_last' == $k ) {
746
-                $v = FrmAppHelper::get_user_id_param($v);
747
-            } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
748
-                //change the attachment ID
749
-                $v = FrmProXMLHelper::get_file_id($v);
750
-            }
743
+	private static function update_postmeta( &$post, $post_id ) {
744
+		foreach ( $post['postmeta'] as $k => $v ) {
745
+			if ( '_edit_last' == $k ) {
746
+				$v = FrmAppHelper::get_user_id_param($v);
747
+			} else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
748
+				//change the attachment ID
749
+				$v = FrmProXMLHelper::get_file_id($v);
750
+			}
751 751
 
752
-            update_post_meta($post_id, $k, $v);
752
+			update_post_meta($post_id, $k, $v);
753 753
 
754
-            unset($k, $v);
755
-        }
756
-    }
754
+			unset($k, $v);
755
+		}
756
+	}
757 757
 
758 758
 	/**
759 759
 	 * If a template includes custom css, let's include it.
@@ -786,72 +786,72 @@  discard block
 block discarded – undo
786 786
 		}
787 787
 	}
788 788
 
789
-    /**
790
-     * @param string $message
791
-     */
789
+	/**
790
+	 * @param string $message
791
+	 */
792 792
 	public static function parse_message( $result, &$message, &$errors ) {
793
-        if ( is_wp_error($result) ) {
794
-            $errors[] = $result->get_error_message();
795
-        } else if ( ! $result ) {
796
-            return;
797
-        }
798
-
799
-        if ( ! is_array($result) ) {
800
-            $message = is_string( $result ) ? $result : print_r( $result, 1 );
801
-            return;
802
-        }
803
-
804
-        $t_strings = array(
805
-            'imported'  => __( 'Imported', 'formidable' ),
806
-            'updated'   => __( 'Updated', 'formidable' ),
807
-        );
808
-
809
-        $message = '<ul>';
810
-        foreach ( $result as $type => $results ) {
793
+		if ( is_wp_error($result) ) {
794
+			$errors[] = $result->get_error_message();
795
+		} else if ( ! $result ) {
796
+			return;
797
+		}
798
+
799
+		if ( ! is_array($result) ) {
800
+			$message = is_string( $result ) ? $result : print_r( $result, 1 );
801
+			return;
802
+		}
803
+
804
+		$t_strings = array(
805
+			'imported'  => __( 'Imported', 'formidable' ),
806
+			'updated'   => __( 'Updated', 'formidable' ),
807
+		);
808
+
809
+		$message = '<ul>';
810
+		foreach ( $result as $type => $results ) {
811 811
 			if ( ! isset( $t_strings[ $type ] ) ) {
812
-                // only print imported and updated
813
-                continue;
814
-            }
812
+				// only print imported and updated
813
+				continue;
814
+			}
815 815
 
816
-            $s_message = array();
817
-            foreach ( $results as $k => $m ) {
818
-                self::item_count_message($m, $k, $s_message);
819
-                unset($k, $m);
820
-            }
816
+			$s_message = array();
817
+			foreach ( $results as $k => $m ) {
818
+				self::item_count_message($m, $k, $s_message);
819
+				unset($k, $m);
820
+			}
821 821
 
822
-            if ( ! empty($s_message) ) {
822
+			if ( ! empty($s_message) ) {
823 823
 				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
824
-                $message .= implode(', ', $s_message);
825
-                $message .= '</li>';
826
-            }
827
-        }
828
-
829
-        if ( $message == '<ul>' ) {
830
-            $message = '';
831
-            $errors[] = __( 'Nothing was imported or updated', 'formidable' );
832
-        } else {
833
-            $message .= '</ul>';
834
-        }
835
-    }
824
+				$message .= implode(', ', $s_message);
825
+				$message .= '</li>';
826
+			}
827
+		}
828
+
829
+		if ( $message == '<ul>' ) {
830
+			$message = '';
831
+			$errors[] = __( 'Nothing was imported or updated', 'formidable' );
832
+		} else {
833
+			$message .= '</ul>';
834
+		}
835
+	}
836 836
 
837 837
 	public static function item_count_message( $m, $type, &$s_message ) {
838
-        if ( ! $m ) {
839
-            return;
840
-        }
841
-
842
-        $strings = array(
843
-            'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
844
-            'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
845
-            'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
846
-            'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
847
-            'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
848
-            'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
849
-            'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
850
-            'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
851
-        );
838
+		if ( ! $m ) {
839
+			return;
840
+		}
841
+
842
+		$strings = array(
843
+			'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
844
+			'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
845
+			'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
846
+			'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
847
+			'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
848
+			'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
849
+			'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
850
+			'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
851
+		);
852 852
 
853 853
 		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
854
-    }
854
+	}
855 855
 
856 856
 	/**
857 857
 	 * Prepare the form options for export
@@ -882,16 +882,16 @@  discard block
 block discarded – undo
882 882
 	}
883 883
 
884 884
 	public static function cdata( $str ) {
885
-	    $str = maybe_unserialize($str);
886
-	    if ( is_array($str) ) {
887
-	        $str = json_encode($str);
885
+		$str = maybe_unserialize($str);
886
+		if ( is_array($str) ) {
887
+			$str = json_encode($str);
888 888
 		} else if ( seems_utf8( $str ) == false ) {
889 889
 			$str = utf8_encode( $str );
890 890
 		}
891 891
 
892
-        if ( is_numeric($str) ) {
893
-            return $str;
894
-        }
892
+		if ( is_numeric($str) ) {
893
+			return $str;
894
+		}
895 895
 
896 896
 		self::remove_invalid_characters_from_xml( $str );
897 897
 
@@ -912,58 +912,58 @@  discard block
 block discarded – undo
912 912
 		$str = str_replace( '\x1F', '', $str );
913 913
 	}
914 914
 
915
-    public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
916
-        // Get post type
917
-        $post_type = FrmFormActionsController::$action_post_type;
918
-
919
-        // Set up imported index, if not set up yet
920
-        if ( ! isset( $imported['imported']['actions'] ) ) {
921
-            $imported['imported']['actions'] = 0;
922
-        }
923
-
924
-        // Migrate post settings to action
925
-        self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
926
-
927
-        // Migrate email settings to action
928
-        self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
929
-    }
930
-
931
-    /**
932
-    * Migrate post settings to form action
933
-    *
934
-    * @param string $post_type
935
-    */
936
-    private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
937
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
938
-            return;
939
-        }
940
-
941
-        $new_action = array(
942
-            'post_type'     => $post_type,
943
-            'post_excerpt'  => 'wppost',
915
+	public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
916
+		// Get post type
917
+		$post_type = FrmFormActionsController::$action_post_type;
918
+
919
+		// Set up imported index, if not set up yet
920
+		if ( ! isset( $imported['imported']['actions'] ) ) {
921
+			$imported['imported']['actions'] = 0;
922
+		}
923
+
924
+		// Migrate post settings to action
925
+		self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
926
+
927
+		// Migrate email settings to action
928
+		self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
929
+	}
930
+
931
+	/**
932
+	 * Migrate post settings to form action
933
+	 *
934
+	 * @param string $post_type
935
+	 */
936
+	private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
937
+		if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
938
+			return;
939
+		}
940
+
941
+		$new_action = array(
942
+			'post_type'     => $post_type,
943
+			'post_excerpt'  => 'wppost',
944 944
 			'post_title'    => __( 'Create Posts', 'formidable' ),
945
-            'menu_order'    => $form_id,
946
-            'post_status'   => 'publish',
947
-            'post_content'  => array(),
945
+			'menu_order'    => $form_id,
946
+			'post_status'   => 'publish',
947
+			'post_content'  => array(),
948 948
 			'post_name'     => $form_id . '_wppost_1',
949
-        );
949
+		);
950 950
 
951
-        $post_settings = array(
952
-            'post_type', 'post_category', 'post_content',
953
-            'post_excerpt', 'post_title', 'post_name', 'post_date',
951
+		$post_settings = array(
952
+			'post_type', 'post_category', 'post_content',
953
+			'post_excerpt', 'post_title', 'post_name', 'post_date',
954 954
 			'post_status', 'post_custom_fields', 'post_password',
955
-        );
955
+		);
956 956
 
957
-        foreach ( $post_settings as $post_setting ) {
957
+		foreach ( $post_settings as $post_setting ) {
958 958
 			if ( isset( $form_options[ $post_setting ] ) ) {
959 959
 				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
960
-            }
961
-            unset($post_setting);
962
-        }
960
+			}
961
+			unset($post_setting);
962
+		}
963 963
 
964 964
 		$new_action['event'] = array( 'create', 'update' );
965 965
 
966
-        if ( $switch ) {
966
+		if ( $switch ) {
967 967
 			// Fields with string or int saved
968 968
 			$basic_fields = array( 'post_title', 'post_content', 'post_excerpt', 'post_password', 'post_date', 'post_status' );
969 969
 
@@ -971,22 +971,22 @@  discard block
 block discarded – undo
971 971
 			$array_fields = array( 'post_category', 'post_custom_fields' );
972 972
 
973 973
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
974
-        }
975
-        $new_action['post_content'] = json_encode($new_action['post_content']);
974
+		}
975
+		$new_action['post_content'] = json_encode($new_action['post_content']);
976 976
 
977
-        $exists = get_posts( array(
978
-            'name'          => $new_action['post_name'],
979
-            'post_type'     => $new_action['post_type'],
980
-            'post_status'   => $new_action['post_status'],
981
-            'numberposts'   => 1,
982
-        ) );
977
+		$exists = get_posts( array(
978
+			'name'          => $new_action['post_name'],
979
+			'post_type'     => $new_action['post_type'],
980
+			'post_status'   => $new_action['post_status'],
981
+			'numberposts'   => 1,
982
+		) );
983 983
 
984
-        if ( ! $exists ) {
984
+		if ( ! $exists ) {
985 985
 			// this isn't an email, but we need to use a class that will always be included
986 986
 			FrmAppHelper::save_json_post( $new_action );
987
-            $imported['imported']['actions']++;
988
-        }
989
-    }
987
+			$imported['imported']['actions']++;
988
+		}
989
+	}
990 990
 
991 991
 	/**
992 992
 	 * Switch old field IDs for new field IDs in emails and post
@@ -999,211 +999,211 @@  discard block
 block discarded – undo
999 999
 	 * @return string $post_content - new field IDs
1000 1000
 	 */
1001 1001
 	private static function switch_action_field_ids( $post_content, $basic_fields, $array_fields = array() ) {
1002
-        global $frm_duplicate_ids;
1002
+		global $frm_duplicate_ids;
1003 1003
 
1004
-        // If there aren't IDs that were switched, end now
1005
-        if ( ! $frm_duplicate_ids ) {
1006
-            return;
1007
-        }
1004
+		// If there aren't IDs that were switched, end now
1005
+		if ( ! $frm_duplicate_ids ) {
1006
+			return;
1007
+		}
1008 1008
 
1009
-        // Get old IDs
1010
-        $old = array_keys( $frm_duplicate_ids );
1009
+		// Get old IDs
1010
+		$old = array_keys( $frm_duplicate_ids );
1011 1011
 
1012
-        // Get new IDs
1013
-        $new = array_values( $frm_duplicate_ids );
1012
+		// Get new IDs
1013
+		$new = array_values( $frm_duplicate_ids );
1014 1014
 
1015
-        // Do a str_replace with each item to set the new IDs
1016
-        foreach ( $post_content as $key => $setting ) {
1017
-            if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
1018
-                // Replace old IDs with new IDs
1015
+		// Do a str_replace with each item to set the new IDs
1016
+		foreach ( $post_content as $key => $setting ) {
1017
+			if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
1018
+				// Replace old IDs with new IDs
1019 1019
 				$post_content[ $key ] = str_replace( $old, $new, $setting );
1020
-            } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
1021
-                foreach ( $setting as $k => $val ) {
1022
-                    // Replace old IDs with new IDs
1020
+			} else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
1021
+				foreach ( $setting as $k => $val ) {
1022
+					// Replace old IDs with new IDs
1023 1023
 					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
1024
-                }
1025
-            }
1026
-            unset( $key, $setting );
1027
-        }
1028
-        return $post_content;
1029
-    }
1030
-
1031
-    private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
1032
-        // No old notifications or autoresponders to carry over
1024
+				}
1025
+			}
1026
+			unset( $key, $setting );
1027
+		}
1028
+		return $post_content;
1029
+	}
1030
+
1031
+	private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
1032
+		// No old notifications or autoresponders to carry over
1033 1033
 		if ( ! isset( $form_options['auto_responder'] ) && ! isset( $form_options['notification'] ) && ! isset( $form_options['email_to'] ) ) {
1034
-            return;
1035
-        }
1034
+			return;
1035
+		}
1036 1036
 
1037
-        // Initialize notifications array
1038
-        $notifications = array();
1037
+		// Initialize notifications array
1038
+		$notifications = array();
1039 1039
 
1040
-        // Migrate regular notifications
1041
-        self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
1040
+		// Migrate regular notifications
1041
+		self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
1042 1042
 
1043
-        // Migrate autoresponders
1044
-        self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
1043
+		// Migrate autoresponders
1044
+		self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
1045 1045
 
1046
-        if ( empty( $notifications ) ) {
1047
-            return;
1048
-        }
1046
+		if ( empty( $notifications ) ) {
1047
+			return;
1048
+		}
1049 1049
 
1050
-        foreach ( $notifications as $new_notification ) {
1051
-            $new_notification['post_type']      = $post_type;
1052
-            $new_notification['post_excerpt']   = 'email';
1050
+		foreach ( $notifications as $new_notification ) {
1051
+			$new_notification['post_type']      = $post_type;
1052
+			$new_notification['post_excerpt']   = 'email';
1053 1053
 			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
1054
-            $new_notification['menu_order']     = $form_id;
1055
-            $new_notification['post_status']    = 'publish';
1054
+			$new_notification['menu_order']     = $form_id;
1055
+			$new_notification['post_status']    = 'publish';
1056 1056
 
1057
-            // Switch field IDs and keys, if needed
1058
-            if ( $switch ) {
1057
+			// Switch field IDs and keys, if needed
1058
+			if ( $switch ) {
1059 1059
 
1060 1060
 				// Switch field IDs in email conditional logic
1061 1061
 				self::switch_email_contition_field_ids( $new_notification['post_content'] );
1062 1062
 
1063 1063
 				// Switch all other field IDs in email
1064
-                $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1065
-            }
1066
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1067
-
1068
-            $exists = get_posts( array(
1069
-                'name'          => $new_notification['post_name'],
1070
-                'post_type'     => $new_notification['post_type'],
1071
-                'post_status'   => $new_notification['post_status'],
1072
-                'numberposts'   => 1,
1073
-            ) );
1074
-
1075
-            if ( empty($exists) ) {
1064
+				$new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1065
+			}
1066
+			$new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1067
+
1068
+			$exists = get_posts( array(
1069
+				'name'          => $new_notification['post_name'],
1070
+				'post_type'     => $new_notification['post_type'],
1071
+				'post_status'   => $new_notification['post_status'],
1072
+				'numberposts'   => 1,
1073
+			) );
1074
+
1075
+			if ( empty($exists) ) {
1076 1076
 				FrmAppHelper::save_json_post( $new_notification );
1077
-                $imported['imported']['actions']++;
1078
-            }
1079
-            unset($new_notification);
1080
-        }
1081
-    }
1082
-
1083
-    private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
1084
-        if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
1085
-            // add old settings into notification array
1077
+				$imported['imported']['actions']++;
1078
+			}
1079
+			unset($new_notification);
1080
+		}
1081
+	}
1082
+
1083
+	private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
1084
+		if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
1085
+			// add old settings into notification array
1086 1086
 			$form_options['notification'] = array( 0 => $form_options );
1087
-        } else if ( isset( $form_options['notification']['email_to'] ) ) {
1088
-            // make sure it's in the correct format
1087
+		} else if ( isset( $form_options['notification']['email_to'] ) ) {
1088
+			// make sure it's in the correct format
1089 1089
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
1090
-        }
1090
+		}
1091 1091
 
1092
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1093
-            foreach ( $form_options['notification'] as $email_key => $notification ) {
1092
+		if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1093
+			foreach ( $form_options['notification'] as $email_key => $notification ) {
1094 1094
 
1095
-                $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
1095
+				$atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
1096 1096
 
1097
-                // Format the email data
1098
-                self::format_email_data( $atts, $notification );
1097
+				// Format the email data
1098
+				self::format_email_data( $atts, $notification );
1099 1099
 
1100 1100
 				if ( isset( $notification['twilio'] ) && $notification['twilio'] ) {
1101 1101
 					do_action( 'frm_create_twilio_action', $atts, $notification );
1102 1102
 				}
1103 1103
 
1104
-                // Setup the new notification
1105
-                $new_notification = array();
1106
-                self::setup_new_notification( $new_notification, $notification, $atts );
1104
+				// Setup the new notification
1105
+				$new_notification = array();
1106
+				self::setup_new_notification( $new_notification, $notification, $atts );
1107 1107
 
1108
-                $notifications[] = $new_notification;
1109
-            }
1110
-        }
1111
-    }
1108
+				$notifications[] = $new_notification;
1109
+			}
1110
+		}
1111
+	}
1112 1112
 
1113
-    private static function format_email_data( &$atts, $notification ) {
1114
-        // Format email_to
1115
-        self::format_email_to_data( $atts, $notification );
1113
+	private static function format_email_data( &$atts, $notification ) {
1114
+		// Format email_to
1115
+		self::format_email_to_data( $atts, $notification );
1116 1116
 
1117
-        // Format the reply to email and name
1118
-        $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
1119
-        foreach ( $reply_fields as $f => $val ) {
1117
+		// Format the reply to email and name
1118
+		$reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
1119
+		foreach ( $reply_fields as $f => $val ) {
1120 1120
 			if ( isset( $notification[ $f ] ) ) {
1121 1121
 				$atts[ $f ] = $notification[ $f ];
1122 1122
 				if ( 'custom' == $notification[ $f ] ) {
1123 1123
 					$atts[ $f ] = $notification[ 'cust_' . $f ];
1124 1124
 				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
1125 1125
 					$atts[ $f ] = '[' . $atts[ $f ] . ']';
1126
-                }
1127
-            }
1128
-            unset( $f, $val );
1129
-        }
1126
+				}
1127
+			}
1128
+			unset( $f, $val );
1129
+		}
1130 1130
 
1131
-        // Format event
1131
+		// Format event
1132 1132
 		$atts['event'] = array( 'create' );
1133
-        if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1134
-            $atts['event'][] = 'update';
1135
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1133
+		if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1134
+			$atts['event'][] = 'update';
1135
+		} else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1136 1136
 			$atts['event'] = array( 'update' );
1137
-        }
1138
-    }
1137
+		}
1138
+	}
1139 1139
 
1140
-    private static function format_email_to_data( &$atts, $notification ) {
1141
-        if ( isset( $notification['email_to'] ) ) {
1140
+	private static function format_email_to_data( &$atts, $notification ) {
1141
+		if ( isset( $notification['email_to'] ) ) {
1142 1142
 			$atts['email_to'] = preg_split( '/ (,|;) /', $notification['email_to'] );
1143
-        } else {
1144
-            $atts['email_to'] = array();
1145
-        }
1143
+		} else {
1144
+			$atts['email_to'] = array();
1145
+		}
1146 1146
 
1147
-        if ( isset( $notification['also_email_to'] ) ) {
1148
-            $email_fields = (array) $notification['also_email_to'];
1149
-            $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1150
-            unset( $email_fields );
1151
-        }
1147
+		if ( isset( $notification['also_email_to'] ) ) {
1148
+			$email_fields = (array) $notification['also_email_to'];
1149
+			$atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1150
+			unset( $email_fields );
1151
+		}
1152 1152
 
1153
-        foreach ( $atts['email_to'] as $key => $email_field ) {
1153
+		foreach ( $atts['email_to'] as $key => $email_field ) {
1154 1154
 
1155
-            if ( is_numeric( $email_field ) ) {
1155
+			if ( is_numeric( $email_field ) ) {
1156 1156
 				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1157
-            }
1157
+			}
1158 1158
 
1159
-            if ( strpos( $email_field, '|') ) {
1160
-                $email_opt = explode( '|', $email_field );
1161
-                if ( isset( $email_opt[0] ) ) {
1159
+			if ( strpos( $email_field, '|') ) {
1160
+				$email_opt = explode( '|', $email_field );
1161
+				if ( isset( $email_opt[0] ) ) {
1162 1162
 					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1163
-                }
1164
-                unset( $email_opt );
1165
-            }
1166
-        }
1167
-        $atts['email_to'] = implode(', ', $atts['email_to']);
1168
-    }
1169
-
1170
-    private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1171
-        // Set up new notification
1172
-        $new_notification = array(
1173
-            'post_content'  => array(
1174
-                'email_to'      => $atts['email_to'],
1175
-                'event'         => $atts['event'],
1176
-            ),
1163
+				}
1164
+				unset( $email_opt );
1165
+			}
1166
+		}
1167
+		$atts['email_to'] = implode(', ', $atts['email_to']);
1168
+	}
1169
+
1170
+	private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1171
+		// Set up new notification
1172
+		$new_notification = array(
1173
+			'post_content'  => array(
1174
+				'email_to'      => $atts['email_to'],
1175
+				'event'         => $atts['event'],
1176
+			),
1177 1177
 			'post_name'         => $atts['form_id'] . '_email_' . $atts['email_key'],
1178
-        );
1178
+		);
1179 1179
 
1180
-        // Add more fields to the new notification
1181
-        $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1182
-        foreach ( $add_fields as $add_field ) {
1180
+		// Add more fields to the new notification
1181
+		$add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1182
+		foreach ( $add_fields as $add_field ) {
1183 1183
 			if ( isset( $notification[ $add_field ] ) ) {
1184 1184
 				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1185
-            } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1185
+			} else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1186 1186
 				$new_notification['post_content'][ $add_field ] = 0;
1187
-            } else {
1187
+			} else {
1188 1188
 				$new_notification['post_content'][ $add_field ] = '';
1189
-            }
1190
-            unset( $add_field );
1191
-        }
1189
+			}
1190
+			unset( $add_field );
1191
+		}
1192 1192
 
1193 1193
 		// Set reply to
1194 1194
 		$new_notification['post_content']['reply_to'] = $atts['reply_to'];
1195 1195
 
1196
-        // Set from
1196
+		// Set from
1197 1197
 		if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) {
1198 1198
 			$new_notification['post_content']['from'] = ( empty( $atts['reply_to_name'] ) ? '[sitename]' : $atts['reply_to_name'] ) . ' <' . ( empty( $atts['reply_to'] ) ? '[admin_email]' : $atts['reply_to'] ) . '>';
1199
-        }
1200
-    }
1199
+		}
1200
+	}
1201 1201
 
1202 1202
 	/**
1203
-	* Switch field IDs in pre-2.0 email conditional logic
1204
-	*
1205
-	* @param $post_content array, pass by reference
1206
-	*/
1203
+	 * Switch field IDs in pre-2.0 email conditional logic
1204
+	 *
1205
+	 * @param $post_content array, pass by reference
1206
+	 */
1207 1207
 	private static function switch_email_contition_field_ids( &$post_content ) {
1208 1208
 		// Switch field IDs in conditional logic
1209 1209
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
@@ -1216,36 +1216,36 @@  discard block
 block discarded – undo
1216 1216
 		}
1217 1217
 	}
1218 1218
 
1219
-    private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1220
-        if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1221
-            // migrate autoresponder
1222
-
1223
-            $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1224
-            if ( strpos($email_field, '|') ) {
1225
-                // data from entries field
1226
-                $email_field = explode('|', $email_field);
1227
-                if ( isset($email_field[1]) ) {
1228
-                    $email_field = $email_field[1];
1229
-                }
1230
-            }
1231
-            if ( is_numeric($email_field) && ! empty($email_field) ) {
1219
+	private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1220
+		if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1221
+			// migrate autoresponder
1222
+
1223
+			$email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1224
+			if ( strpos($email_field, '|') ) {
1225
+				// data from entries field
1226
+				$email_field = explode('|', $email_field);
1227
+				if ( isset($email_field[1]) ) {
1228
+					$email_field = $email_field[1];
1229
+				}
1230
+			}
1231
+			if ( is_numeric($email_field) && ! empty($email_field) ) {
1232 1232
 				$email_field = '[' . $email_field . ']';
1233
-            }
1234
-
1235
-            $notification = $form_options;
1236
-            $new_notification2 = array(
1237
-                'post_content'  => array(
1238
-                    'email_message' => $notification['ar_email_message'],
1239
-                    'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1240
-                    'email_to'      => $email_field,
1241
-                    'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1242
-                    'inc_user_info' => 0,
1243
-                ),
1233
+			}
1234
+
1235
+			$notification = $form_options;
1236
+			$new_notification2 = array(
1237
+				'post_content'  => array(
1238
+					'email_message' => $notification['ar_email_message'],
1239
+					'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1240
+					'email_to'      => $email_field,
1241
+					'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1242
+					'inc_user_info' => 0,
1243
+				),
1244 1244
 				'post_name'     => $form_id . '_email_' . count( $notifications ),
1245
-            );
1245
+			);
1246 1246
 
1247
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1248
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1247
+			$reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1248
+			$reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1249 1249
 
1250 1250
 			if ( ! empty( $reply_to ) ) {
1251 1251
 				$new_notification2['post_content']['reply_to'] = $reply_to;
@@ -1255,9 +1255,9 @@  discard block
 block discarded – undo
1255 1255
 				$new_notification2['post_content']['from'] = ( empty( $reply_to_name ) ? '[sitename]' : $reply_to_name ) . ' <' . ( empty( $reply_to ) ? '[admin_email]' : $reply_to ) . '>';
1256 1256
 			}
1257 1257
 
1258
-            $notifications[] = $new_notification2;
1259
-            unset( $new_notification2 );
1260
-        }
1261
-    }
1258
+			$notifications[] = $new_notification2;
1259
+			unset( $new_notification2 );
1260
+		}
1261
+	}
1262 1262
 }
1263 1263
 
Please login to merge, or discard this patch.
Spacing   +149 added lines, -149 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 );
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
 			} else {
145 145
 				$form_id = FrmForm::create( $form );
146 146
 		        if ( $form_id ) {
147
-		            $imported['imported']['forms']++;
147
+		            $imported['imported']['forms'] ++;
148 148
 		            // Keep track of whether this specific form was updated or not
149
-					$imported['form_status'][ $form_id ] = 'imported';
149
+					$imported['form_status'][$form_id] = 'imported';
150 150
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
151 151
 		        }
152 152
 			}
@@ -158,14 +158,14 @@  discard block
 block discarded – undo
158 158
 		    // Update field ids/keys to new ones
159 159
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
160 160
 
161
-			$imported['forms'][ (int) $item->id ] = $form_id;
161
+			$imported['forms'][(int) $item->id] = $form_id;
162 162
 
163 163
             // Send pre 2.0 form options through function that creates actions
164 164
             self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true );
165 165
 
166 166
 			do_action( 'frm_after_import_form', $form_id, $form );
167 167
 
168
-		    unset($form, $item);
168
+		    unset( $form, $item );
169 169
 		}
170 170
 
171 171
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
@@ -207,18 +207,18 @@  discard block
 block discarded – undo
207 207
 	private static function update_form( $this_form, $form, &$imported ) {
208 208
 		$form_id = $this_form->id;
209 209
 		FrmForm::update( $form_id, $form );
210
-		$imported['updated']['forms']++;
210
+		$imported['updated']['forms'] ++;
211 211
 		// Keep track of whether this specific form was updated or not
212
-		$imported['form_status'][ $form_id ] = 'updated';
212
+		$imported['form_status'][$form_id] = 'updated';
213 213
 	}
214 214
 
215 215
 	private static function get_form_fields( $form_id ) {
216 216
 		$form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' );
217 217
 		$old_fields = array();
218 218
 		foreach ( $form_fields as $f ) {
219
-			$old_fields[ $f->id ] = $f;
220
-			$old_fields[ $f->field_key ] = $f->id;
221
-			unset($f);
219
+			$old_fields[$f->id] = $f;
220
+			$old_fields[$f->field_key] = $f->id;
221
+			unset( $f );
222 222
 		}
223 223
 		$form_fields = $old_fields;
224 224
 		return $form_fields;
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 		$regular_forms = array();
250 250
 
251 251
 		foreach ( $forms as $form ) {
252
-			$parent_form_id = isset( $form->parent_form_id) ? (int) $form->parent_form_id : 0;
252
+			$parent_form_id = isset( $form->parent_form_id ) ? (int) $form->parent_form_id : 0;
253 253
 
254 254
 			if ( $parent_form_id ) {
255 255
 				$child_forms[] = $form;
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	*/
272 272
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
273 273
 		if ( $parent_form_id ) {
274
-			$child_forms[ $form_id ] = $parent_form_id;
274
+			$child_forms[$form_id] = $parent_form_id;
275 275
 		}
276 276
 	}
277 277
 
@@ -286,9 +286,9 @@  discard block
 block discarded – undo
286 286
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
287 287
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
288 288
 
289
-			if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) {
289
+			if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) {
290 290
 				// Update all children with this old parent_form_id
291
-				$new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ];
291
+				$new_parent_form_id = (int) $imported_forms[$old_parent_form_id];
292 292
 
293 293
 				FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) );
294 294
 			}
@@ -307,15 +307,15 @@  discard block
 block discarded – undo
307 307
 		foreach ( $xml_fields as $field ) {
308 308
 			$f = self::fill_field( $field, $form_id );
309 309
 
310
-		    if ( is_array($f['default_value']) && in_array($f['type'], array(
310
+		    if ( is_array( $f['default_value'] ) && in_array( $f['type'], array(
311 311
 		        'text', 'email', 'url', 'textarea',
312
-		        'number','phone', 'date',
312
+		        'number', 'phone', 'date',
313 313
 		        'hidden', 'password', 'tag', 'image',
314
-		    )) ) {
315
-		        if ( count($f['default_value']) === 1 ) {
314
+		    ) ) ) {
315
+		        if ( count( $f['default_value'] ) === 1 ) {
316 316
 					$f['default_value'] = '[' . reset( $f['default_value'] ) . ']';
317 317
 		        } else {
318
-		            $f['default_value'] = reset($f['default_value']);
318
+		            $f['default_value'] = reset( $f['default_value'] );
319 319
 		        }
320 320
 		    }
321 321
 
@@ -323,27 +323,27 @@  discard block
 block discarded – undo
323 323
 			self::maybe_update_form_select( $f, $imported );
324 324
 			self::maybe_update_get_values_form_setting( $imported, $f );
325 325
 
326
-			if ( ! empty($this_form) ) {
326
+			if ( ! empty( $this_form ) ) {
327 327
 				// check for field to edit by field id
328
-				if ( isset( $form_fields[ $f['id'] ] ) ) {
328
+				if ( isset( $form_fields[$f['id']] ) ) {
329 329
 					FrmField::update( $f['id'], $f );
330
-					$imported['updated']['fields']++;
330
+					$imported['updated']['fields'] ++;
331 331
 
332
-					unset( $form_fields[ $f['id'] ] );
332
+					unset( $form_fields[$f['id']] );
333 333
 
334 334
 					//unset old field key
335
-					if ( isset( $form_fields[ $f['field_key'] ] ) ) {
336
-						unset( $form_fields[ $f['field_key'] ] );
335
+					if ( isset( $form_fields[$f['field_key']] ) ) {
336
+						unset( $form_fields[$f['field_key']] );
337 337
 					}
338
-				} else if ( isset( $form_fields[ $f['field_key'] ] ) ) {
338
+				} else if ( isset( $form_fields[$f['field_key']] ) ) {
339 339
 					// check for field to edit by field key
340
-					unset($f['id']);
340
+					unset( $f['id'] );
341 341
 
342
-					FrmField::update( $form_fields[ $f['field_key'] ], $f );
343
-					$imported['updated']['fields']++;
342
+					FrmField::update( $form_fields[$f['field_key']], $f );
343
+					$imported['updated']['fields'] ++;
344 344
 
345
-					unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id
346
-					unset( $form_fields[ $f['field_key'] ] ); //unset old field key
345
+					unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id
346
+					unset( $form_fields[$f['field_key']] ); //unset old field key
347 347
 				} else {
348 348
 					// if no matching field id or key in this form, create the field
349 349
 					self::create_imported_field( $f, $imported );
@@ -362,11 +362,11 @@  discard block
 block discarded – undo
362 362
 			'name'          => (string) $field->name,
363 363
 			'description'   => (string) $field->description,
364 364
 			'type'          => (string) $field->type,
365
-			'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
365
+			'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value ),
366 366
 			'field_order'   => (int) $field->field_order,
367 367
 			'form_id'       => (int) $form_id,
368 368
 			'required'      => (int) $field->required,
369
-			'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
369
+			'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options ),
370 370
 			'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
371 371
 		);
372 372
 	}
@@ -410,8 +410,8 @@  discard block
 block discarded – undo
410 410
 		if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) {
411 411
 			if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) {
412 412
 				$form_select = $f['field_options']['form_select'];
413
-				if ( isset( $imported['forms'][ $form_select ] ) ) {
414
-					$f['field_options']['form_select'] = $imported['forms'][ $form_select ];
413
+				if ( isset( $imported['forms'][$form_select] ) ) {
414
+					$f['field_options']['form_select'] = $imported['forms'][$form_select];
415 415
 				}
416 416
 			}
417 417
 		}
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 
432 432
 		if ( FrmField::is_option_true_in_array( $f['field_options'], 'get_values_form' ) ) {
433 433
 			$old_form = $f['field_options']['get_values_form'];
434
-			if ( isset( $imported['forms'][ $old_form ] ) ) {
435
-				$f['field_options']['get_values_form'] = $imported['forms'][ $old_form ];
434
+			if ( isset( $imported['forms'][$old_form] ) ) {
435
+				$f['field_options']['get_values_form'] = $imported['forms'][$old_form];
436 436
 			}
437 437
 		}
438 438
 	}
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 	private static function create_imported_field( $f, &$imported ) {
448 448
 		$new_id = FrmField::create( $f );
449 449
 		if ( $new_id != false ) {
450
-			$imported['imported']['fields']++;
450
+			$imported['imported']['fields'] ++;
451 451
 			do_action( 'frm_after_field_is_imported', $f, $new_id );
452 452
 		}
453 453
 	}
@@ -546,9 +546,9 @@  discard block
 block discarded – undo
546 546
 			);
547 547
 
548 548
             $old_id = $post['post_id'];
549
-            self::populate_post($post, $item, $imported);
549
+            self::populate_post( $post, $item, $imported );
550 550
 
551
-			unset($item);
551
+			unset( $item );
552 552
 
553 553
 			$post_id = false;
554 554
             if ( $post['post_type'] == $form_action_type ) {
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 				if ( $action_control && is_object( $action_control ) ) {
557 557
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
558 558
 				}
559
-                unset($action_control);
559
+                unset( $action_control );
560 560
             } else if ( $post['post_type'] == 'frm_styles' ) {
561 561
                 // Properly encode post content before inserting the post
562 562
                 $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
@@ -571,24 +571,24 @@  discard block
 block discarded – undo
571 571
                 $post_id = wp_insert_post( $post );
572 572
             }
573 573
 
574
-            if ( ! is_numeric($post_id) ) {
574
+            if ( ! is_numeric( $post_id ) ) {
575 575
                 continue;
576 576
             }
577 577
 
578
-            self::update_postmeta($post, $post_id);
578
+            self::update_postmeta( $post, $post_id );
579 579
 
580 580
             $this_type = 'posts';
581
-			if ( isset( $post_types[ $post['post_type'] ] ) ) {
582
-				$this_type = $post_types[ $post['post_type'] ];
581
+			if ( isset( $post_types[$post['post_type']] ) ) {
582
+				$this_type = $post_types[$post['post_type']];
583 583
             }
584 584
 
585
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
586
-                $imported['updated'][ $this_type ]++;
585
+            if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) {
586
+                $imported['updated'][$this_type] ++;
587 587
             } else {
588
-                $imported['imported'][ $this_type ]++;
588
+                $imported['imported'][$this_type] ++;
589 589
             }
590 590
 
591
-			$imported['posts'][ (int) $old_id ] = $post_id;
591
+			$imported['posts'][(int) $old_id] = $post_id;
592 592
 
593 593
 			do_action( 'frm_after_import_view', $post_id, $post );
594 594
 
@@ -601,13 +601,13 @@  discard block
 block discarded – undo
601 601
     }
602 602
 
603 603
     private static function populate_post( &$post, $item, $imported ) {
604
-		if ( isset($item->attachment_url) ) {
604
+		if ( isset( $item->attachment_url ) ) {
605 605
 			$post['attachment_url'] = (string) $item->attachment_url;
606 606
 		}
607 607
 
608
-		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
608
+		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) {
609 609
 		    // update to new form id
610
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
610
+		    $post['menu_order'] = $imported['forms'][(int) $post['menu_order']];
611 611
 		}
612 612
 
613 613
 		// Don't allow default styles to take over a site's default style
@@ -616,13 +616,13 @@  discard block
 block discarded – undo
616 616
 		}
617 617
 
618 618
 		foreach ( $item->postmeta as $meta ) {
619
-		    self::populate_postmeta($post, $meta, $imported);
620
-			unset($meta);
619
+		    self::populate_postmeta( $post, $meta, $imported );
620
+			unset( $meta );
621 621
 		}
622 622
 
623
-        self::populate_taxonomies($post, $item);
623
+        self::populate_taxonomies( $post, $item );
624 624
 
625
-        self::maybe_editing_post($post);
625
+        self::maybe_editing_post( $post );
626 626
     }
627 627
 
628 628
     private static function populate_postmeta( &$post, $meta, $imported ) {
@@ -634,27 +634,27 @@  discard block
 block discarded – undo
634 634
 		);
635 635
 
636 636
 		//switch old form and field ids to new ones
637
-		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
638
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
637
+		if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) {
638
+		    $m['value'] = $imported['forms'][(int) $m['value']];
639 639
 		} else {
640
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
640
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
641 641
 
642
-		    if ( ! empty($frm_duplicate_ids) ) {
642
+		    if ( ! empty( $frm_duplicate_ids ) ) {
643 643
 
644 644
 		        if ( $m['key'] == 'frm_dyncontent' ) {
645
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
645
+		            $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] );
646 646
     		    } else if ( $m['key'] == 'frm_options' ) {
647 647
 
648 648
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
649
-						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
650
-							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
649
+						if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) {
650
+							$m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]];
651 651
     		            }
652 652
     		        }
653 653
 
654 654
                     $check_dup_array = array();
655 655
     		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
656
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
657
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
656
+    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) {
657
+    		                $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']];
658 658
     		            } else if ( is_array( $m['value']['order_by'] ) ) {
659 659
                             $check_dup_array[] = 'order_by';
660 660
     		            }
@@ -665,22 +665,22 @@  discard block
 block discarded – undo
665 665
     		        }
666 666
 
667 667
                     foreach ( $check_dup_array as $check_k ) {
668
-						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
669
-							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
670
-								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
668
+						foreach ( (array) $m['value'][$check_k] as $mk => $mv ) {
669
+							if ( isset( $frm_duplicate_ids[$mv] ) ) {
670
+								$m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv];
671 671
 		                    }
672
-		                    unset($mk, $mv);
672
+		                    unset( $mk, $mv );
673 673
 		                }
674 674
                     }
675 675
     		    }
676 676
 		    }
677 677
 		}
678 678
 
679
-		if ( ! is_array($m['value']) ) {
680
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
679
+		if ( ! is_array( $m['value'] ) ) {
680
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
681 681
 		}
682 682
 
683
-		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
683
+		$post['postmeta'][(string) $meta->meta_key] = $m['value'];
684 684
     }
685 685
 
686 686
     /**
@@ -696,23 +696,23 @@  discard block
 block discarded – undo
696 696
             }
697 697
 
698 698
 		    $taxonomy = (string) $att['domain'];
699
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
699
+		    if ( is_taxonomy_hierarchical( $taxonomy ) ) {
700 700
 		        $name = (string) $att['nicename'];
701
-		        $h_term = get_term_by('slug', $name, $taxonomy);
701
+		        $h_term = get_term_by( 'slug', $name, $taxonomy );
702 702
 		        if ( $h_term ) {
703 703
 		            $name = $h_term->term_id;
704 704
 		        }
705
-		        unset($h_term);
705
+		        unset( $h_term );
706 706
 		    } else {
707 707
 		        $name = (string) $c;
708 708
 		    }
709 709
 
710
-			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
711
-				$post['tax_input'][ $taxonomy ] = array();
710
+			if ( ! isset( $post['tax_input'][$taxonomy] ) ) {
711
+				$post['tax_input'][$taxonomy] = array();
712 712
 			}
713 713
 
714
-			$post['tax_input'][ $taxonomy ][] = $name;
715
-		    unset($name);
714
+			$post['tax_input'][$taxonomy][] = $name;
715
+		    unset( $name );
716 716
 		}
717 717
     }
718 718
 
@@ -729,29 +729,29 @@  discard block
 block discarded – undo
729 729
 
730 730
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
731 731
 		    $match_by['include'] = $post['post_id'];
732
-		    unset($match_by['name']);
732
+		    unset( $match_by['name'] );
733 733
 		}
734 734
 
735
-		$editing = get_posts($match_by);
735
+		$editing = get_posts( $match_by );
736 736
 
737
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
737
+        if ( ! empty( $editing ) && current( $editing )->post_date == $post['post_date'] ) {
738 738
             // set the id of the post to edit
739
-            $post['ID'] = current($editing)->ID;
739
+            $post['ID'] = current( $editing )->ID;
740 740
         }
741 741
     }
742 742
 
743 743
     private static function update_postmeta( &$post, $post_id ) {
744 744
         foreach ( $post['postmeta'] as $k => $v ) {
745 745
             if ( '_edit_last' == $k ) {
746
-                $v = FrmAppHelper::get_user_id_param($v);
746
+                $v = FrmAppHelper::get_user_id_param( $v );
747 747
             } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
748 748
                 //change the attachment ID
749
-                $v = FrmProXMLHelper::get_file_id($v);
749
+                $v = FrmProXMLHelper::get_file_id( $v );
750 750
             }
751 751
 
752
-            update_post_meta($post_id, $k, $v);
752
+            update_post_meta( $post_id, $k, $v );
753 753
 
754
-            unset($k, $v);
754
+            unset( $k, $v );
755 755
         }
756 756
     }
757 757
 
@@ -790,13 +790,13 @@  discard block
 block discarded – undo
790 790
      * @param string $message
791 791
      */
792 792
 	public static function parse_message( $result, &$message, &$errors ) {
793
-        if ( is_wp_error($result) ) {
793
+        if ( is_wp_error( $result ) ) {
794 794
             $errors[] = $result->get_error_message();
795 795
         } else if ( ! $result ) {
796 796
             return;
797 797
         }
798 798
 
799
-        if ( ! is_array($result) ) {
799
+        if ( ! is_array( $result ) ) {
800 800
             $message = is_string( $result ) ? $result : print_r( $result, 1 );
801 801
             return;
802 802
         }
@@ -808,20 +808,20 @@  discard block
 block discarded – undo
808 808
 
809 809
         $message = '<ul>';
810 810
         foreach ( $result as $type => $results ) {
811
-			if ( ! isset( $t_strings[ $type ] ) ) {
811
+			if ( ! isset( $t_strings[$type] ) ) {
812 812
                 // only print imported and updated
813 813
                 continue;
814 814
             }
815 815
 
816 816
             $s_message = array();
817 817
             foreach ( $results as $k => $m ) {
818
-                self::item_count_message($m, $k, $s_message);
819
-                unset($k, $m);
818
+                self::item_count_message( $m, $k, $s_message );
819
+                unset( $k, $m );
820 820
             }
821 821
 
822
-            if ( ! empty($s_message) ) {
823
-				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
824
-                $message .= implode(', ', $s_message);
822
+            if ( ! empty( $s_message ) ) {
823
+				$message .= '<li><strong>' . $t_strings[$type] . ':</strong> ';
824
+                $message .= implode( ', ', $s_message );
825 825
                 $message .= '</li>';
826 826
             }
827 827
         }
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
             'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
851 851
         );
852 852
 
853
-		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
853
+		$s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type );
854 854
     }
855 855
 
856 856
 	/**
@@ -882,14 +882,14 @@  discard block
 block discarded – undo
882 882
 	}
883 883
 
884 884
 	public static function cdata( $str ) {
885
-	    $str = maybe_unserialize($str);
886
-	    if ( is_array($str) ) {
887
-	        $str = json_encode($str);
885
+	    $str = maybe_unserialize( $str );
886
+	    if ( is_array( $str ) ) {
887
+	        $str = json_encode( $str );
888 888
 		} else if ( seems_utf8( $str ) == false ) {
889 889
 			$str = utf8_encode( $str );
890 890
 		}
891 891
 
892
-        if ( is_numeric($str) ) {
892
+        if ( is_numeric( $str ) ) {
893 893
             return $str;
894 894
         }
895 895
 
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
     * @param string $post_type
935 935
     */
936 936
     private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
937
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
937
+        if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) {
938 938
             return;
939 939
         }
940 940
 
@@ -955,10 +955,10 @@  discard block
 block discarded – undo
955 955
         );
956 956
 
957 957
         foreach ( $post_settings as $post_setting ) {
958
-			if ( isset( $form_options[ $post_setting ] ) ) {
959
-				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
958
+			if ( isset( $form_options[$post_setting] ) ) {
959
+				$new_action['post_content'][$post_setting] = $form_options[$post_setting];
960 960
             }
961
-            unset($post_setting);
961
+            unset( $post_setting );
962 962
         }
963 963
 
964 964
 		$new_action['event'] = array( 'create', 'update' );
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
 
973 973
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
974 974
         }
975
-        $new_action['post_content'] = json_encode($new_action['post_content']);
975
+        $new_action['post_content'] = json_encode( $new_action['post_content'] );
976 976
 
977 977
         $exists = get_posts( array(
978 978
             'name'          => $new_action['post_name'],
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
         if ( ! $exists ) {
985 985
 			// this isn't an email, but we need to use a class that will always be included
986 986
 			FrmAppHelper::save_json_post( $new_action );
987
-            $imported['imported']['actions']++;
987
+            $imported['imported']['actions'] ++;
988 988
         }
989 989
     }
990 990
 
@@ -1016,11 +1016,11 @@  discard block
 block discarded – undo
1016 1016
         foreach ( $post_content as $key => $setting ) {
1017 1017
             if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
1018 1018
                 // Replace old IDs with new IDs
1019
-				$post_content[ $key ] = str_replace( $old, $new, $setting );
1019
+				$post_content[$key] = str_replace( $old, $new, $setting );
1020 1020
             } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
1021 1021
                 foreach ( $setting as $k => $val ) {
1022 1022
                     // Replace old IDs with new IDs
1023
-					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
1023
+					$post_content[$key][$k] = str_replace( $old, $new, $val );
1024 1024
                 }
1025 1025
             }
1026 1026
             unset( $key, $setting );
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
         foreach ( $notifications as $new_notification ) {
1051 1051
             $new_notification['post_type']      = $post_type;
1052 1052
             $new_notification['post_excerpt']   = 'email';
1053
-			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
1053
+			$new_notification['post_title'] = __( 'Email Notification', 'formidable' );
1054 1054
             $new_notification['menu_order']     = $form_id;
1055 1055
             $new_notification['post_status']    = 'publish';
1056 1056
 
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
 				// Switch all other field IDs in email
1064 1064
                 $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1065 1065
             }
1066
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1066
+            $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1067 1067
 
1068 1068
             $exists = get_posts( array(
1069 1069
                 'name'          => $new_notification['post_name'],
@@ -1072,11 +1072,11 @@  discard block
 block discarded – undo
1072 1072
                 'numberposts'   => 1,
1073 1073
             ) );
1074 1074
 
1075
-            if ( empty($exists) ) {
1075
+            if ( empty( $exists ) ) {
1076 1076
 				FrmAppHelper::save_json_post( $new_notification );
1077
-                $imported['imported']['actions']++;
1077
+                $imported['imported']['actions'] ++;
1078 1078
             }
1079
-            unset($new_notification);
1079
+            unset( $new_notification );
1080 1080
         }
1081 1081
     }
1082 1082
 
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
1090 1090
         }
1091 1091
 
1092
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1092
+        if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) {
1093 1093
             foreach ( $form_options['notification'] as $email_key => $notification ) {
1094 1094
 
1095 1095
                 $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
@@ -1117,12 +1117,12 @@  discard block
 block discarded – undo
1117 1117
         // Format the reply to email and name
1118 1118
         $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
1119 1119
         foreach ( $reply_fields as $f => $val ) {
1120
-			if ( isset( $notification[ $f ] ) ) {
1121
-				$atts[ $f ] = $notification[ $f ];
1122
-				if ( 'custom' == $notification[ $f ] ) {
1123
-					$atts[ $f ] = $notification[ 'cust_' . $f ];
1124
-				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
1125
-					$atts[ $f ] = '[' . $atts[ $f ] . ']';
1120
+			if ( isset( $notification[$f] ) ) {
1121
+				$atts[$f] = $notification[$f];
1122
+				if ( 'custom' == $notification[$f] ) {
1123
+					$atts[$f] = $notification['cust_' . $f];
1124
+				} else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) {
1125
+					$atts[$f] = '[' . $atts[$f] . ']';
1126 1126
                 }
1127 1127
             }
1128 1128
             unset( $f, $val );
@@ -1132,7 +1132,7 @@  discard block
 block discarded – undo
1132 1132
 		$atts['event'] = array( 'create' );
1133 1133
         if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1134 1134
             $atts['event'][] = 'update';
1135
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1135
+        } else if ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) {
1136 1136
 			$atts['event'] = array( 'update' );
1137 1137
         }
1138 1138
     }
@@ -1153,18 +1153,18 @@  discard block
 block discarded – undo
1153 1153
         foreach ( $atts['email_to'] as $key => $email_field ) {
1154 1154
 
1155 1155
             if ( is_numeric( $email_field ) ) {
1156
-				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1156
+				$atts['email_to'][$key] = '[' . $email_field . ']';
1157 1157
             }
1158 1158
 
1159
-            if ( strpos( $email_field, '|') ) {
1159
+            if ( strpos( $email_field, '|' ) ) {
1160 1160
                 $email_opt = explode( '|', $email_field );
1161 1161
                 if ( isset( $email_opt[0] ) ) {
1162
-					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1162
+					$atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1163 1163
                 }
1164 1164
                 unset( $email_opt );
1165 1165
             }
1166 1166
         }
1167
-        $atts['email_to'] = implode(', ', $atts['email_to']);
1167
+        $atts['email_to'] = implode( ', ', $atts['email_to'] );
1168 1168
     }
1169 1169
 
1170 1170
     private static function setup_new_notification( &$new_notification, $notification, $atts ) {
@@ -1180,12 +1180,12 @@  discard block
 block discarded – undo
1180 1180
         // Add more fields to the new notification
1181 1181
         $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1182 1182
         foreach ( $add_fields as $add_field ) {
1183
-			if ( isset( $notification[ $add_field ] ) ) {
1184
-				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1183
+			if ( isset( $notification[$add_field] ) ) {
1184
+				$new_notification['post_content'][$add_field] = $notification[$add_field];
1185 1185
             } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1186
-				$new_notification['post_content'][ $add_field ] = 0;
1186
+				$new_notification['post_content'][$add_field] = 0;
1187 1187
             } else {
1188
-				$new_notification['post_content'][ $add_field ] = '';
1188
+				$new_notification['post_content'][$add_field] = '';
1189 1189
             }
1190 1190
             unset( $add_field );
1191 1191
         }
@@ -1209,26 +1209,26 @@  discard block
 block discarded – undo
1209 1209
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
1210 1210
 			foreach ( $post_content['conditions'] as $email_key => $val ) {
1211 1211
 				if ( is_numeric( $email_key ) ) {
1212
-					$post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1212
+					$post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1213 1213
 				}
1214
-				unset( $email_key, $val);
1214
+				unset( $email_key, $val );
1215 1215
 			}
1216 1216
 		}
1217 1217
 	}
1218 1218
 
1219 1219
     private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1220
-        if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1220
+        if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) {
1221 1221
             // migrate autoresponder
1222 1222
 
1223
-            $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1224
-            if ( strpos($email_field, '|') ) {
1223
+            $email_field = isset( $form_options['ar_email_to'] ) ? $form_options['ar_email_to'] : 0;
1224
+            if ( strpos( $email_field, '|' ) ) {
1225 1225
                 // data from entries field
1226
-                $email_field = explode('|', $email_field);
1227
-                if ( isset($email_field[1]) ) {
1226
+                $email_field = explode( '|', $email_field );
1227
+                if ( isset( $email_field[1] ) ) {
1228 1228
                     $email_field = $email_field[1];
1229 1229
                 }
1230 1230
             }
1231
-            if ( is_numeric($email_field) && ! empty($email_field) ) {
1231
+            if ( is_numeric( $email_field ) && ! empty( $email_field ) ) {
1232 1232
 				$email_field = '[' . $email_field . ']';
1233 1233
             }
1234 1234
 
@@ -1236,16 +1236,16 @@  discard block
 block discarded – undo
1236 1236
             $new_notification2 = array(
1237 1237
                 'post_content'  => array(
1238 1238
                     'email_message' => $notification['ar_email_message'],
1239
-                    'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1239
+                    'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '',
1240 1240
                     'email_to'      => $email_field,
1241
-                    'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1241
+                    'plain_text'    => isset( $notification['ar_plain_text'] ) ? $notification['ar_plain_text'] : 0,
1242 1242
                     'inc_user_info' => 0,
1243 1243
                 ),
1244 1244
 				'post_name'     => $form_id . '_email_' . count( $notifications ),
1245 1245
             );
1246 1246
 
1247
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1248
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1247
+            $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : '';
1248
+            $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : '';
1249 1249
 
1250 1250
 			if ( ! empty( $reply_to ) ) {
1251 1251
 				$new_notification2['post_content']['reply_to'] = $reply_to;
Please login to merge, or discard this patch.
classes/views/frm-entries/new.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1
-<div class="frm_forms <?php echo FrmFormsHelper::get_form_style_class($values); ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container" <?php echo apply_filters( 'frm_form_div_attributes', '', $form ); ?>>
1
+<div class="frm_forms <?php echo FrmFormsHelper::get_form_style_class( $values ); ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container" <?php echo apply_filters( 'frm_form_div_attributes', '', $form ); ?>>
2 2
 <?php
3 3
 if ( ! isset( $include_form_tag ) || $include_form_tag ) {
4 4
 ?>
5
-<form enctype="<?php echo esc_attr( apply_filters( 'frm_form_enctype', 'multipart/form-data', $form ) ) ?>" method="post" class="frm-show-form <?php do_action('frm_form_classes', $form) ?>" id="form_<?php echo esc_attr( $form->form_key ) ?>" <?php echo $frm_settings->use_html ? '' : 'action=""'; ?> <?php echo apply_filters( 'frm_form_attributes', '', $form ); ?>>
5
+<form enctype="<?php echo esc_attr( apply_filters( 'frm_form_enctype', 'multipart/form-data', $form ) ) ?>" method="post" class="frm-show-form <?php do_action( 'frm_form_classes', $form ) ?>" id="form_<?php echo esc_attr( $form->form_key ) ?>" <?php echo $frm_settings->use_html ? '' : 'action=""'; ?> <?php echo apply_filters( 'frm_form_attributes', '', $form ); ?>>
6 6
 <?php
7 7
 } else { ?>
8
-<div id="form_<?php echo esc_attr( $form->form_key ) ?>" class="frm-show-form <?php do_action('frm_form_classes', $form) ?>" >
8
+<div id="form_<?php echo esc_attr( $form->form_key ) ?>" class="frm-show-form <?php do_action( 'frm_form_classes', $form ) ?>" >
9 9
 <?php
10 10
 }
11 11
 
Please login to merge, or discard this patch.
classes/widgets/FrmShowForm.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 	}
9 9
 
10 10
 	public function widget( $args, $instance ) {
11
-        $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
11
+		$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
12 12
 
13 13
 		echo $args['before_widget'];
14 14
 
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
 	}
35 35
 
36 36
 	public function form( $instance ) {
37
-	    //Defaults
37
+		//Defaults
38 38
 		$instance = wp_parse_args( (array) $instance, array(
39
-		    'title' => false, 'form' => false, 'description' => false,
39
+			'title' => false, 'form' => false, 'description' => false,
40 40
 		) );
41 41
 ?>
42 42
 	<p><label for="<?php echo esc_attr( $this->get_field_id('title') ); ?>"><?php _e( 'Title', 'formidable' ) ?>:</label><br/>
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
 
45 45
 	<p><label for="<?php echo esc_attr( $this->get_field_id('form') ); ?>"><?php _e( 'Form', 'formidable' ) ?>:</label><br/>
46 46
 <?php
47
-	    FrmFormsHelper::forms_dropdown( $this->get_field_name('form'), $instance['form'], array(
48
-	        'blank' => false, 'field_id' => $this->get_field_id('form'),
49
-            'class' => 'widefat',
50
-	    ) );
47
+		FrmFormsHelper::forms_dropdown( $this->get_field_name('form'), $instance['form'], array(
48
+			'blank' => false, 'field_id' => $this->get_field_id('form'),
49
+			'class' => 'widefat',
50
+		) );
51 51
 ?>
52 52
 	</p>
53 53
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 	public function __construct() {
6 6
 		$widget_ops = array( 'description' => __( 'Display a Formidable Form', 'formidable' ) );
7
-		parent::__construct('frm_show_form', __( 'Formidable Form', 'formidable' ), $widget_ops);
7
+		parent::__construct( 'frm_show_form', __( 'Formidable Form', 'formidable' ), $widget_ops );
8 8
 	}
9 9
 
10 10
 	public function widget( $args, $instance ) {
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 		echo '<div class="frm_form_widget">';
16 16
 		if ( $title ) {
17
-			echo $args['before_title'] . stripslashes($title) . $args['after_title'];
17
+			echo $args['before_title'] . stripslashes( $title ) . $args['after_title'];
18 18
 		}
19 19
 
20 20
 		$form_atts = array(
@@ -39,19 +39,19 @@  discard block
 block discarded – undo
39 39
 		    'title' => false, 'form' => false, 'description' => false,
40 40
 		) );
41 41
 ?>
42
-	<p><label for="<?php echo esc_attr( $this->get_field_id('title') ); ?>"><?php _e( 'Title', 'formidable' ) ?>:</label><br/>
43
-	<input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id('title') ); ?>" name="<?php echo esc_attr( $this->get_field_name('title') ); ?>" value="<?php echo esc_attr( stripslashes($instance['title']) ); ?>" /></p>
42
+	<p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title', 'formidable' ) ?>:</label><br/>
43
+	<input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_attr( stripslashes( $instance['title'] ) ); ?>" /></p>
44 44
 
45
-	<p><label for="<?php echo esc_attr( $this->get_field_id('form') ); ?>"><?php _e( 'Form', 'formidable' ) ?>:</label><br/>
45
+	<p><label for="<?php echo esc_attr( $this->get_field_id( 'form' ) ); ?>"><?php _e( 'Form', 'formidable' ) ?>:</label><br/>
46 46
 <?php
47
-	    FrmFormsHelper::forms_dropdown( $this->get_field_name('form'), $instance['form'], array(
48
-	        'blank' => false, 'field_id' => $this->get_field_id('form'),
47
+	    FrmFormsHelper::forms_dropdown( $this->get_field_name( 'form' ), $instance['form'], array(
48
+	        'blank' => false, 'field_id' => $this->get_field_id( 'form' ),
49 49
             'class' => 'widefat',
50 50
 	    ) );
51 51
 ?>
52 52
 	</p>
53 53
 
54
-	<p><label for="<?php echo esc_attr( $this->get_field_id('description') ); ?>"><input class="checkbox" type="checkbox" <?php checked($instance['description'], true) ?> id="<?php echo esc_attr( $this->get_field_id('description') ); ?>" name="<?php echo esc_attr( $this->get_field_name('description') ); ?>" value="1" />
54
+	<p><label for="<?php echo esc_attr( $this->get_field_id( 'description' ) ); ?>"><input class="checkbox" type="checkbox" <?php checked( $instance['description'], true ) ?> id="<?php echo esc_attr( $this->get_field_id( 'description' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'description' ) ); ?>" value="1" />
55 55
 	<?php _e( 'Show Description', 'formidable' ) ?></label></p>
56 56
 <?php
57 57
 	}
Please login to merge, or discard this patch.
classes/controllers/FrmAddonsController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -194,7 +194,7 @@
 block discarded – undo
194 194
 			}
195 195
 			$addon['link'] = FrmAppHelper::make_affiliate_url( $addon['link'] );
196 196
 
197
-			$addons[ $slug ] = $addon;
197
+			$addons[$slug] = $addon;
198 198
 		}
199 199
 	}
200 200
 
Please login to merge, or discard this patch.
classes/controllers/FrmSettingsController.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -2,26 +2,26 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmSettingsController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		// Make sure admins can see the menu items
7 7
 		FrmAppHelper::force_capability( 'frm_change_settings' );
8 8
 
9
-        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' );
10
-    }
9
+		add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' );
10
+	}
11 11
 
12
-    public static function license_box() {
12
+	public static function license_box() {
13 13
 		$a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
14
-        include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' );
15
-    }
14
+		include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' );
15
+	}
16 16
 
17
-    public static function display_form( $errors = array(), $message = '' ) {
18
-        global $frm_vars;
17
+	public static function display_form( $errors = array(), $message = '' ) {
18
+		global $frm_vars;
19 19
 
20
-        $frm_settings = FrmAppHelper::get_settings();
21
-        $frm_roles = FrmAppHelper::frm_capabilities();
20
+		$frm_settings = FrmAppHelper::get_settings();
21
+		$frm_roles = FrmAppHelper::frm_capabilities();
22 22
 
23
-        $uploads = wp_upload_dir();
24
-        $target_path = $uploads['basedir'] . '/formidable/css';
23
+		$uploads = wp_upload_dir();
24
+		$target_path = $uploads['basedir'] . '/formidable/css';
25 25
 
26 26
 		$sections = self::get_settings_tabs();
27 27
 
@@ -64,47 +64,47 @@  discard block
 block discarded – undo
64 64
 		wp_die();
65 65
 	}
66 66
 
67
-    public static function process_form( $stop_load = false ) {
68
-        global $frm_vars;
67
+	public static function process_form( $stop_load = false ) {
68
+		global $frm_vars;
69 69
 
70
-        $frm_settings = FrmAppHelper::get_settings();
70
+		$frm_settings = FrmAppHelper::get_settings();
71 71
 
72 72
 		$process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
73 73
 		if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
74
-            wp_die( $frm_settings->admin_permission );
75
-        }
74
+			wp_die( $frm_settings->admin_permission );
75
+		}
76 76
 
77
-        $errors = array();
78
-        $message = '';
77
+		$errors = array();
78
+		$message = '';
79 79
 
80
-        if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
81
-            $errors = $frm_settings->validate( $_POST, array() );
80
+		if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
81
+			$errors = $frm_settings->validate( $_POST, array() );
82 82
 
83
-            $frm_settings->update( stripslashes_deep( $_POST ) );
83
+			$frm_settings->update( stripslashes_deep( $_POST ) );
84 84
 
85
-            if ( empty( $errors ) ) {
86
-                $frm_settings->store();
87
-                $message = __( 'Settings Saved', 'formidable' );
88
-            }
89
-        } else {
90
-            $message = __( 'Settings Saved', 'formidable' );
91
-        }
85
+			if ( empty( $errors ) ) {
86
+				$frm_settings->store();
87
+				$message = __( 'Settings Saved', 'formidable' );
88
+			}
89
+		} else {
90
+			$message = __( 'Settings Saved', 'formidable' );
91
+		}
92 92
 
93 93
 		if ( $stop_load == 'stop_load' ) {
94
-            $frm_vars['settings_routed'] = true;
95
-            return;
96
-        }
94
+			$frm_vars['settings_routed'] = true;
95
+			return;
96
+		}
97 97
 
98
-        self::display_form( $errors, $message );
99
-    }
98
+		self::display_form( $errors, $message );
99
+	}
100 100
 
101
-    public static function route( $stop_load = false ) {
102
-        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
101
+	public static function route( $stop_load = false ) {
102
+		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
103 103
 		$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
104
-        if ( $action == 'process-form' ) {
104
+		if ( $action == 'process-form' ) {
105 105
 			self::process_form( $stop_load );
106
-        } else if ( $stop_load != 'stop_load' ) {
106
+		} else if ( $stop_load != 'stop_load' ) {
107 107
 			self::display_form();
108
-        }
109
-    }
108
+		}
109
+	}
110 110
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,16 +45,16 @@
 block discarded – undo
45 45
 	}
46 46
 
47 47
 	public static function load_settings_tab() {
48
-		FrmAppHelper::permission_check('frm_change_settings');
48
+		FrmAppHelper::permission_check( 'frm_change_settings' );
49 49
 		check_ajax_referer( 'frm_ajax', 'nonce' );
50 50
 
51 51
 		$section = FrmAppHelper::get_post_param( 'tab', '', 'sanitize_text_field' );
52 52
 		$sections = self::get_settings_tabs();
53
-		if ( ! isset( $sections[ $section ] ) ) {
53
+		if ( ! isset( $sections[$section] ) ) {
54 54
 			wp_die();
55 55
 		}
56 56
 
57
-		$section = $sections[ $section ];
57
+		$section = $sections[$section];
58 58
 
59 59
 		if ( isset( $section['class'] ) ) {
60 60
 			call_user_func( array( $section['class'], $section['function'] ) );
Please login to merge, or discard this patch.
classes/views/frm-settings/form.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -191,10 +191,10 @@
 block discarded – undo
191 191
 					} else {
192 192
 						call_user_func( ( isset( $section['function'] ) ? $section['function'] : $section ) );
193 193
 					}
194
-                } ?>
194
+				} ?>
195 195
             </div>
196 196
         <?php
197
-        } ?>
197
+		} ?>
198 198
 
199 199
         <p class="alignright frm_uninstall">
200 200
             <a href="javascript:void(0)" id="frm_uninstall_now"><?php _e( 'Uninstall Formidable', 'formidable' ) ?></a>
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -27,14 +27,14 @@  discard block
 block discarded – undo
27 27
         </ul>
28 28
         </div>
29 29
 
30
-    <?php do_action('frm_before_settings'); ?>
30
+    <?php do_action( 'frm_before_settings' ); ?>
31 31
 
32 32
 	<form name="frm_settings_form" method="post" class="frm_settings_form" action="?page=formidable-settings<?php echo ( $a ? '&amp;t=' . $a : '' ); ?>">
33 33
         <input type="hidden" name="frm_action" value="process-form" />
34 34
         <input type="hidden" name="action" value="process-form" />
35
-        <?php wp_nonce_field('process_form_nonce', 'process_form'); ?>
35
+        <?php wp_nonce_field( 'process_form_nonce', 'process_form' ); ?>
36 36
 
37
-        <div class="general_settings tabs-panel <?php echo ($a == 'general_settings') ? 'frm_block' : 'frm_hidden'; ?>">
37
+        <div class="general_settings tabs-panel <?php echo ( $a == 'general_settings' ) ? 'frm_block' : 'frm_hidden'; ?>">
38 38
             <p class="submit">
39 39
 				<input class="button-primary" type="submit" value="<?php esc_attr_e( 'Update Options', 'formidable' ) ?>" />
40 40
             </p>
@@ -43,20 +43,20 @@  discard block
 block discarded – undo
43 43
 
44 44
             <p><label class="frm_left_label"><?php _e( 'Load form styling', 'formidable' ) ?></label>
45 45
                 <select id="frm_load_style" name="frm_load_style">
46
-                <option value="all" <?php selected($frm_settings->load_style, 'all') ?>><?php _e( 'on every page of your site', 'formidable' ) ?></option>
47
-                <option value="dynamic" <?php selected($frm_settings->load_style, 'dynamic') ?>><?php _e( 'only on applicable pages', 'formidable' ) ?></option>
48
-                <option value="none" <?php selected($frm_settings->load_style, 'none') ?>><?php _e( 'Don\'t use form styling on any page', 'formidable' ) ?></option>
46
+                <option value="all" <?php selected( $frm_settings->load_style, 'all' ) ?>><?php _e( 'on every page of your site', 'formidable' ) ?></option>
47
+                <option value="dynamic" <?php selected( $frm_settings->load_style, 'dynamic' ) ?>><?php _e( 'only on applicable pages', 'formidable' ) ?></option>
48
+                <option value="none" <?php selected( $frm_settings->load_style, 'none' ) ?>><?php _e( 'Don\'t use form styling on any page', 'formidable' ) ?></option>
49 49
                 </select>
50 50
             </p>
51 51
 
52 52
             <p>
53 53
 				<label for="frm_use_html">
54
-					<input type="checkbox" id="frm_use_html" name="frm_use_html" value="1" <?php checked($frm_settings->use_html, 1) ?>	> <?php _e( 'Use HTML5 in forms', 'formidable' ) ?>
54
+					<input type="checkbox" id="frm_use_html" name="frm_use_html" value="1" <?php checked( $frm_settings->use_html, 1 ) ?>	> <?php _e( 'Use HTML5 in forms', 'formidable' ) ?>
55 55
 				</label>
56 56
 				<span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'We recommend using HTML 5 for your forms. It adds some nifty options like placeholders, patterns, and autocomplete.', 'formidable' ) ?>"></span>
57 57
             </p>
58 58
 
59
-            <?php do_action('frm_style_general_settings', $frm_settings); ?>
59
+            <?php do_action( 'frm_style_general_settings', $frm_settings ); ?>
60 60
 
61 61
 			<h3><?php _e( 'User Permissions', 'formidable' ); ?>
62 62
 				<span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'Select users that are allowed access to Formidable. Without access to View Forms, users will be unable to see the Formidable menu.', 'formidable' ) ?>"></span>
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 			</p>
81 81
 
82 82
 			<p><label class="frm_left_label"><?php _e( 'Site Key', 'formidable' ) ?></label>
83
-			<input type="text" name="frm_pubkey" id="frm_pubkey" size="42" value="<?php echo esc_attr($frm_settings->pubkey) ?>" placeholder="<?php esc_attr_e( 'Optional', 'formidable' ) ?>" /></p>
83
+			<input type="text" name="frm_pubkey" id="frm_pubkey" size="42" value="<?php echo esc_attr( $frm_settings->pubkey ) ?>" placeholder="<?php esc_attr_e( 'Optional', 'formidable' ) ?>" /></p>
84 84
 
85 85
 			<p><label class="frm_left_label"><?php _e( 'Secret Key', 'formidable' ) ?></label>
86
-			<input type="text" name="frm_privkey" id="frm_privkey" size="42" value="<?php echo esc_attr($frm_settings->privkey) ?>" placeholder="<?php esc_attr_e( 'Optional', 'formidable' ) ?>" /></p>
86
+			<input type="text" name="frm_privkey" id="frm_privkey" size="42" value="<?php echo esc_attr( $frm_settings->privkey ) ?>" placeholder="<?php esc_attr_e( 'Optional', 'formidable' ) ?>" /></p>
87 87
 
88 88
 		    <p><label class="frm_left_label"><?php _e( 'reCAPTCHA Type', 'formidable' ) ?></label>
89 89
 			<select name="frm_re_type" id="frm_re_type">
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 			<select name="frm_re_lang" id="frm_re_lang">
100 100
 				<option value="" <?php selected( $frm_settings->re_lang, '' ) ?>><?php esc_html_e( 'Browser Default', 'formidable' ); ?></option>
101 101
 			    <?php foreach ( $captcha_lang as $lang => $lang_name ) { ?>
102
-				<option value="<?php echo esc_attr($lang) ?>" <?php selected($frm_settings->re_lang, $lang) ?>><?php echo esc_html( $lang_name ) ?></option>
102
+				<option value="<?php echo esc_attr( $lang ) ?>" <?php selected( $frm_settings->re_lang, $lang ) ?>><?php echo esc_html( $lang_name ) ?></option>
103 103
                 <?php } ?>
104 104
             </select></p>
105 105
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 			<label class="frm_left_label"><?php _e( 'Success Message', 'formidable' ); ?>
153 153
 				<span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'The default message seen after a form is submitted.', 'formidable' ) ?>" ></span>
154 154
 			</label>
155
-            <input type="text" id="frm_success_msg" name="frm_success_msg" class="frm_with_left_label" value="<?php echo esc_attr($frm_settings->success_msg) ?>" />
155
+            <input type="text" id="frm_success_msg" name="frm_success_msg" class="frm_with_left_label" value="<?php echo esc_attr( $frm_settings->success_msg ) ?>" />
156 156
 		</p>
157 157
 
158 158
 		<p>
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			<input type="text" value="<?php echo esc_attr( $frm_settings->submit_value ) ?>" id="frm_submit_value" name="frm_submit_value" class="frm_with_left_label" />
161 161
 		</p>
162 162
 
163
-        <?php do_action('frm_settings_form', $frm_settings); ?>
163
+        <?php do_action( 'frm_settings_form', $frm_settings ); ?>
164 164
 
165 165
         <?php if ( ! FrmAppHelper::pro_is_installed() ) { ?>
166 166
 			<div class="clear"></div>
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		<?php } ?>
171 171
 
172 172
         <p><label class="frm_left_label"><?php _e( 'Preview Page', 'formidable' ); ?></label>
173
-        <?php FrmAppHelper::wp_pages_dropdown('frm-preview-page-id', $frm_settings->preview_page_id ) ?>
173
+        <?php FrmAppHelper::wp_pages_dropdown( 'frm-preview-page-id', $frm_settings->preview_page_id ) ?>
174 174
         </p>
175 175
 
176 176
     </div>
Please login to merge, or discard this patch.
classes/models/FrmEntryFormat.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -151,6 +151,7 @@
 block discarded – undo
151 151
 
152 152
 	/**
153 153
 	 * @deprecated 2.03.11
154
+	 * @param string $val
154 155
 	 */
155 156
 	private static function get_field_value( $atts, &$val ) {
156 157
 		_deprecated_function( __FUNCTION__, '2.03.11', 'instance of FrmEntryValues or FrmProEntryValues' );
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -98,15 +98,15 @@  discard block
 block discarded – undo
98 98
 		self::prepare_field_output( $atts, $val );
99 99
 
100 100
 		if ( $atts['format'] != 'text' ) {
101
-			$values[ $f->field_key ] = $val;
101
+			$values[$f->field_key] = $val;
102 102
 			if ( $atts['entry'] && $f->type != 'textarea' ) {
103
-				$prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] );
103
+				$prev_val = maybe_unserialize( $atts['entry']->metas[$f->id] );
104 104
 				if ( $prev_val != $val ) {
105
-					$values[ $f->field_key . '-value' ] = $prev_val;
105
+					$values[$f->field_key . '-value'] = $prev_val;
106 106
 				}
107 107
 			}
108 108
 		} else {
109
-			$values[ $f->id ] = array( 'label' => $f->name, 'val' => $val, 'type' => $f->type );
109
+			$values[$f->id] = array( 'label' => $f->name, 'val' => $val, 'type' => $f->type );
110 110
 		}
111 111
 	}
112 112
 
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 	private static function fill_missing_fields( $atts, &$values ) {
117 117
 		_deprecated_function( __FUNCTION__, '2.03.11', 'instance of FrmEntryValues or FrmProEntryValues' );
118 118
 
119
-		if ( $atts['entry'] && ! isset( $atts['entry']->metas[ $atts['field']->id ] ) ) {
119
+		if ( $atts['entry'] && ! isset( $atts['entry']->metas[$atts['field']->id] ) ) {
120 120
 			// In case include_blank is set
121
-			$atts['entry']->metas[ $atts['field']->id ] = '';
121
+			$atts['entry']->metas[$atts['field']->id] = '';
122 122
 			$atts['entry'] = apply_filters( 'frm_prepare_entry_content', $atts['entry'], array( 'field' => $atts['field'] ) );
123 123
 			self::fill_values_from_entry( $atts, $values );
124 124
 		}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 			'type'  => $f->type,
147 147
 		);
148 148
 
149
-		$values[ $f->id ] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f );
149
+		$values[$f->id] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f );
150 150
 	}
151 151
 
152 152
 	/**
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 
158 158
 		$f = $atts['field'];
159 159
 		if ( $atts['entry'] ) {
160
-			$prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] );
160
+			$prev_val = maybe_unserialize( $atts['entry']->metas[$f->id] );
161 161
 			$meta = array( 'item_id' => $atts['id'], 'field_id' => $f->id, 'meta_value' => $prev_val, 'field_type' => $f->type );
162 162
 
163 163
 			//This filter applies to the default-message shortcode and frm-show-entry shortcode only
Please login to merge, or discard this patch.