Completed
Push — master ( 4ef3e4...2cdabf )
by Stephanie
03:15
created
classes/models/FrmPointers.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
 	/**
14 14
 	 * Get the singleton instance of this class
15 15
 	 *
16
-	 * @return object
16
+	 * @return FrmPointers
17 17
 	 */
18 18
 	public static function get_instance() {
19 19
 		_deprecated_function( __FUNCTION__, '3.01.03' );
Please login to merge, or discard this patch.
classes/models/FrmAddon.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -248,7 +248,8 @@
 block discarded – undo
248 248
 	}
249 249
 
250 250
 	private function is_license_revoked() {
251
-		if ( empty( $this->license ) || empty( $this->plugin_slug ) || isset( $_POST['license'] ) ) { // WPCS: CSRF ok.
251
+		if ( empty( $this->license ) || empty( $this->plugin_slug ) || isset( $_POST['license'] ) ) {
252
+// WPCS: CSRF ok.
252 253
 			return;
253 254
 		}
254 255
 
Please login to merge, or discard this patch.
classes/models/FrmEDD_SL_Plugin_Updater.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 		$this->beta        = ! empty( $this->api_data['beta'] ) ? true : false;
45 45
 		$this->cache_key   = md5( serialize( $this->slug . $this->version . $this->api_data['license'] . $this->beta ) );
46 46
 
47
-		$frm_edd_plugin_data[ $this->slug ] = $this->api_data;
47
+		$frm_edd_plugin_data[$this->slug] = $this->api_data;
48 48
 
49 49
 		/**
50 50
 		 * Fires after the $frm_edd_plugin_data is setup.
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 			$_transient_data = new stdClass;
94 94
 		}
95 95
 
96
-		if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
96
+		if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[$this->name] ) && false === $this->wp_override ) {
97 97
 			return $_transient_data;
98 98
 		}
99 99
 
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
 					$version_info->plugin = $this->name;
118 118
 				}
119 119
 
120
-				$_transient_data->response[ $this->name ] = $version_info;
120
+				$_transient_data->response[$this->name] = $version_info;
121 121
 
122 122
 			}
123 123
 
124 124
 			$_transient_data->last_checked           = time();
125
-			$_transient_data->checked[ $this->name ] = $this->version;
125
+			$_transient_data->checked[$this->name] = $this->version;
126 126
 
127 127
 		}
128 128
 
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 		if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
187 187
 			$new_sections = array();
188 188
 			foreach ( $_data->sections as $key => $value ) {
189
-				$new_sections[ $key ] = $value;
189
+				$new_sections[$key] = $value;
190 190
 			}
191 191
 
192 192
 			$_data->sections = $new_sections;
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 		if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
197 197
 			$new_banners = array();
198 198
 			foreach ( $_data->banners as $key => $value ) {
199
-				$new_banners[ $key ] = $value;
199
+				$new_banners[$key] = $value;
200 200
 			}
201 201
 
202 202
 			$_data->banners = $new_banners;
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 		}
311 311
 
312 312
 		$slug         = sanitize_text_field( $_REQUEST['slug'] ); // WPCS: CSRF ok.
313
-		$data         = $frm_edd_plugin_data[ $slug ];
313
+		$data         = $frm_edd_plugin_data[$slug];
314 314
 		$beta         = ! empty( $data['beta'] ) ? true : false;
315 315
 		$cache_key    = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' ); // WPCS: CSRF ok.
316 316
 		$version_info = $this->get_cached_version_info( $cache_key );
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -297,11 +297,13 @@
 block discarded – undo
297 297
 
298 298
 		global $frm_edd_plugin_data;
299 299
 
300
-		if ( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' !== $_REQUEST['edd_sl_action'] ) { // WPCS: CSRF ok.
300
+		if ( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' !== $_REQUEST['edd_sl_action'] ) {
301
+// WPCS: CSRF ok.
301 302
 			return;
302 303
 		}
303 304
 
304
-		if ( empty( $_REQUEST['plugin'] ) || empty( $_REQUEST['slug'] ) ) { // WPCS: CSRF ok.
305
+		if ( empty( $_REQUEST['plugin'] ) || empty( $_REQUEST['slug'] ) ) {
306
+// WPCS: CSRF ok.
305 307
 			return;
306 308
 		}
307 309
 
Please login to merge, or discard this patch.
classes/models/FrmEntry.php 1 patch
Indentation   +306 added lines, -306 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'] ) {
57
+		if ( $new_values['item_key'] == $new_values['name'] ) {
58 58
 			unset( $check_val['name'] );
59
-        }
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 64
 		if ( ! $entry_exists || empty( $entry_exists ) || ! isset( $values['item_meta'] ) ) {
65
-            return false;
66
-        }
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
72
+			//add more checks here to make sure it's a duplicate
73 73
 			$metas = FrmEntryMeta::get_entry_meta_info( $entry_exist );
74
-            $field_metas = array();
75
-            foreach ( $metas as $meta ) {
74
+			$field_metas = array();
75
+			foreach ( $metas as $meta ) {
76 76
 				$field_metas[ $meta->field_id ] = $meta->meta_value;
77
-            }
77
+			}
78 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
-            }
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 84
 
85 85
 			$diff = array_diff_assoc( $field_metas, array_map( 'maybe_serialize', $values['item_meta'] ) );
86
-            foreach ( $diff as $field_id => $meta_value ) {
86
+			foreach ( $diff as $field_id => $meta_value ) {
87 87
 				if ( ! empty( $meta_value ) ) {
88
-                    $is_duplicate = false;
89
-                    continue;
90
-                }
91
-            }
88
+					$is_duplicate = false;
89
+					continue;
90
+				}
91
+			}
92 92
 
93
-            if ( $is_duplicate ) {
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
@@ -141,32 +141,32 @@  discard block
 block discarded – undo
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;
150
+		global $frm_vars;
151 151
 		if ( ! isset( $frm_vars['saved_entries'] ) ) {
152
-            $frm_vars['saved_entries'] = array();
153
-        }
154
-        $frm_vars['saved_entries'][] = (int) $entry_id;
152
+			$frm_vars['saved_entries'] = array();
153
+		}
154
+		$frm_vars['saved_entries'][] = (int) $entry_id;
155 155
 
156 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,14 +200,14 @@  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 212
 		do_action( 'frm_before_destroy_entry', $id, $entry );
213 213
 
@@ -216,18 +216,18 @@  discard block
 block discarded – undo
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;
223
+		global $wpdb;
224 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
@@ -269,19 +269,19 @@  discard block
 block discarded – undo
269 269
 	}
270 270
 
271 271
 	public static function getOne( $id, $meta = false ) {
272
-        global $wpdb;
272
+		global $wpdb;
273 273
 
274
-        $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
274
+		$query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
275 275
                   LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE ";
276 276
 
277 277
 		$query .= is_numeric( $id ) ? 'it.id=%d' : 'it.item_key=%s';
278
-        $query_args = array( $id );
279
-        $query = $wpdb->prepare( $query, $query_args ); // WPCS: unprepared SQL ok.
278
+		$query_args = array( $id );
279
+		$query = $wpdb->prepare( $query, $query_args ); // WPCS: unprepared SQL ok.
280 280
 
281
-        if ( ! $meta ) {
281
+		if ( ! $meta ) {
282 282
 			$entry = FrmDb::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' );
283 283
 			return stripslashes_deep( $entry );
284
-        }
284
+		}
285 285
 
286 286
 		$entry = FrmDb::check_cache( $id, 'frm_entry' );
287 287
 		if ( $entry !== false ) {
@@ -292,69 +292,69 @@  discard block
 block discarded – undo
292 292
 		$entry = self::get_meta( $entry );
293 293
 
294 294
 		return stripslashes_deep( $entry );
295
-    }
295
+	}
296 296
 
297 297
 	public static function get_meta( $entry ) {
298
-        if ( ! $entry ) {
299
-            return $entry;
300
-        }
298
+		if ( ! $entry ) {
299
+			return $entry;
300
+		}
301 301
 
302
-        global $wpdb;
302
+		global $wpdb;
303 303
 		$metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas m LEFT JOIN ' . $wpdb->prefix . 'frm_fields f ON m.field_id=f.id', array(
304 304
 			'item_id' => $entry->id,
305 305
 			'field_id !' => 0,
306 306
 		), 'field_id, meta_value, field_key, item_id' );
307 307
 
308
-        $entry->metas = array();
308
+		$entry->metas = array();
309 309
 
310 310
 		$include_key = apply_filters( 'frm_include_meta_keys', false, array( 'form_id' => $entry->form_id ) );
311
-        foreach ( $metas as $meta_val ) {
312
-            if ( $meta_val->item_id == $entry->id ) {
311
+		foreach ( $metas as $meta_val ) {
312
+			if ( $meta_val->item_id == $entry->id ) {
313 313
 				$entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
314 314
 				if ( $include_key ) {
315 315
 					$entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ];
316 316
 				}
317
-                 continue;
318
-            }
317
+				 continue;
318
+			}
319 319
 
320
-            // include sub entries in an array
320
+			// include sub entries in an array
321 321
 			if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) {
322 322
 				$entry->metas[ $meta_val->field_id ] = array();
323
-            }
323
+			}
324 324
 
325 325
 			$entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value );
326 326
 
327 327
 			unset( $meta_val );
328
-        }
328
+		}
329 329
 		unset( $metas );
330 330
 
331 331
 		FrmDb::set_cache( $entry->id, $entry, 'frm_entry' );
332 332
 
333
-        return $entry;
334
-    }
333
+		return $entry;
334
+	}
335 335
 
336
-    /**
337
-     * @param string $id
338
-     */
336
+	/**
337
+	 * @param string $id
338
+	 */
339 339
 	public static function exists( $id ) {
340
-        global $wpdb;
340
+		global $wpdb;
341 341
 
342
-        if ( FrmDb::check_cache( $id, 'frm_entry' ) ) {
343
-            $exists = true;
344
-            return $exists;
345
-        }
342
+		if ( FrmDb::check_cache( $id, 'frm_entry' ) ) {
343
+			$exists = true;
344
+			return $exists;
345
+		}
346 346
 
347 347
 		if ( is_numeric( $id ) ) {
348
-            $where = array( 'id' => $id );
349
-        } else {
350
-            $where = array( 'item_key' => $id );
351
-        }
348
+			$where = array( 'id' => $id );
349
+		} else {
350
+			$where = array( 'item_key' => $id );
351
+		}
352 352
 		$id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where );
353 353
 
354 354
 		return ( $id && $id > 0 );
355
-    }
355
+	}
356 356
 
357
-    public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
357
+	public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
358 358
 		global $wpdb;
359 359
 
360 360
 		$limit = FrmDb::esc_limit( $limit );
@@ -362,21 +362,21 @@  discard block
 block discarded – undo
362 362
 		$cache_key = maybe_serialize( $where ) . $order_by . $limit . $inc_form;
363 363
 		$entries = wp_cache_get( $cache_key, 'frm_entry' );
364 364
 
365
-        if ( false === $entries ) {
366
-            $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';
365
+		if ( false === $entries ) {
366
+			$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';
367 367
 			$table = $wpdb->prefix . 'frm_items it ';
368 368
 
369
-            if ( $inc_form ) {
370
-                $fields = 'it.*, fr.name as form_name,fr.form_key as form_key';
371
-                $table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id ';
372
-            }
369
+			if ( $inc_form ) {
370
+				$fields = 'it.*, fr.name as form_name,fr.form_key as form_key';
371
+				$table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id ';
372
+			}
373 373
 
374
-            if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) {
375
-    		    // sort by a requested field
376
-                $field_id = (int) $order_matches[1];
374
+			if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) {
375
+				// sort by a requested field
376
+				$field_id = (int) $order_matches[1];
377 377
 				$fields .= ', (SELECT meta_value FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id = ' . $field_id . ' AND item_id = it.id) as meta_' . $field_id;
378 378
 				unset( $order_matches, $field_id );
379
-		    }
379
+			}
380 380
 
381 381
 			// prepare the query
382 382
 			$query = 'SELECT ' . $fields . ' FROM ' . $table . FrmDb::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
@@ -385,45 +385,45 @@  discard block
 block discarded – undo
385 385
 			unset( $query );
386 386
 
387 387
 			FrmDb::set_cache( $cache_key, $entries, 'frm_entry' );
388
-        }
388
+		}
389 389
 
390
-        if ( ! $meta || ! $entries ) {
390
+		if ( ! $meta || ! $entries ) {
391 391
 			return stripslashes_deep( $entries );
392
-        }
392
+		}
393 393
 		unset( $meta );
394 394
 
395 395
 		if ( ! is_array( $where ) && preg_match( '/^it\.form_id=\d+$/', $where ) ) {
396 396
 			$where = array( 'it.form_id' => substr( $where, 11 ) );
397
-        }
397
+		}
398 398
 
399
-        $meta_where = array( 'field_id !' => 0 );
399
+		$meta_where = array( 'field_id !' => 0 );
400 400
 		if ( $limit == '' && is_array( $where ) && count( $where ) == 1 && isset( $where['it.form_id'] ) ) {
401
-            $meta_where['fi.form_id'] = $where['it.form_id'];
402
-        } else {
403
-            $meta_where['item_id'] = array_keys( $entries );
404
-        }
401
+			$meta_where['fi.form_id'] = $where['it.form_id'];
402
+		} else {
403
+			$meta_where['item_id'] = array_keys( $entries );
404
+		}
405 405
 
406
-        $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' );
406
+		$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' );
407 407
 
408
-        unset( $meta_where );
408
+		unset( $meta_where );
409 409
 
410
-        if ( ! $metas ) {
410
+		if ( ! $metas ) {
411 411
 			return stripslashes_deep( $entries );
412
-        }
412
+		}
413 413
 
414
-        foreach ( $metas as $m_key => $meta_val ) {
415
-            if ( ! isset( $entries[ $meta_val->item_id ] ) ) {
416
-                continue;
417
-            }
414
+		foreach ( $metas as $m_key => $meta_val ) {
415
+			if ( ! isset( $entries[ $meta_val->item_id ] ) ) {
416
+				continue;
417
+			}
418 418
 
419
-            if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
419
+			if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
420 420
 				$entries[ $meta_val->item_id ]->metas = array();
421
-            }
421
+			}
422 422
 
423 423
 			$entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
424 424
 
425 425
 			unset( $m_key, $meta_val );
426
-        }
426
+		}
427 427
 
428 428
 		if ( ! FrmAppHelper::prevent_caching() ) {
429 429
 			foreach ( $entries as $entry ) {
@@ -433,30 +433,30 @@  discard block
 block discarded – undo
433 433
 		}
434 434
 
435 435
 		return stripslashes_deep( $entries );
436
-    }
436
+	}
437 437
 
438
-    // Pagination Methods
439
-    public static function getRecordCount( $where = '' ) {
440
-        global $wpdb;
438
+	// Pagination Methods
439
+	public static function getRecordCount( $where = '' ) {
440
+		global $wpdb;
441 441
 		$table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id';
442 442
 
443 443
 		if ( is_numeric( $where ) ) {
444
-            $table_join = 'frm_items';
445
-            $where = array( 'form_id' => $where );
446
-        }
444
+			$table_join = 'frm_items';
445
+			$where = array( 'form_id' => $where );
446
+		}
447 447
 
448
-        if ( is_array( $where ) ) {
449
-            $count = FrmDb::get_count( $table_join, $where );
450
-        } else {
448
+		if ( is_array( $where ) ) {
449
+			$count = FrmDb::get_count( $table_join, $where );
450
+		} else {
451 451
 			$cache_key = 'count_' . maybe_serialize( $where );
452 452
 			$query = 'SELECT COUNT(*) FROM ' . $table_join . FrmDb::prepend_and_or_where( ' WHERE ', $where );
453 453
 			$count = FrmDb::check_cache( $cache_key, 'frm_entry', $query, 'get_var' );
454
-        }
454
+		}
455 455
 
456
-        return $count;
457
-    }
456
+		return $count;
457
+	}
458 458
 
459
-    public static function getPageCount( $p_size, $where = '' ) {
459
+	public static function getPageCount( $p_size, $where = '' ) {
460 460
 		$p_size = (int) $p_size;
461 461
 		$count = 1;
462 462
 		if ( $p_size ) {
@@ -467,16 +467,16 @@  discard block
 block discarded – undo
467 467
 		}
468 468
 
469 469
 		return $count;
470
-    }
470
+	}
471 471
 
472 472
 	/**
473
-	* Prepare the data before inserting it into the database
474
-	*
475
-	* @since 2.0.16
476
-	* @param array $values
477
-	* @param string $type
478
-	* @return array $new_values
479
-	*/
473
+	 * Prepare the data before inserting it into the database
474
+	 *
475
+	 * @since 2.0.16
476
+	 * @param array $values
477
+	 * @param string $type
478
+	 * @return array $new_values
479
+	 */
480 480
 	private static function before_insert_entry_in_database( &$values, $type ) {
481 481
 
482 482
 		self::sanitize_entry_post( $values );
@@ -491,13 +491,13 @@  discard block
 block discarded – undo
491 491
 	}
492 492
 
493 493
 	/**
494
-	* Create an entry and perform after create actions
495
-	*
496
-	* @since 2.0.16
497
-	* @param array $values
498
-	* @param array $new_values
499
-	* @return boolean|int $entry_id
500
-	*/
494
+	 * Create an entry and perform after create actions
495
+	 *
496
+	 * @since 2.0.16
497
+	 * @param array $values
498
+	 * @param array $new_values
499
+	 * @return boolean|int $entry_id
500
+	 */
501 501
 	private static function continue_to_create_entry( $values, $new_values ) {
502 502
 		$entry_id = self::insert_entry_into_database( $new_values );
503 503
 		if ( ! $entry_id ) {
@@ -509,37 +509,37 @@  discard block
 block discarded – undo
509 509
 		return $entry_id;
510 510
 	}
511 511
 
512
-    /**
513
-     * Sanitize the POST values before we use them
514
-     *
515
-     * @since 2.0
516
-     * @param array $values The POST values by reference
517
-     */
518
-    public static function sanitize_entry_post( &$values ) {
519
-        $sanitize_method = array(
520
-            'form_id'       => 'absint',
521
-            'frm_action'    => 'sanitize_title',
522
-            'form_key'      => 'sanitize_title',
523
-            'item_key'      => 'sanitize_title',
524
-            'item_name'     => 'sanitize_text_field',
525
-            'frm_saving_draft' => 'absint',
526
-            'is_draft'      => 'absint',
527
-            'post_id'       => 'absint',
528
-            'parent_item_id' => 'absint',
529
-            'created_at'    => 'sanitize_text_field',
530
-            'updated_at'    => 'sanitize_text_field',
531
-        );
532
-
533
-        FrmAppHelper::sanitize_request( $sanitize_method, $values );
534
-    }
512
+	/**
513
+	 * Sanitize the POST values before we use them
514
+	 *
515
+	 * @since 2.0
516
+	 * @param array $values The POST values by reference
517
+	 */
518
+	public static function sanitize_entry_post( &$values ) {
519
+		$sanitize_method = array(
520
+			'form_id'       => 'absint',
521
+			'frm_action'    => 'sanitize_title',
522
+			'form_key'      => 'sanitize_title',
523
+			'item_key'      => 'sanitize_title',
524
+			'item_name'     => 'sanitize_text_field',
525
+			'frm_saving_draft' => 'absint',
526
+			'is_draft'      => 'absint',
527
+			'post_id'       => 'absint',
528
+			'parent_item_id' => 'absint',
529
+			'created_at'    => 'sanitize_text_field',
530
+			'updated_at'    => 'sanitize_text_field',
531
+		);
532
+
533
+		FrmAppHelper::sanitize_request( $sanitize_method, $values );
534
+	}
535 535
 
536 536
 	/**
537
-	* Prepare the new values for inserting into the database
538
-	*
539
-	* @since 2.0.16
540
-	* @param array $values
541
-	* @return array $new_values
542
-	*/
537
+	 * Prepare the new values for inserting into the database
538
+	 *
539
+	 * @since 2.0.16
540
+	 * @param array $values
541
+	 * @return array $new_values
542
+	 */
543 543
 	private static function package_entry_data( &$values ) {
544 544
 		global $wpdb;
545 545
 
@@ -592,34 +592,34 @@  discard block
 block discarded – undo
592 592
 	}
593 593
 
594 594
 	/**
595
-	* Get the is_draft value for a new entry
596
-	*
597
-	* @since 2.0.16
598
-	* @param array $values
599
-	* @return int
600
-	*/
595
+	 * Get the is_draft value for a new entry
596
+	 *
597
+	 * @since 2.0.16
598
+	 * @param array $values
599
+	 * @return int
600
+	 */
601 601
 	private static function get_is_draft_value( $values ) {
602 602
 		return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) || ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0;
603 603
 	}
604 604
 
605 605
 	/**
606
-	* Get the created_at value for a new entry
607
-	*
608
-	* @since 2.0.16
609
-	* @param array $values
610
-	* @return string
611
-	*/
606
+	 * Get the created_at value for a new entry
607
+	 *
608
+	 * @since 2.0.16
609
+	 * @param array $values
610
+	 * @return string
611
+	 */
612 612
 	private static function get_created_at( $values ) {
613 613
 		return self::get_entry_value( $values, 'created_at', current_time( 'mysql', 1 ) );
614 614
 	}
615 615
 
616 616
 	/**
617
-	* Get the updated_at value for a new entry
618
-	*
619
-	* @since 2.0.16
620
-	* @param array $values
621
-	* @return string
622
-	*/
617
+	 * Get the updated_at value for a new entry
618
+	 *
619
+	 * @since 2.0.16
620
+	 * @param array $values
621
+	 * @return string
622
+	 */
623 623
 	private static function get_updated_at( $values ) {
624 624
 		if ( isset( $values['updated_at'] ) ) {
625 625
 			$updated_at = $values['updated_at'];
@@ -631,12 +631,12 @@  discard block
 block discarded – undo
631 631
 	}
632 632
 
633 633
 	/**
634
-	* Get the description value for a new entry
635
-	*
636
-	* @since 2.0.16
637
-	* @param array $values
638
-	* @return string
639
-	*/
634
+	 * Get the description value for a new entry
635
+	 *
636
+	 * @since 2.0.16
637
+	 * @param array $values
638
+	 * @return string
639
+	 */
640 640
 	private static function get_entry_description( $values ) {
641 641
 		if ( isset( $values['description'] ) && ! empty( $values['description'] ) ) {
642 642
 			$description = maybe_serialize( $values['description'] );
@@ -651,12 +651,12 @@  discard block
 block discarded – undo
651 651
 	}
652 652
 
653 653
 	/**
654
-	* Get the user_id value for a new entry
655
-	*
656
-	* @since 2.0.16
657
-	* @param array $values
658
-	* @return int
659
-	*/
654
+	 * Get the user_id value for a new entry
655
+	 *
656
+	 * @since 2.0.16
657
+	 * @param array $values
658
+	 * @return int
659
+	 */
660 660
 	private static function get_entry_user_id( $values ) {
661 661
 		if ( isset( $values['frm_user_id'] ) && ( is_numeric( $values['frm_user_id'] ) || FrmAppHelper::is_admin() ) ) {
662 662
 			$user_id = $values['frm_user_id'];
@@ -669,12 +669,12 @@  discard block
 block discarded – undo
669 669
 	}
670 670
 
671 671
 	/**
672
-	* Insert new entry into the database
673
-	*
674
-	* @since 2.0.16
675
-	* @param array $new_values
676
-	* @return int | boolean $entry_id
677
-	*/
672
+	 * Insert new entry into the database
673
+	 *
674
+	 * @since 2.0.16
675
+	 * @param array $new_values
676
+	 * @return int | boolean $entry_id
677
+	 */
678 678
 	private static function insert_entry_into_database( $new_values ) {
679 679
 		global $wpdb;
680 680
 
@@ -690,11 +690,11 @@  discard block
 block discarded – undo
690 690
 	}
691 691
 
692 692
 	/**
693
-	* Add the new entry to global $frm_vars
694
-	*
695
-	* @since 2.0.16
696
-	* @param int $entry_id
697
-	*/
693
+	 * Add the new entry to global $frm_vars
694
+	 *
695
+	 * @since 2.0.16
696
+	 * @param int $entry_id
697
+	 */
698 698
 	private static function add_new_entry_to_frm_vars( $entry_id ) {
699 699
 		global $frm_vars;
700 700
 
@@ -706,12 +706,12 @@  discard block
 block discarded – undo
706 706
 	}
707 707
 
708 708
 	/**
709
-	* Add entry metas, if there are any
710
-	*
711
-	* @since 2.0.16
712
-	* @param array $values
713
-	* @param int $entry_id
714
-	*/
709
+	 * Add entry metas, if there are any
710
+	 *
711
+	 * @since 2.0.16
712
+	 * @param array $values
713
+	 * @param int $entry_id
714
+	 */
715 715
 	private static function maybe_add_entry_metas( $values, $entry_id ) {
716 716
 		if ( isset( $values['item_meta'] ) ) {
717 717
 			FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] );
@@ -719,12 +719,12 @@  discard block
 block discarded – undo
719 719
 	}
720 720
 
721 721
 	/**
722
-	* Trigger frm_after_create_entry hooks
723
-	*
724
-	* @since 2.0.16
725
-	* @param int $entry_id
726
-	* @param array $new_values
727
-	*/
722
+	 * Trigger frm_after_create_entry hooks
723
+	 *
724
+	 * @since 2.0.16
725
+	 * @param int $entry_id
726
+	 * @param array $new_values
727
+	 */
728 728
 	private static function after_entry_created_actions( $entry_id, $values, $new_values ) {
729 729
 		// this is a child entry
730 730
 		$is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' );
@@ -734,13 +734,13 @@  discard block
 block discarded – undo
734 734
 	}
735 735
 
736 736
 	/**
737
-	* Actions to perform immediately after an entry is inserted in the frm_items database
738
-	*
739
-	* @since 2.0.16
740
-	* @param array $values
741
-	* @param array $new_values
742
-	* @param int $entry_id
743
-	*/
737
+	 * Actions to perform immediately after an entry is inserted in the frm_items database
738
+	 *
739
+	 * @since 2.0.16
740
+	 * @param array $values
741
+	 * @param array $new_values
742
+	 * @param int $entry_id
743
+	 */
744 744
 	private static function after_insert_entry_in_database( $values, $new_values, $entry_id ) {
745 745
 
746 746
 		self::add_new_entry_to_frm_vars( $entry_id );
@@ -753,14 +753,14 @@  discard block
 block discarded – undo
753 753
 	}
754 754
 
755 755
 	/**
756
-	* Perform some actions right before updating an entry
757
-	*
758
-	* @since 2.0.16
759
-	* @param int $id
760
-	* @param array $values
761
-	* @param string $update_type
762
-	* @return boolean $update
763
-	*/
756
+	 * Perform some actions right before updating an entry
757
+	 *
758
+	 * @since 2.0.16
759
+	 * @param int $id
760
+	 * @param array $values
761
+	 * @param string $update_type
762
+	 * @return boolean $update
763
+	 */
764 764
 	private static function before_update_entry( $id, &$values, $update_type ) {
765 765
 		$update = true;
766 766
 
@@ -778,13 +778,13 @@  discard block
 block discarded – undo
778 778
 	}
779 779
 
780 780
 	/**
781
-	* Package the entry data for updating
782
-	*
783
-	* @since 2.0.16
784
-	* @param int $id
785
-	* @param array $values
786
-	* @return array $new_values
787
-	*/
781
+	 * Package the entry data for updating
782
+	 *
783
+	 * @since 2.0.16
784
+	 * @param int $id
785
+	 * @param array $values
786
+	 * @return array $new_values
787
+	 */
788 788
 	private static function package_entry_to_update( $id, $values ) {
789 789
 		global $wpdb;
790 790
 
@@ -818,14 +818,14 @@  discard block
 block discarded – undo
818 818
 	}
819 819
 
820 820
 	/**
821
-	* Perform some actions right after updating an entry
822
-	*
823
-	* @since 2.0.16
824
-	* @param boolean|int $query_results
825
-	* @param int $id
826
-	* @param array $values
827
-	* @param array $new_values
828
-	*/
821
+	 * Perform some actions right after updating an entry
822
+	 *
823
+	 * @since 2.0.16
824
+	 * @param boolean|int $query_results
825
+	 * @param int $id
826
+	 * @param array $values
827
+	 * @param array $new_values
828
+	 */
829 829
 	private static function after_update_entry( $query_results, $id, $values, $new_values ) {
830 830
 		if ( $query_results ) {
831 831
 			self::clear_cache();
@@ -847,13 +847,13 @@  discard block
 block discarded – undo
847 847
 	}
848 848
 
849 849
 	/**
850
-	* Create entry from an XML import
851
-	* Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.)
852
-	*
853
-	* @since 2.0.16
854
-	* @param array $values
855
-	* @return int | boolean $entry_id
856
-	*/
850
+	 * Create entry from an XML import
851
+	 * Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.)
852
+	 *
853
+	 * @since 2.0.16
854
+	 * @param array $values
855
+	 * @return int | boolean $entry_id
856
+	 */
857 857
 	public static function create_entry_from_xml( $values ) {
858 858
 		$entry_id = self::create_entry( $values, 'xml' );
859 859
 
@@ -861,26 +861,26 @@  discard block
 block discarded – undo
861 861
 	}
862 862
 
863 863
 	/**
864
-	* Update entry from an XML import
865
-	* Certain actions aren't necessary when importing (like saving sub entries and modifying other vals)
866
-	*
867
-	* @since 2.0.16
868
-	* @param int $id
869
-	* @param array $values
870
-	* @return int | boolean $updated
871
-	*/
864
+	 * Update entry from an XML import
865
+	 * Certain actions aren't necessary when importing (like saving sub entries and modifying other vals)
866
+	 *
867
+	 * @since 2.0.16
868
+	 * @param int $id
869
+	 * @param array $values
870
+	 * @return int | boolean $updated
871
+	 */
872 872
 	public static function update_entry_from_xml( $id, $values ) {
873 873
 		$updated = self::update_entry( $id, $values, 'xml' );
874 874
 
875 875
 		return $updated;
876 876
 	}
877 877
 
878
-    /**
879
-     * @param string $key
880
-     * @return int entry_id
881
-     */
878
+	/**
879
+	 * @param string $key
880
+	 * @return int entry_id
881
+	 */
882 882
 	public static function get_id_by_key( $key ) {
883
-        $entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) );
884
-        return $entry_id;
885
-    }
883
+		$entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) );
884
+		return $entry_id;
885
+	}
886 886
 }
Please login to merge, or discard this patch.
classes/models/FrmMigrate.php 1 patch
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
 		return $charset_collate;
85 85
 	}
86 86
 
87
-    private function create_tables() {
88
-        $charset_collate = $this->collation();
89
-        $sql = array();
87
+	private function create_tables() {
88
+		$charset_collate = $this->collation();
89
+		$sql = array();
90 90
 
91
-        /* Create/Upgrade Fields Table */
91
+		/* Create/Upgrade Fields Table */
92 92
 		$sql[] = 'CREATE TABLE ' . $this->fields . ' (
93 93
 				id BIGINT(20) NOT NULL auto_increment,
94 94
 				field_key varchar(100) default NULL,
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                 UNIQUE KEY field_key (field_key)
108 108
         )';
109 109
 
110
-        /* Create/Upgrade Forms Table */
110
+		/* Create/Upgrade Forms Table */
111 111
 		$sql[] = 'CREATE TABLE ' . $this->forms . ' (
112 112
                 id int(11) NOT NULL auto_increment,
113 113
 				form_key varchar(100) default NULL,
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
                 UNIQUE KEY form_key (form_key)
126 126
         )';
127 127
 
128
-        /* Create/Upgrade Items Table */
128
+		/* Create/Upgrade Items Table */
129 129
 		$sql[] = 'CREATE TABLE ' . $this->entries . ' (
130 130
 				id BIGINT(20) NOT NULL auto_increment,
131 131
 				item_key varchar(100) default NULL,
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
                 UNIQUE KEY item_key (item_key)
149 149
         )';
150 150
 
151
-        /* Create/Upgrade Meta Table */
151
+		/* Create/Upgrade Meta Table */
152 152
 		$sql[] = 'CREATE TABLE ' . $this->entry_metas . ' (
153 153
 				id BIGINT(20) NOT NULL auto_increment,
154 154
 				meta_value longtext default NULL,
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                 KEY item_id (item_id)
161 161
         )';
162 162
 
163
-        foreach ( $sql as $q ) {
163
+		foreach ( $sql as $q ) {
164 164
 			if ( function_exists( 'dbDelta' ) ) {
165 165
 				dbDelta( $q . $charset_collate . ';' );
166 166
 			} else {
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 				$wpdb->query( $q . $charset_collate ); // WPCS: unprepared SQL ok.
169 169
 			}
170 170
 			unset( $q );
171
-        }
172
-    }
171
+		}
172
+	}
173 173
 
174 174
 	private function maybe_create_contact_form() {
175 175
 		$template_id = FrmForm::get_id_by_key( 'contact' );
@@ -216,13 +216,13 @@  discard block
 block discarded – undo
216 216
 		}
217 217
 	}
218 218
 
219
-    public function uninstall() {
219
+	public function uninstall() {
220 220
 		if ( ! current_user_can( 'administrator' ) ) {
221
-            $frm_settings = FrmAppHelper::get_settings();
221
+			$frm_settings = FrmAppHelper::get_settings();
222 222
 			wp_die( $frm_settings->admin_permission );
223
-        }
223
+		}
224 224
 
225
-        global $wpdb, $wp_roles;
225
+		global $wpdb, $wp_roles;
226 226
 
227 227
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->fields ); // WPCS: unprepared SQL ok.
228 228
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->forms ); // WPCS: unprepared SQL ok.
@@ -232,12 +232,12 @@  discard block
 block discarded – undo
232 232
 		delete_option( 'frm_options' );
233 233
 		delete_option( 'frm_db_version' );
234 234
 
235
-        //delete roles
236
-        $frm_roles = FrmAppHelper::frm_capabilities();
237
-        $roles = get_editable_roles();
238
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
239
-            foreach ( $roles as $role => $details ) {
240
-                $wp_roles->remove_cap( $role, $frm_role );
235
+		//delete roles
236
+		$frm_roles = FrmAppHelper::frm_capabilities();
237
+		$roles = get_editable_roles();
238
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
239
+			foreach ( $roles as $role => $details ) {
240
+				$wp_roles->remove_cap( $role, $frm_role );
241 241
 				unset( $role, $details );
242 242
 			}
243 243
 			unset( $frm_role, $frm_role_description );
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) );
266 266
 
267 267
 		do_action( 'frm_after_uninstall' );
268
-        return true;
269
-    }
268
+		return true;
269
+	}
270 270
 
271 271
 	/**
272 272
 	 * Reverse migration 17 -- Divide by 9
@@ -433,44 +433,44 @@  discard block
 block discarded – undo
433 433
 		$size .= 'px';
434 434
 	}
435 435
 
436
-    /**
437
-     * Migrate post and email notification settings into actions
438
-     */
439
-    private function migrate_to_16() {
440
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' );
441
-
442
-        /**
443
-        * Old email settings format:
444
-        * email_to: Email or field id
445
-        * also_email_to: array of fields ids
446
-        * reply_to: Email, field id, 'custom'
447
-        * cust_reply_to: string
448
-        * reply_to_name: field id, 'custom'
449
-        * cust_reply_to_name: string
450
-        * plain_text: 0|1
451
-        * email_message: string or ''
452
-        * email_subject: string or ''
453
-        * inc_user_info: 0|1
454
-        * update_email: 0, 1, 2
455
-        *
456
-        * Old autoresponder settings format:
457
-        * auto_responder: 0|1
458
-        * ar_email_message: string or ''
459
-        * ar_email_to: field id
460
-        * ar_plain_text: 0|1
461
-        * ar_reply_to_name: string
462
-        * ar_reply_to: string
463
-        * ar_email_subject: string
464
-        * ar_update_email: 0, 1, 2
465
-        *
466
-        * New email settings:
467
-        * post_content: json settings
468
-        * post_title: form id
469
-        * post_excerpt: message
470
-        *
471
-        */
472
-
473
-        foreach ( $forms as $form ) {
436
+	/**
437
+	 * Migrate post and email notification settings into actions
438
+	 */
439
+	private function migrate_to_16() {
440
+		$forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' );
441
+
442
+		/**
443
+		 * Old email settings format:
444
+		 * email_to: Email or field id
445
+		 * also_email_to: array of fields ids
446
+		 * reply_to: Email, field id, 'custom'
447
+		 * cust_reply_to: string
448
+		 * reply_to_name: field id, 'custom'
449
+		 * cust_reply_to_name: string
450
+		 * plain_text: 0|1
451
+		 * email_message: string or ''
452
+		 * email_subject: string or ''
453
+		 * inc_user_info: 0|1
454
+		 * update_email: 0, 1, 2
455
+		 *
456
+		 * Old autoresponder settings format:
457
+		 * auto_responder: 0|1
458
+		 * ar_email_message: string or ''
459
+		 * ar_email_to: field id
460
+		 * ar_plain_text: 0|1
461
+		 * ar_reply_to_name: string
462
+		 * ar_reply_to: string
463
+		 * ar_email_subject: string
464
+		 * ar_update_email: 0, 1, 2
465
+		 *
466
+		 * New email settings:
467
+		 * post_content: json settings
468
+		 * post_title: form id
469
+		 * post_excerpt: message
470
+		 *
471
+		 */
472
+
473
+		foreach ( $forms as $form ) {
474 474
 			if ( $form->is_template && $form->default_template ) {
475 475
 				// don't migrate the default templates since the email will be added anyway
476 476
 				continue;
@@ -479,19 +479,19 @@  discard block
 block discarded – undo
479 479
 			// Format form options
480 480
 			$form_options = maybe_unserialize( $form->options );
481 481
 
482
-            // Migrate settings to actions
483
-            FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
484
-        }
485
-    }
482
+			// Migrate settings to actions
483
+			FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
484
+		}
485
+	}
486 486
 
487
-    private function migrate_to_11() {
488
-        global $wpdb;
487
+	private function migrate_to_11() {
488
+		global $wpdb;
489 489
 
490 490
 		$forms = FrmDb::get_results( $this->forms, array(), 'id, options' );
491 491
 
492
-        $sending = __( 'Sending', 'formidable' );
492
+		$sending = __( 'Sending', 'formidable' );
493 493
 		$img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
494
-        $old_default_html = <<<DEFAULT_HTML
494
+		$old_default_html = <<<DEFAULT_HTML
495 495
 <div class="frm_submit">
496 496
 [if back_button]<input type="submit" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" [back_hook] />[/if back_button]
497 497
 <input type="submit" value="[button_label]" [button_action] />
@@ -501,21 +501,21 @@  discard block
 block discarded – undo
501 501
 		unset( $sending, $img );
502 502
 
503 503
 		$new_default_html = FrmFormsHelper::get_default_html( 'submit' );
504
-        $draft_link = FrmFormsHelper::get_draft_link();
504
+		$draft_link = FrmFormsHelper::get_draft_link();
505 505
 		foreach ( $forms as $form ) {
506 506
 			$form->options = maybe_unserialize( $form->options );
507 507
 			if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) {
508
-                continue;
509
-            }
508
+				continue;
509
+			}
510 510
 
511
-            if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
512
-                $form->options['submit_html'] = $new_default_html;
511
+			if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
512
+				$form->options['submit_html'] = $new_default_html;
513 513
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
514 514
 			} else if ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) {
515 515
 				$form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
516 516
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
517
-            }
517
+			}
518 518
 			unset( $form );
519
-        }
520
-    }
519
+		}
520
+	}
521 521
 }
Please login to merge, or discard this patch.
classes/models/FrmEntryMeta.php 1 patch
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -5,23 +5,23 @@  discard block
 block discarded – undo
5 5
 
6 6
 class FrmEntryMeta {
7 7
 
8
-    /**
9
-     * @param string $meta_key
10
-     */
8
+	/**
9
+	 * @param string $meta_key
10
+	 */
11 11
 	public static function add_entry_meta( $entry_id, $field_id, $meta_key = null, $meta_value ) {
12
-        global $wpdb;
12
+		global $wpdb;
13 13
 
14
-        if ( FrmAppHelper::is_empty_value( $meta_value ) ) {
15
-            // don't save blank fields
16
-            return 0;
17
-        }
14
+		if ( FrmAppHelper::is_empty_value( $meta_value ) ) {
15
+			// don't save blank fields
16
+			return 0;
17
+		}
18 18
 
19
-        $new_values = array(
19
+		$new_values = array(
20 20
 			'meta_value'    => is_array( $meta_value ) ? serialize( array_filter( $meta_value, 'FrmAppHelper::is_not_empty_value' ) ) : trim( $meta_value ),
21
-            'item_id'       => $entry_id,
22
-            'field_id'      => $field_id,
21
+			'item_id'       => $entry_id,
22
+			'field_id'      => $field_id,
23 23
 			'created_at'    => current_time( 'mysql', 1 ),
24
-        );
24
+		);
25 25
 
26 26
 		self::set_value_before_save( $new_values );
27 27
 		$new_values = apply_filters( 'frm_add_entry_meta', $new_values );
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
 			$id = 0;
37 37
 		}
38 38
 
39
-        return $id;
40
-    }
39
+		return $id;
40
+	}
41 41
 
42 42
 	/**
43 43
 	 * @param int $entry_id
@@ -48,18 +48,18 @@  discard block
 block discarded – undo
48 48
 	 * @return bool|false|int
49 49
 	 */
50 50
 	public static function update_entry_meta( $entry_id, $field_id, $meta_key = null, $meta_value ) {
51
-        if ( ! $field_id ) {
52
-            return false;
53
-        }
51
+		if ( ! $field_id ) {
52
+			return false;
53
+		}
54 54
 
55
-        global $wpdb;
55
+		global $wpdb;
56 56
 
57 57
 		$values = array(
58 58
 			'item_id'  => $entry_id,
59 59
 			'field_id' => $field_id,
60 60
 		);
61 61
 		$where_values = $values;
62
-        $values['meta_value'] = $meta_value;
62
+		$values['meta_value'] = $meta_value;
63 63
 		self::set_value_before_save( $values );
64 64
 		$values = apply_filters( 'frm_update_entry_meta', $values );
65 65
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		self::clear_cache();
73 73
 
74 74
 		return $wpdb->update( $wpdb->prefix . 'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
75
-    }
75
+	}
76 76
 
77 77
 	/**
78 78
 	 * @since 3.0
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
 	}
102 102
 
103 103
 	public static function update_entry_metas( $entry_id, $values ) {
104
-        global $wpdb;
104
+		global $wpdb;
105 105
 
106 106
 		$prev_values = FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array(
107 107
 			'item_id'    => $entry_id,
108 108
 			'field_id !' => 0,
109 109
 		), 'field_id' );
110 110
 
111
-        foreach ( $values as $field_id => $meta_value ) {
111
+		foreach ( $values as $field_id => $meta_value ) {
112 112
 			$field = false;
113 113
 			if ( ! empty( $field_id ) ) {
114 114
 				$field = FrmField::getOne( $field_id );
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 		// Delete any leftovers
152 152
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas ' . $where['where'], $where['values'] ) ); // WPCS: unprepared SQL ok.
153 153
 		self::clear_cache();
154
-    }
154
+	}
155 155
 
156 156
 	public static function duplicate_entry_metas( $old_id, $new_id ) {
157 157
 		$metas = self::get_entry_meta_info( $old_id );
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
 	}
164 164
 
165 165
 	public static function delete_entry_meta( $entry_id, $field_id ) {
166
-        global $wpdb;
166
+		global $wpdb;
167 167
 		self::clear_cache();
168 168
 		return $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id ) );
169
-    }
169
+	}
170 170
 
171 171
 	/**
172 172
 	 * Clear entry meta caching
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	}
192 192
 
193 193
 	public static function get_entry_meta_by_field( $entry_id, $field_id ) {
194
-        global $wpdb;
194
+		global $wpdb;
195 195
 
196 196
 		if ( is_object( $entry_id ) ) {
197 197
 			$entry = $entry_id;
@@ -205,89 +205,89 @@  discard block
 block discarded – undo
205 205
 		if ( $cached && isset( $cached->metas ) && isset( $cached->metas[ $field_id ] ) ) {
206 206
 			$result = $cached->metas[ $field_id ];
207 207
 			return stripslashes_deep( $result );
208
-        }
208
+		}
209 209
 
210 210
 		$get_table = $wpdb->prefix . 'frm_item_metas';
211 211
 		$query = array( 'item_id' => $entry_id );
212 212
 		if ( is_numeric( $field_id ) ) {
213 213
 			$query['field_id'] = $field_id;
214
-        } else {
214
+		} else {
215 215
 			$get_table .= ' it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
216 216
 			$query['fi.field_key'] = $field_id;
217
-        }
217
+		}
218 218
 
219 219
 		$result = FrmDb::get_var( $get_table, $query, 'meta_value' );
220 220
 		$result = maybe_unserialize( $result );
221 221
 		$result = stripslashes_deep( $result );
222 222
 
223
-        return $result;
224
-    }
223
+		return $result;
224
+	}
225 225
 
226
-    public static function get_entry_metas_for_field( $field_id, $order = '', $limit = '', $args = array() ) {
226
+	public static function get_entry_metas_for_field( $field_id, $order = '', $limit = '', $args = array() ) {
227 227
 		$defaults = array(
228 228
 			'value'    => false,
229 229
 			'unique'   => false,
230 230
 			'stripslashes' => true,
231 231
 			'is_draft' => false,
232 232
 		);
233
-        $args = wp_parse_args( $args, $defaults );
233
+		$args = wp_parse_args( $args, $defaults );
234 234
 
235
-        $query = array();
235
+		$query = array();
236 236
 		self::meta_field_query( $field_id, $order, $limit, $args, $query );
237 237
 		$query = implode( ' ', $query );
238 238
 
239 239
 		$cache_key = 'entry_metas_for_field_' . $field_id . $order . $limit . maybe_serialize( $args );
240 240
 		$values = FrmDb::check_cache( $cache_key, 'frm_entry', $query, 'get_col' );
241 241
 
242
-        if ( ! $args['stripslashes'] ) {
243
-            return $values;
244
-        }
242
+		if ( ! $args['stripslashes'] ) {
243
+			return $values;
244
+		}
245 245
 
246 246
 		foreach ( $values as $k => $v ) {
247 247
 			$values[ $k ] = maybe_unserialize( $v );
248 248
 			unset( $k, $v );
249
-        }
249
+		}
250 250
 
251 251
 		return stripslashes_deep( $values );
252
-    }
252
+	}
253 253
 
254
-    /**
255
-     * @param string $order
256
-     * @param string $limit
257
-     */
254
+	/**
255
+	 * @param string $order
256
+	 * @param string $limit
257
+	 */
258 258
 	private static function meta_field_query( $field_id, $order, $limit, $args, array &$query ) {
259
-        global $wpdb;
260
-        $query[] = 'SELECT';
261
-        $query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value';
259
+		global $wpdb;
260
+		$query[] = 'SELECT';
261
+		$query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value';
262 262
 		$query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas em ';
263 263
 
264
-        if ( ! $args['is_draft'] ) {
264
+		if ( ! $args['is_draft'] ) {
265 265
 			$query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=em.item_id)';
266
-        }
266
+		}
267 267
 
268 268
 		if ( is_numeric( $field_id ) ) {
269 269
 			$query[] = $wpdb->prepare( 'WHERE em.field_id=%d', $field_id );
270 270
 		} else {
271 271
 			$query[] = $wpdb->prepare( 'LEFT JOIN ' . $wpdb->prefix . 'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id );
272
-        }
272
+		}
273 273
 
274
-        if ( ! $args['is_draft'] ) {
275
-            $query[] = 'AND e.is_draft=0';
276
-        }
274
+		if ( ! $args['is_draft'] ) {
275
+			$query[] = 'AND e.is_draft=0';
276
+		}
277 277
 
278
-        if ( $args['value'] ) {
278
+		if ( $args['value'] ) {
279 279
 			$query[] = $wpdb->prepare( ' AND meta_value=%s', $args['value'] );
280
-        }
281
-        $query[] = $order . $limit;
282
-    }
280
+		}
281
+		$query[] = $order . $limit;
282
+	}
283 283
 
284 284
 	public static function get_entry_meta_info( $entry_id ) {
285 285
 		return FrmDb::get_results( 'frm_item_metas', array( 'item_id' => $entry_id ) );
286
-    }
286
+	}
287 287
 
288 288
 	public static function getAll( $where = array(), $order_by = '', $limit = '', $stripslashes = false ) {
289
-        global $wpdb;
290
-        $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key,
289
+		global $wpdb;
290
+		$query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key,
291 291
             fi.required as required, fi.form_id as field_form_id, fi.name as field_name, fi.options as fi_options
292 292
 			FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id' .
293 293
 			FrmDb::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
@@ -305,9 +305,9 @@  discard block
 block discarded – undo
305 305
 		}
306 306
 
307 307
 		return $results;
308
-    }
308
+	}
309 309
 
310
-    public static function getEntryIds( $where = array(), $order_by = '', $limit = '', $unique = true, $args = array() ) {
310
+	public static function getEntryIds( $where = array(), $order_by = '', $limit = '', $unique = true, $args = array() ) {
311 311
 		$defaults = array(
312 312
 			'is_draft' => false,
313 313
 			'user_id'  => '',
@@ -315,22 +315,22 @@  discard block
 block discarded – undo
315 315
 		);
316 316
 		$args = wp_parse_args( $args, $defaults );
317 317
 
318
-        $query = array();
318
+		$query = array();
319 319
 		self::get_ids_query( $where, $order_by, $limit, $unique, $args, $query );
320 320
 		$query = implode( ' ', $query );
321 321
 
322 322
 		$cache_key = 'ids_' . maybe_serialize( $where ) . $order_by . 'l' . $limit . 'u' . $unique . maybe_serialize( $args );
323 323
 		return FrmDb::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_var' : 'get_col' ) );
324
-    }
324
+	}
325 325
 
326
-    /**
327
-     * @param string|array $where
328
-     * @param string $order_by
329
-     * @param string $limit
330
-     */
326
+	/**
327
+	 * @param string|array $where
328
+	 * @param string $order_by
329
+	 * @param string $limit
330
+	 */
331 331
 	private static function get_ids_query( $where, $order_by, $limit, $unique, $args, array &$query ) {
332
-        global $wpdb;
333
-        $query[] = 'SELECT';
332
+		global $wpdb;
333
+		$query[] = 'SELECT';
334 334
 
335 335
 		$defaults = array( 'return_parent_id' => false );
336 336
 		$args = array_merge( $defaults, $args );
@@ -345,30 +345,30 @@  discard block
 block discarded – undo
345 345
 
346 346
 		$query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=it.item_id)';
347 347
 		if ( is_array( $where ) ) {
348
-            if ( ! $args['is_draft'] ) {
349
-                $where['e.is_draft'] = 0;
350
-            } else if ( $args['is_draft'] == 1 ) {
351
-                $where['e.is_draft'] = 1;
352
-            }
348
+			if ( ! $args['is_draft'] ) {
349
+				$where['e.is_draft'] = 0;
350
+			} else if ( $args['is_draft'] == 1 ) {
351
+				$where['e.is_draft'] = 1;
352
+			}
353 353
 
354 354
 			if ( ! empty( $args['user_id'] ) ) {
355
-                $where['e.user_id'] = $args['user_id'];
356
-            }
355
+				$where['e.user_id'] = $args['user_id'];
356
+			}
357 357
 			$query[] = FrmDb::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
358 358
 
359 359
 			if ( $args['group_by'] ) {
360 360
 				$query[] = ' GROUP BY ' . sanitize_text_field( $args['group_by'] );
361 361
 			}
362
-            return;
363
-        }
362
+			return;
363
+		}
364 364
 
365 365
 		$draft_where = '';
366 366
 		$user_where = '';
367
-        if ( ! $args['is_draft'] ) {
367
+		if ( ! $args['is_draft'] ) {
368 368
 			$draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 0 );
369
-        } else if ( $args['is_draft'] == 1 ) {
369
+		} else if ( $args['is_draft'] == 1 ) {
370 370
 			$draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 1 );
371
-        }
371
+		}
372 372
 
373 373
 		if ( ! empty( $args['user_id'] ) ) {
374 374
 			$user_where = $wpdb->prepare( ' AND e.user_id=%d', $args['user_id'] );
@@ -377,56 +377,56 @@  discard block
 block discarded – undo
377 377
 		if ( strpos( $where, ' GROUP BY ' ) ) {
378 378
 			// don't inject WHERE filtering after GROUP BY
379 379
 			$parts = explode( ' GROUP BY ', $where );
380
-            $where = $parts[0];
381
-            $where .= $draft_where . $user_where;
380
+			$where = $parts[0];
381
+			$where .= $draft_where . $user_where;
382 382
 			$where .= ' GROUP BY ' . $parts[1];
383
-        } else {
384
-            $where .= $draft_where . $user_where;
385
-        }
383
+		} else {
384
+			$where .= $draft_where . $user_where;
385
+		}
386 386
 
387 387
 		// The query has already been prepared
388 388
 		$query[] = FrmDb::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
389
-    }
389
+	}
390 390
 
391
-    public static function search_entry_metas( $search, $field_id = '', $operator ) {
391
+	public static function search_entry_metas( $search, $field_id = '', $operator ) {
392 392
 		$cache_key = 'search_' . maybe_serialize( $search ) . $field_id . $operator;
393 393
 		$results = wp_cache_get( $cache_key, 'frm_entry' );
394
-        if ( false !== $results ) {
395
-            return $results;
396
-        }
394
+		if ( false !== $results ) {
395
+			return $results;
396
+		}
397 397
 
398
-        global $wpdb;
398
+		global $wpdb;
399 399
 		if ( is_array( $search ) ) {
400
-            $where = '';
400
+			$where = '';
401 401
 			foreach ( $search as $field => $value ) {
402 402
 				if ( $value <= 0 || ! in_array( $field, array( 'year', 'month', 'day' ) ) ) {
403
-                    continue;
404
-                }
403
+					continue;
404
+				}
405 405
 
406
-                switch ( $field ) {
407
-                    case 'year':
406
+				switch ( $field ) {
407
+					case 'year':
408 408
 						$value = '%' . $value;
409 409
 						break;
410
-                    case 'month':
411
-                        $value .= '%';
410
+					case 'month':
411
+						$value .= '%';
412 412
 						break;
413
-                    case 'day':
413
+					case 'day':
414 414
 						$value = '%' . $value . '%';
415
-                }
415
+				}
416 416
 				$where .= $wpdb->prepare( ' meta_value ' . $operator . ' %s and', $value ); // WPCS: unprepared SQL ok.
417
-            }
417
+			}
418 418
 			$where .= $wpdb->prepare( ' field_id=%d', $field_id );
419 419
 			$query = 'SELECT DISTINCT item_id FROM ' . $wpdb->prefix . 'frm_item_metas' . FrmDb::prepend_and_or_where( ' WHERE ', $where );
420
-        } else {
420
+		} else {
421 421
 			if ( $operator == 'LIKE' ) {
422
-                $search = '%' . $search . '%';
422
+				$search = '%' . $search . '%';
423 423
 			}
424 424
 			$query = $wpdb->prepare( "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id ); // WPCS: unprepared SQL ok.
425
-        }
425
+		}
426 426
 
427 427
 		$results = $wpdb->get_col( $query, 0 ); // WPCS: unprepared SQL ok.
428 428
 		FrmDb::set_cache( $cache_key, $results, 'frm_entry' );
429 429
 
430
-        return $results;
431
-    }
430
+		return $results;
431
+	}
432 432
 }
Please login to merge, or discard this patch.
classes/models/FrmForm.php 3 patches
Indentation   +225 added lines, -225 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-    die( 'You are not allowed to call this page directly.' );
3
+	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
6 6
 class FrmForm {
7 7
 
8
-    /**
9
-     * @return int|boolean id on success or false on failure
10
-     */
11
-    public static function create( $values ) {
12
-        global $wpdb;
8
+	/**
9
+	 * @return int|boolean id on success or false on failure
10
+	 */
11
+	public static function create( $values ) {
12
+		global $wpdb;
13 13
 
14 14
 		$new_values = array(
15 15
 			'form_key'      => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ),
@@ -34,52 +34,52 @@  discard block
 block discarded – undo
34 34
 		$options = apply_filters( 'frm_form_options_before_update', $options, $values );
35 35
 		$new_values['options'] = serialize( $options );
36 36
 
37
-        //if(isset($values['id']) && is_numeric($values['id']))
38
-        //    $new_values['id'] = $values['id'];
37
+		//if(isset($values['id']) && is_numeric($values['id']))
38
+		//    $new_values['id'] = $values['id'];
39 39
 
40 40
 		$wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
41 41
 
42
-        $id = $wpdb->insert_id;
42
+		$id = $wpdb->insert_id;
43 43
 
44 44
 		// Clear form caching
45 45
 		self::clear_form_cache();
46 46
 
47
-        return $id;
48
-    }
47
+		return $id;
48
+	}
49 49
 
50
-    /**
51
-     * @return int|boolean ID on success or false on failure
52
-     */
53
-    public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) {
54
-        global $wpdb;
50
+	/**
51
+	 * @return int|boolean ID on success or false on failure
52
+	 */
53
+	public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) {
54
+		global $wpdb;
55 55
 
56
-        $values = self::getOne( $id, $blog_id );
57
-        if ( ! $values ) {
58
-            return false;
59
-        }
56
+		$values = self::getOne( $id, $blog_id );
57
+		if ( ! $values ) {
58
+			return false;
59
+		}
60 60
 
61
-        $new_key = $copy_keys ? $values->form_key : '';
61
+		$new_key = $copy_keys ? $values->form_key : '';
62 62
 
63
-        $new_values = array(
63
+		$new_values = array(
64 64
 			'form_key'      => FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_forms', 'form_key' ),
65
-            'name'          => $values->name,
66
-            'description'   => $values->description,
67
-            'status'        => $template ? 'published' : 'draft',
68
-            'logged_in'     => $values->logged_in ? $values->logged_in : 0,
69
-            'editable'      => $values->editable ? $values->editable : 0,
65
+			'name'          => $values->name,
66
+			'description'   => $values->description,
67
+			'status'        => $template ? 'published' : 'draft',
68
+			'logged_in'     => $values->logged_in ? $values->logged_in : 0,
69
+			'editable'      => $values->editable ? $values->editable : 0,
70 70
 			'created_at'    => current_time( 'mysql', 1 ),
71
-            'is_template'   => $template ? 1 : 0,
72
-        );
71
+			'is_template'   => $template ? 1 : 0,
72
+		);
73 73
 
74
-        if ( $blog_id ) {
75
-            $new_values['status'] = 'published';
74
+		if ( $blog_id ) {
75
+			$new_values['status'] = 'published';
76 76
 			$new_options = maybe_unserialize( $values->options );
77 77
 			$new_options['email_to'] = get_option( 'admin_email' );
78
-            $new_options['copy'] = false;
79
-            $new_values['options'] = $new_options;
80
-        } else {
81
-            $new_values['options'] = $values->options;
82
-        }
78
+			$new_options['copy'] = false;
79
+			$new_values['options'] = $new_options;
80
+		} else {
81
+			$new_values['options'] = $values->options;
82
+		}
83 83
 
84 84
 		if ( is_array( $new_values['options'] ) ) {
85 85
 			$new_values['options'] = serialize( $new_values['options'] );
@@ -87,20 +87,20 @@  discard block
 block discarded – undo
87 87
 
88 88
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
89 89
 
90
-        if ( $query_results ) {
90
+		if ( $query_results ) {
91 91
 			// Clear form caching
92 92
 			self::clear_form_cache();
93 93
 
94
-            $form_id = $wpdb->insert_id;
94
+			$form_id = $wpdb->insert_id;
95 95
 			FrmField::duplicate( $id, $form_id, $copy_keys, $blog_id );
96 96
 
97
-            // update form settings after fields are created
97
+			// update form settings after fields are created
98 98
 			do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) );
99
-            return $form_id;
100
-        }
99
+			return $form_id;
100
+		}
101 101
 
102
-        return false;
103
-    }
102
+		return false;
103
+	}
104 104
 
105 105
 	public static function after_duplicate( $form_id, $values ) {
106 106
 		$new_opts = maybe_unserialize( $values['options'] );
@@ -112,48 +112,48 @@  discard block
 block discarded – undo
112 112
 
113 113
 		$new_opts = apply_filters( 'frm_after_duplicate_form_values', $new_opts, $form_id );
114 114
 
115
-        if ( $new_opts != $values['options'] ) {
116
-            global $wpdb;
115
+		if ( $new_opts != $values['options'] ) {
116
+			global $wpdb;
117 117
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $new_opts ) ), array( 'id' => $form_id ) );
118
-        }
119
-    }
118
+		}
119
+	}
120 120
 
121
-    /**
122
-     * @return int|boolean
123
-     */
124
-    public static function update( $id, $values, $create_link = false ) {
125
-        global $wpdb;
121
+	/**
122
+	 * @return int|boolean
123
+	 */
124
+	public static function update( $id, $values, $create_link = false ) {
125
+		global $wpdb;
126 126
 
127
-        if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) {
128
-            $values['status'] = 'published';
129
-        }
127
+		if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) {
128
+			$values['status'] = 'published';
129
+		}
130 130
 
131 131
 		if ( isset( $values['form_key'] ) ) {
132 132
 			$values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id );
133
-        }
133
+		}
134 134
 
135 135
 		$form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
136 136
 
137 137
 		$new_values = self::set_update_options( array(), $values );
138 138
 
139
-        foreach ( $values as $value_key => $value ) {
139
+		foreach ( $values as $value_key => $value ) {
140 140
 			if ( $value_key && in_array( $value_key, $form_fields ) ) {
141 141
 				$new_values[ $value_key ] = $value;
142
-            }
143
-        }
142
+			}
143
+		}
144 144
 
145
-        if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) {
146
-            $new_values['status'] = $values['new_status'];
147
-        }
145
+		if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) {
146
+			$new_values['status'] = $values['new_status'];
147
+		}
148 148
 
149
-        if ( ! empty( $new_values ) ) {
149
+		if ( ! empty( $new_values ) ) {
150 150
 			$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $id ) );
151
-            if ( $query_results ) {
151
+			if ( $query_results ) {
152 152
 				self::clear_form_cache();
153
-            }
154
-        } else {
155
-            $query_results = true;
156
-        }
153
+			}
154
+		} else {
155
+			$query_results = true;
156
+		}
157 157
 		unset( $new_values );
158 158
 
159 159
 		$values = self::update_fields( $id, $values );
@@ -161,16 +161,16 @@  discard block
 block discarded – undo
161 161
 		do_action( 'frm_update_form', $id, $values );
162 162
 		do_action( 'frm_update_form_' . $id, $values );
163 163
 
164
-        return $query_results;
165
-    }
164
+		return $query_results;
165
+	}
166 166
 
167
-    /**
168
-     * @return array
169
-     */
167
+	/**
168
+	 * @return array
169
+	 */
170 170
 	public static function set_update_options( $new_values, $values ) {
171 171
 		if ( ! isset( $values['options'] ) ) {
172
-            return $new_values;
173
-        }
172
+			return $new_values;
173
+		}
174 174
 
175 175
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
176 176
 		FrmFormsHelper::fill_form_options( $options, $values );
@@ -184,17 +184,17 @@  discard block
 block discarded – undo
184 184
 		$new_values['options'] = serialize( $options );
185 185
 
186 186
 		return $new_values;
187
-    }
187
+	}
188 188
 
189 189
 
190
-    /**
191
-     * @return array
192
-     */
190
+	/**
191
+	 * @return array
192
+	 */
193 193
 	public static function update_fields( $id, $values ) {
194 194
 
195 195
 		if ( ! isset( $values['item_meta'] ) && ! isset( $values['field_options'] ) ) {
196
-            return $values;
197
-        }
196
+			return $values;
197
+		}
198 198
 
199 199
 		$all_fields = FrmField::get_all_for_form( $id );
200 200
 		if ( empty( $all_fields ) ) {
@@ -205,26 +205,26 @@  discard block
 block discarded – undo
205 205
 			$values['item_meta'] = array();
206 206
 		}
207 207
 
208
-        $field_array = array();
209
-        $existing_keys = array_keys( $values['item_meta'] );
210
-        foreach ( $all_fields as $fid ) {
208
+		$field_array = array();
209
+		$existing_keys = array_keys( $values['item_meta'] );
210
+		foreach ( $all_fields as $fid ) {
211 211
 			if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) {
212 212
 				$values['item_meta'][ $fid->id ] = '';
213
-            }
213
+			}
214 214
 			$field_array[ $fid->id ] = $fid;
215
-        }
215
+		}
216 216
 		unset( $all_fields );
217 217
 
218
-        foreach ( $values['item_meta'] as $field_id => $default_value ) {
218
+		foreach ( $values['item_meta'] as $field_id => $default_value ) {
219 219
 			if ( isset( $field_array[ $field_id ] ) ) {
220 220
 				$field = $field_array[ $field_id ];
221
-            } else {
221
+			} else {
222 222
 				$field = FrmField::getOne( $field_id );
223
-            }
223
+			}
224 224
 
225
-            if ( ! $field ) {
226
-                continue;
227
-            }
225
+			if ( ! $field ) {
226
+				continue;
227
+			}
228 228
 
229 229
 			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) );
230 230
 			if ( $is_settings_page ) {
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 				if ( is_string( $field->field_options[ $opt ] ) ) {
246 246
 					$field->field_options[ $opt ] = trim( FrmAppHelper::kses( $field->field_options[ $opt ], 'all' ) );
247 247
 				}
248
-            }
248
+			}
249 249
 
250 250
 			$field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values );
251 251
 			$default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
@@ -260,11 +260,11 @@  discard block
 block discarded – undo
260 260
 			FrmField::update( $field_id, $new_field );
261 261
 
262 262
 			FrmField::delete_form_transient( $field->form_id );
263
-        }
263
+		}
264 264
 		self::clear_form_cache();
265 265
 
266
-        return $values;
267
-    }
266
+		return $values;
267
+	}
268 268
 
269 269
 	/**
270 270
 	 * updating the settings page
@@ -301,21 +301,21 @@  discard block
 block discarded – undo
301 301
 		}
302 302
 	}
303 303
 
304
-    /**
305
-     * @param string $status
306
-     * @return int|boolean
307
-     */
304
+	/**
305
+	 * @param string $status
306
+	 * @return int|boolean
307
+	 */
308 308
 	public static function set_status( $id, $status ) {
309
-        if ( 'trash' == $status ) {
309
+		if ( 'trash' == $status ) {
310 310
 			return self::trash( $id );
311
-        }
311
+		}
312 312
 
313 313
 		$statuses  = array( 'published', 'draft', 'trash' );
314
-        if ( ! in_array( $status, $statuses ) ) {
315
-            return false;
316
-        }
314
+		if ( ! in_array( $status, $statuses ) ) {
315
+			return false;
316
+		}
317 317
 
318
-        global $wpdb;
318
+		global $wpdb;
319 319
 
320 320
 		if ( is_array( $id ) ) {
321 321
 			$where = array(
@@ -327,33 +327,33 @@  discard block
 block discarded – undo
327 327
 			array_unshift( $where['values'], $status );
328 328
 
329 329
 			$query_results = $wpdb->query( $wpdb->prepare( 'UPDATE ' . $wpdb->prefix . 'frm_forms SET status = %s ' . $where['where'], $where['values'] ) ); // WPCS: unprepared SQL ok.
330
-        } else {
330
+		} else {
331 331
 			$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'id' => $id ) );
332 332
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'parent_form_id' => $id ) );
333
-        }
333
+		}
334 334
 
335
-        if ( $query_results ) {
335
+		if ( $query_results ) {
336 336
 			self::clear_form_cache();
337
-        }
337
+		}
338 338
 
339
-        return $query_results;
340
-    }
339
+		return $query_results;
340
+	}
341 341
 
342
-    /**
343
-     * @return int|boolean
344
-     */
342
+	/**
343
+	 * @return int|boolean
344
+	 */
345 345
 	public static function trash( $id ) {
346
-        if ( ! EMPTY_TRASH_DAYS ) {
347
-            return self::destroy( $id );
348
-        }
346
+		if ( ! EMPTY_TRASH_DAYS ) {
347
+			return self::destroy( $id );
348
+		}
349 349
 
350 350
 		$form = self::getOne( $id );
351
-        if ( ! $form ) {
352
-            return false;
353
-        }
351
+		if ( ! $form ) {
352
+			return false;
353
+		}
354 354
 
355
-        $options = $form->options;
356
-        $options['trash_time'] = time();
355
+		$options = $form->options;
356
+		$options['trash_time'] = time();
357 357
 
358 358
 		global $wpdb;
359 359
 		$query_results = $wpdb->update(
@@ -378,39 +378,39 @@  discard block
 block discarded – undo
378 378
 			)
379 379
 		);
380 380
 
381
-        if ( $query_results ) {
381
+		if ( $query_results ) {
382 382
 			self::clear_form_cache();
383
-        }
383
+		}
384 384
 
385
-        return $query_results;
386
-    }
385
+		return $query_results;
386
+	}
387 387
 
388
-    /**
389
-     * @return int|boolean
390
-     */
388
+	/**
389
+	 * @return int|boolean
390
+	 */
391 391
 	public static function destroy( $id ) {
392
-        global $wpdb;
392
+		global $wpdb;
393 393
 
394 394
 		$form = self::getOne( $id );
395
-        if ( ! $form ) {
396
-            return false;
397
-        }
395
+		if ( ! $form ) {
396
+			return false;
397
+		}
398 398
 		$id = $form->id;
399 399
 
400
-        // Disconnect the entries from this form
400
+		// Disconnect the entries from this form
401 401
 		$entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) );
402 402
 		foreach ( $entries as $entry_id ) {
403 403
 			FrmEntry::destroy( $entry_id );
404 404
 			unset( $entry_id );
405 405
 		}
406 406
 
407
-        // Disconnect the fields from this form
407
+		// Disconnect the fields from this form
408 408
 		$wpdb->query( $wpdb->prepare( 'DELETE fi FROM ' . $wpdb->prefix . 'frm_fields AS fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id) WHERE fi.form_id=%d OR parent_form_id=%d', $id, $id ) );
409 409
 
410 410
 		$query_results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id ) );
411
-        if ( $query_results ) {
412
-            // Delete all form actions linked to this form
413
-            $action_control = FrmFormActionsController::get_form_actions( 'email' );
411
+		if ( $query_results ) {
412
+			// Delete all form actions linked to this form
413
+			$action_control = FrmFormActionsController::get_form_actions( 'email' );
414 414
 			$action_control->destroy( $id, 'all' );
415 415
 
416 416
 			// Clear form caching
@@ -418,10 +418,10 @@  discard block
 block discarded – undo
418 418
 
419 419
 			do_action( 'frm_destroy_form', $id );
420 420
 			do_action( 'frm_destroy_form_' . $id );
421
-        }
421
+		}
422 422
 
423
-        return $query_results;
424
-    }
423
+		return $query_results;
424
+	}
425 425
 
426 426
 	/**
427 427
 	 * Delete trashed forms based on how long they have been trashed
@@ -453,60 +453,60 @@  discard block
 block discarded – undo
453 453
 		return $count;
454 454
 	}
455 455
 
456
-    /**
457
-     * @return string form name
458
-     */
459
-    public static function getName( $id ) {
456
+	/**
457
+	 * @return string form name
458
+	 */
459
+	public static function getName( $id ) {
460 460
 		$form = FrmDb::check_cache( $id, 'frm_form' );
461
-        if ( $form ) {
461
+		if ( $form ) {
462 462
 			$r = stripslashes( $form->name );
463
-            return $r;
464
-        }
463
+			return $r;
464
+		}
465 465
 
466
-        $query_key = is_numeric( $id ) ? 'id' : 'form_key';
467
-        $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
466
+		$query_key = is_numeric( $id ) ? 'id' : 'form_key';
467
+		$r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
468 468
 		$r = stripslashes( $r );
469 469
 
470
-        return $r;
471
-    }
470
+		return $r;
471
+	}
472 472
 
473
-    /**
473
+	/**
474 474
 	 * @since 3.0
475
-     * @param string $key
476
-     * @return int form id
477
-     */
475
+	 * @param string $key
476
+	 * @return int form id
477
+	 */
478 478
 	public static function get_id_by_key( $key ) {
479 479
 		return (int) FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) );
480
-    }
480
+	}
481 481
 
482 482
 	/**
483 483
 	 * @deprecated 3.0
484 484
 	 * @codeCoverageIgnore
485 485
 	 *
486
-     * @param string $key
487
-     * @return int form id
488
-     */
486
+	 * @param string $key
487
+	 * @return int form id
488
+	 */
489 489
 	public static function getIdByKey( $key ) {
490 490
 		_deprecated_function( __METHOD__, '3.0', 'FrmForm::get_id_by_key' );
491 491
 		return self::get_id_by_key( $key );
492
-    }
492
+	}
493 493
 
494
-    /**
494
+	/**
495 495
 	 * @since 3.0
496
-     * @param int $id
497
-     * @return string form key
498
-     */
496
+	 * @param int $id
497
+	 * @return string form key
498
+	 */
499 499
 	public static function get_key_by_id( $id ) {
500
-        $id = (int) $id;
500
+		$id = (int) $id;
501 501
 		$cache = FrmDb::check_cache( $id, 'frm_form' );
502
-        if ( $cache ) {
503
-            return $cache->form_key;
504
-        }
502
+		if ( $cache ) {
503
+			return $cache->form_key;
504
+		}
505 505
 
506
-        $key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' );
506
+		$key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' );
507 507
 
508
-        return $key;
509
-    }
508
+		return $key;
509
+	}
510 510
 
511 511
 	/**
512 512
 	 * @deprecated 3.0
@@ -528,47 +528,47 @@  discard block
 block discarded – undo
528 528
 		}
529 529
 	}
530 530
 
531
-    /**
532
-     * @return object form
533
-     */
534
-    public static function getOne( $id, $blog_id = false ) {
535
-        global $wpdb;
531
+	/**
532
+	 * @return object form
533
+	 */
534
+	public static function getOne( $id, $blog_id = false ) {
535
+		global $wpdb;
536 536
 
537
-        if ( $blog_id && is_multisite() ) {
538
-            global $wpmuBaseTablePrefix;
537
+		if ( $blog_id && is_multisite() ) {
538
+			global $wpmuBaseTablePrefix;
539 539
 			$prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix . $blog_id . '_' : $wpdb->get_blog_prefix( $blog_id );
540 540
 
541 541
 			$table_name = $prefix . 'frm_forms';
542
-        } else {
542
+		} else {
543 543
 			$table_name = $wpdb->prefix . 'frm_forms';
544 544
 			$cache = wp_cache_get( $id, 'frm_form' );
545
-            if ( $cache ) {
545
+			if ( $cache ) {
546 546
 				if ( isset( $cache->options ) ) {
547 547
 					$cache->options = maybe_unserialize( $cache->options );
548
-                }
548
+				}
549 549
 
550 550
 				return stripslashes_deep( $cache );
551
-            }
552
-        }
551
+			}
552
+		}
553 553
 
554 554
 		if ( is_numeric( $id ) ) {
555
-            $where = array( 'id' => $id );
556
-        } else {
557
-            $where = array( 'form_key' => $id );
558
-        }
555
+			$where = array( 'id' => $id );
556
+		} else {
557
+			$where = array( 'form_key' => $id );
558
+		}
559 559
 
560
-        $results = FrmDb::get_row( $table_name, $where );
560
+		$results = FrmDb::get_row( $table_name, $where );
561 561
 
562 562
 		if ( isset( $results->options ) ) {
563 563
 			FrmDb::set_cache( $results->id, $results, 'frm_form' );
564 564
 			$results->options = maybe_unserialize( $results->options );
565
-        }
565
+		}
566 566
 		return stripslashes_deep( $results );
567
-    }
567
+	}
568 568
 
569
-    /**
570
-     * @return object|array of objects
571
-     */
569
+	/**
570
+	 * @return object|array of objects
571
+	 */
572 572
 	public static function getAll( $where = array(), $order_by = '', $limit = '' ) {
573 573
 		if ( is_array( $where ) && ! empty( $where ) ) {
574 574
 			$results = FrmDb::get_results( 'frm_forms', $where, '*', array(
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 		}
597 597
 
598 598
 		return stripslashes_deep( $results );
599
-    }
599
+	}
600 600
 
601 601
 	/**
602 602
 	 * Get all published forms
@@ -614,18 +614,18 @@  discard block
 block discarded – undo
614 614
 		return $forms;
615 615
 	}
616 616
 
617
-    /**
618
-     * @return int count of forms
619
-     */
620
-    public static function get_count() {
621
-    	global $wpdb;
617
+	/**
618
+	 * @return int count of forms
619
+	 */
620
+	public static function get_count() {
621
+		global $wpdb;
622 622
 
623
-    	$cache_key = 'frm_form_counts';
623
+		$cache_key = 'frm_form_counts';
624 624
 
625
-    	$counts = wp_cache_get( $cache_key, 'frm_form' );
626
-    	if ( false !== $counts ) {
627
-    	    return $counts;
628
-    	}
625
+		$counts = wp_cache_get( $cache_key, 'frm_form' );
626
+		if ( false !== $counts ) {
627
+			return $counts;
628
+		}
629 629
 
630 630
 		$results = (array) FrmDb::get_results( 'frm_forms', array(
631 631
 			'or' => 1,
@@ -634,31 +634,31 @@  discard block
 block discarded – undo
634 634
 		), 'status, is_template' );
635 635
 
636 636
 		$statuses = array( 'published', 'draft', 'template', 'trash' );
637
-    	$counts = array_fill_keys( $statuses, 0 );
637
+		$counts = array_fill_keys( $statuses, 0 );
638 638
 
639
-    	foreach ( $results as $row ) {
640
-            if ( 'trash' != $row->status ) {
641
-    	        if ( $row->is_template ) {
639
+		foreach ( $results as $row ) {
640
+			if ( 'trash' != $row->status ) {
641
+				if ( $row->is_template ) {
642 642
 					$counts['template']++;
643
-    	        } else {
643
+				} else {
644 644
 					$counts['published']++;
645
-    	        }
646
-    	    } else {
645
+				}
646
+			} else {
647 647
 				$counts['trash']++;
648
-        	}
648
+			}
649 649
 
650
-    	    if ( 'draft' == $row->status ) {
650
+			if ( 'draft' == $row->status ) {
651 651
 				$counts['draft']++;
652
-    	    }
652
+			}
653 653
 
654 654
 			unset( $row );
655
-    	}
655
+		}
656 656
 
657
-    	$counts = (object) $counts;
657
+		$counts = (object) $counts;
658 658
 		FrmDb::set_cache( $cache_key, $counts, 'frm_form' );
659 659
 
660
-    	return $counts;
661
-    }
660
+		return $counts;
661
+	}
662 662
 
663 663
 	/**
664 664
 	 * Clear form caching
@@ -671,14 +671,14 @@  discard block
 block discarded – undo
671 671
 		FrmDb::cache_delete_group( 'frm_form' );
672 672
 	}
673 673
 
674
-    /**
675
-     * @return array of errors
676
-     */
674
+	/**
675
+	 * @return array of errors
676
+	 */
677 677
 	public static function validate( $values ) {
678
-        $errors = array();
678
+		$errors = array();
679 679
 
680 680
 		return apply_filters( 'frm_validate_form', $errors, $values );
681
-    }
681
+	}
682 682
 
683 683
 	public static function get_params( $form = null ) {
684 684
 		global $frm_vars;
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 
139 139
         foreach ( $values as $value_key => $value ) {
140 140
 			if ( $value_key && in_array( $value_key, $form_fields ) ) {
141
-				$new_values[ $value_key ] = $value;
141
+				$new_values[$value_key] = $value;
142 142
             }
143 143
         }
144 144
 
@@ -209,15 +209,15 @@  discard block
 block discarded – undo
209 209
         $existing_keys = array_keys( $values['item_meta'] );
210 210
         foreach ( $all_fields as $fid ) {
211 211
 			if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) {
212
-				$values['item_meta'][ $fid->id ] = '';
212
+				$values['item_meta'][$fid->id] = '';
213 213
             }
214
-			$field_array[ $fid->id ] = $fid;
214
+			$field_array[$fid->id] = $fid;
215 215
         }
216 216
 		unset( $all_fields );
217 217
 
218 218
         foreach ( $values['item_meta'] as $field_id => $default_value ) {
219
-			if ( isset( $field_array[ $field_id ] ) ) {
220
-				$field = $field_array[ $field_id ];
219
+			if ( isset( $field_array[$field_id] ) ) {
220
+				$field = $field_array[$field_id];
221 221
             } else {
222 222
 				$field = FrmField::getOne( $field_id );
223 223
             }
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
                 continue;
227 227
             }
228 228
 
229
-			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) );
229
+			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) );
230 230
 			if ( $is_settings_page ) {
231 231
 				self::get_settings_page_html( $values, $field );
232 232
 
@@ -241,14 +241,14 @@  discard block
 block discarded – undo
241 241
 			$update_options = apply_filters( 'frm_field_options_to_update', $update_options );
242 242
 
243 243
 			foreach ( $update_options as $opt => $default ) {
244
-				$field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? $values['field_options'][ $opt . '_' . $field_id ] : $default;
245
-				if ( is_string( $field->field_options[ $opt ] ) ) {
246
-					$field->field_options[ $opt ] = trim( FrmAppHelper::kses( $field->field_options[ $opt ], 'all' ) );
244
+				$field->field_options[$opt] = isset( $values['field_options'][$opt . '_' . $field_id] ) ? $values['field_options'][$opt . '_' . $field_id] : $default;
245
+				if ( is_string( $field->field_options[$opt] ) ) {
246
+					$field->field_options[$opt] = trim( FrmAppHelper::kses( $field->field_options[$opt], 'all' ) );
247 247
 				}
248 248
             }
249 249
 
250 250
 			$field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values );
251
-			$default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
251
+			$default_value = maybe_serialize( $values['item_meta'][$field_id] );
252 252
 
253 253
 			$new_field = array(
254 254
 				'field_options' => $field->field_options,
@@ -270,10 +270,10 @@  discard block
 block discarded – undo
270 270
 	 * updating the settings page
271 271
 	 */
272 272
 	private static function get_settings_page_html( $values, &$field ) {
273
-		if ( isset( $values['field_options'][ 'custom_html_' . $field->id ] ) ) {
273
+		if ( isset( $values['field_options']['custom_html_' . $field->id] ) ) {
274 274
 			$prev_opts = array();
275 275
 			$fallback_html = isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type );
276
-			$field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field->id ] ) ? $values['field_options'][ 'custom_html_' . $field->id ] : $fallback_html;
276
+			$field->field_options['custom_html'] = isset( $values['field_options']['custom_html_' . $field->id] ) ? $values['field_options']['custom_html_' . $field->id] : $fallback_html;
277 277
 		} elseif ( $field->type == 'hidden' || $field->type == 'user_id' ) {
278 278
 			$prev_opts = $field->field_options;
279 279
 		}
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 		);
298 298
 		foreach ( $field_cols as $col => $default ) {
299 299
 			$default = ( $default === '' ) ? $field->{$col} : $default;
300
-			$new_field[ $col ] = isset( $values['field_options'][ $col . '_' . $field->id ] ) ? $values['field_options'][ $col . '_' . $field->id ] : $default;
300
+			$new_field[$col] = isset( $values['field_options'][$col . '_' . $field->id] ) ? $values['field_options'][$col . '_' . $field->id] : $default;
301 301
 		}
302 302
 	}
303 303
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 			return self::trash( $id );
311 311
         }
312 312
 
313
-		$statuses  = array( 'published', 'draft', 'trash' );
313
+		$statuses = array( 'published', 'draft', 'trash' );
314 314
         if ( ! in_array( $status, $statuses ) ) {
315 315
             return false;
316 316
         }
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 			$form->options = maybe_unserialize( $form->options );
446 446
 			if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) {
447 447
 				self::destroy( $form->id );
448
-				$count++;
448
+				$count ++;
449 449
 			}
450 450
 
451 451
 			unset( $form );
@@ -639,16 +639,16 @@  discard block
 block discarded – undo
639 639
     	foreach ( $results as $row ) {
640 640
             if ( 'trash' != $row->status ) {
641 641
     	        if ( $row->is_template ) {
642
-					$counts['template']++;
642
+					$counts['template'] ++;
643 643
     	        } else {
644
-					$counts['published']++;
644
+					$counts['published'] ++;
645 645
     	        }
646 646
     	    } else {
647
-				$counts['trash']++;
647
+				$counts['trash'] ++;
648 648
         	}
649 649
 
650 650
     	    if ( 'draft' == $row->status ) {
651
-				$counts['draft']++;
651
+				$counts['draft'] ++;
652 652
     	    }
653 653
 
654 654
 			unset( $row );
@@ -689,8 +689,8 @@  discard block
 block discarded – undo
689 689
 			self::maybe_get_form( $form );
690 690
 		}
691 691
 
692
-		if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) {
693
-			return $frm_vars['form_params'][ $form->id ];
692
+		if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][$form->id] ) ) {
693
+			return $frm_vars['form_params'][$form->id];
694 694
 		}
695 695
 
696 696
 		$action_var = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; // WPCS: CSRF ok.
@@ -719,15 +719,15 @@  discard block
 block discarded – undo
719 719
 			//if there are two forms on the same page, make sure not to submit both
720 720
 			foreach ( $default_values as $var => $default ) {
721 721
 				if ( $var == 'action' ) {
722
-					$values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
722
+					$values[$var] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
723 723
 				} else {
724
-					$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
724
+					$values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
725 725
 				}
726 726
 				unset( $var, $default );
727 727
 			}
728 728
 		} else {
729 729
 			foreach ( $default_values as $var => $default ) {
730
-				$values[ $var ] = $default;
730
+				$values[$var] = $default;
731 731
 				unset( $var, $default );
732 732
 			}
733 733
 		}
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
 			'sdir'   => '',
752 752
 		);
753 753
 		foreach ( $defaults as $var => $default ) {
754
-			$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
754
+			$values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
755 755
 		}
756 756
 
757 757
 		return $values;
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
 			'keep_post' => '',
780 780
 		);
781 781
 		foreach ( $defaults as $var => $default ) {
782
-			$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
782
+			$values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
783 783
 		}
784 784
 
785 785
 		return $values;
@@ -860,6 +860,6 @@  discard block
 block discarded – undo
860 860
 	 */
861 861
 	public static function get_option( $atts ) {
862 862
 		$form = $atts['form'];
863
-		return isset( $form->options[ $atts['option'] ] ) ? $form->options[ $atts['option'] ] : $atts['default'];
863
+		return isset( $form->options[$atts['option']] ) ? $form->options[$atts['option']] : $atts['default'];
864 864
 	}
865 865
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -732,7 +732,8 @@
 block discarded – undo
732 732
 			}
733 733
 		}
734 734
 
735
-		if ( in_array( $values['action'], array( 'create', 'update' ) ) && ( ! $_POST || ( ! isset( $_POST['action'] ) && ! isset( $_POST['frm_action'] ) ) ) ) { // WPCS: CSRF ok.
735
+		if ( in_array( $values['action'], array( 'create', 'update' ) ) && ( ! $_POST || ( ! isset( $_POST['action'] ) && ! isset( $_POST['frm_action'] ) ) ) ) {
736
+// WPCS: CSRF ok.
736 737
 			$values['action'] = 'new';
737 738
 		}
738 739
 
Please login to merge, or discard this patch.
classes/models/FrmEntryValidate.php 3 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmEntryValidate {
4
-    public static function validate( $values, $exclude = false ) {
5
-        FrmEntry::sanitize_entry_post( $values );
6
-        $errors = array();
4
+	public static function validate( $values, $exclude = false ) {
5
+		FrmEntry::sanitize_entry_post( $values );
6
+		$errors = array();
7 7
 
8 8
 		if ( ! isset( $values['form_id'] ) || ! isset( $values['item_meta'] ) ) {
9
-            $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
10
-            return $errors;
11
-        }
9
+			$errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
10
+			return $errors;
11
+		}
12 12
 
13 13
 		if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) {
14
-            $errors['form'] = __( 'You do not have permission to do that', 'formidable' );
15
-        }
14
+			$errors['form'] = __( 'You do not have permission to do that', 'formidable' );
15
+		}
16 16
 
17 17
 		self::set_item_key( $values );
18 18
 
@@ -57,24 +57,24 @@  discard block
 block discarded – undo
57 57
 		return FrmField::getAll( $where, 'field_order' );
58 58
 	}
59 59
 
60
-    public static function validate_field( $posted_field, &$errors, $values, $args = array() ) {
61
-        $defaults = array(
62
-            'id'              => $posted_field->id,
63
-            'parent_field_id' => '', // the id of the repeat or embed form
64
-            'key_pointer'     => '', // the pointer in the posted array
65
-            'exclude'         => array(), // exclude these field types from validation
66
-        );
67
-        $args = wp_parse_args( $args, $defaults );
60
+	public static function validate_field( $posted_field, &$errors, $values, $args = array() ) {
61
+		$defaults = array(
62
+			'id'              => $posted_field->id,
63
+			'parent_field_id' => '', // the id of the repeat or embed form
64
+			'key_pointer'     => '', // the pointer in the posted array
65
+			'exclude'         => array(), // exclude these field types from validation
66
+		);
67
+		$args = wp_parse_args( $args, $defaults );
68 68
 
69 69
 		if ( empty( $args['parent_field_id'] ) ) {
70 70
 			$value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
71
-        } else {
72
-            // value is from a nested form
73
-            $value = $values;
74
-        }
71
+		} else {
72
+			// value is from a nested form
73
+			$value = $values;
74
+		}
75 75
 
76
-        // Check for values in "Other" fields
77
-        FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
76
+		// Check for values in "Other" fields
77
+		FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
78 78
 
79 79
 		self::maybe_clear_value_for_default_blank_setting( $posted_field, $value );
80 80
 
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
 			$value = trim( $value );
88 88
 		}
89 89
 
90
-        if ( $posted_field->required == '1' && FrmAppHelper::is_empty_value( $value ) ) {
90
+		if ( $posted_field->required == '1' && FrmAppHelper::is_empty_value( $value ) ) {
91 91
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
92
-        } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { // WPCS: CSRF ok.
93
-            $_POST['item_name'] = $value;
94
-        }
92
+		} else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { // WPCS: CSRF ok.
93
+			$_POST['item_name'] = $value;
94
+		}
95 95
 
96 96
 		FrmEntriesHelper::set_posted_value( $posted_field, $value, $args );
97 97
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
 		$errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args );
105 105
 		$errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args );
106
-    }
106
+	}
107 107
 
108 108
 	private static function maybe_clear_value_for_default_blank_setting( $field, &$value ) {
109 109
 		$is_default = ( FrmField::is_option_true_in_object( $field, 'default_blank' ) && $value == $field->default_value );
@@ -261,34 +261,34 @@  discard block
 block discarded – undo
261 261
 		}
262 262
 
263 263
 		self::validate_field_types( $errors, $field, '', $args );
264
-    }
265
-
266
-    /**
267
-     * check for spam
268
-     * @param boolean $exclude
269
-     * @param array $values
270
-     * @param array $errors by reference
271
-     */
272
-    public static function spam_check( $exclude, $values, &$errors ) {
273
-        if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
274
-            // only check spam if there are no other errors
275
-            return;
276
-        }
264
+	}
265
+
266
+	/**
267
+	 * check for spam
268
+	 * @param boolean $exclude
269
+	 * @param array $values
270
+	 * @param array $errors by reference
271
+	 */
272
+	public static function spam_check( $exclude, $values, &$errors ) {
273
+		if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
274
+			// only check spam if there are no other errors
275
+			return;
276
+		}
277 277
 
278 278
 		if ( self::is_honeypot_spam() || self::is_spam_bot() ) {
279 279
 			$errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
280 280
 		}
281 281
 
282
-    	if ( self::blacklist_check( $values ) ) {
283
-            $errors['spam'] = __( 'Your entry appears to be blacklist spam!', 'formidable' );
284
-    	}
282
+		if ( self::blacklist_check( $values ) ) {
283
+			$errors['spam'] = __( 'Your entry appears to be blacklist spam!', 'formidable' );
284
+		}
285 285
 
286
-        if ( self::is_akismet_spam( $values ) ) {
286
+		if ( self::is_akismet_spam( $values ) ) {
287 287
 			if ( self::is_akismet_enabled_for_user( $values['form_id'] ) ) {
288 288
 				$errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
289 289
 			}
290
-	    }
291
-    }
290
+		}
291
+	}
292 292
 
293 293
 	private static function is_honeypot_spam() {
294 294
 		$honeypot_value = FrmAppHelper::get_param( 'frm_verify', '', 'get', 'sanitize_text_field' );
@@ -310,15 +310,15 @@  discard block
 block discarded – undo
310 310
 		return ( isset( $form->options['akismet'] ) && ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] != 'logged' || ! is_user_logged_in() ) );
311 311
 	}
312 312
 
313
-    public static function blacklist_check( $values ) {
313
+	public static function blacklist_check( $values ) {
314 314
 		if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) {
315
-            return false;
316
-        }
315
+			return false;
316
+		}
317 317
 
318
-    	$mod_keys = trim( get_option( 'blacklist_keys' ) );
319
-    	if ( empty( $mod_keys ) ) {
320
-    		return false;
321
-    	}
318
+		$mod_keys = trim( get_option( 'blacklist_keys' ) );
319
+		if ( empty( $mod_keys ) ) {
320
+			return false;
321
+		}
322 322
 
323 323
 		$content = FrmEntriesHelper::entry_array_to_string( $values );
324 324
 		if ( empty( $content ) ) {
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 		$user_info = self::get_spam_check_user_info( $values );
331 331
 
332 332
 		return wp_blacklist_check( $user_info['comment_author'], $user_info['comment_author_email'], $user_info['comment_author_url'], $content, $ip, $user_agent );
333
-    }
333
+	}
334 334
 
335 335
 	/**
336 336
 	 * Check entries for Akismet spam
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
             return $errors;
11 11
         }
12 12
 
13
-		if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) {
13
+		if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values['frm_submit_entry_' . $values['form_id']] ) || ! wp_verify_nonce( $values['frm_submit_entry_' . $values['form_id']], 'frm_submit_entry_nonce' ) ) ) {
14 14
             $errors['form'] = __( 'You do not have permission to do that', 'formidable' );
15 15
         }
16 16
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         $args = wp_parse_args( $args, $defaults );
68 68
 
69 69
 		if ( empty( $args['parent_field_id'] ) ) {
70
-			$value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
70
+			$value = isset( $values['item_meta'][$args['id']] ) ? $values['item_meta'][$args['id']] : '';
71 71
         } else {
72 72
             // value is from a nested form
73 73
             $value = $values;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		}
89 89
 
90 90
         if ( $posted_field->required == '1' && FrmAppHelper::is_empty_value( $value ) ) {
91
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
91
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
92 92
         } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { // WPCS: CSRF ok.
93 93
             $_POST['item_name'] = $value;
94 94
         }
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			$pattern = self::phone_format( $field );
184 184
 
185 185
 			if ( ! preg_match( $pattern, $value ) ) {
186
-				$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
186
+				$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
187 187
 			}
188 188
 		}
189 189
 	}
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 
425 425
 			// Send any potentially useful $_SERVER vars, but avoid sending junk we don't need.
426 426
 			if ( $include_value ) {
427
-				$datas[ $key ] = $value;
427
+				$datas[$key] = $value;
428 428
 			}
429 429
 			unset( $key, $value );
430 430
 		}
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -89,7 +89,8 @@
 block discarded – undo
89 89
 
90 90
         if ( $posted_field->required == '1' && FrmAppHelper::is_empty_value( $value ) ) {
91 91
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
92
-        } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { // WPCS: CSRF ok.
92
+        } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
93
+// WPCS: CSRF ok.
93 94
             $_POST['item_name'] = $value;
94 95
         }
95 96
 
Please login to merge, or discard this patch.
classes/models/fields/FrmFieldUserID.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 
42 42
 		$user_ID = get_current_user_id();
43 43
 		$user_ID = ( $user_ID ? $user_ID : '' );
44
-		$posted_value = ( FrmAppHelper::is_admin() && $_POST && isset( $_POST['item_meta'][ $this->field['id'] ] ) ); // WPCS: CSRF ok.
44
+		$posted_value = ( FrmAppHelper::is_admin() && $_POST && isset( $_POST['item_meta'][$this->field['id']] ) ); // WPCS: CSRF ok.
45 45
 		$updating = ( isset( $args['action'] ) && $args['action'] == 'update' );
46 46
 		$value = ( is_numeric( $this->field['value'] ) || $posted_value || $updating ) ? $this->field['value'] : $user_ID;
47 47
 
Please login to merge, or discard this patch.