Completed
Push — master ( 9a0984...263488 )
by Stephanie
11:38 queued 05:45
created
classes/models/FrmField.php 2 patches
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 
6 6
 class FrmField {
7 7
 
8
-    static $use_cache = true;
8
+	static $use_cache = true;
9 9
 	static $transient_size = 200;
10 10
 
11 11
 	public static function field_selection() {
@@ -148,41 +148,41 @@  discard block
 block discarded – undo
148 148
 		));
149 149
 	}
150 150
 
151
-    public static function create( $values, $return = true ) {
152
-        global $wpdb, $frm_duplicate_ids;
151
+	public static function create( $values, $return = true ) {
152
+		global $wpdb, $frm_duplicate_ids;
153 153
 
154
-        $new_values = array();
155
-        $key = isset($values['field_key']) ? $values['field_key'] : $values['name'];
154
+		$new_values = array();
155
+		$key = isset($values['field_key']) ? $values['field_key'] : $values['name'];
156 156
 		$new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' );
157 157
 
158 158
 		foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) {
159 159
 			$new_values[ $col ] = $values[ $col ];
160
-        }
160
+		}
161 161
 
162
-        $new_values['options'] = $values['options'];
162
+		$new_values['options'] = $values['options'];
163 163
 
164
-        $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null;
165
-        $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0;
166
-        $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null;
167
-        $new_values['field_options'] = $values['field_options'];
168
-        $new_values['created_at'] = current_time('mysql', 1);
164
+		$new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null;
165
+		$new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0;
166
+		$new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null;
167
+		$new_values['field_options'] = $values['field_options'];
168
+		$new_values['created_at'] = current_time('mysql', 1);
169 169
 
170 170
 		if ( isset( $values['id'] ) ) {
171 171
 			$frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key'];
172
-            $new_values = apply_filters('frm_duplicated_field', $new_values);
173
-        }
172
+			$new_values = apply_filters('frm_duplicated_field', $new_values);
173
+		}
174 174
 
175 175
 		self::preserve_format_option_backslashes( $new_values );
176 176
 
177 177
 		foreach ( $new_values as $k => $v ) {
178
-            if ( is_array( $v ) ) {
178
+			if ( is_array( $v ) ) {
179 179
 				$new_values[ $k ] = serialize( $v );
180 180
 			}
181
-            unset( $k, $v );
182
-        }
181
+			unset( $k, $v );
182
+		}
183 183
 
184
-        //if(isset($values['id']) and is_numeric($values['id']))
185
-        //    $new_values['id'] = $values['id'];
184
+		//if(isset($values['id']) and is_numeric($values['id']))
185
+		//    $new_values['id'] = $values['id'];
186 186
 
187 187
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_fields', $new_values );
188 188
 		$new_id = 0;
@@ -203,10 +203,10 @@  discard block
 block discarded – undo
203 203
 		} else {
204 204
 			return false;
205 205
 		}
206
-    }
206
+	}
207 207
 
208
-    public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) {
209
-        global $frm_duplicate_ids;
208
+	public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) {
209
+		global $frm_duplicate_ids;
210 210
 
211 211
 		$where = array(
212 212
 			array(
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
 		);
218 218
 		$fields = self::getAll( $where, 'field_order', '', $blog_id );
219 219
 
220
-        foreach ( (array) $fields as $field ) {
220
+		foreach ( (array) $fields as $field ) {
221 221
 			$new_key = $copy_keys ? $field->field_key : '';
222
-            if ( $copy_keys && substr($field->field_key, -1) == 2 ) {
223
-                $new_key = rtrim($new_key, 2);
224
-            }
222
+			if ( $copy_keys && substr($field->field_key, -1) == 2 ) {
223
+				$new_key = rtrim($new_key, 2);
224
+			}
225 225
 
226
-            $values = array();
227
-            FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key );
226
+			$values = array();
227
+			FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key );
228 228
 
229 229
 			// If this is a repeating section, create new form
230 230
 			if ( self::is_repeating_field( $field ) ) {
@@ -246,16 +246,16 @@  discard block
 block discarded – undo
246 246
 				$values['form_id'] = $new_repeat_form_id;
247 247
 			}
248 248
 
249
-            $values = apply_filters('frm_duplicated_field', $values);
250
-            $new_id = self::create($values);
251
-            $frm_duplicate_ids[ $field->id ] = $new_id;
252
-            $frm_duplicate_ids[ $field->field_key ] = $new_id;
253
-            unset($field);
254
-        }
255
-    }
249
+			$values = apply_filters('frm_duplicated_field', $values);
250
+			$new_id = self::create($values);
251
+			$frm_duplicate_ids[ $field->id ] = $new_id;
252
+			$frm_duplicate_ids[ $field->field_key ] = $new_id;
253
+			unset($field);
254
+		}
255
+	}
256 256
 
257 257
 	public static function update( $id, $values ) {
258
-        global $wpdb;
258
+		global $wpdb;
259 259
 
260 260
 		$id = absint( $id );
261 261
 
@@ -263,9 +263,9 @@  discard block
 block discarded – undo
263 263
 			$values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id );
264 264
 		}
265 265
 
266
-        if ( isset($values['required']) ) {
267
-            $values['required'] = (int) $values['required'];
268
-        }
266
+		if ( isset($values['required']) ) {
267
+			$values['required'] = (int) $values['required'];
268
+		}
269 269
 
270 270
 		self::preserve_format_option_backslashes( $values );
271 271
 
@@ -287,41 +287,41 @@  discard block
 block discarded – undo
287 287
 
288 288
 		$query_results = $wpdb->update( $wpdb->prefix . 'frm_fields', $values, array( 'id' => $id ) );
289 289
 
290
-        $form_id = 0;
290
+		$form_id = 0;
291 291
 		if ( isset( $values['form_id'] ) ) {
292
-            $form_id = absint( $values['form_id'] );
292
+			$form_id = absint( $values['form_id'] );
293 293
 		} else {
294
-            $field = self::getOne($id);
295
-            if ( $field ) {
296
-                $form_id = $field->form_id;
297
-            }
298
-            unset($field);
299
-        }
300
-        unset($values);
294
+			$field = self::getOne($id);
295
+			if ( $field ) {
296
+				$form_id = $field->form_id;
297
+			}
298
+			unset($field);
299
+		}
300
+		unset($values);
301 301
 
302 302
 		if ( $query_results ) {
303
-            wp_cache_delete( $id, 'frm_field' );
304
-            if ( $form_id ) {
305
-                self::delete_form_transient( $form_id );
306
-            }
307
-        }
303
+			wp_cache_delete( $id, 'frm_field' );
304
+			if ( $form_id ) {
305
+				self::delete_form_transient( $form_id );
306
+			}
307
+		}
308 308
 
309
-        return $query_results;
310
-    }
309
+		return $query_results;
310
+	}
311 311
 
312 312
 	/**
313
-	* Keep backslashes in the phone format option
314
-	*
315
-	* @since 2.0.8
316
-	* @param $values array - pass by reference
317
-	*/
313
+	 * Keep backslashes in the phone format option
314
+	 *
315
+	 * @since 2.0.8
316
+	 * @param $values array - pass by reference
317
+	 */
318 318
 	private static function preserve_format_option_backslashes( &$values ) {
319 319
 		if ( isset( $values['field_options']['format'] ) ) {
320 320
 			$values['field_options']['format'] = FrmAppHelper::preserve_backslashes( $values['field_options']['format'] );
321 321
 		}
322 322
 	}
323 323
 
324
-    public static function destroy( $id ) {
324
+	public static function destroy( $id ) {
325 325
 		global $wpdb;
326 326
 
327 327
 		do_action( 'frm_before_destroy_field', $id );
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 
337 337
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id=%d', $id ) );
338 338
 		return $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_fields WHERE id=%d', $id ) );
339
-    }
339
+	}
340 340
 
341 341
 	public static function delete_form_transient( $form_id ) {
342 342
 		$form_id = absint( $form_id );
@@ -350,11 +350,11 @@  discard block
 block discarded – undo
350 350
 
351 351
 		FrmDb::cache_delete_group( 'frm_field' );
352 352
 
353
-        $form = FrmForm::getOne($form_id);
354
-        if ( $form && $form->parent_form_id && $form->parent_form_id != $form_id ) {
355
-            self::delete_form_transient( $form->parent_form_id );
356
-        }
357
-    }
353
+		$form = FrmForm::getOne($form_id);
354
+		if ( $form && $form->parent_form_id && $form->parent_form_id != $form_id ) {
355
+			self::delete_form_transient( $form->parent_form_id );
356
+		}
357
+	}
358 358
 
359 359
 	/**
360 360
 	 * If $field is numeric, get the field object
@@ -370,83 +370,83 @@  discard block
 block discarded – undo
370 370
 			return null;
371 371
 		}
372 372
 
373
-        global $wpdb;
373
+		global $wpdb;
374 374
 
375
-        $where = is_numeric($id) ? 'id=%d' : 'field_key=%s';
375
+		$where = is_numeric($id) ? 'id=%d' : 'field_key=%s';
376 376
 		$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id );
377 377
 
378
-        $results = FrmDb::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
378
+		$results = FrmDb::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
379 379
 
380
-        if ( empty($results) ) {
381
-            return $results;
382
-        }
380
+		if ( empty($results) ) {
381
+			return $results;
382
+		}
383 383
 
384
-        if ( is_numeric($id) ) {
384
+		if ( is_numeric($id) ) {
385 385
 			FrmDb::set_cache( $results->field_key, $results, 'frm_field' );
386
-        } else if ( $results ) {
386
+		} else if ( $results ) {
387 387
 			FrmDb::set_cache( $results->id, $results, 'frm_field' );
388
-        }
388
+		}
389 389
 
390 390
 		self::prepare_options( $results );
391 391
 
392
-        return stripslashes_deep($results);
393
-    }
392
+		return stripslashes_deep($results);
393
+	}
394 394
 
395
-    /**
396
-     * Get the field type by key or id
397
-     * @param int|string The field id or key
395
+	/**
396
+	 * Get the field type by key or id
397
+	 * @param int|string The field id or key
398 398
 	 * @param mixed $col The name of the column in the fields database table
399
-     */
400
-    public static function get_type( $id, $col = 'type' ) {
401
-        $field = FrmDb::check_cache( $id, 'frm_field' );
402
-        if ( $field ) {
403
-            $type = $field->{$col};
404
-        } else {
399
+	 */
400
+	public static function get_type( $id, $col = 'type' ) {
401
+		$field = FrmDb::check_cache( $id, 'frm_field' );
402
+		if ( $field ) {
403
+			$type = $field->{$col};
404
+		} else {
405 405
 			$where = array(
406 406
 				'or'        => 1,
407 407
 				'id'        => $id,
408 408
 				'field_key' => $id,
409 409
 			);
410 410
 			$type = FrmDb::get_var( 'frm_fields', $where, $col );
411
-        }
411
+		}
412 412
 
413
-        return $type;
414
-    }
413
+		return $type;
414
+	}
415 415
 
416 416
 	public static function get_all_types_in_form( $form_id, $type, $limit = '', $inc_sub = 'exclude' ) {
417
-        if ( ! $form_id ) {
418
-            return array();
419
-        }
417
+		if ( ! $form_id ) {
418
+			return array();
419
+		}
420 420
 
421 421
 		$results = self::get_fields_from_transients( $form_id, array(
422 422
 			'inc_embed'  => $inc_sub,
423 423
 			'inc_repeat' => $inc_sub,
424 424
 		) );
425 425
 		if ( ! empty( $results ) ) {
426
-            $fields = array();
427
-            $count = 0;
428
-            foreach ( $results as $result ) {
429
-                if ( $type != $result->type ) {
430
-                    continue;
431
-                }
426
+			$fields = array();
427
+			$count = 0;
428
+			foreach ( $results as $result ) {
429
+				if ( $type != $result->type ) {
430
+					continue;
431
+				}
432 432
 
433 433
 				$fields[ $result->id ] = $result;
434
-                $count++;
435
-                if ( $limit == 1 ) {
436
-                    $fields = $result;
437
-                    break;
438
-                }
434
+				$count++;
435
+				if ( $limit == 1 ) {
436
+					$fields = $result;
437
+					break;
438
+				}
439 439
 
440
-                if ( ! empty($limit) && $count >= $limit ) {
441
-                    break;
442
-                }
440
+				if ( ! empty($limit) && $count >= $limit ) {
441
+					break;
442
+				}
443 443
 
444
-                unset($result);
445
-            }
446
-            return stripslashes_deep($fields);
447
-        }
444
+				unset($result);
445
+			}
446
+			return stripslashes_deep($fields);
447
+		}
448 448
 
449
-        self::$use_cache = false;
449
+		self::$use_cache = false;
450 450
 
451 451
 		$where = array(
452 452
 			'fi.form_id' => (int) $form_id,
@@ -454,65 +454,65 @@  discard block
 block discarded – undo
454 454
 		);
455 455
 		self::maybe_include_repeating_fields( $inc_sub, $where );
456 456
 		$results = self::getAll( $where, 'field_order', $limit );
457
-        self::$use_cache = true;
458
-        self::include_sub_fields($results, $inc_sub, $type);
457
+		self::$use_cache = true;
458
+		self::include_sub_fields($results, $inc_sub, $type);
459 459
 
460
-        return $results;
461
-    }
460
+		return $results;
461
+	}
462 462
 
463 463
 	public static function get_all_for_form( $form_id, $limit = '', $inc_embed = 'exclude', $inc_repeat = 'include' ) {
464
-        if ( ! (int) $form_id ) {
465
-            return array();
466
-        }
464
+		if ( ! (int) $form_id ) {
465
+			return array();
466
+		}
467 467
 
468 468
 		$results = self::get_fields_from_transients( $form_id, array(
469 469
 			'inc_embed'  => $inc_embed,
470 470
 			'inc_repeat' => $inc_repeat,
471 471
 		) );
472 472
 		if ( ! empty( $results ) ) {
473
-            if ( empty($limit) ) {
473
+			if ( empty($limit) ) {
474 474
 				return $results;
475
-            }
475
+			}
476 476
 
477
-            $fields = array();
478
-            $count = 0;
479
-            foreach ( $results as $result ) {
477
+			$fields = array();
478
+			$count = 0;
479
+			foreach ( $results as $result ) {
480 480
 				$count++;
481 481
 				$fields[ $result->id ] = $result;
482
-                if ( ! empty($limit) && $count >= $limit ) {
483
-                    break;
484
-                }
485
-            }
482
+				if ( ! empty($limit) && $count >= $limit ) {
483
+					break;
484
+				}
485
+			}
486 486
 
487 487
 			return $fields;
488
-        }
488
+		}
489 489
 
490
-        self::$use_cache = false;
490
+		self::$use_cache = false;
491 491
 
492 492
 		$where = array( 'fi.form_id' => absint( $form_id ) );
493 493
 		self::maybe_include_repeating_fields( $inc_repeat, $where );
494 494
 		$results = self::getAll( $where, 'field_order', $limit );
495 495
 
496
-        self::$use_cache = true;
496
+		self::$use_cache = true;
497 497
 
498 498
 		self::include_sub_fields( $results, $inc_embed, 'all' );
499 499
 
500
-        if ( empty($limit) ) {
500
+		if ( empty($limit) ) {
501 501
 			self::set_field_transient( $results, $form_id, 0, array(
502 502
 				'inc_embed'  => $inc_embed,
503 503
 				'inc_repeat' => $inc_repeat,
504 504
 			) );
505
-        }
505
+		}
506 506
 
507 507
 		return $results;
508
-    }
508
+	}
509 509
 
510 510
 	/**
511
-	* If repeating fields should be included, adjust $where accordingly
512
-	*
513
-	* @param string $inc_repeat
514
-	* @param array $where - pass by reference
515
-	*/
511
+	 * If repeating fields should be included, adjust $where accordingly
512
+	 *
513
+	 * @param string $inc_repeat
514
+	 * @param array $where - pass by reference
515
+	 */
516 516
 	private static function maybe_include_repeating_fields( $inc_repeat, &$where ) {
517 517
 		if ( $inc_repeat == 'include' ) {
518 518
 			$form_id = $where['fi.form_id'];
@@ -527,57 +527,57 @@  discard block
 block discarded – undo
527 527
 
528 528
 	public static function include_sub_fields( &$results, $inc_embed, $type = 'all' ) {
529 529
 		if ( 'include' != $inc_embed || empty( $results ) ) {
530
-            return;
531
-        }
530
+			return;
531
+		}
532 532
 
533
-        $form_fields = $results;
533
+		$form_fields = $results;
534 534
 		$index_offset = 1;
535
-        foreach ( $form_fields as $k => $field ) {
536
-            if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) {
537
-                continue;
538
-            }
539
-
540
-            if ( $type == 'all' ) {
541
-                $sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
542
-            } else {
543
-                $sub_fields = self::get_all_types_in_form($field->form_id, $type);
544
-            }
545
-
546
-            if ( ! empty($sub_fields) ) {
535
+		foreach ( $form_fields as $k => $field ) {
536
+			if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) {
537
+				continue;
538
+			}
539
+
540
+			if ( $type == 'all' ) {
541
+				$sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
542
+			} else {
543
+				$sub_fields = self::get_all_types_in_form($field->form_id, $type);
544
+			}
545
+
546
+			if ( ! empty($sub_fields) ) {
547 547
 				$index = $k + $index_offset;
548 548
 				$index_offset += count( $sub_fields );
549 549
 				array_splice($results, $index, 0, $sub_fields);
550
-            }
551
-            unset($field, $sub_fields);
552
-        }
553
-    }
550
+			}
551
+			unset($field, $sub_fields);
552
+		}
553
+	}
554 554
 
555 555
 	public static function getAll( $where = array(), $order_by = '', $limit = '', $blog_id = false ) {
556 556
 		$cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id;
557
-        if ( self::$use_cache ) {
558
-            // make sure old cache doesn't get saved as a transient
559
-            $results = wp_cache_get($cache_key, 'frm_field');
560
-            if ( false !== $results ) {
561
-                return stripslashes_deep($results);
562
-            }
563
-        }
564
-
565
-        global $wpdb;
566
-
567
-        if ( $blog_id && is_multisite() ) {
568
-            global $wpmuBaseTablePrefix;
569
-            if ( $wpmuBaseTablePrefix ) {
557
+		if ( self::$use_cache ) {
558
+			// make sure old cache doesn't get saved as a transient
559
+			$results = wp_cache_get($cache_key, 'frm_field');
560
+			if ( false !== $results ) {
561
+				return stripslashes_deep($results);
562
+			}
563
+		}
564
+
565
+		global $wpdb;
566
+
567
+		if ( $blog_id && is_multisite() ) {
568
+			global $wpmuBaseTablePrefix;
569
+			if ( $wpmuBaseTablePrefix ) {
570 570
 				$prefix = $wpmuBaseTablePrefix . $blog_id . '_';
571
-            } else {
572
-                $prefix = $wpdb->get_blog_prefix( $blog_id );
573
-            }
571
+			} else {
572
+				$prefix = $wpdb->get_blog_prefix( $blog_id );
573
+			}
574 574
 
575 575
 			$table_name = $prefix . 'frm_fields';
576 576
 			$form_table_name = $prefix . 'frm_forms';
577 577
 		} else {
578 578
 			$table_name = $wpdb->prefix . 'frm_fields';
579 579
 			$form_table_name = $wpdb->prefix . 'frm_forms';
580
-        }
580
+		}
581 581
 
582 582
 		if ( ! empty( $order_by ) && strpos( $order_by, 'ORDER BY' ) === false ) {
583 583
 			$order_by = ' ORDER BY ' . $order_by;
@@ -585,8 +585,8 @@  discard block
 block discarded – undo
585 585
 
586 586
 		$limit = FrmDb::esc_limit( $limit );
587 587
 
588
-        $query = "SELECT fi.*, fr.name as form_name  FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
589
-        $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results';
588
+		$query = "SELECT fi.*, fr.name as form_name  FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
589
+		$query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results';
590 590
 
591 591
 		if ( is_array( $where ) ) {
592 592
 			$args = array(
@@ -600,8 +600,8 @@  discard block
 block discarded – undo
600 600
 
601 601
 			$function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results';
602 602
 			$results = $wpdb->$function_name( $query );
603
-        }
604
-        unset( $where );
603
+		}
604
+		unset( $where );
605 605
 
606 606
 		self::format_field_results( $results );
607 607
 
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
 	}
850 850
 
851 851
 	/**
852
-	* @since 2.0.09
853
-	*/
852
+	 * @since 2.0.09
853
+	 */
854 854
 	public static function is_repeating_field( $field ) {
855 855
 		if ( is_array( $field ) ) {
856 856
 			$is_repeating_field = ( 'divider' == $field['type'] );
@@ -860,14 +860,14 @@  discard block
 block discarded – undo
860 860
 		return ( $is_repeating_field && self::is_option_true( $field, 'repeat' ) );
861 861
 	}
862 862
 
863
-    /**
864
-     * @param string $key
865
-     * @return int field id
866
-     */
863
+	/**
864
+	 * @param string $key
865
+	 * @return int field id
866
+	 */
867 867
 	public static function get_id_by_key( $key ) {
868
-        $id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) );
869
-        return $id;
870
-    }
868
+		$id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) );
869
+		return $id;
870
+	}
871 871
 
872 872
 	/**
873 873
 	 * @param string $id
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 	static $transient_size = 200;
10 10
 
11 11
 	public static function field_selection() {
12
-		$fields = apply_filters('frm_available_fields', array(
12
+		$fields = apply_filters( 'frm_available_fields', array(
13 13
 			'text'      => array(
14 14
 				'name'  => __( 'Text', 'formidable' ),
15 15
 				'icon'  => 'frm_css_icon frm_text_icon',
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 				'name'  => __( 'reCAPTCHA', 'formidable' ),
63 63
 				'icon'  => 'frm_icon_font frm_shield-check_icon',
64 64
 			),
65
-		));
65
+		) );
66 66
 
67 67
 		return $fields;
68 68
 	}
@@ -145,38 +145,38 @@  discard block
 block discarded – undo
145 145
 				'name'  => __( 'Address', 'formidable' ),
146 146
 				'icon'  => 'frm_icon_font frm_location_icon',
147 147
 			),
148
-		));
148
+		) );
149 149
 	}
150 150
 
151 151
     public static function create( $values, $return = true ) {
152 152
         global $wpdb, $frm_duplicate_ids;
153 153
 
154 154
         $new_values = array();
155
-        $key = isset($values['field_key']) ? $values['field_key'] : $values['name'];
155
+        $key = isset( $values['field_key'] ) ? $values['field_key'] : $values['name'];
156 156
 		$new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' );
157 157
 
158 158
 		foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) {
159
-			$new_values[ $col ] = $values[ $col ];
159
+			$new_values[$col] = $values[$col];
160 160
         }
161 161
 
162 162
         $new_values['options'] = $values['options'];
163 163
 
164
-        $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null;
165
-        $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0;
166
-        $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null;
164
+        $new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null;
165
+        $new_values['required'] = isset( $values['required'] ) ? (int) $values['required'] : 0;
166
+        $new_values['form_id'] = isset( $values['form_id'] ) ? (int) $values['form_id'] : null;
167 167
         $new_values['field_options'] = $values['field_options'];
168
-        $new_values['created_at'] = current_time('mysql', 1);
168
+        $new_values['created_at'] = current_time( 'mysql', 1 );
169 169
 
170 170
 		if ( isset( $values['id'] ) ) {
171
-			$frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key'];
172
-            $new_values = apply_filters('frm_duplicated_field', $new_values);
171
+			$frm_duplicate_ids[$values['field_key']] = $new_values['field_key'];
172
+            $new_values = apply_filters( 'frm_duplicated_field', $new_values );
173 173
         }
174 174
 
175 175
 		self::preserve_format_option_backslashes( $new_values );
176 176
 
177 177
 		foreach ( $new_values as $k => $v ) {
178 178
             if ( is_array( $v ) ) {
179
-				$new_values[ $k ] = serialize( $v );
179
+				$new_values[$k] = serialize( $v );
180 180
 			}
181 181
             unset( $k, $v );
182 182
         }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 
198 198
 		if ( $query_results ) {
199 199
 			if ( isset( $values['id'] ) ) {
200
-				$frm_duplicate_ids[ $values['id'] ] = $new_id;
200
+				$frm_duplicate_ids[$values['id']] = $new_id;
201 201
 			}
202 202
 			return $new_id;
203 203
 		} else {
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
 
220 220
         foreach ( (array) $fields as $field ) {
221 221
 			$new_key = $copy_keys ? $field->field_key : '';
222
-            if ( $copy_keys && substr($field->field_key, -1) == 2 ) {
223
-                $new_key = rtrim($new_key, 2);
222
+            if ( $copy_keys && substr( $field->field_key, -1 ) == 2 ) {
223
+                $new_key = rtrim( $new_key, 2 );
224 224
             }
225 225
 
226 226
             $values = array();
@@ -246,11 +246,11 @@  discard block
 block discarded – undo
246 246
 				$values['form_id'] = $new_repeat_form_id;
247 247
 			}
248 248
 
249
-            $values = apply_filters('frm_duplicated_field', $values);
250
-            $new_id = self::create($values);
251
-            $frm_duplicate_ids[ $field->id ] = $new_id;
252
-            $frm_duplicate_ids[ $field->field_key ] = $new_id;
253
-            unset($field);
249
+            $values = apply_filters( 'frm_duplicated_field', $values );
250
+            $new_id = self::create( $values );
251
+            $frm_duplicate_ids[$field->id] = $new_id;
252
+            $frm_duplicate_ids[$field->field_key] = $new_id;
253
+            unset( $field );
254 254
         }
255 255
     }
256 256
 
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 			$values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id );
264 264
 		}
265 265
 
266
-        if ( isset($values['required']) ) {
266
+        if ( isset( $values['required'] ) ) {
267 267
             $values['required'] = (int) $values['required'];
268 268
         }
269 269
 
@@ -280,8 +280,8 @@  discard block
 block discarded – undo
280 280
 
281 281
 		// serialize array values
282 282
 		foreach ( array( 'default_value', 'field_options', 'options' ) as $opt ) {
283
-			if ( isset( $values[ $opt ] ) && is_array( $values[ $opt ] ) ) {
284
-				$values[ $opt ] = serialize( $values[ $opt ] );
283
+			if ( isset( $values[$opt] ) && is_array( $values[$opt] ) ) {
284
+				$values[$opt] = serialize( $values[$opt] );
285 285
 			}
286 286
 		}
287 287
 
@@ -291,13 +291,13 @@  discard block
 block discarded – undo
291 291
 		if ( isset( $values['form_id'] ) ) {
292 292
             $form_id = absint( $values['form_id'] );
293 293
 		} else {
294
-            $field = self::getOne($id);
294
+            $field = self::getOne( $id );
295 295
             if ( $field ) {
296 296
                 $form_id = $field->form_id;
297 297
             }
298
-            unset($field);
298
+            unset( $field );
299 299
         }
300
-        unset($values);
300
+        unset( $values );
301 301
 
302 302
 		if ( $query_results ) {
303 303
             wp_cache_delete( $id, 'frm_field' );
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 
351 351
 		FrmDb::cache_delete_group( 'frm_field' );
352 352
 
353
-        $form = FrmForm::getOne($form_id);
353
+        $form = FrmForm::getOne( $form_id );
354 354
         if ( $form && $form->parent_form_id && $form->parent_form_id != $form_id ) {
355 355
             self::delete_form_transient( $form->parent_form_id );
356 356
         }
@@ -372,16 +372,16 @@  discard block
 block discarded – undo
372 372
 
373 373
         global $wpdb;
374 374
 
375
-        $where = is_numeric($id) ? 'id=%d' : 'field_key=%s';
375
+        $where = is_numeric( $id ) ? 'id=%d' : 'field_key=%s';
376 376
 		$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id );
377 377
 
378 378
         $results = FrmDb::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
379 379
 
380
-        if ( empty($results) ) {
380
+        if ( empty( $results ) ) {
381 381
             return $results;
382 382
         }
383 383
 
384
-        if ( is_numeric($id) ) {
384
+        if ( is_numeric( $id ) ) {
385 385
 			FrmDb::set_cache( $results->field_key, $results, 'frm_field' );
386 386
         } else if ( $results ) {
387 387
 			FrmDb::set_cache( $results->id, $results, 'frm_field' );
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 
390 390
 		self::prepare_options( $results );
391 391
 
392
-        return stripslashes_deep($results);
392
+        return stripslashes_deep( $results );
393 393
     }
394 394
 
395 395
     /**
@@ -430,20 +430,20 @@  discard block
 block discarded – undo
430 430
                     continue;
431 431
                 }
432 432
 
433
-				$fields[ $result->id ] = $result;
434
-                $count++;
433
+				$fields[$result->id] = $result;
434
+                $count ++;
435 435
                 if ( $limit == 1 ) {
436 436
                     $fields = $result;
437 437
                     break;
438 438
                 }
439 439
 
440
-                if ( ! empty($limit) && $count >= $limit ) {
440
+                if ( ! empty( $limit ) && $count >= $limit ) {
441 441
                     break;
442 442
                 }
443 443
 
444
-                unset($result);
444
+                unset( $result );
445 445
             }
446
-            return stripslashes_deep($fields);
446
+            return stripslashes_deep( $fields );
447 447
         }
448 448
 
449 449
         self::$use_cache = false;
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 		self::maybe_include_repeating_fields( $inc_sub, $where );
456 456
 		$results = self::getAll( $where, 'field_order', $limit );
457 457
         self::$use_cache = true;
458
-        self::include_sub_fields($results, $inc_sub, $type);
458
+        self::include_sub_fields( $results, $inc_sub, $type );
459 459
 
460 460
         return $results;
461 461
     }
@@ -470,16 +470,16 @@  discard block
 block discarded – undo
470 470
 			'inc_repeat' => $inc_repeat,
471 471
 		) );
472 472
 		if ( ! empty( $results ) ) {
473
-            if ( empty($limit) ) {
473
+            if ( empty( $limit ) ) {
474 474
 				return $results;
475 475
             }
476 476
 
477 477
             $fields = array();
478 478
             $count = 0;
479 479
             foreach ( $results as $result ) {
480
-				$count++;
481
-				$fields[ $result->id ] = $result;
482
-                if ( ! empty($limit) && $count >= $limit ) {
480
+				$count ++;
481
+				$fields[$result->id] = $result;
482
+                if ( ! empty( $limit ) && $count >= $limit ) {
483 483
                     break;
484 484
                 }
485 485
             }
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 
498 498
 		self::include_sub_fields( $results, $inc_embed, 'all' );
499 499
 
500
-        if ( empty($limit) ) {
500
+        if ( empty( $limit ) ) {
501 501
 			self::set_field_transient( $results, $form_id, 0, array(
502 502
 				'inc_embed'  => $inc_embed,
503 503
 				'inc_repeat' => $inc_repeat,
@@ -533,22 +533,22 @@  discard block
 block discarded – undo
533 533
         $form_fields = $results;
534 534
 		$index_offset = 1;
535 535
         foreach ( $form_fields as $k => $field ) {
536
-            if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) {
536
+            if ( 'form' != $field->type || ! isset( $field->field_options['form_select'] ) ) {
537 537
                 continue;
538 538
             }
539 539
 
540 540
             if ( $type == 'all' ) {
541 541
                 $sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
542 542
             } else {
543
-                $sub_fields = self::get_all_types_in_form($field->form_id, $type);
543
+                $sub_fields = self::get_all_types_in_form( $field->form_id, $type );
544 544
             }
545 545
 
546
-            if ( ! empty($sub_fields) ) {
546
+            if ( ! empty( $sub_fields ) ) {
547 547
 				$index = $k + $index_offset;
548 548
 				$index_offset += count( $sub_fields );
549
-				array_splice($results, $index, 0, $sub_fields);
549
+				array_splice( $results, $index, 0, $sub_fields );
550 550
             }
551
-            unset($field, $sub_fields);
551
+            unset( $field, $sub_fields );
552 552
         }
553 553
     }
554 554
 
@@ -556,9 +556,9 @@  discard block
 block discarded – undo
556 556
 		$cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id;
557 557
         if ( self::$use_cache ) {
558 558
             // make sure old cache doesn't get saved as a transient
559
-            $results = wp_cache_get($cache_key, 'frm_field');
559
+            $results = wp_cache_get( $cache_key, 'frm_field' );
560 560
             if ( false !== $results ) {
561
-                return stripslashes_deep($results);
561
+                return stripslashes_deep( $results );
562 562
             }
563 563
         }
564 564
 
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 			$results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', $args, '', $query_type );
597 597
 		} else {
598 598
 			// if the query is not an array, then it has already been prepared
599
-			$query .= FrmDb::prepend_and_or_where(' WHERE ', $where ) . $order_by . $limit;
599
+			$query .= FrmDb::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
600 600
 
601 601
 			$function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results';
602 602
 			$results = $wpdb->$function_name( $query );
@@ -619,9 +619,9 @@  discard block
 block discarded – undo
619 619
 				FrmDb::set_cache( $result->id, $result, 'frm_field' );
620 620
 				FrmDb::set_cache( $result->field_key, $result, 'frm_field' );
621 621
 
622
-				$results[ $r_key ]->field_options = maybe_unserialize( $result->field_options );
623
-				$results[ $r_key ]->options = maybe_unserialize( $result->options );
624
-				$results[ $r_key ]->default_value = maybe_unserialize( $result->default_value );
622
+				$results[$r_key]->field_options = maybe_unserialize( $result->field_options );
623
+				$results[$r_key]->options = maybe_unserialize( $result->options );
624
+				$results[$r_key]->default_value = maybe_unserialize( $result->default_value );
625 625
 
626 626
 				unset( $r_key, $result );
627 627
 			}
@@ -640,8 +640,8 @@  discard block
 block discarded – undo
640 640
 	private static function prepare_options( &$results ) {
641 641
 		$results->field_options = maybe_unserialize( $results->field_options );
642 642
 
643
-		$results->options = maybe_unserialize($results->options);
644
-		$results->default_value = maybe_unserialize($results->default_value);
643
+		$results->options = maybe_unserialize( $results->options );
644
+		$results->default_value = maybe_unserialize( $results->default_value );
645 645
 	}
646 646
 
647 647
 	/**
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 
669 669
 			if ( count( $next_fields ) >= self::$transient_size ) {
670 670
 				// if this transient is full, check for another
671
-				$next++;
671
+				$next ++;
672 672
 				self::get_next_transient( $fields, $base_name, $next );
673 673
 			}
674 674
 		}
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
 				return;
695 695
 			}
696 696
 
697
-			$next++;
697
+			$next ++;
698 698
 		}
699 699
 	}
700 700
 
@@ -809,23 +809,23 @@  discard block
 block discarded – undo
809 809
 	}
810 810
 
811 811
 	public static function is_option_true_in_array( $field, $option ) {
812
-		return isset( $field[ $option ] ) && $field[ $option ];
812
+		return isset( $field[$option] ) && $field[$option];
813 813
 	}
814 814
 
815 815
 	public static function is_option_true_in_object( $field, $option ) {
816
-		return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ];
816
+		return isset( $field->field_options[$option] ) && $field->field_options[$option];
817 817
 	}
818 818
 
819 819
 	public static function is_option_empty_in_array( $field, $option ) {
820
-		return ! isset( $field[ $option ] ) || empty( $field[ $option ] );
820
+		return ! isset( $field[$option] ) || empty( $field[$option] );
821 821
 	}
822 822
 
823 823
 	public static function is_option_empty_in_object( $field, $option ) {
824
-		return ! isset( $field->field_options[ $option ] ) || empty( $field->field_options[ $option ] );
824
+		return ! isset( $field->field_options[$option] ) || empty( $field->field_options[$option] );
825 825
 	}
826 826
 
827 827
 	public static function is_option_value_in_object( $field, $option ) {
828
-		return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ] != '';
828
+		return isset( $field->field_options[$option] ) && $field->field_options[$option] != '';
829 829
 	}
830 830
 
831 831
 	/**
@@ -841,11 +841,11 @@  discard block
 block discarded – undo
841 841
 	}
842 842
 
843 843
 	public static function get_option_in_array( $field, $option ) {
844
-		return isset( $field[ $option ] ) ? $field[ $option ] : '';
844
+		return isset( $field[$option] ) ? $field[$option] : '';
845 845
 	}
846 846
 
847 847
 	public static function get_option_in_object( $field, $option ) {
848
-		return isset( $field->field_options[ $option ] ) ? $field->field_options[ $option ] : '';
848
+		return isset( $field->field_options[$option] ) ? $field->field_options[$option] : '';
849 849
 	}
850 850
 
851 851
 	/**
Please login to merge, or discard this patch.
classes/helpers/FrmStylesHelper.php 2 patches
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -1,67 +1,67 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class FrmStylesHelper {
3 3
 
4
-    public static function jquery_themes() {
5
-        $themes = array(
6
-            'ui-lightness'  => 'UI Lightness',
7
-            'ui-darkness'   => 'UI Darkness',
8
-            'smoothness'    => 'Smoothness',
9
-            'start'         => 'Start',
10
-            'redmond'       => 'Redmond',
11
-            'sunny'         => 'Sunny',
12
-            'overcast'      => 'Overcast',
13
-            'le-frog'       => 'Le Frog',
14
-            'flick'         => 'Flick',
4
+	public static function jquery_themes() {
5
+		$themes = array(
6
+			'ui-lightness'  => 'UI Lightness',
7
+			'ui-darkness'   => 'UI Darkness',
8
+			'smoothness'    => 'Smoothness',
9
+			'start'         => 'Start',
10
+			'redmond'       => 'Redmond',
11
+			'sunny'         => 'Sunny',
12
+			'overcast'      => 'Overcast',
13
+			'le-frog'       => 'Le Frog',
14
+			'flick'         => 'Flick',
15 15
 			'pepper-grinder' => 'Pepper Grinder',
16
-            'eggplant'      => 'Eggplant',
17
-            'dark-hive'     => 'Dark Hive',
18
-            'cupertino'     => 'Cupertino',
19
-            'south-street'  => 'South Street',
20
-            'blitzer'       => 'Blitzer',
21
-            'humanity'      => 'Humanity',
22
-            'hot-sneaks'    => 'Hot Sneaks',
23
-            'excite-bike'   => 'Excite Bike',
24
-            'vader'         => 'Vader',
25
-            'dot-luv'       => 'Dot Luv',
26
-            'mint-choc'     => 'Mint Choc',
27
-            'black-tie'     => 'Black Tie',
28
-            'trontastic'    => 'Trontastic',
29
-            'swanky-purse'  => 'Swanky Purse',
30
-        );
31
-
32
-        $themes = apply_filters('frm_jquery_themes', $themes);
33
-        return $themes;
34
-    }
16
+			'eggplant'      => 'Eggplant',
17
+			'dark-hive'     => 'Dark Hive',
18
+			'cupertino'     => 'Cupertino',
19
+			'south-street'  => 'South Street',
20
+			'blitzer'       => 'Blitzer',
21
+			'humanity'      => 'Humanity',
22
+			'hot-sneaks'    => 'Hot Sneaks',
23
+			'excite-bike'   => 'Excite Bike',
24
+			'vader'         => 'Vader',
25
+			'dot-luv'       => 'Dot Luv',
26
+			'mint-choc'     => 'Mint Choc',
27
+			'black-tie'     => 'Black Tie',
28
+			'trontastic'    => 'Trontastic',
29
+			'swanky-purse'  => 'Swanky Purse',
30
+		);
31
+
32
+		$themes = apply_filters('frm_jquery_themes', $themes);
33
+		return $themes;
34
+	}
35 35
 
36 36
 	public static function jquery_css_url( $theme_css ) {
37
-        if ( $theme_css == -1 ) {
38
-            return;
39
-        }
40
-
41
-        if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42
-            $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
-        } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) {
44
-            $css_file = $theme_css;
45
-        } else {
46
-            $uploads = self::get_upload_base();
37
+		if ( $theme_css == -1 ) {
38
+			return;
39
+		}
40
+
41
+		if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42
+			$css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
+		} else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) {
44
+			$css_file = $theme_css;
45
+		} else {
46
+			$uploads = self::get_upload_base();
47 47
 			$file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css';
48
-            if ( file_exists($uploads['basedir'] . $file_path) ) {
49
-                $css_file = $uploads['baseurl'] . $file_path;
50
-            } else {
48
+			if ( file_exists($uploads['basedir'] . $file_path) ) {
49
+				$css_file = $uploads['baseurl'] . $file_path;
50
+			} else {
51 51
 				$css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css';
52
-            }
53
-        }
52
+			}
53
+		}
54 54
 
55
-        return $css_file;
56
-    }
55
+		return $css_file;
56
+	}
57 57
 
58
-    public static function enqueue_jquery_css() {
58
+	public static function enqueue_jquery_css() {
59 59
 		$form = self::get_form_for_page();
60 60
 		$theme_css = FrmStylesController::get_style_val( 'theme_css', $form );
61
-        if ( $theme_css != -1 ) {
62
-            wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
63
-        }
64
-    }
61
+		if ( $theme_css != -1 ) {
62
+			wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
63
+		}
64
+	}
65 65
 
66 66
 	public static function get_form_for_page() {
67 67
 		global $frm_vars;
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
 		return $form_id;
78 78
 	}
79 79
 
80
-    public static function get_upload_base() {
81
-        $uploads = wp_upload_dir();
82
-        if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) {
83
-            $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
84
-        }
80
+	public static function get_upload_base() {
81
+		$uploads = wp_upload_dir();
82
+		if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) {
83
+			$uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
84
+		}
85 85
 
86
-        return $uploads;
87
-    }
86
+		return $uploads;
87
+	}
88 88
 
89 89
 	public static function style_menu( $active = '' ) {
90 90
 ?>
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 			<a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php esc_html_e( 'Custom CSS', 'formidable' ) ?></a>
95 95
         </h2>
96 96
 <?php
97
-    }
97
+	}
98 98
 
99 99
 	/**
100 100
 	 * @since 2.05
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 		);
187 187
 	}
188 188
 
189
-    /**
190
-     * @since 2.0
191
-     * @return The class for this icon
192
-     */
189
+	/**
190
+	 * @since 2.0
191
+	 * @return The class for this icon
192
+	 */
193 193
 	public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) {
194 194
 		if ( 'arrow' == $type && is_numeric( $key ) ) {
195 195
 			//frm_arrowup6_icon
@@ -208,20 +208,20 @@  discard block
 block discarded – undo
208 208
 			$class = 'frm_' . $plus[ $icon ];
209 209
 		}
210 210
 
211
-        if ( $key ) {
212
-            $class .= $key;
213
-        }
214
-        $class .= '_icon';
211
+		if ( $key ) {
212
+			$class .= $key;
213
+		}
214
+		$class .= '_icon';
215 215
 
216
-        return $class;
217
-    }
216
+		return $class;
217
+	}
218 218
 
219 219
 	public static function bs_icon_select( $style, $frm_style, $type = 'arrow' ) {
220 220
 		$function_name = $type . '_icons';
221 221
 		$icons = self::$function_name();
222 222
 		unset( $function_name );
223 223
 
224
-        $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
224
+		$name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
225 225
 ?>
226 226
     	<select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
227 227
             <?php foreach ( $icons as $key => $icon ) { ?>
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
             </ul>
255 255
         </div>
256 256
 <?php
257
-    }
257
+	}
258 258
 
259 259
 	public static function hex2rgb( $hex ) {
260 260
 		$hex = str_replace( '#', '', $hex );
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
             'swanky-purse'  => 'Swanky Purse',
30 30
         );
31 31
 
32
-        $themes = apply_filters('frm_jquery_themes', $themes);
32
+        $themes = apply_filters( 'frm_jquery_themes', $themes );
33 33
         return $themes;
34 34
     }
35 35
 
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 
41 41
         if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42 42
             $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
-        } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) {
43
+        } else if ( preg_match( '/^http.?:\/\/.*\..*$/', $theme_css ) ) {
44 44
             $css_file = $theme_css;
45 45
         } else {
46 46
             $uploads = self::get_upload_base();
47 47
 			$file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css';
48
-            if ( file_exists($uploads['basedir'] . $file_path) ) {
48
+            if ( file_exists( $uploads['basedir'] . $file_path ) ) {
49 49
                 $css_file = $uploads['baseurl'] . $file_path;
50 50
             } else {
51 51
 				$css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css';
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		$form = self::get_form_for_page();
60 60
 		$theme_css = FrmStylesController::get_style_val( 'theme_css', $form );
61 61
         if ( $theme_css != -1 ) {
62
-            wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
62
+            wp_enqueue_style( 'jquery-theme', self::jquery_css_url( $theme_css ), array(), FrmAppHelper::plugin_version() );
63 63
         }
64 64
     }
65 65
 
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 
80 80
     public static function get_upload_base() {
81 81
         $uploads = wp_upload_dir();
82
-        if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) {
83
-            $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
82
+        if ( is_ssl() && ! preg_match( '/^https:\/\/.*\..*$/', $uploads['baseurl'] ) ) {
83
+            $uploads['baseurl'] = str_replace( 'http://', 'https://', $uploads['baseurl'] );
84 84
         }
85 85
 
86 86
         return $uploads;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         <h2 class="nav-tab-wrapper">
92 92
 			<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles' ) ) ?>" class="nav-tab <?php echo ( '' == $active ) ? 'nav-tab-active' : '' ?>"><?php esc_html_e( 'Edit Styles', 'formidable' ) ?></a>
93 93
 			<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=manage' ) ) ?>" class="nav-tab <?php echo ( 'manage' == $active ) ? 'nav-tab-active' : '' ?>"><?php esc_html_e( 'Manage Form Styles', 'formidable' ) ?></a>
94
-			<a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php esc_html_e( 'Custom CSS', 'formidable' ) ?></a>
94
+			<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php esc_html_e( 'Custom CSS', 'formidable' ) ?></a>
95 95
         </h2>
96 96
 <?php
97 97
     }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 				'-' => 'down',
198 198
 				'+' => 'up',
199 199
 			);
200
-			$class = 'frm_arrow' . $arrow[ $icon ];
200
+			$class = 'frm_arrow' . $arrow[$icon];
201 201
 		} else {
202 202
 			//frm_minus1_icon
203 203
 			$key = str_replace( 'p', '', $key );
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 				'-' => 'minus',
206 206
 				'+' => 'plus',
207 207
 			);
208
-			$class = 'frm_' . $plus[ $icon ];
208
+			$class = 'frm_' . $plus[$icon];
209 209
 		}
210 210
 
211 211
         if ( $key ) {
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
 
224 224
         $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
225 225
 ?>
226
-    	<select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
226
+    	<select name="<?php echo esc_attr( $frm_style->get_field_name( $name ) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
227 227
             <?php foreach ( $icons as $key => $icon ) { ?>
228
-			<option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[ $name ], $key ) ?>>
228
+			<option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[$name], $key ) ?>>
229 229
 				<?php echo '&#xe' . $icon['+'] . '; &#xe' . $icon['-'] . ';'; ?>
230 230
             </option>
231 231
             <?php } ?>
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
 
234 234
         <div class="btn-group hide-if-no-js" id="frm_<?php echo esc_attr( $name ) ?>_select">
235 235
             <button class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" type="button">
236
-				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '+', $type ) ) ?>"></i>
237
-				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '-', $type ) ) ?>"></i>
236
+				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '+', $type ) ) ?>"></i>
237
+				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '-', $type ) ) ?>"></i>
238 238
                 <b class="caret"></b>
239 239
             </button>
240 240
             <ul class="multiselect-container frm-dropdown-menu">
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 * @since 2.3
272 272
 	 */
273 273
 	public static function adjust_brightness( $hex, $steps ) {
274
-		$steps = max( -255, min( 255, $steps ) );
274
+		$steps = max( - 255, min( 255, $steps ) );
275 275
 
276 276
 		// Normalize into a six character long hex string
277 277
 		$hex = str_replace( '#', '', $hex );
@@ -322,8 +322,8 @@  discard block
 block discarded – undo
322 322
 
323 323
 		$checkbox_opts = array( 'important_style', 'auto_width', 'submit_style', 'collapse_icon', 'center_form' );
324 324
 		foreach ( $checkbox_opts as $opt ) {
325
-			if ( ! isset( $settings[ $opt ] ) ) {
326
-				$settings[ $opt ] = 0;
325
+			if ( ! isset( $settings[$opt] ) ) {
326
+				$settings[$opt] = 0;
327 327
 			}
328 328
 		}
329 329
 
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 		$colors = self::allow_color_override();
340 340
 		foreach ( $colors as $css => $opts ) {
341 341
 			foreach ( $opts as $opt ) {
342
-				self::get_color_output( $css, $settings[ $opt ] );
342
+				self::get_color_output( $css, $settings[$opt] );
343 343
 			}
344 344
 		}
345 345
 	}
Please login to merge, or discard this patch.
classes/helpers/FrmAppHelper.php 2 patches
Spacing   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -24,11 +24,11 @@  discard block
 block discarded – undo
24 24
     }
25 25
 
26 26
     public static function plugin_folder() {
27
-        return basename(self::plugin_path());
27
+        return basename( self::plugin_path() );
28 28
     }
29 29
 
30 30
     public static function plugin_path() {
31
-        return dirname(dirname(dirname(__FILE__)));
31
+        return dirname( dirname( dirname( __FILE__ ) ) );
32 32
     }
33 33
 
34 34
     public static function plugin_url() {
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
      * @return string
56 56
      */
57 57
     public static function site_name() {
58
-        return get_option('blogname');
58
+        return get_option( 'blogname' );
59 59
     }
60 60
 
61 61
 	public static function make_affiliate_url( $url ) {
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public static function get_settings() {
83 83
         global $frm_settings;
84
-        if ( empty($frm_settings) ) {
84
+        if ( empty( $frm_settings ) ) {
85 85
             $frm_settings = new FrmSettings();
86 86
         }
87 87
         return $frm_settings;
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	}
102 102
 
103 103
     public static function pro_is_installed() {
104
-        return apply_filters('frm_pro_installed', false);
104
+        return apply_filters( 'frm_pro_installed', false );
105 105
     }
106 106
 
107 107
 	public static function is_formidable_admin() {
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		if ( function_exists( 'wp_doing_ajax' ) ) {
177 177
 			$doing_ajax = wp_doing_ajax();
178 178
 		} else {
179
-			$doing_ajax = defined('DOING_AJAX') && DOING_AJAX;
179
+			$doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
180 180
 		}
181 181
 		return $doing_ajax;
182 182
 	}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
      * @return string
226 226
      */
227 227
 	public static function get_server_value( $value ) {
228
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
228
+        return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : '';
229 229
     }
230 230
 
231 231
     /**
@@ -237,14 +237,14 @@  discard block
 block discarded – undo
237 237
     public static function get_ip_address() {
238 238
 		$ip = '';
239 239
 		foreach ( array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) {
240
-            if ( ! isset( $_SERVER[ $key ] ) ) {
240
+            if ( ! isset( $_SERVER[$key] ) ) {
241 241
                 continue;
242 242
             }
243 243
 
244
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
245
-                $ip = trim($ip); // just to be safe
244
+            foreach ( explode( ',', $_SERVER[$key] ) as $ip ) {
245
+                $ip = trim( $ip ); // just to be safe
246 246
 
247
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
247
+                if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
248 248
                     return sanitize_text_field( $ip );
249 249
                 }
250 250
             }
@@ -254,15 +254,15 @@  discard block
 block discarded – undo
254 254
     }
255 255
 
256 256
     public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
257
-        if ( strpos($param, '[') ) {
258
-            $params = explode('[', $param);
257
+        if ( strpos( $param, '[' ) ) {
258
+            $params = explode( '[', $param );
259 259
             $param = $params[0];
260 260
         }
261 261
 
262 262
 		if ( $src == 'get' ) {
263
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
264
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
265
-                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
263
+            $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default );
264
+            if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) {
265
+                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[$param] ) );
266 266
             }
267 267
 			self::sanitize_value( $sanitize, $value );
268 268
 		} else {
@@ -276,12 +276,12 @@  discard block
 block discarded – undo
276 276
 
277 277
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
278 278
             foreach ( $params as $k => $p ) {
279
-                if ( ! $k || ! is_array($value) ) {
279
+                if ( ! $k || ! is_array( $value ) ) {
280 280
                     continue;
281 281
                 }
282 282
 
283
-                $p = trim($p, ']');
284
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
283
+                $p = trim( $p, ']' );
284
+                $value = isset( $value[$p] ) ? $value[$p] : $default;
285 285
             }
286 286
         }
287 287
 
@@ -332,16 +332,16 @@  discard block
 block discarded – undo
332 332
 
333 333
 		$value = $args['default'];
334 334
 		if ( $args['type'] == 'get' ) {
335
-			if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
336
-				$value = $_GET[ $args['param'] ];
335
+			if ( $_GET && isset( $_GET[$args['param']] ) ) {
336
+				$value = $_GET[$args['param']];
337 337
 			}
338 338
 		} else if ( $args['type'] == 'post' ) {
339
-			if ( isset( $_POST[ $args['param'] ] ) ) {
340
-				$value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) );
339
+			if ( isset( $_POST[$args['param']] ) ) {
340
+				$value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) );
341 341
 			}
342 342
 		} else {
343
-			if ( isset( $_REQUEST[ $args['param'] ] ) ) {
344
-				$value = $_REQUEST[ $args['param'] ];
343
+			if ( isset( $_REQUEST[$args['param']] ) ) {
344
+				$value = $_REQUEST[$args['param']];
345 345
 			}
346 346
 		}
347 347
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 			if ( is_array( $value ) ) {
370 370
 				$temp_values = $value;
371 371
 				foreach ( $temp_values as $k => $v ) {
372
-					FrmAppHelper::sanitize_value( $sanitize, $value[ $k ] );
372
+					FrmAppHelper::sanitize_value( $sanitize, $value[$k] );
373 373
 				}
374 374
 			} else {
375 375
 				$value = call_user_func( $sanitize, $value );
@@ -380,8 +380,8 @@  discard block
 block discarded – undo
380 380
     public static function sanitize_request( $sanitize_method, &$values ) {
381 381
         $temp_values = $values;
382 382
         foreach ( $temp_values as $k => $val ) {
383
-            if ( isset( $sanitize_method[ $k ] ) ) {
384
-				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
383
+            if ( isset( $sanitize_method[$k] ) ) {
384
+				$values[$k] = call_user_func( $sanitize_method[$k], $val );
385 385
             }
386 386
         }
387 387
     }
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 	public static function sanitize_array( &$values ) {
390 390
 		$temp_values = $values;
391 391
 		foreach ( $temp_values as $k => $val ) {
392
-			$values[ $k ] = wp_kses_post( $val );
392
+			$values[$k] = wp_kses_post( $val );
393 393
 		}
394 394
 	}
395 395
 
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 			$allowed_html = $html;
417 417
 		} elseif ( ! empty( $allowed ) ) {
418 418
 			foreach ( (array) $allowed as $a ) {
419
-				$allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
419
+				$allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array();
420 420
 			}
421 421
 		}
422 422
 
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
      * @since 2.0
518 518
      */
519 519
     public static function remove_get_action() {
520
-        if ( ! isset($_GET) ) {
520
+        if ( ! isset( $_GET ) ) {
521 521
             return;
522 522
         }
523 523
 
@@ -539,8 +539,8 @@  discard block
 block discarded – undo
539 539
         }
540 540
 
541 541
         global $wp_query;
542
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
543
-            $value = $wp_query->query_vars[ $param ];
542
+        if ( isset( $wp_query->query_vars[$param] ) ) {
543
+            $value = $wp_query->query_vars[$param];
544 544
         }
545 545
 
546 546
         return $value;
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 		return get_posts( array(
623 623
 			'post_type'   => 'page',
624 624
 			'post_status' => array( 'publish', 'private' ),
625
-			'numberposts' => -1,
625
+			'numberposts' => - 1,
626 626
 			'orderby'     => 'title',
627 627
 			'order'       => 'ASC',
628 628
 		) );
@@ -632,10 +632,10 @@  discard block
 block discarded – undo
632 632
         $pages = self::get_pages();
633 633
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
634 634
     ?>
635
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
635
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
636 636
             <option value=""> </option>
637 637
             <?php foreach ( $pages as $page ) { ?>
638
-				<option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>>
638
+				<option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>>
639 639
 					<?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?>
640 640
 				</option>
641 641
             <?php } ?>
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
     }
645 645
 
646 646
 	public static function post_edit_link( $post_id ) {
647
-        $post = get_post($post_id);
647
+        $post = get_post( $post_id );
648 648
         if ( $post ) {
649 649
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
650 650
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 
655 655
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
656 656
 		?>
657
-		<select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php echo ( 'multiple' === $multiple ) ? 'multiple="multiple"' : ''; ?> class="frm_multiselect">
657
+		<select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php echo ( 'multiple' === $multiple ) ? 'multiple="multiple"' : ''; ?> class="frm_multiselect">
658 658
 			<?php self::roles_options( $capability ); ?>
659 659
 		</select>
660 660
 		<?php
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 
663 663
 	public static function roles_options( $capability ) {
664 664
         global $frm_vars;
665
-        if ( isset($frm_vars['editable_roles']) ) {
665
+        if ( isset( $frm_vars['editable_roles'] ) ) {
666 666
             $editable_roles = $frm_vars['editable_roles'];
667 667
         } else {
668 668
             $editable_roles = get_editable_roles();
@@ -672,9 +672,9 @@  discard block
 block discarded – undo
672 672
         foreach ( $editable_roles as $role => $details ) {
673 673
 			$name = translate_user_role( $details['name'] );
674 674
 			?>
675
-        <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
675
+        <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option>
676 676
 <?php
677
-            unset($role, $details);
677
+            unset( $role, $details );
678 678
         }
679 679
     }
680 680
 
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
     public static function maybe_add_permissions() {
731 731
 		self::force_capability( 'frm_view_entries' );
732 732
 
733
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
733
+        if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
734 734
             return;
735 735
         }
736 736
 
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
         $frm_roles = self::frm_capabilities();
740 740
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
741 741
 			$user->add_cap( $frm_role );
742
-            unset($frm_role, $frm_role_description);
742
+            unset( $frm_role, $frm_role_description );
743 743
         }
744 744
     }
745 745
 
@@ -764,12 +764,12 @@  discard block
 block discarded – undo
764 764
      * @param string $permission
765 765
      */
766 766
 	public static function permission_check( $permission, $show_message = 'show' ) {
767
-        $permission_error = self::permission_nonce_error($permission);
767
+        $permission_error = self::permission_nonce_error( $permission );
768 768
         if ( $permission_error !== false ) {
769 769
             if ( 'hide' == $show_message ) {
770 770
                 $permission_error = '';
771 771
             }
772
-            wp_die($permission_error);
772
+            wp_die( $permission_error );
773 773
         }
774 774
     }
775 775
 
@@ -786,11 +786,11 @@  discard block
 block discarded – undo
786 786
 		}
787 787
 
788 788
 		$error = false;
789
-        if ( empty($nonce_name) ) {
789
+        if ( empty( $nonce_name ) ) {
790 790
             return $error;
791 791
         }
792 792
 
793
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
793
+        if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) {
794 794
             $frm_settings = self::get_settings();
795 795
             $error = $frm_settings->admin_permission;
796 796
         }
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
 			} else {
826 826
 				foreach ( $value as $k => $v ) {
827 827
 					if ( ! is_array( $v ) ) {
828
-						$value[ $k ] = call_user_func( $original_function, $v );
828
+						$value[$k] = call_user_func( $original_function, $v );
829 829
 					}
830 830
 				}
831 831
 			}
@@ -846,11 +846,11 @@  discard block
 block discarded – undo
846 846
 	public static function array_flatten( $array, $keys = 'keep' ) {
847 847
         $return = array();
848 848
         foreach ( $array as $key => $value ) {
849
-            if ( is_array($value) ) {
849
+            if ( is_array( $value ) ) {
850 850
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
851 851
             } else {
852 852
 				if ( $keys == 'keep' ) {
853
-					$return[ $key ] = $value;
853
+					$return[$key] = $value;
854 854
 				} else {
855 855
 					$return[] = $value;
856 856
 				}
@@ -873,8 +873,8 @@  discard block
 block discarded – undo
873 873
      * @since 2.0
874 874
      */
875 875
 	public static function use_wpautop( $content ) {
876
-        if ( apply_filters('frm_use_wpautop', true) ) {
877
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
876
+        if ( apply_filters( 'frm_use_wpautop', true ) ) {
877
+            $content = wpautop( str_replace( '<br>', '<br />', $content ) );
878 878
         }
879 879
         return $content;
880 880
     }
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
      */
894 894
     public static function jquery_ui_base_url() {
895 895
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
896
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
896
+        $url = apply_filters( 'frm_jquery_ui_base_url', $url );
897 897
         return $url;
898 898
     }
899 899
 
@@ -907,11 +907,11 @@  discard block
 block discarded – undo
907 907
 		}
908 908
 
909 909
 		$ver = $default;
910
-		if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
910
+		if ( ! isset( $wp_scripts->registered[$handle] ) ) {
911 911
 			return $ver;
912 912
 		}
913 913
 
914
-		$query = $wp_scripts->registered[ $handle ];
914
+		$query = $wp_scripts->registered[$handle];
915 915
 		if ( is_object( $query ) && ! empty( $query->ver ) ) {
916 916
 			$ver = $query->ver;
917 917
 		}
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
     }
925 925
 
926 926
 	public static function get_user_id_param( $user_id ) {
927
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
927
+        if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
928 928
             return $user_id;
929 929
         }
930 930
 
@@ -932,29 +932,29 @@  discard block
 block discarded – undo
932 932
 		if ( $user_id == 'current' ) {
933 933
 			$user_id = get_current_user_id();
934 934
 		} else {
935
-            if ( is_email($user_id) ) {
936
-                $user = get_user_by('email', $user_id);
935
+            if ( is_email( $user_id ) ) {
936
+                $user = get_user_by( 'email', $user_id );
937 937
             } else {
938
-                $user = get_user_by('login', $user_id);
938
+                $user = get_user_by( 'login', $user_id );
939 939
             }
940 940
 
941 941
             if ( $user ) {
942 942
                 $user_id = $user->ID;
943 943
             }
944
-            unset($user);
944
+            unset( $user );
945 945
         }
946 946
 
947 947
         return $user_id;
948 948
     }
949 949
 
950 950
 	public static function get_file_contents( $filename, $atts = array() ) {
951
-        if ( ! is_file($filename) ) {
951
+        if ( ! is_file( $filename ) ) {
952 952
             return false;
953 953
         }
954 954
 
955
-        extract($atts);
955
+        extract( $atts );
956 956
         ob_start();
957
-        include($filename);
957
+        include( $filename );
958 958
         $contents = ob_get_contents();
959 959
         ob_end_clean();
960 960
         return $contents;
@@ -970,16 +970,16 @@  discard block
 block discarded – undo
970 970
         $key = '';
971 971
 
972 972
         if ( ! empty( $name ) ) {
973
-            $key = sanitize_key($name);
973
+            $key = sanitize_key( $name );
974 974
         }
975 975
 
976 976
 		if ( empty( $key ) ) {
977
-            $max_slug_value = pow(36, $num_chars);
977
+            $max_slug_value = pow( 36, $num_chars );
978 978
             $min_slug_value = 37; // we want to have at least 2 characters in the slug
979
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
979
+            $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
980 980
         }
981 981
 
982
-		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
982
+		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
983 983
 			$key = $key . 'a';
984 984
         }
985 985
 
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
 			'ID !'  => $id,
989 989
 		), $column );
990 990
 
991
-        if ( $key_check || is_numeric($key_check) ) {
991
+        if ( $key_check || is_numeric( $key_check ) ) {
992 992
             $suffix = 2;
993 993
 			do {
994 994
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
 					$column => $alt_post_name,
997 997
 					'ID !'  => $id,
998 998
 				), $column );
999
-				$suffix++;
999
+				$suffix ++;
1000 1000
 			} while ( $key_check || is_numeric( $key_check ) );
1001 1001
 			$key = $alt_post_name;
1002 1002
         }
@@ -1013,8 +1013,8 @@  discard block
 block discarded – undo
1013 1013
             return false;
1014 1014
         }
1015 1015
 
1016
-        if ( empty($post_values) ) {
1017
-            $post_values = stripslashes_deep($_POST);
1016
+        if ( empty( $post_values ) ) {
1017
+            $post_values = stripslashes_deep( $_POST );
1018 1018
         }
1019 1019
 
1020 1020
 		$values = array(
@@ -1023,14 +1023,14 @@  discard block
 block discarded – undo
1023 1023
 		);
1024 1024
 
1025 1025
 		foreach ( array( 'name', 'description' ) as $var ) {
1026
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
1027
-			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
1028
-            unset($var, $default_val);
1026
+            $default_val = isset( $record->{$var}) ? $record->{$var} : '';
1027
+			$values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
1028
+            unset( $var, $default_val );
1029 1029
         }
1030 1030
 
1031
-        $values['description'] = self::use_wpautop($values['description']);
1031
+        $values['description'] = self::use_wpautop( $values['description'] );
1032 1032
 
1033
-        self::fill_form_opts($record, $table, $post_values, $values);
1033
+        self::fill_form_opts( $record, $table, $post_values, $values );
1034 1034
 
1035 1035
 		self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) );
1036 1036
 
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
 	private static function prepare_field_arrays( $fields, $record, array &$values, $args ) {
1047 1047
 		if ( ! empty( $fields ) ) {
1048 1048
 			foreach ( (array) $fields as $field ) {
1049
-				$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
1049
+				$field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true );
1050 1050
 				$args['parent_form_id'] = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
1051 1051
 				self::fill_field_defaults( $field, $record, $values, $args );
1052 1052
 			}
@@ -1059,8 +1059,8 @@  discard block
 block discarded – undo
1059 1059
         if ( $args['default'] ) {
1060 1060
             $meta_value = $field->default_value;
1061 1061
         } else {
1062
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1063
-                if ( ! isset($field->field_options['custom_field']) ) {
1062
+            if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
1063
+                if ( ! isset( $field->field_options['custom_field'] ) ) {
1064 1064
                     $field->field_options['custom_field'] = '';
1065 1065
                 }
1066 1066
 				$meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array(
@@ -1074,8 +1074,8 @@  discard block
 block discarded – undo
1074 1074
             }
1075 1075
         }
1076 1076
 
1077
-		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1078
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1077
+		$field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type;
1078
+        $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value;
1079 1079
 
1080 1080
 		$field_array = self::start_field_array( $field );
1081 1081
 		$field_array['value'] = $new_value;
@@ -1086,13 +1086,13 @@  discard block
 block discarded – undo
1086 1086
 
1087 1087
 		FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args );
1088 1088
 
1089
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1089
+        if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1090 1090
             $field_array['unique_msg'] = '';
1091 1091
         }
1092 1092
 
1093 1093
         $field_array = array_merge( $field->field_options, $field_array );
1094 1094
 
1095
-        $values['fields'][ $field->id ] = $field_array;
1095
+        $values['fields'][$field->id] = $field_array;
1096 1096
     }
1097 1097
 
1098 1098
 	/**
@@ -1129,18 +1129,18 @@  discard block
 block discarded – undo
1129 1129
             return;
1130 1130
         }
1131 1131
 
1132
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1132
+        $values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1133 1133
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1134 1134
 
1135
-        if ( ! is_array($form->options) ) {
1135
+        if ( ! is_array( $form->options ) ) {
1136 1136
             return;
1137 1137
         }
1138 1138
 
1139 1139
         foreach ( $form->options as $opt => $value ) {
1140
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1140
+            $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value;
1141 1141
         }
1142 1142
 
1143
-        self::fill_form_defaults($post_values, $values);
1143
+        self::fill_form_defaults( $post_values, $values );
1144 1144
     }
1145 1145
 
1146 1146
     /**
@@ -1150,11 +1150,11 @@  discard block
 block discarded – undo
1150 1150
         $form_defaults = FrmFormsHelper::get_default_opts();
1151 1151
 
1152 1152
         foreach ( $form_defaults as $opt => $default ) {
1153
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1154
-				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1153
+            if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) {
1154
+				$values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default;
1155 1155
             }
1156 1156
 
1157
-            unset($opt, $defaut);
1157
+            unset( $opt, $defaut );
1158 1158
         }
1159 1159
 
1160 1160
 		if ( ! isset( $values['custom_style'] ) ) {
@@ -1162,10 +1162,10 @@  discard block
 block discarded – undo
1162 1162
 		}
1163 1163
 
1164 1164
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1165
-			if ( ! isset( $values[ $h . '_html' ] ) ) {
1166
-				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1165
+			if ( ! isset( $values[$h . '_html'] ) ) {
1166
+				$values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) );
1167 1167
             }
1168
-            unset($h);
1168
+            unset( $h );
1169 1169
         }
1170 1170
     }
1171 1171
 
@@ -1192,9 +1192,9 @@  discard block
 block discarded – undo
1192 1192
 		}
1193 1193
     ?>
1194 1194
 <li>
1195
-    <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a>
1196
-    <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a>
1197
-    <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a>
1195
+    <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['id'] ) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a>
1196
+    <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['key'] ) ?>" >[<?php echo esc_attr( self::truncate( $args['key'], 10 ) ) ?>]</a>
1197
+    <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['id'] ) ?>" ><?php echo esc_attr( self::truncate( $args['name'], 60 ) ) ?></a>
1198 1198
 </li>
1199 1199
     <?php
1200 1200
     }
@@ -1223,18 +1223,18 @@  discard block
 block discarded – undo
1223 1223
 		foreach ( $words as $word ) {
1224 1224
 			$part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1225 1225
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1226
-            if ( $total_len > $length && str_word_count($sub) ) {
1226
+            if ( $total_len > $length && str_word_count( $sub ) ) {
1227 1227
                 break;
1228 1228
             }
1229 1229
 
1230 1230
             $sub .= $part;
1231 1231
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1232 1232
 
1233
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1233
+            if ( str_word_count( $sub ) > $minword && $total_len >= $length ) {
1234 1234
                 break;
1235 1235
             }
1236 1236
 
1237
-            unset($total_len, $word);
1237
+            unset( $total_len, $word );
1238 1238
         }
1239 1239
 
1240 1240
 		return $sub . ( ( $len < $original_len ) ? $continue : '' );
@@ -1250,17 +1250,17 @@  discard block
 block discarded – undo
1250 1250
 	}
1251 1251
 
1252 1252
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1253
-        if ( empty($date) ) {
1253
+        if ( empty( $date ) ) {
1254 1254
             return $date;
1255 1255
         }
1256 1256
 
1257
-        if ( empty($date_format) ) {
1258
-            $date_format = get_option('date_format');
1257
+        if ( empty( $date_format ) ) {
1258
+            $date_format = get_option( 'date_format' );
1259 1259
         }
1260 1260
 
1261
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1261
+        if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1262 1262
             $frmpro_settings = new FrmProSettings();
1263
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1263
+            $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1264 1264
         }
1265 1265
 
1266 1266
 		$formatted = self::get_localized_date( $date_format, $date );
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
 
1276 1276
 	private static function add_time_to_date( $time_format, $date ) {
1277 1277
 		if ( empty( $time_format ) ) {
1278
-			$time_format = get_option('time_format');
1278
+			$time_format = get_option( 'time_format' );
1279 1279
 		}
1280 1280
 
1281 1281
 		$trimmed_format = trim( $time_format );
@@ -1321,10 +1321,10 @@  discard block
 block discarded – undo
1321 1321
 		$time_strings = self::get_time_strings();
1322 1322
 
1323 1323
 		foreach ( $time_strings as $k => $v ) {
1324
-			if ( $diff[ $k ] ) {
1325
-				$time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] );
1324
+			if ( $diff[$k] ) {
1325
+				$time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] );
1326 1326
 			} else {
1327
-				unset( $time_strings[ $k ] );
1327
+				unset( $time_strings[$k] );
1328 1328
 			}
1329 1329
 		}
1330 1330
 
@@ -1379,19 +1379,19 @@  discard block
 block discarded – undo
1379 1379
 	public static function json_to_array( $json_vars ) {
1380 1380
         $vars = array();
1381 1381
         foreach ( $json_vars as $jv ) {
1382
-            $jv_name = explode('[', $jv['name']);
1383
-            $last = count($jv_name) - 1;
1382
+            $jv_name = explode( '[', $jv['name'] );
1383
+            $last = count( $jv_name ) - 1;
1384 1384
             foreach ( $jv_name as $p => $n ) {
1385
-                $name = trim($n, ']');
1386
-                if ( ! isset($l1) ) {
1385
+                $name = trim( $n, ']' );
1386
+                if ( ! isset( $l1 ) ) {
1387 1387
                     $l1 = $name;
1388 1388
                 }
1389 1389
 
1390
-                if ( ! isset($l2) ) {
1390
+                if ( ! isset( $l2 ) ) {
1391 1391
                     $l2 = $name;
1392 1392
                 }
1393 1393
 
1394
-                if ( ! isset($l3) ) {
1394
+                if ( ! isset( $l3 ) ) {
1395 1395
                     $l3 = $name;
1396 1396
                 }
1397 1397
 
@@ -1405,23 +1405,23 @@  discard block
 block discarded – undo
1405 1405
 
1406 1406
                     case 1:
1407 1407
                         $l2 = $name;
1408
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1408
+                        self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] );
1409 1409
 						break;
1410 1410
 
1411 1411
                     case 2:
1412 1412
                         $l3 = $name;
1413
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1413
+                        self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] );
1414 1414
 						break;
1415 1415
 
1416 1416
                     case 3:
1417 1417
                         $l4 = $name;
1418
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1418
+                        self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] );
1419 1419
                 }
1420 1420
 
1421
-                unset($this_val, $n);
1421
+                unset( $this_val, $n );
1422 1422
             }
1423 1423
 
1424
-            unset($last, $jv);
1424
+            unset( $last, $jv );
1425 1425
         }
1426 1426
 
1427 1427
         return $vars;
@@ -1434,8 +1434,8 @@  discard block
 block discarded – undo
1434 1434
     public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1435 1435
         if ( $name == '' ) {
1436 1436
             $vars[] = $val;
1437
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1438
-            $vars[ $l1 ] = $val;
1437
+        } else if ( ! isset( $vars[$l1] ) ) {
1438
+            $vars[$l1] = $val;
1439 1439
         }
1440 1440
     }
1441 1441
 
@@ -1450,7 +1450,7 @@  discard block
 block discarded – undo
1450 1450
             'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ),
1451 1451
         );
1452 1452
 
1453
-        if ( ! isset( $tooltips[ $name ] ) ) {
1453
+        if ( ! isset( $tooltips[$name] ) ) {
1454 1454
             return;
1455 1455
         }
1456 1456
 
@@ -1460,7 +1460,7 @@  discard block
 block discarded – undo
1460 1460
             echo ' class="frm_help"';
1461 1461
         }
1462 1462
 
1463
-		echo ' title="' . esc_attr( $tooltips[ $name ] );
1463
+		echo ' title="' . esc_attr( $tooltips[$name] );
1464 1464
 
1465 1465
         if ( 'open' != $class ) {
1466 1466
             echo '"';
@@ -1512,13 +1512,13 @@  discard block
 block discarded – undo
1512 1512
     }
1513 1513
 
1514 1514
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1515
-		if ( ! isset( $post_content[ $key ] ) ) {
1515
+		if ( ! isset( $post_content[$key] ) ) {
1516 1516
 			return;
1517 1517
 		}
1518 1518
 
1519 1519
 		if ( is_array( $val ) ) {
1520 1520
 			foreach ( $val as $k1 => $v1 ) {
1521
-				self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] );
1521
+				self::prepare_action_slashes( $v1, $k1, $post_content[$key] );
1522 1522
 				unset( $k1, $v1 );
1523 1523
 			}
1524 1524
 		} else {
@@ -1526,22 +1526,22 @@  discard block
 block discarded – undo
1526 1526
 			$val = stripslashes( $val );
1527 1527
 
1528 1528
 			// Add backslashes before double quotes and forward slashes only
1529
-			$post_content[ $key ] = addcslashes( $val, '"\\/' );
1529
+			$post_content[$key] = addcslashes( $val, '"\\/' );
1530 1530
 		}
1531 1531
 	}
1532 1532
 
1533 1533
 	public static function maybe_json_decode( $string ) {
1534
-        if ( is_array($string) ) {
1534
+        if ( is_array( $string ) ) {
1535 1535
             return $string;
1536 1536
         }
1537 1537
 
1538
-        $new_string = json_decode($string, true);
1539
-        if ( function_exists('json_last_error') ) {
1538
+        $new_string = json_decode( $string, true );
1539
+        if ( function_exists( 'json_last_error' ) ) {
1540 1540
 			// php 5.3+
1541 1541
             if ( json_last_error() == JSON_ERROR_NONE ) {
1542 1542
                 $string = $new_string;
1543 1543
             }
1544
-        } else if ( isset($new_string) ) {
1544
+        } else if ( isset( $new_string ) ) {
1545 1545
 			// php < 5.3 fallback
1546 1546
             $string = $new_string;
1547 1547
         }
@@ -1557,11 +1557,11 @@  discard block
 block discarded – undo
1557 1557
 	public static function maybe_highlight_menu( $post_type ) {
1558 1558
         global $post;
1559 1559
 
1560
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1560
+        if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1561 1561
             return;
1562 1562
         }
1563 1563
 
1564
-        if ( is_object($post) && $post->post_type != $post_type ) {
1564
+        if ( is_object( $post ) && $post->post_type != $post_type ) {
1565 1565
             return;
1566 1566
         }
1567 1567
 
@@ -1665,11 +1665,11 @@  discard block
 block discarded – undo
1665 1665
         $frm_version = self::plugin_version();
1666 1666
 
1667 1667
         // check if Formidable meets minimum requirements
1668
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1668
+        if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1669 1669
             return;
1670 1670
         }
1671 1671
 
1672
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1672
+        $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1673 1673
 		echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' .
1674 1674
         __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1675 1675
         '</div></td></tr>';
@@ -1751,8 +1751,8 @@  discard block
 block discarded – undo
1751 1751
 			$unset = array( 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', 'es-419', 'tr' );
1752 1752
 		}
1753 1753
 
1754
-        $locales = array_diff_key($locales, array_flip($unset));
1755
-        $locales = apply_filters('frm_locales', $locales);
1754
+        $locales = array_diff_key( $locales, array_flip( $unset ) );
1755
+        $locales = apply_filters( 'frm_locales', $locales );
1756 1756
 
1757 1757
         return $locales;
1758 1758
     }
Please login to merge, or discard this patch.
Indentation   +694 added lines, -694 removed lines patch added patch discarded remove patch
@@ -13,50 +13,50 @@  discard block
 block discarded – undo
13 13
 	 */
14 14
 	public static $plug_version = '3.0.05';
15 15
 
16
-    /**
17
-     * @since 1.07.02
18
-     *
19
-     * @param none
20
-     * @return string The version of this plugin
21
-     */
22
-    public static function plugin_version() {
23
-        return self::$plug_version;
24
-    }
25
-
26
-    public static function plugin_folder() {
27
-        return basename(self::plugin_path());
28
-    }
29
-
30
-    public static function plugin_path() {
31
-        return dirname(dirname(dirname(__FILE__)));
32
-    }
33
-
34
-    public static function plugin_url() {
35
-        //prevously FRM_URL constant
16
+	/**
17
+	 * @since 1.07.02
18
+	 *
19
+	 * @param none
20
+	 * @return string The version of this plugin
21
+	 */
22
+	public static function plugin_version() {
23
+		return self::$plug_version;
24
+	}
25
+
26
+	public static function plugin_folder() {
27
+		return basename(self::plugin_path());
28
+	}
29
+
30
+	public static function plugin_path() {
31
+		return dirname(dirname(dirname(__FILE__)));
32
+	}
33
+
34
+	public static function plugin_url() {
35
+		//prevously FRM_URL constant
36 36
 		return plugins_url( '', self::plugin_path() . '/formidable.php' );
37
-    }
37
+	}
38 38
 
39 39
 	public static function relative_plugin_url() {
40 40
 		return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() );
41 41
 	}
42 42
 
43
-    /**
44
-     * @return string Site URL
45
-     */
46
-    public static function site_url() {
47
-        return site_url();
48
-    }
49
-
50
-    /**
51
-     * Get the name of this site
52
-     * Used for [sitename] shortcode
53
-     *
54
-     * @since 2.0
55
-     * @return string
56
-     */
57
-    public static function site_name() {
58
-        return get_option('blogname');
59
-    }
43
+	/**
44
+	 * @return string Site URL
45
+	 */
46
+	public static function site_url() {
47
+		return site_url();
48
+	}
49
+
50
+	/**
51
+	 * Get the name of this site
52
+	 * Used for [sitename] shortcode
53
+	 *
54
+	 * @since 2.0
55
+	 * @return string
56
+	 */
57
+	public static function site_name() {
58
+		return get_option('blogname');
59
+	}
60 60
 
61 61
 	public static function make_affiliate_url( $url ) {
62 62
 		$affiliate_id = self::get_affiliate();
@@ -71,21 +71,21 @@  discard block
 block discarded – undo
71 71
 		return absint( apply_filters( 'frm_affiliate_id', 0 ) );
72 72
 	}
73 73
 
74
-    /**
75
-     * Get the Formidable settings
76
-     *
77
-     * @since 2.0
78
-     *
79
-     * @param None
80
-     * @return FrmSettings $frm_setings
81
-     */
82
-    public static function get_settings() {
83
-        global $frm_settings;
84
-        if ( empty($frm_settings) ) {
85
-            $frm_settings = new FrmSettings();
86
-        }
87
-        return $frm_settings;
88
-    }
74
+	/**
75
+	 * Get the Formidable settings
76
+	 *
77
+	 * @since 2.0
78
+	 *
79
+	 * @param None
80
+	 * @return FrmSettings $frm_setings
81
+	 */
82
+	public static function get_settings() {
83
+		global $frm_settings;
84
+		if ( empty($frm_settings) ) {
85
+			$frm_settings = new FrmSettings();
86
+		}
87
+		return $frm_settings;
88
+	}
89 89
 
90 90
 	public static function get_menu_name() {
91 91
 		$frm_settings = FrmAppHelper::get_settings();
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
 		return ! $frm_settings->no_ips;
101 101
 	}
102 102
 
103
-    public static function pro_is_installed() {
104
-        return apply_filters('frm_pro_installed', false);
105
-    }
103
+	public static function pro_is_installed() {
104
+		return apply_filters('frm_pro_installed', false);
105
+	}
106 106
 
107 107
 	public static function is_formidable_admin() {
108 108
 		$page = self::simple_get( 'page', 'sanitize_title' );
@@ -119,50 +119,50 @@  discard block
 block discarded – undo
119 119
 		return $is_formidable;
120 120
 	}
121 121
 
122
-    /**
123
-     * Check for certain page in Formidable settings
124
-     *
125
-     * @since 2.0
126
-     *
127
-     * @param string $page The name of the page to check
128
-     * @return boolean
129
-     */
122
+	/**
123
+	 * Check for certain page in Formidable settings
124
+	 *
125
+	 * @since 2.0
126
+	 *
127
+	 * @param string $page The name of the page to check
128
+	 * @return boolean
129
+	 */
130 130
 	public static function is_admin_page( $page = 'formidable' ) {
131
-        global $pagenow;
131
+		global $pagenow;
132 132
 		$get_page = self::simple_get( 'page', 'sanitize_title' );
133
-        if ( $pagenow ) {
133
+		if ( $pagenow ) {
134 134
 			// allow this to be true during ajax load i.e. ajax form builder loading
135 135
 			return ( $pagenow == 'admin.php' || $pagenow == 'admin-ajax.php' ) && $get_page == $page;
136
-        }
136
+		}
137 137
 
138 138
 		return is_admin() && $get_page == $page;
139
-    }
140
-
141
-    /**
142
-     * Check for the form preview page
143
-     *
144
-     * @since 2.0
145
-     *
146
-     * @param None
147
-     * @return boolean
148
-     */
149
-    public static function is_preview_page() {
150
-        global $pagenow;
139
+	}
140
+
141
+	/**
142
+	 * Check for the form preview page
143
+	 *
144
+	 * @since 2.0
145
+	 *
146
+	 * @param None
147
+	 * @return boolean
148
+	 */
149
+	public static function is_preview_page() {
150
+		global $pagenow;
151 151
 		$action = FrmAppHelper::simple_get( 'action', 'sanitize_title' );
152 152
 		return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
153
-    }
154
-
155
-    /**
156
-     * Check for ajax except the form preview page
157
-     *
158
-     * @since 2.0
159
-     *
160
-     * @param None
161
-     * @return boolean
162
-     */
163
-    public static function doing_ajax() {
164
-        return self::wp_doing_ajax() && ! self::is_preview_page();
165
-    }
153
+	}
154
+
155
+	/**
156
+	 * Check for ajax except the form preview page
157
+	 *
158
+	 * @since 2.0
159
+	 *
160
+	 * @param None
161
+	 * @return boolean
162
+	 */
163
+	public static function doing_ajax() {
164
+		return self::wp_doing_ajax() && ! self::is_preview_page();
165
+	}
166 166
 
167 167
 	public static function js_suffix() {
168 168
 		return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
@@ -189,81 +189,81 @@  discard block
 block discarded – undo
189 189
 		return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
190 190
 	}
191 191
 
192
-    /**
193
-     * Check if on an admin page
194
-     *
195
-     * @since 2.0
196
-     *
197
-     * @param None
198
-     * @return boolean
199
-     */
200
-    public static function is_admin() {
201
-        return is_admin() && ! self::wp_doing_ajax();
202
-    }
203
-
204
-    /**
205
-     * Check if value contains blank value or empty array
206
-     *
207
-     * @since 2.0
208
-     * @param mixed $value - value to check
192
+	/**
193
+	 * Check if on an admin page
194
+	 *
195
+	 * @since 2.0
196
+	 *
197
+	 * @param None
198
+	 * @return boolean
199
+	 */
200
+	public static function is_admin() {
201
+		return is_admin() && ! self::wp_doing_ajax();
202
+	}
203
+
204
+	/**
205
+	 * Check if value contains blank value or empty array
206
+	 *
207
+	 * @since 2.0
208
+	 * @param mixed $value - value to check
209 209
 	 * @param string
210
-     * @return boolean
211
-     */
212
-    public static function is_empty_value( $value, $empty = '' ) {
213
-        return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
214
-    }
215
-
216
-    public static function is_not_empty_value( $value, $empty = '' ) {
217
-        return ! self::is_empty_value( $value, $empty );
218
-    }
219
-
220
-    /**
221
-     * Get any value from the $_SERVER
222
-     *
223
-     * @since 2.0
224
-     * @param string $value
225
-     * @return string
226
-     */
210
+	 * @return boolean
211
+	 */
212
+	public static function is_empty_value( $value, $empty = '' ) {
213
+		return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
214
+	}
215
+
216
+	public static function is_not_empty_value( $value, $empty = '' ) {
217
+		return ! self::is_empty_value( $value, $empty );
218
+	}
219
+
220
+	/**
221
+	 * Get any value from the $_SERVER
222
+	 *
223
+	 * @since 2.0
224
+	 * @param string $value
225
+	 * @return string
226
+	 */
227 227
 	public static function get_server_value( $value ) {
228
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
229
-    }
230
-
231
-    /**
232
-     * Check for the IP address in several places
233
-     * Used by [ip] shortcode
234
-     *
235
-     * @return string The IP address of the current user
236
-     */
237
-    public static function get_ip_address() {
228
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
229
+	}
230
+
231
+	/**
232
+	 * Check for the IP address in several places
233
+	 * Used by [ip] shortcode
234
+	 *
235
+	 * @return string The IP address of the current user
236
+	 */
237
+	public static function get_ip_address() {
238 238
 		$ip = '';
239 239
 		foreach ( array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) {
240
-            if ( ! isset( $_SERVER[ $key ] ) ) {
241
-                continue;
242
-            }
240
+			if ( ! isset( $_SERVER[ $key ] ) ) {
241
+				continue;
242
+			}
243 243
 
244
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
245
-                $ip = trim($ip); // just to be safe
244
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
245
+				$ip = trim($ip); // just to be safe
246 246
 
247
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
248
-                    return sanitize_text_field( $ip );
249
-                }
250
-            }
251
-        }
247
+				if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
248
+					return sanitize_text_field( $ip );
249
+				}
250
+			}
251
+		}
252 252
 
253 253
 		return sanitize_text_field( $ip );
254
-    }
254
+	}
255 255
 
256
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
257
-        if ( strpos($param, '[') ) {
258
-            $params = explode('[', $param);
259
-            $param = $params[0];
260
-        }
256
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
257
+		if ( strpos($param, '[') ) {
258
+			$params = explode('[', $param);
259
+			$param = $params[0];
260
+		}
261 261
 
262 262
 		if ( $src == 'get' ) {
263
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
264
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
265
-                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
266
-            }
263
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
264
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
265
+				$value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
266
+			}
267 267
 			self::sanitize_value( $sanitize, $value );
268 268
 		} else {
269 269
 			$value = self::get_simple_request( array(
@@ -275,18 +275,18 @@  discard block
 block discarded – undo
275 275
 		}
276 276
 
277 277
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
278
-            foreach ( $params as $k => $p ) {
279
-                if ( ! $k || ! is_array($value) ) {
280
-                    continue;
281
-                }
278
+			foreach ( $params as $k => $p ) {
279
+				if ( ! $k || ! is_array($value) ) {
280
+					continue;
281
+				}
282 282
 
283
-                $p = trim($p, ']');
284
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
285
-            }
286
-        }
283
+				$p = trim($p, ']');
284
+				$value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
285
+			}
286
+		}
287 287
 
288
-        return $value;
289
-    }
288
+		return $value;
289
+	}
290 290
 
291 291
 	public static function get_post_param( $param, $default = '', $sanitize = '' ) {
292 292
 		return self::get_simple_request( array(
@@ -350,12 +350,12 @@  discard block
 block discarded – undo
350 350
 	}
351 351
 
352 352
 	/**
353
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
354
-	*
355
-	* @since 2.0.8
356
-	* @param string $value
357
-	* @return string $value
358
-	*/
353
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
354
+	 *
355
+	 * @since 2.0.8
356
+	 * @param string $value
357
+	 * @return string $value
358
+	 */
359 359
 	public static function preserve_backslashes( $value ) {
360 360
 		// If backslashes have already been added, don't add them again
361 361
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -377,14 +377,14 @@  discard block
 block discarded – undo
377 377
 		}
378 378
 	}
379 379
 
380
-    public static function sanitize_request( $sanitize_method, &$values ) {
381
-        $temp_values = $values;
382
-        foreach ( $temp_values as $k => $val ) {
383
-            if ( isset( $sanitize_method[ $k ] ) ) {
380
+	public static function sanitize_request( $sanitize_method, &$values ) {
381
+		$temp_values = $values;
382
+		foreach ( $temp_values as $k => $val ) {
383
+			if ( isset( $sanitize_method[ $k ] ) ) {
384 384
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
385
-            }
386
-        }
387
-    }
385
+			}
386
+		}
387
+	}
388 388
 
389 389
 	public static function sanitize_array( &$values ) {
390 390
 		$temp_values = $values;
@@ -512,39 +512,39 @@  discard block
 block discarded – undo
512 512
 		);
513 513
 	}
514 514
 
515
-    /**
516
-     * Used when switching the action for a bulk action
517
-     * @since 2.0
518
-     */
519
-    public static function remove_get_action() {
520
-        if ( ! isset($_GET) ) {
521
-            return;
522
-        }
515
+	/**
516
+	 * Used when switching the action for a bulk action
517
+	 * @since 2.0
518
+	 */
519
+	public static function remove_get_action() {
520
+		if ( ! isset($_GET) ) {
521
+			return;
522
+		}
523 523
 
524
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
525
-        if ( ! empty( $new_action ) ) {
524
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
525
+		if ( ! empty( $new_action ) ) {
526 526
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
527
-        }
528
-    }
527
+		}
528
+	}
529 529
 
530
-    /**
531
-     * Check the WP query for a parameter
532
-     *
533
-     * @since 2.0
534
-     * @return string|array
535
-     */
536
-    public static function get_query_var( $value, $param ) {
537
-        if ( $value != '' ) {
538
-            return $value;
539
-        }
530
+	/**
531
+	 * Check the WP query for a parameter
532
+	 *
533
+	 * @since 2.0
534
+	 * @return string|array
535
+	 */
536
+	public static function get_query_var( $value, $param ) {
537
+		if ( $value != '' ) {
538
+			return $value;
539
+		}
540 540
 
541
-        global $wp_query;
542
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
543
-            $value = $wp_query->query_vars[ $param ];
544
-        }
541
+		global $wp_query;
542
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
543
+			$value = $wp_query->query_vars[ $param ];
544
+		}
545 545
 
546
-        return $value;
547
-    }
546
+		return $value;
547
+	}
548 548
 
549 549
 	/**
550 550
 	 * @since 3.0
@@ -566,16 +566,16 @@  discard block
 block discarded – undo
566 566
 		}
567 567
 	}
568 568
 
569
-    /**
570
-     * @param string $type
571
-     */
572
-    public static function trigger_hook_load( $type, $object = null ) {
573
-        // only load the form hooks once
569
+	/**
570
+	 * @param string $type
571
+	 */
572
+	public static function trigger_hook_load( $type, $object = null ) {
573
+		// only load the form hooks once
574 574
 		$hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
575
-        if ( ! $hooks_loaded ) {
575
+		if ( ! $hooks_loaded ) {
576 576
 			do_action( 'frm_load_' . $type . '_hooks' );
577
-        }
578
-    }
577
+		}
578
+	}
579 579
 
580 580
 	/**
581 581
 	 * Save all front-end js scripts into a single file
@@ -597,26 +597,26 @@  discard block
 block discarded – undo
597 597
 		$new_file->combine_files( $files );
598 598
 	}
599 599
 
600
-    /**
601
-     * Check a value from a shortcode to see if true or false.
602
-     * True when value is 1, true, 'true', 'yes'
603
-     *
604
-     * @since 1.07.10
605
-     *
606
-     * @param string $value The value to compare
607
-     * @return boolean True or False
608
-     */
600
+	/**
601
+	 * Check a value from a shortcode to see if true or false.
602
+	 * True when value is 1, true, 'true', 'yes'
603
+	 *
604
+	 * @since 1.07.10
605
+	 *
606
+	 * @param string $value The value to compare
607
+	 * @return boolean True or False
608
+	 */
609 609
 	public static function is_true( $value ) {
610
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
611
-    }
610
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
611
+	}
612 612
 
613
-    /**
614
-     * Used to filter shortcode in text widgets
615
-     */
616
-    public static function widget_text_filter_callback( $matches ) {
613
+	/**
614
+	 * Used to filter shortcode in text widgets
615
+	 */
616
+	public static function widget_text_filter_callback( $matches ) {
617 617
 		_deprecated_function( __METHOD__, '2.5.4' );
618
-        return do_shortcode( $matches[0] );
619
-    }
618
+		return do_shortcode( $matches[0] );
619
+	}
620 620
 
621 621
 	public static function get_pages() {
622 622
 		return get_posts( array(
@@ -628,10 +628,10 @@  discard block
 block discarded – undo
628 628
 		) );
629 629
 	}
630 630
 
631
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
632
-        $pages = self::get_pages();
631
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
632
+		$pages = self::get_pages();
633 633
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
634
-    ?>
634
+	?>
635 635
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
636 636
             <option value=""> </option>
637 637
             <?php foreach ( $pages as $page ) { ?>
@@ -641,16 +641,16 @@  discard block
 block discarded – undo
641 641
             <?php } ?>
642 642
         </select>
643 643
     <?php
644
-    }
644
+	}
645 645
 
646 646
 	public static function post_edit_link( $post_id ) {
647
-        $post = get_post($post_id);
648
-        if ( $post ) {
647
+		$post = get_post($post_id);
648
+		if ( $post ) {
649 649
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
650 650
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
651
-        }
652
-        return '';
653
-    }
651
+		}
652
+		return '';
653
+	}
654 654
 
655 655
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
656 656
 		?>
@@ -661,87 +661,87 @@  discard block
 block discarded – undo
661 661
 	}
662 662
 
663 663
 	public static function roles_options( $capability ) {
664
-        global $frm_vars;
665
-        if ( isset($frm_vars['editable_roles']) ) {
666
-            $editable_roles = $frm_vars['editable_roles'];
667
-        } else {
668
-            $editable_roles = get_editable_roles();
669
-            $frm_vars['editable_roles'] = $editable_roles;
670
-        }
671
-
672
-        foreach ( $editable_roles as $role => $details ) {
664
+		global $frm_vars;
665
+		if ( isset($frm_vars['editable_roles']) ) {
666
+			$editable_roles = $frm_vars['editable_roles'];
667
+		} else {
668
+			$editable_roles = get_editable_roles();
669
+			$frm_vars['editable_roles'] = $editable_roles;
670
+		}
671
+
672
+		foreach ( $editable_roles as $role => $details ) {
673 673
 			$name = translate_user_role( $details['name'] );
674 674
 			?>
675 675
         <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
676 676
 <?php
677
-            unset($role, $details);
678
-        }
679
-    }
677
+			unset($role, $details);
678
+		}
679
+	}
680 680
 
681 681
 	public static function frm_capabilities( $type = 'auto' ) {
682
-        $cap = array(
683
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
684
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
685
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
686
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
687
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
688
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
689
-        );
682
+		$cap = array(
683
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
684
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
685
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
686
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
687
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
688
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
689
+		);
690 690
 
691 691
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
692
-            return $cap;
693
-        }
692
+			return $cap;
693
+		}
694 694
 
695
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
696
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
697
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
698
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
695
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
696
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
697
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
698
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
699 699
 
700
-        return $cap;
701
-    }
700
+		return $cap;
701
+	}
702 702
 
703 703
 	public static function user_has_permission( $needed_role ) {
704
-        if ( $needed_role == '-1' ) {
705
-            return false;
704
+		if ( $needed_role == '-1' ) {
705
+			return false;
706 706
 		}
707 707
 
708
-        // $needed_role will be equal to blank if "Logged-in users" is selected
709
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
710
-            return true;
711
-        }
708
+		// $needed_role will be equal to blank if "Logged-in users" is selected
709
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
710
+			return true;
711
+		}
712 712
 
713
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
714
-        foreach ( $roles as $role ) {
713
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
714
+		foreach ( $roles as $role ) {
715 715
 			if ( current_user_can( $role ) ) {
716
-        		return true;
716
+				return true;
717 717
 			}
718
-        	if ( $role == $needed_role ) {
719
-        		break;
718
+			if ( $role == $needed_role ) {
719
+				break;
720 720
 			}
721
-        }
722
-        return false;
723
-    }
724
-
725
-    /**
726
-     * Make sure administrators can see Formidable menu
727
-     *
728
-     * @since 2.0
729
-     */
730
-    public static function maybe_add_permissions() {
721
+		}
722
+		return false;
723
+	}
724
+
725
+	/**
726
+	 * Make sure administrators can see Formidable menu
727
+	 *
728
+	 * @since 2.0
729
+	 */
730
+	public static function maybe_add_permissions() {
731 731
 		self::force_capability( 'frm_view_entries' );
732 732
 
733
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
734
-            return;
735
-        }
733
+		if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
734
+			return;
735
+		}
736 736
 
737 737
 		$user_id = get_current_user_id();
738 738
 		$user = new WP_User( $user_id );
739
-        $frm_roles = self::frm_capabilities();
740
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
739
+		$frm_roles = self::frm_capabilities();
740
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
741 741
 			$user->add_cap( $frm_role );
742
-            unset($frm_role, $frm_role_description);
743
-        }
744
-    }
742
+			unset($frm_role, $frm_role_description);
743
+		}
744
+	}
745 745
 
746 746
 	/**
747 747
 	 * Make sure admins have permission to see the menu items
@@ -757,28 +757,28 @@  discard block
 block discarded – undo
757 757
 		}
758 758
 	}
759 759
 
760
-    /**
761
-     * Check if the user has permision for action.
762
-     * Return permission message and stop the action if no permission
763
-     * @since 2.0
764
-     * @param string $permission
765
-     */
760
+	/**
761
+	 * Check if the user has permision for action.
762
+	 * Return permission message and stop the action if no permission
763
+	 * @since 2.0
764
+	 * @param string $permission
765
+	 */
766 766
 	public static function permission_check( $permission, $show_message = 'show' ) {
767
-        $permission_error = self::permission_nonce_error($permission);
768
-        if ( $permission_error !== false ) {
769
-            if ( 'hide' == $show_message ) {
770
-                $permission_error = '';
771
-            }
772
-            wp_die($permission_error);
773
-        }
774
-    }
775
-
776
-    /**
777
-     * Check user permission and nonce
778
-     * @since 2.0
779
-     * @param string $permission
780
-     * @return false|string The permission message or false if allowed
781
-     */
767
+		$permission_error = self::permission_nonce_error($permission);
768
+		if ( $permission_error !== false ) {
769
+			if ( 'hide' == $show_message ) {
770
+				$permission_error = '';
771
+			}
772
+			wp_die($permission_error);
773
+		}
774
+	}
775
+
776
+	/**
777
+	 * Check user permission and nonce
778
+	 * @since 2.0
779
+	 * @param string $permission
780
+	 * @return false|string The permission message or false if allowed
781
+	 */
782 782
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
783 783
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
784 784
 			$frm_settings = self::get_settings();
@@ -786,23 +786,23 @@  discard block
 block discarded – undo
786 786
 		}
787 787
 
788 788
 		$error = false;
789
-        if ( empty($nonce_name) ) {
790
-            return $error;
791
-        }
789
+		if ( empty($nonce_name) ) {
790
+			return $error;
791
+		}
792 792
 
793
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
794
-            $frm_settings = self::get_settings();
795
-            $error = $frm_settings->admin_permission;
796
-        }
793
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
794
+			$frm_settings = self::get_settings();
795
+			$error = $frm_settings->admin_permission;
796
+		}
797 797
 
798
-        return $error;
799
-    }
798
+		return $error;
799
+	}
800 800
 
801
-    public static function checked( $values, $current ) {
801
+	public static function checked( $values, $current ) {
802 802
 		if ( self::check_selected( $values, $current ) ) {
803
-            echo ' checked="checked"';
803
+			echo ' checked="checked"';
804 804
 		}
805
-    }
805
+	}
806 806
 
807 807
 	public static function check_selected( $values, $current ) {
808 808
 		$values = self::recursive_function_map( $values, 'trim' );
@@ -840,24 +840,24 @@  discard block
 block discarded – undo
840 840
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
841 841
 	}
842 842
 
843
-    /**
844
-     * Flatten a multi-dimensional array
845
-     */
843
+	/**
844
+	 * Flatten a multi-dimensional array
845
+	 */
846 846
 	public static function array_flatten( $array, $keys = 'keep' ) {
847
-        $return = array();
848
-        foreach ( $array as $key => $value ) {
849
-            if ( is_array($value) ) {
847
+		$return = array();
848
+		foreach ( $array as $key => $value ) {
849
+			if ( is_array($value) ) {
850 850
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
851
-            } else {
851
+			} else {
852 852
 				if ( $keys == 'keep' ) {
853 853
 					$return[ $key ] = $value;
854 854
 				} else {
855 855
 					$return[] = $value;
856 856
 				}
857
-            }
858
-        }
859
-        return $return;
860
-    }
857
+			}
858
+		}
859
+		return $return;
860
+	}
861 861
 
862 862
 	public static function esc_textarea( $text, $is_rich_text = false ) {
863 863
 		$safe_text = str_replace( '&quot;', '"', $text );
@@ -868,38 +868,38 @@  discard block
 block discarded – undo
868 868
 		return apply_filters( 'esc_textarea', $safe_text, $text );
869 869
 	}
870 870
 
871
-    /**
872
-     * Add auto paragraphs to text areas
873
-     * @since 2.0
874
-     */
871
+	/**
872
+	 * Add auto paragraphs to text areas
873
+	 * @since 2.0
874
+	 */
875 875
 	public static function use_wpautop( $content ) {
876
-        if ( apply_filters('frm_use_wpautop', true) ) {
877
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
878
-        }
879
-        return $content;
880
-    }
876
+		if ( apply_filters('frm_use_wpautop', true) ) {
877
+			$content = wpautop(str_replace( '<br>', '<br />', $content));
878
+		}
879
+		return $content;
880
+	}
881 881
 
882 882
 	public static function replace_quotes( $val ) {
883
-        //Replace double quotes
883
+		//Replace double quotes
884 884
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
885
-        //Replace single quotes
886
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
887
-        return $val;
888
-    }
889
-
890
-    /**
891
-     * @since 2.0
892
-     * @return string The base Google APIS url for the current version of jQuery UI
893
-     */
894
-    public static function jquery_ui_base_url() {
885
+		//Replace single quotes
886
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
887
+		return $val;
888
+	}
889
+
890
+	/**
891
+	 * @since 2.0
892
+	 * @return string The base Google APIS url for the current version of jQuery UI
893
+	 */
894
+	public static function jquery_ui_base_url() {
895 895
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
896
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
897
-        return $url;
898
-    }
896
+		$url = apply_filters('frm_jquery_ui_base_url', $url);
897
+		return $url;
898
+	}
899 899
 
900
-    /**
901
-     * @param string $handle
902
-     */
900
+	/**
901
+	 * @param string $handle
902
+	 */
903 903
 	public static function script_version( $handle, $default = 0 ) {
904 904
 		global $wp_scripts;
905 905
 		if ( ! $wp_scripts ) {
@@ -921,75 +921,75 @@  discard block
 block discarded – undo
921 921
 
922 922
 	public static function js_redirect( $url ) {
923 923
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
924
-    }
924
+	}
925 925
 
926 926
 	public static function get_user_id_param( $user_id ) {
927
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
928
-            return $user_id;
929
-        }
927
+		if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
928
+			return $user_id;
929
+		}
930 930
 
931 931
 		$user_id = sanitize_text_field( $user_id );
932 932
 		if ( $user_id == 'current' ) {
933 933
 			$user_id = get_current_user_id();
934 934
 		} else {
935
-            if ( is_email($user_id) ) {
936
-                $user = get_user_by('email', $user_id);
937
-            } else {
938
-                $user = get_user_by('login', $user_id);
939
-            }
935
+			if ( is_email($user_id) ) {
936
+				$user = get_user_by('email', $user_id);
937
+			} else {
938
+				$user = get_user_by('login', $user_id);
939
+			}
940 940
 
941
-            if ( $user ) {
942
-                $user_id = $user->ID;
943
-            }
944
-            unset($user);
945
-        }
941
+			if ( $user ) {
942
+				$user_id = $user->ID;
943
+			}
944
+			unset($user);
945
+		}
946 946
 
947
-        return $user_id;
948
-    }
947
+		return $user_id;
948
+	}
949 949
 
950 950
 	public static function get_file_contents( $filename, $atts = array() ) {
951
-        if ( ! is_file($filename) ) {
952
-            return false;
953
-        }
954
-
955
-        extract($atts);
956
-        ob_start();
957
-        include($filename);
958
-        $contents = ob_get_contents();
959
-        ob_end_clean();
960
-        return $contents;
961
-    }
962
-
963
-    /**
964
-     * @param string $table_name
965
-     * @param string $column
951
+		if ( ! is_file($filename) ) {
952
+			return false;
953
+		}
954
+
955
+		extract($atts);
956
+		ob_start();
957
+		include($filename);
958
+		$contents = ob_get_contents();
959
+		ob_end_clean();
960
+		return $contents;
961
+	}
962
+
963
+	/**
964
+	 * @param string $table_name
965
+	 * @param string $column
966 966
 	 * @param int $id
967 967
 	 * @param int $num_chars
968
-     */
969
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
970
-        $key = '';
968
+	 */
969
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
970
+		$key = '';
971 971
 
972
-        if ( ! empty( $name ) ) {
973
-            $key = sanitize_key($name);
974
-        }
972
+		if ( ! empty( $name ) ) {
973
+			$key = sanitize_key($name);
974
+		}
975 975
 
976 976
 		if ( empty( $key ) ) {
977
-            $max_slug_value = pow(36, $num_chars);
978
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
979
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
980
-        }
977
+			$max_slug_value = pow(36, $num_chars);
978
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
979
+			$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
980
+		}
981 981
 
982 982
 		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
983 983
 			$key = $key . 'a';
984
-        }
984
+		}
985 985
 
986 986
 		$key_check = FrmDb::get_var( $table_name, array(
987 987
 			$column => $key,
988 988
 			'ID !'  => $id,
989 989
 		), $column );
990 990
 
991
-        if ( $key_check || is_numeric($key_check) ) {
992
-            $suffix = 2;
991
+		if ( $key_check || is_numeric($key_check) ) {
992
+			$suffix = 2;
993 993
 			do {
994 994
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
995 995
 				$key_check = FrmDb::get_var( $table_name, array(
@@ -999,23 +999,23 @@  discard block
 block discarded – undo
999 999
 				$suffix++;
1000 1000
 			} while ( $key_check || is_numeric( $key_check ) );
1001 1001
 			$key = $alt_post_name;
1002
-        }
1003
-        return $key;
1004
-    }
1005
-
1006
-    /**
1007
-     * Editing a Form or Entry
1008
-     * @param string $table
1009
-     * @return bool|array
1010
-     */
1011
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1012
-        if ( ! $record ) {
1013
-            return false;
1014
-        }
1015
-
1016
-        if ( empty($post_values) ) {
1017
-            $post_values = stripslashes_deep($_POST);
1018
-        }
1002
+		}
1003
+		return $key;
1004
+	}
1005
+
1006
+	/**
1007
+	 * Editing a Form or Entry
1008
+	 * @param string $table
1009
+	 * @return bool|array
1010
+	 */
1011
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1012
+		if ( ! $record ) {
1013
+			return false;
1014
+		}
1015
+
1016
+		if ( empty($post_values) ) {
1017
+			$post_values = stripslashes_deep($_POST);
1018
+		}
1019 1019
 
1020 1020
 		$values = array(
1021 1021
 			'id' => $record->id,
@@ -1023,25 +1023,25 @@  discard block
 block discarded – undo
1023 1023
 		);
1024 1024
 
1025 1025
 		foreach ( array( 'name', 'description' ) as $var ) {
1026
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
1026
+			$default_val = isset($record->{$var}) ? $record->{$var} : '';
1027 1027
 			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
1028
-            unset($var, $default_val);
1029
-        }
1028
+			unset($var, $default_val);
1029
+		}
1030 1030
 
1031
-        $values['description'] = self::use_wpautop($values['description']);
1031
+		$values['description'] = self::use_wpautop($values['description']);
1032 1032
 
1033
-        self::fill_form_opts($record, $table, $post_values, $values);
1033
+		self::fill_form_opts($record, $table, $post_values, $values);
1034 1034
 
1035 1035
 		self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) );
1036 1036
 
1037
-        if ( $table == 'entries' ) {
1038
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1039
-        } else if ( $table == 'forms' ) {
1040
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1041
-        }
1037
+		if ( $table == 'entries' ) {
1038
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1039
+		} else if ( $table == 'forms' ) {
1040
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1041
+		}
1042 1042
 
1043
-        return $values;
1044
-    }
1043
+		return $values;
1044
+	}
1045 1045
 
1046 1046
 	private static function prepare_field_arrays( $fields, $record, array &$values, $args ) {
1047 1047
 		if ( ! empty( $fields ) ) {
@@ -1054,46 +1054,46 @@  discard block
 block discarded – undo
1054 1054
 	}
1055 1055
 
1056 1056
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
1057
-        $post_values = $args['post_values'];
1058
-
1059
-        if ( $args['default'] ) {
1060
-            $meta_value = $field->default_value;
1061
-        } else {
1062
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1063
-                if ( ! isset($field->field_options['custom_field']) ) {
1064
-                    $field->field_options['custom_field'] = '';
1065
-                }
1057
+		$post_values = $args['post_values'];
1058
+
1059
+		if ( $args['default'] ) {
1060
+			$meta_value = $field->default_value;
1061
+		} else {
1062
+			if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1063
+				if ( ! isset($field->field_options['custom_field']) ) {
1064
+					$field->field_options['custom_field'] = '';
1065
+				}
1066 1066
 				$meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array(
1067 1067
 					'truncate' => false,
1068 1068
 					'type' => $field->type,
1069 1069
 					'form_id' => $field->form_id,
1070 1070
 					'field' => $field,
1071 1071
 				) );
1072
-            } else {
1072
+			} else {
1073 1073
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1074
-            }
1075
-        }
1074
+			}
1075
+		}
1076 1076
 
1077 1077
 		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1078
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1078
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1079 1079
 
1080 1080
 		$field_array = self::start_field_array( $field );
1081 1081
 		$field_array['value'] = $new_value;
1082 1082
 		$field_array['type']  = apply_filters( 'frm_field_type', $field_type, $field, $new_value );
1083 1083
 		$field_array['parent_form_id'] = $args['parent_form_id'];
1084 1084
 
1085
-        $args['field_type'] = $field_type;
1085
+		$args['field_type'] = $field_type;
1086 1086
 
1087 1087
 		FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args );
1088 1088
 
1089
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1090
-            $field_array['unique_msg'] = '';
1091
-        }
1089
+		if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1090
+			$field_array['unique_msg'] = '';
1091
+		}
1092 1092
 
1093
-        $field_array = array_merge( $field->field_options, $field_array );
1093
+		$field_array = array_merge( $field->field_options, $field_array );
1094 1094
 
1095
-        $values['fields'][ $field->id ] = $field_array;
1096
-    }
1095
+		$values['fields'][ $field->id ] = $field_array;
1096
+	}
1097 1097
 
1098 1098
 	/**
1099 1099
 	 * @since 3.0
@@ -1114,48 +1114,48 @@  discard block
 block discarded – undo
1114 1114
 		);
1115 1115
 	}
1116 1116
 
1117
-    /**
1118
-     * @param string $table
1119
-     */
1117
+	/**
1118
+	 * @param string $table
1119
+	 */
1120 1120
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1121
-        if ( $table == 'entries' ) {
1122
-            $form = $record->form_id;
1121
+		if ( $table == 'entries' ) {
1122
+			$form = $record->form_id;
1123 1123
 			FrmForm::maybe_get_form( $form );
1124
-        } else {
1125
-            $form = $record;
1126
-        }
1124
+		} else {
1125
+			$form = $record;
1126
+		}
1127 1127
 
1128
-        if ( ! $form ) {
1129
-            return;
1130
-        }
1128
+		if ( ! $form ) {
1129
+			return;
1130
+		}
1131 1131
 
1132
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1132
+		$values['form_name'] = isset($record->form_id) ? $form->name : '';
1133 1133
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1134 1134
 
1135
-        if ( ! is_array($form->options) ) {
1136
-            return;
1137
-        }
1135
+		if ( ! is_array($form->options) ) {
1136
+			return;
1137
+		}
1138 1138
 
1139
-        foreach ( $form->options as $opt => $value ) {
1140
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1141
-        }
1139
+		foreach ( $form->options as $opt => $value ) {
1140
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1141
+		}
1142 1142
 
1143
-        self::fill_form_defaults($post_values, $values);
1144
-    }
1143
+		self::fill_form_defaults($post_values, $values);
1144
+	}
1145 1145
 
1146
-    /**
1147
-     * Set to POST value or default
1148
-     */
1146
+	/**
1147
+	 * Set to POST value or default
1148
+	 */
1149 1149
 	private static function fill_form_defaults( $post_values, array &$values ) {
1150
-        $form_defaults = FrmFormsHelper::get_default_opts();
1150
+		$form_defaults = FrmFormsHelper::get_default_opts();
1151 1151
 
1152
-        foreach ( $form_defaults as $opt => $default ) {
1153
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1152
+		foreach ( $form_defaults as $opt => $default ) {
1153
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1154 1154
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1155
-            }
1155
+			}
1156 1156
 
1157
-            unset($opt, $defaut);
1158
-        }
1157
+			unset($opt, $defaut);
1158
+		}
1159 1159
 
1160 1160
 		if ( ! isset( $values['custom_style'] ) ) {
1161 1161
 			$values['custom_style'] = self::custom_style_value( $post_values );
@@ -1164,10 +1164,10 @@  discard block
 block discarded – undo
1164 1164
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1165 1165
 			if ( ! isset( $values[ $h . '_html' ] ) ) {
1166 1166
 				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1167
-            }
1168
-            unset($h);
1169
-        }
1170
-    }
1167
+			}
1168
+			unset($h);
1169
+		}
1170
+	}
1171 1171
 
1172 1172
 	/**
1173 1173
 	 * @since 2.2.10
@@ -1190,55 +1190,55 @@  discard block
 block discarded – undo
1190 1190
 		if ( $possible_email_field ) {
1191 1191
 			$class .= 'show_frm_not_email_to';
1192 1192
 		}
1193
-    ?>
1193
+	?>
1194 1194
 <li>
1195 1195
     <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a>
1196 1196
     <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a>
1197 1197
     <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a>
1198 1198
 </li>
1199 1199
     <?php
1200
-    }
1200
+	}
1201 1201
 
1202 1202
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1203
-        if ( is_array( $str ) ) {
1204
-            return '';
1203
+		if ( is_array( $str ) ) {
1204
+			return '';
1205 1205
 		}
1206 1206
 
1207
-        $length = (int) $length;
1207
+		$length = (int) $length;
1208 1208
 		$str = wp_strip_all_tags( $str );
1209 1209
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1210 1210
 
1211 1211
 		if ( $length == 0 ) {
1212
-            return '';
1213
-        } else if ( $length <= 10 ) {
1212
+			return '';
1213
+		} else if ( $length <= 10 ) {
1214 1214
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1215 1215
 			return $sub . ( ( $length < $original_len ) ? $continue : '' );
1216
-        }
1216
+		}
1217 1217
 
1218
-        $sub = '';
1219
-        $len = 0;
1218
+		$sub = '';
1219
+		$len = 0;
1220 1220
 
1221 1221
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1222 1222
 
1223 1223
 		foreach ( $words as $word ) {
1224 1224
 			$part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1225 1225
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1226
-            if ( $total_len > $length && str_word_count($sub) ) {
1227
-                break;
1228
-            }
1226
+			if ( $total_len > $length && str_word_count($sub) ) {
1227
+				break;
1228
+			}
1229 1229
 
1230
-            $sub .= $part;
1230
+			$sub .= $part;
1231 1231
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1232 1232
 
1233
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1234
-                break;
1235
-            }
1233
+			if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1234
+				break;
1235
+			}
1236 1236
 
1237
-            unset($total_len, $word);
1238
-        }
1237
+			unset($total_len, $word);
1238
+		}
1239 1239
 
1240 1240
 		return $sub . ( ( $len < $original_len ) ? $continue : '' );
1241
-    }
1241
+	}
1242 1242
 
1243 1243
 	public static function mb_function( $function_names, $args ) {
1244 1244
 		$mb_function_name = $function_names[0];
@@ -1250,18 +1250,18 @@  discard block
 block discarded – undo
1250 1250
 	}
1251 1251
 
1252 1252
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1253
-        if ( empty($date) ) {
1254
-            return $date;
1255
-        }
1253
+		if ( empty($date) ) {
1254
+			return $date;
1255
+		}
1256 1256
 
1257
-        if ( empty($date_format) ) {
1258
-            $date_format = get_option('date_format');
1259
-        }
1257
+		if ( empty($date_format) ) {
1258
+			$date_format = get_option('date_format');
1259
+		}
1260 1260
 
1261
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1262
-            $frmpro_settings = new FrmProSettings();
1263
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1264
-        }
1261
+		if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1262
+			$frmpro_settings = new FrmProSettings();
1263
+			$date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1264
+		}
1265 1265
 
1266 1266
 		$formatted = self::get_localized_date( $date_format, $date );
1267 1267
 
@@ -1270,8 +1270,8 @@  discard block
 block discarded – undo
1270 1270
 			$formatted .= self::add_time_to_date( $time_format, $date );
1271 1271
 		}
1272 1272
 
1273
-        return $formatted;
1274
-    }
1273
+		return $formatted;
1274
+	}
1275 1275
 
1276 1276
 	private static function add_time_to_date( $time_format, $date ) {
1277 1277
 		if ( empty( $time_format ) ) {
@@ -1353,119 +1353,119 @@  discard block
 block discarded – undo
1353 1353
 		);
1354 1354
 	}
1355 1355
 
1356
-    // Pagination Methods
1356
+	// Pagination Methods
1357 1357
 
1358
-    /**
1359
-     * @param integer $current_p
1360
-     */
1358
+	/**
1359
+	 * @param integer $current_p
1360
+	 */
1361 1361
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1362 1362
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1363 1363
 	}
1364 1364
 
1365
-    /**
1366
-     * @param integer $current_p
1367
-     */
1368
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1369
-        if ( $current_p == 1 ) {
1370
-            return 1;
1371
-        } else {
1372
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1373
-        }
1374
-    }
1365
+	/**
1366
+	 * @param integer $current_p
1367
+	 */
1368
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1369
+		if ( $current_p == 1 ) {
1370
+			return 1;
1371
+		} else {
1372
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1373
+		}
1374
+	}
1375 1375
 
1376 1376
 	/**
1377 1377
 	 * @return array
1378 1378
 	 */
1379 1379
 	public static function json_to_array( $json_vars ) {
1380
-        $vars = array();
1381
-        foreach ( $json_vars as $jv ) {
1382
-            $jv_name = explode('[', $jv['name']);
1383
-            $last = count($jv_name) - 1;
1384
-            foreach ( $jv_name as $p => $n ) {
1385
-                $name = trim($n, ']');
1386
-                if ( ! isset($l1) ) {
1387
-                    $l1 = $name;
1388
-                }
1389
-
1390
-                if ( ! isset($l2) ) {
1391
-                    $l2 = $name;
1392
-                }
1393
-
1394
-                if ( ! isset($l3) ) {
1395
-                    $l3 = $name;
1396
-                }
1397
-
1398
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1399
-
1400
-                switch ( $p ) {
1401
-                    case 0:
1402
-                        $l1 = $name;
1403
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1380
+		$vars = array();
1381
+		foreach ( $json_vars as $jv ) {
1382
+			$jv_name = explode('[', $jv['name']);
1383
+			$last = count($jv_name) - 1;
1384
+			foreach ( $jv_name as $p => $n ) {
1385
+				$name = trim($n, ']');
1386
+				if ( ! isset($l1) ) {
1387
+					$l1 = $name;
1388
+				}
1389
+
1390
+				if ( ! isset($l2) ) {
1391
+					$l2 = $name;
1392
+				}
1393
+
1394
+				if ( ! isset($l3) ) {
1395
+					$l3 = $name;
1396
+				}
1397
+
1398
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1399
+
1400
+				switch ( $p ) {
1401
+					case 0:
1402
+						$l1 = $name;
1403
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1404 1404
 						break;
1405 1405
 
1406
-                    case 1:
1407
-                        $l2 = $name;
1408
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1406
+					case 1:
1407
+						$l2 = $name;
1408
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1409 1409
 						break;
1410 1410
 
1411
-                    case 2:
1412
-                        $l3 = $name;
1413
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1411
+					case 2:
1412
+						$l3 = $name;
1413
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1414 1414
 						break;
1415 1415
 
1416
-                    case 3:
1417
-                        $l4 = $name;
1418
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1419
-                }
1416
+					case 3:
1417
+						$l4 = $name;
1418
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1419
+				}
1420 1420
 
1421
-                unset($this_val, $n);
1422
-            }
1421
+				unset($this_val, $n);
1422
+			}
1423 1423
 
1424
-            unset($last, $jv);
1425
-        }
1424
+			unset($last, $jv);
1425
+		}
1426 1426
 
1427
-        return $vars;
1428
-    }
1427
+		return $vars;
1428
+	}
1429 1429
 
1430
-    /**
1431
-     * @param string $name
1432
-     * @param string $l1
1433
-     */
1434
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1435
-        if ( $name == '' ) {
1436
-            $vars[] = $val;
1437
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1438
-            $vars[ $l1 ] = $val;
1439
-        }
1440
-    }
1430
+	/**
1431
+	 * @param string $name
1432
+	 * @param string $l1
1433
+	 */
1434
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1435
+		if ( $name == '' ) {
1436
+			$vars[] = $val;
1437
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1438
+			$vars[ $l1 ] = $val;
1439
+		}
1440
+	}
1441 1441
 
1442 1442
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1443
-        $tooltips = array(
1444
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1445
-            'email_to'      => __( 'Add one or more recipient addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].  [admin_email] is the address set in WP General Settings.', 'formidable' ),
1446
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1447
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1448
-            'reply_to'      => __( 'If you would like a different reply to address than the "from" address, add a single address here.  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1449
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1450
-            'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ),
1451
-        );
1452
-
1453
-        if ( ! isset( $tooltips[ $name ] ) ) {
1454
-            return;
1455
-        }
1456
-
1457
-        if ( 'open' == $class ) {
1458
-            echo ' frm_help"';
1459
-        } else {
1460
-            echo ' class="frm_help"';
1461
-        }
1443
+		$tooltips = array(
1444
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1445
+			'email_to'      => __( 'Add one or more recipient addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].  [admin_email] is the address set in WP General Settings.', 'formidable' ),
1446
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1447
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1448
+			'reply_to'      => __( 'If you would like a different reply to address than the "from" address, add a single address here.  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1449
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1450
+			'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ),
1451
+		);
1452
+
1453
+		if ( ! isset( $tooltips[ $name ] ) ) {
1454
+			return;
1455
+		}
1456
+
1457
+		if ( 'open' == $class ) {
1458
+			echo ' frm_help"';
1459
+		} else {
1460
+			echo ' class="frm_help"';
1461
+		}
1462 1462
 
1463 1463
 		echo ' title="' . esc_attr( $tooltips[ $name ] );
1464 1464
 
1465
-        if ( 'open' != $class ) {
1466
-            echo '"';
1467
-        }
1468
-    }
1465
+		if ( 'open' != $class ) {
1466
+			echo '"';
1467
+		}
1468
+	}
1469 1469
 
1470 1470
 	/**
1471 1471
 	 * Add the current_page class to that page in the form nav
@@ -1481,35 +1481,35 @@  discard block
 block discarded – undo
1481 1481
 		}
1482 1482
 	}
1483 1483
 
1484
-    /**
1485
-     * Prepare and json_encode post content
1486
-     *
1487
-     * @since 2.0
1488
-     *
1489
-     * @param array $post_content
1490
-     * @return string $post_content ( json encoded array )
1491
-     */
1492
-    public static function prepare_and_encode( $post_content ) {
1493
-        //Loop through array to strip slashes and add only the needed ones
1484
+	/**
1485
+	 * Prepare and json_encode post content
1486
+	 *
1487
+	 * @since 2.0
1488
+	 *
1489
+	 * @param array $post_content
1490
+	 * @return string $post_content ( json encoded array )
1491
+	 */
1492
+	public static function prepare_and_encode( $post_content ) {
1493
+		//Loop through array to strip slashes and add only the needed ones
1494 1494
 		foreach ( $post_content as $key => $val ) {
1495 1495
 			// Replace problematic characters (like &quot;)
1496 1496
 			$val = str_replace( '&quot;', '"', $val );
1497 1497
 
1498 1498
 			self::prepare_action_slashes( $val, $key, $post_content );
1499
-            unset( $key, $val );
1500
-        }
1499
+			unset( $key, $val );
1500
+		}
1501 1501
 
1502
-        // json_encode the array
1503
-        $post_content = json_encode( $post_content );
1502
+		// json_encode the array
1503
+		$post_content = json_encode( $post_content );
1504 1504
 
1505
-	    // add extra slashes for \r\n since WP strips them
1505
+		// add extra slashes for \r\n since WP strips them
1506 1506
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1507 1507
 
1508
-        // allow for &quot
1509
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1508
+		// allow for &quot
1509
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1510 1510
 
1511
-        return $post_content;
1512
-    }
1511
+		return $post_content;
1512
+	}
1513 1513
 
1514 1514
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1515 1515
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1531,64 +1531,64 @@  discard block
 block discarded – undo
1531 1531
 	}
1532 1532
 
1533 1533
 	public static function maybe_json_decode( $string ) {
1534
-        if ( is_array($string) ) {
1535
-            return $string;
1536
-        }
1534
+		if ( is_array($string) ) {
1535
+			return $string;
1536
+		}
1537 1537
 
1538
-        $new_string = json_decode($string, true);
1539
-        if ( function_exists('json_last_error') ) {
1538
+		$new_string = json_decode($string, true);
1539
+		if ( function_exists('json_last_error') ) {
1540 1540
 			// php 5.3+
1541
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1542
-                $string = $new_string;
1543
-            }
1544
-        } else if ( isset($new_string) ) {
1541
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1542
+				$string = $new_string;
1543
+			}
1544
+		} else if ( isset($new_string) ) {
1545 1545
 			// php < 5.3 fallback
1546
-            $string = $new_string;
1547
-        }
1548
-        return $string;
1549
-    }
1550
-
1551
-    /**
1552
-     * @since 1.07.10
1553
-     *
1554
-     * @param string $post_type The name of the post type that may need to be highlighted
1555
-     * echo The javascript to open and highlight the Formidable menu
1556
-     */
1546
+			$string = $new_string;
1547
+		}
1548
+		return $string;
1549
+	}
1550
+
1551
+	/**
1552
+	 * @since 1.07.10
1553
+	 *
1554
+	 * @param string $post_type The name of the post type that may need to be highlighted
1555
+	 * echo The javascript to open and highlight the Formidable menu
1556
+	 */
1557 1557
 	public static function maybe_highlight_menu( $post_type ) {
1558
-        global $post;
1558
+		global $post;
1559 1559
 
1560
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1561
-            return;
1562
-        }
1560
+		if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1561
+			return;
1562
+		}
1563 1563
 
1564
-        if ( is_object($post) && $post->post_type != $post_type ) {
1565
-            return;
1566
-        }
1564
+		if ( is_object($post) && $post->post_type != $post_type ) {
1565
+			return;
1566
+		}
1567 1567
 
1568
-        self::load_admin_wide_js();
1569
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1570
-    }
1568
+		self::load_admin_wide_js();
1569
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1570
+	}
1571 1571
 
1572
-    /**
1573
-     * Load the JS file on non-Formidable pages in the admin area
1574
-     * @since 2.0
1575
-     */
1572
+	/**
1573
+	 * Load the JS file on non-Formidable pages in the admin area
1574
+	 * @since 2.0
1575
+	 */
1576 1576
 	public static function load_admin_wide_js( $load = true ) {
1577
-        $version = FrmAppHelper::plugin_version();
1577
+		$version = FrmAppHelper::plugin_version();
1578 1578
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1579 1579
 
1580
-        wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1580
+		wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1581 1581
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1582
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1582
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1583 1583
 			'url'          => FrmAppHelper::plugin_url(),
1584 1584
 			'loading'      => __( 'Loading&hellip;' ),
1585 1585
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
1586
-        ) );
1586
+		) );
1587 1587
 
1588 1588
 		if ( $load ) {
1589 1589
 			wp_enqueue_script( 'formidable_admin_global' );
1590 1590
 		}
1591
-    }
1591
+	}
1592 1592
 
1593 1593
 	/**
1594 1594
 	 * @since 2.0.9
@@ -1597,9 +1597,9 @@  discard block
 block discarded – undo
1597 1597
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1598 1598
 	}
1599 1599
 
1600
-    /**
1601
-     * @param string $location
1602
-     */
1600
+	/**
1601
+	 * @param string $location
1602
+	 */
1603 1603
 	public static function localize_script( $location ) {
1604 1604
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1605 1605
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1655,27 +1655,27 @@  discard block
 block discarded – undo
1655 1655
 		}
1656 1656
 	}
1657 1657
 
1658
-    /**
1658
+	/**
1659 1659
 	 * echo the message on the plugins listing page
1660
-     * @since 1.07.10
1661
-     *
1662
-     * @param float $min_version The version the add-on requires
1663
-     */
1660
+	 * @since 1.07.10
1661
+	 *
1662
+	 * @param float $min_version The version the add-on requires
1663
+	 */
1664 1664
 	public static function min_version_notice( $min_version ) {
1665
-        $frm_version = self::plugin_version();
1665
+		$frm_version = self::plugin_version();
1666 1666
 
1667
-        // check if Formidable meets minimum requirements
1668
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1669
-            return;
1670
-        }
1667
+		// check if Formidable meets minimum requirements
1668
+		if ( version_compare($frm_version, $min_version, '>=') ) {
1669
+			return;
1670
+		}
1671 1671
 
1672
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1672
+		$wp_list_table = _get_list_table('WP_Plugins_List_Table');
1673 1673
 		echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' .
1674
-        __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1675
-        '</div></td></tr>';
1676
-    }
1674
+		__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1675
+		'</div></td></tr>';
1676
+	}
1677 1677
 
1678
-    public static function locales( $type = 'date' ) {
1678
+	public static function locales( $type = 'date' ) {
1679 1679
 		$locales = array(
1680 1680
 			'en' => __( 'English', 'formidable' ),
1681 1681
 			''   => __( 'English/Western', 'formidable' ),
@@ -1751,11 +1751,11 @@  discard block
 block discarded – undo
1751 1751
 			$unset = array( 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', 'es-419', 'tr' );
1752 1752
 		}
1753 1753
 
1754
-        $locales = array_diff_key($locales, array_flip($unset));
1755
-        $locales = apply_filters('frm_locales', $locales);
1754
+		$locales = array_diff_key($locales, array_flip($unset));
1755
+		$locales = apply_filters('frm_locales', $locales);
1756 1756
 
1757
-        return $locales;
1758
-    }
1757
+		return $locales;
1758
+	}
1759 1759
 
1760 1760
 	/**
1761 1761
 	 * Prepare and save settings in styles and actions
Please login to merge, or discard this patch.
classes/helpers/FrmFormsListHelper.php 2 patches
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -43,30 +43,30 @@  discard block
 block discarded – undo
43 43
 			),
44 44
 		);
45 45
 		switch ( $this->status ) {
46
-		    case 'template':
47
-                $s_query['is_template'] = 1;
48
-                $s_query['status !'] = 'trash';
49
-		        break;
50
-		    case 'draft':
51
-                $s_query['is_template'] = 0;
52
-                $s_query['status'] = 'draft';
53
-		        break;
54
-		    case 'trash':
55
-                $s_query['status'] = 'trash';
56
-		        break;
57
-		    default:
58
-                $s_query['is_template'] = 0;
59
-                $s_query['status !'] = 'trash';
60
-		        break;
46
+			case 'template':
47
+				$s_query['is_template'] = 1;
48
+				$s_query['status !'] = 'trash';
49
+				break;
50
+			case 'draft':
51
+				$s_query['is_template'] = 0;
52
+				$s_query['status'] = 'draft';
53
+				break;
54
+			case 'trash':
55
+				$s_query['status'] = 'trash';
56
+				break;
57
+			default:
58
+				$s_query['is_template'] = 0;
59
+				$s_query['status !'] = 'trash';
60
+				break;
61 61
 		}
62 62
 
63 63
 		$s = self::get_param( array(
64 64
 			'param' => 's',
65 65
 			'sanitize' => 'sanitize_text_field',
66 66
 		) );
67
-	    if ( $s != '' ) {
68
-	        preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
69
-		    $search_terms = array_map('trim', $matches[0]);
67
+		if ( $s != '' ) {
68
+			preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
69
+			$search_terms = array_map('trim', $matches[0]);
70 70
 			foreach ( (array) $search_terms as $term ) {
71 71
 				$s_query[] = array(
72 72
 					'or'               => true,
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
 				);
77 77
 				unset( $term );
78 78
 			}
79
-	    }
79
+		}
80 80
 
81 81
 		$this->items = FrmForm::getAll( $s_query, $orderby . ' ' . $order, $start . ',' . $per_page );
82
-        $total_items = FrmDb::get_count( 'frm_forms', $s_query );
82
+		$total_items = FrmDb::get_count( 'frm_forms', $s_query );
83 83
 
84 84
 		$this->set_pagination_args( array(
85 85
 			'total_items' => $total_items,
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	}
89 89
 
90 90
 	public function no_items() {
91
-	    if ( 'template' == $this->status ) {
91
+		if ( 'template' == $this->status ) {
92 92
 			esc_html_e( 'No Templates Found.', 'formidable' );
93 93
 		} else {
94 94
 			esc_html_e( 'No Forms Found.', 'formidable' );
@@ -99,51 +99,51 @@  discard block
 block discarded – undo
99 99
 	}
100 100
 
101 101
 	public function get_bulk_actions() {
102
-	    $actions = array();
102
+		$actions = array();
103 103
 
104
-	    if ( 'trash' == $this->status ) {
105
-	        if ( current_user_can('frm_edit_forms') ) {
106
-	            $actions['bulk_untrash'] = __( 'Restore', 'formidable' );
107
-	        }
104
+		if ( 'trash' == $this->status ) {
105
+			if ( current_user_can('frm_edit_forms') ) {
106
+				$actions['bulk_untrash'] = __( 'Restore', 'formidable' );
107
+			}
108 108
 
109
-	        if ( current_user_can('frm_delete_forms') ) {
110
-	            $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
111
-	        }
112
-	    } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) {
113
-	        $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
114
-	    } else if ( current_user_can('frm_delete_forms') ) {
115
-	        $actions['bulk_delete'] = __( 'Delete');
116
-	    }
109
+			if ( current_user_can('frm_delete_forms') ) {
110
+				$actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
111
+			}
112
+		} else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) {
113
+			$actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
114
+		} else if ( current_user_can('frm_delete_forms') ) {
115
+			$actions['bulk_delete'] = __( 'Delete');
116
+		}
117 117
 
118
-        return $actions;
119
-    }
118
+		return $actions;
119
+	}
120 120
 
121 121
 	public function extra_tablenav( $which ) {
122
-        if ( 'top' != $which ) {
123
-            return;
124
-        }
122
+		if ( 'top' != $which ) {
123
+			return;
124
+		}
125 125
 
126
-        if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) {
126
+		if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) {
127 127
 ?>
128 128
             <div class="alignleft actions frm_visible_overflow">
129 129
 			<?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?>
130 130
             </div>
131 131
 <?php
132
-            return;
133
-        }
132
+			return;
133
+		}
134 134
 
135
-        if ( 'template' != $this->status ) {
136
-            return;
137
-        }
135
+		if ( 'template' != $this->status ) {
136
+			return;
137
+		}
138 138
 
139 139
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
140 140
 		$forms = FrmForm::get_published_forms( $where );
141 141
 
142
-        $base = admin_url('admin.php?page=formidable&form_type=template');
143
-        $args = array(
144
-            'frm_action'    => 'duplicate',
145
-            'template'      => true,
146
-        );
142
+		$base = admin_url('admin.php?page=formidable&form_type=template');
143
+		$args = array(
144
+			'frm_action'    => 'duplicate',
145
+			'template'      => true,
146
+		);
147 147
 
148 148
 ?>
149 149
     <div class="alignleft actions frm_visible_overflow">
@@ -155,16 +155,16 @@  discard block
 block discarded – undo
155 155
 		?>
156 156
 			<li class="frm_dropdown_li"><?php esc_html_e( 'You have not created any forms yet. You must create a form before you can make a template.', 'formidable' ) ?></li>
157 157
         <?php
158
-        } else {
159
-            foreach ( $forms as $form ) {
158
+		} else {
159
+			foreach ( $forms as $form ) {
160 160
 				$args['id'] = $form->id;
161 161
 				?>
162 162
 			<li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
163 163
 			<?php
164
-			    unset($form);
164
+				unset($form);
165 165
 			}
166
-        }
167
-        ?>
166
+		}
167
+		?>
168 168
 		</ul>
169 169
 	</div>
170 170
 	</div>
@@ -174,33 +174,33 @@  discard block
 block discarded – undo
174 174
 	public function get_views() {
175 175
 
176 176
 		$statuses = array(
177
-		    'published' => __( 'My Forms', 'formidable' ),
178
-		    'template'  => __( 'Templates', 'formidable' ),
179
-		    'draft'     => __( 'Drafts', 'formidable' ),
180
-		    'trash'     => __( 'Trash', 'formidable' ),
177
+			'published' => __( 'My Forms', 'formidable' ),
178
+			'template'  => __( 'Templates', 'formidable' ),
179
+			'draft'     => __( 'Drafts', 'formidable' ),
180
+			'trash'     => __( 'Trash', 'formidable' ),
181 181
 		);
182 182
 
183
-	    $links = array();
184
-	    $counts = FrmForm::get_count();
183
+		$links = array();
184
+		$counts = FrmForm::get_count();
185 185
 		$form_type = self::get_param( array(
186 186
 			'param' => 'form_type',
187 187
 			'default' => 'published',
188 188
 		) );
189 189
 
190
-	    foreach ( $statuses as $status => $name ) {
190
+		foreach ( $statuses as $status => $name ) {
191 191
 
192
-	        if ( $status == $form_type ) {
193
-    			$class = ' class="current"';
194
-    		} else {
195
-    		    $class = '';
196
-    		}
192
+			if ( $status == $form_type ) {
193
+				$class = ' class="current"';
194
+			} else {
195
+				$class = '';
196
+			}
197 197
 
198
-    		if ( $counts->{$status} || 'published' == $status ) {
198
+			if ( $counts->{$status} || 'published' == $status ) {
199 199
 				$links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
200
-		    }
200
+			}
201 201
 
202
-		    unset($status, $name);
203
-	    }
202
+			unset($status, $name);
203
+		}
204 204
 
205 205
 		return $links;
206 206
 	}
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	}
217 217
 
218 218
 	public function single_row( $item, $style = '' ) {
219
-	    global $frm_vars, $mode;
219
+		global $frm_vars, $mode;
220 220
 
221 221
 		// Set up the hover actions for this user
222 222
 		$actions = array();
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 
225 225
 		$this->get_actions( $actions, $item, $edit_link );
226 226
 
227
-        $action_links = $this->row_actions( $actions );
227
+		$action_links = $this->row_actions( $actions );
228 228
 
229 229
 		// Set up the checkbox ( because the user is editable, otherwise its empty )
230 230
 		$checkbox = '<input type="checkbox" name="item-action[]" id="cb-item-action-' . absint( $item->id ) . '" value="' . esc_attr( $item->id ) . '" />';
@@ -233,9 +233,9 @@  discard block
 block discarded – undo
233 233
 
234 234
 		list( $columns, $hidden ) = $this->get_column_info();
235 235
 
236
-        $format = 'Y/m/d';
237
-        if ( 'list' != $mode ) {
238
-            $format .= ' \<\b\r \/\> g:i:s a';
236
+		$format = 'Y/m/d';
237
+		if ( 'list' != $mode ) {
238
+			$format .= ' \<\b\r \/\> g:i:s a';
239 239
 		}
240 240
 
241 241
 		foreach ( $columns as $column_name => $column_display_name ) {
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
 			$style = '';
245 245
 			if ( in_array( $column_name, $hidden ) ) {
246
-                $class .= ' frm_hidden';
246
+				$class .= ' frm_hidden';
247 247
 			}
248 248
 
249 249
 			$class = 'class="' . esc_attr( $class ) . '"';
@@ -256,41 +256,41 @@  discard block
 block discarded – undo
256 256
 					break;
257 257
 				case 'id':
258 258
 				case 'form_key':
259
-				    $val = $item->{$column_name};
260
-				    break;
259
+					$val = $item->{$column_name};
260
+					break;
261 261
 				case 'name':
262
-				    $val = $this->get_form_name( $item, $actions, $edit_link, $mode );
263
-			        $val .= $action_links;
262
+					$val = $this->get_form_name( $item, $actions, $edit_link, $mode );
263
+					$val .= $action_links;
264 264
 
265
-				    break;
265
+					break;
266 266
 				case 'created_at':
267
-				    $date = date($format, strtotime($item->created_at));
267
+					$date = date($format, strtotime($item->created_at));
268 268
 					$val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
269 269
 					break;
270 270
 				case 'shortcode':
271 271
 					$val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable id=' . $item->id . ']' ) . '" /><br/>';
272
-				    if ( 'excerpt' == $mode ) {
272
+					if ( 'excerpt' == $mode ) {
273 273
 						$val .= '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable key=' . $item->form_key . ']' ) . '" />';
274
-				    }
275
-			        break;
276
-			    case 'entries':
274
+					}
275
+					break;
276
+				case 'entries':
277 277
 					if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) {
278 278
 						$val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr('Saving entries is disabled for this form', 'formidable' ) . '"></i>';
279
-			        } else {
280
-			            $text = FrmEntry::getRecordCount($item->id);
279
+					} else {
280
+						$text = FrmEntry::getRecordCount($item->id);
281 281
 						$val = current_user_can('frm_view_entries') ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
282
-                        unset($text);
283
-                    }
284
-			        break;
285
-                case 'type':
286
-                    $val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' );
287
-                    break;
282
+						unset($text);
283
+					}
284
+					break;
285
+				case 'type':
286
+					$val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' );
287
+					break;
288 288
 			}
289 289
 
290 290
 			if ( isset($val) ) {
291
-			    $r .= "<td $attributes>";
292
-			    $r .= $val;
293
-			    $r .= '</td>';
291
+				$r .= "<td $attributes>";
292
+				$r .= $val;
293
+				$r .= '</td>';
294 294
 			}
295 295
 			unset($val);
296 296
 		}
@@ -299,9 +299,9 @@  discard block
 block discarded – undo
299 299
 		return $r;
300 300
 	}
301 301
 
302
-    /**
303
-     * @param string $edit_link
304
-     */
302
+	/**
303
+	 * @param string $edit_link
304
+	 */
305 305
 	private function get_actions( &$actions, $item, $edit_link ) {
306 306
 		$new_actions = FrmFormsHelper::get_action_links( $item->id, $item );
307 307
 		foreach ( $new_actions as $link => $action ) {
@@ -325,52 +325,52 @@  discard block
 block discarded – undo
325 325
 
326 326
 		$actions = array_merge( $actions, $new_actions );
327 327
 		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>';
328
-    }
328
+	}
329 329
 
330
-    /**
331
-     * @param string $edit_link
332
-     */
330
+	/**
331
+	 * @param string $edit_link
332
+	 */
333 333
 	private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
334
-        $form_name = $item->name;
335
-        if ( trim($form_name) == '' ) {
336
-            $form_name = __( '(no title)');
337
-        }
334
+		$form_name = $item->name;
335
+		if ( trim($form_name) == '' ) {
336
+			$form_name = __( '(no title)');
337
+		}
338 338
 		$form_name = FrmAppHelper::kses( $form_name );
339 339
 		if ( 'excerpt' != $mode ) {
340 340
 			$form_name = FrmAppHelper::truncate( $form_name, 50 );
341 341
 		}
342 342
 
343
-        $val = '<strong>';
344
-        if ( 'trash' == $this->status ) {
345
-            $val .= $form_name;
346
-        } else {
343
+		$val = '<strong>';
344
+		if ( 'trash' == $this->status ) {
345
+			$val .= $form_name;
346
+		} else {
347 347
 			$val .= '<a href="' . esc_url( isset( $actions['frm_edit'] ) ? $edit_link : FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" class="row-title">' . FrmAppHelper::kses( $form_name ) . '</a> ';
348
-        }
348
+		}
349 349
 
350
-        $this->add_draft_label( $item, $val );
351
-        $val .= '</strong>';
350
+		$this->add_draft_label( $item, $val );
351
+		$val .= '</strong>';
352 352
 
353
-        $this->add_form_description( $item, $val );
353
+		$this->add_form_description( $item, $val );
354 354
 
355
-        return $val;
356
-    }
355
+		return $val;
356
+	}
357 357
 
358
-    /**
359
-     * @param string $val
360
-     */
361
-    private function add_draft_label( $item, &$val ) {
362
-        if ( 'draft' == $item->status && 'draft' != $this->status ) {
358
+	/**
359
+	 * @param string $val
360
+	 */
361
+	private function add_draft_label( $item, &$val ) {
362
+		if ( 'draft' == $item->status && 'draft' != $this->status ) {
363 363
 			$val .= ' - <span class="post-state">' . __( 'Draft', 'formidable' ) . '</span>';
364
-        }
365
-    }
366
-
367
-    /**
368
-     * @param string $val
369
-     */
370
-    private function add_form_description( $item, &$val ) {
371
-        global $mode;
372
-        if ( 'excerpt' == $mode ) {
373
-            $val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
374
-        }
375
-    }
364
+		}
365
+	}
366
+
367
+	/**
368
+	 * @param string $val
369
+	 */
370
+	private function add_form_description( $item, &$val ) {
371
+		global $mode;
372
+		if ( 'excerpt' == $mode ) {
373
+			$val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
374
+		}
375
+	}
376 376
 }
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 		$page = $this->get_pagenum();
19 19
 		$per_page = $this->get_items_per_page( 'formidable_page_formidable_per_page' );
20 20
 
21
-		$mode    = self::get_param( array(
21
+		$mode = self::get_param( array(
22 22
 			'param'   => 'mode',
23 23
 			'default' => 'list',
24 24
 		) );
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
 			'param'   => 'orderby',
27 27
 			'default' => 'name',
28 28
 		) );
29
-		$order   = self::get_param( array(
29
+		$order = self::get_param( array(
30 30
 			'param'   => 'order',
31 31
 			'default' => 'ASC',
32 32
 		) );
33
-		$start   = self::get_param( array(
33
+		$start = self::get_param( array(
34 34
 			'param'   => 'start',
35 35
 			'default' => ( $page - 1 ) * $per_page,
36 36
 		) );
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 			'sanitize' => 'sanitize_text_field',
66 66
 		) );
67 67
 	    if ( $s != '' ) {
68
-	        preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
69
-		    $search_terms = array_map('trim', $matches[0]);
68
+	        preg_match_all( '/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches );
69
+		    $search_terms = array_map( 'trim', $matches[0] );
70 70
 			foreach ( (array) $search_terms as $term ) {
71 71
 				$s_query[] = array(
72 72
 					'or'               => true,
@@ -102,17 +102,17 @@  discard block
 block discarded – undo
102 102
 	    $actions = array();
103 103
 
104 104
 	    if ( 'trash' == $this->status ) {
105
-	        if ( current_user_can('frm_edit_forms') ) {
105
+	        if ( current_user_can( 'frm_edit_forms' ) ) {
106 106
 	            $actions['bulk_untrash'] = __( 'Restore', 'formidable' );
107 107
 	        }
108 108
 
109
-	        if ( current_user_can('frm_delete_forms') ) {
109
+	        if ( current_user_can( 'frm_delete_forms' ) ) {
110 110
 	            $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
111 111
 	        }
112
-	    } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) {
112
+	    } else if ( EMPTY_TRASH_DAYS && current_user_can( 'frm_delete_forms' ) ) {
113 113
 	        $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
114
-	    } else if ( current_user_can('frm_delete_forms') ) {
115
-	        $actions['bulk_delete'] = __( 'Delete');
114
+	    } else if ( current_user_can( 'frm_delete_forms' ) ) {
115
+	        $actions['bulk_delete'] = __( 'Delete' );
116 116
 	    }
117 117
 
118 118
         return $actions;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
             return;
124 124
         }
125 125
 
126
-        if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) {
126
+        if ( 'trash' == $this->status && current_user_can( 'frm_delete_forms' ) ) {
127 127
 ?>
128 128
             <div class="alignleft actions frm_visible_overflow">
129 129
 			<?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?>
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
140 140
 		$forms = FrmForm::get_published_forms( $where );
141 141
 
142
-        $base = admin_url('admin.php?page=formidable&form_type=template');
142
+        $base = admin_url( 'admin.php?page=formidable&form_type=template' );
143 143
         $args = array(
144 144
             'frm_action'    => 'duplicate',
145 145
             'template'      => true,
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 				?>
162 162
 			<li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
163 163
 			<?php
164
-			    unset($form);
164
+			    unset( $form );
165 165
 			}
166 166
         }
167 167
         ?>
@@ -196,10 +196,10 @@  discard block
 block discarded – undo
196 196
     		}
197 197
 
198 198
     		if ( $counts->{$status} || 'published' == $status ) {
199
-				$links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
199
+				$links[$status] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
200 200
 		    }
201 201
 
202
-		    unset($status, $name);
202
+		    unset( $status, $name );
203 203
 	    }
204 204
 
205 205
 		return $links;
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 
265 265
 				    break;
266 266
 				case 'created_at':
267
-				    $date = date($format, strtotime($item->created_at));
267
+				    $date = date( $format, strtotime( $item->created_at ) );
268 268
 					$val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
269 269
 					break;
270 270
 				case 'shortcode':
@@ -275,11 +275,11 @@  discard block
 block discarded – undo
275 275
 			        break;
276 276
 			    case 'entries':
277 277
 					if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) {
278
-						$val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr('Saving entries is disabled for this form', 'formidable' ) . '"></i>';
278
+						$val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr( 'Saving entries is disabled for this form', 'formidable' ) . '"></i>';
279 279
 			        } else {
280
-			            $text = FrmEntry::getRecordCount($item->id);
281
-						$val = current_user_can('frm_view_entries') ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
282
-                        unset($text);
280
+			            $text = FrmEntry::getRecordCount( $item->id );
281
+						$val = current_user_can( 'frm_view_entries' ) ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
282
+                        unset( $text );
283 283
                     }
284 284
 			        break;
285 285
                 case 'type':
@@ -287,12 +287,12 @@  discard block
 block discarded – undo
287 287
                     break;
288 288
 			}
289 289
 
290
-			if ( isset($val) ) {
290
+			if ( isset( $val ) ) {
291 291
 			    $r .= "<td $attributes>";
292 292
 			    $r .= $val;
293 293
 			    $r .= '</td>';
294 294
 			}
295
-			unset($val);
295
+			unset( $val );
296 296
 		}
297 297
 		$r .= '</tr>';
298 298
 
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 	private function get_actions( &$actions, $item, $edit_link ) {
306 306
 		$new_actions = FrmFormsHelper::get_action_links( $item->id, $item );
307 307
 		foreach ( $new_actions as $link => $action ) {
308
-			$new_actions[ $link ] = FrmFormsHelper::format_link_html( $action, 'short' );
308
+			$new_actions[$link] = FrmFormsHelper::format_link_html( $action, 'short' );
309 309
 		}
310 310
 
311 311
 		if ( 'trash' == $this->status ) {
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 			return;
314 314
 		}
315 315
 
316
-		if ( current_user_can('frm_edit_forms') ) {
316
+		if ( current_user_can( 'frm_edit_forms' ) ) {
317 317
 			if ( ! $item->is_template || ! $item->default_template ) {
318 318
 				$actions['frm_edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit' ) . '</a>';
319 319
 			}
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 		}
325 325
 
326 326
 		$actions = array_merge( $actions, $new_actions );
327
-		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>';
327
+		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview' ) . '</a>';
328 328
     }
329 329
 
330 330
     /**
@@ -332,8 +332,8 @@  discard block
 block discarded – undo
332 332
      */
333 333
 	private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
334 334
         $form_name = $item->name;
335
-        if ( trim($form_name) == '' ) {
336
-            $form_name = __( '(no title)');
335
+        if ( trim( $form_name ) == '' ) {
336
+            $form_name = __( '(no title)' );
337 337
         }
338 338
 		$form_name = FrmAppHelper::kses( $form_name );
339 339
 		if ( 'excerpt' != $mode ) {
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
     private function add_form_description( $item, &$val ) {
371 371
         global $mode;
372 372
         if ( 'excerpt' == $mode ) {
373
-            $val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
373
+            $val .= FrmAppHelper::truncate( strip_tags( $item->description ), 50 );
374 374
         }
375 375
     }
376 376
 }
Please login to merge, or discard this patch.
classes/helpers/FrmShortcodeHelper.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -56,16 +56,16 @@
 block discarded – undo
56 56
 		}
57 57
 
58 58
 		$with_tags = $args['conditional_check'] ? 3 : 2;
59
-		if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
60
-			$tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
61
-			$tag = str_replace(']', '', $tag);
59
+		if ( ! empty( $shortcodes[$with_tags][$short_key] ) ) {
60
+			$tag = str_replace( '[' . $prefix, '', $shortcodes[0][$short_key] );
61
+			$tag = str_replace( ']', '', $tag );
62 62
 			$tag = str_replace( chr( 194 ) . chr( 160 ), ' ', $tag );
63 63
 			$tags = preg_split( '/\s+/', $tag, 2 );
64
-			if ( is_array($tags) ) {
64
+			if ( is_array( $tags ) ) {
65 65
 				$tag = $tags[0];
66 66
 			}
67 67
 		} else {
68
-			$tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
68
+			$tag = $shortcodes[$with_tags - 1][$short_key];
69 69
 		}
70 70
 
71 71
 		return $tag;
Please login to merge, or discard this patch.
classes/helpers/FrmFieldsHelper.php 3 patches
Indentation   +253 added lines, -253 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@  discard block
 block discarded – undo
7 7
 
8 8
 	public static function setup_new_vars( $type = '', $form_id = '' ) {
9 9
 
10
-        if ( strpos($type, '|') ) {
11
-            list($type, $setting) = explode('|', $type);
12
-        }
10
+		if ( strpos($type, '|') ) {
11
+			list($type, $setting) = explode('|', $type);
12
+		}
13 13
 
14 14
 		$values = self::get_default_field( $type );
15 15
 
@@ -29,17 +29,17 @@  discard block
 block discarded – undo
29 29
 			}
30 30
 		}
31 31
 
32
-        return $values;
33
-    }
32
+		return $values;
33
+	}
34 34
 
35 35
 	public static function get_html_id( $field, $plus = '' ) {
36 36
 		return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field );
37
-    }
37
+	}
38 38
 
39
-    public static function setup_edit_vars( $field, $doing_ajax = false ) {
39
+	public static function setup_edit_vars( $field, $doing_ajax = false ) {
40 40
 		$values = self::field_object_to_array( $field );
41 41
 		return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) );
42
-    }
42
+	}
43 43
 
44 44
 	public static function field_object_to_array( $field ) {
45 45
 		$values = (array) $field;
@@ -239,18 +239,18 @@  discard block
 block discarded – undo
239 239
 		return $field_type->get_new_field_defaults();
240 240
 	}
241 241
 
242
-    public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
243
-        global $wpdb;
242
+	public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
243
+		global $wpdb;
244 244
 
245 245
 		$values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
246
-        $values['form_id'] = $form_id;
247
-        $values['options'] = maybe_serialize($field->options);
248
-        $values['default_value'] = maybe_serialize($field->default_value);
246
+		$values['form_id'] = $form_id;
247
+		$values['options'] = maybe_serialize($field->options);
248
+		$values['default_value'] = maybe_serialize($field->default_value);
249 249
 
250
-        foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
251
-            $values[ $col ] = $field->{$col};
252
-        }
253
-    }
250
+		foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
251
+			$values[ $col ] = $field->{$col};
252
+		}
253
+	}
254 254
 
255 255
 	/**
256 256
 	 * @since 2.0
@@ -391,8 +391,8 @@  discard block
 block discarded – undo
391 391
 
392 392
 	public static function get_shortcode_tag( $shortcodes, $short_key, $args ) {
393 393
 		_deprecated_function( __FUNCTION__, '3.0', 'FrmShortcodeHelper::get_shortcode_tag' );
394
-        return FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key, $args );
395
-    }
394
+		return FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key, $args );
395
+	}
396 396
 
397 397
 	public static function get_checkbox_id( $field, $opt_key ) {
398 398
 		$id = $field['id'];
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 
405 405
 	public static function display_recaptcha( $field ) {
406 406
 		_deprecated_function( __FUNCTION__, '3.0', 'FrmFieldCaptcha::field_input' );
407
-    }
407
+	}
408 408
 
409 409
 	public static function show_single_option( $field ) {
410 410
 		if ( ! is_array( $field['options'] ) ) {
@@ -415,26 +415,26 @@  discard block
 block discarded – undo
415 415
 		$html_id = isset( $field['html_id'] ) ? $field['html_id'] : self::get_html_id( $field );
416 416
 
417 417
 		foreach ( $field['options'] as $opt_key => $opt ) {
418
-		    $field_val = self::get_value_from_array( $opt, $opt_key, $field );
419
-		    $opt = self::get_label_from_array( $opt, $opt_key, $field );
418
+			$field_val = self::get_value_from_array( $opt, $opt_key, $field );
419
+			$opt = self::get_label_from_array( $opt, $opt_key, $field );
420 420
 
421 421
 			// Get string for Other text field, if needed
422 422
 			$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
423 423
 
424 424
 			$checked = ( $other_val || isset( $field['value'] ) && ( ( ! is_array( $field['value'] ) && $field['value'] == $field_val ) || ( is_array($field['value'] ) && in_array( $field_val, $field['value'] ) ) ) ) ? ' checked="checked"' : '';
425 425
 
426
-		    // If this is an "Other" option, get the HTML for it
426
+			// If this is an "Other" option, get the HTML for it
427 427
 			if ( self::is_other_opt( $opt_key ) ) {
428 428
 				if ( FrmAppHelper::pro_is_installed() ) {
429 429
 					require( FrmProAppHelper::plugin_path() . '/classes/views/frmpro-fields/other-option.php' );
430 430
 				}
431
-		    } else {
431
+			} else {
432 432
 				require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
433
-		    }
433
+			}
434 434
 
435 435
 			unset( $checked, $other_val );
436 436
 		}
437
-    }
437
+	}
438 438
 
439 439
 	public static function get_value_from_array( $opt, $opt_key, $field ) {
440 440
 		$opt = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
@@ -452,47 +452,47 @@  discard block
 block discarded – undo
452 452
 	 * @return string
453 453
 	 */
454 454
 	public static function get_term_link( $tax_id ) {
455
-        $tax = get_taxonomy($tax_id);
456
-        if ( ! $tax ) {
457
-            return '';
458
-        }
455
+		$tax = get_taxonomy($tax_id);
456
+		if ( ! $tax ) {
457
+			return '';
458
+		}
459 459
 
460
-        $link = sprintf(
461
-            __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
460
+		$link = sprintf(
461
+			__( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
462 462
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
463
-        );
464
-        unset($tax);
463
+		);
464
+		unset($tax);
465 465
 
466
-        return $link;
467
-    }
466
+		return $link;
467
+	}
468 468
 
469 469
 	public static function value_meets_condition( $observed_value, $cond, $hide_opt ) {
470 470
 		$hide_opt = self::get_value_for_comparision( $hide_opt );
471 471
 		$observed_value = self::get_value_for_comparision( $observed_value );
472 472
 
473
-        if ( is_array($observed_value) ) {
474
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
475
-        }
476
-
477
-        $m = false;
478
-        if ( $cond == '==' ) {
479
-            $m = $observed_value == $hide_opt;
480
-        } else if ( $cond == '!=' ) {
481
-            $m = $observed_value != $hide_opt;
482
-        } else if ( $cond == '>' ) {
483
-            $m = $observed_value > $hide_opt;
484
-        } else if ( $cond == '<' ) {
485
-            $m = $observed_value < $hide_opt;
486
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
487
-            $m = stripos($observed_value, $hide_opt);
488
-            if ( $cond == 'not LIKE' ) {
489
-                $m = ( $m === false ) ? true : false;
490
-            } else {
491
-                $m = ( $m === false ) ? false : true;
492
-            }
493
-        }
494
-        return $m;
495
-    }
473
+		if ( is_array($observed_value) ) {
474
+			return self::array_value_condition($observed_value, $cond, $hide_opt);
475
+		}
476
+
477
+		$m = false;
478
+		if ( $cond == '==' ) {
479
+			$m = $observed_value == $hide_opt;
480
+		} else if ( $cond == '!=' ) {
481
+			$m = $observed_value != $hide_opt;
482
+		} else if ( $cond == '>' ) {
483
+			$m = $observed_value > $hide_opt;
484
+		} else if ( $cond == '<' ) {
485
+			$m = $observed_value < $hide_opt;
486
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
487
+			$m = stripos($observed_value, $hide_opt);
488
+			if ( $cond == 'not LIKE' ) {
489
+				$m = ( $m === false ) ? true : false;
490
+			} else {
491
+				$m = ( $m === false ) ? false : true;
492
+			}
493
+		}
494
+		return $m;
495
+	}
496 496
 
497 497
 	/**
498 498
 	 * Trim and sanitize the values
@@ -508,87 +508,87 @@  discard block
 block discarded – undo
508 508
 	}
509 509
 
510 510
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
511
-        $m = false;
512
-        if ( $cond == '==' ) {
513
-            if ( is_array($hide_opt) ) {
514
-                $m = array_intersect($hide_opt, $observed_value);
515
-                $m = empty($m) ? false : true;
516
-            } else {
517
-                $m = in_array($hide_opt, $observed_value);
518
-            }
519
-        } else if ( $cond == '!=' ) {
520
-            $m = ! in_array($hide_opt, $observed_value);
521
-        } else if ( $cond == '>' ) {
522
-            $min = min($observed_value);
523
-            $m = $min > $hide_opt;
524
-        } else if ( $cond == '<' ) {
525
-            $max = max($observed_value);
526
-            $m = $max < $hide_opt;
527
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
528
-            foreach ( $observed_value as $ob ) {
529
-                $m = strpos($ob, $hide_opt);
530
-                if ( $m !== false ) {
531
-                    $m = true;
532
-                    break;
533
-                }
534
-            }
535
-
536
-            if ( $cond == 'not LIKE' ) {
537
-                $m = ( $m === false ) ? true : false;
538
-            }
539
-        }
540
-
541
-        return $m;
542
-    }
543
-
544
-    /**
545
-     * Replace a few basic shortcodes and field ids
546
-     * @since 2.0
547
-     * @return string
548
-     */
511
+		$m = false;
512
+		if ( $cond == '==' ) {
513
+			if ( is_array($hide_opt) ) {
514
+				$m = array_intersect($hide_opt, $observed_value);
515
+				$m = empty($m) ? false : true;
516
+			} else {
517
+				$m = in_array($hide_opt, $observed_value);
518
+			}
519
+		} else if ( $cond == '!=' ) {
520
+			$m = ! in_array($hide_opt, $observed_value);
521
+		} else if ( $cond == '>' ) {
522
+			$min = min($observed_value);
523
+			$m = $min > $hide_opt;
524
+		} else if ( $cond == '<' ) {
525
+			$max = max($observed_value);
526
+			$m = $max < $hide_opt;
527
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
528
+			foreach ( $observed_value as $ob ) {
529
+				$m = strpos($ob, $hide_opt);
530
+				if ( $m !== false ) {
531
+					$m = true;
532
+					break;
533
+				}
534
+			}
535
+
536
+			if ( $cond == 'not LIKE' ) {
537
+				$m = ( $m === false ) ? true : false;
538
+			}
539
+		}
540
+
541
+		return $m;
542
+	}
543
+
544
+	/**
545
+	 * Replace a few basic shortcodes and field ids
546
+	 * @since 2.0
547
+	 * @return string
548
+	 */
549 549
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
550
-        if ( strpos($value, '[sitename]') !== false ) {
551
-            $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
552
-            $value = str_replace('[sitename]', $new_value, $value);
553
-        }
550
+		if ( strpos($value, '[sitename]') !== false ) {
551
+			$new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
552
+			$value = str_replace('[sitename]', $new_value, $value);
553
+		}
554 554
 
555
-        $value = apply_filters('frm_content', $value, $form, $entry);
556
-        $value = do_shortcode($value);
555
+		$value = apply_filters('frm_content', $value, $form, $entry);
556
+		$value = do_shortcode($value);
557 557
 
558
-        return $value;
559
-    }
558
+		return $value;
559
+	}
560 560
 
561 561
 	public static function get_shortcodes( $content, $form_id ) {
562
-        if ( FrmAppHelper::pro_is_installed() ) {
563
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
564
-        }
562
+		if ( FrmAppHelper::pro_is_installed() ) {
563
+			return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
564
+		}
565 565
 
566 566
 		$fields = FrmField::getAll( array(
567 567
 			'fi.form_id'  => (int) $form_id,
568 568
 			'fi.type not' => FrmField::no_save_fields(),
569 569
 		) );
570 570
 
571
-        $tagregexp = self::allowed_shortcodes($fields);
571
+		$tagregexp = self::allowed_shortcodes($fields);
572 572
 
573
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
573
+		preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
574 574
 
575
-        return $matches;
576
-    }
575
+		return $matches;
576
+	}
577 577
 
578 578
 	public static function allowed_shortcodes( $fields = array() ) {
579 579
 		$tagregexp = array( 'editlink', 'id', 'key', 'ip', 'siteurl', 'sitename', 'admin_email', 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', 'parent[-|_]id' );
580 580
 
581
-        foreach ( $fields as $field ) {
582
-            $tagregexp[] = $field->id;
583
-            $tagregexp[] = $field->field_key;
584
-        }
581
+		foreach ( $fields as $field ) {
582
+			$tagregexp[] = $field->id;
583
+			$tagregexp[] = $field->field_key;
584
+		}
585 585
 
586
-        $tagregexp = implode('|', $tagregexp);
587
-        return $tagregexp;
588
-    }
586
+		$tagregexp = implode('|', $tagregexp);
587
+		return $tagregexp;
588
+	}
589 589
 
590 590
 	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
591
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
591
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
592 592
 			if ( empty( $tag ) ) {
593 593
 				continue;
594 594
 			}
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 		}
609 609
 
610 610
 		return $content;
611
-    }
611
+	}
612 612
 
613 613
 	/**
614 614
 	 * @since 3.0
@@ -702,67 +702,67 @@  discard block
 block discarded – undo
702 702
 		return $replace_with;
703 703
 	}
704 704
 
705
-    /**
706
-     * Get the value to replace a few standard shortcodes
707
-     *
708
-     * @since 2.0
709
-     * @return string
710
-     */
711
-    public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
712
-        $new_value = '';
713
-        switch ( $tag ) {
714
-            case 'admin_email':
715
-                $new_value = get_option('admin_email');
716
-                break;
717
-            case 'siteurl':
718
-                $new_value = FrmAppHelper::site_url();
719
-                break;
720
-            case 'frmurl':
721
-                $new_value = FrmAppHelper::plugin_url();
722
-                break;
723
-            case 'sitename':
724
-                $new_value = FrmAppHelper::site_name();
725
-                break;
726
-            case 'get':
727
-                $new_value = self::process_get_shortcode( $atts, $return_array );
728
-        }
729
-
730
-        return $new_value;
731
-    }
732
-
733
-    /**
734
-     * Process the [get] shortcode
735
-     *
736
-     * @since 2.0
737
-     * @return string|array
738
-     */
739
-    public static function process_get_shortcode( $atts, $return_array = false ) {
740
-        if ( ! isset($atts['param']) ) {
741
-            return '';
742
-        }
743
-
744
-        if ( strpos($atts['param'], '&#91;') ) {
745
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
746
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
747
-        }
705
+	/**
706
+	 * Get the value to replace a few standard shortcodes
707
+	 *
708
+	 * @since 2.0
709
+	 * @return string
710
+	 */
711
+	public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
712
+		$new_value = '';
713
+		switch ( $tag ) {
714
+			case 'admin_email':
715
+				$new_value = get_option('admin_email');
716
+				break;
717
+			case 'siteurl':
718
+				$new_value = FrmAppHelper::site_url();
719
+				break;
720
+			case 'frmurl':
721
+				$new_value = FrmAppHelper::plugin_url();
722
+				break;
723
+			case 'sitename':
724
+				$new_value = FrmAppHelper::site_name();
725
+				break;
726
+			case 'get':
727
+				$new_value = self::process_get_shortcode( $atts, $return_array );
728
+		}
729
+
730
+		return $new_value;
731
+	}
732
+
733
+	/**
734
+	 * Process the [get] shortcode
735
+	 *
736
+	 * @since 2.0
737
+	 * @return string|array
738
+	 */
739
+	public static function process_get_shortcode( $atts, $return_array = false ) {
740
+		if ( ! isset($atts['param']) ) {
741
+			return '';
742
+		}
743
+
744
+		if ( strpos($atts['param'], '&#91;') ) {
745
+			$atts['param'] = str_replace('&#91;', '[', $atts['param']);
746
+			$atts['param'] = str_replace('&#93;', ']', $atts['param']);
747
+		}
748 748
 
749 749
 		$new_value = FrmAppHelper::get_param( $atts['param'], '', 'get', 'sanitize_text_field' );
750
-        $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
750
+		$new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
751 751
 
752
-        if ( $new_value == '' ) {
753
-            if ( ! isset($atts['prev_val']) ) {
754
-                $atts['prev_val'] = '';
755
-            }
752
+		if ( $new_value == '' ) {
753
+			if ( ! isset($atts['prev_val']) ) {
754
+				$atts['prev_val'] = '';
755
+			}
756 756
 
757
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
758
-        }
757
+			$new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
758
+		}
759 759
 
760
-        if ( is_array($new_value) && ! $return_array ) {
761
-            $new_value = implode(', ', $new_value);
762
-        }
760
+		if ( is_array($new_value) && ! $return_array ) {
761
+			$new_value = implode(', ', $new_value);
762
+		}
763 763
 
764
-        return $new_value;
765
-    }
764
+		return $new_value;
765
+	}
766 766
 
767 767
 	public static function get_display_value( $value, $field, $atts = array() ) {
768 768
 
@@ -832,27 +832,27 @@  discard block
 block discarded – undo
832 832
 
833 833
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
834 834
 
835
-        $field_types = array();
836
-        if ( in_array($type, $single_input) ) {
837
-            self::field_types_for_input( $single_input, $field_selection, $field_types );
838
-        } else if ( in_array($type, $multiple_input) ) {
839
-            self::field_types_for_input( $multiple_input, $field_selection, $field_types );
840
-        } else if ( in_array($type, $other_type) ) {
841
-            self::field_types_for_input( $other_type, $field_selection, $field_types );
835
+		$field_types = array();
836
+		if ( in_array($type, $single_input) ) {
837
+			self::field_types_for_input( $single_input, $field_selection, $field_types );
838
+		} else if ( in_array($type, $multiple_input) ) {
839
+			self::field_types_for_input( $multiple_input, $field_selection, $field_types );
840
+		} else if ( in_array($type, $other_type) ) {
841
+			self::field_types_for_input( $other_type, $field_selection, $field_types );
842 842
 		} else if ( isset( $field_selection[ $type ] ) ) {
843
-            $field_types[ $type ] = $field_selection[ $type ];
844
-        }
843
+			$field_types[ $type ] = $field_selection[ $type ];
844
+		}
845 845
 
846 846
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
847
-        return $field_types;
848
-    }
847
+		return $field_types;
848
+	}
849 849
 
850
-    private static function field_types_for_input( $inputs, $fields, &$field_types ) {
851
-        foreach ( $inputs as $input ) {
852
-            $field_types[ $input ] = $fields[ $input ];
853
-            unset($input);
854
-        }
855
-    }
850
+	private static function field_types_for_input( $inputs, $fields, &$field_types ) {
851
+		foreach ( $inputs as $input ) {
852
+			$field_types[ $input ] = $fields[ $input ];
853
+			unset($input);
854
+		}
855
+	}
856 856
 
857 857
 	/**
858 858
 	 * Check if current field option is an "other" option
@@ -866,14 +866,14 @@  discard block
 block discarded – undo
866 866
 		return $opt_key && strpos( $opt_key, 'other_' ) === 0;
867 867
 	}
868 868
 
869
-    /**
870
-    * Get value that belongs in "Other" text box
871
-    *
872
-    * @since 2.0.6
873
-    *
874
-    * @param array $args
875
-    */
876
-    public static function get_other_val( $args ) {
869
+	/**
870
+	 * Get value that belongs in "Other" text box
871
+	 *
872
+	 * @since 2.0.6
873
+	 *
874
+	 * @param array $args
875
+	 */
876
+	public static function get_other_val( $args ) {
877 877
 		$defaults = array(
878 878
 			'opt_key' => 0,
879 879
 			'field'   => array(),
@@ -951,20 +951,20 @@  discard block
 block discarded – undo
951 951
 		}
952 952
 
953 953
 		return $other_val;
954
-    }
955
-
956
-    /**
957
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
958
-    * Intended for front-end use
959
-    *
960
-    * @since 2.0.6
961
-    *
962
-    * @param array $args should include field, opt_key and field name
963
-    * @param boolean $other_opt
964
-    * @param string $checked
965
-    * @return array $other_args
966
-    */
967
-    public static function prepare_other_input( $args, &$other_opt, &$checked ) {
954
+	}
955
+
956
+	/**
957
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
958
+	 * Intended for front-end use
959
+	 *
960
+	 * @since 2.0.6
961
+	 *
962
+	 * @param array $args should include field, opt_key and field name
963
+	 * @param boolean $other_opt
964
+	 * @param string $checked
965
+	 * @return array $other_args
966
+	 */
967
+	public static function prepare_other_input( $args, &$other_opt, &$checked ) {
968 968
 		//Check if this is an "Other" option
969 969
 		if ( ! self::is_other_opt( $args['opt_key'] ) ) {
970 970
 			return;
@@ -980,8 +980,8 @@  discard block
 block discarded – undo
980 980
 			$checked = 'checked="checked" ';
981 981
 		}
982 982
 
983
-        return $other_args;
984
-    }
983
+		return $other_args;
984
+	}
985 985
 
986 986
 	/**
987 987
 	 * @param array $args
@@ -1036,8 +1036,8 @@  discard block
 block discarded – undo
1036 1036
 	 * @since 2.0.6
1037 1037
 	 */
1038 1038
 	public static function include_other_input( $args ) {
1039
-        if ( ! $args['other_opt'] ) {
1040
-        	return;
1039
+		if ( ! $args['other_opt'] ) {
1040
+			return;
1041 1041
 		}
1042 1042
 
1043 1043
 		$classes = array( 'frm_other_input' );
@@ -1062,15 +1062,15 @@  discard block
 block discarded – undo
1062 1062
 	}
1063 1063
 
1064 1064
 	/**
1065
-	* Get the HTML id for an "Other" text field
1066
-	* Note: This does not affect fields in repeating sections
1067
-	*
1068
-	* @since 2.0.08
1069
-	* @param string $type - field type
1070
-	* @param string $html_id
1071
-	* @param string|boolean $opt_key
1072
-	* @return string $other_id
1073
-	*/
1065
+	 * Get the HTML id for an "Other" text field
1066
+	 * Note: This does not affect fields in repeating sections
1067
+	 *
1068
+	 * @since 2.0.08
1069
+	 * @param string $type - field type
1070
+	 * @param string $html_id
1071
+	 * @param string|boolean $opt_key
1072
+	 * @return string $other_id
1073
+	 */
1074 1074
 	public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) {
1075 1075
 		$other_id = $html_id;
1076 1076
 
@@ -1134,10 +1134,10 @@  discard block
 block discarded – undo
1134 1134
 	}
1135 1135
 
1136 1136
 	public static function switch_field_ids( $val ) {
1137
-        global $frm_duplicate_ids;
1138
-        $replace = array();
1139
-        $replace_with = array();
1140
-        foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1137
+		global $frm_duplicate_ids;
1138
+		$replace = array();
1139
+		$replace_with = array();
1140
+		foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1141 1141
 			$replace[] = '[if ' . $old . ']';
1142 1142
 			$replace_with[] = '[if ' . $new . ']';
1143 1143
 			$replace[] = '[if ' . $old . ' ';
@@ -1152,19 +1152,19 @@  discard block
 block discarded – undo
1152 1152
 			$replace_with[] = '[' . $new . ']';
1153 1153
 			$replace[] = '[' . $old . ' ';
1154 1154
 			$replace_with[] = '[' . $new . ' ';
1155
-            unset($old, $new);
1156
-        }
1155
+			unset($old, $new);
1156
+		}
1157 1157
 		if ( is_array( $val ) ) {
1158 1158
 			foreach ( $val as $k => $v ) {
1159
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1160
-                unset($k, $v);
1161
-            }
1162
-        } else {
1163
-            $val = str_replace($replace, $replace_with, $val);
1164
-        }
1159
+				$val[ $k ] = str_replace( $replace, $replace_with, $v );
1160
+				unset($k, $v);
1161
+			}
1162
+		} else {
1163
+			$val = str_replace($replace, $replace_with, $val);
1164
+		}
1165 1165
 
1166
-        return $val;
1167
-    }
1166
+		return $val;
1167
+	}
1168 1168
 
1169 1169
 	public static function get_us_states() {
1170 1170
 		return apply_filters( 'frm_us_states', array(
@@ -1229,15 +1229,15 @@  discard block
 block discarded – undo
1229 1229
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1230 1230
 		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1231 1231
 
1232
-        $states = FrmFieldsHelper::get_us_states();
1233
-        $state_abv = array_keys($states);
1234
-        sort($state_abv);
1232
+		$states = FrmFieldsHelper::get_us_states();
1233
+		$state_abv = array_keys($states);
1234
+		sort($state_abv);
1235 1235
 		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1236 1236
 
1237
-        $states = array_values($states);
1238
-        sort($states);
1237
+		$states = array_values($states);
1238
+		sort($states);
1239 1239
 		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1240
-        unset($state_abv, $states);
1240
+		unset($state_abv, $states);
1241 1241
 
1242 1242
 		$prepop[ __( 'Age', 'formidable' ) ] = array(
1243 1243
 			__( 'Under 18', 'formidable' ),
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
 		);
1279 1279
 
1280 1280
 		$prepop = apply_filters( 'frm_bulk_field_choices', $prepop );
1281
-    }
1281
+	}
1282 1282
 
1283 1283
 	/**
1284 1284
 	 * Display a field value selector
@@ -1288,10 +1288,10 @@  discard block
 block discarded – undo
1288 1288
 	 * @param int $selector_field_id
1289 1289
 	 * @param array $selector_args
1290 1290
 	 */
1291
-    public static function display_field_value_selector( $selector_field_id, $selector_args ) {
1292
-	    $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args );
1293
-	    $field_value_selector->display();
1294
-    }
1291
+	public static function display_field_value_selector( $selector_field_id, $selector_args ) {
1292
+		$field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args );
1293
+		$field_value_selector->display();
1294
+	}
1295 1295
 
1296 1296
 	/**
1297 1297
 	 * Convert a field object to a flat array
Please login to merge, or discard this patch.
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
 
8 8
 	public static function setup_new_vars( $type = '', $form_id = '' ) {
9 9
 
10
-        if ( strpos($type, '|') ) {
11
-            list($type, $setting) = explode('|', $type);
10
+        if ( strpos( $type, '|' ) ) {
11
+            list( $type, $setting ) = explode( '|', $type );
12 12
         }
13 13
 
14 14
 		$values = self::get_default_field( $type );
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 			if ( in_array( $type, array( 'data', 'lookup' ) ) ) {
26 26
 				$values['field_options']['data_type'] = $setting;
27 27
 			} else {
28
-				$values['field_options'][ $setting ] = 1;
28
+				$values['field_options'][$setting] = 1;
29 29
 			}
30 30
 		}
31 31
 
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 		}
128 128
 
129 129
 		foreach ( $defaults as $opt => $default ) {
130
-			$values[ $opt ] = isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default;
130
+			$values[$opt] = isset( $field->field_options[$opt] ) ? $field->field_options[$opt] : $default;
131 131
 
132 132
 			if ( $check_post ) {
133
-				self::get_posted_field_setting( $opt . '_' . $field->id, $values[ $opt ] );
133
+				self::get_posted_field_setting( $opt . '_' . $field->id, $values[$opt] );
134 134
 			}
135 135
 
136 136
 			unset( $opt, $default );
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 	 * @param mixed $value
174 174
 	 */
175 175
 	private static function get_posted_field_setting( $setting, &$value ) {
176
-		if ( isset( $_POST['field_options'][ $setting ] ) ) {
177
-			$value = maybe_unserialize( $_POST['field_options'][ $setting ] );
176
+		if ( isset( $_POST['field_options'][$setting] ) ) {
177
+			$value = maybe_unserialize( $_POST['field_options'][$setting] );
178 178
 			if ( strpos( $setting, 'html' ) !== false ) {
179 179
 				// strip slashes from HTML but not regex
180 180
 				$value = stripslashes_deep( $value );
@@ -244,11 +244,11 @@  discard block
 block discarded – undo
244 244
 
245 245
 		$values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
246 246
         $values['form_id'] = $form_id;
247
-        $values['options'] = maybe_serialize($field->options);
248
-        $values['default_value'] = maybe_serialize($field->default_value);
247
+        $values['options'] = maybe_serialize( $field->options );
248
+        $values['default_value'] = maybe_serialize( $field->default_value );
249 249
 
250 250
         foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
251
-            $values[ $col ] = $field->{$col};
251
+            $values[$col] = $field->{$col};
252 252
         }
253 253
     }
254 254
 
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
 		$defaults = array(
270 270
 			'unique_msg' => array(
271 271
 				'full' => $default_settings['unique_msg'],
272
-				'part' => sprintf( __('%s must be unique', 'formidable' ), $field_name ),
272
+				'part' => sprintf( __( '%s must be unique', 'formidable' ), $field_name ),
273 273
 			),
274 274
 			'invalid'  => array(
275 275
 				'full' => __( 'This field is invalid', 'formidable' ),
276
-				'part' => sprintf( __('%s is invalid', 'formidable' ), $field_name ),
276
+				'part' => sprintf( __( '%s is invalid', 'formidable' ), $field_name ),
277 277
 			),
278 278
 			'blank'    => array(
279 279
 				'full' => $frm_settings->blank_msg,
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 		);
287 287
 
288 288
 		$msg = FrmField::get_option( $field, $error );
289
-		$msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg;
289
+		$msg = empty( $msg ) ? $defaults[$error]['part'] : $msg;
290 290
 		$msg = do_shortcode( $msg );
291 291
 		return $msg;
292 292
 	}
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 			$default_html = apply_filters( 'frm_other_custom_html', '', $type );
306 306
 		}
307 307
 
308
-		return apply_filters('frm_custom_html', $default_html, $type);
308
+		return apply_filters( 'frm_custom_html', $default_html, $type );
309 309
 	}
310 310
 
311 311
 	/**
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 			// Get string for Other text field, if needed
422 422
 			$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
423 423
 
424
-			$checked = ( $other_val || isset( $field['value'] ) && ( ( ! is_array( $field['value'] ) && $field['value'] == $field_val ) || ( is_array($field['value'] ) && in_array( $field_val, $field['value'] ) ) ) ) ? ' checked="checked"' : '';
424
+			$checked = ( $other_val || isset( $field['value'] ) && ( ( ! is_array( $field['value'] ) && $field['value'] == $field_val ) || ( is_array( $field['value'] ) && in_array( $field_val, $field['value'] ) ) ) ) ? ' checked="checked"' : '';
425 425
 
426 426
 		    // If this is an "Other" option, get the HTML for it
427 427
 			if ( self::is_other_opt( $opt_key ) ) {
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 	 * @return string
453 453
 	 */
454 454
 	public static function get_term_link( $tax_id ) {
455
-        $tax = get_taxonomy($tax_id);
455
+        $tax = get_taxonomy( $tax_id );
456 456
         if ( ! $tax ) {
457 457
             return '';
458 458
         }
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
             __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
462 462
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
463 463
         );
464
-        unset($tax);
464
+        unset( $tax );
465 465
 
466 466
         return $link;
467 467
     }
@@ -470,8 +470,8 @@  discard block
 block discarded – undo
470 470
 		$hide_opt = self::get_value_for_comparision( $hide_opt );
471 471
 		$observed_value = self::get_value_for_comparision( $observed_value );
472 472
 
473
-        if ( is_array($observed_value) ) {
474
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
473
+        if ( is_array( $observed_value ) ) {
474
+            return self::array_value_condition( $observed_value, $cond, $hide_opt );
475 475
         }
476 476
 
477 477
         $m = false;
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
         } else if ( $cond == '<' ) {
485 485
             $m = $observed_value < $hide_opt;
486 486
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
487
-            $m = stripos($observed_value, $hide_opt);
487
+            $m = stripos( $observed_value, $hide_opt );
488 488
             if ( $cond == 'not LIKE' ) {
489 489
                 $m = ( $m === false ) ? true : false;
490 490
             } else {
@@ -510,23 +510,23 @@  discard block
 block discarded – undo
510 510
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
511 511
         $m = false;
512 512
         if ( $cond == '==' ) {
513
-            if ( is_array($hide_opt) ) {
514
-                $m = array_intersect($hide_opt, $observed_value);
515
-                $m = empty($m) ? false : true;
513
+            if ( is_array( $hide_opt ) ) {
514
+                $m = array_intersect( $hide_opt, $observed_value );
515
+                $m = empty( $m ) ? false : true;
516 516
             } else {
517
-                $m = in_array($hide_opt, $observed_value);
517
+                $m = in_array( $hide_opt, $observed_value );
518 518
             }
519 519
         } else if ( $cond == '!=' ) {
520
-            $m = ! in_array($hide_opt, $observed_value);
520
+            $m = ! in_array( $hide_opt, $observed_value );
521 521
         } else if ( $cond == '>' ) {
522
-            $min = min($observed_value);
522
+            $min = min( $observed_value );
523 523
             $m = $min > $hide_opt;
524 524
         } else if ( $cond == '<' ) {
525
-            $max = max($observed_value);
525
+            $max = max( $observed_value );
526 526
             $m = $max < $hide_opt;
527 527
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
528 528
             foreach ( $observed_value as $ob ) {
529
-                $m = strpos($ob, $hide_opt);
529
+                $m = strpos( $ob, $hide_opt );
530 530
                 if ( $m !== false ) {
531 531
                     $m = true;
532 532
                     break;
@@ -547,20 +547,20 @@  discard block
 block discarded – undo
547 547
      * @return string
548 548
      */
549 549
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
550
-        if ( strpos($value, '[sitename]') !== false ) {
550
+        if ( strpos( $value, '[sitename]' ) !== false ) {
551 551
             $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
552
-            $value = str_replace('[sitename]', $new_value, $value);
552
+            $value = str_replace( '[sitename]', $new_value, $value );
553 553
         }
554 554
 
555
-        $value = apply_filters('frm_content', $value, $form, $entry);
556
-        $value = do_shortcode($value);
555
+        $value = apply_filters( 'frm_content', $value, $form, $entry );
556
+        $value = do_shortcode( $value );
557 557
 
558 558
         return $value;
559 559
     }
560 560
 
561 561
 	public static function get_shortcodes( $content, $form_id ) {
562 562
         if ( FrmAppHelper::pro_is_installed() ) {
563
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
563
+            return FrmProDisplaysHelper::get_shortcodes( $content, $form_id );
564 564
         }
565 565
 
566 566
 		$fields = FrmField::getAll( array(
@@ -568,9 +568,9 @@  discard block
 block discarded – undo
568 568
 			'fi.type not' => FrmField::no_save_fields(),
569 569
 		) );
570 570
 
571
-        $tagregexp = self::allowed_shortcodes($fields);
571
+        $tagregexp = self::allowed_shortcodes( $fields );
572 572
 
573
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
573
+        preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER );
574 574
 
575 575
         return $matches;
576 576
     }
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
             $tagregexp[] = $field->field_key;
584 584
         }
585 585
 
586
-        $tagregexp = implode('|', $tagregexp);
586
+        $tagregexp = implode( '|', $tagregexp );
587 587
         return $tagregexp;
588 588
     }
589 589
 
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 				continue;
594 594
 			}
595 595
 
596
-			$atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] );
596
+			$atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][$short_key] );
597 597
 			$tag  = FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key );
598 598
 
599 599
 			$atts['entry'] = $entry;
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 			$replace_with = self::get_value_for_shortcode( $atts );
602 602
 
603 603
 			if ( $replace_with !== null ) {
604
-				$content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
604
+				$content = str_replace( $shortcodes[0][$short_key], $replace_with, $content );
605 605
 			}
606 606
 
607 607
 			unset( $atts, $replace_with );
@@ -628,8 +628,8 @@  discard block
 block discarded – undo
628 628
 
629 629
 		$dynamic_default = array( 'admin_email', 'siteurl', 'frmurl', 'sitename', 'get' );
630 630
 
631
-		if ( isset( $shortcode_values[ $atts['tag'] ] ) ) {
632
-			$replace_with = $shortcode_values[ $atts['tag'] ];
631
+		if ( isset( $shortcode_values[$atts['tag']] ) ) {
632
+			$replace_with = $shortcode_values[$atts['tag']];
633 633
 		} elseif ( in_array( $atts['tag'], $dynamic_default ) ) {
634 634
 			$replace_with = self::dynamic_default_values( $atts['tag'], $atts );
635 635
 		} elseif ( $clean_tag == 'user_agent' ) {
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 		if ( isset( $atts['format'] ) ) {
659 659
 			$time_format = ' ';
660 660
 		} else {
661
-			$atts['format'] = get_option('date_format');
661
+			$atts['format'] = get_option( 'date_format' );
662 662
 			$time_format = '';
663 663
 		}
664 664
 
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
         $new_value = '';
713 713
         switch ( $tag ) {
714 714
             case 'admin_email':
715
-                $new_value = get_option('admin_email');
715
+                $new_value = get_option( 'admin_email' );
716 716
                 break;
717 717
             case 'siteurl':
718 718
                 $new_value = FrmAppHelper::site_url();
@@ -737,28 +737,28 @@  discard block
 block discarded – undo
737 737
      * @return string|array
738 738
      */
739 739
     public static function process_get_shortcode( $atts, $return_array = false ) {
740
-        if ( ! isset($atts['param']) ) {
740
+        if ( ! isset( $atts['param'] ) ) {
741 741
             return '';
742 742
         }
743 743
 
744
-        if ( strpos($atts['param'], '&#91;') ) {
745
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
746
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
744
+        if ( strpos( $atts['param'], '&#91;' ) ) {
745
+            $atts['param'] = str_replace( '&#91;', '[', $atts['param'] );
746
+            $atts['param'] = str_replace( '&#93;', ']', $atts['param'] );
747 747
         }
748 748
 
749 749
 		$new_value = FrmAppHelper::get_param( $atts['param'], '', 'get', 'sanitize_text_field' );
750 750
         $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
751 751
 
752 752
         if ( $new_value == '' ) {
753
-            if ( ! isset($atts['prev_val']) ) {
753
+            if ( ! isset( $atts['prev_val'] ) ) {
754 754
                 $atts['prev_val'] = '';
755 755
             }
756 756
 
757
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
757
+            $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val'];
758 758
         }
759 759
 
760
-        if ( is_array($new_value) && ! $return_array ) {
761
-            $new_value = implode(', ', $new_value);
760
+        if ( is_array( $new_value ) && ! $return_array ) {
761
+            $new_value = implode( ', ', $new_value );
762 762
         }
763 763
 
764 764
         return $new_value;
@@ -799,9 +799,9 @@  discard block
 block discarded – undo
799 799
 			'size'  => 96,
800 800
 		);
801 801
 
802
-		$args = wp_parse_args($args, $defaults);
802
+		$args = wp_parse_args( $args, $defaults );
803 803
 
804
-		$user = get_userdata($user_id);
804
+		$user = get_userdata( $user_id );
805 805
 		$info = '';
806 806
 
807 807
 		if ( $user ) {
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 			} elseif ( $user_info == 'author_link' ) {
811 811
 				$info = get_author_posts_url( $user_id );
812 812
 			} else {
813
-				$info = isset($user->$user_info) ? $user->$user_info : '';
813
+				$info = isset( $user->$user_info ) ? $user->$user_info : '';
814 814
 			}
815 815
 
816 816
 			if ( 'display_name' === $user_info && empty( $info ) && ! $args['blank'] ) {
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
 		}
820 820
 
821 821
 		if ( $args['link'] ) {
822
-			$info = '<a href="' . esc_url( admin_url('user-edit.php?user_id=' . $user_id ) ) . '">' . $info . '</a>';
822
+			$info = '<a href="' . esc_url( admin_url( 'user-edit.php?user_id=' . $user_id ) ) . '">' . $info . '</a>';
823 823
 		}
824 824
 
825 825
 		return $info;
@@ -833,14 +833,14 @@  discard block
 block discarded – undo
833 833
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
834 834
 
835 835
         $field_types = array();
836
-        if ( in_array($type, $single_input) ) {
836
+        if ( in_array( $type, $single_input ) ) {
837 837
             self::field_types_for_input( $single_input, $field_selection, $field_types );
838
-        } else if ( in_array($type, $multiple_input) ) {
838
+        } else if ( in_array( $type, $multiple_input ) ) {
839 839
             self::field_types_for_input( $multiple_input, $field_selection, $field_types );
840
-        } else if ( in_array($type, $other_type) ) {
840
+        } else if ( in_array( $type, $other_type ) ) {
841 841
             self::field_types_for_input( $other_type, $field_selection, $field_types );
842
-		} else if ( isset( $field_selection[ $type ] ) ) {
843
-            $field_types[ $type ] = $field_selection[ $type ];
842
+		} else if ( isset( $field_selection[$type] ) ) {
843
+            $field_types[$type] = $field_selection[$type];
844 844
         }
845 845
 
846 846
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
 
850 850
     private static function field_types_for_input( $inputs, $fields, &$field_types ) {
851 851
         foreach ( $inputs as $input ) {
852
-            $field_types[ $input ] = $fields[ $input ];
853
-            unset($input);
852
+            $field_types[$input] = $fields[$input];
853
+            unset( $input );
854 854
         }
855 855
     }
856 856
 
@@ -897,21 +897,21 @@  discard block
 block discarded – undo
897 897
 		// Check posted vals before checking saved values
898 898
 
899 899
 		// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
900
-		if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) {
900
+		if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) {
901 901
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
902
-				$other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) : '';
902
+				$other_val = isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) : '';
903 903
 			} else {
904
-				$other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] );
904
+				$other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] );
905 905
 			}
906 906
 			return $other_val;
907 907
 
908
-		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) {
908
+		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) {
909 909
 			// For normal fields
910 910
 
911 911
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
912
-				$other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : '';
912
+				$other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : '';
913 913
 			} else {
914
-				$other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] );
914
+				$other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] );
915 915
 			}
916 916
 			return $other_val;
917 917
 		}
@@ -920,8 +920,8 @@  discard block
 block discarded – undo
920 920
 		if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) {
921 921
 			// Check if there is an "other" val in saved value and make sure the
922 922
 			// "other" val is not equal to the Other checkbox option
923
-			if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
924
-				$other_val = $field['value'][ $opt_key ];
923
+			if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) {
924
+				$other_val = $field['value'][$opt_key];
925 925
 			}
926 926
 		} else {
927 927
 			/**
@@ -933,8 +933,8 @@  discard block
 block discarded – undo
933 933
 				// Multi-select dropdowns - key is not preserved
934 934
 				if ( is_array( $field['value'] ) ) {
935 935
 					$o_key = array_search( $temp_val, $field['value'] );
936
-					if ( isset( $field['value'][ $o_key ] ) ) {
937
-						unset( $field['value'][ $o_key ], $o_key );
936
+					if ( isset( $field['value'][$o_key] ) ) {
937
+						unset( $field['value'][$o_key], $o_key );
938 938
 					}
939 939
 				} else if ( $temp_val == $field['value'] ) {
940 940
 					// For radio and regular dropdowns
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
 	private static function set_other_name( $args, &$other_args ) {
992 992
 		//Set up name for other field
993 993
 		$other_args['name'] = str_replace( '[]', '', $args['field_name'] );
994
-		$other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']);
994
+		$other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] );
995 995
 		$other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']';
996 996
 
997 997
 		//Converts item_meta[field_id] => item_meta[other][field_id] and
@@ -1018,7 +1018,7 @@  discard block
 block discarded – undo
1018 1018
 		// Count should only be greater than 3 if inside of a repeating section
1019 1019
 		if ( count( $temp_array ) > 3 ) {
1020 1020
 			$parent = str_replace( ']', '', $temp_array[1] );
1021
-			$pointer = str_replace( ']', '', $temp_array[2]);
1021
+			$pointer = str_replace( ']', '', $temp_array[2] );
1022 1022
 		}
1023 1023
 
1024 1024
 		// Get text for "other" text field
@@ -1152,15 +1152,15 @@  discard block
 block discarded – undo
1152 1152
 			$replace_with[] = '[' . $new . ']';
1153 1153
 			$replace[] = '[' . $old . ' ';
1154 1154
 			$replace_with[] = '[' . $new . ' ';
1155
-            unset($old, $new);
1155
+            unset( $old, $new );
1156 1156
         }
1157 1157
 		if ( is_array( $val ) ) {
1158 1158
 			foreach ( $val as $k => $v ) {
1159
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1160
-                unset($k, $v);
1159
+                $val[$k] = str_replace( $replace, $replace_with, $v );
1160
+                unset( $k, $v );
1161 1161
             }
1162 1162
         } else {
1163
-            $val = str_replace($replace, $replace_with, $val);
1163
+            $val = str_replace( $replace, $replace_with, $val );
1164 1164
         }
1165 1165
 
1166 1166
         return $val;
@@ -1227,19 +1227,19 @@  discard block
 block discarded – undo
1227 1227
 	}
1228 1228
 
1229 1229
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1230
-		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1230
+		$prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries();
1231 1231
 
1232 1232
         $states = FrmFieldsHelper::get_us_states();
1233
-        $state_abv = array_keys($states);
1234
-        sort($state_abv);
1235
-		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1233
+        $state_abv = array_keys( $states );
1234
+        sort( $state_abv );
1235
+		$prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv;
1236 1236
 
1237
-        $states = array_values($states);
1238
-        sort($states);
1239
-		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1240
-        unset($state_abv, $states);
1237
+        $states = array_values( $states );
1238
+        sort( $states );
1239
+		$prepop[__( 'U.S. States', 'formidable' )] = $states;
1240
+        unset( $state_abv, $states );
1241 1241
 
1242
-		$prepop[ __( 'Age', 'formidable' ) ] = array(
1242
+		$prepop[__( 'Age', 'formidable' )] = array(
1243 1243
 			__( 'Under 18', 'formidable' ),
1244 1244
 			__( '18-24', 'formidable' ),
1245 1245
 			__( '25-34', 'formidable' ),
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
 			__( 'Prefer Not to Answer', 'formidable' ),
1251 1251
 		);
1252 1252
 
1253
-		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1253
+		$prepop[__( 'Satisfaction', 'formidable' )] = array(
1254 1254
 			__( 'Very Satisfied', 'formidable' ),
1255 1255
 			__( 'Satisfied', 'formidable' ),
1256 1256
 			__( 'Neutral', 'formidable' ),
@@ -1259,7 +1259,7 @@  discard block
 block discarded – undo
1259 1259
 			__( 'N/A', 'formidable' ),
1260 1260
 		);
1261 1261
 
1262
-		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1262
+		$prepop[__( 'Importance', 'formidable' )] = array(
1263 1263
 			__( 'Very Important', 'formidable' ),
1264 1264
 			__( 'Important', 'formidable' ),
1265 1265
 			__( 'Neutral', 'formidable' ),
@@ -1268,7 +1268,7 @@  discard block
 block discarded – undo
1268 1268
 			__( 'N/A', 'formidable' ),
1269 1269
 		);
1270 1270
 
1271
-		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1271
+		$prepop[__( 'Agreement', 'formidable' )] = array(
1272 1272
 			__( 'Strongly Agree', 'formidable' ),
1273 1273
 			__( 'Agree', 'formidable' ),
1274 1274
 			__( 'Neutral', 'formidable' ),
Please login to merge, or discard this patch.
Doc Comments   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	 *
206 206
 	 * @param object $field
207 207
 	 *
208
-	 * @return array
208
+	 * @return stdClass
209 209
 	 */
210 210
 	private static function get_original_field( $field ) {
211 211
 		$original_type = FrmField::get_option( $field, 'original_type' );
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	 *
233 233
 	 * @param string $type
234 234
 	 *
235
-	 * @return array
235
+	 * @return string
236 236
 	 */
237 237
 	public static function get_default_field( $type ) {
238 238
 		$field_type = FrmFieldFactory::get_field_type( $type );
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 	 * @since 2.0
257 257
 	 *
258 258
 	 * @param $field
259
-	 * @param $error
259
+	 * @param string $error
260 260
 	 *
261 261
 	 * @return string
262 262
 	 */
@@ -847,6 +847,9 @@  discard block
 block discarded – undo
847 847
         return $field_types;
848 848
     }
849 849
 
850
+    /**
851
+     * @param string[] $inputs
852
+     */
850 853
     private static function field_types_for_input( $inputs, $fields, &$field_types ) {
851 854
         foreach ( $inputs as $input ) {
852 855
             $field_types[ $input ] = $fields[ $input ];
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesHelper.php 2 patches
Indentation   +218 added lines, -218 removed lines patch added patch discarded remove patch
@@ -5,19 +5,19 @@  discard block
 block discarded – undo
5 5
 
6 6
 class FrmEntriesHelper {
7 7
 
8
-    public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
8
+	public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9 9
 		$values = array(
10 10
 			'name'        => '',
11 11
 			'description' => '',
12 12
 			'item_key'    => '',
13 13
 		);
14 14
 
15
-        $values['fields'] = array();
16
-        if ( empty($fields) ) {
17
-            return apply_filters('frm_setup_new_entry', $values);
18
-        }
15
+		$values['fields'] = array();
16
+		if ( empty($fields) ) {
17
+			return apply_filters('frm_setup_new_entry', $values);
18
+		}
19 19
 
20
-        foreach ( (array) $fields as $field ) {
20
+		foreach ( (array) $fields as $field ) {
21 21
 			$original_default = $field->default_value;
22 22
 			self::prepare_field_default_value( $field );
23 23
 			$new_value = self::get_field_value_for_new_entry( $field, $reset, $args );
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
 
33 33
 			FrmFieldsHelper::prepare_new_front_field( $field_array, $field, $args );
34 34
 
35
-            $field_array = array_merge( $field->field_options, $field_array );
35
+			$field_array = array_merge( $field->field_options, $field_array );
36 36
 
37
-            $values['fields'][] = $field_array;
37
+			$values['fields'][] = $field_array;
38 38
 
39
-            if ( ! $form || ! isset($form->id) ) {
40
-                $form = FrmForm::getOne($field->form_id);
41
-            }
42
-        }
39
+			if ( ! $form || ! isset($form->id) ) {
40
+				$form = FrmForm::getOne($field->form_id);
41
+			}
42
+		}
43 43
 
44 44
 		$form->options = maybe_unserialize( $form->options );
45 45
 		if ( is_array( $form->options ) ) {
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		$values = array_merge( $form_defaults, $values );
55 55
 
56 56
 		return apply_filters( 'frm_setup_new_entry', $values );
57
-    }
57
+	}
58 58
 
59 59
 	/**
60 60
 	 * @since 2.05
@@ -71,16 +71,16 @@  discard block
 block discarded – undo
71 71
 	}
72 72
 
73 73
 	/**
74
-	* Set the value for each field
75
-	* This function is used when the form is first loaded and on all page turns *for a new entry*
76
-	*
77
-	* @since 2.0.13
78
-	*
79
-	* @param object $field - this is passed by reference since it is an object
80
-	* @param boolean $reset
81
-	* @param array $args
82
-	* @return string|array $new_value
83
-	*/
74
+	 * Set the value for each field
75
+	 * This function is used when the form is first loaded and on all page turns *for a new entry*
76
+	 *
77
+	 * @since 2.0.13
78
+	 *
79
+	 * @param object $field - this is passed by reference since it is an object
80
+	 * @param boolean $reset
81
+	 * @param array $args
82
+	 * @return string|array $new_value
83
+	 */
84 84
 	private static function get_field_value_for_new_entry( $field, $reset, $args ) {
85 85
 		$new_value = $field->default_value;
86 86
 
@@ -105,13 +105,13 @@  discard block
 block discarded – undo
105 105
 	}
106 106
 
107 107
 	/**
108
-	* Check if a field has a posted value
109
-	*
110
-	* @since 2.01.0
111
-	* @param object $field
112
-	* @param array $args
113
-	* @return boolean $value_is_posted
114
-	*/
108
+	 * Check if a field has a posted value
109
+	 *
110
+	 * @since 2.01.0
111
+	 * @param object $field
112
+	 * @param array $args
113
+	 * @return boolean $value_is_posted
114
+	 */
115 115
 	public static function value_is_posted( $field, $args ) {
116 116
 		$value_is_posted = false;
117 117
 		if ( $_POST ) {
@@ -129,93 +129,93 @@  discard block
 block discarded – undo
129 129
 
130 130
 	public static function setup_edit_vars( $values, $record ) {
131 131
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
132
-        $values['form_id'] = $record->form_id;
133
-        $values['is_draft'] = $record->is_draft;
134
-        return apply_filters('frm_setup_edit_entry_vars', $values, $record);
135
-    }
132
+		$values['form_id'] = $record->form_id;
133
+		$values['is_draft'] = $record->is_draft;
134
+		return apply_filters('frm_setup_edit_entry_vars', $values, $record);
135
+	}
136 136
 
137 137
 	public static function replace_default_message( $message, $atts ) {
138
-        if ( strpos($message, '[default-message') === false &&
139
-            strpos($message, '[default_message') === false &&
140
-            ! empty( $message ) ) {
141
-            return $message;
142
-        }
138
+		if ( strpos($message, '[default-message') === false &&
139
+			strpos($message, '[default_message') === false &&
140
+			! empty( $message ) ) {
141
+			return $message;
142
+		}
143 143
 
144
-        if ( empty($message) ) {
145
-            $message = '[default-message]';
146
-        }
144
+		if ( empty($message) ) {
145
+			$message = '[default-message]';
146
+		}
147 147
 
148
-        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
148
+		preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
149 149
 
150
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
150
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
151 151
 			$add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
152 152
 			if ( ! empty( $add_atts ) ) {
153
-                $this_atts = array_merge($atts, $add_atts);
154
-            } else {
155
-                $this_atts = $atts;
156
-            }
153
+				$this_atts = array_merge($atts, $add_atts);
154
+			} else {
155
+				$this_atts = $atts;
156
+			}
157 157
 
158 158
 			$default = FrmEntriesController::show_entry_shortcode( $this_atts );
159 159
 
160
-            // Add the default message
161
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
162
-        }
160
+			// Add the default message
161
+			$message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
162
+		}
163 163
 
164
-        return $message;
165
-    }
164
+		return $message;
165
+	}
166 166
 
167 167
 	public static function prepare_display_value( $entry, $field, $atts ) {
168 168
 		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
169 169
 
170
-        if ( FrmAppHelper::pro_is_installed() ) {
170
+		if ( FrmAppHelper::pro_is_installed() ) {
171 171
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
172
-        }
172
+		}
173 173
 
174
-        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
175
-            return self::display_value($field_value, $field, $atts);
176
-        }
174
+		if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
175
+			return self::display_value($field_value, $field, $atts);
176
+		}
177 177
 
178
-        // this is an embeded form
179
-        $val = '';
178
+		// this is an embeded form
179
+		$val = '';
180 180
 
181
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
182
-            //this is a repeating section
181
+		if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
182
+			//this is a repeating section
183 183
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
184
-        } else {
185
-            // get all values for this field
186
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
184
+		} else {
185
+			// get all values for this field
186
+			$child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
187 187
 
188
-            if ( $child_values ) {
189
-	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
190
-	        }
191
-	    }
188
+			if ( $child_values ) {
189
+				$child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
190
+			}
191
+		}
192 192
 
193
-	    $field_value = array();
193
+		$field_value = array();
194 194
 
195
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
196
-            return $val;
197
-        }
195
+		if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
196
+			return $val;
197
+		}
198 198
 
199
-        foreach ( $child_entries as $child_entry ) {
200
-            $atts['item_id'] = $child_entry->id;
201
-            $atts['post_id'] = $child_entry->post_id;
199
+		foreach ( $child_entries as $child_entry ) {
200
+			$atts['item_id'] = $child_entry->id;
201
+			$atts['post_id'] = $child_entry->post_id;
202 202
 
203
-            // get the value for this field -- check for post values as well
204
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
203
+			// get the value for this field -- check for post values as well
204
+			$entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
205 205
 
206
-            if ( $entry_val ) {
207
-                // foreach entry get display_value
208
-                $field_value[] = self::display_value($entry_val, $field, $atts);
209
-            }
206
+			if ( $entry_val ) {
207
+				// foreach entry get display_value
208
+				$field_value[] = self::display_value($entry_val, $field, $atts);
209
+			}
210 210
 
211
-            unset($child_entry);
212
-        }
211
+			unset($child_entry);
212
+		}
213 213
 
214
-        $val = implode(', ', (array) $field_value );
214
+		$val = implode(', ', (array) $field_value );
215 215
 		return FrmAppHelper::kses( $val, 'all' );
216
-    }
216
+	}
217 217
 
218
-    /**
218
+	/**
219 219
 	 * Prepare the saved value for display
220 220
 	 *
221 221
 	 * @param array|string $value
@@ -239,35 +239,35 @@  discard block
 block discarded – undo
239 239
 			'return_array' => false,
240 240
 		);
241 241
 
242
-        $atts = wp_parse_args( $atts, $defaults );
242
+		$atts = wp_parse_args( $atts, $defaults );
243 243
 
244 244
 		if ( FrmField::is_image( $field ) || $field->type == 'star' ) {
245 245
 			$atts['truncate'] = false;
246 246
 			$atts['html'] = true;
247 247
 		}
248 248
 
249
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
249
+		$atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
250 250
 
251
-        if ( ! isset($field->field_options['post_field']) ) {
252
-            $field->field_options['post_field'] = '';
253
-        }
251
+		if ( ! isset($field->field_options['post_field']) ) {
252
+			$field->field_options['post_field'] = '';
253
+		}
254 254
 
255
-        if ( ! isset($field->field_options['custom_field']) ) {
256
-            $field->field_options['custom_field'] = '';
257
-        }
255
+		if ( ! isset($field->field_options['custom_field']) ) {
256
+			$field->field_options['custom_field'] = '';
257
+		}
258 258
 
259
-        if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
260
-            $atts['pre_truncate'] = $atts['truncate'];
261
-            $atts['truncate'] = true;
262
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
259
+		if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
260
+			$atts['pre_truncate'] = $atts['truncate'];
261
+			$atts['truncate'] = true;
262
+			$atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
263 263
 
264
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
265
-            $atts['truncate'] = $atts['pre_truncate'];
266
-        }
264
+			$value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
265
+			$atts['truncate'] = $atts['pre_truncate'];
266
+		}
267 267
 
268
-        if ( $value == '' ) {
269
-            return $value;
270
-        }
268
+		if ( $value == '' ) {
269
+			return $value;
270
+		}
271 271
 
272 272
 		$unfiltered_value = maybe_unserialize( $value );
273 273
 		$value = apply_filters('frm_display_value_custom', $unfiltered_value, $field, $atts);
@@ -277,130 +277,130 @@  discard block
 block discarded – undo
277 277
 			$value = FrmFieldsHelper::get_unfiltered_display_value( compact( 'value', 'field', 'atts' ) );
278 278
 		}
279 279
 
280
-        if ( $atts['truncate'] && $atts['type'] != 'url' ) {
281
-            $value = FrmAppHelper::truncate($value, 50);
282
-        }
280
+		if ( $atts['truncate'] && $atts['type'] != 'url' ) {
281
+			$value = FrmAppHelper::truncate($value, 50);
282
+		}
283 283
 
284 284
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
285 285
 			$value = FrmAppHelper::kses( $value, 'all' );
286 286
 		}
287 287
 
288 288
 		return apply_filters( 'frm_display_value', $value, $field, $atts );
289
-    }
289
+	}
290 290
 
291 291
 	public static function set_posted_value( $field, $value, $args ) {
292
-        // If validating a field with "other" opt, set back to prev value now
293
-        if ( isset( $args['other'] ) && $args['other'] ) {
294
-            $value = $args['temp_value'];
295
-        }
296
-        if ( empty($args['parent_field_id']) ) {
297
-            $_POST['item_meta'][ $field->id ] = $value;
298
-        } else {
299
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
300
-        }
301
-    }
292
+		// If validating a field with "other" opt, set back to prev value now
293
+		if ( isset( $args['other'] ) && $args['other'] ) {
294
+			$value = $args['temp_value'];
295
+		}
296
+		if ( empty($args['parent_field_id']) ) {
297
+			$_POST['item_meta'][ $field->id ] = $value;
298
+		} else {
299
+			$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
300
+		}
301
+	}
302 302
 
303 303
 	public static function get_posted_value( $field, &$value, $args ) {
304 304
 		$field_id = is_object( $field ) ? $field->id : $field;
305 305
 
306
-        if ( empty($args['parent_field_id']) ) {
307
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
308
-        } else {
309
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
310
-        }
306
+		if ( empty($args['parent_field_id']) ) {
307
+			$value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
308
+		} else {
309
+			$value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
310
+		}
311 311
 		FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
312 312
 		$value = stripslashes_deep( $value );
313
-    }
314
-
315
-    /**
316
-    * Check if field has an "Other" option and if any other values are posted
317
-    *
318
-    * @since 2.0
319
-    *
320
-    * @param object $field
321
-    * @param string|array $value
322
-    * @param array $args
323
-    */
324
-    public static function maybe_set_other_validation( $field, &$value, &$args ) {
325
-        $args['other'] = false;
326
-        if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
327
-            return;
328
-        }
329
-
330
-        // Get other value for fields in repeating section
331
-        self::set_other_repeating_vals( $field, $value, $args );
332
-
333
-        // Check if there are any posted "Other" values
313
+	}
314
+
315
+	/**
316
+	 * Check if field has an "Other" option and if any other values are posted
317
+	 *
318
+	 * @since 2.0
319
+	 *
320
+	 * @param object $field
321
+	 * @param string|array $value
322
+	 * @param array $args
323
+	 */
324
+	public static function maybe_set_other_validation( $field, &$value, &$args ) {
325
+		$args['other'] = false;
326
+		if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
327
+			return;
328
+		}
329
+
330
+		// Get other value for fields in repeating section
331
+		self::set_other_repeating_vals( $field, $value, $args );
332
+
333
+		// Check if there are any posted "Other" values
334 334
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
335 335
 
336
-            // Save original value
337
-            $args['temp_value'] = $value;
338
-            $args['other'] = true;
339
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
340
-
341
-            // Set the validation value now
342
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
343
-        }
344
-    }
345
-
346
-    /**
347
-    * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
348
-    *
349
-    * @since 2.0
350
-    *
351
-    * @param object $field
352
-    * @param string|array $value
353
-    * @param array $args
354
-    */
355
-    public static function set_other_repeating_vals( $field, &$value, &$args ) {
356
-        if ( ! $args['parent_field_id'] ) {
357
-            return;
358
-        }
359
-
360
-        // Check if there are any other posted "other" values for this field
336
+			// Save original value
337
+			$args['temp_value'] = $value;
338
+			$args['other'] = true;
339
+			$other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
340
+
341
+			// Set the validation value now
342
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
343
+		}
344
+	}
345
+
346
+	/**
347
+	 * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
348
+	 *
349
+	 * @since 2.0
350
+	 *
351
+	 * @param object $field
352
+	 * @param string|array $value
353
+	 * @param array $args
354
+	 */
355
+	public static function set_other_repeating_vals( $field, &$value, &$args ) {
356
+		if ( ! $args['parent_field_id'] ) {
357
+			return;
358
+		}
359
+
360
+		// Check if there are any other posted "other" values for this field
361 361
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
362
-            // Save original value
363
-            $args['temp_value'] = $value;
364
-            $args['other'] = true;
365
-
366
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
367
-
368
-            // Set the validation value now
369
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
370
-        }
371
-    }
372
-
373
-    /**
374
-    * Modify value used for validation
375
-    * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
376
-    * It also adds any text from the free text fields to the value
377
-    *
378
-    * Needs to accommodate for times when other opt is selected, but no other free text is entered
379
-    *
380
-    * @since 2.0
381
-    *
382
-    * @param string|array $value
383
-    * @param string|array $other_vals (usually of posted values)
384
-    * @param object $field
385
-    * @param array $args
386
-    */
387
-    public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
388
-        // Checkboxes and multi-select dropdowns
389
-        if ( is_array( $value ) && $field->type == 'checkbox' ) {
390
-            // Combine "Other" values with checked values. "Other" values will override checked box values.
391
-            $value = array_merge( $value, $other_vals );
392
-            $value = array_filter( $value );
393
-            if ( count( $value ) == 0 ) {
394
-                $value = '';
395
-            }
396
-        } else {
362
+			// Save original value
363
+			$args['temp_value'] = $value;
364
+			$args['other'] = true;
365
+
366
+			$other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
367
+
368
+			// Set the validation value now
369
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
370
+		}
371
+	}
372
+
373
+	/**
374
+	 * Modify value used for validation
375
+	 * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
376
+	 * It also adds any text from the free text fields to the value
377
+	 *
378
+	 * Needs to accommodate for times when other opt is selected, but no other free text is entered
379
+	 *
380
+	 * @since 2.0
381
+	 *
382
+	 * @param string|array $value
383
+	 * @param string|array $other_vals (usually of posted values)
384
+	 * @param object $field
385
+	 * @param array $args
386
+	 */
387
+	public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
388
+		// Checkboxes and multi-select dropdowns
389
+		if ( is_array( $value ) && $field->type == 'checkbox' ) {
390
+			// Combine "Other" values with checked values. "Other" values will override checked box values.
391
+			$value = array_merge( $value, $other_vals );
392
+			$value = array_filter( $value );
393
+			if ( count( $value ) == 0 ) {
394
+				$value = '';
395
+			}
396
+		} else {
397 397
 			// Radio and dropdowns
398
-            $other_key = array_filter( array_keys($field->options), 'is_string');
399
-            $other_key = reset( $other_key );
398
+			$other_key = array_filter( array_keys($field->options), 'is_string');
399
+			$other_key = reset( $other_key );
400 400
 
401
-            // Multi-select dropdown
402
-            if ( is_array( $value ) ) {
403
-                $o_key = array_search( $field->options[ $other_key ], $value );
401
+			// Multi-select dropdown
402
+			if ( is_array( $value ) ) {
403
+				$o_key = array_search( $field->options[ $other_key ], $value );
404 404
 
405 405
 				if ( $o_key !== false ) {
406 406
 					// Modify the original value so other key will be preserved
@@ -415,15 +415,15 @@  discard block
 block discarded – undo
415 415
 					$args['temp_value'] = $value;
416 416
 					$value[ $other_key ] = reset( $other_vals );
417 417
 				}
418
-            } else if ( $field->options[ $other_key ] == $value ) {
419
-                $value = $other_vals;
420
-            }
421
-        }
422
-    }
418
+			} else if ( $field->options[ $other_key ] == $value ) {
419
+				$value = $other_vals;
420
+			}
421
+		}
422
+	}
423 423
 
424
-    // Add submitted values to a string for spam checking
424
+	// Add submitted values to a string for spam checking
425 425
 	public static function entry_array_to_string( $values ) {
426
-        $content = '';
426
+		$content = '';
427 427
 		foreach ( $values['item_meta'] as $val ) {
428 428
 			if ( $content != '' ) {
429 429
 				$content .= "\n\n";
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 		}
439 439
 
440 440
 		return $content;
441
-    }
441
+	}
442 442
 
443 443
 	/**
444 444
 	 * Get the browser from the user agent
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -13,8 +13,8 @@  discard block
 block discarded – undo
13 13
 		);
14 14
 
15 15
         $values['fields'] = array();
16
-        if ( empty($fields) ) {
17
-            return apply_filters('frm_setup_new_entry', $values);
16
+        if ( empty( $fields ) ) {
17
+            return apply_filters( 'frm_setup_new_entry', $values );
18 18
         }
19 19
 
20 20
         foreach ( (array) $fields as $field ) {
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
 
37 37
             $values['fields'][] = $field_array;
38 38
 
39
-            if ( ! $form || ! isset($form->id) ) {
40
-                $form = FrmForm::getOne($field->form_id);
39
+            if ( ! $form || ! isset( $form->id ) ) {
40
+                $form = FrmForm::getOne( $field->form_id );
41 41
             }
42 42
         }
43 43
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 		$form_defaults = FrmFormsHelper::get_default_opts();
50 50
 
51 51
 		$frm_settings = FrmAppHelper::get_settings();
52
-		$form_defaults['custom_style']  = ( $frm_settings->load_style != 'none' );
52
+		$form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' );
53 53
 
54 54
 		$values = array_merge( $form_defaults, $values );
55 55
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 		}
99 99
 
100 100
 		if ( ! is_array( $new_value ) ) {
101
-			$new_value = str_replace('"', '&quot;', $new_value);
101
+			$new_value = str_replace( '"', '&quot;', $new_value );
102 102
 		}
103 103
 
104 104
 		return $new_value;
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
 		if ( $_POST ) {
118 118
 			$repeating = isset( $args['repeating'] ) && $args['repeating'];
119 119
 			if ( $repeating ) {
120
-				if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) {
120
+				if ( isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] ) ) {
121 121
 					$value_is_posted = true;
122 122
 				}
123
-			} else if ( isset( $_POST['item_meta'][ $field->id ] ) ) {
123
+			} else if ( isset( $_POST['item_meta'][$field->id] ) ) {
124 124
 				$value_is_posted = true;
125 125
 			}
126 126
 		}
@@ -131,26 +131,26 @@  discard block
 block discarded – undo
131 131
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
132 132
         $values['form_id'] = $record->form_id;
133 133
         $values['is_draft'] = $record->is_draft;
134
-        return apply_filters('frm_setup_edit_entry_vars', $values, $record);
134
+        return apply_filters( 'frm_setup_edit_entry_vars', $values, $record );
135 135
     }
136 136
 
137 137
 	public static function replace_default_message( $message, $atts ) {
138
-        if ( strpos($message, '[default-message') === false &&
139
-            strpos($message, '[default_message') === false &&
138
+        if ( strpos( $message, '[default-message' ) === false &&
139
+            strpos( $message, '[default_message' ) === false &&
140 140
             ! empty( $message ) ) {
141 141
             return $message;
142 142
         }
143 143
 
144
-        if ( empty($message) ) {
144
+        if ( empty( $message ) ) {
145 145
             $message = '[default-message]';
146 146
         }
147 147
 
148
-        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
148
+        preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
149 149
 
150 150
         foreach ( $shortcodes[0] as $short_key => $tag ) {
151
-			$add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
151
+			$add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] );
152 152
 			if ( ! empty( $add_atts ) ) {
153
-                $this_atts = array_merge($atts, $add_atts);
153
+                $this_atts = array_merge( $atts, $add_atts );
154 154
             } else {
155 155
                 $this_atts = $atts;
156 156
             }
@@ -158,32 +158,32 @@  discard block
 block discarded – undo
158 158
 			$default = FrmEntriesController::show_entry_shortcode( $this_atts );
159 159
 
160 160
             // Add the default message
161
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
161
+            $message = str_replace( $shortcodes[0][$short_key], $default, $message );
162 162
         }
163 163
 
164 164
         return $message;
165 165
     }
166 166
 
167 167
 	public static function prepare_display_value( $entry, $field, $atts ) {
168
-		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
168
+		$field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false;
169 169
 
170 170
         if ( FrmAppHelper::pro_is_installed() ) {
171 171
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
172 172
         }
173 173
 
174
-        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
175
-            return self::display_value($field_value, $field, $atts);
174
+        if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) {
175
+            return self::display_value( $field_value, $field, $atts );
176 176
         }
177 177
 
178 178
         // this is an embeded form
179 179
         $val = '';
180 180
 
181
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
181
+	    if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) {
182 182
             //this is a repeating section
183 183
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
184 184
         } else {
185 185
             // get all values for this field
186
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
186
+	        $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false;
187 187
 
188 188
             if ( $child_values ) {
189 189
 	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
 	    $field_value = array();
194 194
 
195
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
195
+        if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
196 196
             return $val;
197 197
         }
198 198
 
@@ -201,17 +201,17 @@  discard block
 block discarded – undo
201 201
             $atts['post_id'] = $child_entry->post_id;
202 202
 
203 203
             // get the value for this field -- check for post values as well
204
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
204
+            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field );
205 205
 
206 206
             if ( $entry_val ) {
207 207
                 // foreach entry get display_value
208
-                $field_value[] = self::display_value($entry_val, $field, $atts);
208
+                $field_value[] = self::display_value( $entry_val, $field, $atts );
209 209
             }
210 210
 
211
-            unset($child_entry);
211
+            unset( $child_entry );
212 212
         }
213 213
 
214
-        $val = implode(', ', (array) $field_value );
214
+        $val = implode( ', ', (array) $field_value );
215 215
 		return FrmAppHelper::kses( $val, 'all' );
216 216
     }
217 217
 
@@ -246,22 +246,22 @@  discard block
 block discarded – undo
246 246
 			$atts['html'] = true;
247 247
 		}
248 248
 
249
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
249
+        $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value );
250 250
 
251
-        if ( ! isset($field->field_options['post_field']) ) {
251
+        if ( ! isset( $field->field_options['post_field'] ) ) {
252 252
             $field->field_options['post_field'] = '';
253 253
         }
254 254
 
255
-        if ( ! isset($field->field_options['custom_field']) ) {
255
+        if ( ! isset( $field->field_options['custom_field'] ) ) {
256 256
             $field->field_options['custom_field'] = '';
257 257
         }
258 258
 
259 259
         if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
260 260
             $atts['pre_truncate'] = $atts['truncate'];
261 261
             $atts['truncate'] = true;
262
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
262
+            $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0;
263 263
 
264
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
264
+            $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts );
265 265
             $atts['truncate'] = $atts['pre_truncate'];
266 266
         }
267 267
 
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
         }
271 271
 
272 272
 		$unfiltered_value = maybe_unserialize( $value );
273
-		$value = apply_filters('frm_display_value_custom', $unfiltered_value, $field, $atts);
273
+		$value = apply_filters( 'frm_display_value_custom', $unfiltered_value, $field, $atts );
274 274
 		$value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) );
275 275
 
276 276
 		if ( $value == $unfiltered_value ) {
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 		}
279 279
 
280 280
         if ( $atts['truncate'] && $atts['type'] != 'url' ) {
281
-            $value = FrmAppHelper::truncate($value, 50);
281
+            $value = FrmAppHelper::truncate( $value, 50 );
282 282
         }
283 283
 
284 284
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
@@ -293,20 +293,20 @@  discard block
 block discarded – undo
293 293
         if ( isset( $args['other'] ) && $args['other'] ) {
294 294
             $value = $args['temp_value'];
295 295
         }
296
-        if ( empty($args['parent_field_id']) ) {
297
-            $_POST['item_meta'][ $field->id ] = $value;
296
+        if ( empty( $args['parent_field_id'] ) ) {
297
+            $_POST['item_meta'][$field->id] = $value;
298 298
         } else {
299
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
299
+            $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value;
300 300
         }
301 301
     }
302 302
 
303 303
 	public static function get_posted_value( $field, &$value, $args ) {
304 304
 		$field_id = is_object( $field ) ? $field->id : $field;
305 305
 
306
-        if ( empty($args['parent_field_id']) ) {
307
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
306
+        if ( empty( $args['parent_field_id'] ) ) {
307
+            $value = isset( $_POST['item_meta'][$field_id] ) ? $_POST['item_meta'][$field_id] : '';
308 308
         } else {
309
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
309
+            $value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] : '';
310 310
         }
311 311
 		FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
312 312
 		$value = stripslashes_deep( $value );
@@ -331,12 +331,12 @@  discard block
 block discarded – undo
331 331
         self::set_other_repeating_vals( $field, $value, $args );
332 332
 
333 333
         // Check if there are any posted "Other" values
334
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
334
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) {
335 335
 
336 336
             // Save original value
337 337
             $args['temp_value'] = $value;
338 338
             $args['other'] = true;
339
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
339
+            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][$field->id] );
340 340
 
341 341
             // Set the validation value now
342 342
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -358,12 +358,12 @@  discard block
 block discarded – undo
358 358
         }
359 359
 
360 360
         // Check if there are any other posted "other" values for this field
361
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
361
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) {
362 362
             // Save original value
363 363
             $args['temp_value'] = $value;
364 364
             $args['other'] = true;
365 365
 
366
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
366
+            $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id];
367 367
 
368 368
             // Set the validation value now
369 369
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -395,27 +395,27 @@  discard block
 block discarded – undo
395 395
             }
396 396
         } else {
397 397
 			// Radio and dropdowns
398
-            $other_key = array_filter( array_keys($field->options), 'is_string');
398
+            $other_key = array_filter( array_keys( $field->options ), 'is_string' );
399 399
             $other_key = reset( $other_key );
400 400
 
401 401
             // Multi-select dropdown
402 402
             if ( is_array( $value ) ) {
403
-                $o_key = array_search( $field->options[ $other_key ], $value );
403
+                $o_key = array_search( $field->options[$other_key], $value );
404 404
 
405 405
 				if ( $o_key !== false ) {
406 406
 					// Modify the original value so other key will be preserved
407
-					$value[ $other_key ] = $value[ $o_key ];
407
+					$value[$other_key] = $value[$o_key];
408 408
 
409 409
 					// By default, the array keys will be numeric for multi-select dropdowns
410 410
 					// If going backwards and forwards between pages, the array key will match the other key
411 411
 					if ( $o_key != $other_key ) {
412
-						unset( $value[ $o_key ] );
412
+						unset( $value[$o_key] );
413 413
 					}
414 414
 
415 415
 					$args['temp_value'] = $value;
416
-					$value[ $other_key ] = reset( $other_vals );
416
+					$value[$other_key] = reset( $other_vals );
417 417
 				}
418
-            } else if ( $field->options[ $other_key ] == $value ) {
418
+            } else if ( $field->options[$other_key] == $value ) {
419 419
                 $value = $other_vals;
420 420
             }
421 421
         }
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 				$content .= "\n\n";
430 430
 			}
431 431
 
432
-			if ( is_array($val) ) {
432
+			if ( is_array( $val ) ) {
433 433
 				$val = FrmAppHelper::array_flatten( $val );
434 434
 				$val = implode( ', ', $val );
435 435
 			}
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 		preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers
494 494
 
495 495
 		// see how many we have
496
-		$i = count($matches['browser']);
496
+		$i = count( $matches['browser'] );
497 497
 
498 498
 		if ( $i > 1 ) {
499 499
 			//we will have two since we are not using 'other' argument yet
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesListHelper.php 2 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -6,10 +6,10 @@  discard block
 block discarded – undo
6 6
 	protected $field;
7 7
 
8 8
 	public function prepare_items() {
9
-        global $per_page;
9
+		global $per_page;
10 10
 
11 11
 		$per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' );
12
-        $form_id = $this->params['form'];
12
+		$form_id = $this->params['form'];
13 13
 
14 14
 		$s_query = array();
15 15
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 
62 62
 		$limit = FrmDb::esc_limit( $start . ',' . $per_page );
63 63
 		$this->items = FrmEntry::getAll( $s_query, $order, $limit, true, $join_form_in_query );
64
-        $total_items = FrmEntry::getRecordCount($s_query);
64
+		$total_items = FrmEntry::getRecordCount($s_query);
65 65
 
66 66
 		$this->set_pagination_args( array(
67 67
 			'total_items' => $total_items,
@@ -74,18 +74,18 @@  discard block
 block discarded – undo
74 74
 			'param' => 's',
75 75
 			'sanitize' => 'sanitize_text_field',
76 76
 		) );
77
-	    if ( ! empty($s) ) {
77
+		if ( ! empty($s) ) {
78 78
 			esc_html_e( 'No Entries Found', 'formidable' );
79
-            return;
80
-        }
79
+			return;
80
+		}
81 81
 
82 82
 		$form_id = $this->params['form'];
83 83
 		$form = $this->params['form'];
84 84
 
85
-        if ( $form_id ) {
86
-            $form = FrmForm::getOne($form_id);
87
-        }
88
-        $colspan = $this->get_column_count();
85
+		if ( $form_id ) {
86
+			$form = FrmForm::getOne($form_id);
87
+		}
88
+		$colspan = $this->get_column_count();
89 89
 
90 90
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' );
91 91
 	}
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
 	}
106 106
 
107 107
 	/**
108
-	* Gets the name of the primary column in the Entries screen
109
-	*
110
-	* @since 2.0.14
111
-	*
112
-	* @return string $primary_column
113
-	*/
108
+	 * Gets the name of the primary column in the Entries screen
109
+	 *
110
+	 * @since 2.0.14
111
+	 *
112
+	 * @return string $primary_column
113
+	 */
114 114
 	protected function get_primary_column_name() {
115 115
 		$columns = get_column_headers( $this->screen );
116 116
 		$hidden = get_hidden_columns( $this->screen );
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
 		$this->get_actions( $actions, $item, $view_link );
136 136
 
137
-        $action_links = $this->row_actions( $actions );
137
+		$action_links = $this->row_actions( $actions );
138 138
 
139 139
 		// Set up the checkbox ( because the user is editable, otherwise its empty )
140 140
 		$checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />";
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		$r = "<tr id='item-action-{$item->id}'$style>";
143 143
 
144 144
 		list( $columns, $hidden, , $primary ) = $this->get_column_info();
145
-        $action_col = false;
145
+		$action_col = false;
146 146
 
147 147
 		foreach ( $columns as $column_name => $column_display_name ) {
148 148
 			$class = $column_name . ' column-' . $column_name;
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 			if ( in_array( $column_name, $hidden ) ) {
155 155
 				$class .= ' frm_hidden';
156 156
 			} else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) {
157
-			    $action_col = $column_name;
158
-            }
157
+				$action_col = $column_name;
158
+			}
159 159
 
160 160
 			$attributes = 'class="' . esc_attr( $class ) . '"';
161 161
 			unset($class);
@@ -173,15 +173,15 @@  discard block
 block discarded – undo
173 173
 					$val = $this->column_value( $item );
174 174
 				}
175 175
 
176
-			    $r .= "<td $attributes>";
176
+				$r .= "<td $attributes>";
177 177
 				if ( $column_name == $action_col ) {
178 178
 					$edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id;
179 179
 					$r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
180
-			        $r .= $action_links;
180
+					$r .= $action_links;
181 181
 				} else {
182
-			        $r .= $val;
183
-			    }
184
-			    $r .= '</td>';
182
+					$r .= $val;
183
+				}
184
+				$r .= '</td>';
185 185
 			}
186 186
 			unset($val);
187 187
 		}
@@ -234,19 +234,19 @@  discard block
 block discarded – undo
234 234
 		return $val;
235 235
 	}
236 236
 
237
-    /**
238
-     * @param string $view_link
239
-     */
240
-    private function get_actions( &$actions, $item, $view_link ) {
237
+	/**
238
+	 * @param string $view_link
239
+	 */
240
+	private function get_actions( &$actions, $item, $view_link ) {
241 241
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
242 242
 
243
-        if ( current_user_can('frm_delete_entries') ) {
243
+		if ( current_user_can('frm_delete_entries') ) {
244 244
 			$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
245 245
 			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" data-frmverify="' . esc_attr__( 'Are you sure?', 'formidable' ) . '">' . __( 'Delete' ) . '</a>';
246
-	    }
246
+		}
247 247
 
248
-        $actions = apply_filters('frm_row_actions', $actions, $item);
249
-    }
248
+		$actions = apply_filters('frm_row_actions', $actions, $item);
249
+	}
250 250
 
251 251
 	private function get_column_value( $item, &$val ) {
252 252
 		$col_name = $this->column_name;
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 
62 62
 		$limit = FrmDb::esc_limit( $start . ',' . $per_page );
63 63
 		$this->items = FrmEntry::getAll( $s_query, $order, $limit, true, $join_form_in_query );
64
-        $total_items = FrmEntry::getRecordCount($s_query);
64
+        $total_items = FrmEntry::getRecordCount( $s_query );
65 65
 
66 66
 		$this->set_pagination_args( array(
67 67
 			'total_items' => $total_items,
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 			'param' => 's',
75 75
 			'sanitize' => 'sanitize_text_field',
76 76
 		) );
77
-	    if ( ! empty($s) ) {
77
+	    if ( ! empty( $s ) ) {
78 78
 			esc_html_e( 'No Entries Found', 'formidable' );
79 79
             return;
80 80
         }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		$form = $this->params['form'];
84 84
 
85 85
         if ( $form_id ) {
86
-            $form = FrmForm::getOne($form_id);
86
+            $form = FrmForm::getOne( $form_id );
87 87
         }
88 88
         $colspan = $this->get_column_count();
89 89
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 
142 142
 		$r = "<tr id='item-action-{$item->id}'$style>";
143 143
 
144
-		list( $columns, $hidden, , $primary ) = $this->get_column_info();
144
+		list( $columns, $hidden,, $primary ) = $this->get_column_info();
145 145
         $action_col = false;
146 146
 
147 147
 		foreach ( $columns as $column_name => $column_display_name ) {
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             }
159 159
 
160 160
 			$attributes = 'class="' . esc_attr( $class ) . '"';
161
-			unset($class);
161
+			unset( $class );
162 162
 			$attributes .= ' data-colname="' . $column_display_name . '"';
163 163
 
164 164
 			$form_id = $this->params['form'] ? $this->params['form'] : 0;
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			    }
184 184
 			    $r .= '</td>';
185 185
 			}
186
-			unset($val);
186
+			unset( $val );
187 187
 		}
188 188
 		$r .= '</tr>';
189 189
 
@@ -240,12 +240,12 @@  discard block
 block discarded – undo
240 240
     private function get_actions( &$actions, $item, $view_link ) {
241 241
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
242 242
 
243
-        if ( current_user_can('frm_delete_entries') ) {
243
+        if ( current_user_can( 'frm_delete_entries' ) ) {
244 244
 			$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
245 245
 			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" data-frmverify="' . esc_attr__( 'Are you sure?', 'formidable' ) . '">' . __( 'Delete' ) . '</a>';
246 246
 	    }
247 247
 
248
-        $actions = apply_filters('frm_row_actions', $actions, $item);
248
+        $actions = apply_filters( 'frm_row_actions', $actions, $item );
249 249
     }
250 250
 
251 251
 	private function get_column_value( $item, &$val ) {
Please login to merge, or discard this patch.
classes/helpers/FrmXMLHelper.php 2 patches
Indentation   +483 added lines, -483 removed lines patch added patch discarded remove patch
@@ -33,24 +33,24 @@  discard block
 block discarded – undo
33 33
 			'styles'  => 0,
34 34
 		);
35 35
 
36
-        $imported = array(
37
-            'imported' => $defaults,
36
+		$imported = array(
37
+			'imported' => $defaults,
38 38
 			'updated'  => $defaults,
39 39
 			'forms'    => array(),
40 40
 			'terms'    => array(),
41
-        );
41
+		);
42 42
 
43
-        unset($defaults);
43
+		unset($defaults);
44 44
 
45 45
 		if ( ! defined( 'WP_IMPORTING' ) ) {
46
-            define('WP_IMPORTING', true);
47
-        }
46
+			define('WP_IMPORTING', true);
47
+		}
48 48
 
49 49
 		if ( ! class_exists( 'DOMDocument' ) ) {
50
-            return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
51
-        }
50
+			return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
51
+		}
52 52
 
53
-        $dom = new DOMDocument;
53
+		$dom = new DOMDocument;
54 54
 		$success = $dom->loadXML( file_get_contents( $file ) );
55 55
 		if ( ! $success ) {
56 56
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
@@ -68,45 +68,45 @@  discard block
 block discarded – undo
68 68
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
69 69
 		}
70 70
 
71
-        // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
71
+		// add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
72 72
 		foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
73
-            // grab cats, tags, and terms, or forms or posts
74
-            if ( isset($xml->{$item_type} ) ) {
73
+			// grab cats, tags, and terms, or forms or posts
74
+			if ( isset($xml->{$item_type} ) ) {
75 75
 				$function_name = 'import_xml_' . $item_type . 's';
76 76
 				$imported = self::$function_name( $xml->{$item_type}, $imported );
77 77
 				unset( $function_name, $xml->{$item_type} );
78
-            }
79
-        }
78
+			}
79
+		}
80 80
 
81
-	    $return = apply_filters('frm_importing_xml', $imported, $xml );
81
+		$return = apply_filters('frm_importing_xml', $imported, $xml );
82 82
 
83
-	    return $return;
84
-    }
83
+		return $return;
84
+	}
85 85
 
86 86
 	public static function import_xml_terms( $terms, $imported ) {
87
-        foreach ( $terms as $t ) {
87
+		foreach ( $terms as $t ) {
88 88
 			if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) {
89
-			    continue;
89
+				continue;
90 90
 			}
91 91
 
92 92
 			$parent = self::get_term_parent_id( $t );
93 93
 
94 94
 			$term = wp_insert_term( (string) $t->term_name, (string) $t->term_taxonomy, array(
95
-                'slug'          => (string) $t->term_slug,
96
-                'description'   => (string) $t->term_description,
95
+				'slug'          => (string) $t->term_slug,
96
+				'description'   => (string) $t->term_description,
97 97
 				'parent'        => empty( $parent ) ? 0 : $parent,
98
-            ));
98
+			));
99 99
 
100 100
 			if ( $term && is_array( $term ) ) {
101
-                $imported['imported']['terms']++;
101
+				$imported['imported']['terms']++;
102 102
 				$imported['terms'][ (int) $t->term_id ] = $term['term_id'];
103
-            }
103
+			}
104 104
 
105 105
 			unset( $term, $t );
106 106
 		}
107 107
 
108 108
 		return $imported;
109
-    }
109
+	}
110 110
 
111 111
 	/**
112 112
 	 * @since 2.0.8
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
 		self::put_child_forms_first( $forms );
132 132
 
133 133
 		foreach ( $forms as $item ) {
134
-            $form = self::fill_form( $item );
134
+			$form = self::fill_form( $item );
135 135
 
136 136
 			self::update_custom_style_setting_on_import( $form );
137 137
 
138
-	        $this_form = self::maybe_get_form( $form );
138
+			$this_form = self::maybe_get_form( $form );
139 139
 
140 140
 			$old_id = false;
141 141
 			$form_fields = false;
@@ -147,35 +147,35 @@  discard block
 block discarded – undo
147 147
 				$form_fields = self::get_form_fields( $form_id );
148 148
 			} else {
149 149
 				$form_id = FrmForm::create( $form );
150
-		        if ( $form_id ) {
151
-		            $imported['imported']['forms']++;
152
-		            // Keep track of whether this specific form was updated or not
150
+				if ( $form_id ) {
151
+					$imported['imported']['forms']++;
152
+					// Keep track of whether this specific form was updated or not
153 153
 					$imported['form_status'][ $form_id ] = 'imported';
154 154
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
155
-		        }
155
+				}
156 156
 			}
157 157
 
158 158
 			self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported );
159 159
 
160 160
 			self::delete_removed_fields( $form_fields );
161 161
 
162
-		    // Update field ids/keys to new ones
162
+			// Update field ids/keys to new ones
163 163
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
164 164
 
165 165
 			$imported['forms'][ (int) $item->id ] = $form_id;
166 166
 
167
-            // Send pre 2.0 form options through function that creates actions
168
-            self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true );
167
+			// Send pre 2.0 form options through function that creates actions
168
+			self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true );
169 169
 
170 170
 			do_action( 'frm_after_import_form', $form_id, $form );
171 171
 
172
-		    unset($form, $item);
172
+			unset($form, $item);
173 173
 		}
174 174
 
175 175
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
176 176
 
177 177
 		return $imported;
178
-    }
178
+	}
179 179
 
180 180
 	private static function fill_form( $item ) {
181 181
 		$form = array(
@@ -246,11 +246,11 @@  discard block
 block discarded – undo
246 246
 	}
247 247
 
248 248
 	/**
249
-	* Put child forms first so they will be imported before parents
250
-	*
251
-	* @since 2.0.16
252
-	* @param array $forms
253
-	*/
249
+	 * Put child forms first so they will be imported before parents
250
+	 *
251
+	 * @since 2.0.16
252
+	 * @param array $forms
253
+	 */
254 254
 	private static function put_child_forms_first( &$forms ) {
255 255
 		$child_forms = array();
256 256
 		$regular_forms = array();
@@ -269,13 +269,13 @@  discard block
 block discarded – undo
269 269
 	}
270 270
 
271 271
 	/**
272
-	* Keep track of all imported child forms
273
-	*
274
-	* @since 2.0.16
275
-	* @param int $form_id
276
-	* @param int $parent_form_id
277
-	* @param array $child_forms
278
-	*/
272
+	 * Keep track of all imported child forms
273
+	 *
274
+	 * @since 2.0.16
275
+	 * @param int $form_id
276
+	 * @param int $parent_form_id
277
+	 * @param array $child_forms
278
+	 */
279 279
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
280 280
 		if ( $parent_form_id ) {
281 281
 			$child_forms[ $form_id ] = $parent_form_id;
@@ -283,13 +283,13 @@  discard block
 block discarded – undo
283 283
 	}
284 284
 
285 285
 	/**
286
-	* Update the parent_form_id on imported child forms
287
-	* Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
288
-	*
289
-	* @since 2.0.6
290
-	* @param array $imported_forms
291
-	* @param array $child_forms
292
-	*/
286
+	 * Update the parent_form_id on imported child forms
287
+	 * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
288
+	 *
289
+	 * @since 2.0.6
290
+	 * @param array $imported_forms
291
+	 * @param array $child_forms
292
+	 */
293 293
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
294 294
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
295 295
 
@@ -303,11 +303,11 @@  discard block
 block discarded – undo
303 303
 	}
304 304
 
305 305
 	/**
306
-	* Import all fields for a form
307
-	* @since 2.0.13
308
-	*
309
-	* TODO: Cut down on params
310
-	*/
306
+	 * Import all fields for a form
307
+	 * @since 2.0.13
308
+	 *
309
+	 * TODO: Cut down on params
310
+	 */
311 311
 	private static function import_xml_fields( $xml_fields, $form_id, $this_form, &$form_fields, &$imported ) {
312 312
 		$in_section = 0;
313 313
 
@@ -400,12 +400,12 @@  discard block
 block discarded – undo
400 400
 	}
401 401
 
402 402
 	/**
403
-	* Switch the form_select on a repeating field or embedded form if it needs to be switched
404
-	*
405
-	* @since 2.0.16
406
-	* @param array $f
407
-	* @param array $imported
408
-	*/
403
+	 * Switch the form_select on a repeating field or embedded form if it needs to be switched
404
+	 *
405
+	 * @since 2.0.16
406
+	 * @param array $f
407
+	 * @param array $imported
408
+	 */
409 409
 	private static function maybe_update_form_select( &$f, $imported ) {
410 410
 		if ( ! isset( $imported['forms'] ) ) {
411 411
 			return;
@@ -457,13 +457,13 @@  discard block
 block discarded – undo
457 457
 	}
458 458
 
459 459
 	/**
460
-	* Updates the custom style setting on import
461
-	* Convert the post slug to an ID
462
-	*
463
-	* @since 2.0.19
464
-	* @param array $form
465
-	*
466
-	*/
460
+	 * Updates the custom style setting on import
461
+	 * Convert the post slug to an ID
462
+	 *
463
+	 * @since 2.0.19
464
+	 * @param array $form
465
+	 *
466
+	 */
467 467
 	private static function update_custom_style_setting_on_import( &$form ) {
468 468
 		if ( ! isset( $form['options']['custom_style'] ) ) {
469 469
 			return;
@@ -517,16 +517,16 @@  discard block
 block discarded – undo
517 517
 	}
518 518
 
519 519
 	public static function import_xml_views( $views, $imported ) {
520
-        $imported['posts'] = array();
521
-        $form_action_type = FrmFormActionsController::$action_post_type;
520
+		$imported['posts'] = array();
521
+		$form_action_type = FrmFormActionsController::$action_post_type;
522 522
 
523
-        $post_types = array(
524
-            'frm_display' => 'views',
525
-            $form_action_type => 'actions',
526
-            'frm_styles'    => 'styles',
527
-        );
523
+		$post_types = array(
524
+			'frm_display' => 'views',
525
+			$form_action_type => 'actions',
526
+			'frm_styles'    => 'styles',
527
+		);
528 528
 
529
-        foreach ( $views as $item ) {
529
+		foreach ( $views as $item ) {
530 530
 			$post = array(
531 531
 				'post_title'    => (string) $item->title,
532 532
 				'post_name'     => (string) $item->post_name,
@@ -545,52 +545,52 @@  discard block
 block discarded – undo
545 545
 				'post_date'     => (string) $item->post_date,
546 546
 				'post_date_gmt' => (string) $item->post_date_gmt,
547 547
 				'ping_status'   => (string) $item->ping_status,
548
-                'postmeta'      => array(),
549
-                'tax_input'     => array(),
548
+				'postmeta'      => array(),
549
+				'tax_input'     => array(),
550 550
 			);
551 551
 
552
-            $old_id = $post['post_id'];
553
-            self::populate_post($post, $item, $imported);
552
+			$old_id = $post['post_id'];
553
+			self::populate_post($post, $item, $imported);
554 554
 
555 555
 			unset($item);
556 556
 
557 557
 			$post_id = false;
558
-            if ( $post['post_type'] == $form_action_type ) {
559
-                $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
558
+			if ( $post['post_type'] == $form_action_type ) {
559
+				$action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
560 560
 				if ( $action_control && is_object( $action_control ) ) {
561 561
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
562 562
 				}
563
-                unset($action_control);
564
-            } else if ( $post['post_type'] == 'frm_styles' ) {
565
-                // Properly encode post content before inserting the post
566
-                $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
563
+				unset($action_control);
564
+			} else if ( $post['post_type'] == 'frm_styles' ) {
565
+				// Properly encode post content before inserting the post
566
+				$post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
567 567
 				$custom_css = isset( $post['post_content']['custom_css'] ) ? $post['post_content']['custom_css'] : '';
568
-                $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
568
+				$post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
569 569
 
570
-                // Create/update post now
571
-                $post_id = wp_insert_post( $post );
570
+				// Create/update post now
571
+				$post_id = wp_insert_post( $post );
572 572
 				self::maybe_update_custom_css( $custom_css );
573
-            } else {
574
-                // Create/update post now
575
-                $post_id = wp_insert_post( $post );
576
-            }
573
+			} else {
574
+				// Create/update post now
575
+				$post_id = wp_insert_post( $post );
576
+			}
577 577
 
578
-            if ( ! is_numeric($post_id) ) {
579
-                continue;
580
-            }
578
+			if ( ! is_numeric($post_id) ) {
579
+				continue;
580
+			}
581 581
 
582
-            self::update_postmeta($post, $post_id);
582
+			self::update_postmeta($post, $post_id);
583 583
 
584
-            $this_type = 'posts';
584
+			$this_type = 'posts';
585 585
 			if ( isset( $post_types[ $post['post_type'] ] ) ) {
586 586
 				$this_type = $post_types[ $post['post_type'] ];
587
-            }
587
+			}
588 588
 
589
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
590
-                $imported['updated'][ $this_type ]++;
591
-            } else {
592
-                $imported['imported'][ $this_type ]++;
593
-            }
589
+			if ( isset($post['ID']) && $post_id == $post['ID'] ) {
590
+				$imported['updated'][ $this_type ]++;
591
+			} else {
592
+				$imported['imported'][ $this_type ]++;
593
+			}
594 594
 
595 595
 			$imported['posts'][ (int) $old_id ] = $post_id;
596 596
 
@@ -602,16 +602,16 @@  discard block
 block discarded – undo
602 602
 		self::maybe_update_stylesheet( $imported );
603 603
 
604 604
 		return $imported;
605
-    }
605
+	}
606 606
 
607
-    private static function populate_post( &$post, $item, $imported ) {
607
+	private static function populate_post( &$post, $item, $imported ) {
608 608
 		if ( isset($item->attachment_url) ) {
609 609
 			$post['attachment_url'] = (string) $item->attachment_url;
610 610
 		}
611 611
 
612 612
 		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
613
-		    // update to new form id
614
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
613
+			// update to new form id
614
+			$post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
615 615
 		}
616 616
 
617 617
 		// Don't allow default styles to take over a site's default style
@@ -620,145 +620,145 @@  discard block
 block discarded – undo
620 620
 		}
621 621
 
622 622
 		foreach ( $item->postmeta as $meta ) {
623
-		    self::populate_postmeta($post, $meta, $imported);
623
+			self::populate_postmeta($post, $meta, $imported);
624 624
 			unset($meta);
625 625
 		}
626 626
 
627
-        self::populate_taxonomies($post, $item);
627
+		self::populate_taxonomies($post, $item);
628 628
 
629
-        self::maybe_editing_post($post);
630
-    }
629
+		self::maybe_editing_post($post);
630
+	}
631 631
 
632
-    private static function populate_postmeta( &$post, $meta, $imported ) {
633
-        global $frm_duplicate_ids;
632
+	private static function populate_postmeta( &$post, $meta, $imported ) {
633
+		global $frm_duplicate_ids;
634 634
 
635
-	    $m = array(
635
+		$m = array(
636 636
 			'key'   => (string) $meta->meta_key,
637 637
 			'value' => (string) $meta->meta_value,
638 638
 		);
639 639
 
640 640
 		//switch old form and field ids to new ones
641 641
 		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
642
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
642
+			$m['value'] = $imported['forms'][ (int) $m['value'] ];
643 643
 		} else {
644
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
644
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
645 645
 
646
-		    if ( ! empty($frm_duplicate_ids) ) {
646
+			if ( ! empty($frm_duplicate_ids) ) {
647 647
 
648
-		        if ( $m['key'] == 'frm_dyncontent' ) {
649
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
650
-    		    } else if ( $m['key'] == 'frm_options' ) {
648
+				if ( $m['key'] == 'frm_dyncontent' ) {
649
+					$m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
650
+				} else if ( $m['key'] == 'frm_options' ) {
651 651
 
652 652
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
653 653
 						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
654 654
 							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
655
-    		            }
656
-    		        }
657
-
658
-                    $check_dup_array = array();
659
-    		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
660
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
661
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
662
-    		            } else if ( is_array( $m['value']['order_by'] ) ) {
663
-                            $check_dup_array[] = 'order_by';
664
-    		            }
665
-    		        }
666
-
667
-    		        if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
668
-    		            $check_dup_array[] = 'where';
669
-    		        }
670
-
671
-                    foreach ( $check_dup_array as $check_k ) {
655
+						}
656
+					}
657
+
658
+					$check_dup_array = array();
659
+					if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
660
+						if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
661
+							$m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
662
+						} else if ( is_array( $m['value']['order_by'] ) ) {
663
+							$check_dup_array[] = 'order_by';
664
+						}
665
+					}
666
+
667
+					if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
668
+						$check_dup_array[] = 'where';
669
+					}
670
+
671
+					foreach ( $check_dup_array as $check_k ) {
672 672
 						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
673 673
 							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
674 674
 								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
675
-		                    }
676
-		                    unset($mk, $mv);
677
-		                }
678
-                    }
679
-    		    }
680
-		    }
675
+							}
676
+							unset($mk, $mv);
677
+						}
678
+					}
679
+				}
680
+			}
681 681
 		}
682 682
 
683 683
 		if ( ! is_array($m['value']) ) {
684
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
684
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
685 685
 		}
686 686
 
687 687
 		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
688
-    }
689
-
690
-    /**
691
-     * Add terms to post
692
-     * @param array $post by reference
693
-     * @param object $item The XML object data
694
-     */
695
-    private static function populate_taxonomies( &$post, $item ) {
688
+	}
689
+
690
+	/**
691
+	 * Add terms to post
692
+	 * @param array $post by reference
693
+	 * @param object $item The XML object data
694
+	 */
695
+	private static function populate_taxonomies( &$post, $item ) {
696 696
 		foreach ( $item->category as $c ) {
697 697
 			$att = $c->attributes();
698 698
 			if ( ! isset( $att['nicename'] ) ) {
699
-                continue;
700
-            }
701
-
702
-		    $taxonomy = (string) $att['domain'];
703
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
704
-		        $name = (string) $att['nicename'];
705
-		        $h_term = get_term_by('slug', $name, $taxonomy);
706
-		        if ( $h_term ) {
707
-		            $name = $h_term->term_id;
708
-		        }
709
-		        unset($h_term);
710
-		    } else {
711
-		        $name = (string) $c;
712
-		    }
699
+				continue;
700
+			}
701
+
702
+			$taxonomy = (string) $att['domain'];
703
+			if ( is_taxonomy_hierarchical($taxonomy) ) {
704
+				$name = (string) $att['nicename'];
705
+				$h_term = get_term_by('slug', $name, $taxonomy);
706
+				if ( $h_term ) {
707
+					$name = $h_term->term_id;
708
+				}
709
+				unset($h_term);
710
+			} else {
711
+				$name = (string) $c;
712
+			}
713 713
 
714 714
 			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
715 715
 				$post['tax_input'][ $taxonomy ] = array();
716 716
 			}
717 717
 
718 718
 			$post['tax_input'][ $taxonomy ][] = $name;
719
-		    unset($name);
719
+			unset($name);
720 720
 		}
721
-    }
721
+	}
722 722
 
723
-    /**
724
-     * Edit post if the key and created time match
725
-     */
726
-    private static function maybe_editing_post( &$post ) {
723
+	/**
724
+	 * Edit post if the key and created time match
725
+	 */
726
+	private static function maybe_editing_post( &$post ) {
727 727
 		$match_by = array(
728
-		    'post_type'     => $post['post_type'],
729
-		    'name'          => $post['post_name'],
730
-		    'post_status'   => $post['post_status'],
731
-		    'posts_per_page' => 1,
728
+			'post_type'     => $post['post_type'],
729
+			'name'          => $post['post_name'],
730
+			'post_status'   => $post['post_status'],
731
+			'posts_per_page' => 1,
732 732
 		);
733 733
 
734 734
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
735
-		    $match_by['include'] = $post['post_id'];
736
-		    unset($match_by['name']);
735
+			$match_by['include'] = $post['post_id'];
736
+			unset($match_by['name']);
737 737
 		}
738 738
 
739 739
 		$editing = get_posts($match_by);
740 740
 
741
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
742
-            // set the id of the post to edit
743
-            $post['ID'] = current($editing)->ID;
744
-        }
745
-    }
746
-
747
-    private static function update_postmeta( &$post, $post_id ) {
748
-        foreach ( $post['postmeta'] as $k => $v ) {
749
-            if ( '_edit_last' == $k ) {
750
-                $v = FrmAppHelper::get_user_id_param($v);
751
-            } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
752
-                //change the attachment ID
741
+		if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
742
+			// set the id of the post to edit
743
+			$post['ID'] = current($editing)->ID;
744
+		}
745
+	}
746
+
747
+	private static function update_postmeta( &$post, $post_id ) {
748
+		foreach ( $post['postmeta'] as $k => $v ) {
749
+			if ( '_edit_last' == $k ) {
750
+				$v = FrmAppHelper::get_user_id_param($v);
751
+			} else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
752
+				//change the attachment ID
753 753
 				$field_obj = FrmFieldFactory::get_field_type( 'file' );
754 754
 				$v = $field_obj->get_file_id( $v );
755
-            }
755
+			}
756 756
 
757
-            update_post_meta($post_id, $k, $v);
757
+			update_post_meta($post_id, $k, $v);
758 758
 
759
-            unset($k, $v);
760
-        }
761
-    }
759
+			unset($k, $v);
760
+		}
761
+	}
762 762
 
763 763
 	/**
764 764
 	 * If a template includes custom css, let's include it.
@@ -791,72 +791,72 @@  discard block
 block discarded – undo
791 791
 		}
792 792
 	}
793 793
 
794
-    /**
795
-     * @param string $message
796
-     */
794
+	/**
795
+	 * @param string $message
796
+	 */
797 797
 	public static function parse_message( $result, &$message, &$errors ) {
798
-        if ( is_wp_error($result) ) {
799
-            $errors[] = $result->get_error_message();
800
-        } else if ( ! $result ) {
801
-            return;
802
-        }
803
-
804
-        if ( ! is_array($result) ) {
805
-            $message = is_string( $result ) ? $result : htmlentities( print_r( $result, 1 ) );
806
-            return;
807
-        }
808
-
809
-        $t_strings = array(
810
-            'imported'  => __( 'Imported', 'formidable' ),
811
-            'updated'   => __( 'Updated', 'formidable' ),
812
-        );
813
-
814
-        $message = '<ul>';
815
-        foreach ( $result as $type => $results ) {
798
+		if ( is_wp_error($result) ) {
799
+			$errors[] = $result->get_error_message();
800
+		} else if ( ! $result ) {
801
+			return;
802
+		}
803
+
804
+		if ( ! is_array($result) ) {
805
+			$message = is_string( $result ) ? $result : htmlentities( print_r( $result, 1 ) );
806
+			return;
807
+		}
808
+
809
+		$t_strings = array(
810
+			'imported'  => __( 'Imported', 'formidable' ),
811
+			'updated'   => __( 'Updated', 'formidable' ),
812
+		);
813
+
814
+		$message = '<ul>';
815
+		foreach ( $result as $type => $results ) {
816 816
 			if ( ! isset( $t_strings[ $type ] ) ) {
817
-                // only print imported and updated
818
-                continue;
819
-            }
817
+				// only print imported and updated
818
+				continue;
819
+			}
820 820
 
821
-            $s_message = array();
822
-            foreach ( $results as $k => $m ) {
823
-                self::item_count_message($m, $k, $s_message);
824
-                unset($k, $m);
825
-            }
821
+			$s_message = array();
822
+			foreach ( $results as $k => $m ) {
823
+				self::item_count_message($m, $k, $s_message);
824
+				unset($k, $m);
825
+			}
826 826
 
827
-            if ( ! empty($s_message) ) {
827
+			if ( ! empty($s_message) ) {
828 828
 				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
829
-                $message .= implode(', ', $s_message);
830
-                $message .= '</li>';
831
-            }
832
-        }
833
-
834
-        if ( $message == '<ul>' ) {
835
-            $message = '';
836
-            $errors[] = __( 'Nothing was imported or updated', 'formidable' );
837
-        } else {
838
-            $message .= '</ul>';
839
-        }
840
-    }
829
+				$message .= implode(', ', $s_message);
830
+				$message .= '</li>';
831
+			}
832
+		}
833
+
834
+		if ( $message == '<ul>' ) {
835
+			$message = '';
836
+			$errors[] = __( 'Nothing was imported or updated', 'formidable' );
837
+		} else {
838
+			$message .= '</ul>';
839
+		}
840
+	}
841 841
 
842 842
 	public static function item_count_message( $m, $type, &$s_message ) {
843
-        if ( ! $m ) {
844
-            return;
845
-        }
846
-
847
-        $strings = array(
848
-            'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
849
-            'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
850
-            'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
851
-            'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
852
-            'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
853
-            'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
854
-            'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
855
-            'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
856
-        );
843
+		if ( ! $m ) {
844
+			return;
845
+		}
846
+
847
+		$strings = array(
848
+			'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
849
+			'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
850
+			'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
851
+			'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
852
+			'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
853
+			'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
854
+			'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
855
+			'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
856
+		);
857 857
 
858 858
 		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
859
-    }
859
+	}
860 860
 
861 861
 	/**
862 862
 	 * Prepare the form options for export
@@ -887,16 +887,16 @@  discard block
 block discarded – undo
887 887
 	}
888 888
 
889 889
 	public static function cdata( $str ) {
890
-	    $str = maybe_unserialize($str);
891
-	    if ( is_array($str) ) {
892
-	        $str = json_encode($str);
890
+		$str = maybe_unserialize($str);
891
+		if ( is_array($str) ) {
892
+			$str = json_encode($str);
893 893
 		} else if ( seems_utf8( $str ) == false ) {
894 894
 			$str = utf8_encode( $str );
895 895
 		}
896 896
 
897
-        if ( is_numeric($str) ) {
898
-            return $str;
899
-        }
897
+		if ( is_numeric($str) ) {
898
+			return $str;
899
+		}
900 900
 
901 901
 		self::remove_invalid_characters_from_xml( $str );
902 902
 
@@ -917,54 +917,54 @@  discard block
 block discarded – undo
917 917
 		$str = str_replace( '\x1F', '', $str );
918 918
 	}
919 919
 
920
-    public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
921
-        // Get post type
922
-        $post_type = FrmFormActionsController::$action_post_type;
923
-
924
-        // Set up imported index, if not set up yet
925
-        if ( ! isset( $imported['imported']['actions'] ) ) {
926
-            $imported['imported']['actions'] = 0;
927
-        }
928
-
929
-        // Migrate post settings to action
930
-        self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
931
-
932
-        // Migrate email settings to action
933
-        self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
934
-    }
935
-
936
-    /**
937
-    * Migrate post settings to form action
938
-    *
939
-    * @param string $post_type
940
-    */
941
-    private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
942
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
943
-            return;
944
-        }
945
-
946
-        $new_action = array(
947
-            'post_type'     => $post_type,
948
-            'post_excerpt'  => 'wppost',
920
+	public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
921
+		// Get post type
922
+		$post_type = FrmFormActionsController::$action_post_type;
923
+
924
+		// Set up imported index, if not set up yet
925
+		if ( ! isset( $imported['imported']['actions'] ) ) {
926
+			$imported['imported']['actions'] = 0;
927
+		}
928
+
929
+		// Migrate post settings to action
930
+		self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
931
+
932
+		// Migrate email settings to action
933
+		self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
934
+	}
935
+
936
+	/**
937
+	 * Migrate post settings to form action
938
+	 *
939
+	 * @param string $post_type
940
+	 */
941
+	private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
942
+		if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
943
+			return;
944
+		}
945
+
946
+		$new_action = array(
947
+			'post_type'     => $post_type,
948
+			'post_excerpt'  => 'wppost',
949 949
 			'post_title'    => __( 'Create Posts', 'formidable' ),
950
-            'menu_order'    => $form_id,
951
-            'post_status'   => 'publish',
952
-            'post_content'  => array(),
950
+			'menu_order'    => $form_id,
951
+			'post_status'   => 'publish',
952
+			'post_content'  => array(),
953 953
 			'post_name'     => $form_id . '_wppost_1',
954
-        );
954
+		);
955 955
 
956 956
 		$post_settings = array( 'post_type', 'post_category', 'post_content', 'post_excerpt', 'post_title', 'post_name', 'post_date', 'post_status', 'post_custom_fields', 'post_password' );
957 957
 
958
-        foreach ( $post_settings as $post_setting ) {
958
+		foreach ( $post_settings as $post_setting ) {
959 959
 			if ( isset( $form_options[ $post_setting ] ) ) {
960 960
 				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
961
-            }
962
-            unset($post_setting);
963
-        }
961
+			}
962
+			unset($post_setting);
963
+		}
964 964
 
965 965
 		$new_action['event'] = array( 'create', 'update' );
966 966
 
967
-        if ( $switch ) {
967
+		if ( $switch ) {
968 968
 			// Fields with string or int saved
969 969
 			$basic_fields = array( 'post_title', 'post_content', 'post_excerpt', 'post_password', 'post_date', 'post_status' );
970 970
 
@@ -972,22 +972,22 @@  discard block
 block discarded – undo
972 972
 			$array_fields = array( 'post_category', 'post_custom_fields' );
973 973
 
974 974
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
975
-        }
976
-        $new_action['post_content'] = json_encode($new_action['post_content']);
975
+		}
976
+		$new_action['post_content'] = json_encode($new_action['post_content']);
977 977
 
978
-        $exists = get_posts( array(
979
-            'name'          => $new_action['post_name'],
980
-            'post_type'     => $new_action['post_type'],
981
-            'post_status'   => $new_action['post_status'],
982
-            'numberposts'   => 1,
983
-        ) );
978
+		$exists = get_posts( array(
979
+			'name'          => $new_action['post_name'],
980
+			'post_type'     => $new_action['post_type'],
981
+			'post_status'   => $new_action['post_status'],
982
+			'numberposts'   => 1,
983
+		) );
984 984
 
985
-        if ( ! $exists ) {
985
+		if ( ! $exists ) {
986 986
 			// this isn't an email, but we need to use a class that will always be included
987 987
 			FrmDb::save_json_post( $new_action );
988
-            $imported['imported']['actions']++;
989
-        }
990
-    }
988
+			$imported['imported']['actions']++;
989
+		}
990
+	}
991 991
 
992 992
 	/**
993 993
 	 * Switch old field IDs for new field IDs in emails and post
@@ -1000,88 +1000,88 @@  discard block
 block discarded – undo
1000 1000
 	 * @return string $post_content - new field IDs
1001 1001
 	 */
1002 1002
 	private static function switch_action_field_ids( $post_content, $basic_fields, $array_fields = array() ) {
1003
-        global $frm_duplicate_ids;
1003
+		global $frm_duplicate_ids;
1004 1004
 
1005
-        // If there aren't IDs that were switched, end now
1006
-        if ( ! $frm_duplicate_ids ) {
1007
-            return;
1008
-        }
1005
+		// If there aren't IDs that were switched, end now
1006
+		if ( ! $frm_duplicate_ids ) {
1007
+			return;
1008
+		}
1009 1009
 
1010
-        // Get old IDs
1011
-        $old = array_keys( $frm_duplicate_ids );
1010
+		// Get old IDs
1011
+		$old = array_keys( $frm_duplicate_ids );
1012 1012
 
1013
-        // Get new IDs
1014
-        $new = array_values( $frm_duplicate_ids );
1013
+		// Get new IDs
1014
+		$new = array_values( $frm_duplicate_ids );
1015 1015
 
1016
-        // Do a str_replace with each item to set the new IDs
1017
-        foreach ( $post_content as $key => $setting ) {
1018
-            if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
1019
-                // Replace old IDs with new IDs
1016
+		// Do a str_replace with each item to set the new IDs
1017
+		foreach ( $post_content as $key => $setting ) {
1018
+			if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
1019
+				// Replace old IDs with new IDs
1020 1020
 				$post_content[ $key ] = str_replace( $old, $new, $setting );
1021
-            } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
1022
-                foreach ( $setting as $k => $val ) {
1023
-                    // Replace old IDs with new IDs
1021
+			} else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
1022
+				foreach ( $setting as $k => $val ) {
1023
+					// Replace old IDs with new IDs
1024 1024
 					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
1025
-                }
1026
-            }
1027
-            unset( $key, $setting );
1028
-        }
1029
-        return $post_content;
1030
-    }
1031
-
1032
-    private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
1033
-        // No old notifications or autoresponders to carry over
1025
+				}
1026
+			}
1027
+			unset( $key, $setting );
1028
+		}
1029
+		return $post_content;
1030
+	}
1031
+
1032
+	private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
1033
+		// No old notifications or autoresponders to carry over
1034 1034
 		if ( ! isset( $form_options['auto_responder'] ) && ! isset( $form_options['notification'] ) && ! isset( $form_options['email_to'] ) ) {
1035
-            return;
1036
-        }
1035
+			return;
1036
+		}
1037 1037
 
1038
-        // Initialize notifications array
1039
-        $notifications = array();
1038
+		// Initialize notifications array
1039
+		$notifications = array();
1040 1040
 
1041
-        // Migrate regular notifications
1042
-        self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
1041
+		// Migrate regular notifications
1042
+		self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
1043 1043
 
1044
-        // Migrate autoresponders
1045
-        self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
1044
+		// Migrate autoresponders
1045
+		self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
1046 1046
 
1047
-        if ( empty( $notifications ) ) {
1048
-            return;
1049
-        }
1047
+		if ( empty( $notifications ) ) {
1048
+			return;
1049
+		}
1050 1050
 
1051
-        foreach ( $notifications as $new_notification ) {
1052
-            $new_notification['post_type']      = $post_type;
1053
-            $new_notification['post_excerpt']   = 'email';
1051
+		foreach ( $notifications as $new_notification ) {
1052
+			$new_notification['post_type']      = $post_type;
1053
+			$new_notification['post_excerpt']   = 'email';
1054 1054
 			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
1055
-            $new_notification['menu_order']     = $form_id;
1056
-            $new_notification['post_status']    = 'publish';
1055
+			$new_notification['menu_order']     = $form_id;
1056
+			$new_notification['post_status']    = 'publish';
1057 1057
 
1058
-            // Switch field IDs and keys, if needed
1059
-            if ( $switch ) {
1058
+			// Switch field IDs and keys, if needed
1059
+			if ( $switch ) {
1060 1060
 
1061 1061
 				// Switch field IDs in email conditional logic
1062 1062
 				self::switch_email_contition_field_ids( $new_notification['post_content'] );
1063 1063
 
1064 1064
 				// Switch all other field IDs in email
1065
-                $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1066
-            }
1067
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1068
-
1069
-            $exists = get_posts( array(
1070
-                'name'          => $new_notification['post_name'],
1071
-                'post_type'     => $new_notification['post_type'],
1072
-                'post_status'   => $new_notification['post_status'],
1073
-                'numberposts'   => 1,
1074
-            ) );
1075
-
1076
-            if ( empty($exists) ) {
1065
+				$new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1066
+			}
1067
+			$new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1068
+
1069
+			$exists = get_posts( array(
1070
+				'name'          => $new_notification['post_name'],
1071
+				'post_type'     => $new_notification['post_type'],
1072
+				'post_status'   => $new_notification['post_status'],
1073
+				'numberposts'   => 1,
1074
+			) );
1075
+
1076
+			if ( empty($exists) ) {
1077 1077
 				FrmDb::save_json_post( $new_notification );
1078
-                $imported['imported']['actions']++;
1079
-            }
1080
-            unset($new_notification);
1081
-        }
1078
+				$imported['imported']['actions']++;
1079
+			}
1080
+			unset($new_notification);
1081
+		}
1082 1082
 
1083 1083
 		self::remove_deprecated_notification_settings( $form_id, $form_options );
1084
-    }
1084
+	}
1085 1085
 
1086 1086
 	/**
1087 1087
 	 * Remove deprecated notification settings after migration
@@ -1101,17 +1101,17 @@  discard block
 block discarded – undo
1101 1101
 		FrmForm::update( $form_id, array( 'options' => $form_options ) );
1102 1102
 	}
1103 1103
 
1104
-    private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
1105
-        if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
1106
-            // add old settings into notification array
1104
+	private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
1105
+		if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
1106
+			// add old settings into notification array
1107 1107
 			$form_options['notification'] = array( 0 => $form_options );
1108
-        } else if ( isset( $form_options['notification']['email_to'] ) ) {
1109
-            // make sure it's in the correct format
1108
+		} else if ( isset( $form_options['notification']['email_to'] ) ) {
1109
+			// make sure it's in the correct format
1110 1110
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
1111
-        }
1111
+		}
1112 1112
 
1113
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1114
-            foreach ( $form_options['notification'] as $email_key => $notification ) {
1113
+		if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1114
+			foreach ( $form_options['notification'] as $email_key => $notification ) {
1115 1115
 
1116 1116
 				$atts = array(
1117 1117
 					'email_to'  => '',
@@ -1122,119 +1122,119 @@  discard block
 block discarded – undo
1122 1122
 					'email_key' => $email_key,
1123 1123
 				);
1124 1124
 
1125
-                // Format the email data
1126
-                self::format_email_data( $atts, $notification );
1125
+				// Format the email data
1126
+				self::format_email_data( $atts, $notification );
1127 1127
 
1128 1128
 				if ( isset( $notification['twilio'] ) && $notification['twilio'] ) {
1129 1129
 					do_action( 'frm_create_twilio_action', $atts, $notification );
1130 1130
 				}
1131 1131
 
1132
-                // Setup the new notification
1133
-                $new_notification = array();
1134
-                self::setup_new_notification( $new_notification, $notification, $atts );
1132
+				// Setup the new notification
1133
+				$new_notification = array();
1134
+				self::setup_new_notification( $new_notification, $notification, $atts );
1135 1135
 
1136
-                $notifications[] = $new_notification;
1137
-            }
1138
-        }
1139
-    }
1136
+				$notifications[] = $new_notification;
1137
+			}
1138
+		}
1139
+	}
1140 1140
 
1141
-    private static function format_email_data( &$atts, $notification ) {
1142
-        // Format email_to
1143
-        self::format_email_to_data( $atts, $notification );
1141
+	private static function format_email_data( &$atts, $notification ) {
1142
+		// Format email_to
1143
+		self::format_email_to_data( $atts, $notification );
1144 1144
 
1145
-        // Format the reply to email and name
1145
+		// Format the reply to email and name
1146 1146
 		$reply_fields = array(
1147 1147
 			'reply_to'      => '',
1148 1148
 			'reply_to_name' => '',
1149 1149
 		);
1150
-        foreach ( $reply_fields as $f => $val ) {
1150
+		foreach ( $reply_fields as $f => $val ) {
1151 1151
 			if ( isset( $notification[ $f ] ) ) {
1152 1152
 				$atts[ $f ] = $notification[ $f ];
1153 1153
 				if ( 'custom' == $notification[ $f ] ) {
1154 1154
 					$atts[ $f ] = $notification[ 'cust_' . $f ];
1155 1155
 				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
1156 1156
 					$atts[ $f ] = '[' . $atts[ $f ] . ']';
1157
-                }
1158
-            }
1159
-            unset( $f, $val );
1160
-        }
1157
+				}
1158
+			}
1159
+			unset( $f, $val );
1160
+		}
1161 1161
 
1162
-        // Format event
1162
+		// Format event
1163 1163
 		$atts['event'] = array( 'create' );
1164
-        if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1165
-            $atts['event'][] = 'update';
1166
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1164
+		if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1165
+			$atts['event'][] = 'update';
1166
+		} else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1167 1167
 			$atts['event'] = array( 'update' );
1168
-        }
1169
-    }
1168
+		}
1169
+	}
1170 1170
 
1171
-    private static function format_email_to_data( &$atts, $notification ) {
1172
-        if ( isset( $notification['email_to'] ) ) {
1171
+	private static function format_email_to_data( &$atts, $notification ) {
1172
+		if ( isset( $notification['email_to'] ) ) {
1173 1173
 			$atts['email_to'] = preg_split( '/ (,|;) /', $notification['email_to'] );
1174
-        } else {
1175
-            $atts['email_to'] = array();
1176
-        }
1174
+		} else {
1175
+			$atts['email_to'] = array();
1176
+		}
1177 1177
 
1178
-        if ( isset( $notification['also_email_to'] ) ) {
1179
-            $email_fields = (array) $notification['also_email_to'];
1180
-            $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1181
-            unset( $email_fields );
1182
-        }
1178
+		if ( isset( $notification['also_email_to'] ) ) {
1179
+			$email_fields = (array) $notification['also_email_to'];
1180
+			$atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1181
+			unset( $email_fields );
1182
+		}
1183 1183
 
1184
-        foreach ( $atts['email_to'] as $key => $email_field ) {
1184
+		foreach ( $atts['email_to'] as $key => $email_field ) {
1185 1185
 
1186
-            if ( is_numeric( $email_field ) ) {
1186
+			if ( is_numeric( $email_field ) ) {
1187 1187
 				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1188
-            }
1188
+			}
1189 1189
 
1190
-            if ( strpos( $email_field, '|') ) {
1191
-                $email_opt = explode( '|', $email_field );
1192
-                if ( isset( $email_opt[0] ) ) {
1190
+			if ( strpos( $email_field, '|') ) {
1191
+				$email_opt = explode( '|', $email_field );
1192
+				if ( isset( $email_opt[0] ) ) {
1193 1193
 					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1194
-                }
1195
-                unset( $email_opt );
1196
-            }
1197
-        }
1198
-        $atts['email_to'] = implode(', ', $atts['email_to']);
1199
-    }
1200
-
1201
-    private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1202
-        // Set up new notification
1203
-        $new_notification = array(
1204
-            'post_content'  => array(
1205
-                'email_to'      => $atts['email_to'],
1206
-                'event'         => $atts['event'],
1207
-            ),
1194
+				}
1195
+				unset( $email_opt );
1196
+			}
1197
+		}
1198
+		$atts['email_to'] = implode(', ', $atts['email_to']);
1199
+	}
1200
+
1201
+	private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1202
+		// Set up new notification
1203
+		$new_notification = array(
1204
+			'post_content'  => array(
1205
+				'email_to'      => $atts['email_to'],
1206
+				'event'         => $atts['event'],
1207
+			),
1208 1208
 			'post_name'         => $atts['form_id'] . '_email_' . $atts['email_key'],
1209
-        );
1209
+		);
1210 1210
 
1211
-        // Add more fields to the new notification
1212
-        $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1213
-        foreach ( $add_fields as $add_field ) {
1211
+		// Add more fields to the new notification
1212
+		$add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1213
+		foreach ( $add_fields as $add_field ) {
1214 1214
 			if ( isset( $notification[ $add_field ] ) ) {
1215 1215
 				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1216
-            } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1216
+			} else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1217 1217
 				$new_notification['post_content'][ $add_field ] = 0;
1218
-            } else {
1218
+			} else {
1219 1219
 				$new_notification['post_content'][ $add_field ] = '';
1220
-            }
1221
-            unset( $add_field );
1222
-        }
1220
+			}
1221
+			unset( $add_field );
1222
+		}
1223 1223
 
1224 1224
 		// Set reply to
1225 1225
 		$new_notification['post_content']['reply_to'] = $atts['reply_to'];
1226 1226
 
1227
-        // Set from
1227
+		// Set from
1228 1228
 		if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) {
1229 1229
 			$new_notification['post_content']['from'] = ( empty( $atts['reply_to_name'] ) ? '[sitename]' : $atts['reply_to_name'] ) . ' <' . ( empty( $atts['reply_to'] ) ? '[admin_email]' : $atts['reply_to'] ) . '>';
1230
-        }
1231
-    }
1230
+		}
1231
+	}
1232 1232
 
1233 1233
 	/**
1234
-	* Switch field IDs in pre-2.0 email conditional logic
1235
-	*
1236
-	* @param $post_content array, pass by reference
1237
-	*/
1234
+	 * Switch field IDs in pre-2.0 email conditional logic
1235
+	 *
1236
+	 * @param $post_content array, pass by reference
1237
+	 */
1238 1238
 	private static function switch_email_contition_field_ids( &$post_content ) {
1239 1239
 		// Switch field IDs in conditional logic
1240 1240
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
@@ -1247,36 +1247,36 @@  discard block
 block discarded – undo
1247 1247
 		}
1248 1248
 	}
1249 1249
 
1250
-    private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1251
-        if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1252
-            // migrate autoresponder
1253
-
1254
-            $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1255
-            if ( strpos($email_field, '|') ) {
1256
-                // data from entries field
1257
-                $email_field = explode('|', $email_field);
1258
-                if ( isset($email_field[1]) ) {
1259
-                    $email_field = $email_field[1];
1260
-                }
1261
-            }
1262
-            if ( is_numeric($email_field) && ! empty($email_field) ) {
1250
+	private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1251
+		if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1252
+			// migrate autoresponder
1253
+
1254
+			$email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1255
+			if ( strpos($email_field, '|') ) {
1256
+				// data from entries field
1257
+				$email_field = explode('|', $email_field);
1258
+				if ( isset($email_field[1]) ) {
1259
+					$email_field = $email_field[1];
1260
+				}
1261
+			}
1262
+			if ( is_numeric($email_field) && ! empty($email_field) ) {
1263 1263
 				$email_field = '[' . $email_field . ']';
1264
-            }
1265
-
1266
-            $notification = $form_options;
1267
-            $new_notification2 = array(
1268
-                'post_content'  => array(
1269
-                    'email_message' => $notification['ar_email_message'],
1270
-                    'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1271
-                    'email_to'      => $email_field,
1272
-                    'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1273
-                    'inc_user_info' => 0,
1274
-                ),
1264
+			}
1265
+
1266
+			$notification = $form_options;
1267
+			$new_notification2 = array(
1268
+				'post_content'  => array(
1269
+					'email_message' => $notification['ar_email_message'],
1270
+					'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1271
+					'email_to'      => $email_field,
1272
+					'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1273
+					'inc_user_info' => 0,
1274
+				),
1275 1275
 				'post_name'     => $form_id . '_email_' . count( $notifications ),
1276
-            );
1276
+			);
1277 1277
 
1278
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1279
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1278
+			$reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1279
+			$reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1280 1280
 
1281 1281
 			if ( ! empty( $reply_to ) ) {
1282 1282
 				$new_notification2['post_content']['reply_to'] = $reply_to;
@@ -1286,9 +1286,9 @@  discard block
 block discarded – undo
1286 1286
 				$new_notification2['post_content']['from'] = ( empty( $reply_to_name ) ? '[sitename]' : $reply_to_name ) . ' <' . ( empty( $reply_to ) ? '[admin_email]' : $reply_to ) . '>';
1287 1287
 			}
1288 1288
 
1289
-            $notifications[] = $new_notification2;
1290
-            unset( $new_notification2 );
1291
-        }
1292
-    }
1289
+			$notifications[] = $new_notification2;
1290
+			unset( $new_notification2 );
1291
+		}
1292
+	}
1293 1293
 }
1294 1294
 
Please login to merge, or discard this patch.
Spacing   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
 			'terms'    => array(),
41 41
         );
42 42
 
43
-        unset($defaults);
43
+        unset( $defaults );
44 44
 
45 45
 		if ( ! defined( 'WP_IMPORTING' ) ) {
46
-            define('WP_IMPORTING', true);
46
+            define( 'WP_IMPORTING', true );
47 47
         }
48 48
 
49 49
 		if ( ! class_exists( 'DOMDocument' ) ) {
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
57 57
 		}
58 58
 
59
-		if ( ! function_exists('simplexml_import_dom') ) {
59
+		if ( ! function_exists( 'simplexml_import_dom' ) ) {
60 60
 			return new WP_Error( 'SimpleXML_parse_error', __( 'Your server is missing the simplexml_import_dom function', 'formidable' ), libxml_get_errors() );
61 61
 		}
62 62
 
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
         // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
72 72
 		foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
73 73
             // grab cats, tags, and terms, or forms or posts
74
-            if ( isset($xml->{$item_type} ) ) {
74
+            if ( isset( $xml->{$item_type} ) ) {
75 75
 				$function_name = 'import_xml_' . $item_type . 's';
76 76
 				$imported = self::$function_name( $xml->{$item_type}, $imported );
77 77
 				unset( $function_name, $xml->{$item_type} );
78 78
             }
79 79
         }
80 80
 
81
-	    $return = apply_filters('frm_importing_xml', $imported, $xml );
81
+	    $return = apply_filters( 'frm_importing_xml', $imported, $xml );
82 82
 
83 83
 	    return $return;
84 84
     }
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
                 'slug'          => (string) $t->term_slug,
96 96
                 'description'   => (string) $t->term_description,
97 97
 				'parent'        => empty( $parent ) ? 0 : $parent,
98
-            ));
98
+            ) );
99 99
 
100 100
 			if ( $term && is_array( $term ) ) {
101
-                $imported['imported']['terms']++;
102
-				$imported['terms'][ (int) $t->term_id ] = $term['term_id'];
101
+                $imported['imported']['terms'] ++;
102
+				$imported['terms'][(int) $t->term_id] = $term['term_id'];
103 103
             }
104 104
 
105 105
 			unset( $term, $t );
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
 			} else {
149 149
 				$form_id = FrmForm::create( $form );
150 150
 		        if ( $form_id ) {
151
-		            $imported['imported']['forms']++;
151
+		            $imported['imported']['forms'] ++;
152 152
 		            // Keep track of whether this specific form was updated or not
153
-					$imported['form_status'][ $form_id ] = 'imported';
153
+					$imported['form_status'][$form_id] = 'imported';
154 154
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
155 155
 		        }
156 156
 			}
@@ -162,14 +162,14 @@  discard block
 block discarded – undo
162 162
 		    // Update field ids/keys to new ones
163 163
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
164 164
 
165
-			$imported['forms'][ (int) $item->id ] = $form_id;
165
+			$imported['forms'][(int) $item->id] = $form_id;
166 166
 
167 167
             // Send pre 2.0 form options through function that creates actions
168 168
             self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true );
169 169
 
170 170
 			do_action( 'frm_after_import_form', $form_id, $form );
171 171
 
172
-		    unset($form, $item);
172
+		    unset( $form, $item );
173 173
 		}
174 174
 
175 175
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
@@ -214,18 +214,18 @@  discard block
 block discarded – undo
214 214
 	private static function update_form( $this_form, $form, &$imported ) {
215 215
 		$form_id = $this_form->id;
216 216
 		FrmForm::update( $form_id, $form );
217
-		$imported['updated']['forms']++;
217
+		$imported['updated']['forms'] ++;
218 218
 		// Keep track of whether this specific form was updated or not
219
-		$imported['form_status'][ $form_id ] = 'updated';
219
+		$imported['form_status'][$form_id] = 'updated';
220 220
 	}
221 221
 
222 222
 	private static function get_form_fields( $form_id ) {
223 223
 		$form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' );
224 224
 		$old_fields = array();
225 225
 		foreach ( $form_fields as $f ) {
226
-			$old_fields[ $f->id ] = $f;
227
-			$old_fields[ $f->field_key ] = $f->id;
228
-			unset($f);
226
+			$old_fields[$f->id] = $f;
227
+			$old_fields[$f->field_key] = $f->id;
228
+			unset( $f );
229 229
 		}
230 230
 		$form_fields = $old_fields;
231 231
 		return $form_fields;
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 		$regular_forms = array();
257 257
 
258 258
 		foreach ( $forms as $form ) {
259
-			$parent_form_id = isset( $form->parent_form_id) ? (int) $form->parent_form_id : 0;
259
+			$parent_form_id = isset( $form->parent_form_id ) ? (int) $form->parent_form_id : 0;
260 260
 
261 261
 			if ( $parent_form_id ) {
262 262
 				$child_forms[] = $form;
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	*/
279 279
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
280 280
 		if ( $parent_form_id ) {
281
-			$child_forms[ $form_id ] = $parent_form_id;
281
+			$child_forms[$form_id] = $parent_form_id;
282 282
 		}
283 283
 	}
284 284
 
@@ -293,9 +293,9 @@  discard block
 block discarded – undo
293 293
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
294 294
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
295 295
 
296
-			if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) {
296
+			if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) {
297 297
 				// Update all children with this old parent_form_id
298
-				$new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ];
298
+				$new_parent_form_id = (int) $imported_forms[$old_parent_form_id];
299 299
 
300 300
 				FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) );
301 301
 			}
@@ -327,27 +327,27 @@  discard block
 block discarded – undo
327 327
 			self::maybe_update_form_select( $f, $imported );
328 328
 			self::maybe_update_get_values_form_setting( $imported, $f );
329 329
 
330
-			if ( ! empty($this_form) ) {
330
+			if ( ! empty( $this_form ) ) {
331 331
 				// check for field to edit by field id
332
-				if ( isset( $form_fields[ $f['id'] ] ) ) {
332
+				if ( isset( $form_fields[$f['id']] ) ) {
333 333
 					FrmField::update( $f['id'], $f );
334
-					$imported['updated']['fields']++;
334
+					$imported['updated']['fields'] ++;
335 335
 
336
-					unset( $form_fields[ $f['id'] ] );
336
+					unset( $form_fields[$f['id']] );
337 337
 
338 338
 					//unset old field key
339
-					if ( isset( $form_fields[ $f['field_key'] ] ) ) {
340
-						unset( $form_fields[ $f['field_key'] ] );
339
+					if ( isset( $form_fields[$f['field_key']] ) ) {
340
+						unset( $form_fields[$f['field_key']] );
341 341
 					}
342
-				} else if ( isset( $form_fields[ $f['field_key'] ] ) ) {
342
+				} else if ( isset( $form_fields[$f['field_key']] ) ) {
343 343
 					// check for field to edit by field key
344
-					unset($f['id']);
344
+					unset( $f['id'] );
345 345
 
346
-					FrmField::update( $form_fields[ $f['field_key'] ], $f );
347
-					$imported['updated']['fields']++;
346
+					FrmField::update( $form_fields[$f['field_key']], $f );
347
+					$imported['updated']['fields'] ++;
348 348
 
349
-					unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id
350
-					unset( $form_fields[ $f['field_key'] ] ); //unset old field key
349
+					unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id
350
+					unset( $form_fields[$f['field_key']] ); //unset old field key
351 351
 				} else {
352 352
 					// if no matching field id or key in this form, create the field
353 353
 					self::create_imported_field( $f, $imported );
@@ -366,11 +366,11 @@  discard block
 block discarded – undo
366 366
 			'name'          => (string) $field->name,
367 367
 			'description'   => (string) $field->description,
368 368
 			'type'          => (string) $field->type,
369
-			'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
369
+			'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value ),
370 370
 			'field_order'   => (int) $field->field_order,
371 371
 			'form_id'       => (int) $form_id,
372 372
 			'required'      => (int) $field->required,
373
-			'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
373
+			'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options ),
374 374
 			'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
375 375
 		);
376 376
 	}
@@ -414,8 +414,8 @@  discard block
 block discarded – undo
414 414
 		if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) {
415 415
 			if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) {
416 416
 				$form_select = (int) $f['field_options']['form_select'];
417
-				if ( isset( $imported['forms'][ $form_select ] ) ) {
418
-					$f['field_options']['form_select'] = $imported['forms'][ $form_select ];
417
+				if ( isset( $imported['forms'][$form_select] ) ) {
418
+					$f['field_options']['form_select'] = $imported['forms'][$form_select];
419 419
 				}
420 420
 			}
421 421
 		}
@@ -435,8 +435,8 @@  discard block
 block discarded – undo
435 435
 
436 436
 		if ( FrmField::is_option_true_in_array( $f['field_options'], 'get_values_form' ) ) {
437 437
 			$old_form = $f['field_options']['get_values_form'];
438
-			if ( isset( $imported['forms'][ $old_form ] ) ) {
439
-				$f['field_options']['get_values_form'] = $imported['forms'][ $old_form ];
438
+			if ( isset( $imported['forms'][$old_form] ) ) {
439
+				$f['field_options']['get_values_form'] = $imported['forms'][$old_form];
440 440
 			}
441 441
 		}
442 442
 	}
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 	private static function create_imported_field( $f, &$imported ) {
452 452
 		$new_id = FrmField::create( $f );
453 453
 		if ( $new_id != false ) {
454
-			$imported['imported']['fields']++;
454
+			$imported['imported']['fields'] ++;
455 455
 			do_action( 'frm_after_field_is_imported', $f, $new_id );
456 456
 		}
457 457
 	}
@@ -550,9 +550,9 @@  discard block
 block discarded – undo
550 550
 			);
551 551
 
552 552
             $old_id = $post['post_id'];
553
-            self::populate_post($post, $item, $imported);
553
+            self::populate_post( $post, $item, $imported );
554 554
 
555
-			unset($item);
555
+			unset( $item );
556 556
 
557 557
 			$post_id = false;
558 558
             if ( $post['post_type'] == $form_action_type ) {
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 				if ( $action_control && is_object( $action_control ) ) {
561 561
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
562 562
 				}
563
-                unset($action_control);
563
+                unset( $action_control );
564 564
             } else if ( $post['post_type'] == 'frm_styles' ) {
565 565
                 // Properly encode post content before inserting the post
566 566
                 $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
@@ -575,24 +575,24 @@  discard block
 block discarded – undo
575 575
                 $post_id = wp_insert_post( $post );
576 576
             }
577 577
 
578
-            if ( ! is_numeric($post_id) ) {
578
+            if ( ! is_numeric( $post_id ) ) {
579 579
                 continue;
580 580
             }
581 581
 
582
-            self::update_postmeta($post, $post_id);
582
+            self::update_postmeta( $post, $post_id );
583 583
 
584 584
             $this_type = 'posts';
585
-			if ( isset( $post_types[ $post['post_type'] ] ) ) {
586
-				$this_type = $post_types[ $post['post_type'] ];
585
+			if ( isset( $post_types[$post['post_type']] ) ) {
586
+				$this_type = $post_types[$post['post_type']];
587 587
             }
588 588
 
589
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
590
-                $imported['updated'][ $this_type ]++;
589
+            if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) {
590
+                $imported['updated'][$this_type] ++;
591 591
             } else {
592
-                $imported['imported'][ $this_type ]++;
592
+                $imported['imported'][$this_type] ++;
593 593
             }
594 594
 
595
-			$imported['posts'][ (int) $old_id ] = $post_id;
595
+			$imported['posts'][(int) $old_id] = $post_id;
596 596
 
597 597
 			do_action( 'frm_after_import_view', $post_id, $post );
598 598
 
@@ -605,13 +605,13 @@  discard block
 block discarded – undo
605 605
     }
606 606
 
607 607
     private static function populate_post( &$post, $item, $imported ) {
608
-		if ( isset($item->attachment_url) ) {
608
+		if ( isset( $item->attachment_url ) ) {
609 609
 			$post['attachment_url'] = (string) $item->attachment_url;
610 610
 		}
611 611
 
612
-		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
612
+		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) {
613 613
 		    // update to new form id
614
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
614
+		    $post['menu_order'] = $imported['forms'][(int) $post['menu_order']];
615 615
 		}
616 616
 
617 617
 		// Don't allow default styles to take over a site's default style
@@ -620,13 +620,13 @@  discard block
 block discarded – undo
620 620
 		}
621 621
 
622 622
 		foreach ( $item->postmeta as $meta ) {
623
-		    self::populate_postmeta($post, $meta, $imported);
624
-			unset($meta);
623
+		    self::populate_postmeta( $post, $meta, $imported );
624
+			unset( $meta );
625 625
 		}
626 626
 
627
-        self::populate_taxonomies($post, $item);
627
+        self::populate_taxonomies( $post, $item );
628 628
 
629
-        self::maybe_editing_post($post);
629
+        self::maybe_editing_post( $post );
630 630
     }
631 631
 
632 632
     private static function populate_postmeta( &$post, $meta, $imported ) {
@@ -638,27 +638,27 @@  discard block
 block discarded – undo
638 638
 		);
639 639
 
640 640
 		//switch old form and field ids to new ones
641
-		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
642
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
641
+		if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) {
642
+		    $m['value'] = $imported['forms'][(int) $m['value']];
643 643
 		} else {
644
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
644
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
645 645
 
646
-		    if ( ! empty($frm_duplicate_ids) ) {
646
+		    if ( ! empty( $frm_duplicate_ids ) ) {
647 647
 
648 648
 		        if ( $m['key'] == 'frm_dyncontent' ) {
649
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
649
+		            $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] );
650 650
     		    } else if ( $m['key'] == 'frm_options' ) {
651 651
 
652 652
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
653
-						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
654
-							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
653
+						if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) {
654
+							$m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]];
655 655
     		            }
656 656
     		        }
657 657
 
658 658
                     $check_dup_array = array();
659 659
     		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
660
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
661
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
660
+    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) {
661
+    		                $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']];
662 662
     		            } else if ( is_array( $m['value']['order_by'] ) ) {
663 663
                             $check_dup_array[] = 'order_by';
664 664
     		            }
@@ -669,22 +669,22 @@  discard block
 block discarded – undo
669 669
     		        }
670 670
 
671 671
                     foreach ( $check_dup_array as $check_k ) {
672
-						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
673
-							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
674
-								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
672
+						foreach ( (array) $m['value'][$check_k] as $mk => $mv ) {
673
+							if ( isset( $frm_duplicate_ids[$mv] ) ) {
674
+								$m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv];
675 675
 		                    }
676
-		                    unset($mk, $mv);
676
+		                    unset( $mk, $mv );
677 677
 		                }
678 678
                     }
679 679
     		    }
680 680
 		    }
681 681
 		}
682 682
 
683
-		if ( ! is_array($m['value']) ) {
684
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
683
+		if ( ! is_array( $m['value'] ) ) {
684
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
685 685
 		}
686 686
 
687
-		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
687
+		$post['postmeta'][(string) $meta->meta_key] = $m['value'];
688 688
     }
689 689
 
690 690
     /**
@@ -700,23 +700,23 @@  discard block
 block discarded – undo
700 700
             }
701 701
 
702 702
 		    $taxonomy = (string) $att['domain'];
703
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
703
+		    if ( is_taxonomy_hierarchical( $taxonomy ) ) {
704 704
 		        $name = (string) $att['nicename'];
705
-		        $h_term = get_term_by('slug', $name, $taxonomy);
705
+		        $h_term = get_term_by( 'slug', $name, $taxonomy );
706 706
 		        if ( $h_term ) {
707 707
 		            $name = $h_term->term_id;
708 708
 		        }
709
-		        unset($h_term);
709
+		        unset( $h_term );
710 710
 		    } else {
711 711
 		        $name = (string) $c;
712 712
 		    }
713 713
 
714
-			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
715
-				$post['tax_input'][ $taxonomy ] = array();
714
+			if ( ! isset( $post['tax_input'][$taxonomy] ) ) {
715
+				$post['tax_input'][$taxonomy] = array();
716 716
 			}
717 717
 
718
-			$post['tax_input'][ $taxonomy ][] = $name;
719
-		    unset($name);
718
+			$post['tax_input'][$taxonomy][] = $name;
719
+		    unset( $name );
720 720
 		}
721 721
     }
722 722
 
@@ -733,30 +733,30 @@  discard block
 block discarded – undo
733 733
 
734 734
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
735 735
 		    $match_by['include'] = $post['post_id'];
736
-		    unset($match_by['name']);
736
+		    unset( $match_by['name'] );
737 737
 		}
738 738
 
739
-		$editing = get_posts($match_by);
739
+		$editing = get_posts( $match_by );
740 740
 
741
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
741
+        if ( ! empty( $editing ) && current( $editing )->post_date == $post['post_date'] ) {
742 742
             // set the id of the post to edit
743
-            $post['ID'] = current($editing)->ID;
743
+            $post['ID'] = current( $editing )->ID;
744 744
         }
745 745
     }
746 746
 
747 747
     private static function update_postmeta( &$post, $post_id ) {
748 748
         foreach ( $post['postmeta'] as $k => $v ) {
749 749
             if ( '_edit_last' == $k ) {
750
-                $v = FrmAppHelper::get_user_id_param($v);
750
+                $v = FrmAppHelper::get_user_id_param( $v );
751 751
             } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
752 752
                 //change the attachment ID
753 753
 				$field_obj = FrmFieldFactory::get_field_type( 'file' );
754 754
 				$v = $field_obj->get_file_id( $v );
755 755
             }
756 756
 
757
-            update_post_meta($post_id, $k, $v);
757
+            update_post_meta( $post_id, $k, $v );
758 758
 
759
-            unset($k, $v);
759
+            unset( $k, $v );
760 760
         }
761 761
     }
762 762
 
@@ -795,13 +795,13 @@  discard block
 block discarded – undo
795 795
      * @param string $message
796 796
      */
797 797
 	public static function parse_message( $result, &$message, &$errors ) {
798
-        if ( is_wp_error($result) ) {
798
+        if ( is_wp_error( $result ) ) {
799 799
             $errors[] = $result->get_error_message();
800 800
         } else if ( ! $result ) {
801 801
             return;
802 802
         }
803 803
 
804
-        if ( ! is_array($result) ) {
804
+        if ( ! is_array( $result ) ) {
805 805
             $message = is_string( $result ) ? $result : htmlentities( print_r( $result, 1 ) );
806 806
             return;
807 807
         }
@@ -813,20 +813,20 @@  discard block
 block discarded – undo
813 813
 
814 814
         $message = '<ul>';
815 815
         foreach ( $result as $type => $results ) {
816
-			if ( ! isset( $t_strings[ $type ] ) ) {
816
+			if ( ! isset( $t_strings[$type] ) ) {
817 817
                 // only print imported and updated
818 818
                 continue;
819 819
             }
820 820
 
821 821
             $s_message = array();
822 822
             foreach ( $results as $k => $m ) {
823
-                self::item_count_message($m, $k, $s_message);
824
-                unset($k, $m);
823
+                self::item_count_message( $m, $k, $s_message );
824
+                unset( $k, $m );
825 825
             }
826 826
 
827
-            if ( ! empty($s_message) ) {
828
-				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
829
-                $message .= implode(', ', $s_message);
827
+            if ( ! empty( $s_message ) ) {
828
+				$message .= '<li><strong>' . $t_strings[$type] . ':</strong> ';
829
+                $message .= implode( ', ', $s_message );
830 830
                 $message .= '</li>';
831 831
             }
832 832
         }
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
             'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
856 856
         );
857 857
 
858
-		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
858
+		$s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type );
859 859
     }
860 860
 
861 861
 	/**
@@ -887,14 +887,14 @@  discard block
 block discarded – undo
887 887
 	}
888 888
 
889 889
 	public static function cdata( $str ) {
890
-	    $str = maybe_unserialize($str);
891
-	    if ( is_array($str) ) {
892
-	        $str = json_encode($str);
890
+	    $str = maybe_unserialize( $str );
891
+	    if ( is_array( $str ) ) {
892
+	        $str = json_encode( $str );
893 893
 		} else if ( seems_utf8( $str ) == false ) {
894 894
 			$str = utf8_encode( $str );
895 895
 		}
896 896
 
897
-        if ( is_numeric($str) ) {
897
+        if ( is_numeric( $str ) ) {
898 898
             return $str;
899 899
         }
900 900
 
@@ -939,7 +939,7 @@  discard block
 block discarded – undo
939 939
     * @param string $post_type
940 940
     */
941 941
     private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
942
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
942
+        if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) {
943 943
             return;
944 944
         }
945 945
 
@@ -956,10 +956,10 @@  discard block
 block discarded – undo
956 956
 		$post_settings = array( 'post_type', 'post_category', 'post_content', 'post_excerpt', 'post_title', 'post_name', 'post_date', 'post_status', 'post_custom_fields', 'post_password' );
957 957
 
958 958
         foreach ( $post_settings as $post_setting ) {
959
-			if ( isset( $form_options[ $post_setting ] ) ) {
960
-				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
959
+			if ( isset( $form_options[$post_setting] ) ) {
960
+				$new_action['post_content'][$post_setting] = $form_options[$post_setting];
961 961
             }
962
-            unset($post_setting);
962
+            unset( $post_setting );
963 963
         }
964 964
 
965 965
 		$new_action['event'] = array( 'create', 'update' );
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
 
974 974
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
975 975
         }
976
-        $new_action['post_content'] = json_encode($new_action['post_content']);
976
+        $new_action['post_content'] = json_encode( $new_action['post_content'] );
977 977
 
978 978
         $exists = get_posts( array(
979 979
             'name'          => $new_action['post_name'],
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
         if ( ! $exists ) {
986 986
 			// this isn't an email, but we need to use a class that will always be included
987 987
 			FrmDb::save_json_post( $new_action );
988
-            $imported['imported']['actions']++;
988
+            $imported['imported']['actions'] ++;
989 989
         }
990 990
     }
991 991
 
@@ -1017,11 +1017,11 @@  discard block
 block discarded – undo
1017 1017
         foreach ( $post_content as $key => $setting ) {
1018 1018
             if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
1019 1019
                 // Replace old IDs with new IDs
1020
-				$post_content[ $key ] = str_replace( $old, $new, $setting );
1020
+				$post_content[$key] = str_replace( $old, $new, $setting );
1021 1021
             } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
1022 1022
                 foreach ( $setting as $k => $val ) {
1023 1023
                     // Replace old IDs with new IDs
1024
-					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
1024
+					$post_content[$key][$k] = str_replace( $old, $new, $val );
1025 1025
                 }
1026 1026
             }
1027 1027
             unset( $key, $setting );
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
         foreach ( $notifications as $new_notification ) {
1052 1052
             $new_notification['post_type']      = $post_type;
1053 1053
             $new_notification['post_excerpt']   = 'email';
1054
-			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
1054
+			$new_notification['post_title'] = __( 'Email Notification', 'formidable' );
1055 1055
             $new_notification['menu_order']     = $form_id;
1056 1056
             $new_notification['post_status']    = 'publish';
1057 1057
 
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
 				// Switch all other field IDs in email
1065 1065
                 $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1066 1066
             }
1067
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1067
+            $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1068 1068
 
1069 1069
             $exists = get_posts( array(
1070 1070
                 'name'          => $new_notification['post_name'],
@@ -1073,11 +1073,11 @@  discard block
 block discarded – undo
1073 1073
                 'numberposts'   => 1,
1074 1074
             ) );
1075 1075
 
1076
-            if ( empty($exists) ) {
1076
+            if ( empty( $exists ) ) {
1077 1077
 				FrmDb::save_json_post( $new_notification );
1078
-                $imported['imported']['actions']++;
1078
+                $imported['imported']['actions'] ++;
1079 1079
             }
1080
-            unset($new_notification);
1080
+            unset( $new_notification );
1081 1081
         }
1082 1082
 
1083 1083
 		self::remove_deprecated_notification_settings( $form_id, $form_options );
@@ -1094,8 +1094,8 @@  discard block
 block discarded – undo
1094 1094
 	private static function remove_deprecated_notification_settings( $form_id, $form_options ) {
1095 1095
 		$delete_settings = array( 'notification', 'autoresponder', 'email_to' );
1096 1096
 		foreach ( $delete_settings as $index ) {
1097
-			if ( isset( $form_options[ $index ] ) ) {
1098
-				unset( $form_options[ $index ] );
1097
+			if ( isset( $form_options[$index] ) ) {
1098
+				unset( $form_options[$index] );
1099 1099
 			}
1100 1100
 		}
1101 1101
 		FrmForm::update( $form_id, array( 'options' => $form_options ) );
@@ -1110,7 +1110,7 @@  discard block
 block discarded – undo
1110 1110
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
1111 1111
         }
1112 1112
 
1113
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1113
+        if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) {
1114 1114
             foreach ( $form_options['notification'] as $email_key => $notification ) {
1115 1115
 
1116 1116
 				$atts = array(
@@ -1148,12 +1148,12 @@  discard block
 block discarded – undo
1148 1148
 			'reply_to_name' => '',
1149 1149
 		);
1150 1150
         foreach ( $reply_fields as $f => $val ) {
1151
-			if ( isset( $notification[ $f ] ) ) {
1152
-				$atts[ $f ] = $notification[ $f ];
1153
-				if ( 'custom' == $notification[ $f ] ) {
1154
-					$atts[ $f ] = $notification[ 'cust_' . $f ];
1155
-				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
1156
-					$atts[ $f ] = '[' . $atts[ $f ] . ']';
1151
+			if ( isset( $notification[$f] ) ) {
1152
+				$atts[$f] = $notification[$f];
1153
+				if ( 'custom' == $notification[$f] ) {
1154
+					$atts[$f] = $notification['cust_' . $f];
1155
+				} else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) {
1156
+					$atts[$f] = '[' . $atts[$f] . ']';
1157 1157
                 }
1158 1158
             }
1159 1159
             unset( $f, $val );
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
 		$atts['event'] = array( 'create' );
1164 1164
         if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1165 1165
             $atts['event'][] = 'update';
1166
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1166
+        } else if ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) {
1167 1167
 			$atts['event'] = array( 'update' );
1168 1168
         }
1169 1169
     }
@@ -1184,18 +1184,18 @@  discard block
 block discarded – undo
1184 1184
         foreach ( $atts['email_to'] as $key => $email_field ) {
1185 1185
 
1186 1186
             if ( is_numeric( $email_field ) ) {
1187
-				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1187
+				$atts['email_to'][$key] = '[' . $email_field . ']';
1188 1188
             }
1189 1189
 
1190
-            if ( strpos( $email_field, '|') ) {
1190
+            if ( strpos( $email_field, '|' ) ) {
1191 1191
                 $email_opt = explode( '|', $email_field );
1192 1192
                 if ( isset( $email_opt[0] ) ) {
1193
-					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1193
+					$atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1194 1194
                 }
1195 1195
                 unset( $email_opt );
1196 1196
             }
1197 1197
         }
1198
-        $atts['email_to'] = implode(', ', $atts['email_to']);
1198
+        $atts['email_to'] = implode( ', ', $atts['email_to'] );
1199 1199
     }
1200 1200
 
1201 1201
     private static function setup_new_notification( &$new_notification, $notification, $atts ) {
@@ -1211,12 +1211,12 @@  discard block
 block discarded – undo
1211 1211
         // Add more fields to the new notification
1212 1212
         $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1213 1213
         foreach ( $add_fields as $add_field ) {
1214
-			if ( isset( $notification[ $add_field ] ) ) {
1215
-				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1214
+			if ( isset( $notification[$add_field] ) ) {
1215
+				$new_notification['post_content'][$add_field] = $notification[$add_field];
1216 1216
             } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1217
-				$new_notification['post_content'][ $add_field ] = 0;
1217
+				$new_notification['post_content'][$add_field] = 0;
1218 1218
             } else {
1219
-				$new_notification['post_content'][ $add_field ] = '';
1219
+				$new_notification['post_content'][$add_field] = '';
1220 1220
             }
1221 1221
             unset( $add_field );
1222 1222
         }
@@ -1240,26 +1240,26 @@  discard block
 block discarded – undo
1240 1240
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
1241 1241
 			foreach ( $post_content['conditions'] as $email_key => $val ) {
1242 1242
 				if ( is_numeric( $email_key ) ) {
1243
-					$post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1243
+					$post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1244 1244
 				}
1245
-				unset( $email_key, $val);
1245
+				unset( $email_key, $val );
1246 1246
 			}
1247 1247
 		}
1248 1248
 	}
1249 1249
 
1250 1250
     private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1251
-        if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1251
+        if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) {
1252 1252
             // migrate autoresponder
1253 1253
 
1254
-            $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1255
-            if ( strpos($email_field, '|') ) {
1254
+            $email_field = isset( $form_options['ar_email_to'] ) ? $form_options['ar_email_to'] : 0;
1255
+            if ( strpos( $email_field, '|' ) ) {
1256 1256
                 // data from entries field
1257
-                $email_field = explode('|', $email_field);
1258
-                if ( isset($email_field[1]) ) {
1257
+                $email_field = explode( '|', $email_field );
1258
+                if ( isset( $email_field[1] ) ) {
1259 1259
                     $email_field = $email_field[1];
1260 1260
                 }
1261 1261
             }
1262
-            if ( is_numeric($email_field) && ! empty($email_field) ) {
1262
+            if ( is_numeric( $email_field ) && ! empty( $email_field ) ) {
1263 1263
 				$email_field = '[' . $email_field . ']';
1264 1264
             }
1265 1265
 
@@ -1267,16 +1267,16 @@  discard block
 block discarded – undo
1267 1267
             $new_notification2 = array(
1268 1268
                 'post_content'  => array(
1269 1269
                     'email_message' => $notification['ar_email_message'],
1270
-                    'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1270
+                    'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '',
1271 1271
                     'email_to'      => $email_field,
1272
-                    'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1272
+                    'plain_text'    => isset( $notification['ar_plain_text'] ) ? $notification['ar_plain_text'] : 0,
1273 1273
                     'inc_user_info' => 0,
1274 1274
                 ),
1275 1275
 				'post_name'     => $form_id . '_email_' . count( $notifications ),
1276 1276
             );
1277 1277
 
1278
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1279
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1278
+            $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : '';
1279
+            $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : '';
1280 1280
 
1281 1281
 			if ( ! empty( $reply_to ) ) {
1282 1282
 				$new_notification2['post_content']['reply_to'] = $reply_to;
Please login to merge, or discard this patch.