Completed
Push — master ( 03847b...1411e8 )
by Jamie
02:40
created
classes/models/FrmEntryShortcodeFormatter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -285,7 +285,7 @@
 block discarded – undo
285 285
 			'type'  => $field->type,
286 286
 		);
287 287
 
288
-		$this->array_content[ $field->id ] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $array, $field );
288
+		$this->array_content[$field->id] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $array, $field );
289 289
 	}
290 290
 
291 291
 	/**
Please login to merge, or discard this patch.
classes/helpers/FrmXMLHelper.php 2 patches
Indentation   +505 added lines, -505 removed lines patch added patch discarded remove patch
@@ -23,30 +23,30 @@  discard block
 block discarded – undo
23 23
 	}
24 24
 
25 25
 	public static function import_xml( $file ) {
26
-        $defaults = array(
27
-            'forms' => 0, 'fields' => 0, 'terms' => 0,
28
-            'posts' => 0, 'views' => 0, 'actions' => 0,
29
-            'styles' => 0,
30
-        );
31
-
32
-        $imported = array(
33
-            'imported' => $defaults,
26
+		$defaults = array(
27
+			'forms' => 0, 'fields' => 0, 'terms' => 0,
28
+			'posts' => 0, 'views' => 0, 'actions' => 0,
29
+			'styles' => 0,
30
+		);
31
+
32
+		$imported = array(
33
+			'imported' => $defaults,
34 34
 			'updated'  => $defaults,
35 35
 			'forms'    => array(),
36 36
 			'terms'    => array(),
37
-        );
37
+		);
38 38
 
39
-        unset($defaults);
39
+		unset($defaults);
40 40
 
41 41
 		if ( ! defined( 'WP_IMPORTING' ) ) {
42
-            define('WP_IMPORTING', true);
43
-        }
42
+			define('WP_IMPORTING', true);
43
+		}
44 44
 
45 45
 		if ( ! class_exists( 'DOMDocument' ) ) {
46
-            return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
47
-        }
46
+			return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
47
+		}
48 48
 
49
-        $dom = new DOMDocument;
49
+		$dom = new DOMDocument;
50 50
 		$success = $dom->loadXML( file_get_contents( $file ) );
51 51
 		if ( ! $success ) {
52 52
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
@@ -64,45 +64,45 @@  discard block
 block discarded – undo
64 64
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
65 65
 		}
66 66
 
67
-        // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
67
+		// add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
68 68
 		foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
69
-            // grab cats, tags, and terms, or forms or posts
70
-            if ( isset($xml->{$item_type} ) ) {
69
+			// grab cats, tags, and terms, or forms or posts
70
+			if ( isset($xml->{$item_type} ) ) {
71 71
 				$function_name = 'import_xml_' . $item_type . 's';
72 72
 				$imported = self::$function_name( $xml->{$item_type}, $imported );
73 73
 				unset( $function_name, $xml->{$item_type} );
74
-            }
75
-        }
74
+			}
75
+		}
76 76
 
77
-	    $return = apply_filters('frm_importing_xml', $imported, $xml );
77
+		$return = apply_filters('frm_importing_xml', $imported, $xml );
78 78
 
79
-	    return $return;
80
-    }
79
+		return $return;
80
+	}
81 81
 
82 82
 	public static function import_xml_terms( $terms, $imported ) {
83
-        foreach ( $terms as $t ) {
83
+		foreach ( $terms as $t ) {
84 84
 			if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) {
85
-			    continue;
85
+				continue;
86 86
 			}
87 87
 
88 88
 			$parent = self::get_term_parent_id( $t );
89 89
 
90 90
 			$term = wp_insert_term( (string) $t->term_name, (string) $t->term_taxonomy, array(
91
-                'slug'          => (string) $t->term_slug,
92
-                'description'   => (string) $t->term_description,
91
+				'slug'          => (string) $t->term_slug,
92
+				'description'   => (string) $t->term_description,
93 93
 				'parent'        => empty( $parent ) ? 0 : $parent,
94
-            ));
94
+			));
95 95
 
96 96
 			if ( $term && is_array( $term ) ) {
97
-                $imported['imported']['terms']++;
97
+				$imported['imported']['terms']++;
98 98
 				$imported['terms'][ (int) $t->term_id ] = $term['term_id'];
99
-            }
99
+			}
100 100
 
101 101
 			unset( $term, $t );
102 102
 		}
103 103
 
104 104
 		return $imported;
105
-    }
105
+	}
106 106
 
107 107
 	/**
108 108
 	 * @since 2.0.8
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
 		self::put_child_forms_first( $forms );
128 128
 
129 129
 		foreach ( $forms as $item ) {
130
-            $form = self::fill_form( $item );
130
+			$form = self::fill_form( $item );
131 131
 
132 132
 			self::update_custom_style_setting_on_import( $form );
133 133
 
134
-	        $this_form = self::maybe_get_form( $form );
134
+			$this_form = self::maybe_get_form( $form );
135 135
 
136 136
 			$old_id = false;
137 137
 			$form_fields = false;
@@ -143,35 +143,35 @@  discard block
 block discarded – undo
143 143
 				$form_fields = self::get_form_fields( $form_id );
144 144
 			} else {
145 145
 				$form_id = FrmForm::create( $form );
146
-		        if ( $form_id ) {
147
-		            $imported['imported']['forms']++;
148
-		            // Keep track of whether this specific form was updated or not
146
+				if ( $form_id ) {
147
+					$imported['imported']['forms']++;
148
+					// Keep track of whether this specific form was updated or not
149 149
 					$imported['form_status'][ $form_id ] = 'imported';
150 150
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
151
-		        }
151
+				}
152 152
 			}
153 153
 
154 154
 			self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported );
155 155
 
156 156
 			self::delete_removed_fields( $form_fields );
157 157
 
158
-		    // Update field ids/keys to new ones
158
+			// Update field ids/keys to new ones
159 159
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
160 160
 
161 161
 			$imported['forms'][ (int) $item->id ] = $form_id;
162 162
 
163
-            // Send pre 2.0 form options through function that creates actions
164
-            self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true );
163
+			// Send pre 2.0 form options through function that creates actions
164
+			self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true );
165 165
 
166 166
 			do_action( 'frm_after_import_form', $form_id, $form );
167 167
 
168
-		    unset($form, $item);
168
+			unset($form, $item);
169 169
 		}
170 170
 
171 171
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
172 172
 
173 173
 		return $imported;
174
-    }
174
+	}
175 175
 
176 176
 	private static function fill_form( $item ) {
177 177
 		$form = array(
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
 	}
240 240
 
241 241
 	/**
242
-	* Put child forms first so they will be imported before parents
243
-	*
244
-	* @since 2.0.16
245
-	* @param array $forms
246
-	*/
242
+	 * Put child forms first so they will be imported before parents
243
+	 *
244
+	 * @since 2.0.16
245
+	 * @param array $forms
246
+	 */
247 247
 	private static function put_child_forms_first( &$forms ) {
248 248
 		$child_forms = array();
249 249
 		$regular_forms = array();
@@ -262,13 +262,13 @@  discard block
 block discarded – undo
262 262
 	}
263 263
 
264 264
 	/**
265
-	* Keep track of all imported child forms
266
-	*
267
-	* @since 2.0.16
268
-	* @param int $form_id
269
-	* @param int $parent_form_id
270
-	* @param array $child_forms
271
-	*/
265
+	 * Keep track of all imported child forms
266
+	 *
267
+	 * @since 2.0.16
268
+	 * @param int $form_id
269
+	 * @param int $parent_form_id
270
+	 * @param array $child_forms
271
+	 */
272 272
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
273 273
 		if ( $parent_form_id ) {
274 274
 			$child_forms[ $form_id ] = $parent_form_id;
@@ -276,13 +276,13 @@  discard block
 block discarded – undo
276 276
 	}
277 277
 
278 278
 	/**
279
-	* Update the parent_form_id on imported child forms
280
-	* Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
281
-	*
282
-	* @since 2.0.6
283
-	* @param array $imported_forms
284
-	* @param array $child_forms
285
-	*/
279
+	 * Update the parent_form_id on imported child forms
280
+	 * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
281
+	 *
282
+	 * @since 2.0.6
283
+	 * @param array $imported_forms
284
+	 * @param array $child_forms
285
+	 */
286 286
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
287 287
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
288 288
 
@@ -296,28 +296,28 @@  discard block
 block discarded – undo
296 296
 	}
297 297
 
298 298
 	/**
299
-	* Import all fields for a form
300
-	* @since 2.0.13
301
-	*
302
-	* TODO: Cut down on params
303
-	*/
299
+	 * Import all fields for a form
300
+	 * @since 2.0.13
301
+	 *
302
+	 * TODO: Cut down on params
303
+	 */
304 304
 	private static function import_xml_fields( $xml_fields, $form_id, $this_form, &$form_fields, &$imported ) {
305 305
 		$in_section = 0;
306 306
 
307 307
 		foreach ( $xml_fields as $field ) {
308 308
 			$f = self::fill_field( $field, $form_id );
309 309
 
310
-		    if ( is_array($f['default_value']) && in_array($f['type'], array(
311
-		        'text', 'email', 'url', 'textarea',
312
-		        'number','phone', 'date',
313
-		        'hidden', 'password', 'tag', 'image',
314
-		    )) ) {
315
-		        if ( count($f['default_value']) === 1 ) {
310
+			if ( is_array($f['default_value']) && in_array($f['type'], array(
311
+				'text', 'email', 'url', 'textarea',
312
+				'number','phone', 'date',
313
+				'hidden', 'password', 'tag', 'image',
314
+			)) ) {
315
+				if ( count($f['default_value']) === 1 ) {
316 316
 					$f['default_value'] = '[' . reset( $f['default_value'] ) . ']';
317
-		        } else {
318
-		            $f['default_value'] = reset($f['default_value']);
319
-		        }
320
-		    }
317
+				} else {
318
+					$f['default_value'] = reset($f['default_value']);
319
+				}
320
+			}
321 321
 
322 322
 			self::maybe_update_in_section_variable( $in_section, $f );
323 323
 			self::maybe_update_form_select( $f, $imported );
@@ -396,12 +396,12 @@  discard block
 block discarded – undo
396 396
 	}
397 397
 
398 398
 	/**
399
-	* Switch the form_select on a repeating field or embedded form if it needs to be switched
400
-	*
401
-	* @since 2.0.16
402
-	* @param array $f
403
-	* @param array $imported
404
-	*/
399
+	 * Switch the form_select on a repeating field or embedded form if it needs to be switched
400
+	 *
401
+	 * @since 2.0.16
402
+	 * @param array $f
403
+	 * @param array $imported
404
+	 */
405 405
 	private static function maybe_update_form_select( &$f, $imported ) {
406 406
 		if ( ! isset( $imported['forms'] ) ) {
407 407
 			return;
@@ -453,13 +453,13 @@  discard block
 block discarded – undo
453 453
 	}
454 454
 
455 455
 	/**
456
-	* Updates the custom style setting on import
457
-	* Convert the post slug to an ID
458
-	*
459
-	* @since 2.0.19
460
-	* @param array $form
461
-	*
462
-	*/
456
+	 * Updates the custom style setting on import
457
+	 * Convert the post slug to an ID
458
+	 *
459
+	 * @since 2.0.19
460
+	 * @param array $form
461
+	 *
462
+	 */
463 463
 	private static function update_custom_style_setting_on_import( &$form ) {
464 464
 		if ( ! isset( $form['options']['custom_style'] ) ) {
465 465
 			return;
@@ -513,16 +513,16 @@  discard block
 block discarded – undo
513 513
 	}
514 514
 
515 515
 	public static function import_xml_views( $views, $imported ) {
516
-        $imported['posts'] = array();
517
-        $form_action_type = FrmFormActionsController::$action_post_type;
516
+		$imported['posts'] = array();
517
+		$form_action_type = FrmFormActionsController::$action_post_type;
518 518
 
519
-        $post_types = array(
520
-            'frm_display' => 'views',
521
-            $form_action_type => 'actions',
522
-            'frm_styles'    => 'styles',
523
-        );
519
+		$post_types = array(
520
+			'frm_display' => 'views',
521
+			$form_action_type => 'actions',
522
+			'frm_styles'    => 'styles',
523
+		);
524 524
 
525
-        foreach ( $views as $item ) {
525
+		foreach ( $views as $item ) {
526 526
 			$post = array(
527 527
 				'post_title'    => (string) $item->title,
528 528
 				'post_name'     => (string) $item->post_name,
@@ -541,52 +541,52 @@  discard block
 block discarded – undo
541 541
 				'post_date'     => (string) $item->post_date,
542 542
 				'post_date_gmt' => (string) $item->post_date_gmt,
543 543
 				'ping_status'   => (string) $item->ping_status,
544
-                'postmeta'      => array(),
545
-                'tax_input'     => array(),
544
+				'postmeta'      => array(),
545
+				'tax_input'     => array(),
546 546
 			);
547 547
 
548
-            $old_id = $post['post_id'];
549
-            self::populate_post($post, $item, $imported);
548
+			$old_id = $post['post_id'];
549
+			self::populate_post($post, $item, $imported);
550 550
 
551 551
 			unset($item);
552 552
 
553 553
 			$post_id = false;
554
-            if ( $post['post_type'] == $form_action_type ) {
555
-                $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
554
+			if ( $post['post_type'] == $form_action_type ) {
555
+				$action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
556 556
 				if ( $action_control && is_object( $action_control ) ) {
557 557
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
558 558
 				}
559
-                unset($action_control);
560
-            } else if ( $post['post_type'] == 'frm_styles' ) {
561
-                // Properly encode post content before inserting the post
562
-                $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
559
+				unset($action_control);
560
+			} else if ( $post['post_type'] == 'frm_styles' ) {
561
+				// Properly encode post content before inserting the post
562
+				$post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
563 563
 				$custom_css = isset( $post['post_content']['custom_css'] ) ? $post['post_content']['custom_css'] : '';
564
-                $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
564
+				$post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
565 565
 
566
-                // Create/update post now
567
-                $post_id = wp_insert_post( $post );
566
+				// Create/update post now
567
+				$post_id = wp_insert_post( $post );
568 568
 				self::maybe_update_custom_css( $custom_css );
569
-            } else {
570
-                // Create/update post now
571
-                $post_id = wp_insert_post( $post );
572
-            }
569
+			} else {
570
+				// Create/update post now
571
+				$post_id = wp_insert_post( $post );
572
+			}
573 573
 
574
-            if ( ! is_numeric($post_id) ) {
575
-                continue;
576
-            }
574
+			if ( ! is_numeric($post_id) ) {
575
+				continue;
576
+			}
577 577
 
578
-            self::update_postmeta($post, $post_id);
578
+			self::update_postmeta($post, $post_id);
579 579
 
580
-            $this_type = 'posts';
580
+			$this_type = 'posts';
581 581
 			if ( isset( $post_types[ $post['post_type'] ] ) ) {
582 582
 				$this_type = $post_types[ $post['post_type'] ];
583
-            }
583
+			}
584 584
 
585
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
586
-                $imported['updated'][ $this_type ]++;
587
-            } else {
588
-                $imported['imported'][ $this_type ]++;
589
-            }
585
+			if ( isset($post['ID']) && $post_id == $post['ID'] ) {
586
+				$imported['updated'][ $this_type ]++;
587
+			} else {
588
+				$imported['imported'][ $this_type ]++;
589
+			}
590 590
 
591 591
 			$imported['posts'][ (int) $old_id ] = $post_id;
592 592
 
@@ -598,16 +598,16 @@  discard block
 block discarded – undo
598 598
 		self::maybe_update_stylesheet( $imported );
599 599
 
600 600
 		return $imported;
601
-    }
601
+	}
602 602
 
603
-    private static function populate_post( &$post, $item, $imported ) {
603
+	private static function populate_post( &$post, $item, $imported ) {
604 604
 		if ( isset($item->attachment_url) ) {
605 605
 			$post['attachment_url'] = (string) $item->attachment_url;
606 606
 		}
607 607
 
608 608
 		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
609
-		    // update to new form id
610
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
609
+			// update to new form id
610
+			$post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
611 611
 		}
612 612
 
613 613
 		// Don't allow default styles to take over a site's default style
@@ -616,144 +616,144 @@  discard block
 block discarded – undo
616 616
 		}
617 617
 
618 618
 		foreach ( $item->postmeta as $meta ) {
619
-		    self::populate_postmeta($post, $meta, $imported);
619
+			self::populate_postmeta($post, $meta, $imported);
620 620
 			unset($meta);
621 621
 		}
622 622
 
623
-        self::populate_taxonomies($post, $item);
623
+		self::populate_taxonomies($post, $item);
624 624
 
625
-        self::maybe_editing_post($post);
626
-    }
625
+		self::maybe_editing_post($post);
626
+	}
627 627
 
628
-    private static function populate_postmeta( &$post, $meta, $imported ) {
629
-        global $frm_duplicate_ids;
628
+	private static function populate_postmeta( &$post, $meta, $imported ) {
629
+		global $frm_duplicate_ids;
630 630
 
631
-	    $m = array(
631
+		$m = array(
632 632
 			'key'   => (string) $meta->meta_key,
633 633
 			'value' => (string) $meta->meta_value,
634 634
 		);
635 635
 
636 636
 		//switch old form and field ids to new ones
637 637
 		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
638
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
638
+			$m['value'] = $imported['forms'][ (int) $m['value'] ];
639 639
 		} else {
640
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
640
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
641 641
 
642
-		    if ( ! empty($frm_duplicate_ids) ) {
642
+			if ( ! empty($frm_duplicate_ids) ) {
643 643
 
644
-		        if ( $m['key'] == 'frm_dyncontent' ) {
645
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
646
-    		    } else if ( $m['key'] == 'frm_options' ) {
644
+				if ( $m['key'] == 'frm_dyncontent' ) {
645
+					$m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
646
+				} else if ( $m['key'] == 'frm_options' ) {
647 647
 
648 648
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
649 649
 						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
650 650
 							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
651
-    		            }
652
-    		        }
653
-
654
-                    $check_dup_array = array();
655
-    		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
656
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
657
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
658
-    		            } else if ( is_array( $m['value']['order_by'] ) ) {
659
-                            $check_dup_array[] = 'order_by';
660
-    		            }
661
-    		        }
662
-
663
-    		        if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
664
-    		            $check_dup_array[] = 'where';
665
-    		        }
666
-
667
-                    foreach ( $check_dup_array as $check_k ) {
651
+						}
652
+					}
653
+
654
+					$check_dup_array = array();
655
+					if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
656
+						if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
657
+							$m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
658
+						} else if ( is_array( $m['value']['order_by'] ) ) {
659
+							$check_dup_array[] = 'order_by';
660
+						}
661
+					}
662
+
663
+					if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
664
+						$check_dup_array[] = 'where';
665
+					}
666
+
667
+					foreach ( $check_dup_array as $check_k ) {
668 668
 						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
669 669
 							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
670 670
 								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
671
-		                    }
672
-		                    unset($mk, $mv);
673
-		                }
674
-                    }
675
-    		    }
676
-		    }
671
+							}
672
+							unset($mk, $mv);
673
+						}
674
+					}
675
+				}
676
+			}
677 677
 		}
678 678
 
679 679
 		if ( ! is_array($m['value']) ) {
680
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
680
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
681 681
 		}
682 682
 
683 683
 		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
684
-    }
685
-
686
-    /**
687
-     * Add terms to post
688
-     * @param array $post by reference
689
-     * @param object $item The XML object data
690
-     */
691
-    private static function populate_taxonomies( &$post, $item ) {
684
+	}
685
+
686
+	/**
687
+	 * Add terms to post
688
+	 * @param array $post by reference
689
+	 * @param object $item The XML object data
690
+	 */
691
+	private static function populate_taxonomies( &$post, $item ) {
692 692
 		foreach ( $item->category as $c ) {
693 693
 			$att = $c->attributes();
694 694
 			if ( ! isset( $att['nicename'] ) ) {
695
-                continue;
696
-            }
697
-
698
-		    $taxonomy = (string) $att['domain'];
699
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
700
-		        $name = (string) $att['nicename'];
701
-		        $h_term = get_term_by('slug', $name, $taxonomy);
702
-		        if ( $h_term ) {
703
-		            $name = $h_term->term_id;
704
-		        }
705
-		        unset($h_term);
706
-		    } else {
707
-		        $name = (string) $c;
708
-		    }
695
+				continue;
696
+			}
697
+
698
+			$taxonomy = (string) $att['domain'];
699
+			if ( is_taxonomy_hierarchical($taxonomy) ) {
700
+				$name = (string) $att['nicename'];
701
+				$h_term = get_term_by('slug', $name, $taxonomy);
702
+				if ( $h_term ) {
703
+					$name = $h_term->term_id;
704
+				}
705
+				unset($h_term);
706
+			} else {
707
+				$name = (string) $c;
708
+			}
709 709
 
710 710
 			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
711 711
 				$post['tax_input'][ $taxonomy ] = array();
712 712
 			}
713 713
 
714 714
 			$post['tax_input'][ $taxonomy ][] = $name;
715
-		    unset($name);
715
+			unset($name);
716 716
 		}
717
-    }
717
+	}
718 718
 
719
-    /**
720
-     * Edit post if the key and created time match
721
-     */
722
-    private static function maybe_editing_post( &$post ) {
719
+	/**
720
+	 * Edit post if the key and created time match
721
+	 */
722
+	private static function maybe_editing_post( &$post ) {
723 723
 		$match_by = array(
724
-		    'post_type'     => $post['post_type'],
725
-		    'name'          => $post['post_name'],
726
-		    'post_status'   => $post['post_status'],
727
-		    'posts_per_page' => 1,
724
+			'post_type'     => $post['post_type'],
725
+			'name'          => $post['post_name'],
726
+			'post_status'   => $post['post_status'],
727
+			'posts_per_page' => 1,
728 728
 		);
729 729
 
730 730
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
731
-		    $match_by['include'] = $post['post_id'];
732
-		    unset($match_by['name']);
731
+			$match_by['include'] = $post['post_id'];
732
+			unset($match_by['name']);
733 733
 		}
734 734
 
735 735
 		$editing = get_posts($match_by);
736 736
 
737
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
738
-            // set the id of the post to edit
739
-            $post['ID'] = current($editing)->ID;
740
-        }
741
-    }
737
+		if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
738
+			// set the id of the post to edit
739
+			$post['ID'] = current($editing)->ID;
740
+		}
741
+	}
742 742
 
743
-    private static function update_postmeta( &$post, $post_id ) {
744
-        foreach ( $post['postmeta'] as $k => $v ) {
745
-            if ( '_edit_last' == $k ) {
746
-                $v = FrmAppHelper::get_user_id_param($v);
747
-            } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
748
-                //change the attachment ID
749
-                $v = FrmProXMLHelper::get_file_id($v);
750
-            }
743
+	private static function update_postmeta( &$post, $post_id ) {
744
+		foreach ( $post['postmeta'] as $k => $v ) {
745
+			if ( '_edit_last' == $k ) {
746
+				$v = FrmAppHelper::get_user_id_param($v);
747
+			} else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
748
+				//change the attachment ID
749
+				$v = FrmProXMLHelper::get_file_id($v);
750
+			}
751 751
 
752
-            update_post_meta($post_id, $k, $v);
752
+			update_post_meta($post_id, $k, $v);
753 753
 
754
-            unset($k, $v);
755
-        }
756
-    }
754
+			unset($k, $v);
755
+		}
756
+	}
757 757
 
758 758
 	/**
759 759
 	 * If a template includes custom css, let's include it.
@@ -786,72 +786,72 @@  discard block
 block discarded – undo
786 786
 		}
787 787
 	}
788 788
 
789
-    /**
790
-     * @param string $message
791
-     */
789
+	/**
790
+	 * @param string $message
791
+	 */
792 792
 	public static function parse_message( $result, &$message, &$errors ) {
793
-        if ( is_wp_error($result) ) {
794
-            $errors[] = $result->get_error_message();
795
-        } else if ( ! $result ) {
796
-            return;
797
-        }
798
-
799
-        if ( ! is_array($result) ) {
800
-            $message = is_string( $result ) ? $result : print_r( $result, 1 );
801
-            return;
802
-        }
803
-
804
-        $t_strings = array(
805
-            'imported'  => __( 'Imported', 'formidable' ),
806
-            'updated'   => __( 'Updated', 'formidable' ),
807
-        );
808
-
809
-        $message = '<ul>';
810
-        foreach ( $result as $type => $results ) {
793
+		if ( is_wp_error($result) ) {
794
+			$errors[] = $result->get_error_message();
795
+		} else if ( ! $result ) {
796
+			return;
797
+		}
798
+
799
+		if ( ! is_array($result) ) {
800
+			$message = is_string( $result ) ? $result : print_r( $result, 1 );
801
+			return;
802
+		}
803
+
804
+		$t_strings = array(
805
+			'imported'  => __( 'Imported', 'formidable' ),
806
+			'updated'   => __( 'Updated', 'formidable' ),
807
+		);
808
+
809
+		$message = '<ul>';
810
+		foreach ( $result as $type => $results ) {
811 811
 			if ( ! isset( $t_strings[ $type ] ) ) {
812
-                // only print imported and updated
813
-                continue;
814
-            }
812
+				// only print imported and updated
813
+				continue;
814
+			}
815 815
 
816
-            $s_message = array();
817
-            foreach ( $results as $k => $m ) {
818
-                self::item_count_message($m, $k, $s_message);
819
-                unset($k, $m);
820
-            }
816
+			$s_message = array();
817
+			foreach ( $results as $k => $m ) {
818
+				self::item_count_message($m, $k, $s_message);
819
+				unset($k, $m);
820
+			}
821 821
 
822
-            if ( ! empty($s_message) ) {
822
+			if ( ! empty($s_message) ) {
823 823
 				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
824
-                $message .= implode(', ', $s_message);
825
-                $message .= '</li>';
826
-            }
827
-        }
828
-
829
-        if ( $message == '<ul>' ) {
830
-            $message = '';
831
-            $errors[] = __( 'Nothing was imported or updated', 'formidable' );
832
-        } else {
833
-            $message .= '</ul>';
834
-        }
835
-    }
824
+				$message .= implode(', ', $s_message);
825
+				$message .= '</li>';
826
+			}
827
+		}
828
+
829
+		if ( $message == '<ul>' ) {
830
+			$message = '';
831
+			$errors[] = __( 'Nothing was imported or updated', 'formidable' );
832
+		} else {
833
+			$message .= '</ul>';
834
+		}
835
+	}
836 836
 
837 837
 	public static function item_count_message( $m, $type, &$s_message ) {
838
-        if ( ! $m ) {
839
-            return;
840
-        }
841
-
842
-        $strings = array(
843
-            'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
844
-            'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
845
-            'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
846
-            'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
847
-            'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
848
-            'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
849
-            'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
850
-            'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
851
-        );
838
+		if ( ! $m ) {
839
+			return;
840
+		}
841
+
842
+		$strings = array(
843
+			'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
844
+			'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
845
+			'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
846
+			'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
847
+			'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
848
+			'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
849
+			'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
850
+			'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
851
+		);
852 852
 
853 853
 		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
854
-    }
854
+	}
855 855
 
856 856
 	/**
857 857
 	 * Prepare the form options for export
@@ -882,16 +882,16 @@  discard block
 block discarded – undo
882 882
 	}
883 883
 
884 884
 	public static function cdata( $str ) {
885
-	    $str = maybe_unserialize($str);
886
-	    if ( is_array($str) ) {
887
-	        $str = json_encode($str);
885
+		$str = maybe_unserialize($str);
886
+		if ( is_array($str) ) {
887
+			$str = json_encode($str);
888 888
 		} else if ( seems_utf8( $str ) == false ) {
889 889
 			$str = utf8_encode( $str );
890 890
 		}
891 891
 
892
-        if ( is_numeric($str) ) {
893
-            return $str;
894
-        }
892
+		if ( is_numeric($str) ) {
893
+			return $str;
894
+		}
895 895
 
896 896
 		self::remove_invalid_characters_from_xml( $str );
897 897
 
@@ -912,58 +912,58 @@  discard block
 block discarded – undo
912 912
 		$str = str_replace( '\x1F', '', $str );
913 913
 	}
914 914
 
915
-    public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
916
-        // Get post type
917
-        $post_type = FrmFormActionsController::$action_post_type;
918
-
919
-        // Set up imported index, if not set up yet
920
-        if ( ! isset( $imported['imported']['actions'] ) ) {
921
-            $imported['imported']['actions'] = 0;
922
-        }
923
-
924
-        // Migrate post settings to action
925
-        self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
926
-
927
-        // Migrate email settings to action
928
-        self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
929
-    }
930
-
931
-    /**
932
-    * Migrate post settings to form action
933
-    *
934
-    * @param string $post_type
935
-    */
936
-    private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
937
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
938
-            return;
939
-        }
940
-
941
-        $new_action = array(
942
-            'post_type'     => $post_type,
943
-            'post_excerpt'  => 'wppost',
915
+	public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
916
+		// Get post type
917
+		$post_type = FrmFormActionsController::$action_post_type;
918
+
919
+		// Set up imported index, if not set up yet
920
+		if ( ! isset( $imported['imported']['actions'] ) ) {
921
+			$imported['imported']['actions'] = 0;
922
+		}
923
+
924
+		// Migrate post settings to action
925
+		self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
926
+
927
+		// Migrate email settings to action
928
+		self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
929
+	}
930
+
931
+	/**
932
+	 * Migrate post settings to form action
933
+	 *
934
+	 * @param string $post_type
935
+	 */
936
+	private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
937
+		if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
938
+			return;
939
+		}
940
+
941
+		$new_action = array(
942
+			'post_type'     => $post_type,
943
+			'post_excerpt'  => 'wppost',
944 944
 			'post_title'    => __( 'Create Posts', 'formidable' ),
945
-            'menu_order'    => $form_id,
946
-            'post_status'   => 'publish',
947
-            'post_content'  => array(),
945
+			'menu_order'    => $form_id,
946
+			'post_status'   => 'publish',
947
+			'post_content'  => array(),
948 948
 			'post_name'     => $form_id . '_wppost_1',
949
-        );
949
+		);
950 950
 
951
-        $post_settings = array(
952
-            'post_type', 'post_category', 'post_content',
953
-            'post_excerpt', 'post_title', 'post_name', 'post_date',
951
+		$post_settings = array(
952
+			'post_type', 'post_category', 'post_content',
953
+			'post_excerpt', 'post_title', 'post_name', 'post_date',
954 954
 			'post_status', 'post_custom_fields', 'post_password',
955
-        );
955
+		);
956 956
 
957
-        foreach ( $post_settings as $post_setting ) {
957
+		foreach ( $post_settings as $post_setting ) {
958 958
 			if ( isset( $form_options[ $post_setting ] ) ) {
959 959
 				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
960
-            }
961
-            unset($post_setting);
962
-        }
960
+			}
961
+			unset($post_setting);
962
+		}
963 963
 
964 964
 		$new_action['event'] = array( 'create', 'update' );
965 965
 
966
-        if ( $switch ) {
966
+		if ( $switch ) {
967 967
 			// Fields with string or int saved
968 968
 			$basic_fields = array( 'post_title', 'post_content', 'post_excerpt', 'post_password', 'post_date', 'post_status' );
969 969
 
@@ -971,22 +971,22 @@  discard block
 block discarded – undo
971 971
 			$array_fields = array( 'post_category', 'post_custom_fields' );
972 972
 
973 973
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
974
-        }
975
-        $new_action['post_content'] = json_encode($new_action['post_content']);
974
+		}
975
+		$new_action['post_content'] = json_encode($new_action['post_content']);
976 976
 
977
-        $exists = get_posts( array(
978
-            'name'          => $new_action['post_name'],
979
-            'post_type'     => $new_action['post_type'],
980
-            'post_status'   => $new_action['post_status'],
981
-            'numberposts'   => 1,
982
-        ) );
977
+		$exists = get_posts( array(
978
+			'name'          => $new_action['post_name'],
979
+			'post_type'     => $new_action['post_type'],
980
+			'post_status'   => $new_action['post_status'],
981
+			'numberposts'   => 1,
982
+		) );
983 983
 
984
-        if ( ! $exists ) {
984
+		if ( ! $exists ) {
985 985
 			// this isn't an email, but we need to use a class that will always be included
986 986
 			FrmAppHelper::save_json_post( $new_action );
987
-            $imported['imported']['actions']++;
988
-        }
989
-    }
987
+			$imported['imported']['actions']++;
988
+		}
989
+	}
990 990
 
991 991
 	/**
992 992
 	 * Switch old field IDs for new field IDs in emails and post
@@ -999,88 +999,88 @@  discard block
 block discarded – undo
999 999
 	 * @return string $post_content - new field IDs
1000 1000
 	 */
1001 1001
 	private static function switch_action_field_ids( $post_content, $basic_fields, $array_fields = array() ) {
1002
-        global $frm_duplicate_ids;
1002
+		global $frm_duplicate_ids;
1003 1003
 
1004
-        // If there aren't IDs that were switched, end now
1005
-        if ( ! $frm_duplicate_ids ) {
1006
-            return;
1007
-        }
1004
+		// If there aren't IDs that were switched, end now
1005
+		if ( ! $frm_duplicate_ids ) {
1006
+			return;
1007
+		}
1008 1008
 
1009
-        // Get old IDs
1010
-        $old = array_keys( $frm_duplicate_ids );
1009
+		// Get old IDs
1010
+		$old = array_keys( $frm_duplicate_ids );
1011 1011
 
1012
-        // Get new IDs
1013
-        $new = array_values( $frm_duplicate_ids );
1012
+		// Get new IDs
1013
+		$new = array_values( $frm_duplicate_ids );
1014 1014
 
1015
-        // Do a str_replace with each item to set the new IDs
1016
-        foreach ( $post_content as $key => $setting ) {
1017
-            if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
1018
-                // Replace old IDs with new IDs
1015
+		// Do a str_replace with each item to set the new IDs
1016
+		foreach ( $post_content as $key => $setting ) {
1017
+			if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
1018
+				// Replace old IDs with new IDs
1019 1019
 				$post_content[ $key ] = str_replace( $old, $new, $setting );
1020
-            } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
1021
-                foreach ( $setting as $k => $val ) {
1022
-                    // Replace old IDs with new IDs
1020
+			} else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
1021
+				foreach ( $setting as $k => $val ) {
1022
+					// Replace old IDs with new IDs
1023 1023
 					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
1024
-                }
1025
-            }
1026
-            unset( $key, $setting );
1027
-        }
1028
-        return $post_content;
1029
-    }
1030
-
1031
-    private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
1032
-        // No old notifications or autoresponders to carry over
1024
+				}
1025
+			}
1026
+			unset( $key, $setting );
1027
+		}
1028
+		return $post_content;
1029
+	}
1030
+
1031
+	private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
1032
+		// No old notifications or autoresponders to carry over
1033 1033
 		if ( ! isset( $form_options['auto_responder'] ) && ! isset( $form_options['notification'] ) && ! isset( $form_options['email_to'] ) ) {
1034
-            return;
1035
-        }
1034
+			return;
1035
+		}
1036 1036
 
1037
-        // Initialize notifications array
1038
-        $notifications = array();
1037
+		// Initialize notifications array
1038
+		$notifications = array();
1039 1039
 
1040
-        // Migrate regular notifications
1041
-        self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
1040
+		// Migrate regular notifications
1041
+		self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
1042 1042
 
1043
-        // Migrate autoresponders
1044
-        self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
1043
+		// Migrate autoresponders
1044
+		self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
1045 1045
 
1046
-        if ( empty( $notifications ) ) {
1047
-            return;
1048
-        }
1046
+		if ( empty( $notifications ) ) {
1047
+			return;
1048
+		}
1049 1049
 
1050
-        foreach ( $notifications as $new_notification ) {
1051
-            $new_notification['post_type']      = $post_type;
1052
-            $new_notification['post_excerpt']   = 'email';
1050
+		foreach ( $notifications as $new_notification ) {
1051
+			$new_notification['post_type']      = $post_type;
1052
+			$new_notification['post_excerpt']   = 'email';
1053 1053
 			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
1054
-            $new_notification['menu_order']     = $form_id;
1055
-            $new_notification['post_status']    = 'publish';
1054
+			$new_notification['menu_order']     = $form_id;
1055
+			$new_notification['post_status']    = 'publish';
1056 1056
 
1057
-            // Switch field IDs and keys, if needed
1058
-            if ( $switch ) {
1057
+			// Switch field IDs and keys, if needed
1058
+			if ( $switch ) {
1059 1059
 
1060 1060
 				// Switch field IDs in email conditional logic
1061 1061
 				self::switch_email_contition_field_ids( $new_notification['post_content'] );
1062 1062
 
1063 1063
 				// Switch all other field IDs in email
1064
-                $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1065
-            }
1066
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1067
-
1068
-            $exists = get_posts( array(
1069
-                'name'          => $new_notification['post_name'],
1070
-                'post_type'     => $new_notification['post_type'],
1071
-                'post_status'   => $new_notification['post_status'],
1072
-                'numberposts'   => 1,
1073
-            ) );
1074
-
1075
-            if ( empty($exists) ) {
1064
+				$new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1065
+			}
1066
+			$new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1067
+
1068
+			$exists = get_posts( array(
1069
+				'name'          => $new_notification['post_name'],
1070
+				'post_type'     => $new_notification['post_type'],
1071
+				'post_status'   => $new_notification['post_status'],
1072
+				'numberposts'   => 1,
1073
+			) );
1074
+
1075
+			if ( empty($exists) ) {
1076 1076
 				FrmAppHelper::save_json_post( $new_notification );
1077
-                $imported['imported']['actions']++;
1078
-            }
1079
-            unset($new_notification);
1080
-        }
1077
+				$imported['imported']['actions']++;
1078
+			}
1079
+			unset($new_notification);
1080
+		}
1081 1081
 
1082 1082
 		self::remove_deprecated_notification_settings( $form_id, $form_options );
1083
-    }
1083
+	}
1084 1084
 
1085 1085
 	/**
1086 1086
 	 * Remove deprecated notification settings after migration
@@ -1100,130 +1100,130 @@  discard block
 block discarded – undo
1100 1100
 		FrmForm::update( $form_id, array( 'options' => $form_options ) );
1101 1101
 	}
1102 1102
 
1103
-    private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
1104
-        if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
1105
-            // add old settings into notification array
1103
+	private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
1104
+		if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
1105
+			// add old settings into notification array
1106 1106
 			$form_options['notification'] = array( 0 => $form_options );
1107
-        } else if ( isset( $form_options['notification']['email_to'] ) ) {
1108
-            // make sure it's in the correct format
1107
+		} else if ( isset( $form_options['notification']['email_to'] ) ) {
1108
+			// make sure it's in the correct format
1109 1109
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
1110
-        }
1110
+		}
1111 1111
 
1112
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1113
-            foreach ( $form_options['notification'] as $email_key => $notification ) {
1112
+		if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1113
+			foreach ( $form_options['notification'] as $email_key => $notification ) {
1114 1114
 
1115
-                $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
1115
+				$atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
1116 1116
 
1117
-                // Format the email data
1118
-                self::format_email_data( $atts, $notification );
1117
+				// Format the email data
1118
+				self::format_email_data( $atts, $notification );
1119 1119
 
1120 1120
 				if ( isset( $notification['twilio'] ) && $notification['twilio'] ) {
1121 1121
 					do_action( 'frm_create_twilio_action', $atts, $notification );
1122 1122
 				}
1123 1123
 
1124
-                // Setup the new notification
1125
-                $new_notification = array();
1126
-                self::setup_new_notification( $new_notification, $notification, $atts );
1124
+				// Setup the new notification
1125
+				$new_notification = array();
1126
+				self::setup_new_notification( $new_notification, $notification, $atts );
1127 1127
 
1128
-                $notifications[] = $new_notification;
1129
-            }
1130
-        }
1131
-    }
1128
+				$notifications[] = $new_notification;
1129
+			}
1130
+		}
1131
+	}
1132 1132
 
1133
-    private static function format_email_data( &$atts, $notification ) {
1134
-        // Format email_to
1135
-        self::format_email_to_data( $atts, $notification );
1133
+	private static function format_email_data( &$atts, $notification ) {
1134
+		// Format email_to
1135
+		self::format_email_to_data( $atts, $notification );
1136 1136
 
1137
-        // Format the reply to email and name
1138
-        $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
1139
-        foreach ( $reply_fields as $f => $val ) {
1137
+		// Format the reply to email and name
1138
+		$reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
1139
+		foreach ( $reply_fields as $f => $val ) {
1140 1140
 			if ( isset( $notification[ $f ] ) ) {
1141 1141
 				$atts[ $f ] = $notification[ $f ];
1142 1142
 				if ( 'custom' == $notification[ $f ] ) {
1143 1143
 					$atts[ $f ] = $notification[ 'cust_' . $f ];
1144 1144
 				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
1145 1145
 					$atts[ $f ] = '[' . $atts[ $f ] . ']';
1146
-                }
1147
-            }
1148
-            unset( $f, $val );
1149
-        }
1146
+				}
1147
+			}
1148
+			unset( $f, $val );
1149
+		}
1150 1150
 
1151
-        // Format event
1151
+		// Format event
1152 1152
 		$atts['event'] = array( 'create' );
1153
-        if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1154
-            $atts['event'][] = 'update';
1155
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1153
+		if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1154
+			$atts['event'][] = 'update';
1155
+		} else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1156 1156
 			$atts['event'] = array( 'update' );
1157
-        }
1158
-    }
1157
+		}
1158
+	}
1159 1159
 
1160
-    private static function format_email_to_data( &$atts, $notification ) {
1161
-        if ( isset( $notification['email_to'] ) ) {
1160
+	private static function format_email_to_data( &$atts, $notification ) {
1161
+		if ( isset( $notification['email_to'] ) ) {
1162 1162
 			$atts['email_to'] = preg_split( '/ (,|;) /', $notification['email_to'] );
1163
-        } else {
1164
-            $atts['email_to'] = array();
1165
-        }
1163
+		} else {
1164
+			$atts['email_to'] = array();
1165
+		}
1166 1166
 
1167
-        if ( isset( $notification['also_email_to'] ) ) {
1168
-            $email_fields = (array) $notification['also_email_to'];
1169
-            $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1170
-            unset( $email_fields );
1171
-        }
1167
+		if ( isset( $notification['also_email_to'] ) ) {
1168
+			$email_fields = (array) $notification['also_email_to'];
1169
+			$atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1170
+			unset( $email_fields );
1171
+		}
1172 1172
 
1173
-        foreach ( $atts['email_to'] as $key => $email_field ) {
1173
+		foreach ( $atts['email_to'] as $key => $email_field ) {
1174 1174
 
1175
-            if ( is_numeric( $email_field ) ) {
1175
+			if ( is_numeric( $email_field ) ) {
1176 1176
 				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1177
-            }
1177
+			}
1178 1178
 
1179
-            if ( strpos( $email_field, '|') ) {
1180
-                $email_opt = explode( '|', $email_field );
1181
-                if ( isset( $email_opt[0] ) ) {
1179
+			if ( strpos( $email_field, '|') ) {
1180
+				$email_opt = explode( '|', $email_field );
1181
+				if ( isset( $email_opt[0] ) ) {
1182 1182
 					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1183
-                }
1184
-                unset( $email_opt );
1185
-            }
1186
-        }
1187
-        $atts['email_to'] = implode(', ', $atts['email_to']);
1188
-    }
1189
-
1190
-    private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1191
-        // Set up new notification
1192
-        $new_notification = array(
1193
-            'post_content'  => array(
1194
-                'email_to'      => $atts['email_to'],
1195
-                'event'         => $atts['event'],
1196
-            ),
1183
+				}
1184
+				unset( $email_opt );
1185
+			}
1186
+		}
1187
+		$atts['email_to'] = implode(', ', $atts['email_to']);
1188
+	}
1189
+
1190
+	private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1191
+		// Set up new notification
1192
+		$new_notification = array(
1193
+			'post_content'  => array(
1194
+				'email_to'      => $atts['email_to'],
1195
+				'event'         => $atts['event'],
1196
+			),
1197 1197
 			'post_name'         => $atts['form_id'] . '_email_' . $atts['email_key'],
1198
-        );
1198
+		);
1199 1199
 
1200
-        // Add more fields to the new notification
1201
-        $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1202
-        foreach ( $add_fields as $add_field ) {
1200
+		// Add more fields to the new notification
1201
+		$add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1202
+		foreach ( $add_fields as $add_field ) {
1203 1203
 			if ( isset( $notification[ $add_field ] ) ) {
1204 1204
 				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1205
-            } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1205
+			} else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1206 1206
 				$new_notification['post_content'][ $add_field ] = 0;
1207
-            } else {
1207
+			} else {
1208 1208
 				$new_notification['post_content'][ $add_field ] = '';
1209
-            }
1210
-            unset( $add_field );
1211
-        }
1209
+			}
1210
+			unset( $add_field );
1211
+		}
1212 1212
 
1213 1213
 		// Set reply to
1214 1214
 		$new_notification['post_content']['reply_to'] = $atts['reply_to'];
1215 1215
 
1216
-        // Set from
1216
+		// Set from
1217 1217
 		if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) {
1218 1218
 			$new_notification['post_content']['from'] = ( empty( $atts['reply_to_name'] ) ? '[sitename]' : $atts['reply_to_name'] ) . ' <' . ( empty( $atts['reply_to'] ) ? '[admin_email]' : $atts['reply_to'] ) . '>';
1219
-        }
1220
-    }
1219
+		}
1220
+	}
1221 1221
 
1222 1222
 	/**
1223
-	* Switch field IDs in pre-2.0 email conditional logic
1224
-	*
1225
-	* @param $post_content array, pass by reference
1226
-	*/
1223
+	 * Switch field IDs in pre-2.0 email conditional logic
1224
+	 *
1225
+	 * @param $post_content array, pass by reference
1226
+	 */
1227 1227
 	private static function switch_email_contition_field_ids( &$post_content ) {
1228 1228
 		// Switch field IDs in conditional logic
1229 1229
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
@@ -1236,36 +1236,36 @@  discard block
 block discarded – undo
1236 1236
 		}
1237 1237
 	}
1238 1238
 
1239
-    private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1240
-        if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1241
-            // migrate autoresponder
1242
-
1243
-            $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1244
-            if ( strpos($email_field, '|') ) {
1245
-                // data from entries field
1246
-                $email_field = explode('|', $email_field);
1247
-                if ( isset($email_field[1]) ) {
1248
-                    $email_field = $email_field[1];
1249
-                }
1250
-            }
1251
-            if ( is_numeric($email_field) && ! empty($email_field) ) {
1239
+	private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1240
+		if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1241
+			// migrate autoresponder
1242
+
1243
+			$email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1244
+			if ( strpos($email_field, '|') ) {
1245
+				// data from entries field
1246
+				$email_field = explode('|', $email_field);
1247
+				if ( isset($email_field[1]) ) {
1248
+					$email_field = $email_field[1];
1249
+				}
1250
+			}
1251
+			if ( is_numeric($email_field) && ! empty($email_field) ) {
1252 1252
 				$email_field = '[' . $email_field . ']';
1253
-            }
1254
-
1255
-            $notification = $form_options;
1256
-            $new_notification2 = array(
1257
-                'post_content'  => array(
1258
-                    'email_message' => $notification['ar_email_message'],
1259
-                    'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1260
-                    'email_to'      => $email_field,
1261
-                    'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1262
-                    'inc_user_info' => 0,
1263
-                ),
1253
+			}
1254
+
1255
+			$notification = $form_options;
1256
+			$new_notification2 = array(
1257
+				'post_content'  => array(
1258
+					'email_message' => $notification['ar_email_message'],
1259
+					'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1260
+					'email_to'      => $email_field,
1261
+					'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1262
+					'inc_user_info' => 0,
1263
+				),
1264 1264
 				'post_name'     => $form_id . '_email_' . count( $notifications ),
1265
-            );
1265
+			);
1266 1266
 
1267
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1268
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1267
+			$reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1268
+			$reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1269 1269
 
1270 1270
 			if ( ! empty( $reply_to ) ) {
1271 1271
 				$new_notification2['post_content']['reply_to'] = $reply_to;
@@ -1275,9 +1275,9 @@  discard block
 block discarded – undo
1275 1275
 				$new_notification2['post_content']['from'] = ( empty( $reply_to_name ) ? '[sitename]' : $reply_to_name ) . ' <' . ( empty( $reply_to ) ? '[admin_email]' : $reply_to ) . '>';
1276 1276
 			}
1277 1277
 
1278
-            $notifications[] = $new_notification2;
1279
-            unset( $new_notification2 );
1280
-        }
1281
-    }
1278
+			$notifications[] = $new_notification2;
1279
+			unset( $new_notification2 );
1280
+		}
1281
+	}
1282 1282
 }
1283 1283
 
Please login to merge, or discard this patch.
Spacing   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 			'terms'    => array(),
37 37
         );
38 38
 
39
-        unset($defaults);
39
+        unset( $defaults );
40 40
 
41 41
 		if ( ! defined( 'WP_IMPORTING' ) ) {
42
-            define('WP_IMPORTING', true);
42
+            define( 'WP_IMPORTING', true );
43 43
         }
44 44
 
45 45
 		if ( ! class_exists( 'DOMDocument' ) ) {
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
53 53
 		}
54 54
 
55
-		if ( ! function_exists('simplexml_import_dom') ) {
55
+		if ( ! function_exists( 'simplexml_import_dom' ) ) {
56 56
 			return new WP_Error( 'SimpleXML_parse_error', __( 'Your server is missing the simplexml_import_dom function', 'formidable' ), libxml_get_errors() );
57 57
 		}
58 58
 
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
         // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
68 68
 		foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
69 69
             // grab cats, tags, and terms, or forms or posts
70
-            if ( isset($xml->{$item_type} ) ) {
70
+            if ( isset( $xml->{$item_type} ) ) {
71 71
 				$function_name = 'import_xml_' . $item_type . 's';
72 72
 				$imported = self::$function_name( $xml->{$item_type}, $imported );
73 73
 				unset( $function_name, $xml->{$item_type} );
74 74
             }
75 75
         }
76 76
 
77
-	    $return = apply_filters('frm_importing_xml', $imported, $xml );
77
+	    $return = apply_filters( 'frm_importing_xml', $imported, $xml );
78 78
 
79 79
 	    return $return;
80 80
     }
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
                 'slug'          => (string) $t->term_slug,
92 92
                 'description'   => (string) $t->term_description,
93 93
 				'parent'        => empty( $parent ) ? 0 : $parent,
94
-            ));
94
+            ) );
95 95
 
96 96
 			if ( $term && is_array( $term ) ) {
97
-                $imported['imported']['terms']++;
98
-				$imported['terms'][ (int) $t->term_id ] = $term['term_id'];
97
+                $imported['imported']['terms'] ++;
98
+				$imported['terms'][(int) $t->term_id] = $term['term_id'];
99 99
             }
100 100
 
101 101
 			unset( $term, $t );
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
 			} else {
145 145
 				$form_id = FrmForm::create( $form );
146 146
 		        if ( $form_id ) {
147
-		            $imported['imported']['forms']++;
147
+		            $imported['imported']['forms'] ++;
148 148
 		            // Keep track of whether this specific form was updated or not
149
-					$imported['form_status'][ $form_id ] = 'imported';
149
+					$imported['form_status'][$form_id] = 'imported';
150 150
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
151 151
 		        }
152 152
 			}
@@ -158,14 +158,14 @@  discard block
 block discarded – undo
158 158
 		    // Update field ids/keys to new ones
159 159
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
160 160
 
161
-			$imported['forms'][ (int) $item->id ] = $form_id;
161
+			$imported['forms'][(int) $item->id] = $form_id;
162 162
 
163 163
             // Send pre 2.0 form options through function that creates actions
164 164
             self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true );
165 165
 
166 166
 			do_action( 'frm_after_import_form', $form_id, $form );
167 167
 
168
-		    unset($form, $item);
168
+		    unset( $form, $item );
169 169
 		}
170 170
 
171 171
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
@@ -207,18 +207,18 @@  discard block
 block discarded – undo
207 207
 	private static function update_form( $this_form, $form, &$imported ) {
208 208
 		$form_id = $this_form->id;
209 209
 		FrmForm::update( $form_id, $form );
210
-		$imported['updated']['forms']++;
210
+		$imported['updated']['forms'] ++;
211 211
 		// Keep track of whether this specific form was updated or not
212
-		$imported['form_status'][ $form_id ] = 'updated';
212
+		$imported['form_status'][$form_id] = 'updated';
213 213
 	}
214 214
 
215 215
 	private static function get_form_fields( $form_id ) {
216 216
 		$form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' );
217 217
 		$old_fields = array();
218 218
 		foreach ( $form_fields as $f ) {
219
-			$old_fields[ $f->id ] = $f;
220
-			$old_fields[ $f->field_key ] = $f->id;
221
-			unset($f);
219
+			$old_fields[$f->id] = $f;
220
+			$old_fields[$f->field_key] = $f->id;
221
+			unset( $f );
222 222
 		}
223 223
 		$form_fields = $old_fields;
224 224
 		return $form_fields;
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 		$regular_forms = array();
250 250
 
251 251
 		foreach ( $forms as $form ) {
252
-			$parent_form_id = isset( $form->parent_form_id) ? (int) $form->parent_form_id : 0;
252
+			$parent_form_id = isset( $form->parent_form_id ) ? (int) $form->parent_form_id : 0;
253 253
 
254 254
 			if ( $parent_form_id ) {
255 255
 				$child_forms[] = $form;
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	*/
272 272
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
273 273
 		if ( $parent_form_id ) {
274
-			$child_forms[ $form_id ] = $parent_form_id;
274
+			$child_forms[$form_id] = $parent_form_id;
275 275
 		}
276 276
 	}
277 277
 
@@ -286,9 +286,9 @@  discard block
 block discarded – undo
286 286
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
287 287
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
288 288
 
289
-			if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) {
289
+			if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) {
290 290
 				// Update all children with this old parent_form_id
291
-				$new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ];
291
+				$new_parent_form_id = (int) $imported_forms[$old_parent_form_id];
292 292
 
293 293
 				FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) );
294 294
 			}
@@ -307,15 +307,15 @@  discard block
 block discarded – undo
307 307
 		foreach ( $xml_fields as $field ) {
308 308
 			$f = self::fill_field( $field, $form_id );
309 309
 
310
-		    if ( is_array($f['default_value']) && in_array($f['type'], array(
310
+		    if ( is_array( $f['default_value'] ) && in_array( $f['type'], array(
311 311
 		        'text', 'email', 'url', 'textarea',
312
-		        'number','phone', 'date',
312
+		        'number', 'phone', 'date',
313 313
 		        'hidden', 'password', 'tag', 'image',
314
-		    )) ) {
315
-		        if ( count($f['default_value']) === 1 ) {
314
+		    ) ) ) {
315
+		        if ( count( $f['default_value'] ) === 1 ) {
316 316
 					$f['default_value'] = '[' . reset( $f['default_value'] ) . ']';
317 317
 		        } else {
318
-		            $f['default_value'] = reset($f['default_value']);
318
+		            $f['default_value'] = reset( $f['default_value'] );
319 319
 		        }
320 320
 		    }
321 321
 
@@ -323,27 +323,27 @@  discard block
 block discarded – undo
323 323
 			self::maybe_update_form_select( $f, $imported );
324 324
 			self::maybe_update_get_values_form_setting( $imported, $f );
325 325
 
326
-			if ( ! empty($this_form) ) {
326
+			if ( ! empty( $this_form ) ) {
327 327
 				// check for field to edit by field id
328
-				if ( isset( $form_fields[ $f['id'] ] ) ) {
328
+				if ( isset( $form_fields[$f['id']] ) ) {
329 329
 					FrmField::update( $f['id'], $f );
330
-					$imported['updated']['fields']++;
330
+					$imported['updated']['fields'] ++;
331 331
 
332
-					unset( $form_fields[ $f['id'] ] );
332
+					unset( $form_fields[$f['id']] );
333 333
 
334 334
 					//unset old field key
335
-					if ( isset( $form_fields[ $f['field_key'] ] ) ) {
336
-						unset( $form_fields[ $f['field_key'] ] );
335
+					if ( isset( $form_fields[$f['field_key']] ) ) {
336
+						unset( $form_fields[$f['field_key']] );
337 337
 					}
338
-				} else if ( isset( $form_fields[ $f['field_key'] ] ) ) {
338
+				} else if ( isset( $form_fields[$f['field_key']] ) ) {
339 339
 					// check for field to edit by field key
340
-					unset($f['id']);
340
+					unset( $f['id'] );
341 341
 
342
-					FrmField::update( $form_fields[ $f['field_key'] ], $f );
343
-					$imported['updated']['fields']++;
342
+					FrmField::update( $form_fields[$f['field_key']], $f );
343
+					$imported['updated']['fields'] ++;
344 344
 
345
-					unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id
346
-					unset( $form_fields[ $f['field_key'] ] ); //unset old field key
345
+					unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id
346
+					unset( $form_fields[$f['field_key']] ); //unset old field key
347 347
 				} else {
348 348
 					// if no matching field id or key in this form, create the field
349 349
 					self::create_imported_field( $f, $imported );
@@ -362,11 +362,11 @@  discard block
 block discarded – undo
362 362
 			'name'          => (string) $field->name,
363 363
 			'description'   => (string) $field->description,
364 364
 			'type'          => (string) $field->type,
365
-			'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
365
+			'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value ),
366 366
 			'field_order'   => (int) $field->field_order,
367 367
 			'form_id'       => (int) $form_id,
368 368
 			'required'      => (int) $field->required,
369
-			'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
369
+			'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options ),
370 370
 			'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
371 371
 		);
372 372
 	}
@@ -410,8 +410,8 @@  discard block
 block discarded – undo
410 410
 		if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) {
411 411
 			if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) {
412 412
 				$form_select = (int) $f['field_options']['form_select'];
413
-				if ( isset( $imported['forms'][ $form_select ] ) ) {
414
-					$f['field_options']['form_select'] = $imported['forms'][ $form_select ];
413
+				if ( isset( $imported['forms'][$form_select] ) ) {
414
+					$f['field_options']['form_select'] = $imported['forms'][$form_select];
415 415
 				}
416 416
 			}
417 417
 		}
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 
432 432
 		if ( FrmField::is_option_true_in_array( $f['field_options'], 'get_values_form' ) ) {
433 433
 			$old_form = $f['field_options']['get_values_form'];
434
-			if ( isset( $imported['forms'][ $old_form ] ) ) {
435
-				$f['field_options']['get_values_form'] = $imported['forms'][ $old_form ];
434
+			if ( isset( $imported['forms'][$old_form] ) ) {
435
+				$f['field_options']['get_values_form'] = $imported['forms'][$old_form];
436 436
 			}
437 437
 		}
438 438
 	}
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 	private static function create_imported_field( $f, &$imported ) {
448 448
 		$new_id = FrmField::create( $f );
449 449
 		if ( $new_id != false ) {
450
-			$imported['imported']['fields']++;
450
+			$imported['imported']['fields'] ++;
451 451
 			do_action( 'frm_after_field_is_imported', $f, $new_id );
452 452
 		}
453 453
 	}
@@ -546,9 +546,9 @@  discard block
 block discarded – undo
546 546
 			);
547 547
 
548 548
             $old_id = $post['post_id'];
549
-            self::populate_post($post, $item, $imported);
549
+            self::populate_post( $post, $item, $imported );
550 550
 
551
-			unset($item);
551
+			unset( $item );
552 552
 
553 553
 			$post_id = false;
554 554
             if ( $post['post_type'] == $form_action_type ) {
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 				if ( $action_control && is_object( $action_control ) ) {
557 557
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
558 558
 				}
559
-                unset($action_control);
559
+                unset( $action_control );
560 560
             } else if ( $post['post_type'] == 'frm_styles' ) {
561 561
                 // Properly encode post content before inserting the post
562 562
                 $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
@@ -571,24 +571,24 @@  discard block
 block discarded – undo
571 571
                 $post_id = wp_insert_post( $post );
572 572
             }
573 573
 
574
-            if ( ! is_numeric($post_id) ) {
574
+            if ( ! is_numeric( $post_id ) ) {
575 575
                 continue;
576 576
             }
577 577
 
578
-            self::update_postmeta($post, $post_id);
578
+            self::update_postmeta( $post, $post_id );
579 579
 
580 580
             $this_type = 'posts';
581
-			if ( isset( $post_types[ $post['post_type'] ] ) ) {
582
-				$this_type = $post_types[ $post['post_type'] ];
581
+			if ( isset( $post_types[$post['post_type']] ) ) {
582
+				$this_type = $post_types[$post['post_type']];
583 583
             }
584 584
 
585
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
586
-                $imported['updated'][ $this_type ]++;
585
+            if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) {
586
+                $imported['updated'][$this_type] ++;
587 587
             } else {
588
-                $imported['imported'][ $this_type ]++;
588
+                $imported['imported'][$this_type] ++;
589 589
             }
590 590
 
591
-			$imported['posts'][ (int) $old_id ] = $post_id;
591
+			$imported['posts'][(int) $old_id] = $post_id;
592 592
 
593 593
 			do_action( 'frm_after_import_view', $post_id, $post );
594 594
 
@@ -601,13 +601,13 @@  discard block
 block discarded – undo
601 601
     }
602 602
 
603 603
     private static function populate_post( &$post, $item, $imported ) {
604
-		if ( isset($item->attachment_url) ) {
604
+		if ( isset( $item->attachment_url ) ) {
605 605
 			$post['attachment_url'] = (string) $item->attachment_url;
606 606
 		}
607 607
 
608
-		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
608
+		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) {
609 609
 		    // update to new form id
610
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
610
+		    $post['menu_order'] = $imported['forms'][(int) $post['menu_order']];
611 611
 		}
612 612
 
613 613
 		// Don't allow default styles to take over a site's default style
@@ -616,13 +616,13 @@  discard block
 block discarded – undo
616 616
 		}
617 617
 
618 618
 		foreach ( $item->postmeta as $meta ) {
619
-		    self::populate_postmeta($post, $meta, $imported);
620
-			unset($meta);
619
+		    self::populate_postmeta( $post, $meta, $imported );
620
+			unset( $meta );
621 621
 		}
622 622
 
623
-        self::populate_taxonomies($post, $item);
623
+        self::populate_taxonomies( $post, $item );
624 624
 
625
-        self::maybe_editing_post($post);
625
+        self::maybe_editing_post( $post );
626 626
     }
627 627
 
628 628
     private static function populate_postmeta( &$post, $meta, $imported ) {
@@ -634,27 +634,27 @@  discard block
 block discarded – undo
634 634
 		);
635 635
 
636 636
 		//switch old form and field ids to new ones
637
-		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
638
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
637
+		if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) {
638
+		    $m['value'] = $imported['forms'][(int) $m['value']];
639 639
 		} else {
640
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
640
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
641 641
 
642
-		    if ( ! empty($frm_duplicate_ids) ) {
642
+		    if ( ! empty( $frm_duplicate_ids ) ) {
643 643
 
644 644
 		        if ( $m['key'] == 'frm_dyncontent' ) {
645
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
645
+		            $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] );
646 646
     		    } else if ( $m['key'] == 'frm_options' ) {
647 647
 
648 648
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
649
-						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
650
-							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
649
+						if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) {
650
+							$m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]];
651 651
     		            }
652 652
     		        }
653 653
 
654 654
                     $check_dup_array = array();
655 655
     		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
656
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
657
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
656
+    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) {
657
+    		                $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']];
658 658
     		            } else if ( is_array( $m['value']['order_by'] ) ) {
659 659
                             $check_dup_array[] = 'order_by';
660 660
     		            }
@@ -665,22 +665,22 @@  discard block
 block discarded – undo
665 665
     		        }
666 666
 
667 667
                     foreach ( $check_dup_array as $check_k ) {
668
-						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
669
-							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
670
-								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
668
+						foreach ( (array) $m['value'][$check_k] as $mk => $mv ) {
669
+							if ( isset( $frm_duplicate_ids[$mv] ) ) {
670
+								$m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv];
671 671
 		                    }
672
-		                    unset($mk, $mv);
672
+		                    unset( $mk, $mv );
673 673
 		                }
674 674
                     }
675 675
     		    }
676 676
 		    }
677 677
 		}
678 678
 
679
-		if ( ! is_array($m['value']) ) {
680
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
679
+		if ( ! is_array( $m['value'] ) ) {
680
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
681 681
 		}
682 682
 
683
-		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
683
+		$post['postmeta'][(string) $meta->meta_key] = $m['value'];
684 684
     }
685 685
 
686 686
     /**
@@ -696,23 +696,23 @@  discard block
 block discarded – undo
696 696
             }
697 697
 
698 698
 		    $taxonomy = (string) $att['domain'];
699
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
699
+		    if ( is_taxonomy_hierarchical( $taxonomy ) ) {
700 700
 		        $name = (string) $att['nicename'];
701
-		        $h_term = get_term_by('slug', $name, $taxonomy);
701
+		        $h_term = get_term_by( 'slug', $name, $taxonomy );
702 702
 		        if ( $h_term ) {
703 703
 		            $name = $h_term->term_id;
704 704
 		        }
705
-		        unset($h_term);
705
+		        unset( $h_term );
706 706
 		    } else {
707 707
 		        $name = (string) $c;
708 708
 		    }
709 709
 
710
-			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
711
-				$post['tax_input'][ $taxonomy ] = array();
710
+			if ( ! isset( $post['tax_input'][$taxonomy] ) ) {
711
+				$post['tax_input'][$taxonomy] = array();
712 712
 			}
713 713
 
714
-			$post['tax_input'][ $taxonomy ][] = $name;
715
-		    unset($name);
714
+			$post['tax_input'][$taxonomy][] = $name;
715
+		    unset( $name );
716 716
 		}
717 717
     }
718 718
 
@@ -729,29 +729,29 @@  discard block
 block discarded – undo
729 729
 
730 730
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
731 731
 		    $match_by['include'] = $post['post_id'];
732
-		    unset($match_by['name']);
732
+		    unset( $match_by['name'] );
733 733
 		}
734 734
 
735
-		$editing = get_posts($match_by);
735
+		$editing = get_posts( $match_by );
736 736
 
737
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
737
+        if ( ! empty( $editing ) && current( $editing )->post_date == $post['post_date'] ) {
738 738
             // set the id of the post to edit
739
-            $post['ID'] = current($editing)->ID;
739
+            $post['ID'] = current( $editing )->ID;
740 740
         }
741 741
     }
742 742
 
743 743
     private static function update_postmeta( &$post, $post_id ) {
744 744
         foreach ( $post['postmeta'] as $k => $v ) {
745 745
             if ( '_edit_last' == $k ) {
746
-                $v = FrmAppHelper::get_user_id_param($v);
746
+                $v = FrmAppHelper::get_user_id_param( $v );
747 747
             } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
748 748
                 //change the attachment ID
749
-                $v = FrmProXMLHelper::get_file_id($v);
749
+                $v = FrmProXMLHelper::get_file_id( $v );
750 750
             }
751 751
 
752
-            update_post_meta($post_id, $k, $v);
752
+            update_post_meta( $post_id, $k, $v );
753 753
 
754
-            unset($k, $v);
754
+            unset( $k, $v );
755 755
         }
756 756
     }
757 757
 
@@ -790,13 +790,13 @@  discard block
 block discarded – undo
790 790
      * @param string $message
791 791
      */
792 792
 	public static function parse_message( $result, &$message, &$errors ) {
793
-        if ( is_wp_error($result) ) {
793
+        if ( is_wp_error( $result ) ) {
794 794
             $errors[] = $result->get_error_message();
795 795
         } else if ( ! $result ) {
796 796
             return;
797 797
         }
798 798
 
799
-        if ( ! is_array($result) ) {
799
+        if ( ! is_array( $result ) ) {
800 800
             $message = is_string( $result ) ? $result : print_r( $result, 1 );
801 801
             return;
802 802
         }
@@ -808,20 +808,20 @@  discard block
 block discarded – undo
808 808
 
809 809
         $message = '<ul>';
810 810
         foreach ( $result as $type => $results ) {
811
-			if ( ! isset( $t_strings[ $type ] ) ) {
811
+			if ( ! isset( $t_strings[$type] ) ) {
812 812
                 // only print imported and updated
813 813
                 continue;
814 814
             }
815 815
 
816 816
             $s_message = array();
817 817
             foreach ( $results as $k => $m ) {
818
-                self::item_count_message($m, $k, $s_message);
819
-                unset($k, $m);
818
+                self::item_count_message( $m, $k, $s_message );
819
+                unset( $k, $m );
820 820
             }
821 821
 
822
-            if ( ! empty($s_message) ) {
823
-				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
824
-                $message .= implode(', ', $s_message);
822
+            if ( ! empty( $s_message ) ) {
823
+				$message .= '<li><strong>' . $t_strings[$type] . ':</strong> ';
824
+                $message .= implode( ', ', $s_message );
825 825
                 $message .= '</li>';
826 826
             }
827 827
         }
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
             'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
851 851
         );
852 852
 
853
-		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
853
+		$s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type );
854 854
     }
855 855
 
856 856
 	/**
@@ -882,14 +882,14 @@  discard block
 block discarded – undo
882 882
 	}
883 883
 
884 884
 	public static function cdata( $str ) {
885
-	    $str = maybe_unserialize($str);
886
-	    if ( is_array($str) ) {
887
-	        $str = json_encode($str);
885
+	    $str = maybe_unserialize( $str );
886
+	    if ( is_array( $str ) ) {
887
+	        $str = json_encode( $str );
888 888
 		} else if ( seems_utf8( $str ) == false ) {
889 889
 			$str = utf8_encode( $str );
890 890
 		}
891 891
 
892
-        if ( is_numeric($str) ) {
892
+        if ( is_numeric( $str ) ) {
893 893
             return $str;
894 894
         }
895 895
 
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
     * @param string $post_type
935 935
     */
936 936
     private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
937
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
937
+        if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) {
938 938
             return;
939 939
         }
940 940
 
@@ -955,10 +955,10 @@  discard block
 block discarded – undo
955 955
         );
956 956
 
957 957
         foreach ( $post_settings as $post_setting ) {
958
-			if ( isset( $form_options[ $post_setting ] ) ) {
959
-				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
958
+			if ( isset( $form_options[$post_setting] ) ) {
959
+				$new_action['post_content'][$post_setting] = $form_options[$post_setting];
960 960
             }
961
-            unset($post_setting);
961
+            unset( $post_setting );
962 962
         }
963 963
 
964 964
 		$new_action['event'] = array( 'create', 'update' );
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
 
973 973
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
974 974
         }
975
-        $new_action['post_content'] = json_encode($new_action['post_content']);
975
+        $new_action['post_content'] = json_encode( $new_action['post_content'] );
976 976
 
977 977
         $exists = get_posts( array(
978 978
             'name'          => $new_action['post_name'],
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
         if ( ! $exists ) {
985 985
 			// this isn't an email, but we need to use a class that will always be included
986 986
 			FrmAppHelper::save_json_post( $new_action );
987
-            $imported['imported']['actions']++;
987
+            $imported['imported']['actions'] ++;
988 988
         }
989 989
     }
990 990
 
@@ -1016,11 +1016,11 @@  discard block
 block discarded – undo
1016 1016
         foreach ( $post_content as $key => $setting ) {
1017 1017
             if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
1018 1018
                 // Replace old IDs with new IDs
1019
-				$post_content[ $key ] = str_replace( $old, $new, $setting );
1019
+				$post_content[$key] = str_replace( $old, $new, $setting );
1020 1020
             } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
1021 1021
                 foreach ( $setting as $k => $val ) {
1022 1022
                     // Replace old IDs with new IDs
1023
-					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
1023
+					$post_content[$key][$k] = str_replace( $old, $new, $val );
1024 1024
                 }
1025 1025
             }
1026 1026
             unset( $key, $setting );
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
         foreach ( $notifications as $new_notification ) {
1051 1051
             $new_notification['post_type']      = $post_type;
1052 1052
             $new_notification['post_excerpt']   = 'email';
1053
-			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
1053
+			$new_notification['post_title'] = __( 'Email Notification', 'formidable' );
1054 1054
             $new_notification['menu_order']     = $form_id;
1055 1055
             $new_notification['post_status']    = 'publish';
1056 1056
 
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
 				// Switch all other field IDs in email
1064 1064
                 $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1065 1065
             }
1066
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1066
+            $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1067 1067
 
1068 1068
             $exists = get_posts( array(
1069 1069
                 'name'          => $new_notification['post_name'],
@@ -1072,11 +1072,11 @@  discard block
 block discarded – undo
1072 1072
                 'numberposts'   => 1,
1073 1073
             ) );
1074 1074
 
1075
-            if ( empty($exists) ) {
1075
+            if ( empty( $exists ) ) {
1076 1076
 				FrmAppHelper::save_json_post( $new_notification );
1077
-                $imported['imported']['actions']++;
1077
+                $imported['imported']['actions'] ++;
1078 1078
             }
1079
-            unset($new_notification);
1079
+            unset( $new_notification );
1080 1080
         }
1081 1081
 
1082 1082
 		self::remove_deprecated_notification_settings( $form_id, $form_options );
@@ -1093,8 +1093,8 @@  discard block
 block discarded – undo
1093 1093
 	private static function remove_deprecated_notification_settings( $form_id, $form_options ) {
1094 1094
 		$delete_settings = array( 'notification', 'autoresponder', 'email_to' );
1095 1095
 		foreach ( $delete_settings as $index ) {
1096
-			if ( isset( $form_options[ $index ] ) ) {
1097
-				unset( $form_options[ $index ] );
1096
+			if ( isset( $form_options[$index] ) ) {
1097
+				unset( $form_options[$index] );
1098 1098
 			}
1099 1099
 		}
1100 1100
 		FrmForm::update( $form_id, array( 'options' => $form_options ) );
@@ -1109,7 +1109,7 @@  discard block
 block discarded – undo
1109 1109
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
1110 1110
         }
1111 1111
 
1112
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1112
+        if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) {
1113 1113
             foreach ( $form_options['notification'] as $email_key => $notification ) {
1114 1114
 
1115 1115
                 $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
@@ -1137,12 +1137,12 @@  discard block
 block discarded – undo
1137 1137
         // Format the reply to email and name
1138 1138
         $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
1139 1139
         foreach ( $reply_fields as $f => $val ) {
1140
-			if ( isset( $notification[ $f ] ) ) {
1141
-				$atts[ $f ] = $notification[ $f ];
1142
-				if ( 'custom' == $notification[ $f ] ) {
1143
-					$atts[ $f ] = $notification[ 'cust_' . $f ];
1144
-				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
1145
-					$atts[ $f ] = '[' . $atts[ $f ] . ']';
1140
+			if ( isset( $notification[$f] ) ) {
1141
+				$atts[$f] = $notification[$f];
1142
+				if ( 'custom' == $notification[$f] ) {
1143
+					$atts[$f] = $notification['cust_' . $f];
1144
+				} else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) {
1145
+					$atts[$f] = '[' . $atts[$f] . ']';
1146 1146
                 }
1147 1147
             }
1148 1148
             unset( $f, $val );
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 		$atts['event'] = array( 'create' );
1153 1153
         if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1154 1154
             $atts['event'][] = 'update';
1155
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1155
+        } else if ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) {
1156 1156
 			$atts['event'] = array( 'update' );
1157 1157
         }
1158 1158
     }
@@ -1173,18 +1173,18 @@  discard block
 block discarded – undo
1173 1173
         foreach ( $atts['email_to'] as $key => $email_field ) {
1174 1174
 
1175 1175
             if ( is_numeric( $email_field ) ) {
1176
-				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1176
+				$atts['email_to'][$key] = '[' . $email_field . ']';
1177 1177
             }
1178 1178
 
1179
-            if ( strpos( $email_field, '|') ) {
1179
+            if ( strpos( $email_field, '|' ) ) {
1180 1180
                 $email_opt = explode( '|', $email_field );
1181 1181
                 if ( isset( $email_opt[0] ) ) {
1182
-					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1182
+					$atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1183 1183
                 }
1184 1184
                 unset( $email_opt );
1185 1185
             }
1186 1186
         }
1187
-        $atts['email_to'] = implode(', ', $atts['email_to']);
1187
+        $atts['email_to'] = implode( ', ', $atts['email_to'] );
1188 1188
     }
1189 1189
 
1190 1190
     private static function setup_new_notification( &$new_notification, $notification, $atts ) {
@@ -1200,12 +1200,12 @@  discard block
 block discarded – undo
1200 1200
         // Add more fields to the new notification
1201 1201
         $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1202 1202
         foreach ( $add_fields as $add_field ) {
1203
-			if ( isset( $notification[ $add_field ] ) ) {
1204
-				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1203
+			if ( isset( $notification[$add_field] ) ) {
1204
+				$new_notification['post_content'][$add_field] = $notification[$add_field];
1205 1205
             } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1206
-				$new_notification['post_content'][ $add_field ] = 0;
1206
+				$new_notification['post_content'][$add_field] = 0;
1207 1207
             } else {
1208
-				$new_notification['post_content'][ $add_field ] = '';
1208
+				$new_notification['post_content'][$add_field] = '';
1209 1209
             }
1210 1210
             unset( $add_field );
1211 1211
         }
@@ -1229,26 +1229,26 @@  discard block
 block discarded – undo
1229 1229
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
1230 1230
 			foreach ( $post_content['conditions'] as $email_key => $val ) {
1231 1231
 				if ( is_numeric( $email_key ) ) {
1232
-					$post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1232
+					$post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1233 1233
 				}
1234
-				unset( $email_key, $val);
1234
+				unset( $email_key, $val );
1235 1235
 			}
1236 1236
 		}
1237 1237
 	}
1238 1238
 
1239 1239
     private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1240
-        if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1240
+        if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) {
1241 1241
             // migrate autoresponder
1242 1242
 
1243
-            $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1244
-            if ( strpos($email_field, '|') ) {
1243
+            $email_field = isset( $form_options['ar_email_to'] ) ? $form_options['ar_email_to'] : 0;
1244
+            if ( strpos( $email_field, '|' ) ) {
1245 1245
                 // data from entries field
1246
-                $email_field = explode('|', $email_field);
1247
-                if ( isset($email_field[1]) ) {
1246
+                $email_field = explode( '|', $email_field );
1247
+                if ( isset( $email_field[1] ) ) {
1248 1248
                     $email_field = $email_field[1];
1249 1249
                 }
1250 1250
             }
1251
-            if ( is_numeric($email_field) && ! empty($email_field) ) {
1251
+            if ( is_numeric( $email_field ) && ! empty( $email_field ) ) {
1252 1252
 				$email_field = '[' . $email_field . ']';
1253 1253
             }
1254 1254
 
@@ -1256,16 +1256,16 @@  discard block
 block discarded – undo
1256 1256
             $new_notification2 = array(
1257 1257
                 'post_content'  => array(
1258 1258
                     'email_message' => $notification['ar_email_message'],
1259
-                    'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1259
+                    'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '',
1260 1260
                     'email_to'      => $email_field,
1261
-                    'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1261
+                    'plain_text'    => isset( $notification['ar_plain_text'] ) ? $notification['ar_plain_text'] : 0,
1262 1262
                     'inc_user_info' => 0,
1263 1263
                 ),
1264 1264
 				'post_name'     => $form_id . '_email_' . count( $notifications ),
1265 1265
             );
1266 1266
 
1267
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1268
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1267
+            $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : '';
1268
+            $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : '';
1269 1269
 
1270 1270
 			if ( ! empty( $reply_to ) ) {
1271 1271
 				$new_notification2['post_content']['reply_to'] = $reply_to;
Please login to merge, or discard this patch.
classes/controllers/FrmEntriesController.php 2 patches
Indentation   +252 added lines, -252 removed lines patch added patch discarded remove patch
@@ -2,70 +2,70 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmEntriesController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		FrmAppHelper::force_capability( 'frm_view_entries' );
7 7
 
8
-        add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
8
+		add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
9 9
 
10 10
 		if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
11 11
 			$menu_name = FrmAppHelper::get_menu_name();
12 12
 			add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' );
13 13
 			add_filter( 'get_user_option_manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' );
14 14
 			add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_sortable_columns', 'FrmEntriesController::sortable_columns' );
15
-        }
16
-    }
15
+		}
16
+	}
17 17
 
18
-    /* Display in Back End */
19
-    public static function route() {
18
+	/* Display in Back End */
19
+	public static function route() {
20 20
 		$action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
21 21
 
22
-        switch ( $action ) {
23
-            case 'show':
24
-            case 'destroy':
25
-            case 'destroy_all':
26
-                return self::$action();
22
+		switch ( $action ) {
23
+			case 'show':
24
+			case 'destroy':
25
+			case 'destroy_all':
26
+				return self::$action();
27 27
 
28
-            default:
29
-                do_action( 'frm_entry_action_route', $action );
30
-                if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
31
-                    return;
32
-                }
28
+			default:
29
+				do_action( 'frm_entry_action_route', $action );
30
+				if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
31
+					return;
32
+				}
33 33
 
34
-                return self::display_list();
35
-        }
36
-    }
34
+				return self::display_list();
35
+		}
36
+	}
37 37
 
38 38
 	public static function contextual_help( $help, $screen_id, $screen ) {
39
-        // Only add to certain screens. add_help_tab was introduced in WordPress 3.3
40
-        if ( ! method_exists( $screen, 'add_help_tab' ) ) {
41
-            return $help;
42
-        }
39
+		// Only add to certain screens. add_help_tab was introduced in WordPress 3.3
40
+		if ( ! method_exists( $screen, 'add_help_tab' ) ) {
41
+			return $help;
42
+		}
43 43
 
44 44
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
45 45
 		$page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
46 46
 		if ( $page != 'formidable-entries' || ( ! empty( $action ) && $action != 'list' ) ) {
47
-            return $help;
48
-        }
47
+			return $help;
48
+		}
49 49
 
50 50
 		unset( $action, $page );
51 51
 
52
-        $screen->add_help_tab( array(
53
-            'id'      => 'formidable-entries-tab',
54
-            'title'   => __( 'Overview', 'formidable' ),
52
+		$screen->add_help_tab( array(
53
+			'id'      => 'formidable-entries-tab',
54
+			'title'   => __( 'Overview', 'formidable' ),
55 55
 			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
56
-        ));
56
+		));
57 57
 
58
-        $screen->set_help_sidebar(
58
+		$screen->set_help_sidebar(
59 59
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
60 60
 			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/knowledgebase/manage-entries-from-the-back-end/' ) ) . '" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' .
61 61
 			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>'
62
-    	);
62
+		);
63 63
 
64
-        return $help;
65
-    }
64
+		return $help;
65
+	}
66 66
 
67 67
 	public static function manage_columns( $columns ) {
68
-        global $frm_vars;
68
+		global $frm_vars;
69 69
 		$form_id = FrmForm::get_current_form_id();
70 70
 
71 71
 		$columns[ $form_id . '_id' ] = 'ID';
@@ -83,15 +83,15 @@  discard block
 block discarded – undo
83 83
 		$columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
84 84
 		self::maybe_add_ip_col( $form_id, $columns );
85 85
 
86
-        $frm_vars['cols'] = $columns;
86
+		$frm_vars['cols'] = $columns;
87 87
 
88 88
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
89 89
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
90 90
 			add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) );
91
-        }
91
+		}
92 92
 
93
-        return $columns;
94
-    }
93
+		return $columns;
94
+	}
95 95
 
96 96
 	private static function get_columns_for_form( $form_id, &$columns ) {
97 97
 		$form_cols = FrmField::get_all_for_form( $form_id, '', 'include' );
@@ -141,76 +141,76 @@  discard block
 block discarded – undo
141 141
 		$menu_name = FrmAppHelper::get_menu_name();
142 142
 		$this_page_name = 'manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden';
143 143
 		if ( $meta_key != $this_page_name || $meta_value == $prev_value ) {
144
-            return $check;
145
-        }
144
+			return $check;
145
+		}
146 146
 
147 147
 		if ( empty( $prev_value ) ) {
148 148
 			$prev_value = get_metadata( 'user', $object_id, $meta_key, true );
149 149
 		}
150 150
 
151
-        global $frm_vars;
152
-        //add a check so we don't create a loop
153
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
151
+		global $frm_vars;
152
+		//add a check so we don't create a loop
153
+		$frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
154 154
 
155
-        return $check;
156
-    }
155
+		return $check;
156
+	}
157 157
 
158
-    //add hidden columns back from other forms
158
+	//add hidden columns back from other forms
159 159
 	public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
160 160
 		$menu_name = FrmAppHelper::get_menu_name();
161 161
 		$sanitized = sanitize_title( $menu_name );
162 162
 		$this_page_name = 'manage' . $sanitized . '_page_formidable-entriescolumnshidden';
163 163
 		if ( $meta_key != $this_page_name ) {
164
-            return;
165
-        }
166
-
167
-        global $frm_vars;
168
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
169
-            return; //don't continue if there's no previous value
170
-        }
171
-
172
-        foreach ( $meta_value as $mk => $mv ) {
173
-            //remove blank values
174
-            if ( empty( $mv ) ) {
175
-                unset( $meta_value[ $mk ] );
176
-            }
177
-        }
178
-
179
-        $cur_form_prefix = reset($meta_value);
180
-        $cur_form_prefix = explode('_', $cur_form_prefix);
181
-        $cur_form_prefix = $cur_form_prefix[0];
182
-        $save = false;
183
-
184
-        foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
164
+			return;
165
+		}
166
+
167
+		global $frm_vars;
168
+		if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
169
+			return; //don't continue if there's no previous value
170
+		}
171
+
172
+		foreach ( $meta_value as $mk => $mv ) {
173
+			//remove blank values
174
+			if ( empty( $mv ) ) {
175
+				unset( $meta_value[ $mk ] );
176
+			}
177
+		}
178
+
179
+		$cur_form_prefix = reset($meta_value);
180
+		$cur_form_prefix = explode('_', $cur_form_prefix);
181
+		$cur_form_prefix = $cur_form_prefix[0];
182
+		$save = false;
183
+
184
+		foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
185 185
 			if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) {
186
-                //don't add blank cols or process included cols
187
-                continue;
188
-            }
186
+				//don't add blank cols or process included cols
187
+				continue;
188
+			}
189 189
 
190 190
 			$form_prefix = explode( '_', $prev_hidden );
191
-            $form_prefix = $form_prefix[0];
192
-            if ( $form_prefix == $cur_form_prefix ) {
193
-                //don't add back columns that are meant to be hidden
194
-                continue;
195
-            }
191
+			$form_prefix = $form_prefix[0];
192
+			if ( $form_prefix == $cur_form_prefix ) {
193
+				//don't add back columns that are meant to be hidden
194
+				continue;
195
+			}
196 196
 
197
-            $meta_value[] = $prev_hidden;
198
-            $save = true;
199
-            unset($form_prefix);
200
-        }
197
+			$meta_value[] = $prev_hidden;
198
+			$save = true;
199
+			unset($form_prefix);
200
+		}
201 201
 
202 202
 		if ( $save ) {
203
-            $user = wp_get_current_user();
203
+			$user = wp_get_current_user();
204 204
 			update_user_option( $user->ID, $this_page_name, $meta_value, true );
205
-        }
206
-    }
205
+		}
206
+	}
207 207
 
208 208
 	public static function save_per_page( $save, $option, $value ) {
209
-        if ( $option == 'formidable_page_formidable_entries_per_page' ) {
210
-            $save = (int) $value;
211
-        }
212
-        return $save;
213
-    }
209
+		if ( $option == 'formidable_page_formidable_entries_per_page' ) {
210
+			$save = (int) $value;
211
+		}
212
+		return $save;
213
+	}
214 214
 
215 215
 	public static function sortable_columns() {
216 216
 		$form_id = FrmForm::get_current_form_id();
@@ -236,46 +236,46 @@  discard block
 block discarded – undo
236 236
 	}
237 237
 
238 238
 	public static function hidden_columns( $result ) {
239
-        global $frm_vars;
239
+		global $frm_vars;
240 240
 
241 241
 		$form_id = FrmForm::get_current_form_id();
242 242
 
243
-        $return = false;
244
-        foreach ( (array) $result as $r ) {
245
-            if ( ! empty( $r ) ) {
246
-                $form_prefix = explode( '_', $r );
247
-                $form_prefix = $form_prefix[0];
243
+		$return = false;
244
+		foreach ( (array) $result as $r ) {
245
+			if ( ! empty( $r ) ) {
246
+				$form_prefix = explode( '_', $r );
247
+				$form_prefix = $form_prefix[0];
248 248
 
249
-                if ( (int) $form_prefix == (int) $form_id ) {
250
-                    $return = true;
251
-                    break;
252
-                }
249
+				if ( (int) $form_prefix == (int) $form_id ) {
250
+					$return = true;
251
+					break;
252
+				}
253 253
 
254
-                unset($form_prefix);
255
-            }
256
-        }
254
+				unset($form_prefix);
255
+			}
256
+		}
257 257
 
258
-        if ( $return ) {
258
+		if ( $return ) {
259 259
 			return $result;
260 260
 		}
261 261
 
262
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
263
-        $max_columns = 8;
264
-        if ( $i <= $max_columns ) {
262
+		$i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
263
+		$max_columns = 8;
264
+		if ( $i <= $max_columns ) {
265 265
 			return $result;
266 266
 		}
267 267
 
268
-        global $frm_vars;
269
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
270
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
271
-        }
268
+		global $frm_vars;
269
+		if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
270
+			$frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
271
+		}
272 272
 
273 273
 		$has_custom_hidden_columns = ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) );
274 274
 		if ( $has_custom_hidden_columns ) {
275
-            $result = $frm_vars['current_form']->options['hidden_cols'];
276
-        } else {
277
-            $cols = $frm_vars['cols'];
278
-            $cols = array_reverse($cols, true);
275
+			$result = $frm_vars['current_form']->options['hidden_cols'];
276
+		} else {
277
+			$cols = $frm_vars['cols'];
278
+			$cols = array_reverse($cols, true);
279 279
 
280 280
 			if ( $form_id ) {
281 281
 				$result[] = $form_id . '_id';
@@ -283,59 +283,59 @@  discard block
 block discarded – undo
283 283
 			}
284 284
 
285 285
 			$result[] = $form_id . '_item_key';
286
-            $i--;
286
+			$i--;
287 287
 
288 288
 			foreach ( $cols as $col_key => $col ) {
289
-                if ( $i > $max_columns ) {
289
+				if ( $i > $max_columns ) {
290 290
 					$result[] = $col_key;
291 291
 				}
292
-                //remove some columns by default
293
-                $i--;
294
-                unset($col_key, $col);
295
-            }
296
-        }
292
+				//remove some columns by default
293
+				$i--;
294
+				unset($col_key, $col);
295
+			}
296
+		}
297 297
 
298
-        return $result;
299
-    }
298
+		return $result;
299
+	}
300 300
 
301 301
 	public static function display_list( $message = '', $errors = array() ) {
302
-        global $wpdb, $frm_vars;
302
+		global $wpdb, $frm_vars;
303 303
 
304 304
 		$form = FrmForm::maybe_get_current_form();
305 305
 		$params = FrmForm::get_admin_params( $form );
306 306
 
307
-        if ( $form ) {
308
-            $params['form'] = $form->id;
309
-            $frm_vars['current_form'] = $form;
307
+		if ( $form ) {
308
+			$params['form'] = $form->id;
309
+			$frm_vars['current_form'] = $form;
310 310
 
311 311
 			self::get_delete_form_time( $form, $errors );
312 312
 		}
313 313
 
314
-        $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
314
+		$table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
315 315
 
316
-        $wp_list_table = new $table_class( array( 'params' => $params ) );
316
+		$wp_list_table = new $table_class( array( 'params' => $params ) );
317 317
 
318
-        $pagenum = $wp_list_table->get_pagenum();
318
+		$pagenum = $wp_list_table->get_pagenum();
319 319
 
320
-        $wp_list_table->prepare_items();
320
+		$wp_list_table->prepare_items();
321 321
 
322
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
323
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
322
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
323
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
324 324
 			$url = add_query_arg( 'paged', $total_pages );
325
-            if ( headers_sent() ) {
326
-                echo FrmAppHelper::js_redirect($url);
327
-            } else {
328
-                wp_redirect( esc_url_raw( $url ) );
329
-            }
330
-            die();
331
-        }
332
-
333
-        if ( empty($message) && isset($_GET['import-message']) ) {
334
-            $message = __( 'Your import is complete', 'formidable' );
335
-        }
325
+			if ( headers_sent() ) {
326
+				echo FrmAppHelper::js_redirect($url);
327
+			} else {
328
+				wp_redirect( esc_url_raw( $url ) );
329
+			}
330
+			die();
331
+		}
332
+
333
+		if ( empty($message) && isset($_GET['import-message']) ) {
334
+			$message = __( 'Your import is complete', 'formidable' );
335
+		}
336 336
 
337 337
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' );
338
-    }
338
+	}
339 339
 
340 340
 	private static function get_delete_form_time( $form, &$errors ) {
341 341
 		if ( 'trash' == $form->status ) {
@@ -345,19 +345,19 @@  discard block
 block discarded – undo
345 345
 		}
346 346
 	}
347 347
 
348
-    /* Back End CRUD */
348
+	/* Back End CRUD */
349 349
 	public static function show( $id = 0 ) {
350
-        FrmAppHelper::permission_check('frm_view_entries');
350
+		FrmAppHelper::permission_check('frm_view_entries');
351 351
 
352
-        if ( ! $id ) {
352
+		if ( ! $id ) {
353 353
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
354 354
 
355
-            if ( ! $id ) {
355
+			if ( ! $id ) {
356 356
 				$id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' );
357
-            }
358
-        }
357
+			}
358
+		}
359 359
 
360
-        $entry = FrmEntry::getOne($id, true);
360
+		$entry = FrmEntry::getOne($id, true);
361 361
 		if ( ! $entry ) {
362 362
 			echo '<div id="form_show_entry_page" class="wrap">' .
363 363
 				__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
@@ -365,110 +365,110 @@  discard block
 block discarded – undo
365 365
 			return;
366 366
 		}
367 367
 
368
-        $data = maybe_unserialize($entry->description);
368
+		$data = maybe_unserialize($entry->description);
369 369
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
370 370
 			$data = array( 'referrer' => $data );
371 371
 		}
372 372
 
373 373
 		$fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
374
-        $to_emails = array();
374
+		$to_emails = array();
375 375
 
376 376
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' );
377
-    }
377
+	}
378 378
 
379
-    public static function destroy() {
380
-        FrmAppHelper::permission_check('frm_delete_entries');
379
+	public static function destroy() {
380
+		FrmAppHelper::permission_check('frm_delete_entries');
381 381
 
382 382
 		$params = FrmForm::get_admin_params();
383 383
 
384
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
385
-            //unlink entry from post
386
-            global $wpdb;
384
+		if ( isset($params['keep_post']) && $params['keep_post'] ) {
385
+			//unlink entry from post
386
+			global $wpdb;
387 387
 			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
388
-        }
388
+		}
389 389
 
390
-        $message = '';
391
-        if ( FrmEntry::destroy( $params['id'] ) ) {
392
-            $message = __( 'Entry was Successfully Destroyed', 'formidable' );
393
-        }
390
+		$message = '';
391
+		if ( FrmEntry::destroy( $params['id'] ) ) {
392
+			$message = __( 'Entry was Successfully Destroyed', 'formidable' );
393
+		}
394 394
 
395
-        self::display_list( $message );
396
-    }
395
+		self::display_list( $message );
396
+	}
397 397
 
398
-    public static function destroy_all() {
399
-        if ( ! current_user_can( 'frm_delete_entries' ) ) {
400
-            $frm_settings = FrmAppHelper::get_settings();
401
-            wp_die( $frm_settings->admin_permission );
402
-        }
398
+	public static function destroy_all() {
399
+		if ( ! current_user_can( 'frm_delete_entries' ) ) {
400
+			$frm_settings = FrmAppHelper::get_settings();
401
+			wp_die( $frm_settings->admin_permission );
402
+		}
403 403
 
404
-        global $wpdb;
404
+		global $wpdb;
405 405
 		$params = FrmForm::get_admin_params();
406
-        $message = '';
407
-        $errors = array();
408
-        $form_id = (int) $params['form'];
406
+		$message = '';
407
+		$errors = array();
408
+		$form_id = (int) $params['form'];
409 409
 
410
-        if ( $form_id ) {
411
-            $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
410
+		if ( $form_id ) {
411
+			$entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
412 412
 			$action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 );
413 413
 
414
-            if ( $action ) {
415
-                // this action takes a while, so only trigger it if there are posts to delete
416
-                foreach ( $entry_ids as $entry_id ) {
417
-                    do_action( 'frm_before_destroy_entry', $entry_id );
418
-                    unset( $entry_id );
419
-                }
420
-            }
421
-
422
-            $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) );
423
-            $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
424
-            if ( $results ) {
414
+			if ( $action ) {
415
+				// this action takes a while, so only trigger it if there are posts to delete
416
+				foreach ( $entry_ids as $entry_id ) {
417
+					do_action( 'frm_before_destroy_entry', $entry_id );
418
+					unset( $entry_id );
419
+				}
420
+			}
421
+
422
+			$wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) );
423
+			$results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
424
+			if ( $results ) {
425 425
 				FrmEntry::clear_cache();
426
-                $message = __( 'Entries were Successfully Destroyed', 'formidable' );
427
-            }
428
-        } else {
429
-            $errors = __( 'No entries were specified', 'formidable' );
430
-        }
431
-
432
-        self::display_list( $message, $errors );
433
-    }
434
-
435
-    public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
436
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
437
-        return FrmFormsController::show_form( $id, $key, $title, $description );
438
-    }
439
-
440
-    public static function get_form( $filename, $form, $title, $description ) {
441
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
442
-        return FrmFormsController::get_form( $form, $title, $description );
443
-    }
444
-
445
-    public static function process_entry( $errors = '', $ajax = false ) {
426
+				$message = __( 'Entries were Successfully Destroyed', 'formidable' );
427
+			}
428
+		} else {
429
+			$errors = __( 'No entries were specified', 'formidable' );
430
+		}
431
+
432
+		self::display_list( $message, $errors );
433
+	}
434
+
435
+	public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
436
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
437
+		return FrmFormsController::show_form( $id, $key, $title, $description );
438
+	}
439
+
440
+	public static function get_form( $filename, $form, $title, $description ) {
441
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
442
+		return FrmFormsController::get_form( $form, $title, $description );
443
+	}
444
+
445
+	public static function process_entry( $errors = '', $ajax = false ) {
446 446
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
447 447
 		if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) {
448
-            return;
449
-        }
448
+			return;
449
+		}
450 450
 
451
-        global $frm_vars;
451
+		global $frm_vars;
452 452
 
453 453
 		$form = FrmForm::getOne( $form_id );
454
-        if ( ! $form ) {
455
-            return;
456
-        }
454
+		if ( ! $form ) {
455
+			return;
456
+		}
457 457
 
458 458
 		$params = FrmForm::get_params( $form );
459 459
 
460
-        if ( ! isset( $frm_vars['form_params'] ) ) {
461
-            $frm_vars['form_params'] = array();
462
-        }
460
+		if ( ! isset( $frm_vars['form_params'] ) ) {
461
+			$frm_vars['form_params'] = array();
462
+		}
463 463
 		$frm_vars['form_params'][ $form->id ] = $params;
464 464
 
465 465
 		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
466
-            return;
467
-        }
466
+			return;
467
+		}
468 468
 
469
-        if ( $errors == '' && ! $ajax ) {
469
+		if ( $errors == '' && ! $ajax ) {
470 470
 			$errors = FrmEntryValidate::validate( $_POST );
471
-        }
471
+		}
472 472
 
473 473
 		/**
474 474
 		 * Use this filter to add trigger actions and add errors after
@@ -479,39 +479,39 @@  discard block
 block discarded – undo
479 479
 
480 480
 		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
481 481
 
482
-        if ( empty( $errors ) ) {
482
+		if ( empty( $errors ) ) {
483 483
 			$_POST['frm_skip_cookie'] = 1;
484
-            if ( $params['action'] == 'create' ) {
484
+			if ( $params['action'] == 'create' ) {
485 485
 				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
486 486
 					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
487
-                }
488
-            }
487
+				}
488
+			}
489 489
 
490
-            do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
490
+			do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
491 491
 			unset( $_POST['frm_skip_cookie'] );
492
-        }
493
-    }
494
-
495
-    public static function delete_entry_before_redirect( $url, $form, $atts ) {
496
-        self::_delete_entry( $atts['id'], $form );
497
-        return $url;
498
-    }
499
-
500
-    //Delete entry if not redirected
501
-    public static function delete_entry_after_save( $atts ) {
502
-        self::_delete_entry( $atts['entry_id'], $atts['form'] );
503
-    }
504
-
505
-    private static function _delete_entry( $entry_id, $form ) {
506
-        if ( ! $form ) {
507
-            return;
508
-        }
509
-
510
-        $form->options = maybe_unserialize( $form->options );
511
-        if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
512
-            FrmEntry::destroy( $entry_id );
513
-        }
514
-    }
492
+		}
493
+	}
494
+
495
+	public static function delete_entry_before_redirect( $url, $form, $atts ) {
496
+		self::_delete_entry( $atts['id'], $form );
497
+		return $url;
498
+	}
499
+
500
+	//Delete entry if not redirected
501
+	public static function delete_entry_after_save( $atts ) {
502
+		self::_delete_entry( $atts['entry_id'], $atts['form'] );
503
+	}
504
+
505
+	private static function _delete_entry( $entry_id, $form ) {
506
+		if ( ! $form ) {
507
+			return;
508
+		}
509
+
510
+		$form->options = maybe_unserialize( $form->options );
511
+		if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
512
+			FrmEntry::destroy( $entry_id );
513
+		}
514
+	}
515 515
 
516 516
 	/**
517 517
 	 * @param $atts
@@ -566,15 +566,15 @@  discard block
 block discarded – undo
566 566
 	}
567 567
 
568 568
 	public static function entry_sidebar( $entry ) {
569
-        $data = maybe_unserialize($entry->description);
570
-        $date_format = get_option('date_format');
571
-        $time_format = get_option('time_format');
569
+		$data = maybe_unserialize($entry->description);
570
+		$date_format = get_option('date_format');
571
+		$time_format = get_option('time_format');
572 572
 		if ( isset( $data['browser'] ) ) {
573 573
 			$browser = FrmEntriesHelper::get_browser( $data['browser'] );
574 574
 		}
575 575
 
576 576
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
577
-    }
577
+	}
578 578
 
579 579
 	/***********************************************************************
580 580
 	 * Deprecated Functions
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
     public static function menu() {
6 6
 		FrmAppHelper::force_capability( 'frm_view_entries' );
7 7
 
8
-        add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
8
+        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
9 9
 
10 10
 		if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
11 11
 			$menu_name = FrmAppHelper::get_menu_name();
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
             'id'      => 'formidable-entries-tab',
54 54
             'title'   => __( 'Overview', 'formidable' ),
55 55
 			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
56
-        ));
56
+        ) );
57 57
 
58 58
         $screen->set_help_sidebar(
59 59
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
@@ -68,19 +68,19 @@  discard block
 block discarded – undo
68 68
         global $frm_vars;
69 69
 		$form_id = FrmForm::get_current_form_id();
70 70
 
71
-		$columns[ $form_id . '_id' ] = 'ID';
72
-		$columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
71
+		$columns[$form_id . '_id'] = 'ID';
72
+		$columns[$form_id . '_item_key'] = esc_html__( 'Entry Key', 'formidable' );
73 73
 
74 74
 		if ( $form_id ) {
75 75
 			self::get_columns_for_form( $form_id, $columns );
76 76
 		} else {
77
-			$columns[ $form_id . '_form_id' ] = __( 'Form', 'formidable' );
78
-			$columns[ $form_id . '_name' ] = __( 'Entry Name', 'formidable' );
79
-			$columns[ $form_id . '_user_id' ] = __( 'Created By', 'formidable' );
77
+			$columns[$form_id . '_form_id'] = __( 'Form', 'formidable' );
78
+			$columns[$form_id . '_name'] = __( 'Entry Name', 'formidable' );
79
+			$columns[$form_id . '_user_id'] = __( 'Created By', 'formidable' );
80 80
 		}
81 81
 
82
-		$columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' );
83
-		$columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
82
+		$columns[$form_id . '_created_at'] = __( 'Entry creation date', 'formidable' );
83
+		$columns[$form_id . '_updated_at'] = __( 'Entry update date', 'formidable' );
84 84
 		self::maybe_add_ip_col( $form_id, $columns );
85 85
 
86 86
         $frm_vars['cols'] = $columns;
@@ -107,14 +107,14 @@  discard block
 block discarded – undo
107 107
 				if ( $sub_form_cols ) {
108 108
 					foreach ( $sub_form_cols as $k => $sub_form_col ) {
109 109
 						if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
110
-							unset( $sub_form_cols[ $k ] );
110
+							unset( $sub_form_cols[$k] );
111 111
 							continue;
112 112
 						}
113
-						$columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
114
-						unset($sub_form_col);
113
+						$columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
114
+						unset( $sub_form_col );
115 115
 					}
116 116
 				}
117
-				unset($sub_form_cols);
117
+				unset( $sub_form_cols );
118 118
 			} else {
119 119
 				$col_id = $form_col->field_key;
120 120
 				if ( $form_col->form_id != $form_id ) {
@@ -124,16 +124,16 @@  discard block
 block discarded – undo
124 124
 				$has_separate_value = ! FrmField::is_option_empty( $form_col, 'separate_value' );
125 125
 				$is_post_status     = FrmField::is_option_true( $form_col, 'post_field' ) && $form_col->field_options['post_field'] == 'post_status';
126 126
 				if ( $has_separate_value && ! $is_post_status ) {
127
-					$columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
127
+					$columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
128 128
 				}
129
-				$columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
129
+				$columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
130 130
 			}
131 131
 		}
132 132
 	}
133 133
 
134 134
 	private static function maybe_add_ip_col( $form_id, &$columns ) {
135 135
 		if ( FrmAppHelper::ips_saved() ) {
136
-			$columns[ $form_id . '_ip' ] = 'IP';
136
+			$columns[$form_id . '_ip'] = 'IP';
137 137
 		}
138 138
 	}
139 139
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 
151 151
         global $frm_vars;
152 152
         //add a check so we don't create a loop
153
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
153
+        $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
154 154
 
155 155
         return $check;
156 156
     }
@@ -165,19 +165,19 @@  discard block
 block discarded – undo
165 165
         }
166 166
 
167 167
         global $frm_vars;
168
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
168
+        if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
169 169
             return; //don't continue if there's no previous value
170 170
         }
171 171
 
172 172
         foreach ( $meta_value as $mk => $mv ) {
173 173
             //remove blank values
174 174
             if ( empty( $mv ) ) {
175
-                unset( $meta_value[ $mk ] );
175
+                unset( $meta_value[$mk] );
176 176
             }
177 177
         }
178 178
 
179
-        $cur_form_prefix = reset($meta_value);
180
-        $cur_form_prefix = explode('_', $cur_form_prefix);
179
+        $cur_form_prefix = reset( $meta_value );
180
+        $cur_form_prefix = explode( '_', $cur_form_prefix );
181 181
         $cur_form_prefix = $cur_form_prefix[0];
182 182
         $save = false;
183 183
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 
197 197
             $meta_value[] = $prev_hidden;
198 198
             $save = true;
199
-            unset($form_prefix);
199
+            unset( $form_prefix );
200 200
         }
201 201
 
202 202
 		if ( $save ) {
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 		foreach ( $fields as $field ) {
229 229
 			if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) {
230 230
 				// Can't sort on checkboxes because they are stored serialized, or post fields
231
-				$columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
231
+				$columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id;
232 232
 			}
233 233
 		}
234 234
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
                     break;
252 252
                 }
253 253
 
254
-                unset($form_prefix);
254
+                unset( $form_prefix );
255 255
             }
256 256
         }
257 257
 
@@ -259,15 +259,15 @@  discard block
 block discarded – undo
259 259
 			return $result;
260 260
 		}
261 261
 
262
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
262
+        $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
263 263
         $max_columns = 8;
264 264
         if ( $i <= $max_columns ) {
265 265
 			return $result;
266 266
 		}
267 267
 
268 268
         global $frm_vars;
269
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
270
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
269
+        if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] ) {
270
+            $frm_vars['current_form']->options = maybe_unserialize( $frm_vars['current_form']->options );
271 271
         }
272 272
 
273 273
 		$has_custom_hidden_columns = ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) );
@@ -275,23 +275,23 @@  discard block
 block discarded – undo
275 275
             $result = $frm_vars['current_form']->options['hidden_cols'];
276 276
         } else {
277 277
             $cols = $frm_vars['cols'];
278
-            $cols = array_reverse($cols, true);
278
+            $cols = array_reverse( $cols, true );
279 279
 
280 280
 			if ( $form_id ) {
281 281
 				$result[] = $form_id . '_id';
282
-				$i--;
282
+				$i --;
283 283
 			}
284 284
 
285 285
 			$result[] = $form_id . '_item_key';
286
-            $i--;
286
+            $i --;
287 287
 
288 288
 			foreach ( $cols as $col_key => $col ) {
289 289
                 if ( $i > $max_columns ) {
290 290
 					$result[] = $col_key;
291 291
 				}
292 292
                 //remove some columns by default
293
-                $i--;
294
-                unset($col_key, $col);
293
+                $i --;
294
+                unset( $col_key, $col );
295 295
             }
296 296
         }
297 297
 
@@ -323,14 +323,14 @@  discard block
 block discarded – undo
323 323
         if ( $pagenum > $total_pages && $total_pages > 0 ) {
324 324
 			$url = add_query_arg( 'paged', $total_pages );
325 325
             if ( headers_sent() ) {
326
-                echo FrmAppHelper::js_redirect($url);
326
+                echo FrmAppHelper::js_redirect( $url );
327 327
             } else {
328 328
                 wp_redirect( esc_url_raw( $url ) );
329 329
             }
330 330
             die();
331 331
         }
332 332
 
333
-        if ( empty($message) && isset($_GET['import-message']) ) {
333
+        if ( empty( $message ) && isset( $_GET['import-message'] ) ) {
334 334
             $message = __( 'Your import is complete', 'formidable' );
335 335
         }
336 336
 
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 
348 348
     /* Back End CRUD */
349 349
 	public static function show( $id = 0 ) {
350
-        FrmAppHelper::permission_check('frm_view_entries');
350
+        FrmAppHelper::permission_check( 'frm_view_entries' );
351 351
 
352 352
         if ( ! $id ) {
353 353
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
             }
358 358
         }
359 359
 
360
-        $entry = FrmEntry::getOne($id, true);
360
+        $entry = FrmEntry::getOne( $id, true );
361 361
 		if ( ! $entry ) {
362 362
 			echo '<div id="form_show_entry_page" class="wrap">' .
363 363
 				__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 			return;
366 366
 		}
367 367
 
368
-        $data = maybe_unserialize($entry->description);
368
+        $data = maybe_unserialize( $entry->description );
369 369
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
370 370
 			$data = array( 'referrer' => $data );
371 371
 		}
@@ -377,11 +377,11 @@  discard block
 block discarded – undo
377 377
     }
378 378
 
379 379
     public static function destroy() {
380
-        FrmAppHelper::permission_check('frm_delete_entries');
380
+        FrmAppHelper::permission_check( 'frm_delete_entries' );
381 381
 
382 382
 		$params = FrmForm::get_admin_params();
383 383
 
384
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
384
+        if ( isset( $params['keep_post'] ) && $params['keep_post'] ) {
385 385
             //unlink entry from post
386 386
             global $wpdb;
387 387
 			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
@@ -460,9 +460,9 @@  discard block
 block discarded – undo
460 460
         if ( ! isset( $frm_vars['form_params'] ) ) {
461 461
             $frm_vars['form_params'] = array();
462 462
         }
463
-		$frm_vars['form_params'][ $form->id ] = $params;
463
+		$frm_vars['form_params'][$form->id] = $params;
464 464
 
465
-		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
465
+		if ( isset( $frm_vars['created_entries'][$form_id] ) ) {
466 466
             return;
467 467
         }
468 468
 
@@ -477,13 +477,13 @@  discard block
 block discarded – undo
477 477
 		 */
478 478
 		$errors = apply_filters( 'frm_entries_before_create', $errors, $form );
479 479
 
480
-		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
480
+		$frm_vars['created_entries'][$form_id] = array( 'errors' => $errors );
481 481
 
482 482
         if ( empty( $errors ) ) {
483 483
 			$_POST['frm_skip_cookie'] = 1;
484 484
             if ( $params['action'] == 'create' ) {
485
-				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
486
-					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
485
+				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) {
486
+					$frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST );
487 487
                 }
488 488
             }
489 489
 
@@ -566,9 +566,9 @@  discard block
 block discarded – undo
566 566
 	}
567 567
 
568 568
 	public static function entry_sidebar( $entry ) {
569
-        $data = maybe_unserialize($entry->description);
570
-        $date_format = get_option('date_format');
571
-        $time_format = get_option('time_format');
569
+        $data = maybe_unserialize( $entry->description );
570
+        $date_format = get_option( 'date_format' );
571
+        $time_format = get_option( 'time_format' );
572 572
 		if ( isset( $data['browser'] ) ) {
573 573
 			$browser = FrmEntriesHelper::get_browser( $data['browser'] );
574 574
 		}
Please login to merge, or discard this patch.
classes/models/FrmEntryFormatter.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -375,10 +375,10 @@  discard block
 block discarded – undo
375 375
 		if ( $this->include_field_in_content( $field_value ) ) {
376 376
 
377 377
 			$displayed_value = $this->prepare_display_value_for_array( $field_value->get_displayed_value() );
378
-			$output[ $this->get_key_or_id( $field_value ) ] = $displayed_value;
378
+			$output[$this->get_key_or_id( $field_value )] = $displayed_value;
379 379
 
380 380
 			if ( $displayed_value !== $field_value->get_saved_value() ) {
381
-				$output[ $this->get_key_or_id( $field_value ) . '-value' ] = $field_value->get_saved_value();
381
+				$output[$this->get_key_or_id( $field_value ) . '-value'] = $field_value->get_saved_value();
382 382
 			}
383 383
 		}
384 384
 	}
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
 
634 634
 			if ( is_array( $value ) ) {
635 635
 				foreach ( $value as $key => $single_value ) {
636
-					$value[ $key ] = $this->strip_html( $single_value );
636
+					$value[$key] = $this->strip_html( $single_value );
637 637
 				}
638 638
 			} else if ( $this->is_plain_text && ! is_array( $value ) ) {
639 639
 				if ( strpos( $value, '<img' ) !== false ) {
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 	 *
364 364
 	 * @since 2.04
365 365
 	 *
366
-	 * @param array $field_values
366
+	 * @param FrmFieldValue[] $field_values
367 367
 	 * @param array $output
368 368
 	 */
369 369
 	protected function push_field_values_to_array( $field_values, &$output ) {
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 	 *
571 571
 	 * @param mixed $value
572 572
 	 *
573
-	 * @return mixed|string
573
+	 * @return FrmFieldValue
574 574
 	 */
575 575
 	protected function prepare_display_value_for_array( $value ) {
576 576
 		return $this->strip_html( $value );
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 	 * @param mixed $display_value
586 586
 	 * @param string $field_type
587 587
 	 *
588
-	 * @return mixed|string
588
+	 * @return string
589 589
 	 */
590 590
 	protected function prepare_display_value_for_html_table( $display_value, $field_type = '' ) {
591 591
 		$display_value = $this->flatten_array( $display_value );
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesListHelper.php 2 patches
Indentation   +44 added lines, -44 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
 		$default_orderby = 'id';
15 15
 		$default_order = 'DESC';
@@ -25,27 +25,27 @@  discard block
 block discarded – undo
25 25
 
26 26
 		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
27 27
 
28
-	    if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
29
-	        $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
30
-	        $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid );
31
-	    }
28
+		if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
29
+			$fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
30
+			$s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid );
31
+		}
32 32
 
33 33
 		$s_query = apply_filters( 'frm_entries_list_query', $s_query, compact( 'form_id' ) );
34 34
 
35
-        $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
36
-        if ( strpos($orderby, 'meta') !== false ) {
37
-            $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
35
+		$orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
36
+		if ( strpos($orderby, 'meta') !== false ) {
37
+			$order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
38 38
 			$orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : '';
39
-        }
39
+		}
40 40
 
41 41
 		$order = isset( $_REQUEST['order'] ) ? sanitize_title( $_REQUEST['order'] ) : $default_order;
42 42
 		$order = ' ORDER BY ' . $orderby . ' ' . $order;
43 43
 
44
-        $page = $this->get_pagenum();
44
+		$page = $this->get_pagenum();
45 45
 		$start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page );
46 46
 
47 47
 		$this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, $join_form_in_query );
48
-        $total_items = FrmEntry::getRecordCount($s_query);
48
+		$total_items = FrmEntry::getRecordCount($s_query);
49 49
 
50 50
 		$this->set_pagination_args( array(
51 51
 			'total_items' => $total_items,
@@ -54,19 +54,19 @@  discard block
 block discarded – undo
54 54
 	}
55 55
 
56 56
 	public function no_items() {
57
-        $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
58
-	    if ( ! empty($s) ) {
59
-            _e( 'No Entries Found', 'formidable' );
60
-            return;
61
-        }
57
+		$s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
58
+		if ( ! empty($s) ) {
59
+			_e( 'No Entries Found', 'formidable' );
60
+			return;
61
+		}
62 62
 
63 63
 		$form_id = $this->params['form'];
64 64
 		$form = $this->params['form'];
65 65
 
66
-        if ( $form_id ) {
67
-            $form = FrmForm::getOne($form_id);
68
-        }
69
-        $colspan = $this->get_column_count();
66
+		if ( $form_id ) {
67
+			$form = FrmForm::getOne($form_id);
68
+		}
69
+		$colspan = $this->get_column_count();
70 70
 
71 71
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' );
72 72
 	}
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
 	}
87 87
 
88 88
 	/**
89
-	* Gets the name of the primary column in the Entries screen
90
-	*
91
-	* @since 2.0.14
92
-	*
93
-	* @return string $primary_column
94
-	*/
89
+	 * Gets the name of the primary column in the Entries screen
90
+	 *
91
+	 * @since 2.0.14
92
+	 *
93
+	 * @return string $primary_column
94
+	 */
95 95
 	protected function get_primary_column_name() {
96 96
 		$columns = get_column_headers( $this->screen );
97 97
 		$hidden = get_hidden_columns( $this->screen );
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 
116 116
 		$this->get_actions( $actions, $item, $view_link );
117 117
 
118
-        $action_links = $this->row_actions( $actions );
118
+		$action_links = $this->row_actions( $actions );
119 119
 
120 120
 		// Set up the checkbox ( because the user is editable, otherwise its empty )
121 121
 		$checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />";
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 		$r = "<tr id='item-action-{$item->id}'$style>";
124 124
 
125 125
 		list( $columns, $hidden, , $primary ) = $this->get_column_info();
126
-        $action_col = false;
126
+		$action_col = false;
127 127
 
128 128
 		foreach ( $columns as $column_name => $column_display_name ) {
129 129
 			$class = $column_name . ' column-' . $column_name;
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
 			if ( in_array( $column_name, $hidden ) ) {
136 136
 				$class .= ' frm_hidden';
137 137
 			} else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) {
138
-			    $action_col = $column_name;
139
-            }
138
+				$action_col = $column_name;
139
+			}
140 140
 
141 141
 			$attributes = 'class="' . esc_attr( $class ) . '"';
142 142
 			unset($class);
@@ -154,15 +154,15 @@  discard block
 block discarded – undo
154 154
 					$val = $this->column_value( $item );
155 155
 				}
156 156
 
157
-			    $r .= "<td $attributes>";
157
+				$r .= "<td $attributes>";
158 158
 				if ( $column_name == $action_col ) {
159 159
 					$edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id;
160 160
 					$r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
161
-			        $r .= $action_links;
161
+					$r .= $action_links;
162 162
 				} else {
163
-			        $r .= $val;
164
-			    }
165
-			    $r .= '</td>';
163
+					$r .= $val;
164
+				}
165
+				$r .= '</td>';
166 166
 			}
167 167
 			unset($val);
168 168
 		}
@@ -215,19 +215,19 @@  discard block
 block discarded – undo
215 215
 		return $val;
216 216
 	}
217 217
 
218
-    /**
219
-     * @param string $view_link
220
-     */
221
-    private function get_actions( &$actions, $item, $view_link ) {
218
+	/**
219
+	 * @param string $view_link
220
+	 */
221
+	private function get_actions( &$actions, $item, $view_link ) {
222 222
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
223 223
 
224
-        if ( current_user_can('frm_delete_entries') ) {
224
+		if ( current_user_can('frm_delete_entries') ) {
225 225
 			$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
226 226
 			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>';
227
-	    }
227
+		}
228 228
 
229
-        $actions = apply_filters('frm_row_actions', $actions, $item);
230
-    }
229
+		$actions = apply_filters('frm_row_actions', $actions, $item);
230
+	}
231 231
 
232 232
 	private function get_column_value( $item, &$val ) {
233 233
 		$col_name = $this->column_name;
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 			$join_form_in_query = true;
24 24
 		}
25 25
 
26
-		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
26
+		$s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
27 27
 
28 28
 	    if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
29 29
 	        $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 		$s_query = apply_filters( 'frm_entries_list_query', $s_query, compact( 'form_id' ) );
34 34
 
35 35
         $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
36
-        if ( strpos($orderby, 'meta') !== false ) {
36
+        if ( strpos( $orderby, 'meta' ) !== false ) {
37 37
             $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
38 38
 			$orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : '';
39 39
         }
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		$start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page );
46 46
 
47 47
 		$this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, $join_form_in_query );
48
-        $total_items = FrmEntry::getRecordCount($s_query);
48
+        $total_items = FrmEntry::getRecordCount( $s_query );
49 49
 
50 50
 		$this->set_pagination_args( array(
51 51
 			'total_items' => $total_items,
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
 	public function no_items() {
57 57
         $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
58
-	    if ( ! empty($s) ) {
58
+	    if ( ! empty( $s ) ) {
59 59
             _e( 'No Entries Found', 'formidable' );
60 60
             return;
61 61
         }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 		$form = $this->params['form'];
65 65
 
66 66
         if ( $form_id ) {
67
-            $form = FrmForm::getOne($form_id);
67
+            $form = FrmForm::getOne( $form_id );
68 68
         }
69 69
         $colspan = $this->get_column_count();
70 70
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 
123 123
 		$r = "<tr id='item-action-{$item->id}'$style>";
124 124
 
125
-		list( $columns, $hidden, , $primary ) = $this->get_column_info();
125
+		list( $columns, $hidden,, $primary ) = $this->get_column_info();
126 126
         $action_col = false;
127 127
 
128 128
 		foreach ( $columns as $column_name => $column_display_name ) {
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
             }
140 140
 
141 141
 			$attributes = 'class="' . esc_attr( $class ) . '"';
142
-			unset($class);
142
+			unset( $class );
143 143
 			$attributes .= ' data-colname="' . $column_display_name . '"';
144 144
 
145 145
 			$form_id = $this->params['form'] ? $this->params['form'] : 0;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 			    }
165 165
 			    $r .= '</td>';
166 166
 			}
167
-			unset($val);
167
+			unset( $val );
168 168
 		}
169 169
 		$r .= '</tr>';
170 170
 
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
     private function get_actions( &$actions, $item, $view_link ) {
222 222
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
223 223
 
224
-        if ( current_user_can('frm_delete_entries') ) {
224
+        if ( current_user_can( 'frm_delete_entries' ) ) {
225 225
 			$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
226 226
 			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>';
227 227
 	    }
228 228
 
229
-        $actions = apply_filters('frm_row_actions', $actions, $item);
229
+        $actions = apply_filters( 'frm_row_actions', $actions, $item );
230 230
     }
231 231
 
232 232
 	private function get_column_value( $item, &$val ) {
Please login to merge, or discard this patch.