Completed
Push — master ( 8e2ad2...9fba2a )
by Stephanie
02:58
created
classes/helpers/FrmXMLHelper.php 2 patches
Indentation   +394 added lines, -394 removed lines patch added patch discarded remove patch
@@ -33,24 +33,24 @@  discard block
 block discarded – undo
33 33
 			'styles'  => 0,
34 34
 		);
35 35
 
36
-        $imported = array(
37
-            'imported' => $defaults,
36
+		$imported = array(
37
+			'imported' => $defaults,
38 38
 			'updated'  => $defaults,
39 39
 			'forms'    => array(),
40 40
 			'terms'    => array(),
41
-        );
41
+		);
42 42
 
43 43
 		unset( $defaults );
44 44
 
45 45
 		if ( ! defined( 'WP_IMPORTING' ) ) {
46 46
 			define( 'WP_IMPORTING', true );
47
-        }
47
+		}
48 48
 
49 49
 		if ( ! class_exists( 'DOMDocument' ) ) {
50
-            return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
51
-        }
50
+			return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
51
+		}
52 52
 
53
-        $dom = new DOMDocument;
53
+		$dom = new DOMDocument;
54 54
 		$success = $dom->loadXML( file_get_contents( $file ) );
55 55
 		if ( ! $success ) {
56 56
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
@@ -68,45 +68,45 @@  discard block
 block discarded – undo
68 68
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
69 69
 		}
70 70
 
71
-        // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
71
+		// add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
72 72
 		foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
73
-            // grab cats, tags, and terms, or forms or posts
73
+			// grab cats, tags, and terms, or forms or posts
74 74
 			if ( isset( $xml->{$item_type} ) ) {
75 75
 				$function_name = 'import_xml_' . $item_type . 's';
76 76
 				$imported = self::$function_name( $xml->{$item_type}, $imported );
77 77
 				unset( $function_name, $xml->{$item_type} );
78
-            }
79
-        }
78
+			}
79
+		}
80 80
 
81 81
 		$return = apply_filters( 'frm_importing_xml', $imported, $xml );
82 82
 
83
-	    return $return;
84
-    }
83
+		return $return;
84
+	}
85 85
 
86 86
 	public static function import_xml_terms( $terms, $imported ) {
87
-        foreach ( $terms as $t ) {
87
+		foreach ( $terms as $t ) {
88 88
 			if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) {
89
-			    continue;
89
+				continue;
90 90
 			}
91 91
 
92 92
 			$parent = self::get_term_parent_id( $t );
93 93
 
94 94
 			$term = wp_insert_term( (string) $t->term_name, (string) $t->term_taxonomy, array(
95
-                'slug'          => (string) $t->term_slug,
96
-                'description'   => (string) $t->term_description,
95
+				'slug'          => (string) $t->term_slug,
96
+				'description'   => (string) $t->term_description,
97 97
 				'parent'        => empty( $parent ) ? 0 : $parent,
98
-            ));
98
+			));
99 99
 
100 100
 			if ( $term && is_array( $term ) ) {
101
-                $imported['imported']['terms']++;
101
+				$imported['imported']['terms']++;
102 102
 				$imported['terms'][ (int) $t->term_id ] = $term['term_id'];
103
-            }
103
+			}
104 104
 
105 105
 			unset( $term, $t );
106 106
 		}
107 107
 
108 108
 		return $imported;
109
-    }
109
+	}
110 110
 
111 111
 	/**
112 112
 	 * @since 2.0.8
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
 		self::put_child_forms_first( $forms );
132 132
 
133 133
 		foreach ( $forms as $item ) {
134
-            $form = self::fill_form( $item );
134
+			$form = self::fill_form( $item );
135 135
 
136 136
 			self::update_custom_style_setting_on_import( $form );
137 137
 
138
-	        $this_form = self::maybe_get_form( $form );
138
+			$this_form = self::maybe_get_form( $form );
139 139
 
140 140
 			$old_id = false;
141 141
 			$form_fields = false;
@@ -147,25 +147,25 @@  discard block
 block discarded – undo
147 147
 				$form_fields = self::get_form_fields( $form_id );
148 148
 			} else {
149 149
 				$form_id = FrmForm::create( $form );
150
-		        if ( $form_id ) {
151
-		            $imported['imported']['forms']++;
152
-		            // Keep track of whether this specific form was updated or not
150
+				if ( $form_id ) {
151
+					$imported['imported']['forms']++;
152
+					// Keep track of whether this specific form was updated or not
153 153
 					$imported['form_status'][ $form_id ] = 'imported';
154 154
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
155
-		        }
155
+				}
156 156
 			}
157 157
 
158 158
 			self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported );
159 159
 
160 160
 			self::delete_removed_fields( $form_fields );
161 161
 
162
-		    // Update field ids/keys to new ones
162
+			// Update field ids/keys to new ones
163 163
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
164 164
 
165 165
 			$imported['forms'][ (int) $item->id ] = $form_id;
166 166
 
167
-            // Send pre 2.0 form options through function that creates actions
168
-            self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true );
167
+			// Send pre 2.0 form options through function that creates actions
168
+			self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true );
169 169
 
170 170
 			do_action( 'frm_after_import_form', $form_id, $form );
171 171
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
176 176
 
177 177
 		return $imported;
178
-    }
178
+	}
179 179
 
180 180
 	private static function fill_form( $item ) {
181 181
 		$form = array(
@@ -246,11 +246,11 @@  discard block
 block discarded – undo
246 246
 	}
247 247
 
248 248
 	/**
249
-	* Put child forms first so they will be imported before parents
250
-	*
251
-	* @since 2.0.16
252
-	* @param array $forms
253
-	*/
249
+	 * Put child forms first so they will be imported before parents
250
+	 *
251
+	 * @since 2.0.16
252
+	 * @param array $forms
253
+	 */
254 254
 	private static function put_child_forms_first( &$forms ) {
255 255
 		$child_forms = array();
256 256
 		$regular_forms = array();
@@ -269,13 +269,13 @@  discard block
 block discarded – undo
269 269
 	}
270 270
 
271 271
 	/**
272
-	* Keep track of all imported child forms
273
-	*
274
-	* @since 2.0.16
275
-	* @param int $form_id
276
-	* @param int $parent_form_id
277
-	* @param array $child_forms
278
-	*/
272
+	 * Keep track of all imported child forms
273
+	 *
274
+	 * @since 2.0.16
275
+	 * @param int $form_id
276
+	 * @param int $parent_form_id
277
+	 * @param array $child_forms
278
+	 */
279 279
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
280 280
 		if ( $parent_form_id ) {
281 281
 			$child_forms[ $form_id ] = $parent_form_id;
@@ -283,13 +283,13 @@  discard block
 block discarded – undo
283 283
 	}
284 284
 
285 285
 	/**
286
-	* Update the parent_form_id on imported child forms
287
-	* Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
288
-	*
289
-	* @since 2.0.6
290
-	* @param array $imported_forms
291
-	* @param array $child_forms
292
-	*/
286
+	 * Update the parent_form_id on imported child forms
287
+	 * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
288
+	 *
289
+	 * @since 2.0.6
290
+	 * @param array $imported_forms
291
+	 * @param array $child_forms
292
+	 */
293 293
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
294 294
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
295 295
 
@@ -303,11 +303,11 @@  discard block
 block discarded – undo
303 303
 	}
304 304
 
305 305
 	/**
306
-	* Import all fields for a form
307
-	* @since 2.0.13
308
-	*
309
-	* TODO: Cut down on params
310
-	*/
306
+	 * Import all fields for a form
307
+	 * @since 2.0.13
308
+	 *
309
+	 * TODO: Cut down on params
310
+	 */
311 311
 	private static function import_xml_fields( $xml_fields, $form_id, $this_form, &$form_fields, &$imported ) {
312 312
 		$in_section = 0;
313 313
 
@@ -400,12 +400,12 @@  discard block
 block discarded – undo
400 400
 	}
401 401
 
402 402
 	/**
403
-	* Switch the form_select on a repeating field or embedded form if it needs to be switched
404
-	*
405
-	* @since 2.0.16
406
-	* @param array $f
407
-	* @param array $imported
408
-	*/
403
+	 * Switch the form_select on a repeating field or embedded form if it needs to be switched
404
+	 *
405
+	 * @since 2.0.16
406
+	 * @param array $f
407
+	 * @param array $imported
408
+	 */
409 409
 	private static function maybe_update_form_select( &$f, $imported ) {
410 410
 		if ( ! isset( $imported['forms'] ) ) {
411 411
 			return;
@@ -457,13 +457,13 @@  discard block
 block discarded – undo
457 457
 	}
458 458
 
459 459
 	/**
460
-	* Updates the custom style setting on import
461
-	* Convert the post slug to an ID
462
-	*
463
-	* @since 2.0.19
464
-	* @param array $form
465
-	*
466
-	*/
460
+	 * Updates the custom style setting on import
461
+	 * Convert the post slug to an ID
462
+	 *
463
+	 * @since 2.0.19
464
+	 * @param array $form
465
+	 *
466
+	 */
467 467
 	private static function update_custom_style_setting_on_import( &$form ) {
468 468
 		if ( ! isset( $form['options']['custom_style'] ) ) {
469 469
 			return;
@@ -517,16 +517,16 @@  discard block
 block discarded – undo
517 517
 	}
518 518
 
519 519
 	public static function import_xml_views( $views, $imported ) {
520
-        $imported['posts'] = array();
521
-        $form_action_type = FrmFormActionsController::$action_post_type;
520
+		$imported['posts'] = array();
521
+		$form_action_type = FrmFormActionsController::$action_post_type;
522 522
 
523
-        $post_types = array(
524
-            'frm_display' => 'views',
525
-            $form_action_type => 'actions',
526
-            'frm_styles'    => 'styles',
527
-        );
523
+		$post_types = array(
524
+			'frm_display' => 'views',
525
+			$form_action_type => 'actions',
526
+			'frm_styles'    => 'styles',
527
+		);
528 528
 
529
-        foreach ( $views as $item ) {
529
+		foreach ( $views as $item ) {
530 530
 			$post = array(
531 531
 				'post_title'    => (string) $item->title,
532 532
 				'post_name'     => (string) $item->post_name,
@@ -545,52 +545,52 @@  discard block
 block discarded – undo
545 545
 				'post_date'     => (string) $item->post_date,
546 546
 				'post_date_gmt' => (string) $item->post_date_gmt,
547 547
 				'ping_status'   => (string) $item->ping_status,
548
-                'postmeta'      => array(),
549
-                'tax_input'     => array(),
548
+				'postmeta'      => array(),
549
+				'tax_input'     => array(),
550 550
 			);
551 551
 
552
-            $old_id = $post['post_id'];
552
+			$old_id = $post['post_id'];
553 553
 			self::populate_post( $post, $item, $imported );
554 554
 
555 555
 			unset( $item );
556 556
 
557 557
 			$post_id = false;
558
-            if ( $post['post_type'] == $form_action_type ) {
559
-                $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
558
+			if ( $post['post_type'] == $form_action_type ) {
559
+				$action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
560 560
 				if ( $action_control && is_object( $action_control ) ) {
561 561
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
562 562
 				}
563 563
 				unset( $action_control );
564
-            } else if ( $post['post_type'] == 'frm_styles' ) {
565
-                // Properly encode post content before inserting the post
566
-                $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
564
+			} else if ( $post['post_type'] == 'frm_styles' ) {
565
+				// Properly encode post content before inserting the post
566
+				$post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
567 567
 				$custom_css = isset( $post['post_content']['custom_css'] ) ? $post['post_content']['custom_css'] : '';
568
-                $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
568
+				$post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
569 569
 
570
-                // Create/update post now
571
-                $post_id = wp_insert_post( $post );
570
+				// Create/update post now
571
+				$post_id = wp_insert_post( $post );
572 572
 				self::maybe_update_custom_css( $custom_css );
573
-            } else {
574
-                // Create/update post now
575
-                $post_id = wp_insert_post( $post );
576
-            }
573
+			} else {
574
+				// Create/update post now
575
+				$post_id = wp_insert_post( $post );
576
+			}
577 577
 
578 578
 			if ( ! is_numeric( $post_id ) ) {
579
-                continue;
580
-            }
579
+				continue;
580
+			}
581 581
 
582 582
 			self::update_postmeta( $post, $post_id );
583 583
 
584
-            $this_type = 'posts';
584
+			$this_type = 'posts';
585 585
 			if ( isset( $post_types[ $post['post_type'] ] ) ) {
586 586
 				$this_type = $post_types[ $post['post_type'] ];
587
-            }
587
+			}
588 588
 
589 589
 			if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) {
590
-                $imported['updated'][ $this_type ]++;
591
-            } else {
592
-                $imported['imported'][ $this_type ]++;
593
-            }
590
+				$imported['updated'][ $this_type ]++;
591
+			} else {
592
+				$imported['imported'][ $this_type ]++;
593
+			}
594 594
 
595 595
 			$imported['posts'][ (int) $old_id ] = $post_id;
596 596
 
@@ -602,16 +602,16 @@  discard block
 block discarded – undo
602 602
 		self::maybe_update_stylesheet( $imported );
603 603
 
604 604
 		return $imported;
605
-    }
605
+	}
606 606
 
607
-    private static function populate_post( &$post, $item, $imported ) {
607
+	private static function populate_post( &$post, $item, $imported ) {
608 608
 		if ( isset( $item->attachment_url ) ) {
609 609
 			$post['attachment_url'] = (string) $item->attachment_url;
610 610
 		}
611 611
 
612 612
 		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
613
-		    // update to new form id
614
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
613
+			// update to new form id
614
+			$post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
615 615
 		}
616 616
 
617 617
 		// Don't allow default styles to take over a site's default style
@@ -627,57 +627,57 @@  discard block
 block discarded – undo
627 627
 		self::populate_taxonomies( $post, $item );
628 628
 
629 629
 		self::maybe_editing_post( $post );
630
-    }
630
+	}
631 631
 
632
-    private static function populate_postmeta( &$post, $meta, $imported ) {
633
-        global $frm_duplicate_ids;
632
+	private static function populate_postmeta( &$post, $meta, $imported ) {
633
+		global $frm_duplicate_ids;
634 634
 
635
-	    $m = array(
635
+		$m = array(
636 636
 			'key'   => (string) $meta->meta_key,
637 637
 			'value' => (string) $meta->meta_value,
638 638
 		);
639 639
 
640 640
 		//switch old form and field ids to new ones
641 641
 		if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][ (int) $m['value'] ] ) ) {
642
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
642
+			$m['value'] = $imported['forms'][ (int) $m['value'] ];
643 643
 		} else {
644
-		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
644
+			$m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
645 645
 
646 646
 			if ( ! empty( $frm_duplicate_ids ) ) {
647 647
 
648
-		        if ( $m['key'] == 'frm_dyncontent' ) {
648
+				if ( $m['key'] == 'frm_dyncontent' ) {
649 649
 					$m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] );
650
-    		    } else if ( $m['key'] == 'frm_options' ) {
650
+				} else if ( $m['key'] == 'frm_options' ) {
651 651
 
652 652
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
653 653
 						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
654 654
 							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
655
-    		            }
656
-    		        }
657
-
658
-                    $check_dup_array = array();
659
-    		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
660
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
661
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
662
-    		            } else if ( is_array( $m['value']['order_by'] ) ) {
663
-                            $check_dup_array[] = 'order_by';
664
-    		            }
665
-    		        }
666
-
667
-    		        if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
668
-    		            $check_dup_array[] = 'where';
669
-    		        }
670
-
671
-                    foreach ( $check_dup_array as $check_k ) {
655
+						}
656
+					}
657
+
658
+					$check_dup_array = array();
659
+					if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
660
+						if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
661
+							$m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
662
+						} else if ( is_array( $m['value']['order_by'] ) ) {
663
+							$check_dup_array[] = 'order_by';
664
+						}
665
+					}
666
+
667
+					if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
668
+						$check_dup_array[] = 'where';
669
+					}
670
+
671
+					foreach ( $check_dup_array as $check_k ) {
672 672
 						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
673 673
 							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
674 674
 								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
675
-		                    }
675
+							}
676 676
 							unset( $mk, $mv );
677
-		                }
678
-                    }
679
-    		    }
680
-		    }
677
+						}
678
+					}
679
+				}
680
+			}
681 681
 		}
682 682
 
683 683
 		if ( ! is_array( $m['value'] ) ) {
@@ -685,31 +685,31 @@  discard block
 block discarded – undo
685 685
 		}
686 686
 
687 687
 		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
688
-    }
689
-
690
-    /**
691
-     * Add terms to post
692
-     * @param array $post by reference
693
-     * @param object $item The XML object data
694
-     */
695
-    private static function populate_taxonomies( &$post, $item ) {
688
+	}
689
+
690
+	/**
691
+	 * Add terms to post
692
+	 * @param array $post by reference
693
+	 * @param object $item The XML object data
694
+	 */
695
+	private static function populate_taxonomies( &$post, $item ) {
696 696
 		foreach ( $item->category as $c ) {
697 697
 			$att = $c->attributes();
698 698
 			if ( ! isset( $att['nicename'] ) ) {
699
-                continue;
700
-            }
699
+				continue;
700
+			}
701 701
 
702
-		    $taxonomy = (string) $att['domain'];
702
+			$taxonomy = (string) $att['domain'];
703 703
 			if ( is_taxonomy_hierarchical( $taxonomy ) ) {
704
-		        $name = (string) $att['nicename'];
704
+				$name = (string) $att['nicename'];
705 705
 				$h_term = get_term_by( 'slug', $name, $taxonomy );
706
-		        if ( $h_term ) {
707
-		            $name = $h_term->term_id;
708
-		        }
706
+				if ( $h_term ) {
707
+					$name = $h_term->term_id;
708
+				}
709 709
 				unset( $h_term );
710
-		    } else {
711
-		        $name = (string) $c;
712
-		    }
710
+			} else {
711
+				$name = (string) $c;
712
+			}
713 713
 
714 714
 			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
715 715
 				$post['tax_input'][ $taxonomy ] = array();
@@ -718,21 +718,21 @@  discard block
 block discarded – undo
718 718
 			$post['tax_input'][ $taxonomy ][] = $name;
719 719
 			unset( $name );
720 720
 		}
721
-    }
721
+	}
722 722
 
723
-    /**
724
-     * Edit post if the key and created time match
725
-     */
726
-    private static function maybe_editing_post( &$post ) {
723
+	/**
724
+	 * Edit post if the key and created time match
725
+	 */
726
+	private static function maybe_editing_post( &$post ) {
727 727
 		$match_by = array(
728
-		    'post_type'     => $post['post_type'],
729
-		    'name'          => $post['post_name'],
730
-		    'post_status'   => $post['post_status'],
731
-		    'posts_per_page' => 1,
728
+			'post_type'     => $post['post_type'],
729
+			'name'          => $post['post_name'],
730
+			'post_status'   => $post['post_status'],
731
+			'posts_per_page' => 1,
732 732
 		);
733 733
 
734 734
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
735
-		    $match_by['include'] = $post['post_id'];
735
+			$match_by['include'] = $post['post_id'];
736 736
 			unset( $match_by['name'] );
737 737
 		}
738 738
 
@@ -742,23 +742,23 @@  discard block
 block discarded – undo
742 742
 			// set the id of the post to edit
743 743
 			$post['ID'] = current( $editing )->ID;
744 744
 		}
745
-    }
745
+	}
746 746
 
747
-    private static function update_postmeta( &$post, $post_id ) {
748
-        foreach ( $post['postmeta'] as $k => $v ) {
749
-            if ( '_edit_last' == $k ) {
747
+	private static function update_postmeta( &$post, $post_id ) {
748
+		foreach ( $post['postmeta'] as $k => $v ) {
749
+			if ( '_edit_last' == $k ) {
750 750
 				$v = FrmAppHelper::get_user_id_param( $v );
751
-            } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
752
-                //change the attachment ID
751
+			} else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
752
+				//change the attachment ID
753 753
 				$field_obj = FrmFieldFactory::get_field_type( 'file' );
754 754
 				$v = $field_obj->get_file_id( $v );
755
-            }
755
+			}
756 756
 
757 757
 			update_post_meta( $post_id, $k, $v );
758 758
 
759 759
 			unset( $k, $v );
760
-        }
761
-    }
760
+		}
761
+	}
762 762
 
763 763
 	/**
764 764
 	 * If a template includes custom css, let's include it.
@@ -791,32 +791,32 @@  discard block
 block discarded – undo
791 791
 		}
792 792
 	}
793 793
 
794
-    /**
795
-     * @param string $message
796
-     */
794
+	/**
795
+	 * @param string $message
796
+	 */
797 797
 	public static function parse_message( $result, &$message, &$errors ) {
798 798
 		if ( is_wp_error( $result ) ) {
799
-            $errors[] = $result->get_error_message();
800
-        } else if ( ! $result ) {
801
-            return;
802
-        }
799
+			$errors[] = $result->get_error_message();
800
+		} else if ( ! $result ) {
801
+			return;
802
+		}
803 803
 
804 804
 		if ( ! is_array( $result ) ) {
805
-            $message = is_string( $result ) ? $result : htmlentities( print_r( $result, 1 ) );
806
-            return;
807
-        }
805
+			$message = is_string( $result ) ? $result : htmlentities( print_r( $result, 1 ) );
806
+			return;
807
+		}
808 808
 
809
-        $t_strings = array(
810
-            'imported'  => __( 'Imported', 'formidable' ),
811
-            'updated'   => __( 'Updated', 'formidable' ),
812
-        );
809
+		$t_strings = array(
810
+			'imported'  => __( 'Imported', 'formidable' ),
811
+			'updated'   => __( 'Updated', 'formidable' ),
812
+		);
813 813
 
814
-        $message = '<ul>';
815
-        foreach ( $result as $type => $results ) {
814
+		$message = '<ul>';
815
+		foreach ( $result as $type => $results ) {
816 816
 			if ( ! isset( $t_strings[ $type ] ) ) {
817
-                // only print imported and updated
818
-                continue;
819
-            }
817
+				// only print imported and updated
818
+				continue;
819
+			}
820 820
 
821 821
 			$s_message = array();
822 822
 			foreach ( $results as $k => $m ) {
@@ -829,34 +829,34 @@  discard block
 block discarded – undo
829 829
 				$message .= implode( ', ', $s_message );
830 830
 				$message .= '</li>';
831 831
 			}
832
-        }
832
+		}
833 833
 
834
-        if ( $message == '<ul>' ) {
835
-            $message = '';
836
-            $errors[] = __( 'Nothing was imported or updated', 'formidable' );
837
-        } else {
838
-            $message .= '</ul>';
839
-        }
840
-    }
834
+		if ( $message == '<ul>' ) {
835
+			$message = '';
836
+			$errors[] = __( 'Nothing was imported or updated', 'formidable' );
837
+		} else {
838
+			$message .= '</ul>';
839
+		}
840
+	}
841 841
 
842 842
 	public static function item_count_message( $m, $type, &$s_message ) {
843
-        if ( ! $m ) {
844
-            return;
845
-        }
846
-
847
-        $strings = array(
848
-            'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
849
-            'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
850
-            'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
851
-            'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
852
-            'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
853
-            'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
854
-            'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
855
-            'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
856
-        );
843
+		if ( ! $m ) {
844
+			return;
845
+		}
846
+
847
+		$strings = array(
848
+			'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
849
+			'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
850
+			'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
851
+			'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
852
+			'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
853
+			'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
854
+			'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
855
+			'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
856
+		);
857 857
 
858 858
 		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
859
-    }
859
+	}
860 860
 
861 861
 	/**
862 862
 	 * Prepare the form options for export
@@ -895,8 +895,8 @@  discard block
 block discarded – undo
895 895
 		}
896 896
 
897 897
 		if ( is_numeric( $str ) ) {
898
-            return $str;
899
-        }
898
+			return $str;
899
+		}
900 900
 
901 901
 		self::remove_invalid_characters_from_xml( $str );
902 902
 
@@ -917,54 +917,54 @@  discard block
 block discarded – undo
917 917
 		$str = str_replace( '\x1F', '', $str );
918 918
 	}
919 919
 
920
-    public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
921
-        // Get post type
922
-        $post_type = FrmFormActionsController::$action_post_type;
920
+	public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
921
+		// Get post type
922
+		$post_type = FrmFormActionsController::$action_post_type;
923 923
 
924
-        // Set up imported index, if not set up yet
925
-        if ( ! isset( $imported['imported']['actions'] ) ) {
926
-            $imported['imported']['actions'] = 0;
927
-        }
924
+		// Set up imported index, if not set up yet
925
+		if ( ! isset( $imported['imported']['actions'] ) ) {
926
+			$imported['imported']['actions'] = 0;
927
+		}
928 928
 
929
-        // Migrate post settings to action
930
-        self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
929
+		// Migrate post settings to action
930
+		self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
931 931
 
932
-        // Migrate email settings to action
933
-        self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
934
-    }
932
+		// Migrate email settings to action
933
+		self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
934
+	}
935 935
 
936
-    /**
937
-    * Migrate post settings to form action
938
-    *
939
-    * @param string $post_type
940
-    */
941
-    private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
936
+	/**
937
+	 * Migrate post settings to form action
938
+	 *
939
+	 * @param string $post_type
940
+	 */
941
+	private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
942 942
 		if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) {
943
-            return;
944
-        }
943
+			return;
944
+		}
945 945
 
946
-        $new_action = array(
947
-            'post_type'     => $post_type,
948
-            'post_excerpt'  => 'wppost',
946
+		$new_action = array(
947
+			'post_type'     => $post_type,
948
+			'post_excerpt'  => 'wppost',
949 949
 			'post_title'    => __( 'Create Posts', 'formidable' ),
950
-            'menu_order'    => $form_id,
951
-            'post_status'   => 'publish',
952
-            'post_content'  => array(),
950
+			'menu_order'    => $form_id,
951
+			'post_status'   => 'publish',
952
+			'post_content'  => array(),
953 953
 			'post_name'     => $form_id . '_wppost_1',
954
-        );
954
+		);
955 955
 
956 956
 		$post_settings = array( 'post_type', 'post_category', 'post_content', 'post_excerpt', 'post_title', 'post_name', 'post_date', 'post_status', 'post_custom_fields', 'post_password' );
957 957
 
958
-        foreach ( $post_settings as $post_setting ) {
958
+		foreach ( $post_settings as $post_setting ) {
959 959
 			if ( isset( $form_options[ $post_setting ] ) ) {
960 960
 				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
961
-            }
961
+			}
962 962
 			unset( $post_setting );
963
-        }
963
+		}
964 964
 
965 965
 		$new_action['event'] = array( 'create', 'update' );
966 966
 
967
-        if ( $switch ) {
967
+		if ( $switch ) {
968 968
 			// Fields with string or int saved
969 969
 			$basic_fields = array( 'post_title', 'post_content', 'post_excerpt', 'post_password', 'post_date', 'post_status' );
970 970
 
@@ -972,22 +972,22 @@  discard block
 block discarded – undo
972 972
 			$array_fields = array( 'post_category', 'post_custom_fields' );
973 973
 
974 974
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
975
-        }
975
+		}
976 976
 		$new_action['post_content'] = json_encode( $new_action['post_content'] );
977 977
 
978
-        $exists = get_posts( array(
979
-            'name'          => $new_action['post_name'],
980
-            'post_type'     => $new_action['post_type'],
981
-            'post_status'   => $new_action['post_status'],
982
-            'numberposts'   => 1,
983
-        ) );
978
+		$exists = get_posts( array(
979
+			'name'          => $new_action['post_name'],
980
+			'post_type'     => $new_action['post_type'],
981
+			'post_status'   => $new_action['post_status'],
982
+			'numberposts'   => 1,
983
+		) );
984 984
 
985
-        if ( ! $exists ) {
985
+		if ( ! $exists ) {
986 986
 			// this isn't an email, but we need to use a class that will always be included
987 987
 			FrmDb::save_json_post( $new_action );
988
-            $imported['imported']['actions']++;
989
-        }
990
-    }
988
+			$imported['imported']['actions']++;
989
+		}
990
+	}
991 991
 
992 992
 	/**
993 993
 	 * Switch old field IDs for new field IDs in emails and post
@@ -1000,88 +1000,88 @@  discard block
 block discarded – undo
1000 1000
 	 * @return string $post_content - new field IDs
1001 1001
 	 */
1002 1002
 	private static function switch_action_field_ids( $post_content, $basic_fields, $array_fields = array() ) {
1003
-        global $frm_duplicate_ids;
1003
+		global $frm_duplicate_ids;
1004 1004
 
1005
-        // If there aren't IDs that were switched, end now
1006
-        if ( ! $frm_duplicate_ids ) {
1007
-            return;
1008
-        }
1005
+		// If there aren't IDs that were switched, end now
1006
+		if ( ! $frm_duplicate_ids ) {
1007
+			return;
1008
+		}
1009 1009
 
1010
-        // Get old IDs
1011
-        $old = array_keys( $frm_duplicate_ids );
1010
+		// Get old IDs
1011
+		$old = array_keys( $frm_duplicate_ids );
1012 1012
 
1013
-        // Get new IDs
1014
-        $new = array_values( $frm_duplicate_ids );
1013
+		// Get new IDs
1014
+		$new = array_values( $frm_duplicate_ids );
1015 1015
 
1016
-        // Do a str_replace with each item to set the new IDs
1017
-        foreach ( $post_content as $key => $setting ) {
1018
-            if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
1019
-                // Replace old IDs with new IDs
1016
+		// Do a str_replace with each item to set the new IDs
1017
+		foreach ( $post_content as $key => $setting ) {
1018
+			if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
1019
+				// Replace old IDs with new IDs
1020 1020
 				$post_content[ $key ] = str_replace( $old, $new, $setting );
1021
-            } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
1022
-                foreach ( $setting as $k => $val ) {
1023
-                    // Replace old IDs with new IDs
1021
+			} else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
1022
+				foreach ( $setting as $k => $val ) {
1023
+					// Replace old IDs with new IDs
1024 1024
 					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
1025
-                }
1026
-            }
1027
-            unset( $key, $setting );
1028
-        }
1029
-        return $post_content;
1030
-    }
1031
-
1032
-    private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
1033
-        // No old notifications or autoresponders to carry over
1025
+				}
1026
+			}
1027
+			unset( $key, $setting );
1028
+		}
1029
+		return $post_content;
1030
+	}
1031
+
1032
+	private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
1033
+		// No old notifications or autoresponders to carry over
1034 1034
 		if ( ! isset( $form_options['auto_responder'] ) && ! isset( $form_options['notification'] ) && ! isset( $form_options['email_to'] ) ) {
1035
-            return;
1036
-        }
1035
+			return;
1036
+		}
1037 1037
 
1038
-        // Initialize notifications array
1039
-        $notifications = array();
1038
+		// Initialize notifications array
1039
+		$notifications = array();
1040 1040
 
1041
-        // Migrate regular notifications
1042
-        self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
1041
+		// Migrate regular notifications
1042
+		self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
1043 1043
 
1044
-        // Migrate autoresponders
1045
-        self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
1044
+		// Migrate autoresponders
1045
+		self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
1046 1046
 
1047
-        if ( empty( $notifications ) ) {
1048
-            return;
1049
-        }
1047
+		if ( empty( $notifications ) ) {
1048
+			return;
1049
+		}
1050 1050
 
1051
-        foreach ( $notifications as $new_notification ) {
1052
-            $new_notification['post_type']      = $post_type;
1053
-            $new_notification['post_excerpt']   = 'email';
1051
+		foreach ( $notifications as $new_notification ) {
1052
+			$new_notification['post_type']      = $post_type;
1053
+			$new_notification['post_excerpt']   = 'email';
1054 1054
 			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
1055
-            $new_notification['menu_order']     = $form_id;
1056
-            $new_notification['post_status']    = 'publish';
1055
+			$new_notification['menu_order']     = $form_id;
1056
+			$new_notification['post_status']    = 'publish';
1057 1057
 
1058
-            // Switch field IDs and keys, if needed
1059
-            if ( $switch ) {
1058
+			// Switch field IDs and keys, if needed
1059
+			if ( $switch ) {
1060 1060
 
1061 1061
 				// Switch field IDs in email conditional logic
1062 1062
 				self::switch_email_contition_field_ids( $new_notification['post_content'] );
1063 1063
 
1064 1064
 				// Switch all other field IDs in email
1065
-                $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1066
-            }
1067
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1065
+				$new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1066
+			}
1067
+			$new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1068 1068
 
1069
-            $exists = get_posts( array(
1070
-                'name'          => $new_notification['post_name'],
1071
-                'post_type'     => $new_notification['post_type'],
1072
-                'post_status'   => $new_notification['post_status'],
1073
-                'numberposts'   => 1,
1074
-            ) );
1069
+			$exists = get_posts( array(
1070
+				'name'          => $new_notification['post_name'],
1071
+				'post_type'     => $new_notification['post_type'],
1072
+				'post_status'   => $new_notification['post_status'],
1073
+				'numberposts'   => 1,
1074
+			) );
1075 1075
 
1076 1076
 			if ( empty( $exists ) ) {
1077 1077
 				FrmDb::save_json_post( $new_notification );
1078
-                $imported['imported']['actions']++;
1079
-            }
1078
+				$imported['imported']['actions']++;
1079
+			}
1080 1080
 			unset( $new_notification );
1081
-        }
1081
+		}
1082 1082
 
1083 1083
 		self::remove_deprecated_notification_settings( $form_id, $form_options );
1084
-    }
1084
+	}
1085 1085
 
1086 1086
 	/**
1087 1087
 	 * Remove deprecated notification settings after migration
@@ -1101,17 +1101,17 @@  discard block
 block discarded – undo
1101 1101
 		FrmForm::update( $form_id, array( 'options' => $form_options ) );
1102 1102
 	}
1103 1103
 
1104
-    private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
1105
-        if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
1106
-            // add old settings into notification array
1104
+	private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
1105
+		if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
1106
+			// add old settings into notification array
1107 1107
 			$form_options['notification'] = array( 0 => $form_options );
1108
-        } else if ( isset( $form_options['notification']['email_to'] ) ) {
1109
-            // make sure it's in the correct format
1108
+		} else if ( isset( $form_options['notification']['email_to'] ) ) {
1109
+			// make sure it's in the correct format
1110 1110
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
1111
-        }
1111
+		}
1112 1112
 
1113 1113
 		if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) {
1114
-            foreach ( $form_options['notification'] as $email_key => $notification ) {
1114
+			foreach ( $form_options['notification'] as $email_key => $notification ) {
1115 1115
 
1116 1116
 				$atts = array(
1117 1117
 					'email_to'  => '',
@@ -1122,119 +1122,119 @@  discard block
 block discarded – undo
1122 1122
 					'email_key' => $email_key,
1123 1123
 				);
1124 1124
 
1125
-                // Format the email data
1126
-                self::format_email_data( $atts, $notification );
1125
+				// Format the email data
1126
+				self::format_email_data( $atts, $notification );
1127 1127
 
1128 1128
 				if ( isset( $notification['twilio'] ) && $notification['twilio'] ) {
1129 1129
 					do_action( 'frm_create_twilio_action', $atts, $notification );
1130 1130
 				}
1131 1131
 
1132
-                // Setup the new notification
1133
-                $new_notification = array();
1134
-                self::setup_new_notification( $new_notification, $notification, $atts );
1132
+				// Setup the new notification
1133
+				$new_notification = array();
1134
+				self::setup_new_notification( $new_notification, $notification, $atts );
1135 1135
 
1136
-                $notifications[] = $new_notification;
1137
-            }
1138
-        }
1139
-    }
1136
+				$notifications[] = $new_notification;
1137
+			}
1138
+		}
1139
+	}
1140 1140
 
1141
-    private static function format_email_data( &$atts, $notification ) {
1142
-        // Format email_to
1143
-        self::format_email_to_data( $atts, $notification );
1141
+	private static function format_email_data( &$atts, $notification ) {
1142
+		// Format email_to
1143
+		self::format_email_to_data( $atts, $notification );
1144 1144
 
1145
-        // Format the reply to email and name
1145
+		// Format the reply to email and name
1146 1146
 		$reply_fields = array(
1147 1147
 			'reply_to'      => '',
1148 1148
 			'reply_to_name' => '',
1149 1149
 		);
1150
-        foreach ( $reply_fields as $f => $val ) {
1150
+		foreach ( $reply_fields as $f => $val ) {
1151 1151
 			if ( isset( $notification[ $f ] ) ) {
1152 1152
 				$atts[ $f ] = $notification[ $f ];
1153 1153
 				if ( 'custom' == $notification[ $f ] ) {
1154 1154
 					$atts[ $f ] = $notification[ 'cust_' . $f ];
1155 1155
 				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
1156 1156
 					$atts[ $f ] = '[' . $atts[ $f ] . ']';
1157
-                }
1158
-            }
1159
-            unset( $f, $val );
1160
-        }
1157
+				}
1158
+			}
1159
+			unset( $f, $val );
1160
+		}
1161 1161
 
1162
-        // Format event
1162
+		// Format event
1163 1163
 		$atts['event'] = array( 'create' );
1164
-        if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1165
-            $atts['event'][] = 'update';
1164
+		if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1165
+			$atts['event'][] = 'update';
1166 1166
 		} elseif ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) {
1167 1167
 			$atts['event'] = array( 'update' );
1168
-        }
1169
-    }
1168
+		}
1169
+	}
1170 1170
 
1171
-    private static function format_email_to_data( &$atts, $notification ) {
1172
-        if ( isset( $notification['email_to'] ) ) {
1171
+	private static function format_email_to_data( &$atts, $notification ) {
1172
+		if ( isset( $notification['email_to'] ) ) {
1173 1173
 			$atts['email_to'] = preg_split( '/ (,|;) /', $notification['email_to'] );
1174
-        } else {
1175
-            $atts['email_to'] = array();
1176
-        }
1174
+		} else {
1175
+			$atts['email_to'] = array();
1176
+		}
1177 1177
 
1178
-        if ( isset( $notification['also_email_to'] ) ) {
1179
-            $email_fields = (array) $notification['also_email_to'];
1180
-            $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1181
-            unset( $email_fields );
1182
-        }
1178
+		if ( isset( $notification['also_email_to'] ) ) {
1179
+			$email_fields = (array) $notification['also_email_to'];
1180
+			$atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1181
+			unset( $email_fields );
1182
+		}
1183 1183
 
1184
-        foreach ( $atts['email_to'] as $key => $email_field ) {
1184
+		foreach ( $atts['email_to'] as $key => $email_field ) {
1185 1185
 
1186
-            if ( is_numeric( $email_field ) ) {
1186
+			if ( is_numeric( $email_field ) ) {
1187 1187
 				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1188
-            }
1188
+			}
1189 1189
 
1190 1190
 			if ( strpos( $email_field, '|' ) ) {
1191
-                $email_opt = explode( '|', $email_field );
1192
-                if ( isset( $email_opt[0] ) ) {
1191
+				$email_opt = explode( '|', $email_field );
1192
+				if ( isset( $email_opt[0] ) ) {
1193 1193
 					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1194
-                }
1195
-                unset( $email_opt );
1196
-            }
1197
-        }
1194
+				}
1195
+				unset( $email_opt );
1196
+			}
1197
+		}
1198 1198
 		$atts['email_to'] = implode( ', ', $atts['email_to'] );
1199
-    }
1200
-
1201
-    private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1202
-        // Set up new notification
1203
-        $new_notification = array(
1204
-            'post_content'  => array(
1205
-                'email_to'      => $atts['email_to'],
1206
-                'event'         => $atts['event'],
1207
-            ),
1199
+	}
1200
+
1201
+	private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1202
+		// Set up new notification
1203
+		$new_notification = array(
1204
+			'post_content'  => array(
1205
+				'email_to'      => $atts['email_to'],
1206
+				'event'         => $atts['event'],
1207
+			),
1208 1208
 			'post_name'         => $atts['form_id'] . '_email_' . $atts['email_key'],
1209
-        );
1209
+		);
1210 1210
 
1211
-        // Add more fields to the new notification
1212
-        $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1213
-        foreach ( $add_fields as $add_field ) {
1211
+		// Add more fields to the new notification
1212
+		$add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1213
+		foreach ( $add_fields as $add_field ) {
1214 1214
 			if ( isset( $notification[ $add_field ] ) ) {
1215 1215
 				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1216
-            } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1216
+			} else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1217 1217
 				$new_notification['post_content'][ $add_field ] = 0;
1218
-            } else {
1218
+			} else {
1219 1219
 				$new_notification['post_content'][ $add_field ] = '';
1220
-            }
1221
-            unset( $add_field );
1222
-        }
1220
+			}
1221
+			unset( $add_field );
1222
+		}
1223 1223
 
1224 1224
 		// Set reply to
1225 1225
 		$new_notification['post_content']['reply_to'] = $atts['reply_to'];
1226 1226
 
1227
-        // Set from
1227
+		// Set from
1228 1228
 		if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) {
1229 1229
 			$new_notification['post_content']['from'] = ( empty( $atts['reply_to_name'] ) ? '[sitename]' : $atts['reply_to_name'] ) . ' <' . ( empty( $atts['reply_to'] ) ? '[admin_email]' : $atts['reply_to'] ) . '>';
1230
-        }
1231
-    }
1230
+		}
1231
+	}
1232 1232
 
1233 1233
 	/**
1234
-	* Switch field IDs in pre-2.0 email conditional logic
1235
-	*
1236
-	* @param $post_content array, pass by reference
1237
-	*/
1234
+	 * Switch field IDs in pre-2.0 email conditional logic
1235
+	 *
1236
+	 * @param $post_content array, pass by reference
1237
+	 */
1238 1238
 	private static function switch_email_contition_field_ids( &$post_content ) {
1239 1239
 		// Switch field IDs in conditional logic
1240 1240
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
@@ -1247,7 +1247,7 @@  discard block
 block discarded – undo
1247 1247
 		}
1248 1248
 	}
1249 1249
 
1250
-    private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1250
+	private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1251 1251
 		if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) {
1252 1252
 			// migrate autoresponder
1253 1253
 
@@ -1263,8 +1263,8 @@  discard block
 block discarded – undo
1263 1263
 				$email_field = '[' . $email_field . ']';
1264 1264
 			}
1265 1265
 
1266
-            $notification = $form_options;
1267
-            $new_notification2 = array(
1266
+			$notification = $form_options;
1267
+			$new_notification2 = array(
1268 1268
 				'post_content'  => array(
1269 1269
 					'email_message' => $notification['ar_email_message'],
1270 1270
 					'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '',
@@ -1273,7 +1273,7 @@  discard block
 block discarded – undo
1273 1273
 					'inc_user_info' => 0,
1274 1274
 				),
1275 1275
 				'post_name'     => $form_id . '_email_' . count( $notifications ),
1276
-            );
1276
+			);
1277 1277
 
1278 1278
 			$reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : '';
1279 1279
 			$reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : '';
@@ -1286,9 +1286,9 @@  discard block
 block discarded – undo
1286 1286
 				$new_notification2['post_content']['from'] = ( empty( $reply_to_name ) ? '[sitename]' : $reply_to_name ) . ' <' . ( empty( $reply_to ) ? '[admin_email]' : $reply_to ) . '>';
1287 1287
 			}
1288 1288
 
1289
-            $notifications[] = $new_notification2;
1290
-            unset( $new_notification2 );
1291
-        }
1292
-    }
1289
+			$notifications[] = $new_notification2;
1290
+			unset( $new_notification2 );
1291
+		}
1292
+	}
1293 1293
 }
1294 1294
 
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
                 'slug'          => (string) $t->term_slug,
96 96
                 'description'   => (string) $t->term_description,
97 97
 				'parent'        => empty( $parent ) ? 0 : $parent,
98
-            ));
98
+            ) );
99 99
 
100 100
 			if ( $term && is_array( $term ) ) {
101
-                $imported['imported']['terms']++;
102
-				$imported['terms'][ (int) $t->term_id ] = $term['term_id'];
101
+                $imported['imported']['terms'] ++;
102
+				$imported['terms'][(int) $t->term_id] = $term['term_id'];
103 103
             }
104 104
 
105 105
 			unset( $term, $t );
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
 			} else {
149 149
 				$form_id = FrmForm::create( $form );
150 150
 		        if ( $form_id ) {
151
-		            $imported['imported']['forms']++;
151
+		            $imported['imported']['forms'] ++;
152 152
 		            // Keep track of whether this specific form was updated or not
153
-					$imported['form_status'][ $form_id ] = 'imported';
153
+					$imported['form_status'][$form_id] = 'imported';
154 154
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
155 155
 		        }
156 156
 			}
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 		    // Update field ids/keys to new ones
163 163
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
164 164
 
165
-			$imported['forms'][ (int) $item->id ] = $form_id;
165
+			$imported['forms'][(int) $item->id] = $form_id;
166 166
 
167 167
             // Send pre 2.0 form options through function that creates actions
168 168
             self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true );
@@ -214,17 +214,17 @@  discard block
 block discarded – undo
214 214
 	private static function update_form( $this_form, $form, &$imported ) {
215 215
 		$form_id = $this_form->id;
216 216
 		FrmForm::update( $form_id, $form );
217
-		$imported['updated']['forms']++;
217
+		$imported['updated']['forms'] ++;
218 218
 		// Keep track of whether this specific form was updated or not
219
-		$imported['form_status'][ $form_id ] = 'updated';
219
+		$imported['form_status'][$form_id] = 'updated';
220 220
 	}
221 221
 
222 222
 	private static function get_form_fields( $form_id ) {
223 223
 		$form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' );
224 224
 		$old_fields = array();
225 225
 		foreach ( $form_fields as $f ) {
226
-			$old_fields[ $f->id ] = $f;
227
-			$old_fields[ $f->field_key ] = $f->id;
226
+			$old_fields[$f->id] = $f;
227
+			$old_fields[$f->field_key] = $f->id;
228 228
 			unset( $f );
229 229
 		}
230 230
 		$form_fields = $old_fields;
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	*/
279 279
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
280 280
 		if ( $parent_form_id ) {
281
-			$child_forms[ $form_id ] = $parent_form_id;
281
+			$child_forms[$form_id] = $parent_form_id;
282 282
 		}
283 283
 	}
284 284
 
@@ -293,9 +293,9 @@  discard block
 block discarded – undo
293 293
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
294 294
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
295 295
 
296
-			if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) {
296
+			if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) {
297 297
 				// Update all children with this old parent_form_id
298
-				$new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ];
298
+				$new_parent_form_id = (int) $imported_forms[$old_parent_form_id];
299 299
 
300 300
 				FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) );
301 301
 			}
@@ -329,25 +329,25 @@  discard block
 block discarded – undo
329 329
 
330 330
 			if ( ! empty( $this_form ) ) {
331 331
 				// check for field to edit by field id
332
-				if ( isset( $form_fields[ $f['id'] ] ) ) {
332
+				if ( isset( $form_fields[$f['id']] ) ) {
333 333
 					FrmField::update( $f['id'], $f );
334
-					$imported['updated']['fields']++;
334
+					$imported['updated']['fields'] ++;
335 335
 
336
-					unset( $form_fields[ $f['id'] ] );
336
+					unset( $form_fields[$f['id']] );
337 337
 
338 338
 					//unset old field key
339
-					if ( isset( $form_fields[ $f['field_key'] ] ) ) {
340
-						unset( $form_fields[ $f['field_key'] ] );
339
+					if ( isset( $form_fields[$f['field_key']] ) ) {
340
+						unset( $form_fields[$f['field_key']] );
341 341
 					}
342
-				} else if ( isset( $form_fields[ $f['field_key'] ] ) ) {
342
+				} else if ( isset( $form_fields[$f['field_key']] ) ) {
343 343
 					// check for field to edit by field key
344 344
 					unset( $f['id'] );
345 345
 
346
-					FrmField::update( $form_fields[ $f['field_key'] ], $f );
347
-					$imported['updated']['fields']++;
346
+					FrmField::update( $form_fields[$f['field_key']], $f );
347
+					$imported['updated']['fields'] ++;
348 348
 
349
-					unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id
350
-					unset( $form_fields[ $f['field_key'] ] ); //unset old field key
349
+					unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id
350
+					unset( $form_fields[$f['field_key']] ); //unset old field key
351 351
 				} else {
352 352
 					// if no matching field id or key in this form, create the field
353 353
 					self::create_imported_field( $f, $imported );
@@ -414,8 +414,8 @@  discard block
 block discarded – undo
414 414
 		if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) {
415 415
 			if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) {
416 416
 				$form_select = (int) $f['field_options']['form_select'];
417
-				if ( isset( $imported['forms'][ $form_select ] ) ) {
418
-					$f['field_options']['form_select'] = $imported['forms'][ $form_select ];
417
+				if ( isset( $imported['forms'][$form_select] ) ) {
418
+					$f['field_options']['form_select'] = $imported['forms'][$form_select];
419 419
 				}
420 420
 			}
421 421
 		}
@@ -435,8 +435,8 @@  discard block
 block discarded – undo
435 435
 
436 436
 		if ( FrmField::is_option_true_in_array( $f['field_options'], 'get_values_form' ) ) {
437 437
 			$old_form = $f['field_options']['get_values_form'];
438
-			if ( isset( $imported['forms'][ $old_form ] ) ) {
439
-				$f['field_options']['get_values_form'] = $imported['forms'][ $old_form ];
438
+			if ( isset( $imported['forms'][$old_form] ) ) {
439
+				$f['field_options']['get_values_form'] = $imported['forms'][$old_form];
440 440
 			}
441 441
 		}
442 442
 	}
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 	private static function create_imported_field( $f, &$imported ) {
452 452
 		$new_id = FrmField::create( $f );
453 453
 		if ( $new_id != false ) {
454
-			$imported['imported']['fields']++;
454
+			$imported['imported']['fields'] ++;
455 455
 			do_action( 'frm_after_field_is_imported', $f, $new_id );
456 456
 		}
457 457
 	}
@@ -582,17 +582,17 @@  discard block
 block discarded – undo
582 582
 			self::update_postmeta( $post, $post_id );
583 583
 
584 584
             $this_type = 'posts';
585
-			if ( isset( $post_types[ $post['post_type'] ] ) ) {
586
-				$this_type = $post_types[ $post['post_type'] ];
585
+			if ( isset( $post_types[$post['post_type']] ) ) {
586
+				$this_type = $post_types[$post['post_type']];
587 587
             }
588 588
 
589 589
 			if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) {
590
-                $imported['updated'][ $this_type ]++;
590
+                $imported['updated'][$this_type] ++;
591 591
             } else {
592
-                $imported['imported'][ $this_type ]++;
592
+                $imported['imported'][$this_type] ++;
593 593
             }
594 594
 
595
-			$imported['posts'][ (int) $old_id ] = $post_id;
595
+			$imported['posts'][(int) $old_id] = $post_id;
596 596
 
597 597
 			do_action( 'frm_after_import_view', $post_id, $post );
598 598
 
@@ -609,9 +609,9 @@  discard block
 block discarded – undo
609 609
 			$post['attachment_url'] = (string) $item->attachment_url;
610 610
 		}
611 611
 
612
-		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
612
+		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) {
613 613
 		    // update to new form id
614
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
614
+		    $post['menu_order'] = $imported['forms'][(int) $post['menu_order']];
615 615
 		}
616 616
 
617 617
 		// Don't allow default styles to take over a site's default style
@@ -638,8 +638,8 @@  discard block
 block discarded – undo
638 638
 		);
639 639
 
640 640
 		//switch old form and field ids to new ones
641
-		if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][ (int) $m['value'] ] ) ) {
642
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
641
+		if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) {
642
+		    $m['value'] = $imported['forms'][(int) $m['value']];
643 643
 		} else {
644 644
 		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
645 645
 
@@ -650,15 +650,15 @@  discard block
 block discarded – undo
650 650
     		    } else if ( $m['key'] == 'frm_options' ) {
651 651
 
652 652
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
653
-						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
654
-							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
653
+						if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) {
654
+							$m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]];
655 655
     		            }
656 656
     		        }
657 657
 
658 658
                     $check_dup_array = array();
659 659
     		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
660
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
661
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
660
+    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) {
661
+    		                $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']];
662 662
     		            } else if ( is_array( $m['value']['order_by'] ) ) {
663 663
                             $check_dup_array[] = 'order_by';
664 664
     		            }
@@ -669,9 +669,9 @@  discard block
 block discarded – undo
669 669
     		        }
670 670
 
671 671
                     foreach ( $check_dup_array as $check_k ) {
672
-						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
673
-							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
674
-								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
672
+						foreach ( (array) $m['value'][$check_k] as $mk => $mv ) {
673
+							if ( isset( $frm_duplicate_ids[$mv] ) ) {
674
+								$m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv];
675 675
 		                    }
676 676
 							unset( $mk, $mv );
677 677
 		                }
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 			$m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
685 685
 		}
686 686
 
687
-		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
687
+		$post['postmeta'][(string) $meta->meta_key] = $m['value'];
688 688
     }
689 689
 
690 690
     /**
@@ -711,11 +711,11 @@  discard block
 block discarded – undo
711 711
 		        $name = (string) $c;
712 712
 		    }
713 713
 
714
-			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
715
-				$post['tax_input'][ $taxonomy ] = array();
714
+			if ( ! isset( $post['tax_input'][$taxonomy] ) ) {
715
+				$post['tax_input'][$taxonomy] = array();
716 716
 			}
717 717
 
718
-			$post['tax_input'][ $taxonomy ][] = $name;
718
+			$post['tax_input'][$taxonomy][] = $name;
719 719
 			unset( $name );
720 720
 		}
721 721
     }
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 
814 814
         $message = '<ul>';
815 815
         foreach ( $result as $type => $results ) {
816
-			if ( ! isset( $t_strings[ $type ] ) ) {
816
+			if ( ! isset( $t_strings[$type] ) ) {
817 817
                 // only print imported and updated
818 818
                 continue;
819 819
             }
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
 			}
826 826
 
827 827
 			if ( ! empty( $s_message ) ) {
828
-				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
828
+				$message .= '<li><strong>' . $t_strings[$type] . ':</strong> ';
829 829
 				$message .= implode( ', ', $s_message );
830 830
 				$message .= '</li>';
831 831
 			}
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
             'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
856 856
         );
857 857
 
858
-		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
858
+		$s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type );
859 859
     }
860 860
 
861 861
 	/**
@@ -956,8 +956,8 @@  discard block
 block discarded – undo
956 956
 		$post_settings = array( 'post_type', 'post_category', 'post_content', 'post_excerpt', 'post_title', 'post_name', 'post_date', 'post_status', 'post_custom_fields', 'post_password' );
957 957
 
958 958
         foreach ( $post_settings as $post_setting ) {
959
-			if ( isset( $form_options[ $post_setting ] ) ) {
960
-				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
959
+			if ( isset( $form_options[$post_setting] ) ) {
960
+				$new_action['post_content'][$post_setting] = $form_options[$post_setting];
961 961
             }
962 962
 			unset( $post_setting );
963 963
         }
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
         if ( ! $exists ) {
986 986
 			// this isn't an email, but we need to use a class that will always be included
987 987
 			FrmDb::save_json_post( $new_action );
988
-            $imported['imported']['actions']++;
988
+            $imported['imported']['actions'] ++;
989 989
         }
990 990
     }
991 991
 
@@ -1017,11 +1017,11 @@  discard block
 block discarded – undo
1017 1017
         foreach ( $post_content as $key => $setting ) {
1018 1018
             if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
1019 1019
                 // Replace old IDs with new IDs
1020
-				$post_content[ $key ] = str_replace( $old, $new, $setting );
1020
+				$post_content[$key] = str_replace( $old, $new, $setting );
1021 1021
             } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
1022 1022
                 foreach ( $setting as $k => $val ) {
1023 1023
                     // Replace old IDs with new IDs
1024
-					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
1024
+					$post_content[$key][$k] = str_replace( $old, $new, $val );
1025 1025
                 }
1026 1026
             }
1027 1027
             unset( $key, $setting );
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
         foreach ( $notifications as $new_notification ) {
1052 1052
             $new_notification['post_type']      = $post_type;
1053 1053
             $new_notification['post_excerpt']   = 'email';
1054
-			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
1054
+			$new_notification['post_title'] = __( 'Email Notification', 'formidable' );
1055 1055
             $new_notification['menu_order']     = $form_id;
1056 1056
             $new_notification['post_status']    = 'publish';
1057 1057
 
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
 				// Switch all other field IDs in email
1065 1065
                 $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1066 1066
             }
1067
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1067
+            $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1068 1068
 
1069 1069
             $exists = get_posts( array(
1070 1070
                 'name'          => $new_notification['post_name'],
@@ -1075,7 +1075,7 @@  discard block
 block discarded – undo
1075 1075
 
1076 1076
 			if ( empty( $exists ) ) {
1077 1077
 				FrmDb::save_json_post( $new_notification );
1078
-                $imported['imported']['actions']++;
1078
+                $imported['imported']['actions'] ++;
1079 1079
             }
1080 1080
 			unset( $new_notification );
1081 1081
         }
@@ -1094,8 +1094,8 @@  discard block
 block discarded – undo
1094 1094
 	private static function remove_deprecated_notification_settings( $form_id, $form_options ) {
1095 1095
 		$delete_settings = array( 'notification', 'autoresponder', 'email_to' );
1096 1096
 		foreach ( $delete_settings as $index ) {
1097
-			if ( isset( $form_options[ $index ] ) ) {
1098
-				unset( $form_options[ $index ] );
1097
+			if ( isset( $form_options[$index] ) ) {
1098
+				unset( $form_options[$index] );
1099 1099
 			}
1100 1100
 		}
1101 1101
 		FrmForm::update( $form_id, array( 'options' => $form_options ) );
@@ -1148,12 +1148,12 @@  discard block
 block discarded – undo
1148 1148
 			'reply_to_name' => '',
1149 1149
 		);
1150 1150
         foreach ( $reply_fields as $f => $val ) {
1151
-			if ( isset( $notification[ $f ] ) ) {
1152
-				$atts[ $f ] = $notification[ $f ];
1153
-				if ( 'custom' == $notification[ $f ] ) {
1154
-					$atts[ $f ] = $notification[ 'cust_' . $f ];
1155
-				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
1156
-					$atts[ $f ] = '[' . $atts[ $f ] . ']';
1151
+			if ( isset( $notification[$f] ) ) {
1152
+				$atts[$f] = $notification[$f];
1153
+				if ( 'custom' == $notification[$f] ) {
1154
+					$atts[$f] = $notification['cust_' . $f];
1155
+				} else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) {
1156
+					$atts[$f] = '[' . $atts[$f] . ']';
1157 1157
                 }
1158 1158
             }
1159 1159
             unset( $f, $val );
@@ -1184,13 +1184,13 @@  discard block
 block discarded – undo
1184 1184
         foreach ( $atts['email_to'] as $key => $email_field ) {
1185 1185
 
1186 1186
             if ( is_numeric( $email_field ) ) {
1187
-				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1187
+				$atts['email_to'][$key] = '[' . $email_field . ']';
1188 1188
             }
1189 1189
 
1190 1190
 			if ( strpos( $email_field, '|' ) ) {
1191 1191
                 $email_opt = explode( '|', $email_field );
1192 1192
                 if ( isset( $email_opt[0] ) ) {
1193
-					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1193
+					$atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1194 1194
                 }
1195 1195
                 unset( $email_opt );
1196 1196
             }
@@ -1211,12 +1211,12 @@  discard block
 block discarded – undo
1211 1211
         // Add more fields to the new notification
1212 1212
         $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1213 1213
         foreach ( $add_fields as $add_field ) {
1214
-			if ( isset( $notification[ $add_field ] ) ) {
1215
-				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1214
+			if ( isset( $notification[$add_field] ) ) {
1215
+				$new_notification['post_content'][$add_field] = $notification[$add_field];
1216 1216
             } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1217
-				$new_notification['post_content'][ $add_field ] = 0;
1217
+				$new_notification['post_content'][$add_field] = 0;
1218 1218
             } else {
1219
-				$new_notification['post_content'][ $add_field ] = '';
1219
+				$new_notification['post_content'][$add_field] = '';
1220 1220
             }
1221 1221
             unset( $add_field );
1222 1222
         }
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
1241 1241
 			foreach ( $post_content['conditions'] as $email_key => $val ) {
1242 1242
 				if ( is_numeric( $email_key ) ) {
1243
-					$post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1243
+					$post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1244 1244
 				}
1245 1245
 				unset( $email_key, $val );
1246 1246
 			}
Please login to merge, or discard this patch.
classes/controllers/FrmFormsController.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         global $frm_vars;
65 65
 
66 66
 		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
67
-		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
67
+		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[$action];
68 68
 
69 69
 		if ( $action == 'create' ) {
70 70
 			self::create( $values );
@@ -404,11 +404,11 @@  discard block
 block discarded – undo
404 404
 			),
405 405
 		);
406 406
 
407
-		if ( ! isset( $available_status[ $status ] ) ) {
407
+		if ( ! isset( $available_status[$status] ) ) {
408 408
 			return;
409 409
 		}
410 410
 
411
-		FrmAppHelper::permission_check( $available_status[ $status ]['permission'] );
411
+		FrmAppHelper::permission_check( $available_status[$status]['permission'] );
412 412
 
413 413
 		$params = FrmForm::list_page_params();
414 414
 
@@ -416,8 +416,8 @@  discard block
 block discarded – undo
416 416
 		check_admin_referer( $status . '_form_' . $params['id'] );
417 417
 
418 418
 		$count = 0;
419
-		if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
420
-			$count++;
419
+		if ( FrmForm::set_status( $params['id'], $available_status[$status]['new_status'] ) ) {
420
+			$count ++;
421 421
 		}
422 422
 
423 423
 		$form_type = FrmAppHelper::get_simple_request( array(
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 		$available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
429 429
 		$available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type=' . $form_type . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
430 430
 
431
-		$message = $available_status[ $status ]['message'];
431
+		$message = $available_status[$status]['message'];
432 432
 
433 433
 		self::display_forms_list( $params, $message );
434 434
 	}
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
         $count = 0;
440 440
         foreach ( $ids as $id ) {
441 441
             if ( FrmForm::trash( $id ) ) {
442
-                $count++;
442
+                $count ++;
443 443
             }
444 444
         }
445 445
 
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 
463 463
         $count = 0;
464 464
         if ( FrmForm::destroy( $params['id'] ) ) {
465
-            $count++;
465
+            $count ++;
466 466
         }
467 467
 
468 468
 		$message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
         foreach ( $ids as $id ) {
478 478
             $d = FrmForm::destroy( $id );
479 479
             if ( $d ) {
480
-                $count++;
480
+                $count ++;
481 481
             }
482 482
         }
483 483
 
@@ -949,8 +949,8 @@  discard block
 block discarded – undo
949 949
 		$path = untrailingslashit( trim( $path ) );
950 950
 		$templates = glob( $path . '/*.php' );
951 951
 
952
-		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
953
-			$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) );
952
+		for ( $i = count( $templates ) - 1; $i >= 0; $i -- ) {
953
+			$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[$i] ) );
954 954
 			$template_query = array( 'form_key' => $filename );
955 955
             if ( $template ) {
956 956
                 $template_query['is_template'] = 1;
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
                 $values['default_template'] = 1;
969 969
             }
970 970
 
971
-            include( $templates[ $i ] );
971
+            include( $templates[$i] );
972 972
 
973 973
             //get updated form
974 974
 			if ( isset( $form ) && ! empty( $form ) ) {
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 				add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
1004 1004
             } else {
1005 1005
 				$vars = FrmAppHelper::json_to_array( $json_vars );
1006
-                $action = $vars[ $action ];
1006
+                $action = $vars[$action];
1007 1007
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
1008 1008
 				$_REQUEST = array_merge( $_REQUEST, $vars );
1009 1009
 				$_POST = array_merge( $_POST, $_REQUEST );
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
         $actions = array();
1079 1079
 		foreach ( $frm_vars['forms_loaded'] as $form ) {
1080 1080
 			if ( is_object( $form ) ) {
1081
-				$actions[ $form->id ] = $form->name;
1081
+				$actions[$form->id] = $form->name;
1082 1082
 			}
1083 1083
 			unset( $form );
1084 1084
 		}
@@ -1289,8 +1289,8 @@  discard block
 block discarded – undo
1289 1289
 	private static function get_saved_errors( $form, $params ) {
1290 1290
 		global $frm_vars;
1291 1291
 
1292
-		if ( $params['posted_form_id'] == $form->id && $_POST && isset( $frm_vars['created_entries'][ $form->id ] ) ) {
1293
-			$errors = $frm_vars['created_entries'][ $form->id ]['errors'];
1292
+		if ( $params['posted_form_id'] == $form->id && $_POST && isset( $frm_vars['created_entries'][$form->id] ) ) {
1293
+			$errors = $frm_vars['created_entries'][$form->id]['errors'];
1294 1294
 		} else {
1295 1295
 			$errors = array();
1296 1296
 		}
@@ -1302,7 +1302,7 @@  discard block
 block discarded – undo
1302 1302
 	 */
1303 1303
 	public static function just_created_entry( $form_id ) {
1304 1304
 		global $frm_vars;
1305
-		return ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form_id ] ) && isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) ? $frm_vars['created_entries'][ $form_id ]['entry_id'] : 0;
1305
+		return ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][$form_id] ) && isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) ? $frm_vars['created_entries'][$form_id]['entry_id'] : 0;
1306 1306
 	}
1307 1307
 
1308 1308
 	/**
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 	 */
1311 1311
 	private static function get_confirmation_method( $atts ) {
1312 1312
 		$opt = 'success_action';
1313
-		$method = ( isset( $atts['form']->options[ $opt ] ) && ! empty( $atts['form']->options[ $opt ] ) ) ? $atts['form']->options[ $opt ] : 'message';
1313
+		$method = ( isset( $atts['form']->options[$opt] ) && ! empty( $atts['form']->options[$opt] ) ) ? $atts['form']->options[$opt] : 'message';
1314 1314
 		$method = apply_filters( 'frm_success_filter', $method, $atts['form'], 'create' );
1315 1315
 
1316 1316
 		if ( $method != 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) {
@@ -1323,7 +1323,7 @@  discard block
 block discarded – undo
1323 1323
 	public static function maybe_trigger_redirect( $form, $params, $args ) {
1324 1324
 		if ( ! isset( $params['id'] ) ) {
1325 1325
 			global $frm_vars;
1326
-			$params['id'] = $frm_vars['created_entries'][ $form->id ]['entry_id'];
1326
+			$params['id'] = $frm_vars['created_entries'][$form->id]['entry_id'];
1327 1327
 		}
1328 1328
 
1329 1329
 		$conf_method = self::get_confirmation_method( array(
@@ -1363,7 +1363,7 @@  discard block
 block discarded – undo
1363 1363
 
1364 1364
 		$opt = ( ! isset( $args['action'] ) || $args['action'] == 'create' ) ? 'success' : 'edit';
1365 1365
 		$args['success_opt'] = $opt;
1366
-		if ( $args['conf_method'] == 'page' && is_numeric( $args['form']->options[ $opt . '_page_id' ] ) ) {
1366
+		if ( $args['conf_method'] == 'page' && is_numeric( $args['form']->options[$opt . '_page_id'] ) ) {
1367 1367
 			self::load_page_after_submit( $args );
1368 1368
 		} elseif ( $args['conf_method'] == 'redirect' ) {
1369 1369
 			self::redirect_after_submit( $args );
@@ -1378,8 +1378,8 @@  discard block
 block discarded – undo
1378 1378
 	private static function load_page_after_submit( $args ) {
1379 1379
 		global $post;
1380 1380
 		$opt = $args['success_opt'];
1381
-		if ( ! $post || $args['form']->options[ $opt . '_page_id' ] != $post->ID ) {
1382
-			$page = get_post( $args['form']->options[ $opt . '_page_id' ] );
1381
+		if ( ! $post || $args['form']->options[$opt . '_page_id'] != $post->ID ) {
1382
+			$page = get_post( $args['form']->options[$opt . '_page_id'] );
1383 1383
 			$old_post = $post;
1384 1384
 			$post = $page;
1385 1385
 			$content = apply_filters( 'frm_content', $page->post_content, $args['form'], $args['entry_id'] );
@@ -1397,11 +1397,11 @@  discard block
 block discarded – undo
1397 1397
 		add_filter( 'frm_use_wpautop', '__return_false' );
1398 1398
 
1399 1399
 		$opt = $args['success_opt'];
1400
-		$success_url = trim( $args['form']->options[ $opt . '_url' ] );
1400
+		$success_url = trim( $args['form']->options[$opt . '_url'] );
1401 1401
 		$success_url = apply_filters( 'frm_content', $success_url, $args['form'], $args['entry_id'] );
1402 1402
 		$success_url = do_shortcode( $success_url );
1403 1403
 
1404
-		$success_msg = isset( $args['form']->options[ $opt . '_msg' ] ) ? $args['form']->options[ $opt . '_msg' ] : __( 'Please wait while you are redirected.', 'formidable' );
1404
+		$success_msg = isset( $args['form']->options[$opt . '_msg'] ) ? $args['form']->options[$opt . '_msg'] : __( 'Please wait while you are redirected.', 'formidable' );
1405 1405
 
1406 1406
 		$redirect_msg = self::get_redirect_message( $success_url, $success_msg, $args );
1407 1407
 
Please login to merge, or discard this patch.