Completed
Push — master ( ce8119...4b9c52 )
by Jamie
04:16
created
classes/helpers/FrmStylesHelper.php 2 patches
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -1,67 +1,67 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class FrmStylesHelper {
3 3
 
4
-    public static function jquery_themes() {
5
-        $themes = array(
6
-            'ui-lightness'  => 'UI Lightness',
7
-            'ui-darkness'   => 'UI Darkness',
8
-            'smoothness'    => 'Smoothness',
9
-            'start'         => 'Start',
10
-            'redmond'       => 'Redmond',
11
-            'sunny'         => 'Sunny',
12
-            'overcast'      => 'Overcast',
13
-            'le-frog'       => 'Le Frog',
14
-            'flick'         => 'Flick',
4
+	public static function jquery_themes() {
5
+		$themes = array(
6
+			'ui-lightness'  => 'UI Lightness',
7
+			'ui-darkness'   => 'UI Darkness',
8
+			'smoothness'    => 'Smoothness',
9
+			'start'         => 'Start',
10
+			'redmond'       => 'Redmond',
11
+			'sunny'         => 'Sunny',
12
+			'overcast'      => 'Overcast',
13
+			'le-frog'       => 'Le Frog',
14
+			'flick'         => 'Flick',
15 15
 			'pepper-grinder' => 'Pepper Grinder',
16
-            'eggplant'      => 'Eggplant',
17
-            'dark-hive'     => 'Dark Hive',
18
-            'cupertino'     => 'Cupertino',
19
-            'south-street'  => 'South Street',
20
-            'blitzer'       => 'Blitzer',
21
-            'humanity'      => 'Humanity',
22
-            'hot-sneaks'    => 'Hot Sneaks',
23
-            'excite-bike'   => 'Excite Bike',
24
-            'vader'         => 'Vader',
25
-            'dot-luv'       => 'Dot Luv',
26
-            'mint-choc'     => 'Mint Choc',
27
-            'black-tie'     => 'Black Tie',
28
-            'trontastic'    => 'Trontastic',
29
-            'swanky-purse'  => 'Swanky Purse',
30
-        );
31
-
32
-        $themes = apply_filters('frm_jquery_themes', $themes);
33
-        return $themes;
34
-    }
16
+			'eggplant'      => 'Eggplant',
17
+			'dark-hive'     => 'Dark Hive',
18
+			'cupertino'     => 'Cupertino',
19
+			'south-street'  => 'South Street',
20
+			'blitzer'       => 'Blitzer',
21
+			'humanity'      => 'Humanity',
22
+			'hot-sneaks'    => 'Hot Sneaks',
23
+			'excite-bike'   => 'Excite Bike',
24
+			'vader'         => 'Vader',
25
+			'dot-luv'       => 'Dot Luv',
26
+			'mint-choc'     => 'Mint Choc',
27
+			'black-tie'     => 'Black Tie',
28
+			'trontastic'    => 'Trontastic',
29
+			'swanky-purse'  => 'Swanky Purse',
30
+		);
31
+
32
+		$themes = apply_filters('frm_jquery_themes', $themes);
33
+		return $themes;
34
+	}
35 35
 
36 36
 	public static function jquery_css_url( $theme_css ) {
37
-        if ( $theme_css == -1 ) {
38
-            return;
39
-        }
40
-
41
-        if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42
-            $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
-        } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) {
44
-            $css_file = $theme_css;
45
-        } else {
46
-            $uploads = self::get_upload_base();
37
+		if ( $theme_css == -1 ) {
38
+			return;
39
+		}
40
+
41
+		if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42
+			$css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
+		} else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) {
44
+			$css_file = $theme_css;
45
+		} else {
46
+			$uploads = self::get_upload_base();
47 47
 			$file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css';
48
-            if ( file_exists($uploads['basedir'] . $file_path) ) {
49
-                $css_file = $uploads['baseurl'] . $file_path;
50
-            } else {
48
+			if ( file_exists($uploads['basedir'] . $file_path) ) {
49
+				$css_file = $uploads['baseurl'] . $file_path;
50
+			} else {
51 51
 				$css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css';
52
-            }
53
-        }
52
+			}
53
+		}
54 54
 
55
-        return $css_file;
56
-    }
55
+		return $css_file;
56
+	}
57 57
 
58
-    public static function enqueue_jquery_css() {
58
+	public static function enqueue_jquery_css() {
59 59
 		$form = self::get_form_for_page();
60 60
 		$theme_css = FrmStylesController::get_style_val( 'theme_css', $form );
61
-        if ( $theme_css != -1 ) {
62
-            wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
63
-        }
64
-    }
61
+		if ( $theme_css != -1 ) {
62
+			wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
63
+		}
64
+	}
65 65
 
66 66
 	public static function get_form_for_page() {
67 67
 		global $frm_vars;
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
 		return $form_id;
78 78
 	}
79 79
 
80
-    public static function get_upload_base() {
81
-        $uploads = wp_upload_dir();
82
-        if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) {
83
-            $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
84
-        }
80
+	public static function get_upload_base() {
81
+		$uploads = wp_upload_dir();
82
+		if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) {
83
+			$uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
84
+		}
85 85
 
86
-        return $uploads;
87
-    }
86
+		return $uploads;
87
+	}
88 88
 
89 89
 	public static function style_menu( $active = '' ) {
90 90
 ?>
@@ -94,22 +94,22 @@  discard block
 block discarded – undo
94 94
 			<a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a>
95 95
         </h2>
96 96
 <?php
97
-    }
97
+	}
98 98
 
99
-    public static function minus_icons() {
100
-        return array(
99
+	public static function minus_icons() {
100
+		return array(
101 101
 			0 => array( '-' => '62e', '+' => '62f' ),
102 102
 			1 => array( '-' => '600', '+' => '602' ),
103 103
 			2 => array( '-' => '604', '+' => '603' ),
104 104
 			3 => array( '-' => '633', '+' => '632' ),
105 105
 			4 => array( '-' => '613', '+' => '60f' ),
106
-        );
107
-    }
106
+		);
107
+	}
108 108
 
109
-    public static function arrow_icons() {
110
-        $minus_icons = self::minus_icons();
109
+	public static function arrow_icons() {
110
+		$minus_icons = self::minus_icons();
111 111
 
112
-        return array(
112
+		return array(
113 113
 			6 => array( '-' => '62d', '+' => '62a' ),
114 114
 			0 => array( '-' => '60d', '+' => '609' ),
115 115
 			1 => array( '-' => '60e', '+' => '60c' ),
@@ -117,44 +117,44 @@  discard block
 block discarded – undo
117 117
 			3 => array( '-' => '62b', '+' => '628' ),
118 118
 			4 => array( '-' => '62c', '+' => '629' ),
119 119
 			5 => array( '-' => '635', '+' => '634' ),
120
-            'p0' => $minus_icons[0],
121
-            'p1' => $minus_icons[1],
122
-            'p2' => $minus_icons[2],
123
-            'p3' => $minus_icons[3],
124
-            'p4' => $minus_icons[4],
125
-        );
126
-    }
127
-
128
-    /**
129
-     * @since 2.0
130
-     * @return The class for this icon
131
-     */
120
+			'p0' => $minus_icons[0],
121
+			'p1' => $minus_icons[1],
122
+			'p2' => $minus_icons[2],
123
+			'p3' => $minus_icons[3],
124
+			'p4' => $minus_icons[4],
125
+		);
126
+	}
127
+
128
+	/**
129
+	 * @since 2.0
130
+	 * @return The class for this icon
131
+	 */
132 132
 	public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) {
133
-        if ( 'arrow' == $type && is_numeric($key) ) {
134
-            //frm_arrowup6_icon
133
+		if ( 'arrow' == $type && is_numeric($key) ) {
134
+			//frm_arrowup6_icon
135 135
 			$arrow = array( '-' => 'down', '+' => 'up' );
136 136
 			$class = 'frm_arrow' . $arrow[ $icon ];
137
-        } else {
138
-            //frm_minus1_icon
139
-            $key = str_replace('p', '', $key);
137
+		} else {
138
+			//frm_minus1_icon
139
+			$key = str_replace('p', '', $key);
140 140
 			$plus = array( '-' => 'minus', '+' => 'plus' );
141 141
 			$class = 'frm_' . $plus[ $icon ];
142
-        }
142
+		}
143 143
 
144
-        if ( $key ) {
145
-            $class .= $key;
146
-        }
147
-        $class .= '_icon';
144
+		if ( $key ) {
145
+			$class .= $key;
146
+		}
147
+		$class .= '_icon';
148 148
 
149
-        return $class;
150
-    }
149
+		return $class;
150
+	}
151 151
 
152 152
 	public static function bs_icon_select( $style, $frm_style, $type = 'arrow' ) {
153 153
 		$function_name = $type . '_icons';
154 154
 		$icons = self::$function_name();
155 155
 		unset( $function_name );
156 156
 
157
-        $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
157
+		$name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
158 158
 ?>
159 159
     	<select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
160 160
             <?php foreach ( $icons as $key => $icon ) { ?>
@@ -187,22 +187,22 @@  discard block
 block discarded – undo
187 187
             </ul>
188 188
         </div>
189 189
 <?php
190
-    }
190
+	}
191 191
 
192 192
 	public static function hex2rgb( $hex ) {
193
-        $hex = str_replace('#', '', $hex);
193
+		$hex = str_replace('#', '', $hex);
194 194
 
195
-        if ( strlen($hex) == 3 ) {
195
+		if ( strlen($hex) == 3 ) {
196 196
 			$r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
197 197
 			$g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) );
198 198
 			$b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) );
199
-        } else {
199
+		} else {
200 200
 			$r = hexdec( substr( $hex, 0, 2 ) );
201 201
 			$g = hexdec( substr( $hex, 2, 2 ) );
202 202
 			$b = hexdec( substr( $hex, 4, 2 ) );
203
-        }
203
+		}
204 204
 		$rgb = array( $r, $g, $b );
205
-        return implode(',', $rgb); // returns the rgb values separated by commas
206
-        //return $rgb; // returns an array with the rgb values
207
-    }
205
+		return implode(',', $rgb); // returns the rgb values separated by commas
206
+		//return $rgb; // returns an array with the rgb values
207
+	}
208 208
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
             'swanky-purse'  => 'Swanky Purse',
30 30
         );
31 31
 
32
-        $themes = apply_filters('frm_jquery_themes', $themes);
32
+        $themes = apply_filters( 'frm_jquery_themes', $themes );
33 33
         return $themes;
34 34
     }
35 35
 
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 
41 41
         if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42 42
             $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
-        } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) {
43
+        } else if ( preg_match( '/^http.?:\/\/.*\..*$/', $theme_css ) ) {
44 44
             $css_file = $theme_css;
45 45
         } else {
46 46
             $uploads = self::get_upload_base();
47 47
 			$file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css';
48
-            if ( file_exists($uploads['basedir'] . $file_path) ) {
48
+            if ( file_exists( $uploads['basedir'] . $file_path ) ) {
49 49
                 $css_file = $uploads['baseurl'] . $file_path;
50 50
             } else {
51 51
 				$css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css';
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		$form = self::get_form_for_page();
60 60
 		$theme_css = FrmStylesController::get_style_val( 'theme_css', $form );
61 61
         if ( $theme_css != -1 ) {
62
-            wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
62
+            wp_enqueue_style( 'jquery-theme', self::jquery_css_url( $theme_css ), array(), FrmAppHelper::plugin_version() );
63 63
         }
64 64
     }
65 65
 
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 
80 80
     public static function get_upload_base() {
81 81
         $uploads = wp_upload_dir();
82
-        if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) {
83
-            $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
82
+        if ( is_ssl() && ! preg_match( '/^https:\/\/.*\..*$/', $uploads['baseurl'] ) ) {
83
+            $uploads['baseurl'] = str_replace( 'http://', 'https://', $uploads['baseurl'] );
84 84
         }
85 85
 
86 86
         return $uploads;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         <h2 class="nav-tab-wrapper">
92 92
 			<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles' ) ) ?>" class="nav-tab <?php echo ( '' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Edit Styles', 'formidable' ) ?></a>
93 93
 			<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=manage' ) ) ?>" class="nav-tab <?php echo ( 'manage' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Manage Form Styles', 'formidable' ) ?></a>
94
-			<a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a>
94
+			<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a>
95 95
         </h2>
96 96
 <?php
97 97
     }
@@ -130,15 +130,15 @@  discard block
 block discarded – undo
130 130
      * @return The class for this icon
131 131
      */
132 132
 	public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) {
133
-        if ( 'arrow' == $type && is_numeric($key) ) {
133
+        if ( 'arrow' == $type && is_numeric( $key ) ) {
134 134
             //frm_arrowup6_icon
135 135
 			$arrow = array( '-' => 'down', '+' => 'up' );
136
-			$class = 'frm_arrow' . $arrow[ $icon ];
136
+			$class = 'frm_arrow' . $arrow[$icon];
137 137
         } else {
138 138
             //frm_minus1_icon
139
-            $key = str_replace('p', '', $key);
139
+            $key = str_replace( 'p', '', $key );
140 140
 			$plus = array( '-' => 'minus', '+' => 'plus' );
141
-			$class = 'frm_' . $plus[ $icon ];
141
+			$class = 'frm_' . $plus[$icon];
142 142
         }
143 143
 
144 144
         if ( $key ) {
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
 
157 157
         $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
158 158
 ?>
159
-    	<select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
159
+    	<select name="<?php echo esc_attr( $frm_style->get_field_name( $name ) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
160 160
             <?php foreach ( $icons as $key => $icon ) { ?>
161
-			<option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[ $name ], $key ) ?>>
161
+			<option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[$name], $key ) ?>>
162 162
 				<?php echo '&#xe' . $icon['+'] . '; &#xe' . $icon['-'] . ';'; ?>
163 163
             </option>
164 164
             <?php } ?>
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 
167 167
         <div class="btn-group hide-if-no-js" id="frm_<?php echo esc_attr( $name ) ?>_select">
168 168
             <button class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" type="button">
169
-				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '+', $type ) ) ?>"></i>
170
-				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '-', $type ) ) ?>"></i>
169
+				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '+', $type ) ) ?>"></i>
170
+				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '-', $type ) ) ?>"></i>
171 171
                 <b class="caret"></b>
172 172
             </button>
173 173
             <ul class="multiselect-container frm-dropdown-menu">
@@ -190,9 +190,9 @@  discard block
 block discarded – undo
190 190
     }
191 191
 
192 192
 	public static function hex2rgb( $hex ) {
193
-        $hex = str_replace('#', '', $hex);
193
+        $hex = str_replace( '#', '', $hex );
194 194
 
195
-        if ( strlen($hex) == 3 ) {
195
+        if ( strlen( $hex ) == 3 ) {
196 196
 			$r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
197 197
 			$g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) );
198 198
 			$b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) );
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 			$b = hexdec( substr( $hex, 4, 2 ) );
203 203
         }
204 204
 		$rgb = array( $r, $g, $b );
205
-        return implode(',', $rgb); // returns the rgb values separated by commas
205
+        return implode( ',', $rgb ); // returns the rgb values separated by commas
206 206
         //return $rgb; // returns an array with the rgb values
207 207
     }
208 208
 }
Please login to merge, or discard this patch.
css/_single_theme.css.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -3,23 +3,23 @@  discard block
 block discarded – undo
3 3
 if ( isset($_GET['frm_style_setting']) || isset($_GET['flat']) ) {
4 4
 	if ( isset( $_GET['frm_style_setting'] ) ) {
5 5
 		extract( $_GET['frm_style_setting']['post_content'] );
6
-    } else {
7
-        extract($_GET);
8
-    }
6
+	} else {
7
+		extract($_GET);
8
+	}
9 9
 
10
-    $important_style = isset($important_style) ? $important_style : 0;
11
-    $auto_width = isset($auto_width) ? $auto_width : 0;
12
-    $submit_style = isset($submit_style) ? $submit_style : 0;
10
+	$important_style = isset($important_style) ? $important_style : 0;
11
+	$auto_width = isset($auto_width) ? $auto_width : 0;
12
+	$submit_style = isset($submit_style) ? $submit_style : 0;
13 13
 
14 14
 	$style_name = FrmAppHelper::simple_get( 'style_name', 'sanitize_title' );
15 15
 	if ( ! empty( $style_name ) ) {
16 16
 		$style_class = $style_name . '.with_frm_style';
17
-    } else {
18
-        $style_class = 'with_frm_style';
19
-    }
17
+	} else {
18
+		$style_class = 'with_frm_style';
19
+	}
20 20
 } else {
21 21
 	$style_class = 'frm_style_' . $style->post_name . '.with_frm_style';
22
-    extract($style->post_content);
22
+	extract($style->post_content);
23 23
 }
24 24
 
25 25
 $important = empty($important_style) ? '' : ' !important';
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 }
41 41
 
42 42
 if ( ! isset($collapse_icon) ) {
43
-    $collapse_icon = 0;
43
+	$collapse_icon = 0;
44 44
 }
45 45
 
46 46
 if ( ! isset( $center_form ) ) {
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
     color:#<?php echo esc_html( $text_color . $important ) ?>;
338 338
 	background-color:<?php echo esc_html( ( empty( $bg_color ) ? 'transparent' : '#' . $bg_color ) . $important ); ?>;
339 339
 <?php if ( ! empty($important) ) {
340
-    echo esc_html( 'background-image:none' . $important . ';' );
340
+	echo esc_html( 'background-image:none' . $important . ';' );
341 341
 }
342 342
 ?>
343 343
     border-color:#<?php echo esc_html( $border_color . $important ) ?>;
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
     color:#<?php echo esc_html( $submit_active_color . $important ) ?>;
549 549
 }
550 550
 <?php
551
-    }
551
+	}
552 552
 }
553 553
 ?>
554 554
 
@@ -851,11 +851,11 @@  discard block
 block discarded – undo
851 851
 
852 852
 .<?php echo esc_html( $style_class ) ?> .chosen-container-single .chosen-single div{
853 853
 <?php
854
-    // calculate the top position based on field padding
855
-    $top_pad = explode(' ', $field_pad);
856
-    $top_pad = reset($top_pad); // the top padding is listed first
857
-    $pad_unit = preg_replace('/[0-9]+/', '', $top_pad); //px, em, rem...
858
-    $top_margin = (int) str_replace($pad_unit, '', $top_pad) / 2;
854
+	// calculate the top position based on field padding
855
+	$top_pad = explode(' ', $field_pad);
856
+	$top_pad = reset($top_pad); // the top padding is listed first
857
+	$pad_unit = preg_replace('/[0-9]+/', '', $top_pad); //px, em, rem...
858
+	$top_margin = (int) str_replace($pad_unit, '', $top_pad) / 2;
859 859
 ?>
860 860
     top:<?php echo esc_html( $top_margin . $pad_unit . $important ) ?>;
861 861
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( isset($_GET['frm_style_setting']) || isset($_GET['flat']) ) {
3
+if ( isset( $_GET['frm_style_setting'] ) || isset( $_GET['flat'] ) ) {
4 4
 	if ( isset( $_GET['frm_style_setting'] ) ) {
5 5
 		extract( $_GET['frm_style_setting']['post_content'] );
6 6
     } else {
7
-        extract($_GET);
7
+        extract( $_GET );
8 8
     }
9 9
 
10
-    $important_style = isset($important_style) ? $important_style : 0;
11
-    $auto_width = isset($auto_width) ? $auto_width : 0;
12
-    $submit_style = isset($submit_style) ? $submit_style : 0;
10
+    $important_style = isset( $important_style ) ? $important_style : 0;
11
+    $auto_width = isset( $auto_width ) ? $auto_width : 0;
12
+    $submit_style = isset( $submit_style ) ? $submit_style : 0;
13 13
 
14 14
 	$style_name = FrmAppHelper::simple_get( 'style_name', 'sanitize_title' );
15 15
 	if ( ! empty( $style_name ) ) {
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
     }
20 20
 } else {
21 21
 	$style_class = 'frm_style_' . $style->post_name . '.with_frm_style';
22
-    extract($style->post_content);
22
+    extract( $style->post_content );
23 23
 }
24 24
 
25
-$important = empty($important_style) ? '' : ' !important';
25
+$important = empty( $important_style ) ? '' : ' !important';
26 26
 $label_margin = (int) $width + 10;
27 27
 
28 28
 $minus_icons = FrmStylesHelper::minus_icons();
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	$change_margin = 650 . 'px';
40 40
 }
41 41
 
42
-if ( ! isset($collapse_icon) ) {
42
+if ( ! isset( $collapse_icon ) ) {
43 43
     $collapse_icon = 0;
44 44
 }
45 45
 
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
 }
149 149
 
150 150
 .<?php echo esc_html( $style_class ) ?> .frm_icon_font.frm_minus_icon:before{
151
-	content:"\e<?php echo esc_html( isset( $minus_icons[ $repeat_icon ] ) ? $minus_icons[ $repeat_icon ]['-'] : $minus_icons[1]['-'] ) ?>";
151
+	content:"\e<?php echo esc_html( isset( $minus_icons[$repeat_icon] ) ? $minus_icons[$repeat_icon]['-'] : $minus_icons[1]['-'] ) ?>";
152 152
 }
153 153
 
154 154
 .<?php echo esc_html( $style_class ) ?> .frm_icon_font.frm_plus_icon:before{
155
-	content:"\e<?php echo esc_html( isset( $minus_icons[ $repeat_icon ] ) ? $minus_icons[ $repeat_icon ]['+'] : $minus_icons[1]['+'] ) ?>";
155
+	content:"\e<?php echo esc_html( isset( $minus_icons[$repeat_icon] ) ? $minus_icons[$repeat_icon]['+'] : $minus_icons[1]['+'] ) ?>";
156 156
 }
157 157
 
158 158
 .<?php echo esc_html( $style_class ) ?> .frm_icon_font.frm_minus_icon:before,
@@ -161,11 +161,11 @@  discard block
 block discarded – undo
161 161
 }
162 162
 
163 163
 .<?php echo esc_html( $style_class ) ?> .frm_trigger.active .frm_icon_font.frm_arrow_icon:before{
164
-	content:"\e<?php echo esc_html( isset( $arrow_icons[ $collapse_icon ] ) ? $arrow_icons[ $collapse_icon ]['-'] : $arrow_icons[1]['-'] ) ?>";
164
+	content:"\e<?php echo esc_html( isset( $arrow_icons[$collapse_icon] ) ? $arrow_icons[$collapse_icon]['-'] : $arrow_icons[1]['-'] ) ?>";
165 165
 }
166 166
 
167 167
 .<?php echo esc_html( $style_class ) ?> .frm_trigger .frm_icon_font.frm_arrow_icon:before{
168
-	content:"\e<?php echo esc_html( isset( $arrow_icons[ $collapse_icon ] ) ? $arrow_icons[ $collapse_icon ]['+'] : $arrow_icons[1]['+'] ) ?>";
168
+	content:"\e<?php echo esc_html( isset( $arrow_icons[$collapse_icon] ) ? $arrow_icons[$collapse_icon]['+'] : $arrow_icons[1]['+'] ) ?>";
169 169
 }
170 170
 
171 171
 .<?php echo esc_html( $style_class ) ?> .form-field{
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 .<?php echo esc_html( $style_class ) ?> .frm_error{
188 188
     margin:0;
189 189
     padding:0;
190
-    font-family:<?php echo FrmAppHelper::kses( stripslashes($font) . $important ) ?>;
190
+    font-family:<?php echo FrmAppHelper::kses( stripslashes( $font ) . $important ) ?>;
191 191
     font-size:<?php echo esc_html( $description_font_size . $important ) ?>;
192 192
     color:#<?php echo esc_html( $description_color . $important ) ?>;
193 193
     font-weight:<?php echo esc_html( $description_weight . $important ) ?>;
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 
294 294
 .<?php echo esc_html( $style_class ) ?> .frm_scale label{
295 295
     font-weight:<?php echo esc_html( $check_weight . $important ) ?>;
296
-    font-family:<?php echo FrmAppHelper::kses( stripslashes($font) . $important ) ?>;
296
+    font-family:<?php echo FrmAppHelper::kses( stripslashes( $font ) . $important ) ?>;
297 297
     font-size:<?php echo esc_html( $check_font_size . $important ) ?>;
298 298
     color:#<?php echo esc_html( $check_label_color . $important ) ?>;
299 299
 }
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 .<?php echo esc_html( $style_class ) ?> select,
314 314
 .<?php echo esc_html( $style_class ) ?> textarea,
315 315
 .<?php echo esc_html( $style_class ) ?> .chosen-container{
316
-	font-family:<?php echo FrmAppHelper::kses( stripslashes($font) . $important ) ?>;
316
+	font-family:<?php echo FrmAppHelper::kses( stripslashes( $font ) . $important ) ?>;
317 317
     font-size:<?php echo esc_html( $field_font_size ) ?>;
318 318
     margin-bottom:0<?php echo esc_html( $important ) ?>;
319 319
 }
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 .<?php echo esc_html( $style_class ) ?> .chosen-container-single .chosen-single{
337 337
     color:#<?php echo esc_html( $text_color . $important ) ?>;
338 338
 	background-color:<?php echo esc_html( ( empty( $bg_color ) ? 'transparent' : '#' . $bg_color ) . $important ); ?>;
339
-<?php if ( ! empty($important) ) {
339
+<?php if ( ! empty( $important ) ) {
340 340
     echo esc_html( 'background-image:none' . $important . ';' );
341 341
 }
342 342
 ?>
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
     line-height:normal<?php echo esc_html( $important ) ?>;
495 495
     text-align:center;
496 496
     background:#<?php echo esc_html( $submit_bg_color );
497
-	if ( ! empty($submit_bg_img) ) {
497
+	if ( ! empty( $submit_bg_img ) ) {
498 498
 		echo esc_html( ' url(' . $submit_bg_img . ')' );
499 499
 	}
500 500
 	echo esc_html( $important ); ?>;
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 
593 593
 .<?php echo esc_html( $style_class ) ?> .frm_radio label,
594 594
 .<?php echo esc_html( $style_class ) ?> .frm_checkbox label{
595
-    font-family:<?php echo FrmAppHelper::kses( stripslashes($font) . $important ) ?>;
595
+    font-family:<?php echo FrmAppHelper::kses( stripslashes( $font ) . $important ) ?>;
596 596
     font-size:<?php echo esc_html( $check_font_size . $important ) ?>;
597 597
     color:#<?php echo esc_html( $check_label_color . $important ) ?>;
598 598
     font-weight:<?php echo esc_html( $check_weight . $important ) ?>;
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
     -webkit-border-radius:<?php echo esc_html( $border_radius . $important ) ?>;
734 734
     border-radius:<?php echo esc_html( $border_radius . $important ) ?>;
735 735
     font-size:<?php echo esc_html( $submit_font_size . $important ) ?>;
736
-    font-family:<?php echo FrmAppHelper::kses( stripslashes($font) . $important ) ?>;
736
+    font-family:<?php echo FrmAppHelper::kses( stripslashes( $font ) . $important ) ?>;
737 737
     font-weight:<?php echo esc_html( $submit_weight . $important ) ?>;
738 738
     color:#<?php echo esc_html( $submit_text_color . $important ) ?>;
739 739
     background:#<?php echo esc_html( $submit_bg_color . $important ) ?>;
@@ -852,10 +852,10 @@  discard block
 block discarded – undo
852 852
 .<?php echo esc_html( $style_class ) ?> .chosen-container-single .chosen-single div{
853 853
 <?php
854 854
     // calculate the top position based on field padding
855
-    $top_pad = explode(' ', $field_pad);
856
-    $top_pad = reset($top_pad); // the top padding is listed first
857
-    $pad_unit = preg_replace('/[0-9]+/', '', $top_pad); //px, em, rem...
858
-    $top_margin = (int) str_replace($pad_unit, '', $top_pad) / 2;
855
+    $top_pad = explode( ' ', $field_pad );
856
+    $top_pad = reset( $top_pad ); // the top padding is listed first
857
+    $pad_unit = preg_replace( '/[0-9]+/', '', $top_pad ); //px, em, rem...
858
+    $top_margin = (int) str_replace( $pad_unit, '', $top_pad ) / 2;
859 859
 ?>
860 860
     top:<?php echo esc_html( $top_margin . $pad_unit . $important ) ?>;
861 861
 }
Please login to merge, or discard this patch.
css/custom_theme.css.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! isset($saving) ) {
3
-    header( 'Content-type: text/css' );
3
+	header( 'Content-type: text/css' );
4 4
 
5
-    if ( isset($css) && $css ) {
6
-        echo $css;
7
-        die();
8
-    }
5
+	if ( isset($css) && $css ) {
6
+		echo $css;
7
+		die();
8
+	}
9 9
 }
10 10
 
11 11
 if ( ! isset($frm_style) ) {
12
-    $frm_style = new FrmStyle();
12
+	$frm_style = new FrmStyle();
13 13
 }
14 14
 
15 15
 $styles = $frm_style->get_all();
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 <?php
188 188
 foreach ( $styles as $style ) {
189 189
 	include( dirname( __FILE__ ) . '/_single_theme.css.php' );
190
-    unset($style);
190
+	unset($style);
191 191
 }
192 192
 ?>
193 193
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! isset($saving) ) {
2
+if ( ! isset( $saving ) ) {
3 3
     header( 'Content-type: text/css' );
4 4
 
5
-    if ( isset($css) && $css ) {
5
+    if ( isset( $css ) && $css ) {
6 6
         echo $css;
7 7
         die();
8 8
     }
9 9
 }
10 10
 
11
-if ( ! isset($frm_style) ) {
11
+if ( ! isset( $frm_style ) ) {
12 12
     $frm_style = new FrmStyle();
13 13
 }
14 14
 
15 15
 $styles = $frm_style->get_all();
16
-$default_style = $frm_style->get_default_style($styles);
16
+$default_style = $frm_style->get_default_style( $styles );
17 17
 $defaults = $default_style->post_content;
18 18
 ?>
19 19
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 <?php
188 188
 foreach ( $styles as $style ) {
189 189
 	include( dirname( __FILE__ ) . '/_single_theme.css.php' );
190
-    unset($style);
190
+    unset( $style );
191 191
 }
192 192
 ?>
193 193
 
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
     overflow:hidden!important;
620 620
 }
621 621
 
622
-<?php include( dirname(__FILE__) . '/frm_grids.css' ); ?>
622
+<?php include( dirname( __FILE__ ) . '/frm_grids.css' ); ?>
623 623
 
624 624
 /* Left and right label styling for non-Formidable styling - very basic, not responsive */
625 625
 .frm_form_field.frm_left_container label.frm_primary_label{
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
     -moz-border-radius:<?php echo $defaults['border_radius'] ?>;
976 976
     -webkit-border-radius:<?php echo $defaults['border_radius'] ?>;
977 977
     border-radius:<?php echo $defaults['border_radius'] ?>;
978
-    width:<?php echo ($defaults['field_width'] == '' ? 'auto' : $defaults['field_width']) ?>;
978
+    width:<?php echo ( $defaults['field_width'] == '' ? 'auto' : $defaults['field_width'] ) ?>;
979 979
     max-width:100%;
980 980
     font-size:<?php echo $defaults['field_font_size'] ?>;
981 981
     padding:<?php echo $defaults['field_pad'] ?>;
Please login to merge, or discard this patch.
classes/views/frm-fields/input.php 2 patches
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -10,41 +10,41 @@  discard block
 block discarded – undo
10 10
 <?php
11 11
 
12 12
 } else if ( $field['type'] == 'radio' ) {
13
-    $read_only = false;
13
+	$read_only = false;
14 14
 	if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
15
-        $read_only = true; ?>
15
+		$read_only = true; ?>
16 16
 <input type="hidden" value="<?php echo esc_attr( $field['value'] ) ?>" name="<?php echo esc_attr( $field_name ) ?>" />
17 17
 <?php
18
-    }
18
+	}
19 19
 
20
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
20
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
21 21
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
22
-    } else if ( is_array($field['options']) ) {
23
-        foreach ( $field['options'] as $opt_key => $opt ) {
22
+	} else if ( is_array($field['options']) ) {
23
+		foreach ( $field['options'] as $opt_key => $opt ) {
24 24
 			if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
25
-                continue;
26
-            }
25
+				continue;
26
+			}
27 27
 
28
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
28
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
30 30
 			<div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php
31 31
 
32 32
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
33 33
 				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
34
-            }
35
-            $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
34
+			}
35
+			$checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
36 36
 
37
-            $other_opt = false;
38
-            $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39
-            ?>
37
+			$other_opt = false;
38
+			$other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39
+			?>
40 40
             <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php
41
-            echo $checked;
42
-            do_action('frm_field_input_html', $field);
41
+			echo $checked;
42
+			do_action('frm_field_input_html', $field);
43 43
 ?>/><?php
44 44
 
45 45
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
46 46
 				echo ' ' . $opt . '</label>';
47
-            }
47
+			}
48 48
 
49 49
 			FrmFieldsHelper::include_other_input( array(
50 50
 				'other_opt' => $other_opt, 'read_only' => $read_only,
@@ -53,14 +53,14 @@  discard block
 block discarded – undo
53 53
 				'html_id' => $html_id, 'opt_key' => $opt_key,
54 54
 			) );
55 55
 
56
-            unset( $other_opt, $other_args );
56
+			unset( $other_opt, $other_args );
57 57
 ?></div>
58 58
 <?php
59
-        }
60
-    }
59
+		}
60
+	}
61 61
 } else if ( $field['type'] == 'select' ) {
62
-    $read_only = false;
63
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
62
+	$read_only = false;
63
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
64 64
 		echo FrmFieldsHelper::dropdown_categories( array( 'name' => $field_name, 'field' => $field ) );
65 65
 	} else {
66 66
 		if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 			?>
94 94
 		<option value="<?php echo esc_attr($field_val) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : '';?>><?php echo ($opt == '') ? ' ' : $opt; ?></option>
95 95
     <?php
96
-    	} ?>
96
+		} ?>
97 97
 </select>
98 98
 <?php
99 99
 		FrmFieldsHelper::include_other_input( array(
@@ -102,52 +102,52 @@  discard block
 block discarded – undo
102 102
 			'value' => $other_args['value'], 'field' => $field,
103 103
 			'html_id' => $html_id, 'opt_key' => false,
104 104
 		) );
105
-    }
105
+	}
106 106
 } else if ( $field['type'] == 'checkbox' ) {
107
-    $checked_values = $field['value'];
108
-    $read_only = false;
107
+	$checked_values = $field['value'];
108
+	$read_only = false;
109 109
 
110 110
 	if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
111
-        $read_only = true;
112
-        if ( $checked_values ) {
113
-            foreach ( (array) $checked_values as $checked_value ) { ?>
111
+		$read_only = true;
112
+		if ( $checked_values ) {
113
+			foreach ( (array) $checked_values as $checked_value ) { ?>
114 114
 <input type="hidden" value="<?php echo esc_attr( $checked_value ) ?>" name="<?php echo esc_attr( $field_name ) ?>[]" />
115 115
 <?php
116
-            }
117
-        } else { ?>
116
+			}
117
+		} else { ?>
118 118
 <input type="hidden" value="" name="<?php echo esc_attr( $field_name ) ?>[]" />
119 119
 <?php
120
-        }
121
-    }
120
+		}
121
+	}
122 122
 
123
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
123
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
124 124
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
125
-    } else if ( $field['options'] ) {
126
-        foreach ( $field['options'] as $opt_key => $opt ) {
127
-            if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
128
-                continue;
129
-            }
130
-
131
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
132
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
133
-            $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
134
-
135
-            // Check if other opt, and get values for other field if needed
136
-            $other_opt = false;
125
+	} else if ( $field['options'] ) {
126
+		foreach ( $field['options'] as $opt_key => $opt ) {
127
+			if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
128
+				continue;
129
+			}
130
+
131
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
132
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
133
+			$checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
134
+
135
+			// Check if other opt, and get values for other field if needed
136
+			$other_opt = false;
137 137
 			$other_args = FrmFieldsHelper::prepare_other_input( compact( 'field', 'field_name', 'opt_key' ), $other_opt, $checked );
138 138
 
139
-            ?>
139
+			?>
140 140
 			<div class="<?php echo esc_attr( apply_filters( 'frm_checkbox_class', 'frm_checkbox', $field, $field_val ) ) ?>" id="frm_checkbox_<?php echo esc_attr( $field['id'] ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
141 141
 
142
-            if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
143
-                ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
144
-            }
142
+			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
143
+				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
144
+			}
145 145
 
146
-            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
146
+			?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
147 147
 
148
-            if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
148
+			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
149 149
 				echo ' ' . $opt . '</label>';
150
-            }
150
+			}
151 151
 
152 152
 			FrmFieldsHelper::include_other_input( array(
153 153
 				'other_opt' => $other_opt, 'read_only' => $read_only,
@@ -156,17 +156,17 @@  discard block
 block discarded – undo
156 156
 				'html_id' => $html_id, 'opt_key' => $opt_key,
157 157
 			) );
158 158
 
159
-            unset( $other_opt, $other_args, $checked );
159
+			unset( $other_opt, $other_args, $checked );
160 160
 
161
-            ?></div>
161
+			?></div>
162 162
 <?php
163
-        }
164
-    }
163
+		}
164
+	}
165 165
 } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) {
166
-    $frm_settings = FrmAppHelper::get_settings();
167
-    if ( ! empty($frm_settings->pubkey) ) {
168
-        FrmFieldsHelper::display_recaptcha($field);
169
-    }
166
+	$frm_settings = FrmAppHelper::get_settings();
167
+	if ( ! empty($frm_settings->pubkey) ) {
168
+		FrmFieldsHelper::display_recaptcha($field);
169
+	}
170 170
 } else {
171 171
 	do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) );
172 172
 	do_action( 'frm_form_field_' . $field['type'], $field, $field_name, compact( 'errors', 'html_id' ) );
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php if ( in_array( $field['type'], array( 'email', 'url', 'text' ) ) ) { ?>
2
-<input type="<?php echo ( $frm_settings->use_html || $field['type'] == 'password' ) ? $field['type'] : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action('frm_field_input_html', $field) ?>/>
2
+<input type="<?php echo ( $frm_settings->use_html || $field['type'] == 'password' ) ? $field['type'] : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>/>
3 3
 <?php } else if ( $field['type'] == 'textarea' ) { ?>
4 4
 <textarea name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php
5 5
 if ( $field['max'] ) {
6 6
 	echo 'rows="' . esc_attr( $field['max'] ) . '" ';
7 7
 }
8
-do_action('frm_field_input_html', $field);
9
-?>><?php echo FrmAppHelper::esc_textarea($field['value']) ?></textarea>
8
+do_action( 'frm_field_input_html', $field );
9
+?>><?php echo FrmAppHelper::esc_textarea( $field['value'] ) ?></textarea>
10 10
 <?php
11 11
 
12 12
 } else if ( $field['type'] == 'radio' ) {
@@ -17,29 +17,29 @@  discard block
 block discarded – undo
17 17
 <?php
18 18
     }
19 19
 
20
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
20
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
21 21
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
22
-    } else if ( is_array($field['options']) ) {
22
+    } else if ( is_array( $field['options'] ) ) {
23 23
         foreach ( $field['options'] as $opt_key => $opt ) {
24 24
 			if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
25 25
                 continue;
26 26
             }
27 27
 
28
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
28
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
29
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); ?>
30 30
 			<div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php
31 31
 
32 32
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
33 33
 				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
34 34
             }
35
-            $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
35
+            $checked = FrmAppHelper::check_selected( $field['value'], $field_val ) ? 'checked="checked" ' : ' ';
36 36
 
37 37
             $other_opt = false;
38 38
             $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39 39
             ?>
40 40
             <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php
41 41
             echo $checked;
42
-            do_action('frm_field_input_html', $field);
42
+            do_action( 'frm_field_input_html', $field );
43 43
 ?>/><?php
44 44
 
45 45
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     }
61 61
 } else if ( $field['type'] == 'select' ) {
62 62
     $read_only = false;
63
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
63
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
64 64
 		echo FrmFieldsHelper::dropdown_categories( array( 'name' => $field_name, 'field' => $field ) );
65 65
 	} else {
66 66
 		if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
 					<input type="hidden" value="<?php echo esc_attr( $selected_value ) ?>" name="<?php echo esc_attr( $field_name ) ?>[]" /> <?php
72 72
 				}
73 73
 			} else { ?>
74
-				<input type="hidden" value="<?php echo esc_attr($field['value']) ?>" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" /> <?php
74
+				<input type="hidden" value="<?php echo esc_attr( $field['value'] ) ?>" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" /> <?php
75 75
 			} ?>
76
-				<select disabled="disabled" <?php do_action('frm_field_input_html', $field) ?>> <?php
76
+				<select disabled="disabled" <?php do_action( 'frm_field_input_html', $field ) ?>> <?php
77 77
 
78 78
 		} else { ?>
79
-<select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action('frm_field_input_html', $field) ?>>
79
+<select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>>
80 80
 <?php   }
81 81
 
82 82
 		$other_opt = $other_checked = false;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 				}
92 92
 			}
93 93
 			?>
94
-		<option value="<?php echo esc_attr($field_val) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : '';?>><?php echo ($opt == '') ? ' ' : $opt; ?></option>
94
+		<option value="<?php echo esc_attr( $field_val ) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : ''; ?>><?php echo ( $opt == '' ) ? ' ' : $opt; ?></option>
95 95
     <?php
96 96
     	} ?>
97 97
 </select>
@@ -120,17 +120,17 @@  discard block
 block discarded – undo
120 120
         }
121 121
     }
122 122
 
123
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
123
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
124 124
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
125 125
     } else if ( $field['options'] ) {
126 126
         foreach ( $field['options'] as $opt_key => $opt ) {
127
-            if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
127
+            if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
128 128
                 continue;
129 129
             }
130 130
 
131
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
132
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
133
-            $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
131
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
132
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
133
+            $checked = FrmAppHelper::check_selected( $checked_values, $field_val ) ? ' checked="checked"' : '';
134 134
 
135 135
             // Check if other opt, and get values for other field if needed
136 136
             $other_opt = false;
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                 ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
144 144
             }
145 145
 
146
-            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
146
+            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action( 'frm_field_input_html', $field ) ?> /><?php
147 147
 
148 148
             if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
149 149
 				echo ' ' . $opt . '</label>';
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
     }
165 165
 } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) {
166 166
     $frm_settings = FrmAppHelper::get_settings();
167
-    if ( ! empty($frm_settings->pubkey) ) {
168
-        FrmFieldsHelper::display_recaptcha($field);
167
+    if ( ! empty( $frm_settings->pubkey ) ) {
168
+        FrmFieldsHelper::display_recaptcha( $field );
169 169
     }
170 170
 } else {
171 171
 	do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) );
Please login to merge, or discard this patch.
classes/controllers/FrmFieldsController.php 2 patches
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 class FrmFieldsController {
4 4
 
5 5
     public static function load_field() {
6
-		FrmAppHelper::permission_check('frm_edit_forms');
6
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
7 7
         check_ajax_referer( 'frm_ajax', 'nonce' );
8 8
 
9 9
         $fields = $_POST['field'];
@@ -34,17 +34,17 @@  discard block
 block discarded – undo
34 34
             }
35 35
 
36 36
 			$field_name = 'item_meta[' . $field_id . ']';
37
-            $html_id = FrmFieldsHelper::get_html_id($field);
37
+            $html_id = FrmFieldsHelper::get_html_id( $field );
38 38
 
39 39
             ob_start();
40 40
 			include( $path . '/classes/views/frm-forms/add_field.php' );
41
-            $field_html[ $field_id ] = ob_get_contents();
41
+            $field_html[$field_id] = ob_get_contents();
42 42
             ob_end_clean();
43 43
         }
44 44
 
45
-        unset($path);
45
+        unset( $path );
46 46
 
47
-        echo json_encode($field_html);
47
+        echo json_encode( $field_html );
48 48
 
49 49
         wp_die();
50 50
     }
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 * Create a new field with ajax
54 54
 	 */
55 55
     public static function create() {
56
-		FrmAppHelper::permission_check('frm_edit_forms');
56
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
57 57
         check_ajax_referer( 'frm_ajax', 'nonce' );
58 58
 
59 59
 		$field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' );
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 		$field = self::include_new_field( $field_type, $form_id, $section_id );
64 64
 
65 65
         // this hook will allow for multiple fields to be added at once
66
-        do_action('frm_after_field_created', $field, $form_id);
66
+        do_action( 'frm_after_field_created', $field, $form_id );
67 67
 
68 68
         wp_die();
69 69
     }
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	public static function include_new_field( $field_type, $form_id, $section_id = 0 ) {
80 80
         $values = array();
81 81
         if ( FrmAppHelper::pro_is_installed() ) {
82
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
82
+            $values['post_type'] = FrmProFormsHelper::post_type( $form_id );
83 83
         }
84 84
 
85 85
 		$field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id );
@@ -92,27 +92,27 @@  discard block
 block discarded – undo
92 92
             return false;
93 93
         }
94 94
 
95
-        $field = self::include_single_field($field_id, $values, $form_id);
95
+        $field = self::include_single_field( $field_id, $values, $form_id );
96 96
 
97 97
         return $field;
98 98
     }
99 99
 
100 100
 	public static function edit_name( $field = 'name', $id = '' ) {
101
-		FrmAppHelper::permission_check('frm_edit_forms');
101
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
102 102
         check_ajax_referer( 'frm_ajax', 'nonce' );
103 103
 
104
-        if ( empty($field) ) {
104
+        if ( empty( $field ) ) {
105 105
             $field = 'name';
106 106
         }
107 107
 
108
-        if ( empty($id) ) {
108
+        if ( empty( $id ) ) {
109 109
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
110 110
 			$id = str_replace( 'field_label_', '', $id );
111 111
         }
112 112
 
113 113
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
114 114
 		$value = trim( $value );
115
-        if ( trim(strip_tags($value)) == '' ) {
115
+        if ( trim( strip_tags( $value ) ) == '' ) {
116 116
             // set blank value if there is no content
117 117
             $value = '';
118 118
         }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     }
127 127
 
128 128
     public static function update_ajax_option() {
129
-		FrmAppHelper::permission_check('frm_edit_forms');
129
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
130 130
         check_ajax_referer( 'frm_ajax', 'nonce' );
131 131
 
132 132
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		if ( isset( $_POST['separate_value'] ) ) {
140 140
 			$new_val = FrmField::is_option_true( $field, 'separate_value' ) ? 0 : 1;
141 141
 			$field->field_options['separate_value'] = $new_val;
142
-			unset($new_val);
142
+			unset( $new_val );
143 143
 		}
144 144
 
145 145
         FrmField::update( $field_id, array(
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     }
151 151
 
152 152
     public static function duplicate() {
153
-		FrmAppHelper::permission_check('frm_edit_forms');
153
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
154 154
         check_ajax_referer( 'frm_ajax', 'nonce' );
155 155
 
156 156
         global $wpdb;
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
 
174 174
         $values['field_order'] = $field_count + 1;
175 175
 
176
-        if ( ! $field_id = FrmField::create($values) ) {
176
+        if ( ! $field_id = FrmField::create( $values ) ) {
177 177
             wp_die();
178 178
         }
179 179
 
180
-        self::include_single_field($field_id, $values);
180
+        self::include_single_field( $field_id, $values );
181 181
 
182 182
         wp_die();
183 183
     }
@@ -186,9 +186,9 @@  discard block
 block discarded – undo
186 186
      * Load a single field in the form builder along with all needed variables
187 187
      */
188 188
     public static function include_single_field( $field_id, $values, $form_id = 0 ) {
189
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
189
+        $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) );
190 190
 		$field_name = 'item_meta[' . $field_id . ']';
191
-        $html_id = FrmFieldsHelper::get_html_id($field);
191
+        $html_id = FrmFieldsHelper::get_html_id( $field );
192 192
         $id = $form_id ? $form_id : $field['form_id'];
193 193
         if ( $field['type'] == 'html' ) {
194 194
             $field['stop_filter'] = true;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
     }
201 201
 
202 202
     public static function destroy() {
203
-		FrmAppHelper::permission_check('frm_edit_forms');
203
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
204 204
         check_ajax_referer( 'frm_ajax', 'nonce' );
205 205
 
206 206
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
@@ -212,14 +212,14 @@  discard block
 block discarded – undo
212 212
 
213 213
     //Add Single Option or Other Option
214 214
     public static function add_option() {
215
-		FrmAppHelper::permission_check('frm_edit_forms');
215
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
216 216
         check_ajax_referer( 'frm_ajax', 'nonce' );
217 217
 
218 218
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
219 219
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
220 220
 
221 221
         //Get the field
222
-        $field = FrmField::getOne($id);
222
+        $field = FrmField::getOne( $id );
223 223
 
224 224
 		if ( ! empty( $field->options ) ) {
225 225
 			$keys = array_keys( $field->options );
@@ -242,13 +242,13 @@  discard block
 block discarded – undo
242 242
 			$first_opt = reset( $field->options );
243 243
 			$next_opt = count( $field->options );
244 244
             if ( $first_opt != '' ) {
245
-                $next_opt++;
245
+                $next_opt ++;
246 246
             }
247 247
 			$opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt;
248
-            unset($next_opt);
248
+            unset( $next_opt );
249 249
         }
250 250
         $field_val = $opt;
251
-		$field->options[ $opt_key ] = $opt;
251
+		$field->options[$opt_key] = $opt;
252 252
 
253 253
         //Update options in DB
254 254
 		FrmField::update( $id, array( 'options' => $field->options ) );
@@ -257,13 +257,13 @@  discard block
 block discarded – undo
257 257
         $field = array(
258 258
             'type'  => $field_data->type,
259 259
             'id'    => $id,
260
-            'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
260
+            'separate_value' => isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0,
261 261
             'form_id' => $field_data->form_id,
262 262
             'field_key' => $field_data->field_key,
263 263
         );
264 264
 
265 265
 		$field_name = 'item_meta[' . $id . ']';
266
-        $html_id = FrmFieldsHelper::get_html_id($field);
266
+        $html_id = FrmFieldsHelper::get_html_id( $field );
267 267
         $checked = '';
268 268
 
269 269
         if ( 'other' == $opt_type ) {
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
     }
276 276
 
277 277
     public static function edit_option() {
278
-		FrmAppHelper::permission_check('frm_edit_forms');
278
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
279 279
         check_ajax_referer( 'frm_ajax', 'nonce' );
280 280
 
281 281
 		$element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
@@ -289,28 +289,28 @@  discard block
 block discarded – undo
289 289
             $new_label = $update_value;
290 290
         }
291 291
 
292
-        $field = FrmField::getOne($id);
292
+        $field = FrmField::getOne( $id );
293 293
         $separate_values = FrmField::is_option_true( $field, 'separate_value' );
294 294
 
295
-        $this_opt_id = end($ids);
296
-		$this_opt = (array) $field->options[ $this_opt_id ];
297
-		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false );
295
+        $this_opt_id = end( $ids );
296
+		$this_opt = (array) $field->options[$this_opt_id];
297
+		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other' ) !== false );
298 298
 
299
-        $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
300
-        $value = isset($this_opt['value']) ? $this_opt['value'] : '';
299
+        $label = isset( $this_opt['label'] ) ? $this_opt['label'] : reset( $this_opt );
300
+        $value = isset( $this_opt['value'] ) ? $this_opt['value'] : '';
301 301
 
302 302
         if ( ! isset( $new_label ) ) {
303 303
             $new_label = $label;
304 304
         }
305 305
 
306
-        if ( isset($new_value) || isset($value) ) {
307
-            $update_value = isset($new_value) ? $new_value : $value;
306
+        if ( isset( $new_value ) || isset( $value ) ) {
307
+            $update_value = isset( $new_value ) ? $new_value : $value;
308 308
         }
309 309
 
310 310
 		if ( $update_value != $new_label && $other_opt === false && $separate_values ) {
311
-			$field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label );
311
+			$field->options[$this_opt_id] = array( 'value' => $update_value, 'label' => $new_label );
312 312
         } else {
313
-			$field->options[ $this_opt_id ] = $orig_update_value;
313
+			$field->options[$this_opt_id] = $orig_update_value;
314 314
         }
315 315
 
316 316
 		FrmField::update( $field->id, array( 'options' => $field->options ) );
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
     }
320 320
 
321 321
     public static function delete_option() {
322
-		FrmAppHelper::permission_check('frm_edit_forms');
322
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
323 323
         check_ajax_referer( 'frm_ajax', 'nonce' );
324 324
 
325 325
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' );
329 329
 
330 330
 		$options = $field->options;
331
-        unset( $options[ $opt_key ] );
331
+        unset( $options[$opt_key] );
332 332
         $response = array( 'other' => true );
333 333
 
334 334
         //If the deleted option is an "other" option
@@ -394,9 +394,9 @@  discard block
 block discarded – undo
394 394
 
395 395
         $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
396 396
         $prepop = array();
397
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
397
+        FrmFieldsHelper::get_bulk_prefilled_opts( $prepop );
398 398
 
399
-        $field = FrmField::getOne($field_id);
399
+        $field = FrmField::getOne( $field_id );
400 400
 
401 401
         wp_enqueue_script( 'utils' );
402 402
 		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
@@ -407,33 +407,33 @@  discard block
 block discarded – undo
407 407
     }
408 408
 
409 409
     public static function import_options() {
410
-		FrmAppHelper::permission_check('frm_edit_forms');
410
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
411 411
         check_ajax_referer( 'frm_ajax', 'nonce' );
412 412
 
413
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
413
+        if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
414 414
             return;
415 415
         }
416 416
 
417 417
 		$field_id = absint( $_POST['field_id'] );
418
-        $field = FrmField::getOne($field_id);
418
+        $field = FrmField::getOne( $field_id );
419 419
 
420 420
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
421 421
             return;
422 422
         }
423 423
 
424
-        $field = FrmFieldsHelper::setup_edit_vars($field);
425
-        $opts = stripslashes_deep($_POST['opts']);
426
-        $opts = explode("\n", rtrim($opts, "\n"));
424
+        $field = FrmFieldsHelper::setup_edit_vars( $field );
425
+        $opts = stripslashes_deep( $_POST['opts'] );
426
+        $opts = explode( "\n", rtrim( $opts, "\n" ) );
427 427
         if ( $field['separate_value'] ) {
428 428
             foreach ( $opts as $opt_key => $opt ) {
429
-                if ( strpos($opt, '|') !== false ) {
430
-                    $vals = explode('|', $opt);
429
+                if ( strpos( $opt, '|' ) !== false ) {
430
+                    $vals = explode( '|', $opt );
431 431
                     if ( $vals[0] != $vals[1] ) {
432
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
432
+                        $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
433 433
                     }
434
-                    unset($vals);
434
+                    unset( $vals );
435 435
                 }
436
-                unset($opt_key, $opt);
436
+                unset( $opt_key, $opt );
437 437
             }
438 438
         }
439 439
 
@@ -442,12 +442,12 @@  discard block
 block discarded – undo
442 442
             $other_array = array();
443 443
             foreach ( $field['options'] as $opt_key => $opt ) {
444 444
                 if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
445
-                    $other_array[ $opt_key ] = $opt;
445
+                    $other_array[$opt_key] = $opt;
446 446
                 }
447
-                unset($opt_key, $opt);
447
+                unset( $opt_key, $opt );
448 448
             }
449
-            if ( ! empty($other_array) ) {
450
-                $opts = array_merge( $opts, $other_array);
449
+            if ( ! empty( $other_array ) ) {
450
+                $opts = array_merge( $opts, $other_array );
451 451
             }
452 452
         }
453 453
 
@@ -462,14 +462,14 @@  discard block
 block discarded – undo
462 462
         if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
463 463
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
464 464
         } else {
465
-            FrmFieldsHelper::show_single_option($field);
465
+            FrmFieldsHelper::show_single_option( $field );
466 466
         }
467 467
 
468 468
         wp_die();
469 469
     }
470 470
 
471 471
     public static function update_order() {
472
-		FrmAppHelper::permission_check('frm_edit_forms');
472
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
473 473
         check_ajax_referer( 'frm_ajax', 'nonce' );
474 474
 
475 475
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
@@ -486,13 +486,13 @@  discard block
 block discarded – undo
486 486
             'rte'       => 'textarea',
487 487
             'website'   => 'url',
488 488
         );
489
-        if ( isset( $type_switch[ $type ] ) ) {
490
-            $type = $type_switch[ $type ];
489
+        if ( isset( $type_switch[$type] ) ) {
490
+            $type = $type_switch[$type];
491 491
         }
492 492
 
493 493
 		$frm_field_selection = FrmField::field_selection();
494
-        $types = array_keys($frm_field_selection);
495
-        if ( ! in_array($type, $types) && $type != 'captcha' ) {
494
+        $types = array_keys( $frm_field_selection );
495
+        if ( ! in_array( $type, $types ) && $type != 'captcha' ) {
496 496
             $type = 'text';
497 497
         }
498 498
 
@@ -531,19 +531,19 @@  discard block
 block discarded – undo
531 531
 
532 532
     public static function input_html( $field, $echo = true ) {
533 533
         $class = array(); //$field['type'];
534
-        self::add_input_classes($field, $class);
534
+        self::add_input_classes( $field, $class );
535 535
 
536 536
         $add_html = array();
537
-        self::add_html_size($field, $add_html);
538
-        self::add_html_length($field, $add_html);
539
-        self::add_html_placeholder($field, $add_html, $class);
537
+        self::add_html_size( $field, $add_html );
538
+        self::add_html_length( $field, $add_html );
539
+        self::add_html_placeholder( $field, $add_html, $class );
540 540
 		self::add_validation_messages( $field, $add_html );
541 541
 
542
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
542
+        $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field );
543 543
 
544 544
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
545 545
 
546
-        self::add_shortcodes_to_html($field, $add_html);
546
+        self::add_shortcodes_to_html( $field, $add_html );
547 547
 
548 548
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
549 549
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
     }
557 557
 
558 558
 	private static function add_input_classes( $field, array &$class ) {
559
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
559
+        if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) {
560 560
             $class[] = $field['input_class'];
561 561
         }
562 562
 
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
             $class[] = 'dyn_default_value';
570 570
         }
571 571
 
572
-        if ( isset($field['size']) && $field['size'] > 0 ) {
572
+        if ( isset( $field['size'] ) && $field['size'] > 0 ) {
573 573
             $class[] = 'auto_width';
574 574
         }
575 575
     }
@@ -579,19 +579,19 @@  discard block
 block discarded – undo
579 579
             return;
580 580
         }
581 581
 
582
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
582
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
583 583
             return;
584 584
         }
585 585
 
586
-        if ( is_numeric($field['size']) ) {
586
+        if ( is_numeric( $field['size'] ) ) {
587 587
             $field['size'] .= 'px';
588 588
         }
589 589
 
590
-        $important = apply_filters('frm_use_important_width', 1, $field);
590
+        $important = apply_filters( 'frm_use_important_width', 1, $field );
591 591
         // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
592 592
 		$add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
593 593
 
594
-        self::add_html_cols($field, $add_html);
594
+        self::add_html_cols( $field, $add_html );
595 595
     }
596 596
 
597 597
 	private static function add_html_cols( $field, array &$add_html ) {
@@ -608,13 +608,13 @@  discard block
 block discarded – undo
608 608
         );
609 609
 
610 610
         // include "col" for valid html
611
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
611
+        $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) );
612 612
 
613
-        if ( ! isset( $calc[ $unit ] ) ) {
613
+        if ( ! isset( $calc[$unit] ) ) {
614 614
             return;
615 615
         }
616 616
 
617
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
617
+        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit];
618 618
 
619 619
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
620 620
     }
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
             return;
626 626
         }
627 627
 
628
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
628
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
629 629
             // don't load on form builder page
630 630
             return;
631 631
         }
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
658 658
             // use HMTL5 placeholder with js fallback
659 659
 			$add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"';
660
-            wp_enqueue_script('jquery-placeholder');
660
+            wp_enqueue_script( 'jquery-placeholder' );
661 661
         } else if ( ! $frm_settings->use_html ) {
662 662
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
663 663
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"';
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 			$format = FrmEntryValidate::phone_format( $field );
685 685
 			$format = substr( $format, 2, -2 );
686 686
 			$key = 'pattern';
687
-			$add_html[ $key ] = $key . '="' . esc_attr( $format ) . '"';
687
+			$add_html[$key] = $key . '="' . esc_attr( $format ) . '"';
688 688
 		}
689 689
 	}
690 690
 
@@ -698,15 +698,15 @@  discard block
 block discarded – undo
698 698
                 continue;
699 699
             }
700 700
 
701
-            if ( is_numeric($k) && strpos($v, '=') ) {
701
+            if ( is_numeric( $k ) && strpos( $v, '=' ) ) {
702 702
                 $add_html[] = $v;
703
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
704
-				$add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
703
+            } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) {
704
+				$add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] );
705 705
             } else {
706
-				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
706
+				$add_html[$k] = $k . '="' . esc_attr( $v ) . '"';
707 707
             }
708 708
 
709
-            unset($k, $v);
709
+            unset( $k, $v );
710 710
         }
711 711
     }
712 712
 
@@ -722,8 +722,8 @@  discard block
 block discarded – undo
722 722
     }
723 723
 
724 724
 	public static function check_label( $opt ) {
725
-        if ( is_array($opt) ) {
726
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
725
+        if ( is_array( $opt ) ) {
726
+            $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
727 727
         }
728 728
 
729 729
         return $opt;
Please login to merge, or discard this patch.
Indentation   +434 added lines, -434 removed lines patch added patch discarded remove patch
@@ -2,129 +2,129 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmFieldsController {
4 4
 
5
-    public static function load_field() {
5
+	public static function load_field() {
6 6
 		FrmAppHelper::permission_check('frm_edit_forms');
7
-        check_ajax_referer( 'frm_ajax', 'nonce' );
7
+		check_ajax_referer( 'frm_ajax', 'nonce' );
8 8
 
9
-        $fields = $_POST['field'];
10
-        if ( empty( $fields ) ) {
11
-            wp_die();
12
-        }
9
+		$fields = $_POST['field'];
10
+		if ( empty( $fields ) ) {
11
+			wp_die();
12
+		}
13 13
 
14
-        $_GET['page'] = 'formidable';
15
-        $fields = stripslashes_deep( $fields );
14
+		$_GET['page'] = 'formidable';
15
+		$fields = stripslashes_deep( $fields );
16 16
 
17
-        $ajax = true;
17
+		$ajax = true;
18 18
 		$values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) );
19
-        $path = FrmAppHelper::plugin_path();
20
-        $field_html = array();
21
-
22
-        foreach ( $fields as $field ) {
23
-            $field = htmlspecialchars_decode( nl2br( $field ) );
24
-            $field = json_decode( $field, true );
25
-            if ( ! isset( $field['id'] ) ) {
26
-                // this field may have already been loaded
27
-                continue;
28
-            }
19
+		$path = FrmAppHelper::plugin_path();
20
+		$field_html = array();
21
+
22
+		foreach ( $fields as $field ) {
23
+			$field = htmlspecialchars_decode( nl2br( $field ) );
24
+			$field = json_decode( $field, true );
25
+			if ( ! isset( $field['id'] ) ) {
26
+				// this field may have already been loaded
27
+				continue;
28
+			}
29 29
 
30
-            $field_id = absint( $field['id'] );
30
+			$field_id = absint( $field['id'] );
31 31
 
32
-            if ( ! isset( $field['value'] ) ) {
33
-                $field['value'] = '';
34
-            }
32
+			if ( ! isset( $field['value'] ) ) {
33
+				$field['value'] = '';
34
+			}
35 35
 
36 36
 			$field_name = 'item_meta[' . $field_id . ']';
37
-            $html_id = FrmFieldsHelper::get_html_id($field);
37
+			$html_id = FrmFieldsHelper::get_html_id($field);
38 38
 
39
-            ob_start();
39
+			ob_start();
40 40
 			include( $path . '/classes/views/frm-forms/add_field.php' );
41
-            $field_html[ $field_id ] = ob_get_contents();
42
-            ob_end_clean();
43
-        }
41
+			$field_html[ $field_id ] = ob_get_contents();
42
+			ob_end_clean();
43
+		}
44 44
 
45
-        unset($path);
45
+		unset($path);
46 46
 
47
-        echo json_encode($field_html);
47
+		echo json_encode($field_html);
48 48
 
49
-        wp_die();
50
-    }
49
+		wp_die();
50
+	}
51 51
 
52 52
 	/**
53 53
 	 * Create a new field with ajax
54 54
 	 */
55
-    public static function create() {
55
+	public static function create() {
56 56
 		FrmAppHelper::permission_check('frm_edit_forms');
57
-        check_ajax_referer( 'frm_ajax', 'nonce' );
57
+		check_ajax_referer( 'frm_ajax', 'nonce' );
58 58
 
59 59
 		$field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' );
60 60
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
61 61
 
62 62
 		$field = self::include_new_field( $field_type, $form_id );
63 63
 
64
-        // this hook will allow for multiple fields to be added at once
65
-        do_action('frm_after_field_created', $field, $form_id);
64
+		// this hook will allow for multiple fields to be added at once
65
+		do_action('frm_after_field_created', $field, $form_id);
66 66
 
67
-        wp_die();
68
-    }
67
+		wp_die();
68
+	}
69 69
 
70
-    /**
71
-     * Set up and create a new field
72
-     *
73
-     * @param string $field_type
74
-     * @param integer $form_id
75
-     * @return array|bool
76
-     */
70
+	/**
71
+	 * Set up and create a new field
72
+	 *
73
+	 * @param string $field_type
74
+	 * @param integer $form_id
75
+	 * @return array|bool
76
+	 */
77 77
 	public static function include_new_field( $field_type, $form_id ) {
78
-        $values = array();
79
-        if ( FrmAppHelper::pro_is_installed() ) {
80
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
81
-        }
78
+		$values = array();
79
+		if ( FrmAppHelper::pro_is_installed() ) {
80
+			$values['post_type'] = FrmProFormsHelper::post_type($form_id);
81
+		}
82 82
 
83 83
 		$field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id );
84
-        $field_values = apply_filters( 'frm_before_field_created', $field_values );
84
+		$field_values = apply_filters( 'frm_before_field_created', $field_values );
85 85
 
86
-        $field_id = FrmField::create( $field_values );
86
+		$field_id = FrmField::create( $field_values );
87 87
 
88
-        if ( ! $field_id ) {
89
-            return false;
90
-        }
88
+		if ( ! $field_id ) {
89
+			return false;
90
+		}
91 91
 
92
-        $field = self::include_single_field($field_id, $values, $form_id);
92
+		$field = self::include_single_field($field_id, $values, $form_id);
93 93
 
94
-        return $field;
95
-    }
94
+		return $field;
95
+	}
96 96
 
97 97
 	public static function edit_name( $field = 'name', $id = '' ) {
98 98
 		FrmAppHelper::permission_check('frm_edit_forms');
99
-        check_ajax_referer( 'frm_ajax', 'nonce' );
99
+		check_ajax_referer( 'frm_ajax', 'nonce' );
100 100
 
101
-        if ( empty($field) ) {
102
-            $field = 'name';
103
-        }
101
+		if ( empty($field) ) {
102
+			$field = 'name';
103
+		}
104 104
 
105
-        if ( empty($id) ) {
105
+		if ( empty($id) ) {
106 106
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
107 107
 			$id = str_replace( 'field_label_', '', $id );
108
-        }
108
+		}
109 109
 
110 110
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
111 111
 		$value = trim( $value );
112
-        if ( trim(strip_tags($value)) == '' ) {
113
-            // set blank value if there is no content
114
-            $value = '';
115
-        }
112
+		if ( trim(strip_tags($value)) == '' ) {
113
+			// set blank value if there is no content
114
+			$value = '';
115
+		}
116 116
 
117 117
 		FrmField::update( $id, array( $field => $value ) );
118 118
 
119 119
 		do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) );
120 120
 
121 121
 		echo stripslashes( wp_kses_post( $value ) );
122
-        wp_die();
123
-    }
122
+		wp_die();
123
+	}
124 124
 
125
-    public static function update_ajax_option() {
125
+	public static function update_ajax_option() {
126 126
 		FrmAppHelper::permission_check('frm_edit_forms');
127
-        check_ajax_referer( 'frm_ajax', 'nonce' );
127
+		check_ajax_referer( 'frm_ajax', 'nonce' );
128 128
 
129 129
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
130 130
 		if ( ! $field_id ) {
@@ -139,143 +139,143 @@  discard block
 block discarded – undo
139 139
 			unset($new_val);
140 140
 		}
141 141
 
142
-        FrmField::update( $field_id, array(
143
-            'field_options' => $field->field_options,
142
+		FrmField::update( $field_id, array(
143
+			'field_options' => $field->field_options,
144 144
 			'form_id'		=> $field->form_id,
145
-        ) );
146
-        wp_die();
147
-    }
145
+		) );
146
+		wp_die();
147
+	}
148 148
 
149
-    public static function duplicate() {
149
+	public static function duplicate() {
150 150
 		FrmAppHelper::permission_check('frm_edit_forms');
151
-        check_ajax_referer( 'frm_ajax', 'nonce' );
151
+		check_ajax_referer( 'frm_ajax', 'nonce' );
152 152
 
153
-        global $wpdb;
153
+		global $wpdb;
154 154
 
155 155
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
156 156
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
157 157
 
158 158
 		$copy_field = FrmField::getOne( $field_id );
159
-        if ( ! $copy_field ) {
160
-            wp_die();
161
-        }
159
+		if ( ! $copy_field ) {
160
+			wp_die();
161
+		}
162 162
 
163 163
 		do_action( 'frm_duplicate_field', $copy_field, $form_id );
164 164
 		do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id );
165 165
 
166 166
 		$values = array();
167
-        FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
167
+		FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
168 168
 
169 169
 		$field_count = FrmDb::get_count( $wpdb->prefix . 'frm_fields fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) );
170 170
 
171
-        $values['field_order'] = $field_count + 1;
171
+		$values['field_order'] = $field_count + 1;
172 172
 
173
-	    $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values );
173
+		$values = apply_filters( 'frm_prepare_single_field_for_duplication', $values );
174 174
 
175
-        if ( ! $field_id = FrmField::create($values) ) {
176
-            wp_die();
177
-        }
175
+		if ( ! $field_id = FrmField::create($values) ) {
176
+			wp_die();
177
+		}
178 178
 
179
-        self::include_single_field($field_id, $values);
179
+		self::include_single_field($field_id, $values);
180 180
 
181
-        wp_die();
182
-    }
181
+		wp_die();
182
+	}
183 183
 
184
-    /**
185
-     * Load a single field in the form builder along with all needed variables
186
-     */
187
-    public static function include_single_field( $field_id, $values, $form_id = 0 ) {
188
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
184
+	/**
185
+	 * Load a single field in the form builder along with all needed variables
186
+	 */
187
+	public static function include_single_field( $field_id, $values, $form_id = 0 ) {
188
+		$field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
189 189
 		$field_name = 'item_meta[' . $field_id . ']';
190
-        $html_id = FrmFieldsHelper::get_html_id($field);
191
-        $id = $form_id ? $form_id : $field['form_id'];
192
-        if ( $field['type'] == 'html' ) {
193
-            $field['stop_filter'] = true;
194
-        }
190
+		$html_id = FrmFieldsHelper::get_html_id($field);
191
+		$id = $form_id ? $form_id : $field['form_id'];
192
+		if ( $field['type'] == 'html' ) {
193
+			$field['stop_filter'] = true;
194
+		}
195 195
 
196 196
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' );
197 197
 
198
-        return $field;
199
-    }
198
+		return $field;
199
+	}
200 200
 
201
-    public static function destroy() {
201
+	public static function destroy() {
202 202
 		FrmAppHelper::permission_check('frm_edit_forms');
203
-        check_ajax_referer( 'frm_ajax', 'nonce' );
203
+		check_ajax_referer( 'frm_ajax', 'nonce' );
204 204
 
205 205
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
206 206
 		FrmField::destroy( $field_id );
207
-        wp_die();
208
-    }
207
+		wp_die();
208
+	}
209 209
 
210
-    /* Field Options */
210
+	/* Field Options */
211 211
 
212
-    //Add Single Option or Other Option
213
-    public static function add_option() {
212
+	//Add Single Option or Other Option
213
+	public static function add_option() {
214 214
 		FrmAppHelper::permission_check('frm_edit_forms');
215
-        check_ajax_referer( 'frm_ajax', 'nonce' );
215
+		check_ajax_referer( 'frm_ajax', 'nonce' );
216 216
 
217 217
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
218 218
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
219 219
 
220
-        //Get the field
221
-        $field = FrmField::getOne($id);
220
+		//Get the field
221
+		$field = FrmField::getOne($id);
222 222
 
223 223
 		if ( ! empty( $field->options ) ) {
224 224
 			$keys = array_keys( $field->options );
225
-            $last = str_replace( 'other_', '', end( $keys ) );
226
-        } else {
227
-            $last = 0;
228
-        }
229
-        $opt_key = $last + 1;
225
+			$last = str_replace( 'other_', '', end( $keys ) );
226
+		} else {
227
+			$last = 0;
228
+		}
229
+		$opt_key = $last + 1;
230 230
 
231
-        if ( 'other' == $opt_type ) {
231
+		if ( 'other' == $opt_type ) {
232 232
 			$opt = esc_html__( 'Other', 'formidable' );
233
-            $other_val = '';
234
-            $opt_key = 'other_' . $opt_key;
235
-
236
-            //Update value of "other" in DB
237
-            $field_options = maybe_unserialize( $field->field_options );
238
-            $field_options['other'] = 1;
239
-            FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
240
-        } else {
233
+			$other_val = '';
234
+			$opt_key = 'other_' . $opt_key;
235
+
236
+			//Update value of "other" in DB
237
+			$field_options = maybe_unserialize( $field->field_options );
238
+			$field_options['other'] = 1;
239
+			FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
240
+		} else {
241 241
 			$first_opt = reset( $field->options );
242 242
 			$next_opt = count( $field->options );
243
-            if ( $first_opt != '' ) {
244
-                $next_opt++;
245
-            }
243
+			if ( $first_opt != '' ) {
244
+				$next_opt++;
245
+			}
246 246
 			$opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt;
247
-            unset($next_opt);
248
-        }
249
-        $field_val = $opt;
247
+			unset($next_opt);
248
+		}
249
+		$field_val = $opt;
250 250
 		$field->options[ $opt_key ] = $opt;
251 251
 
252
-        //Update options in DB
252
+		//Update options in DB
253 253
 		FrmField::update( $id, array( 'options' => $field->options ) );
254 254
 
255
-        $field_data = $field;
256
-        $field = array(
257
-            'type'  => $field_data->type,
258
-            'id'    => $id,
259
-            'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
260
-            'form_id' => $field_data->form_id,
261
-            'field_key' => $field_data->field_key,
262
-        );
255
+		$field_data = $field;
256
+		$field = array(
257
+			'type'  => $field_data->type,
258
+			'id'    => $id,
259
+			'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
260
+			'form_id' => $field_data->form_id,
261
+			'field_key' => $field_data->field_key,
262
+		);
263 263
 
264 264
 		$field_name = 'item_meta[' . $id . ']';
265
-        $html_id = FrmFieldsHelper::get_html_id($field);
266
-        $checked = '';
265
+		$html_id = FrmFieldsHelper::get_html_id($field);
266
+		$checked = '';
267 267
 
268
-        if ( 'other' == $opt_type ) {
268
+		if ( 'other' == $opt_type ) {
269 269
 			require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
270
-        } else {
270
+		} else {
271 271
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
272
-        }
273
-        wp_die();
274
-    }
272
+		}
273
+		wp_die();
274
+	}
275 275
 
276
-    public static function edit_option() {
276
+	public static function edit_option() {
277 277
 		FrmAppHelper::permission_check('frm_edit_forms');
278
-        check_ajax_referer( 'frm_ajax', 'nonce' );
278
+		check_ajax_referer( 'frm_ajax', 'nonce' );
279 279
 
280 280
 		$element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
281 281
 		$ids = explode( '-', $element_id );
@@ -283,43 +283,43 @@  discard block
 block discarded – undo
283 283
 
284 284
 		$orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ) );
285 285
 		if ( strpos( $element_id, 'key_' ) ) {
286
-            $new_value = $update_value;
287
-        } else {
288
-            $new_label = $update_value;
289
-        }
286
+			$new_value = $update_value;
287
+		} else {
288
+			$new_label = $update_value;
289
+		}
290 290
 
291
-        $field = FrmField::getOne($id);
292
-        $separate_values = FrmField::is_option_true( $field, 'separate_value' );
291
+		$field = FrmField::getOne($id);
292
+		$separate_values = FrmField::is_option_true( $field, 'separate_value' );
293 293
 
294
-        $this_opt_id = end($ids);
294
+		$this_opt_id = end($ids);
295 295
 		$this_opt = (array) $field->options[ $this_opt_id ];
296 296
 		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false );
297 297
 
298
-        $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
299
-        $value = isset($this_opt['value']) ? $this_opt['value'] : '';
298
+		$label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
299
+		$value = isset($this_opt['value']) ? $this_opt['value'] : '';
300 300
 
301
-        if ( ! isset( $new_label ) ) {
302
-            $new_label = $label;
303
-        }
301
+		if ( ! isset( $new_label ) ) {
302
+			$new_label = $label;
303
+		}
304 304
 
305
-        if ( isset($new_value) || isset($value) ) {
306
-            $update_value = isset($new_value) ? $new_value : $value;
307
-        }
305
+		if ( isset($new_value) || isset($value) ) {
306
+			$update_value = isset($new_value) ? $new_value : $value;
307
+		}
308 308
 
309 309
 		if ( $update_value != $new_label && $other_opt === false && $separate_values ) {
310 310
 			$field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label );
311
-        } else {
311
+		} else {
312 312
 			$field->options[ $this_opt_id ] = $orig_update_value;
313
-        }
313
+		}
314 314
 
315 315
 		FrmField::update( $field->id, array( 'options' => $field->options ) );
316 316
 		echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value );
317
-        wp_die();
318
-    }
317
+		wp_die();
318
+	}
319 319
 
320
-    public static function delete_option() {
320
+	public static function delete_option() {
321 321
 		FrmAppHelper::permission_check('frm_edit_forms');
322
-        check_ajax_referer( 'frm_ajax', 'nonce' );
322
+		check_ajax_referer( 'frm_ajax', 'nonce' );
323 323
 
324 324
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
325 325
 		$field = FrmField::getOne( $field_id );
@@ -327,310 +327,310 @@  discard block
 block discarded – undo
327 327
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' );
328 328
 
329 329
 		$options = $field->options;
330
-        unset( $options[ $opt_key ] );
331
-        $response = array( 'other' => true );
330
+		unset( $options[ $opt_key ] );
331
+		$response = array( 'other' => true );
332 332
 
333
-        //If the deleted option is an "other" option
333
+		//If the deleted option is an "other" option
334 334
 		if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
335
-            //Assume all other options are gone, unless proven otherwise
336
-            $other = false;
335
+			//Assume all other options are gone, unless proven otherwise
336
+			$other = false;
337 337
 
338
-            //Check if all other options are really gone
339
-            foreach ( $options as $o_key => $o_val ) {
340
-                //If there is still an other option in the field, set other to true
338
+			//Check if all other options are really gone
339
+			foreach ( $options as $o_key => $o_val ) {
340
+				//If there is still an other option in the field, set other to true
341 341
 				if ( FrmFieldsHelper::is_other_opt( $o_key ) ) {
342
-                    $other = true;
343
-                    break;
344
-                }
345
-                unset( $o_key, $o_val );
346
-            }
347
-
348
-            //If all other options are gone
349
-            if ( false === $other ) {
350
-                $field_options = maybe_unserialize( $field->field_options );
351
-                $field_options['other'] = 0;
342
+					$other = true;
343
+					break;
344
+				}
345
+				unset( $o_key, $o_val );
346
+			}
347
+
348
+			//If all other options are gone
349
+			if ( false === $other ) {
350
+				$field_options = maybe_unserialize( $field->field_options );
351
+				$field_options['other'] = 0;
352 352
 				FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) );
353
-                $response = array( 'other' => false );
354
-            }
355
-        }
356
-        echo json_encode( $response );
353
+				$response = array( 'other' => false );
354
+			}
355
+		}
356
+		echo json_encode( $response );
357 357
 
358 358
 		FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) );
359 359
 
360
-        wp_die();
361
-    }
360
+		wp_die();
361
+	}
362 362
 
363
-    public static function import_choices() {
364
-        FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
363
+	public static function import_choices() {
364
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
365 365
 
366 366
 		$field_id = absint( $_REQUEST['field_id'] );
367 367
 
368
-        global $current_screen, $hook_suffix;
368
+		global $current_screen, $hook_suffix;
369 369
 
370
-        // Catch plugins that include admin-header.php before admin.php completes.
371
-        if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
372
-            $hook_suffix = '';
373
-        	set_current_screen();
374
-        }
370
+		// Catch plugins that include admin-header.php before admin.php completes.
371
+		if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
372
+			$hook_suffix = '';
373
+			set_current_screen();
374
+		}
375 375
 
376
-        if ( function_exists( 'register_admin_color_schemes' ) ) {
377
-            register_admin_color_schemes();
378
-        }
376
+		if ( function_exists( 'register_admin_color_schemes' ) ) {
377
+			register_admin_color_schemes();
378
+		}
379 379
 
380
-        $hook_suffix = $admin_body_class = '';
380
+		$hook_suffix = $admin_body_class = '';
381 381
 
382
-        if ( get_user_setting( 'mfold' ) == 'f' ) {
383
-        	$admin_body_class .= ' folded';
384
-        }
382
+		if ( get_user_setting( 'mfold' ) == 'f' ) {
383
+			$admin_body_class .= ' folded';
384
+		}
385 385
 
386
-        if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
387
-        	$admin_body_class .= ' admin-bar';
388
-        }
386
+		if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
387
+			$admin_body_class .= ' admin-bar';
388
+		}
389 389
 
390
-        if ( is_rtl() ) {
391
-        	$admin_body_class .= ' rtl';
392
-        }
390
+		if ( is_rtl() ) {
391
+			$admin_body_class .= ' rtl';
392
+		}
393 393
 
394
-        $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
395
-        $prepop = array();
396
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
394
+		$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
395
+		$prepop = array();
396
+		FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
397 397
 
398
-        $field = FrmField::getOne($field_id);
398
+		$field = FrmField::getOne($field_id);
399 399
 
400
-        wp_enqueue_script( 'utils' );
400
+		wp_enqueue_script( 'utils' );
401 401
 		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
402
-        FrmAppHelper::load_admin_wide_js();
402
+		FrmAppHelper::load_admin_wide_js();
403 403
 
404 404
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' );
405
-        wp_die();
406
-    }
405
+		wp_die();
406
+	}
407 407
 
408
-    public static function import_options() {
408
+	public static function import_options() {
409 409
 		FrmAppHelper::permission_check('frm_edit_forms');
410
-        check_ajax_referer( 'frm_ajax', 'nonce' );
410
+		check_ajax_referer( 'frm_ajax', 'nonce' );
411 411
 
412
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
413
-            return;
414
-        }
412
+		if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
413
+			return;
414
+		}
415 415
 
416 416
 		$field_id = absint( $_POST['field_id'] );
417
-        $field = FrmField::getOne($field_id);
417
+		$field = FrmField::getOne($field_id);
418 418
 
419 419
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
420
-            return;
421
-        }
422
-
423
-        $field = FrmFieldsHelper::setup_edit_vars($field);
424
-        $opts = stripslashes_deep($_POST['opts']);
425
-        $opts = explode("\n", rtrim($opts, "\n"));
426
-        if ( $field['separate_value'] ) {
427
-            foreach ( $opts as $opt_key => $opt ) {
428
-                if ( strpos($opt, '|') !== false ) {
429
-                    $vals = explode('|', $opt);
430
-                    if ( $vals[0] != $vals[1] ) {
431
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
432
-                    }
433
-                    unset($vals);
434
-                }
435
-                unset($opt_key, $opt);
436
-            }
437
-        }
438
-
439
-        //Keep other options after bulk update
440
-        if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
441
-            $other_array = array();
442
-            foreach ( $field['options'] as $opt_key => $opt ) {
443
-                if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
444
-                    $other_array[ $opt_key ] = $opt;
445
-                }
446
-                unset($opt_key, $opt);
447
-            }
448
-            if ( ! empty($other_array) ) {
449
-                $opts = array_merge( $opts, $other_array);
450
-            }
451
-        }
452
-
453
-        FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
454
-
455
-        $field['options'] = $opts;
456
-        $field_name = $field['name'];
457
-
458
-        // Get html_id which will be used in single-option.php
459
-        $html_id = FrmFieldsHelper::get_html_id( $field );
460
-
461
-        if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
420
+			return;
421
+		}
422
+
423
+		$field = FrmFieldsHelper::setup_edit_vars($field);
424
+		$opts = stripslashes_deep($_POST['opts']);
425
+		$opts = explode("\n", rtrim($opts, "\n"));
426
+		if ( $field['separate_value'] ) {
427
+			foreach ( $opts as $opt_key => $opt ) {
428
+				if ( strpos($opt, '|') !== false ) {
429
+					$vals = explode('|', $opt);
430
+					if ( $vals[0] != $vals[1] ) {
431
+						$opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
432
+					}
433
+					unset($vals);
434
+				}
435
+				unset($opt_key, $opt);
436
+			}
437
+		}
438
+
439
+		//Keep other options after bulk update
440
+		if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
441
+			$other_array = array();
442
+			foreach ( $field['options'] as $opt_key => $opt ) {
443
+				if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
444
+					$other_array[ $opt_key ] = $opt;
445
+				}
446
+				unset($opt_key, $opt);
447
+			}
448
+			if ( ! empty($other_array) ) {
449
+				$opts = array_merge( $opts, $other_array);
450
+			}
451
+		}
452
+
453
+		FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
454
+
455
+		$field['options'] = $opts;
456
+		$field_name = $field['name'];
457
+
458
+		// Get html_id which will be used in single-option.php
459
+		$html_id = FrmFieldsHelper::get_html_id( $field );
460
+
461
+		if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
462 462
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
463
-        } else {
464
-            FrmFieldsHelper::show_single_option($field);
465
-        }
463
+		} else {
464
+			FrmFieldsHelper::show_single_option($field);
465
+		}
466 466
 
467
-        wp_die();
468
-    }
467
+		wp_die();
468
+	}
469 469
 
470
-    public static function update_order() {
470
+	public static function update_order() {
471 471
 		FrmAppHelper::permission_check('frm_edit_forms');
472
-        check_ajax_referer( 'frm_ajax', 'nonce' );
472
+		check_ajax_referer( 'frm_ajax', 'nonce' );
473 473
 
474 474
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
475 475
 		foreach ( (array) $fields as $position => $item ) {
476 476
 			FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) );
477 477
 		}
478
-        wp_die();
479
-    }
478
+		wp_die();
479
+	}
480 480
 
481 481
 	public static function change_type( $type ) {
482
-        $type_switch = array(
483
-            'scale'     => 'radio',
484
-            '10radio'   => 'radio',
485
-            'rte'       => 'textarea',
486
-            'website'   => 'url',
487
-        );
488
-        if ( isset( $type_switch[ $type ] ) ) {
489
-            $type = $type_switch[ $type ];
490
-        }
482
+		$type_switch = array(
483
+			'scale'     => 'radio',
484
+			'10radio'   => 'radio',
485
+			'rte'       => 'textarea',
486
+			'website'   => 'url',
487
+		);
488
+		if ( isset( $type_switch[ $type ] ) ) {
489
+			$type = $type_switch[ $type ];
490
+		}
491 491
 
492 492
 		$frm_field_selection = FrmField::field_selection();
493
-        $types = array_keys($frm_field_selection);
494
-        if ( ! in_array($type, $types) && $type != 'captcha' ) {
495
-            $type = 'text';
496
-        }
493
+		$types = array_keys($frm_field_selection);
494
+		if ( ! in_array($type, $types) && $type != 'captcha' ) {
495
+			$type = 'text';
496
+		}
497 497
 
498
-        return $type;
499
-    }
498
+		return $type;
499
+	}
500 500
 
501 501
 	public static function display_field_options( $display ) {
502 502
 		switch ( $display['type'] ) {
503
-            case 'captcha':
504
-                $display['required'] = false;
505
-                $display['invalid'] = true;
506
-                $display['default_blank'] = false;
503
+			case 'captcha':
504
+				$display['required'] = false;
505
+				$display['invalid'] = true;
506
+				$display['default_blank'] = false;
507 507
 				$display['captcha_size'] = true;
508
-            break;
509
-            case 'radio':
510
-                $display['default_blank'] = false;
511
-            break;
512
-            case 'text':
513
-            case 'textarea':
514
-                $display['size'] = true;
515
-                $display['clear_on_focus'] = true;
516
-            break;
517
-            case 'select':
518
-                $display['size'] = true;
519
-            break;
520
-            case 'url':
521
-            case 'website':
522
-            case 'email':
523
-                $display['size'] = true;
524
-                $display['clear_on_focus'] = true;
525
-                $display['invalid'] = true;
526
-        }
527
-
528
-        return $display;
529
-    }
530
-
531
-    public static function input_html( $field, $echo = true ) {
532
-        $class = array(); //$field['type'];
533
-        self::add_input_classes($field, $class);
534
-
535
-        $add_html = array();
536
-        self::add_html_size($field, $add_html);
537
-        self::add_html_length($field, $add_html);
538
-        self::add_html_placeholder($field, $add_html, $class);
508
+			break;
509
+			case 'radio':
510
+				$display['default_blank'] = false;
511
+			break;
512
+			case 'text':
513
+			case 'textarea':
514
+				$display['size'] = true;
515
+				$display['clear_on_focus'] = true;
516
+			break;
517
+			case 'select':
518
+				$display['size'] = true;
519
+			break;
520
+			case 'url':
521
+			case 'website':
522
+			case 'email':
523
+				$display['size'] = true;
524
+				$display['clear_on_focus'] = true;
525
+				$display['invalid'] = true;
526
+		}
527
+
528
+		return $display;
529
+	}
530
+
531
+	public static function input_html( $field, $echo = true ) {
532
+		$class = array(); //$field['type'];
533
+		self::add_input_classes($field, $class);
534
+
535
+		$add_html = array();
536
+		self::add_html_size($field, $add_html);
537
+		self::add_html_length($field, $add_html);
538
+		self::add_html_placeholder($field, $add_html, $class);
539 539
 		self::add_validation_messages( $field, $add_html );
540 540
 
541
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
541
+		$class = apply_filters('frm_field_classes', implode(' ', $class), $field);
542 542
 
543 543
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
544 544
 
545
-        self::add_shortcodes_to_html($field, $add_html);
545
+		self::add_shortcodes_to_html($field, $add_html);
546 546
 
547 547
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
548 548
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
549 549
 
550
-        if ( $echo ) {
551
-            echo $add_html;
552
-        }
550
+		if ( $echo ) {
551
+			echo $add_html;
552
+		}
553 553
 
554
-        return $add_html;
555
-    }
554
+		return $add_html;
555
+	}
556 556
 
557 557
 	private static function add_input_classes( $field, array &$class ) {
558
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
559
-            $class[] = $field['input_class'];
560
-        }
558
+		if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
559
+			$class[] = $field['input_class'];
560
+		}
561 561
 
562
-        if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
563
-            return;
564
-        }
562
+		if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
563
+			return;
564
+		}
565 565
 
566
-        global $frm_vars;
566
+		global $frm_vars;
567 567
 		if ( is_admin() && ! FrmAppHelper::is_preview_page() && ! in_array( $field['type'], array( 'scale', 'radio', 'checkbox', 'data' ) ) ) {
568
-            $class[] = 'dyn_default_value';
569
-        }
568
+			$class[] = 'dyn_default_value';
569
+		}
570 570
 
571
-        if ( isset($field['size']) && $field['size'] > 0 ) {
572
-            $class[] = 'auto_width';
573
-        }
574
-    }
571
+		if ( isset($field['size']) && $field['size'] > 0 ) {
572
+			$class[] = 'auto_width';
573
+		}
574
+	}
575 575
 
576 576
 	private static function add_html_size( $field, array &$add_html ) {
577 577
 		if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden' ) ) ) {
578
-            return;
579
-        }
578
+			return;
579
+		}
580 580
 
581
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
582
-            return;
583
-        }
581
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
582
+			return;
583
+		}
584 584
 
585
-        if ( is_numeric($field['size']) ) {
586
-            $field['size'] .= 'px';
587
-        }
585
+		if ( is_numeric($field['size']) ) {
586
+			$field['size'] .= 'px';
587
+		}
588 588
 
589
-        $important = apply_filters('frm_use_important_width', 1, $field);
590
-        // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
589
+		$important = apply_filters('frm_use_important_width', 1, $field);
590
+		// Note: This inline styling must stay since we cannot realistically set a class for every possible field size
591 591
 		$add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
592 592
 
593
-        self::add_html_cols($field, $add_html);
594
-    }
593
+		self::add_html_cols($field, $add_html);
594
+	}
595 595
 
596 596
 	private static function add_html_cols( $field, array &$add_html ) {
597 597
 		if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
598
-            return;
599
-        }
598
+			return;
599
+		}
600 600
 
601
-        // convert to cols for textareas
602
-        $calc = array(
603
-            ''      => 9,
604
-            'px'    => 9,
605
-            'rem'   => 0.444,
606
-            'em'    => 0.544,
607
-        );
601
+		// convert to cols for textareas
602
+		$calc = array(
603
+			''      => 9,
604
+			'px'    => 9,
605
+			'rem'   => 0.444,
606
+			'em'    => 0.544,
607
+		);
608 608
 
609
-        // include "col" for valid html
610
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
609
+		// include "col" for valid html
610
+		$unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
611 611
 
612
-        if ( ! isset( $calc[ $unit ] ) ) {
613
-            return;
614
-        }
612
+		if ( ! isset( $calc[ $unit ] ) ) {
613
+			return;
614
+		}
615 615
 
616
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
616
+		$size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
617 617
 
618 618
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
619
-    }
619
+	}
620 620
 
621 621
 	private static function add_html_length( $field, array &$add_html ) {
622
-        // check for max setting and if this field accepts maxlength
622
+		// check for max setting and if this field accepts maxlength
623 623
 		if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden' ) ) ) {
624
-            return;
625
-        }
624
+			return;
625
+		}
626 626
 
627
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
628
-            // don't load on form builder page
629
-            return;
630
-        }
627
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
628
+			// don't load on form builder page
629
+			return;
630
+		}
631 631
 
632 632
 		$add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"';
633
-    }
633
+	}
634 634
 
635 635
 	private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
636 636
 		if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) {
@@ -638,35 +638,35 @@  discard block
 block discarded – undo
638 638
 		}
639 639
 
640 640
 		$default_value_array = is_array( $field['default_value'] );
641
-        if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
641
+		if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
642 642
 			if ( $default_value_array ) {
643 643
 				$field['default_value'] = json_encode( $field['default_value'] );
644 644
 			}
645 645
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"';
646
-            return;
647
-        }
646
+			return;
647
+		}
648 648
 
649 649
 		if ( $default_value_array ) {
650 650
 			// don't include a json placeholder
651 651
 			return;
652 652
 		}
653 653
 
654
-        $frm_settings = FrmAppHelper::get_settings();
654
+		$frm_settings = FrmAppHelper::get_settings();
655 655
 
656 656
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
657
-            // use HMTL5 placeholder with js fallback
657
+			// use HMTL5 placeholder with js fallback
658 658
 			$add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"';
659
-            wp_enqueue_script('jquery-placeholder');
660
-        } else if ( ! $frm_settings->use_html ) {
659
+			wp_enqueue_script('jquery-placeholder');
660
+		} else if ( ! $frm_settings->use_html ) {
661 661
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
662 662
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"';
663
-            $class[] = 'frm_toggle_default';
663
+			$class[] = 'frm_toggle_default';
664 664
 
665
-            if ( $field['value'] == $field['default_value'] ) {
666
-                $class[] = 'frm_default';
667
-            }
668
-        }
669
-    }
665
+			if ( $field['value'] == $field['default_value'] ) {
666
+				$class[] = 'frm_default';
667
+			}
668
+		}
669
+	}
670 670
 
671 671
 	private static function add_validation_messages( $field, array &$add_html ) {
672 672
 		if ( FrmField::is_required( $field ) ) {
@@ -687,44 +687,44 @@  discard block
 block discarded – undo
687 687
 		}
688 688
 	}
689 689
 
690
-    private static function add_shortcodes_to_html( $field, array &$add_html ) {
691
-        if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
692
-            return;
693
-        }
690
+	private static function add_shortcodes_to_html( $field, array &$add_html ) {
691
+		if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
692
+			return;
693
+		}
694 694
 
695
-        foreach ( $field['shortcodes'] as $k => $v ) {
696
-            if ( 'opt' === $k ) {
697
-                continue;
698
-            }
695
+		foreach ( $field['shortcodes'] as $k => $v ) {
696
+			if ( 'opt' === $k ) {
697
+				continue;
698
+			}
699 699
 
700
-            if ( is_numeric($k) && strpos($v, '=') ) {
701
-                $add_html[] = $v;
702
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
700
+			if ( is_numeric($k) && strpos($v, '=') ) {
701
+				$add_html[] = $v;
702
+			} else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
703 703
 				$add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
704
-            } else {
704
+			} else {
705 705
 				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
706
-            }
707
-
708
-            unset($k, $v);
709
-        }
710
-    }
711
-
712
-    public static function check_value( $opt, $opt_key, $field ) {
713
-        if ( is_array( $opt ) ) {
714
-            if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
715
-                $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
716
-            } else {
717
-                $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
718
-            }
719
-        }
720
-        return $opt;
721
-    }
706
+			}
707
+
708
+			unset($k, $v);
709
+		}
710
+	}
711
+
712
+	public static function check_value( $opt, $opt_key, $field ) {
713
+		if ( is_array( $opt ) ) {
714
+			if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
715
+				$opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
716
+			} else {
717
+				$opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
718
+			}
719
+		}
720
+		return $opt;
721
+	}
722 722
 
723 723
 	public static function check_label( $opt ) {
724
-        if ( is_array($opt) ) {
725
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
726
-        }
724
+		if ( is_array($opt) ) {
725
+			$opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
726
+		}
727 727
 
728
-        return $opt;
729
-    }
728
+		return $opt;
729
+	}
730 730
 }
Please login to merge, or discard this patch.
classes/models/FrmEntryValidate.php 2 patches
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -1,26 +1,26 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmEntryValidate {
4
-    public static function validate( $values, $exclude = false ) {
5
-        global $wpdb;
4
+	public static function validate( $values, $exclude = false ) {
5
+		global $wpdb;
6 6
 
7
-        FrmEntry::sanitize_entry_post( $values );
8
-        $errors = array();
7
+		FrmEntry::sanitize_entry_post( $values );
8
+		$errors = array();
9 9
 
10
-        if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
11
-            $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
12
-            return $errors;
13
-        }
10
+		if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
11
+			$errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
12
+			return $errors;
13
+		}
14 14
 
15 15
 		if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) {
16
-            $errors['form'] = __( 'You do not have permission to do that', 'formidable' );
17
-        }
16
+			$errors['form'] = __( 'You do not have permission to do that', 'formidable' );
17
+		}
18 18
 
19
-        if ( ! isset($values['item_key']) || $values['item_key'] == '' ) {
19
+		if ( ! isset($values['item_key']) || $values['item_key'] == '' ) {
20 20
 			$_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' );
21
-        }
21
+		}
22 22
 
23
-        $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) );
23
+		$where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) );
24 24
 		// Don't get subfields
25 25
 		$where['fr.parent_form_id'] = array( null, 0 );
26 26
 		// Don't get excluded fields (like file upload fields in the ajax validation)
@@ -28,46 +28,46 @@  discard block
 block discarded – undo
28 28
 			$where['fi.type not'] = $exclude;
29 29
 		}
30 30
 
31
-        $posted_fields = FrmField::getAll($where, 'field_order');
31
+		$posted_fields = FrmField::getAll($where, 'field_order');
32 32
 
33
-        // Pass exclude value to validate_field function so it can be used for repeating sections
34
-        $args = array( 'exclude' => $exclude );
33
+		// Pass exclude value to validate_field function so it can be used for repeating sections
34
+		$args = array( 'exclude' => $exclude );
35 35
 
36
-        foreach ( $posted_fields as $posted_field ) {
37
-            self::validate_field($posted_field, $errors, $values, $args);
38
-            unset($posted_field);
39
-        }
36
+		foreach ( $posted_fields as $posted_field ) {
37
+			self::validate_field($posted_field, $errors, $values, $args);
38
+			unset($posted_field);
39
+		}
40 40
 
41
-        // check for spam
42
-        self::spam_check( $exclude, $values, $errors );
41
+		// check for spam
42
+		self::spam_check( $exclude, $values, $errors );
43 43
 
44
-        $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') );
44
+		$errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') );
45 45
 
46
-        return $errors;
47
-    }
46
+		return $errors;
47
+	}
48 48
 
49
-    public static function validate_field( $posted_field, &$errors, $values, $args = array() ) {
50
-        $defaults = array(
51
-            'id'              => $posted_field->id,
52
-            'parent_field_id' => '', // the id of the repeat or embed form
53
-            'key_pointer'     => '', // the pointer in the posted array
54
-            'exclude'         => array(), // exclude these field types from validation
55
-        );
56
-        $args = wp_parse_args( $args, $defaults );
49
+	public static function validate_field( $posted_field, &$errors, $values, $args = array() ) {
50
+		$defaults = array(
51
+			'id'              => $posted_field->id,
52
+			'parent_field_id' => '', // the id of the repeat or embed form
53
+			'key_pointer'     => '', // the pointer in the posted array
54
+			'exclude'         => array(), // exclude these field types from validation
55
+		);
56
+		$args = wp_parse_args( $args, $defaults );
57 57
 
58
-        if ( empty($args['parent_field_id']) ) {
58
+		if ( empty($args['parent_field_id']) ) {
59 59
 			$value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
60
-        } else {
61
-            // value is from a nested form
62
-            $value = $values;
63
-        }
60
+		} else {
61
+			// value is from a nested form
62
+			$value = $values;
63
+		}
64 64
 
65
-        // Check for values in "Other" fields
66
-        FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
65
+		// Check for values in "Other" fields
66
+		FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
67 67
 
68
-        if ( isset($posted_field->field_options['default_blank']) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) {
69
-            $value = '';
70
-        }
68
+		if ( isset($posted_field->field_options['default_blank']) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) {
69
+			$value = '';
70
+		}
71 71
 
72 72
 		// Check for an array with only one value
73 73
 		// Don't reset values in "Other" fields because array keys need to be preserved
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
 			$value = reset($value);
76 76
 		}
77 77
 
78
-        if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
78
+		if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
79 79
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
80
-        } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
81
-            $_POST['item_name'] = $value;
82
-        }
80
+		} else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
81
+			$_POST['item_name'] = $value;
82
+		}
83 83
 
84 84
 		if ( $value != '' ) {
85 85
 			self::validate_url_field( $errors, $posted_field, $value, $args );
@@ -88,42 +88,42 @@  discard block
 block discarded – undo
88 88
 			self::validate_phone_field( $errors, $posted_field, $value, $args );
89 89
 		}
90 90
 
91
-        FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
91
+		FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
92 92
 
93
-        self::validate_recaptcha($errors, $posted_field, $args);
93
+		self::validate_recaptcha($errors, $posted_field, $args);
94 94
 
95
-        $errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args);
95
+		$errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args);
96 96
 		$errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args );
97
-    }
97
+	}
98 98
 
99 99
 	public static function validate_url_field( &$errors, $field, &$value, $args ) {
100 100
 		if ( $value == '' || ! in_array( $field->type, array( 'website', 'url', 'image' ) ) ) {
101
-            return;
102
-        }
101
+			return;
102
+		}
103 103
 
104
-        if ( trim($value) == 'http://' ) {
105
-            $value = '';
106
-        } else {
107
-            $value = esc_url_raw( $value );
104
+		if ( trim($value) == 'http://' ) {
105
+			$value = '';
106
+		} else {
107
+			$value = esc_url_raw( $value );
108 108
 			$value = preg_match( '/^(https?|ftps?|mailto|news|feed|telnet):/is', $value ) ? $value : 'http://' . $value;
109
-        }
109
+		}
110 110
 
111
-        //validate the url format
112
-        if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) {
111
+		//validate the url format
112
+		if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) {
113 113
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
114
-        }
115
-    }
114
+		}
115
+	}
116 116
 
117 117
 	public static function validate_email_field( &$errors, $field, $value, $args ) {
118
-        if ( $value == '' || $field->type != 'email' ) {
119
-            return;
120
-        }
118
+		if ( $value == '' || $field->type != 'email' ) {
119
+			return;
120
+		}
121 121
 
122
-        //validate the email format
123
-        if ( ! is_email($value) ) {
122
+		//validate the email format
123
+		if ( ! is_email($value) ) {
124 124
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
125
-        }
126
-    }
125
+		}
126
+	}
127 127
 
128 128
 	public static function validate_number_field( &$errors, $field, $value, $args ) {
129 129
 		//validate the number format
@@ -200,9 +200,9 @@  discard block
 block discarded – undo
200 200
 	}
201 201
 
202 202
 	public static function validate_recaptcha( &$errors, $field, $args ) {
203
-        if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) {
204
-            return;
205
-        }
203
+		if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) {
204
+			return;
205
+		}
206 206
 
207 207
 		$frm_settings = FrmAppHelper::get_settings();
208 208
 		if ( empty( $frm_settings->pubkey ) ) {
@@ -210,57 +210,57 @@  discard block
 block discarded – undo
210 210
 			return;
211 211
 		}
212 212
 
213
-        if ( ! isset($_POST['g-recaptcha-response']) ) {
214
-            // If captcha is missing, check if it was already verified
213
+		if ( ! isset($_POST['g-recaptcha-response']) ) {
214
+			// If captcha is missing, check if it was already verified
215 215
 			if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) {
216
-                // There was no captcha submitted
216
+				// There was no captcha submitted
217 217
 				$errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' );
218
-            }
219
-            return;
220
-        }
218
+			}
219
+			return;
220
+		}
221 221
 
222
-        $arg_array = array(
223
-            'body'      => array(
222
+		$arg_array = array(
223
+			'body'      => array(
224 224
 				'secret'   => $frm_settings->privkey,
225 225
 				'response' => $_POST['g-recaptcha-response'],
226 226
 				'remoteip' => FrmAppHelper::get_ip_address(),
227 227
 			),
228 228
 		);
229
-        $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
230
-        $response = json_decode(wp_remote_retrieve_body( $resp ), true);
229
+		$resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
230
+		$response = json_decode(wp_remote_retrieve_body( $resp ), true);
231 231
 
232
-        if ( isset( $response['success'] ) && ! $response['success'] ) {
233
-            // What happens when the CAPTCHA was entered incorrectly
232
+		if ( isset( $response['success'] ) && ! $response['success'] ) {
233
+			// What happens when the CAPTCHA was entered incorrectly
234 234
 			$errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
235
-        } else if ( is_wp_error( $resp ) ) {
235
+		} else if ( is_wp_error( $resp ) ) {
236 236
 			$error_string = $resp->get_error_message();
237 237
 			$errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' );
238 238
 			$errors[ 'field' . $args['id'] ] .= ' ' . $error_string;
239
-        }
240
-    }
241
-
242
-    /**
243
-     * check for spam
244
-     * @param boolean $exclude
245
-     * @param array $values
246
-     * @param array $errors by reference
247
-     */
248
-    public static function spam_check( $exclude, $values, &$errors ) {
249
-        if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
250
-            // only check spam if there are no other errors
251
-            return;
252
-        }
253
-
254
-        if ( self::is_akismet_spam( $values ) ) {
239
+		}
240
+	}
241
+
242
+	/**
243
+	 * check for spam
244
+	 * @param boolean $exclude
245
+	 * @param array $values
246
+	 * @param array $errors by reference
247
+	 */
248
+	public static function spam_check( $exclude, $values, &$errors ) {
249
+		if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
250
+			// only check spam if there are no other errors
251
+			return;
252
+		}
253
+
254
+		if ( self::is_akismet_spam( $values ) ) {
255 255
 			if ( self::is_akismet_enabled_for_user( $values['form_id'] ) ) {
256 256
 				$errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
257 257
 			}
258
-	    }
258
+		}
259 259
 
260
-    	if ( self::blacklist_check( $values ) ) {
261
-            $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
262
-    	}
263
-    }
260
+		if ( self::blacklist_check( $values ) ) {
261
+			$errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
262
+		}
263
+	}
264 264
 
265 265
 	private static function is_akismet_spam( $values ) {
266 266
 		global $wpcom_api_key;
@@ -272,54 +272,54 @@  discard block
 block discarded – undo
272 272
 		return ( isset( $form->options['akismet'] ) && ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] != 'logged' || ! is_user_logged_in() ) );
273 273
 	}
274 274
 
275
-    public static function blacklist_check( $values ) {
276
-        if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
277
-            return false;
278
-        }
275
+	public static function blacklist_check( $values ) {
276
+		if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
277
+			return false;
278
+		}
279 279
 
280
-    	$mod_keys = trim( get_option( 'blacklist_keys' ) );
280
+		$mod_keys = trim( get_option( 'blacklist_keys' ) );
281 281
 
282
-    	if ( empty( $mod_keys ) ) {
283
-    		return false;
284
-    	}
282
+		if ( empty( $mod_keys ) ) {
283
+			return false;
284
+		}
285 285
 
286
-    	$content = FrmEntriesHelper::entry_array_to_string($values);
286
+		$content = FrmEntriesHelper::entry_array_to_string($values);
287 287
 
288 288
 		if ( empty($content) ) {
289
-		    return false;
289
+			return false;
290 290
 		}
291 291
 
292
-    	$words = explode( "\n", $mod_keys );
292
+		$words = explode( "\n", $mod_keys );
293 293
 
294
-    	foreach ( (array) $words as $word ) {
295
-    		$word = trim( $word );
294
+		foreach ( (array) $words as $word ) {
295
+			$word = trim( $word );
296 296
 
297
-    		if ( empty($word) ) {
298
-    			continue;
299
-    		}
297
+			if ( empty($word) ) {
298
+				continue;
299
+			}
300 300
 
301
-    		if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) {
302
-    			return true;
303
-    		}
304
-    	}
301
+			if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) {
302
+				return true;
303
+			}
304
+		}
305 305
 
306
-    	return false;
307
-    }
306
+		return false;
307
+	}
308 308
 
309
-    /**
310
-     * Check entries for spam
311
-     *
312
-     * @return boolean true if is spam
313
-     */
314
-    public static function akismet( $values ) {
315
-	    $content = FrmEntriesHelper::entry_array_to_string( $values );
309
+	/**
310
+	 * Check entries for spam
311
+	 *
312
+	 * @return boolean true if is spam
313
+	 */
314
+	public static function akismet( $values ) {
315
+		$content = FrmEntriesHelper::entry_array_to_string( $values );
316 316
 
317 317
 		if ( empty( $content ) ) {
318
-		    return false;
318
+			return false;
319 319
 		}
320 320
 
321
-        $datas = array();
322
-        self::parse_akismet_array( $datas, $content );
321
+		$datas = array();
322
+		self::parse_akismet_array( $datas, $content );
323 323
 
324 324
 		$query_string = '';
325 325
 		foreach ( $datas as $key => $data ) {
@@ -327,35 +327,35 @@  discard block
 block discarded – undo
327 327
 			unset( $key, $data );
328 328
 		}
329 329
 
330
-        $response = Akismet::http_post($query_string, 'comment-check');
330
+		$response = Akismet::http_post($query_string, 'comment-check');
331 331
 
332 332
 		return ( is_array( $response ) && $response[1] == 'true' );
333
-    }
334
-
335
-    /**
336
-     * @since 2.0
337
-     * @param string $content
338
-     */
339
-    private  static function parse_akismet_array( &$datas, $content ) {
340
-        $datas['blog'] = FrmAppHelper::site_url();
341
-        $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() );
333
+	}
334
+
335
+	/**
336
+	 * @since 2.0
337
+	 * @param string $content
338
+	 */
339
+	private  static function parse_akismet_array( &$datas, $content ) {
340
+		$datas['blog'] = FrmAppHelper::site_url();
341
+		$datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() );
342 342
 		$datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' );
343 343
 		$datas['referrer'] = isset( $_SERVER['HTTP_REFERER'] ) ? FrmAppHelper::get_server_value( 'HTTP_REFERER' ) : false;
344
-        $datas['comment_type'] = 'formidable';
345
-        $datas['comment_content'] = $content;
344
+		$datas['comment_type'] = 'formidable';
345
+		$datas['comment_content'] = $content;
346 346
 
347
-        if ( $permalink = get_permalink() ) {
348
-            $datas['permalink'] = $permalink;
349
-        }
347
+		if ( $permalink = get_permalink() ) {
348
+			$datas['permalink'] = $permalink;
349
+		}
350 350
 
351
-        foreach ( $_SERVER as $key => $value ) {
351
+		foreach ( $_SERVER as $key => $value ) {
352 352
 			if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) {
353 353
 				$datas[ $key ] = wp_strip_all_tags( $value );
354
-            } else {
354
+			} else {
355 355
 				$datas[ $key ] = '';
356
-            }
356
+			}
357 357
 
358
-            unset($key, $value);
359
-        }
360
-    }
358
+			unset($key, $value);
359
+		}
360
+	}
361 361
 }
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -7,20 +7,20 @@  discard block
 block discarded – undo
7 7
         FrmEntry::sanitize_entry_post( $values );
8 8
         $errors = array();
9 9
 
10
-        if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
10
+        if ( ! isset( $values['form_id'] ) || ! isset( $values['item_meta'] ) ) {
11 11
             $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
12 12
             return $errors;
13 13
         }
14 14
 
15
-		if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) {
15
+		if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values['frm_submit_entry_' . $values['form_id']] ) || ! wp_verify_nonce( $values['frm_submit_entry_' . $values['form_id']], 'frm_submit_entry_nonce' ) ) ) {
16 16
             $errors['form'] = __( 'You do not have permission to do that', 'formidable' );
17 17
         }
18 18
 
19
-        if ( ! isset($values['item_key']) || $values['item_key'] == '' ) {
19
+        if ( ! isset( $values['item_key'] ) || $values['item_key'] == '' ) {
20 20
 			$_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' );
21 21
         }
22 22
 
23
-        $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) );
23
+        $where = apply_filters( 'frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) );
24 24
 		// Don't get subfields
25 25
 		$where['fr.parent_form_id'] = array( null, 0 );
26 26
 		// Don't get excluded fields (like file upload fields in the ajax validation)
@@ -28,20 +28,20 @@  discard block
 block discarded – undo
28 28
 			$where['fi.type not'] = $exclude;
29 29
 		}
30 30
 
31
-        $posted_fields = FrmField::getAll($where, 'field_order');
31
+        $posted_fields = FrmField::getAll( $where, 'field_order' );
32 32
 
33 33
         // Pass exclude value to validate_field function so it can be used for repeating sections
34 34
         $args = array( 'exclude' => $exclude );
35 35
 
36 36
         foreach ( $posted_fields as $posted_field ) {
37
-            self::validate_field($posted_field, $errors, $values, $args);
38
-            unset($posted_field);
37
+            self::validate_field( $posted_field, $errors, $values, $args );
38
+            unset( $posted_field );
39 39
         }
40 40
 
41 41
         // check for spam
42 42
         self::spam_check( $exclude, $values, $errors );
43 43
 
44
-        $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') );
44
+        $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact( 'exclude' ) );
45 45
 
46 46
         return $errors;
47 47
     }
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
         );
56 56
         $args = wp_parse_args( $args, $defaults );
57 57
 
58
-        if ( empty($args['parent_field_id']) ) {
59
-			$value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
58
+        if ( empty( $args['parent_field_id'] ) ) {
59
+			$value = isset( $values['item_meta'][$args['id']] ) ? $values['item_meta'][$args['id']] : '';
60 60
         } else {
61 61
             // value is from a nested form
62 62
             $value = $values;
@@ -65,18 +65,18 @@  discard block
 block discarded – undo
65 65
         // Check for values in "Other" fields
66 66
         FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
67 67
 
68
-        if ( isset($posted_field->field_options['default_blank']) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) {
68
+        if ( isset( $posted_field->field_options['default_blank'] ) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) {
69 69
             $value = '';
70 70
         }
71 71
 
72 72
 		// Check for an array with only one value
73 73
 		// Don't reset values in "Other" fields because array keys need to be preserved
74
-		if ( is_array($value) && count( $value ) == 1 && $args['other'] !== true ) {
75
-			$value = reset($value);
74
+		if ( is_array( $value ) && count( $value ) == 1 && $args['other'] !== true ) {
75
+			$value = reset( $value );
76 76
 		}
77 77
 
78 78
         if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
79
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
79
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
80 80
         } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
81 81
             $_POST['item_name'] = $value;
82 82
         }
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
 			self::validate_phone_field( $errors, $posted_field, $value, $args );
89 89
 		}
90 90
 
91
-        FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
91
+        FrmEntriesHelper::set_posted_value( $posted_field, $value, $args );
92 92
 
93
-        self::validate_recaptcha($errors, $posted_field, $args);
93
+        self::validate_recaptcha( $errors, $posted_field, $args );
94 94
 
95
-        $errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args);
95
+        $errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args );
96 96
 		$errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args );
97 97
     }
98 98
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
             return;
102 102
         }
103 103
 
104
-        if ( trim($value) == 'http://' ) {
104
+        if ( trim( $value ) == 'http://' ) {
105 105
             $value = '';
106 106
         } else {
107 107
             $value = esc_url_raw( $value );
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
         }
110 110
 
111 111
         //validate the url format
112
-        if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) {
113
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
112
+        if ( ! preg_match( '/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value ) ) {
113
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
114 114
         }
115 115
     }
116 116
 
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
         }
121 121
 
122 122
         //validate the email format
123
-        if ( ! is_email($value) ) {
124
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
123
+        if ( ! is_email( $value ) ) {
124
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
125 125
         }
126 126
     }
127 127
 
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 			return;
132 132
 		}
133 133
 
134
-		if ( ! is_numeric( $value) ) {
135
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
134
+		if ( ! is_numeric( $value ) ) {
135
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
136 136
 		}
137 137
 
138 138
 		// validate number settings
@@ -142,9 +142,9 @@  discard block
 block discarded – undo
142 142
 			if ( $frm_settings->use_html && isset( $field->field_options['minnum'] ) && isset( $field->field_options['maxnum'] ) ) {
143 143
 				//minnum maxnum
144 144
 				if ( (float) $value < $field->field_options['minnum'] ) {
145
-					$errors[ 'field' . $args['id'] ] = __( 'Please select a higher number', 'formidable' );
145
+					$errors['field' . $args['id']] = __( 'Please select a higher number', 'formidable' );
146 146
 				} else if ( (float) $value > $field->field_options['maxnum'] ) {
147
-					$errors[ 'field' . $args['id'] ] = __( 'Please select a lower number', 'formidable' );
147
+					$errors['field' . $args['id']] = __( 'Please select a lower number', 'formidable' );
148 148
 				}
149 149
 			}
150 150
 		}
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 		$pattern = self::phone_format( $field );
159 159
 
160 160
 		if ( ! preg_match( $pattern, $value ) ) {
161
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
161
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
162 162
 		}
163 163
 	}
164 164
 
@@ -210,11 +210,11 @@  discard block
 block discarded – undo
210 210
 			return;
211 211
 		}
212 212
 
213
-        if ( ! isset($_POST['g-recaptcha-response']) ) {
213
+        if ( ! isset( $_POST['g-recaptcha-response'] ) ) {
214 214
             // If captcha is missing, check if it was already verified
215 215
 			if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) {
216 216
                 // There was no captcha submitted
217
-				$errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' );
217
+				$errors['field' . $args['id']] = __( 'The captcha is missing from this form', 'formidable' );
218 218
             }
219 219
             return;
220 220
         }
@@ -227,15 +227,15 @@  discard block
 block discarded – undo
227 227
 			),
228 228
 		);
229 229
         $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
230
-        $response = json_decode(wp_remote_retrieve_body( $resp ), true);
230
+        $response = json_decode( wp_remote_retrieve_body( $resp ), true );
231 231
 
232 232
         if ( isset( $response['success'] ) && ! $response['success'] ) {
233 233
             // What happens when the CAPTCHA was entered incorrectly
234
-			$errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
234
+			$errors['field' . $args['id']] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
235 235
         } else if ( is_wp_error( $resp ) ) {
236 236
 			$error_string = $resp->get_error_message();
237
-			$errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' );
238
-			$errors[ 'field' . $args['id'] ] .= ' ' . $error_string;
237
+			$errors['field' . $args['id']] = __( 'There was a problem verifying your recaptcha', 'formidable' );
238
+			$errors['field' . $args['id']] .= ' ' . $error_string;
239 239
         }
240 240
     }
241 241
 
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 
265 265
 	private static function is_akismet_spam( $values ) {
266 266
 		global $wpcom_api_key;
267
-		return ( is_callable('Akismet::http_post') && ( get_option('wordpress_api_key') || $wpcom_api_key ) && self::akismet( $values ) );
267
+		return ( is_callable( 'Akismet::http_post' ) && ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) && self::akismet( $values ) );
268 268
 	}
269 269
 
270 270
 	private static function is_akismet_enabled_for_user( $form_id ) {
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	}
274 274
 
275 275
     public static function blacklist_check( $values ) {
276
-        if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
276
+        if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) {
277 277
             return false;
278 278
         }
279 279
 
@@ -283,9 +283,9 @@  discard block
 block discarded – undo
283 283
     		return false;
284 284
     	}
285 285
 
286
-    	$content = FrmEntriesHelper::entry_array_to_string($values);
286
+    	$content = FrmEntriesHelper::entry_array_to_string( $values );
287 287
 
288
-		if ( empty($content) ) {
288
+		if ( empty( $content ) ) {
289 289
 		    return false;
290 290
 		}
291 291
 
@@ -294,11 +294,11 @@  discard block
 block discarded – undo
294 294
     	foreach ( (array) $words as $word ) {
295 295
     		$word = trim( $word );
296 296
 
297
-    		if ( empty($word) ) {
297
+    		if ( empty( $word ) ) {
298 298
     			continue;
299 299
     		}
300 300
 
301
-    		if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) {
301
+    		if ( preg_match( '#' . preg_quote( $word, '#' ) . '#', $content ) ) {
302 302
     			return true;
303 303
     		}
304 304
     	}
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 			unset( $key, $data );
328 328
 		}
329 329
 
330
-        $response = Akismet::http_post($query_string, 'comment-check');
330
+        $response = Akismet::http_post( $query_string, 'comment-check' );
331 331
 
332 332
 		return ( is_array( $response ) && $response[1] == 'true' );
333 333
     }
@@ -350,12 +350,12 @@  discard block
 block discarded – undo
350 350
 
351 351
         foreach ( $_SERVER as $key => $value ) {
352 352
 			if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) {
353
-				$datas[ $key ] = wp_strip_all_tags( $value );
353
+				$datas[$key] = wp_strip_all_tags( $value );
354 354
             } else {
355
-				$datas[ $key ] = '';
355
+				$datas[$key] = '';
356 356
             }
357 357
 
358
-            unset($key, $value);
358
+            unset( $key, $value );
359 359
         }
360 360
     }
361 361
 }
Please login to merge, or discard this patch.
classes/helpers/FrmFieldsHelper.php 2 patches
Indentation   +776 added lines, -776 removed lines patch added patch discarded remove patch
@@ -7,71 +7,71 @@  discard block
 block discarded – undo
7 7
 
8 8
 	public static function setup_new_vars( $type = '', $form_id = '' ) {
9 9
 
10
-        if ( strpos($type, '|') ) {
11
-            list($type, $setting) = explode('|', $type);
12
-        }
13
-
14
-        $defaults = self::get_default_field_opts($type, $form_id);
15
-        $defaults['field_options']['custom_html'] = self::get_default_html($type);
16
-
17
-        $values = array();
18
-
19
-        foreach ( $defaults as $var => $default ) {
20
-            if ( $var == 'field_options' ) {
21
-                $values['field_options'] = array();
22
-                foreach ( $default as $opt_var => $opt_default ) {
23
-                    $values['field_options'][ $opt_var ] = $opt_default;
24
-                    unset($opt_var, $opt_default);
25
-                }
26
-            } else {
27
-                $values[ $var ] = $default;
28
-            }
29
-            unset($var, $default);
30
-        }
31
-
32
-        if ( isset( $setting ) && ! empty( $setting ) ) {
33
-            if ( 'data' == $type ) {
34
-                $values['field_options']['data_type'] = $setting;
35
-            } else {
36
-                $values['field_options'][ $setting ] = 1;
37
-            }
38
-        }
39
-
40
-        if ( $type == 'radio' || $type == 'checkbox' ) {
41
-            $values['options'] = serialize( array(
42
-                __( 'Option 1', 'formidable' ),
43
-                __( 'Option 2', 'formidable' ),
44
-            ) );
45
-        } else if ( $type == 'select' ) {
46
-            $values['options'] = serialize( array(
47
-                '', __( 'Option 1', 'formidable' ),
48
-            ) );
49
-        } else if ( $type == 'textarea' ) {
50
-            $values['field_options']['max'] = '5';
51
-        } else if ( $type == 'captcha' ) {
52
-            $frm_settings = FrmAppHelper::get_settings();
53
-            $values['invalid'] = $frm_settings->re_msg;
54
-        } else if ( 'url' == $type ) {
55
-            $values['name'] = __( 'Website', 'formidable' );
56
-        }
10
+		if ( strpos($type, '|') ) {
11
+			list($type, $setting) = explode('|', $type);
12
+		}
13
+
14
+		$defaults = self::get_default_field_opts($type, $form_id);
15
+		$defaults['field_options']['custom_html'] = self::get_default_html($type);
16
+
17
+		$values = array();
18
+
19
+		foreach ( $defaults as $var => $default ) {
20
+			if ( $var == 'field_options' ) {
21
+				$values['field_options'] = array();
22
+				foreach ( $default as $opt_var => $opt_default ) {
23
+					$values['field_options'][ $opt_var ] = $opt_default;
24
+					unset($opt_var, $opt_default);
25
+				}
26
+			} else {
27
+				$values[ $var ] = $default;
28
+			}
29
+			unset($var, $default);
30
+		}
31
+
32
+		if ( isset( $setting ) && ! empty( $setting ) ) {
33
+			if ( 'data' == $type ) {
34
+				$values['field_options']['data_type'] = $setting;
35
+			} else {
36
+				$values['field_options'][ $setting ] = 1;
37
+			}
38
+		}
39
+
40
+		if ( $type == 'radio' || $type == 'checkbox' ) {
41
+			$values['options'] = serialize( array(
42
+				__( 'Option 1', 'formidable' ),
43
+				__( 'Option 2', 'formidable' ),
44
+			) );
45
+		} else if ( $type == 'select' ) {
46
+			$values['options'] = serialize( array(
47
+				'', __( 'Option 1', 'formidable' ),
48
+			) );
49
+		} else if ( $type == 'textarea' ) {
50
+			$values['field_options']['max'] = '5';
51
+		} else if ( $type == 'captcha' ) {
52
+			$frm_settings = FrmAppHelper::get_settings();
53
+			$values['invalid'] = $frm_settings->re_msg;
54
+		} else if ( 'url' == $type ) {
55
+			$values['name'] = __( 'Website', 'formidable' );
56
+		}
57 57
 
58 58
 		$fields = FrmField::field_selection();
59
-        $fields = array_merge($fields, FrmField::pro_field_selection());
59
+		$fields = array_merge($fields, FrmField::pro_field_selection());
60 60
 
61
-        if ( isset( $fields[ $type ] ) ) {
62
-            $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
63
-        }
61
+		if ( isset( $fields[ $type ] ) ) {
62
+			$values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
63
+		}
64 64
 
65
-        unset($fields);
65
+		unset($fields);
66 66
 
67
-        return $values;
68
-    }
67
+		return $values;
68
+	}
69 69
 
70 70
 	public static function get_html_id( $field, $plus = '' ) {
71 71
 		return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field );
72
-    }
72
+	}
73 73
 
74
-    public static function setup_edit_vars( $record, $doing_ajax = false ) {
74
+	public static function setup_edit_vars( $record, $doing_ajax = false ) {
75 75
 		$values = array( 'id' => $record->id, 'form_id' => $record->form_id );
76 76
 		$defaults = array(
77 77
 			'name'          => $record->name,
@@ -84,86 +84,86 @@  discard block
 block discarded – undo
84 84
 		);
85 85
 
86 86
 		if ( $doing_ajax ) {
87
-            $values = $values + $defaults;
88
-            $values['form_name'] = '';
87
+			$values = $values + $defaults;
88
+			$values['form_name'] = '';
89 89
 		} else {
90 90
 			foreach ( $defaults as $var => $default ) {
91
-                $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
-                unset($var, $default);
93
-            }
91
+				$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
+				unset($var, $default);
93
+			}
94 94
 
95 95
 			$values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : '';
96
-        }
96
+		}
97 97
 
98 98
 		unset( $defaults );
99 99
 
100
-        $values['options'] = $record->options;
101
-        $values['field_options'] = $record->field_options;
100
+		$values['options'] = $record->options;
101
+		$values['field_options'] = $record->field_options;
102 102
 
103
-        $defaults = self::get_default_field_opts($values['type'], $record, true);
103
+		$defaults = self::get_default_field_opts($values['type'], $record, true);
104 104
 
105 105
 		if ( $values['type'] == 'captcha' ) {
106
-            $frm_settings = FrmAppHelper::get_settings();
107
-            $defaults['invalid'] = $frm_settings->re_msg;
108
-        }
106
+			$frm_settings = FrmAppHelper::get_settings();
107
+			$defaults['invalid'] = $frm_settings->re_msg;
108
+		}
109 109
 
110 110
 		foreach ( $defaults as $opt => $default ) {
111
-            $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
112
-            unset($opt, $default);
113
-        }
111
+			$values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
112
+			unset($opt, $default);
113
+		}
114 114
 
115
-        $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
115
+		$values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
116 116
 
117 117
 		return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) );
118
-    }
118
+	}
119 119
 
120
-    public static function get_default_field_opts( $type, $field, $limit = false ) {
121
-        $field_options = array(
122
-            'size' => '', 'max' => '', 'label' => '', 'blank' => '',
123
-            'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0,
124
-            'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '',
120
+	public static function get_default_field_opts( $type, $field, $limit = false ) {
121
+		$field_options = array(
122
+			'size' => '', 'max' => '', 'label' => '', 'blank' => '',
123
+			'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0,
124
+			'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '',
125 125
 			'custom_html' => '', 'captcha_size' => 'default', 'captcha_theme' => 'light',
126
-        );
126
+		);
127 127
 
128 128
 		if ( $limit ) {
129
-            return $field_options;
129
+			return $field_options;
130 130
 		}
131 131
 
132
-        global $wpdb;
132
+		global $wpdb;
133 133
 
134
-        $form_id = (is_numeric($field)) ? $field : $field->form_id;
134
+		$form_id = (is_numeric($field)) ? $field : $field->form_id;
135 135
 
136 136
 		$key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key;
137 137
 
138
-        $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) );
138
+		$field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) );
139 139
 
140
-        $frm_settings = FrmAppHelper::get_settings();
141
-        return array(
142
-            'name' => __( 'Untitled', 'formidable' ), 'description' => '',
140
+		$frm_settings = FrmAppHelper::get_settings();
141
+		return array(
142
+			'name' => __( 'Untitled', 'formidable' ), 'description' => '',
143 143
 			'field_key' => $key, 'type' => $type, 'options' => '', 'default_value' => '',
144 144
 			'field_order' => $field_count + 1, 'required' => false,
145
-            'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg,
146
-            'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id,
145
+			'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg,
146
+			'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id,
147 147
 			'field_options' => $field_options,
148
-        );
149
-    }
148
+		);
149
+	}
150 150
 
151
-    public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
152
-        global $wpdb;
151
+	public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
152
+		global $wpdb;
153 153
 
154 154
 		$values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
155
-        $values['form_id'] = $form_id;
156
-        $values['options'] = maybe_serialize($field->options);
157
-        $values['default_value'] = maybe_serialize($field->default_value);
158
-
159
-        foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
160
-            $values[ $col ] = $field->{$col};
161
-        }
162
-    }
163
-
164
-    /**
165
-     * @since 2.0
166
-     */
155
+		$values['form_id'] = $form_id;
156
+		$values['options'] = maybe_serialize($field->options);
157
+		$values['default_value'] = maybe_serialize($field->default_value);
158
+
159
+		foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
160
+			$values[ $col ] = $field->{$col};
161
+		}
162
+	}
163
+
164
+	/**
165
+	 * @since 2.0
166
+	 */
167 167
 	public static function get_error_msg( $field, $error ) {
168 168
 		$frm_settings = FrmAppHelper::get_settings();
169 169
 		$default_settings = $frm_settings->default_options();
@@ -181,21 +181,21 @@  discard block
 block discarded – undo
181 181
 		return $msg;
182 182
 	}
183 183
 
184
-    public static function get_form_fields( $form_id, $error = false ) {
185
-        $fields = FrmField::get_all_for_form($form_id);
186
-        $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error);
187
-        return $fields;
188
-    }
184
+	public static function get_form_fields( $form_id, $error = false ) {
185
+		$fields = FrmField::get_all_for_form($form_id);
186
+		$fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error);
187
+		return $fields;
188
+	}
189 189
 
190 190
 	public static function get_default_html( $type = 'text' ) {
191 191
 		if ( apply_filters( 'frm_normal_field_type_html', true, $type ) ) {
192 192
 			$input = ( in_array( $type, array( 'radio', 'checkbox', 'data' ) ) ) ? '<div class="frm_opt_container">[input]</div>' : '[input]';
193
-            $for = '';
193
+			$for = '';
194 194
 			if ( ! in_array( $type, array( 'radio', 'checkbox', 'data', 'scale' ) ) ) {
195
-                $for = 'for="field_[key]"';
196
-            }
195
+				$for = 'for="field_[key]"';
196
+			}
197 197
 
198
-            $default_html = <<<DEFAULT_HTML
198
+			$default_html = <<<DEFAULT_HTML
199 199
 <div id="frm_field_[id]_container" class="frm_form_field form-field [required_class][error_class]">
200 200
     <label $for class="frm_primary_label">[field_name]
201 201
         <span class="frm_required">[required_label]</span>
@@ -205,145 +205,145 @@  discard block
 block discarded – undo
205 205
     [if error]<div class="frm_error">[error]</div>[/if error]
206 206
 </div>
207 207
 DEFAULT_HTML;
208
-        } else {
208
+		} else {
209 209
 			$default_html = apply_filters('frm_other_custom_html', '', $type);
210
-        }
210
+		}
211 211
 
212
-        return apply_filters('frm_custom_html', $default_html, $type);
213
-    }
212
+		return apply_filters('frm_custom_html', $default_html, $type);
213
+	}
214 214
 
215 215
 	public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) {
216
-        $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
216
+		$html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
217 217
 
218
-        $defaults = array(
218
+		$defaults = array(
219 219
 			'field_name'    => 'item_meta[' . $field['id'] . ']',
220 220
 			'field_id'      => $field['id'],
221
-            'field_plus_id' => '',
222
-            'section_id'    => '',
223
-        );
224
-        $args = wp_parse_args($args, $defaults);
225
-        $field_name = $args['field_name'];
226
-        $field_id = $args['field_id'];
227
-        $html_id = self::get_html_id($field, $args['field_plus_id']);
221
+			'field_plus_id' => '',
222
+			'section_id'    => '',
223
+		);
224
+		$args = wp_parse_args($args, $defaults);
225
+		$field_name = $args['field_name'];
226
+		$field_id = $args['field_id'];
227
+		$html_id = self::get_html_id($field, $args['field_plus_id']);
228 228
 
229
-        if ( FrmField::is_multiple_select($field) ) {
230
-            $field_name .= '[]';
231
-        }
229
+		if ( FrmField::is_multiple_select($field) ) {
230
+			$field_name .= '[]';
231
+		}
232 232
 
233
-        //replace [id]
234
-        $html = str_replace('[id]', $field_id, $html);
233
+		//replace [id]
234
+		$html = str_replace('[id]', $field_id, $html);
235 235
 
236
-        // Remove the for attribute for captcha
237
-        if ( $field['type'] == 'captcha' ) {
238
-            $html = str_replace(' for="field_[key]"', '', $html);
239
-        }
236
+		// Remove the for attribute for captcha
237
+		if ( $field['type'] == 'captcha' ) {
238
+			$html = str_replace(' for="field_[key]"', '', $html);
239
+		}
240 240
 
241
-        // set the label for
242
-        $html = str_replace('field_[key]', $html_id, $html);
241
+		// set the label for
242
+		$html = str_replace('field_[key]', $html_id, $html);
243 243
 
244
-        //replace [key]
245
-        $html = str_replace('[key]', $field['field_key'], $html);
244
+		//replace [key]
245
+		$html = str_replace('[key]', $field['field_key'], $html);
246 246
 
247
-        //replace [description] and [required_label] and [error]
247
+		//replace [description] and [required_label] and [error]
248 248
 		$required = FrmField::is_required( $field ) ? $field['required_indicator'] : '';
249
-        if ( ! is_array( $errors ) ) {
250
-            $errors = array();
251
-        }
249
+		if ( ! is_array( $errors ) ) {
250
+			$errors = array();
251
+		}
252 252
 		$error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false;
253 253
 
254
-        //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
255
-        if ( $field['type'] == 'divider' ) {
256
-            if ( FrmField::is_option_true( $field, 'description' ) ) {
257
-                $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
258
-            } else {
259
-                $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
260
-            }
261
-        }
254
+		//If field type is section heading, add class so a bottom margin can be added to either the h3 or description
255
+		if ( $field['type'] == 'divider' ) {
256
+			if ( FrmField::is_option_true( $field, 'description' ) ) {
257
+				$html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
258
+			} else {
259
+				$html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
260
+			}
261
+		}
262 262
 
263 263
 		foreach ( array( 'description' => $field['description'], 'required_label' => $required, 'error' => $error ) as $code => $value ) {
264
-            self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html );
265
-        }
264
+			self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html );
265
+		}
266 266
 
267
-        //replace [required_class]
267
+		//replace [required_class]
268 268
 		$required_class = FrmField::is_required( $field ) ? ' frm_required_field' : '';
269
-        $html = str_replace('[required_class]', $required_class, $html);
269
+		$html = str_replace('[required_class]', $required_class, $html);
270 270
 
271
-        //replace [label_position]
272
-        $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
273
-        $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
271
+		//replace [label_position]
272
+		$field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
273
+		$field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
274 274
 		$html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html );
275 275
 
276
-        //replace [field_name]
277
-        $html = str_replace('[field_name]', $field['name'], $html);
276
+		//replace [field_name]
277
+		$html = str_replace('[field_name]', $field['name'], $html);
278 278
 
279
-        //replace [error_class]
279
+		//replace [error_class]
280 280
 		$error_class = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : '';
281 281
 		self::get_more_field_classes( $error_class, $field, $field_id, $html );
282 282
 		if ( $field['type'] == 'html' && strpos( $html, '[error_class]' ) === false ) {
283 283
 			// there is no error_class shortcode to use for addign fields
284 284
 			$html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . $error_class, $html );
285 285
 		}
286
-        $html = str_replace('[error_class]', $error_class, $html);
286
+		$html = str_replace('[error_class]', $error_class, $html);
287 287
 
288
-        //replace [entry_key]
289
-        $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
290
-        $html = str_replace('[entry_key]', $entry_key, $html);
288
+		//replace [entry_key]
289
+		$entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
290
+		$html = str_replace('[entry_key]', $entry_key, $html);
291 291
 
292
-        //replace [input]
293
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
294
-        global $frm_vars;
295
-        $frm_settings = FrmAppHelper::get_settings();
292
+		//replace [input]
293
+		preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
294
+		global $frm_vars;
295
+		$frm_settings = FrmAppHelper::get_settings();
296 296
 
297
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
298
-            $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
297
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
298
+			$atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
299 299
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
300 300
 
301
-            $replace_with = '';
301
+			$replace_with = '';
302 302
 
303
-            if ( $tag == 'input' ) {
304
-                if ( isset($atts['opt']) ) {
305
-                    $atts['opt']--;
306
-                }
303
+			if ( $tag == 'input' ) {
304
+				if ( isset($atts['opt']) ) {
305
+					$atts['opt']--;
306
+				}
307 307
 
308
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
309
-                if ( isset($atts['class']) ) {
310
-                    unset($atts['class']);
311
-                }
308
+				$field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
309
+				if ( isset($atts['class']) ) {
310
+					unset($atts['class']);
311
+				}
312 312
 
313
-                $field['shortcodes'] = $atts;
314
-                ob_start();
313
+				$field['shortcodes'] = $atts;
314
+				ob_start();
315 315
 				include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' );
316
-                $replace_with = ob_get_contents();
317
-                ob_end_clean();
318
-            } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
319
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
320
-            }
316
+				$replace_with = ob_get_contents();
317
+				ob_end_clean();
318
+			} else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
319
+				$replace_with = FrmProEntriesController::entry_delete_link($atts);
320
+			}
321 321
 
322
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
323
-        }
322
+			$html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
323
+		}
324 324
 
325 325
 		if ( $form ) {
326
-            $form = (array) $form;
326
+			$form = (array) $form;
327 327
 
328
-            //replace [form_key]
329
-            $html = str_replace('[form_key]', $form['form_key'], $html);
328
+			//replace [form_key]
329
+			$html = str_replace('[form_key]', $form['form_key'], $html);
330 330
 
331
-            //replace [form_name]
332
-            $html = str_replace('[form_name]', $form['name'], $html);
333
-        }
334
-        $html .= "\n";
331
+			//replace [form_name]
332
+			$html = str_replace('[form_name]', $form['name'], $html);
333
+		}
334
+		$html .= "\n";
335 335
 
336
-        //Return html if conf_field to prevent loop
337
-        if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
338
-            return $html;
339
-        }
336
+		//Return html if conf_field to prevent loop
337
+		if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
338
+			return $html;
339
+		}
340 340
 
341
-        //If field is in repeating section
342
-        if ( $args['section_id'] ) {
343
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ));
344
-        } else {
345
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
346
-        }
341
+		//If field is in repeating section
342
+		if ( $args['section_id'] ) {
343
+			$html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ));
344
+		} else {
345
+			$html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
346
+		}
347 347
 
348 348
 		self::remove_collapse_shortcode( $html );
349 349
 
@@ -351,18 +351,18 @@  discard block
 block discarded – undo
351 351
 			$html = do_shortcode( $html );
352 352
 		}
353 353
 
354
-        return $html;
355
-    }
354
+		return $html;
355
+	}
356 356
 
357 357
 	/**
358
-	* Add more classes to certain fields (like confirmation fields, other fields, repeating fields, etc.)
359
-	*
360
-	* @since 2.0
361
-	* @param $error_class string, pass by reference
362
-	* @param $field array
363
-	* @param $field_id int
364
-	* @param $html string
365
-	*/
358
+	 * Add more classes to certain fields (like confirmation fields, other fields, repeating fields, etc.)
359
+	 *
360
+	 * @since 2.0
361
+	 * @param $error_class string, pass by reference
362
+	 * @param $field array
363
+	 * @param $field_id int
364
+	 * @param $html string
365
+	 */
366 366
 	private static function get_more_field_classes( &$error_class, $field, $field_id, $html ) {
367 367
 		$error_class .= ' frm_' . $field['label'] . '_container';
368 368
 		if ( $field['id'] != $field_id ) {
@@ -426,46 +426,46 @@  discard block
 block discarded – undo
426 426
 		}
427 427
 	}
428 428
 
429
-    public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
430
-        if ( $no_vars ) {
429
+	public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
430
+		if ( $no_vars ) {
431 431
 			$html = str_replace( '[if ' . $code . ']', '', $html );
432 432
 			$html = str_replace( '[/if ' . $code . ']', '', $html );
433
-        } else {
433
+		} else {
434 434
 			$html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html );
435
-        }
435
+		}
436 436
 
437 437
 		$html = str_replace( '[' . $code . ']', $replace_with, $html );
438
-    }
438
+	}
439 439
 
440 440
 	public static function get_shortcode_tag( $shortcodes, $short_key, $args ) {
441 441
 		$args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) );
442
-        if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
443
-            $args['conditional_check'] = true;
444
-        }
445
-
446
-        $prefix = '';
447
-        if ( $args['conditional_check'] ) {
448
-            if ( $args['conditional'] ) {
449
-                $prefix = 'if ';
450
-            } else if ( $args['foreach'] ) {
451
-                $prefix = 'foreach ';
452
-            }
453
-        }
454
-
455
-        $with_tags = $args['conditional_check'] ? 3 : 2;
456
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
457
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
458
-            $tag = str_replace(']', '', $tag);
459
-            $tags = explode(' ', $tag);
460
-            if ( is_array($tags) ) {
461
-                $tag = $tags[0];
462
-            }
463
-        } else {
464
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
465
-        }
466
-
467
-        return $tag;
468
-    }
442
+		if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
443
+			$args['conditional_check'] = true;
444
+		}
445
+
446
+		$prefix = '';
447
+		if ( $args['conditional_check'] ) {
448
+			if ( $args['conditional'] ) {
449
+				$prefix = 'if ';
450
+			} else if ( $args['foreach'] ) {
451
+				$prefix = 'foreach ';
452
+			}
453
+		}
454
+
455
+		$with_tags = $args['conditional_check'] ? 3 : 2;
456
+		if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
457
+			$tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
458
+			$tag = str_replace(']', '', $tag);
459
+			$tags = explode(' ', $tag);
460
+			if ( is_array($tags) ) {
461
+				$tag = $tags[0];
462
+			}
463
+		} else {
464
+			$tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
465
+		}
466
+
467
+		return $tag;
468
+	}
469 469
 
470 470
 	/**
471 471
 	 * Remove [collapse_this] if it's still included after all processing
@@ -490,124 +490,124 @@  discard block
 block discarded – undo
490 490
 			$class_prefix = 'frm-';
491 491
 		}
492 492
 
493
-        if ( $lang != 'en' ) {
493
+		if ( $lang != 'en' ) {
494 494
 			$api_js_url .= '&hl=' . $lang;
495
-        }
495
+		}
496 496
 		$api_js_url = apply_filters( 'frm_recaptcha_js_url', $api_js_url );
497 497
 
498
-        wp_register_script( 'recaptcha-api', $api_js_url, '', true );
499
-        wp_enqueue_script( 'recaptcha-api' );
498
+		wp_register_script( 'recaptcha-api', $api_js_url, '', true );
499
+		wp_enqueue_script( 'recaptcha-api' );
500 500
 
501 501
 ?>
502 502
 <div id="field_<?php echo esc_attr( $field['field_key'] ) ?>" class="<?php echo esc_attr( $class_prefix ) ?>g-recaptcha" data-sitekey="<?php echo esc_attr( $frm_settings->pubkey ) ?>" data-size="<?php echo esc_attr( $field['captcha_size'] ) ?>" data-theme="<?php echo esc_attr( $field['captcha_theme'] ) ?>"></div>
503 503
 <?php
504
-    }
504
+	}
505 505
 
506 506
 	public static function show_single_option( $field ) {
507
-        $field_name = $field['name'];
508
-        $html_id = self::get_html_id($field);
509
-        foreach ( $field['options'] as $opt_key => $opt ) {
510
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
511
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
507
+		$field_name = $field['name'];
508
+		$html_id = self::get_html_id($field);
509
+		foreach ( $field['options'] as $opt_key => $opt ) {
510
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
511
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
512 512
 
513
-            // If this is an "Other" option, get the HTML for it
513
+			// If this is an "Other" option, get the HTML for it
514 514
 			if ( self::is_other_opt( $opt_key ) ) {
515
-                // Get string for Other text field, if needed
515
+				// Get string for Other text field, if needed
516 516
 				$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
517 517
 				require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
518
-            } else {
518
+			} else {
519 519
 				require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
520
-            }
521
-        }
522
-    }
520
+			}
521
+		}
522
+	}
523 523
 
524 524
 	public static function dropdown_categories( $args ) {
525 525
 		$defaults = array( 'field' => false, 'name' => false, 'show_option_all' => ' ' );
526
-        $args = wp_parse_args($args, $defaults);
526
+		$args = wp_parse_args($args, $defaults);
527 527
 
528
-        if ( ! $args['field'] ) {
529
-            return;
530
-        }
528
+		if ( ! $args['field'] ) {
529
+			return;
530
+		}
531 531
 
532
-        if ( ! $args['name'] ) {
532
+		if ( ! $args['name'] ) {
533 533
 			$args['name'] = 'item_meta[' . $args['field']['id'] . ']';
534
-        }
534
+		}
535 535
 
536
-        $id = self::get_html_id($args['field']);
537
-        $class = $args['field']['type'];
536
+		$id = self::get_html_id($args['field']);
537
+		$class = $args['field']['type'];
538 538
 
539
-        $exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat'];
540
-        $exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']);
539
+		$exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat'];
540
+		$exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']);
541 541
 
542
-        if ( is_array($args['field']['value']) ) {
543
-            if ( ! empty($exclude) ) {
544
-                $args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude));
545
-            }
546
-            $selected = reset($args['field']['value']);
547
-        } else {
548
-            $selected = $args['field']['value'];
549
-        }
542
+		if ( is_array($args['field']['value']) ) {
543
+			if ( ! empty($exclude) ) {
544
+				$args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude));
545
+			}
546
+			$selected = reset($args['field']['value']);
547
+		} else {
548
+			$selected = $args['field']['value'];
549
+		}
550 550
 
551
-        $tax_atts = array(
552
-            'show_option_all' => $args['show_option_all'], 'hierarchical' => 1, 'name' => $args['name'],
553
-            'id' => $id, 'exclude' => $exclude, 'class' => $class, 'selected' => $selected,
554
-            'hide_empty' => false, 'echo' => 0, 'orderby' => 'name',
555
-        );
551
+		$tax_atts = array(
552
+			'show_option_all' => $args['show_option_all'], 'hierarchical' => 1, 'name' => $args['name'],
553
+			'id' => $id, 'exclude' => $exclude, 'class' => $class, 'selected' => $selected,
554
+			'hide_empty' => false, 'echo' => 0, 'orderby' => 'name',
555
+		);
556 556
 
557
-        $tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']);
557
+		$tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']);
558 558
 
559
-        if ( FrmAppHelper::pro_is_installed() ) {
560
-            $post_type = FrmProFormsHelper::post_type($args['field']['form_id']);
561
-            $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']);
562
-            if ( ! $tax_atts['taxonomy'] ) {
563
-                return;
564
-            }
559
+		if ( FrmAppHelper::pro_is_installed() ) {
560
+			$post_type = FrmProFormsHelper::post_type($args['field']['form_id']);
561
+			$tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']);
562
+			if ( ! $tax_atts['taxonomy'] ) {
563
+				return;
564
+			}
565 565
 
566
-            // If field type is dropdown (not Dynamic), exclude children when parent is excluded
567
-            if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) {
568
-                $tax_atts['exclude_tree'] = $exclude;
569
-            }
570
-        }
566
+			// If field type is dropdown (not Dynamic), exclude children when parent is excluded
567
+			if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) {
568
+				$tax_atts['exclude_tree'] = $exclude;
569
+			}
570
+		}
571 571
 
572
-        $dropdown = wp_dropdown_categories($tax_atts);
572
+		$dropdown = wp_dropdown_categories($tax_atts);
573 573
 
574
-        $add_html = FrmFieldsController::input_html($args['field'], false);
574
+		$add_html = FrmFieldsController::input_html($args['field'], false);
575 575
 
576
-        if ( FrmAppHelper::pro_is_installed() ) {
577
-            $add_html .= FrmProFieldsController::input_html($args['field'], false);
578
-        }
576
+		if ( FrmAppHelper::pro_is_installed() ) {
577
+			$add_html .= FrmProFieldsController::input_html($args['field'], false);
578
+		}
579 579
 
580 580
 		$dropdown = str_replace( "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' class='" . esc_attr( $class ) . "'", "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' " . $add_html, $dropdown );
581 581
 
582
-        if ( is_array($args['field']['value']) ) {
583
-            $skip = true;
584
-            foreach ( $args['field']['value'] as $v ) {
582
+		if ( is_array($args['field']['value']) ) {
583
+			$skip = true;
584
+			foreach ( $args['field']['value'] as $v ) {
585 585
 				if ( $skip ) {
586
-                    $skip = false;
587
-                    continue;
588
-                }
586
+					$skip = false;
587
+					continue;
588
+				}
589 589
 				$dropdown = str_replace(' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown );
590
-                unset($v);
591
-            }
592
-        }
590
+				unset($v);
591
+			}
592
+		}
593 593
 
594
-        return $dropdown;
595
-    }
594
+		return $dropdown;
595
+	}
596 596
 
597 597
 	public static function get_term_link( $tax_id ) {
598
-        $tax = get_taxonomy($tax_id);
599
-        if ( ! $tax ) {
600
-            return;
601
-        }
598
+		$tax = get_taxonomy($tax_id);
599
+		if ( ! $tax ) {
600
+			return;
601
+		}
602 602
 
603
-        $link = sprintf(
604
-            __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
603
+		$link = sprintf(
604
+			__( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
605 605
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
606
-        );
607
-        unset($tax);
606
+		);
607
+		unset($tax);
608 608
 
609
-        return $link;
610
-    }
609
+		return $link;
610
+	}
611 611
 
612 612
 	public static function value_meets_condition( $observed_value, $cond, $hide_opt ) {
613 613
 		// Remove white space from hide_opt
@@ -615,195 +615,195 @@  discard block
 block discarded – undo
615 615
 			$hide_opt = rtrim( $hide_opt );
616 616
 		}
617 617
 
618
-        if ( is_array($observed_value) ) {
619
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
620
-        }
621
-
622
-        $m = false;
623
-        if ( $cond == '==' ) {
624
-            $m = $observed_value == $hide_opt;
625
-        } else if ( $cond == '!=' ) {
626
-            $m = $observed_value != $hide_opt;
627
-        } else if ( $cond == '>' ) {
628
-            $m = $observed_value > $hide_opt;
629
-        } else if ( $cond == '<' ) {
630
-            $m = $observed_value < $hide_opt;
631
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
632
-            $m = stripos($observed_value, $hide_opt);
633
-            if ( $cond == 'not LIKE' ) {
634
-                $m = ( $m === false ) ? true : false;
635
-            } else {
636
-                $m = ( $m === false ) ? false : true;
637
-            }
638
-        }
639
-        return $m;
640
-    }
618
+		if ( is_array($observed_value) ) {
619
+			return self::array_value_condition($observed_value, $cond, $hide_opt);
620
+		}
621
+
622
+		$m = false;
623
+		if ( $cond == '==' ) {
624
+			$m = $observed_value == $hide_opt;
625
+		} else if ( $cond == '!=' ) {
626
+			$m = $observed_value != $hide_opt;
627
+		} else if ( $cond == '>' ) {
628
+			$m = $observed_value > $hide_opt;
629
+		} else if ( $cond == '<' ) {
630
+			$m = $observed_value < $hide_opt;
631
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
632
+			$m = stripos($observed_value, $hide_opt);
633
+			if ( $cond == 'not LIKE' ) {
634
+				$m = ( $m === false ) ? true : false;
635
+			} else {
636
+				$m = ( $m === false ) ? false : true;
637
+			}
638
+		}
639
+		return $m;
640
+	}
641 641
 
642 642
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
643
-        $m = false;
644
-        if ( $cond == '==' ) {
645
-            if ( is_array($hide_opt) ) {
646
-                $m = array_intersect($hide_opt, $observed_value);
647
-                $m = empty($m) ? false : true;
648
-            } else {
649
-                $m = in_array($hide_opt, $observed_value);
650
-            }
651
-        } else if ( $cond == '!=' ) {
652
-            $m = ! in_array($hide_opt, $observed_value);
653
-        } else if ( $cond == '>' ) {
654
-            $min = min($observed_value);
655
-            $m = $min > $hide_opt;
656
-        } else if ( $cond == '<' ) {
657
-            $max = max($observed_value);
658
-            $m = $max < $hide_opt;
659
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
660
-            foreach ( $observed_value as $ob ) {
661
-                $m = strpos($ob, $hide_opt);
662
-                if ( $m !== false ) {
663
-                    $m = true;
664
-                    break;
665
-                }
666
-            }
667
-
668
-            if ( $cond == 'not LIKE' ) {
669
-                $m = ( $m === false ) ? true : false;
670
-            }
671
-        }
672
-
673
-        return $m;
674
-    }
675
-
676
-    /**
677
-     * Replace a few basic shortcodes and field ids
678
-     * @since 2.0
679
-     * @return string
680
-     */
643
+		$m = false;
644
+		if ( $cond == '==' ) {
645
+			if ( is_array($hide_opt) ) {
646
+				$m = array_intersect($hide_opt, $observed_value);
647
+				$m = empty($m) ? false : true;
648
+			} else {
649
+				$m = in_array($hide_opt, $observed_value);
650
+			}
651
+		} else if ( $cond == '!=' ) {
652
+			$m = ! in_array($hide_opt, $observed_value);
653
+		} else if ( $cond == '>' ) {
654
+			$min = min($observed_value);
655
+			$m = $min > $hide_opt;
656
+		} else if ( $cond == '<' ) {
657
+			$max = max($observed_value);
658
+			$m = $max < $hide_opt;
659
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
660
+			foreach ( $observed_value as $ob ) {
661
+				$m = strpos($ob, $hide_opt);
662
+				if ( $m !== false ) {
663
+					$m = true;
664
+					break;
665
+				}
666
+			}
667
+
668
+			if ( $cond == 'not LIKE' ) {
669
+				$m = ( $m === false ) ? true : false;
670
+			}
671
+		}
672
+
673
+		return $m;
674
+	}
675
+
676
+	/**
677
+	 * Replace a few basic shortcodes and field ids
678
+	 * @since 2.0
679
+	 * @return string
680
+	 */
681 681
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
682
-        if ( strpos($value, '[sitename]') !== false ) {
683
-            $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
684
-            $value = str_replace('[sitename]', $new_value, $value);
685
-        }
682
+		if ( strpos($value, '[sitename]') !== false ) {
683
+			$new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
684
+			$value = str_replace('[sitename]', $new_value, $value);
685
+		}
686 686
 
687
-        $value = apply_filters('frm_content', $value, $form, $entry);
688
-        $value = do_shortcode($value);
687
+		$value = apply_filters('frm_content', $value, $form, $entry);
688
+		$value = do_shortcode($value);
689 689
 
690
-        return $value;
691
-    }
690
+		return $value;
691
+	}
692 692
 
693 693
 	public static function get_shortcodes( $content, $form_id ) {
694
-        if ( FrmAppHelper::pro_is_installed() ) {
695
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
696
-        }
694
+		if ( FrmAppHelper::pro_is_installed() ) {
695
+			return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
696
+		}
697 697
 
698
-        $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
698
+		$fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
699 699
 
700
-        $tagregexp = self::allowed_shortcodes($fields);
700
+		$tagregexp = self::allowed_shortcodes($fields);
701 701
 
702
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
702
+		preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
703 703
 
704
-        return $matches;
705
-    }
704
+		return $matches;
705
+	}
706 706
 
707 707
 	public static function allowed_shortcodes( $fields = array() ) {
708
-        $tagregexp = array(
709
-            'editlink', 'id', 'key', 'ip',
710
-            'siteurl', 'sitename', 'admin_email',
711
-            'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
708
+		$tagregexp = array(
709
+			'editlink', 'id', 'key', 'ip',
710
+			'siteurl', 'sitename', 'admin_email',
711
+			'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
712 712
 			'parent[-|_]id',
713
-        );
713
+		);
714 714
 
715
-        foreach ( $fields as $field ) {
716
-            $tagregexp[] = $field->id;
717
-            $tagregexp[] = $field->field_key;
718
-        }
715
+		foreach ( $fields as $field ) {
716
+			$tagregexp[] = $field->id;
717
+			$tagregexp[] = $field->field_key;
718
+		}
719 719
 
720
-        $tagregexp = implode('|', $tagregexp);
721
-        return $tagregexp;
722
-    }
720
+		$tagregexp = implode('|', $tagregexp);
721
+		return $tagregexp;
722
+	}
723 723
 
724 724
 	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
725
-        $shortcode_values = array(
726
-           'id'     => $entry->id,
727
-           'key'    => $entry->item_key,
728
-           'ip'     => $entry->ip,
729
-        );
725
+		$shortcode_values = array(
726
+		   'id'     => $entry->id,
727
+		   'key'    => $entry->item_key,
728
+		   'ip'     => $entry->ip,
729
+		);
730 730
 
731
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
732
-            $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
731
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
732
+			$atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
733 733
 
734
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
734
+			if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
735 735
 				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
736
-                $tags = explode(' ', $tag);
737
-                if ( is_array($tags) ) {
738
-                    $tag = $tags[0];
739
-                }
740
-            } else {
741
-                $tag = $shortcodes[2][ $short_key ];
742
-            }
743
-
744
-            switch ( $tag ) {
745
-                case 'id':
746
-                case 'key':
747
-                case 'ip':
748
-                    $replace_with = $shortcode_values[ $tag ];
749
-                break;
750
-
751
-                case 'user_agent':
752
-                case 'user-agent':
753
-                    $entry->description = maybe_unserialize($entry->description);
736
+				$tags = explode(' ', $tag);
737
+				if ( is_array($tags) ) {
738
+					$tag = $tags[0];
739
+				}
740
+			} else {
741
+				$tag = $shortcodes[2][ $short_key ];
742
+			}
743
+
744
+			switch ( $tag ) {
745
+				case 'id':
746
+				case 'key':
747
+				case 'ip':
748
+					$replace_with = $shortcode_values[ $tag ];
749
+				break;
750
+
751
+				case 'user_agent':
752
+				case 'user-agent':
753
+					$entry->description = maybe_unserialize($entry->description);
754 754
 					$replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] );
755
-                break;
756
-
757
-                case 'created_at':
758
-                case 'created-at':
759
-                case 'updated_at':
760
-                case 'updated-at':
761
-                    if ( isset($atts['format']) ) {
762
-                        $time_format = ' ';
763
-                    } else {
764
-                        $atts['format'] = get_option('date_format');
765
-                        $time_format = '';
766
-                    }
767
-
768
-                    $this_tag = str_replace('-', '_', $tag);
769
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
770
-                    unset($this_tag);
771
-                break;
772
-
773
-                case 'created_by':
774
-                case 'created-by':
775
-                case 'updated_by':
776
-                case 'updated-by':
777
-                    $this_tag = str_replace('-', '_', $tag);
755
+				break;
756
+
757
+				case 'created_at':
758
+				case 'created-at':
759
+				case 'updated_at':
760
+				case 'updated-at':
761
+					if ( isset($atts['format']) ) {
762
+						$time_format = ' ';
763
+					} else {
764
+						$atts['format'] = get_option('date_format');
765
+						$time_format = '';
766
+					}
767
+
768
+					$this_tag = str_replace('-', '_', $tag);
769
+					$replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
770
+					unset($this_tag);
771
+				break;
772
+
773
+				case 'created_by':
774
+				case 'created-by':
775
+				case 'updated_by':
776
+				case 'updated-by':
777
+					$this_tag = str_replace('-', '_', $tag);
778 778
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
779
-                    unset($this_tag);
780
-                break;
781
-
782
-                case 'admin_email':
783
-                case 'siteurl':
784
-                case 'frmurl':
785
-                case 'sitename':
786
-                case 'get':
787
-                    $replace_with = self::dynamic_default_values( $tag, $atts );
788
-                break;
789
-
790
-                default:
791
-                    $field = FrmField::getOne( $tag );
792
-                    if ( ! $field ) {
793
-                        break;
794
-                    }
795
-
796
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
797
-
798
-                    $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
799
-
800
-                    $atts['entry_id'] = $entry->id;
801
-                    $atts['entry_key'] = $entry->item_key;
802
-
803
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
804
-                        $replace_with = $field->name;
805
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
806
-                        $replace_with = $field->description;
779
+					unset($this_tag);
780
+				break;
781
+
782
+				case 'admin_email':
783
+				case 'siteurl':
784
+				case 'frmurl':
785
+				case 'sitename':
786
+				case 'get':
787
+					$replace_with = self::dynamic_default_values( $tag, $atts );
788
+				break;
789
+
790
+				default:
791
+					$field = FrmField::getOne( $tag );
792
+					if ( ! $field ) {
793
+						break;
794
+					}
795
+
796
+					$sep = isset($atts['sep']) ? $atts['sep'] : ', ';
797
+
798
+					$replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
799
+
800
+					$atts['entry_id'] = $entry->id;
801
+					$atts['entry_key'] = $entry->item_key;
802
+
803
+					if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
804
+						$replace_with = $field->name;
805
+					} else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
806
+						$replace_with = $field->description;
807 807
 					} else {
808 808
 						$string_value = $replace_with;
809 809
 						if ( is_array( $replace_with ) ) {
@@ -817,82 +817,82 @@  discard block
 block discarded – undo
817 817
 						}
818 818
 					}
819 819
 
820
-                    unset($field);
821
-                break;
822
-            }
820
+					unset($field);
821
+				break;
822
+			}
823 823
 
824
-            if ( isset($replace_with) ) {
825
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
826
-            }
824
+			if ( isset($replace_with) ) {
825
+				$content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
826
+			}
827 827
 
828
-            unset($atts, $conditional, $replace_with);
828
+			unset($atts, $conditional, $replace_with);
829 829
 		}
830 830
 
831 831
 		return $content;
832
-    }
833
-
834
-    /**
835
-     * Get the value to replace a few standard shortcodes
836
-     *
837
-     * @since 2.0
838
-     * @return string
839
-     */
840
-    public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
841
-        $new_value = '';
842
-        switch ( $tag ) {
843
-            case 'admin_email':
844
-                $new_value = get_option('admin_email');
845
-                break;
846
-            case 'siteurl':
847
-                $new_value = FrmAppHelper::site_url();
848
-                break;
849
-            case 'frmurl':
850
-                $new_value = FrmAppHelper::plugin_url();
851
-                break;
852
-            case 'sitename':
853
-                $new_value = FrmAppHelper::site_name();
854
-                break;
855
-            case 'get':
856
-                $new_value = self::process_get_shortcode( $atts, $return_array );
857
-                break;
858
-        }
859
-
860
-        return $new_value;
861
-    }
862
-
863
-    /**
864
-     * Process the [get] shortcode
865
-     *
866
-     * @since 2.0
867
-     * @return string|array
868
-     */
869
-    public static function process_get_shortcode( $atts, $return_array = false ) {
870
-        if ( ! isset($atts['param']) ) {
871
-            return '';
872
-        }
873
-
874
-        if ( strpos($atts['param'], '&#91;') ) {
875
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
876
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
877
-        }
878
-
879
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
880
-        $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
881
-
882
-        if ( $new_value == '' ) {
883
-            if ( ! isset($atts['prev_val']) ) {
884
-                $atts['prev_val'] = '';
885
-            }
886
-
887
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
888
-        }
889
-
890
-        if ( is_array($new_value) && ! $return_array ) {
891
-            $new_value = implode(', ', $new_value);
892
-        }
893
-
894
-        return $new_value;
895
-    }
832
+	}
833
+
834
+	/**
835
+	 * Get the value to replace a few standard shortcodes
836
+	 *
837
+	 * @since 2.0
838
+	 * @return string
839
+	 */
840
+	public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
841
+		$new_value = '';
842
+		switch ( $tag ) {
843
+			case 'admin_email':
844
+				$new_value = get_option('admin_email');
845
+				break;
846
+			case 'siteurl':
847
+				$new_value = FrmAppHelper::site_url();
848
+				break;
849
+			case 'frmurl':
850
+				$new_value = FrmAppHelper::plugin_url();
851
+				break;
852
+			case 'sitename':
853
+				$new_value = FrmAppHelper::site_name();
854
+				break;
855
+			case 'get':
856
+				$new_value = self::process_get_shortcode( $atts, $return_array );
857
+				break;
858
+		}
859
+
860
+		return $new_value;
861
+	}
862
+
863
+	/**
864
+	 * Process the [get] shortcode
865
+	 *
866
+	 * @since 2.0
867
+	 * @return string|array
868
+	 */
869
+	public static function process_get_shortcode( $atts, $return_array = false ) {
870
+		if ( ! isset($atts['param']) ) {
871
+			return '';
872
+		}
873
+
874
+		if ( strpos($atts['param'], '&#91;') ) {
875
+			$atts['param'] = str_replace('&#91;', '[', $atts['param']);
876
+			$atts['param'] = str_replace('&#93;', ']', $atts['param']);
877
+		}
878
+
879
+		$new_value = FrmAppHelper::get_param($atts['param'], '');
880
+		$new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
881
+
882
+		if ( $new_value == '' ) {
883
+			if ( ! isset($atts['prev_val']) ) {
884
+				$atts['prev_val'] = '';
885
+			}
886
+
887
+			$new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
888
+		}
889
+
890
+		if ( is_array($new_value) && ! $return_array ) {
891
+			$new_value = implode(', ', $new_value);
892
+		}
893
+
894
+		return $new_value;
895
+	}
896 896
 
897 897
 	public static function get_display_value( $replace_with, $field, $atts = array() ) {
898 898
 		$atts['sep'] = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
@@ -900,14 +900,14 @@  discard block
 block discarded – undo
900 900
 		$replace_with = apply_filters( 'frm_get_' . $field->type . '_display_value', $replace_with, $field, $atts );
901 901
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
902 902
 
903
-        if ( $field->type == 'textarea' || $field->type == 'rte' ) {
904
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
905
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
906
-                if ( is_array($replace_with) ) {
907
-                    $replace_with = implode("\n", $replace_with);
908
-                }
909
-                $replace_with = wpautop($replace_with);
910
-            }
903
+		if ( $field->type == 'textarea' || $field->type == 'rte' ) {
904
+			$autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
905
+			if ( apply_filters('frm_use_wpautop', $autop) ) {
906
+				if ( is_array($replace_with) ) {
907
+					$replace_with = implode("\n", $replace_with);
908
+				}
909
+				$replace_with = wpautop($replace_with);
910
+			}
911 911
 			unset( $autop );
912 912
 		} else if ( is_array( $replace_with ) ) {
913 913
 			$replace_with = implode( $atts['sep'], $replace_with );
@@ -917,57 +917,57 @@  discard block
 block discarded – undo
917 917
 	}
918 918
 
919 919
 	public static function get_field_types( $type ) {
920
-        $single_input = array(
921
-            'text', 'textarea', 'rte', 'number', 'email', 'url',
922
-            'image', 'file', 'date', 'phone', 'hidden', 'time',
923
-            'user_id', 'tag', 'password',
924
-        );
920
+		$single_input = array(
921
+			'text', 'textarea', 'rte', 'number', 'email', 'url',
922
+			'image', 'file', 'date', 'phone', 'hidden', 'time',
923
+			'user_id', 'tag', 'password',
924
+		);
925 925
 		$multiple_input = array( 'radio', 'checkbox', 'select', 'scale' );
926 926
 		$other_type = array( 'divider', 'html', 'break' );
927 927
 
928 928
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
929 929
 
930
-        $field_types = array();
931
-        if ( in_array($type, $single_input) ) {
932
-            self::field_types_for_input( $single_input, $field_selection, $field_types );
933
-        } else if ( in_array($type, $multiple_input) ) {
934
-            self::field_types_for_input( $multiple_input, $field_selection, $field_types );
935
-        } else if ( in_array($type, $other_type) ) {
936
-            self::field_types_for_input( $other_type, $field_selection, $field_types );
930
+		$field_types = array();
931
+		if ( in_array($type, $single_input) ) {
932
+			self::field_types_for_input( $single_input, $field_selection, $field_types );
933
+		} else if ( in_array($type, $multiple_input) ) {
934
+			self::field_types_for_input( $multiple_input, $field_selection, $field_types );
935
+		} else if ( in_array($type, $other_type) ) {
936
+			self::field_types_for_input( $other_type, $field_selection, $field_types );
937 937
 		} else if ( isset( $field_selection[ $type ] ) ) {
938
-            $field_types[ $type ] = $field_selection[ $type ];
939
-        }
940
-
941
-        return $field_types;
942
-    }
943
-
944
-    private static function field_types_for_input( $inputs, $fields, &$field_types ) {
945
-        foreach ( $inputs as $input ) {
946
-            $field_types[ $input ] = $fields[ $input ];
947
-            unset($input);
948
-        }
949
-    }
950
-
951
-    /**
952
-    * Check if current field option is an "other" option
953
-    *
954
-    * @since 2.0.6
955
-    *
956
-    * @param string $opt_key
957
-    * @return boolean Returns true if current field option is an "Other" option
958
-    */
959
-    public static function is_other_opt( $opt_key ) {
960
-        return $opt_key && strpos( $opt_key, 'other' ) !== false;
961
-    }
962
-
963
-    /**
964
-    * Get value that belongs in "Other" text box
965
-    *
966
-    * @since 2.0.6
967
-    *
968
-    * @param array $args
969
-    */
970
-    public static function get_other_val( $args ) {
938
+			$field_types[ $type ] = $field_selection[ $type ];
939
+		}
940
+
941
+		return $field_types;
942
+	}
943
+
944
+	private static function field_types_for_input( $inputs, $fields, &$field_types ) {
945
+		foreach ( $inputs as $input ) {
946
+			$field_types[ $input ] = $fields[ $input ];
947
+			unset($input);
948
+		}
949
+	}
950
+
951
+	/**
952
+	 * Check if current field option is an "other" option
953
+	 *
954
+	 * @since 2.0.6
955
+	 *
956
+	 * @param string $opt_key
957
+	 * @return boolean Returns true if current field option is an "Other" option
958
+	 */
959
+	public static function is_other_opt( $opt_key ) {
960
+		return $opt_key && strpos( $opt_key, 'other' ) !== false;
961
+	}
962
+
963
+	/**
964
+	 * Get value that belongs in "Other" text box
965
+	 *
966
+	 * @since 2.0.6
967
+	 *
968
+	 * @param array $args
969
+	 */
970
+	public static function get_other_val( $args ) {
971 971
 		$defaults = array(
972 972
 			'opt_key' => 0, 'field' => array(),
973 973
 			'parent' => false, 'pointer' => false,
@@ -1043,20 +1043,20 @@  discard block
 block discarded – undo
1043 1043
 		}
1044 1044
 
1045 1045
 		return $other_val;
1046
-    }
1047
-
1048
-    /**
1049
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
1050
-    * Intended for front-end use
1051
-    *
1052
-    * @since 2.0.6
1053
-    *
1054
-    * @param array $args should include field, opt_key and field name
1055
-    * @param boolean $other_opt
1056
-    * @param string $checked
1057
-    * @return string $other_val
1058
-    */
1059
-    public static function prepare_other_input( $args, &$other_opt, &$checked ) {
1046
+	}
1047
+
1048
+	/**
1049
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
1050
+	 * Intended for front-end use
1051
+	 *
1052
+	 * @since 2.0.6
1053
+	 *
1054
+	 * @param array $args should include field, opt_key and field name
1055
+	 * @param boolean $other_opt
1056
+	 * @param string $checked
1057
+	 * @return string $other_val
1058
+	 */
1059
+	public static function prepare_other_input( $args, &$other_opt, &$checked ) {
1060 1060
 		//Check if this is an "Other" option
1061 1061
 		if ( ! self::is_other_opt( $args['opt_key'] ) ) {
1062 1062
 			return;
@@ -1072,8 +1072,8 @@  discard block
 block discarded – undo
1072 1072
 			$checked = 'checked="checked" ';
1073 1073
 		}
1074 1074
 
1075
-        return $other_args;
1076
-    }
1075
+		return $other_args;
1076
+	}
1077 1077
 
1078 1078
 	/**
1079 1079
 	 * @param array $args
@@ -1122,8 +1122,8 @@  discard block
 block discarded – undo
1122 1122
 	 * @since 2.0.6
1123 1123
 	 */
1124 1124
 	public static function include_other_input( $args ) {
1125
-        if ( ! $args['other_opt'] ) {
1126
-        	return;
1125
+		if ( ! $args['other_opt'] ) {
1126
+			return;
1127 1127
 		}
1128 1128
 
1129 1129
 		$classes = array( 'frm_other_input' );
@@ -1144,15 +1144,15 @@  discard block
 block discarded – undo
1144 1144
 	}
1145 1145
 
1146 1146
 	/**
1147
-	* Get the HTML id for an "Other" text field
1148
-	* Note: This does not affect fields in repeating sections
1149
-	*
1150
-	* @since 2.0.08
1151
-	* @param string $type - field type
1152
-	* @param string $html_id
1153
-	* @param string|boolean $opt_key
1154
-	* @return string $other_id
1155
-	*/
1147
+	 * Get the HTML id for an "Other" text field
1148
+	 * Note: This does not affect fields in repeating sections
1149
+	 *
1150
+	 * @since 2.0.08
1151
+	 * @param string $type - field type
1152
+	 * @param string $html_id
1153
+	 * @param string|boolean $opt_key
1154
+	 * @return string $other_id
1155
+	 */
1156 1156
 	public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) {
1157 1157
 		$other_id = $html_id;
1158 1158
 
@@ -1210,10 +1210,10 @@  discard block
 block discarded – undo
1210 1210
 	}
1211 1211
 
1212 1212
 	public static function switch_field_ids( $val ) {
1213
-        global $frm_duplicate_ids;
1214
-        $replace = array();
1215
-        $replace_with = array();
1216
-        foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1213
+		global $frm_duplicate_ids;
1214
+		$replace = array();
1215
+		$replace_with = array();
1216
+		foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1217 1217
 			$replace[] = '[if ' . $old . ']';
1218 1218
 			$replace_with[] = '[if ' . $new . ']';
1219 1219
 			$replace[] = '[if ' . $old . ' ';
@@ -1228,153 +1228,153 @@  discard block
 block discarded – undo
1228 1228
 			$replace_with[] = '[' . $new . ']';
1229 1229
 			$replace[] = '[' . $old . ' ';
1230 1230
 			$replace_with[] = '[' . $new . ' ';
1231
-            unset($old, $new);
1232
-        }
1231
+			unset($old, $new);
1232
+		}
1233 1233
 		if ( is_array( $val ) ) {
1234 1234
 			foreach ( $val as $k => $v ) {
1235
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1236
-                unset($k, $v);
1237
-            }
1238
-        } else {
1239
-            $val = str_replace($replace, $replace_with, $val);
1240
-        }
1241
-
1242
-        return $val;
1243
-    }
1244
-
1245
-    public static function get_us_states() {
1246
-        return apply_filters( 'frm_us_states', array(
1247
-            'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1248
-            'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1249
-            'DC' => 'District of Columbia',
1250
-            'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1251
-            'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1252
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1253
-            'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1254
-            'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1255
-            'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1256
-            'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1257
-            'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1258
-            'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1259
-            'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1260
-            'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1261
-        ) );
1262
-    }
1263
-
1264
-    public static function get_countries() {
1265
-        return apply_filters( 'frm_countries', array(
1266
-            __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1267
-            __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1268
-            __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1269
-            __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1270
-            __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1271
-            __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1272
-            __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1273
-            __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1274
-            __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1275
-            __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1276
-            __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1277
-            __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1278
-            __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1279
-            __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1280
-            __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1281
-            __( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1282
-            __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1283
-            __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1284
-            __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1285
-            __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1286
-            __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1287
-            __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1288
-            __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1289
-            __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1290
-            __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1291
-            __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1292
-            __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1293
-            __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1294
-            __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1295
-            __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1296
-            __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1297
-            __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1298
-            __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1299
-            __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1300
-            __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1301
-            __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1302
-            __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1303
-            __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1304
-            __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1305
-            __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1306
-            __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1307
-            __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1308
-            __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1309
-            __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1310
-            __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1311
-            __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1312
-            __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1313
-            __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1314
-            __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1315
-            __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1316
-            __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1317
-            __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1318
-            __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1319
-            __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1320
-            __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1321
-            __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1322
-            __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1323
-            __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1324
-            __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1325
-            __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1326
-            __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1327
-            __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1328
-            __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1329
-            __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1330
-            __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1331
-            __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1332
-            __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1333
-            __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1334
-            __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1335
-            __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1336
-            __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1337
-            __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1338
-            __( 'Zimbabwe', 'formidable' ),
1339
-        ) );
1340
-    }
1235
+				$val[ $k ] = str_replace( $replace, $replace_with, $v );
1236
+				unset($k, $v);
1237
+			}
1238
+		} else {
1239
+			$val = str_replace($replace, $replace_with, $val);
1240
+		}
1241
+
1242
+		return $val;
1243
+	}
1244
+
1245
+	public static function get_us_states() {
1246
+		return apply_filters( 'frm_us_states', array(
1247
+			'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1248
+			'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1249
+			'DC' => 'District of Columbia',
1250
+			'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1251
+			'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1252
+			'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1253
+			'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1254
+			'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1255
+			'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1256
+			'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1257
+			'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1258
+			'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1259
+			'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1260
+			'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1261
+		) );
1262
+	}
1263
+
1264
+	public static function get_countries() {
1265
+		return apply_filters( 'frm_countries', array(
1266
+			__( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1267
+			__( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1268
+			__( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1269
+			__( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1270
+			__( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1271
+			__( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1272
+			__( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1273
+			__( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1274
+			__( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1275
+			__( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1276
+			__( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1277
+			__( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1278
+			__( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1279
+			__( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1280
+			__( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1281
+			__( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1282
+			__( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1283
+			__( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1284
+			__( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1285
+			__( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1286
+			__( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1287
+			__( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1288
+			__( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1289
+			__( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1290
+			__( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1291
+			__( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1292
+			__( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1293
+			__( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1294
+			__( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1295
+			__( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1296
+			__( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1297
+			__( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1298
+			__( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1299
+			__( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1300
+			__( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1301
+			__( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1302
+			__( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1303
+			__( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1304
+			__( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1305
+			__( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1306
+			__( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1307
+			__( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1308
+			__( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1309
+			__( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1310
+			__( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1311
+			__( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1312
+			__( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1313
+			__( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1314
+			__( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1315
+			__( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1316
+			__( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1317
+			__( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1318
+			__( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1319
+			__( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1320
+			__( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1321
+			__( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1322
+			__( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1323
+			__( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1324
+			__( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1325
+			__( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1326
+			__( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1327
+			__( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1328
+			__( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1329
+			__( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1330
+			__( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1331
+			__( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1332
+			__( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1333
+			__( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1334
+			__( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1335
+			__( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1336
+			__( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1337
+			__( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1338
+			__( 'Zimbabwe', 'formidable' ),
1339
+		) );
1340
+	}
1341 1341
 
1342 1342
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1343 1343
 		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1344 1344
 
1345
-        $states = FrmFieldsHelper::get_us_states();
1346
-        $state_abv = array_keys($states);
1347
-        sort($state_abv);
1345
+		$states = FrmFieldsHelper::get_us_states();
1346
+		$state_abv = array_keys($states);
1347
+		sort($state_abv);
1348 1348
 		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1349 1349
 
1350
-        $states = array_values($states);
1351
-        sort($states);
1350
+		$states = array_values($states);
1351
+		sort($states);
1352 1352
 		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1353
-        unset($state_abv, $states);
1353
+		unset($state_abv, $states);
1354 1354
 
1355 1355
 		$prepop[ __( 'Age', 'formidable' ) ] = array(
1356
-            __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1357
-            __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1358
-            __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1359
-        );
1356
+			__( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1357
+			__( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1358
+			__( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1359
+		);
1360 1360
 
1361 1361
 		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1362
-            __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1363
-            __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1364
-        );
1362
+			__( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1363
+			__( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1364
+		);
1365 1365
 
1366 1366
 		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1367
-            __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1368
-            __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1369
-        );
1367
+			__( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1368
+			__( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1369
+		);
1370 1370
 
1371 1371
 		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1372
-            __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1373
-            __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1374
-        );
1372
+			__( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1373
+			__( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1374
+		);
1375 1375
 
1376 1376
 		$prepop = apply_filters( 'frm_bulk_field_choices', $prepop );
1377
-    }
1377
+	}
1378 1378
 
1379 1379
 	public static function field_selection() {
1380 1380
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::field_selection' );
@@ -1411,8 +1411,8 @@  discard block
 block discarded – undo
1411 1411
 		return FrmField::is_required( $field );
1412 1412
 	}
1413 1413
 
1414
-    public static function maybe_get_field( &$field ) {
1414
+	public static function maybe_get_field( &$field ) {
1415 1415
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' );
1416 1416
 		FrmField::maybe_get_field( $field );
1417
-    }
1417
+	}
1418 1418
 }
Please login to merge, or discard this patch.
Spacing   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
 
8 8
 	public static function setup_new_vars( $type = '', $form_id = '' ) {
9 9
 
10
-        if ( strpos($type, '|') ) {
11
-            list($type, $setting) = explode('|', $type);
10
+        if ( strpos( $type, '|' ) ) {
11
+            list( $type, $setting ) = explode( '|', $type );
12 12
         }
13 13
 
14
-        $defaults = self::get_default_field_opts($type, $form_id);
15
-        $defaults['field_options']['custom_html'] = self::get_default_html($type);
14
+        $defaults = self::get_default_field_opts( $type, $form_id );
15
+        $defaults['field_options']['custom_html'] = self::get_default_html( $type );
16 16
 
17 17
         $values = array();
18 18
 
@@ -20,20 +20,20 @@  discard block
 block discarded – undo
20 20
             if ( $var == 'field_options' ) {
21 21
                 $values['field_options'] = array();
22 22
                 foreach ( $default as $opt_var => $opt_default ) {
23
-                    $values['field_options'][ $opt_var ] = $opt_default;
24
-                    unset($opt_var, $opt_default);
23
+                    $values['field_options'][$opt_var] = $opt_default;
24
+                    unset( $opt_var, $opt_default );
25 25
                 }
26 26
             } else {
27
-                $values[ $var ] = $default;
27
+                $values[$var] = $default;
28 28
             }
29
-            unset($var, $default);
29
+            unset( $var, $default );
30 30
         }
31 31
 
32 32
         if ( isset( $setting ) && ! empty( $setting ) ) {
33 33
             if ( 'data' == $type ) {
34 34
                 $values['field_options']['data_type'] = $setting;
35 35
             } else {
36
-                $values['field_options'][ $setting ] = 1;
36
+                $values['field_options'][$setting] = 1;
37 37
             }
38 38
         }
39 39
 
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
         }
57 57
 
58 58
 		$fields = FrmField::field_selection();
59
-        $fields = array_merge($fields, FrmField::pro_field_selection());
59
+        $fields = array_merge( $fields, FrmField::pro_field_selection() );
60 60
 
61
-        if ( isset( $fields[ $type ] ) ) {
62
-            $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
61
+        if ( isset( $fields[$type] ) ) {
62
+            $values['name'] = is_array( $fields[$type] ) ? $fields[$type]['name'] : $fields[$type];
63 63
         }
64 64
 
65
-        unset($fields);
65
+        unset( $fields );
66 66
 
67 67
         return $values;
68 68
     }
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
             $values['form_name'] = '';
89 89
 		} else {
90 90
 			foreach ( $defaults as $var => $default ) {
91
-                $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
-                unset($var, $default);
91
+                $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
+                unset( $var, $default );
93 93
             }
94 94
 
95 95
 			$values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : '';
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         $values['options'] = $record->options;
101 101
         $values['field_options'] = $record->field_options;
102 102
 
103
-        $defaults = self::get_default_field_opts($values['type'], $record, true);
103
+        $defaults = self::get_default_field_opts( $values['type'], $record, true );
104 104
 
105 105
 		if ( $values['type'] == 'captcha' ) {
106 106
             $frm_settings = FrmAppHelper::get_settings();
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
         }
109 109
 
110 110
 		foreach ( $defaults as $opt => $default ) {
111
-            $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
112
-            unset($opt, $default);
111
+            $values[$opt] = isset( $record->field_options[$opt] ) ? $record->field_options[$opt] : $default;
112
+            unset( $opt, $default );
113 113
         }
114 114
 
115
-        $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
115
+        $values['custom_html'] = ( isset( $record->field_options['custom_html'] ) ) ? $record->field_options['custom_html'] : self::get_default_html( $record->type );
116 116
 
117 117
 		return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) );
118 118
     }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 
132 132
         global $wpdb;
133 133
 
134
-        $form_id = (is_numeric($field)) ? $field : $field->form_id;
134
+        $form_id = ( is_numeric( $field ) ) ? $field : $field->form_id;
135 135
 
136 136
 		$key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key;
137 137
 
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
 
154 154
 		$values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
155 155
         $values['form_id'] = $form_id;
156
-        $values['options'] = maybe_serialize($field->options);
157
-        $values['default_value'] = maybe_serialize($field->default_value);
156
+        $values['options'] = maybe_serialize( $field->options );
157
+        $values['default_value'] = maybe_serialize( $field->default_value );
158 158
 
159 159
         foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
160
-            $values[ $col ] = $field->{$col};
160
+            $values[$col] = $field->{$col};
161 161
         }
162 162
     }
163 163
 
@@ -170,20 +170,20 @@  discard block
 block discarded – undo
170 170
 		$field_name = is_array( $field ) ? $field['name'] : $field->name;
171 171
 
172 172
 		$defaults = array(
173
-			'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __('%s must be unique', 'formidable' ), $field_name ) ),
174
-			'invalid'   => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __('%s is invalid', 'formidable' ), $field_name ) ),
173
+			'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __( '%s must be unique', 'formidable' ), $field_name ) ),
174
+			'invalid'   => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __( '%s is invalid', 'formidable' ), $field_name ) ),
175 175
 			'blank'     => array( 'full' => $frm_settings->blank_msg, 'part' => $frm_settings->blank_msg ),
176 176
 		);
177 177
 
178 178
 		$msg = FrmField::get_option( $field, $error );
179
-		$msg = ( $msg == $defaults[ $error ]['full'] || empty( $msg ) ) ? $defaults[ $error ]['part'] : $msg;
179
+		$msg = ( $msg == $defaults[$error]['full'] || empty( $msg ) ) ? $defaults[$error]['part'] : $msg;
180 180
 		$msg = do_shortcode( $msg );
181 181
 		return $msg;
182 182
 	}
183 183
 
184 184
     public static function get_form_fields( $form_id, $error = false ) {
185
-        $fields = FrmField::get_all_for_form($form_id);
186
-        $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error);
185
+        $fields = FrmField::get_all_for_form( $form_id );
186
+        $fields = apply_filters( 'frm_get_paged_fields', $fields, $form_id, $error );
187 187
         return $fields;
188 188
     }
189 189
 
@@ -206,14 +206,14 @@  discard block
 block discarded – undo
206 206
 </div>
207 207
 DEFAULT_HTML;
208 208
         } else {
209
-			$default_html = apply_filters('frm_other_custom_html', '', $type);
209
+			$default_html = apply_filters( 'frm_other_custom_html', '', $type );
210 210
         }
211 211
 
212
-        return apply_filters('frm_custom_html', $default_html, $type);
212
+        return apply_filters( 'frm_custom_html', $default_html, $type );
213 213
     }
214 214
 
215 215
 	public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) {
216
-        $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
216
+        $html = apply_filters( 'frm_before_replace_shortcodes', $html, $field, $errors, $form );
217 217
 
218 218
         $defaults = array(
219 219
 			'field_name'    => 'item_meta[' . $field['id'] . ']',
@@ -221,42 +221,42 @@  discard block
 block discarded – undo
221 221
             'field_plus_id' => '',
222 222
             'section_id'    => '',
223 223
         );
224
-        $args = wp_parse_args($args, $defaults);
224
+        $args = wp_parse_args( $args, $defaults );
225 225
         $field_name = $args['field_name'];
226 226
         $field_id = $args['field_id'];
227
-        $html_id = self::get_html_id($field, $args['field_plus_id']);
227
+        $html_id = self::get_html_id( $field, $args['field_plus_id'] );
228 228
 
229
-        if ( FrmField::is_multiple_select($field) ) {
229
+        if ( FrmField::is_multiple_select( $field ) ) {
230 230
             $field_name .= '[]';
231 231
         }
232 232
 
233 233
         //replace [id]
234
-        $html = str_replace('[id]', $field_id, $html);
234
+        $html = str_replace( '[id]', $field_id, $html );
235 235
 
236 236
         // Remove the for attribute for captcha
237 237
         if ( $field['type'] == 'captcha' ) {
238
-            $html = str_replace(' for="field_[key]"', '', $html);
238
+            $html = str_replace( ' for="field_[key]"', '', $html );
239 239
         }
240 240
 
241 241
         // set the label for
242
-        $html = str_replace('field_[key]', $html_id, $html);
242
+        $html = str_replace( 'field_[key]', $html_id, $html );
243 243
 
244 244
         //replace [key]
245
-        $html = str_replace('[key]', $field['field_key'], $html);
245
+        $html = str_replace( '[key]', $field['field_key'], $html );
246 246
 
247 247
         //replace [description] and [required_label] and [error]
248 248
 		$required = FrmField::is_required( $field ) ? $field['required_indicator'] : '';
249 249
         if ( ! is_array( $errors ) ) {
250 250
             $errors = array();
251 251
         }
252
-		$error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false;
252
+		$error = isset( $errors['field' . $field_id] ) ? $errors['field' . $field_id] : false;
253 253
 
254 254
         //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
255 255
         if ( $field['type'] == 'divider' ) {
256 256
             if ( FrmField::is_option_true( $field, 'description' ) ) {
257 257
                 $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
258 258
             } else {
259
-                $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
259
+                $html = str_replace( '[label_position]', '[label_position] frm_section_spacing', $html );
260 260
             }
261 261
         }
262 262
 
@@ -266,48 +266,48 @@  discard block
 block discarded – undo
266 266
 
267 267
         //replace [required_class]
268 268
 		$required_class = FrmField::is_required( $field ) ? ' frm_required_field' : '';
269
-        $html = str_replace('[required_class]', $required_class, $html);
269
+        $html = str_replace( '[required_class]', $required_class, $html );
270 270
 
271 271
         //replace [label_position]
272
-        $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
272
+        $field['label'] = apply_filters( 'frm_html_label_position', $field['label'], $field, $form );
273 273
         $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
274 274
 		$html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html );
275 275
 
276 276
         //replace [field_name]
277
-        $html = str_replace('[field_name]', $field['name'], $html);
277
+        $html = str_replace( '[field_name]', $field['name'], $html );
278 278
 
279 279
         //replace [error_class]
280
-		$error_class = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : '';
280
+		$error_class = isset( $errors['field' . $field_id] ) ? ' frm_blank_field' : '';
281 281
 		self::get_more_field_classes( $error_class, $field, $field_id, $html );
282 282
 		if ( $field['type'] == 'html' && strpos( $html, '[error_class]' ) === false ) {
283 283
 			// there is no error_class shortcode to use for addign fields
284 284
 			$html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . $error_class, $html );
285 285
 		}
286
-        $html = str_replace('[error_class]', $error_class, $html);
286
+        $html = str_replace( '[error_class]', $error_class, $html );
287 287
 
288 288
         //replace [entry_key]
289 289
         $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
290
-        $html = str_replace('[entry_key]', $entry_key, $html);
290
+        $html = str_replace( '[entry_key]', $entry_key, $html );
291 291
 
292 292
         //replace [input]
293
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
293
+        preg_match_all( "/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER );
294 294
         global $frm_vars;
295 295
         $frm_settings = FrmAppHelper::get_settings();
296 296
 
297 297
         foreach ( $shortcodes[0] as $short_key => $tag ) {
298
-            $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
298
+            $atts = shortcode_parse_atts( $shortcodes[2][$short_key] );
299 299
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
300 300
 
301 301
             $replace_with = '';
302 302
 
303 303
             if ( $tag == 'input' ) {
304
-                if ( isset($atts['opt']) ) {
305
-                    $atts['opt']--;
304
+                if ( isset( $atts['opt'] ) ) {
305
+                    $atts['opt'] --;
306 306
                 }
307 307
 
308
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
309
-                if ( isset($atts['class']) ) {
310
-                    unset($atts['class']);
308
+                $field['input_class'] = isset( $atts['class'] ) ? $atts['class'] : '';
309
+                if ( isset( $atts['class'] ) ) {
310
+                    unset( $atts['class'] );
311 311
                 }
312 312
 
313 313
                 $field['shortcodes'] = $atts;
@@ -316,33 +316,33 @@  discard block
 block discarded – undo
316 316
                 $replace_with = ob_get_contents();
317 317
                 ob_end_clean();
318 318
             } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
319
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
319
+                $replace_with = FrmProEntriesController::entry_delete_link( $atts );
320 320
             }
321 321
 
322
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
322
+            $html = str_replace( $shortcodes[0][$short_key], $replace_with, $html );
323 323
         }
324 324
 
325 325
 		if ( $form ) {
326 326
             $form = (array) $form;
327 327
 
328 328
             //replace [form_key]
329
-            $html = str_replace('[form_key]', $form['form_key'], $html);
329
+            $html = str_replace( '[form_key]', $form['form_key'], $html );
330 330
 
331 331
             //replace [form_name]
332
-            $html = str_replace('[form_name]', $form['name'], $html);
332
+            $html = str_replace( '[form_name]', $form['name'], $html );
333 333
         }
334 334
         $html .= "\n";
335 335
 
336 336
         //Return html if conf_field to prevent loop
337
-        if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
337
+        if ( isset( $field['conf_field'] ) && $field['conf_field'] == 'stop' ) {
338 338
             return $html;
339 339
         }
340 340
 
341 341
         //If field is in repeating section
342 342
         if ( $args['section_id'] ) {
343
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ));
343
+            $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ) );
344 344
         } else {
345
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
345
+            $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ) );
346 346
         }
347 347
 
348 348
 		self::remove_collapse_shortcode( $html );
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 
420 420
 		//insert custom CSS classes
421 421
 		if ( ! empty( $field['classes'] ) ) {
422
-			if ( ! strpos( $html, 'frm_form_field ') ) {
422
+			if ( ! strpos( $html, 'frm_form_field ' ) ) {
423 423
 				$error_class .= ' frm_form_field';
424 424
 			}
425 425
 			$error_class .= ' ' . $field['classes'];
@@ -453,15 +453,15 @@  discard block
 block discarded – undo
453 453
         }
454 454
 
455 455
         $with_tags = $args['conditional_check'] ? 3 : 2;
456
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
457
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
458
-            $tag = str_replace(']', '', $tag);
459
-            $tags = explode(' ', $tag);
460
-            if ( is_array($tags) ) {
456
+        if ( ! empty( $shortcodes[$with_tags][$short_key] ) ) {
457
+            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][$short_key] );
458
+            $tag = str_replace( ']', '', $tag );
459
+            $tags = explode( ' ', $tag );
460
+            if ( is_array( $tags ) ) {
461 461
                 $tag = $tags[0];
462 462
             }
463 463
         } else {
464
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
464
+            $tag = $shortcodes[$with_tags - 1][$short_key];
465 465
         }
466 466
 
467 467
         return $tag;
@@ -505,10 +505,10 @@  discard block
 block discarded – undo
505 505
 
506 506
 	public static function show_single_option( $field ) {
507 507
         $field_name = $field['name'];
508
-        $html_id = self::get_html_id($field);
508
+        $html_id = self::get_html_id( $field );
509 509
         foreach ( $field['options'] as $opt_key => $opt ) {
510
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
511
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
510
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
511
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
512 512
 
513 513
             // If this is an "Other" option, get the HTML for it
514 514
 			if ( self::is_other_opt( $opt_key ) ) {
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 
524 524
 	public static function dropdown_categories( $args ) {
525 525
 		$defaults = array( 'field' => false, 'name' => false, 'show_option_all' => ' ' );
526
-        $args = wp_parse_args($args, $defaults);
526
+        $args = wp_parse_args( $args, $defaults );
527 527
 
528 528
         if ( ! $args['field'] ) {
529 529
             return;
@@ -533,17 +533,17 @@  discard block
 block discarded – undo
533 533
 			$args['name'] = 'item_meta[' . $args['field']['id'] . ']';
534 534
         }
535 535
 
536
-        $id = self::get_html_id($args['field']);
536
+        $id = self::get_html_id( $args['field'] );
537 537
         $class = $args['field']['type'];
538 538
 
539
-        $exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat'];
540
-        $exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']);
539
+        $exclude = ( is_array( $args['field']['exclude_cat'] ) ) ? implode( ',', $args['field']['exclude_cat'] ) : $args['field']['exclude_cat'];
540
+        $exclude = apply_filters( 'frm_exclude_cats', $exclude, $args['field'] );
541 541
 
542
-        if ( is_array($args['field']['value']) ) {
543
-            if ( ! empty($exclude) ) {
544
-                $args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude));
542
+        if ( is_array( $args['field']['value'] ) ) {
543
+            if ( ! empty( $exclude ) ) {
544
+                $args['field']['value'] = array_diff( $args['field']['value'], explode( ',', $exclude ) );
545 545
             }
546
-            $selected = reset($args['field']['value']);
546
+            $selected = reset( $args['field']['value'] );
547 547
         } else {
548 548
             $selected = $args['field']['value'];
549 549
         }
@@ -554,40 +554,40 @@  discard block
 block discarded – undo
554 554
             'hide_empty' => false, 'echo' => 0, 'orderby' => 'name',
555 555
         );
556 556
 
557
-        $tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']);
557
+        $tax_atts = apply_filters( 'frm_dropdown_cat', $tax_atts, $args['field'] );
558 558
 
559 559
         if ( FrmAppHelper::pro_is_installed() ) {
560
-            $post_type = FrmProFormsHelper::post_type($args['field']['form_id']);
561
-            $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']);
560
+            $post_type = FrmProFormsHelper::post_type( $args['field']['form_id'] );
561
+            $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy( $post_type, $args['field'] );
562 562
             if ( ! $tax_atts['taxonomy'] ) {
563 563
                 return;
564 564
             }
565 565
 
566 566
             // If field type is dropdown (not Dynamic), exclude children when parent is excluded
567
-            if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) {
567
+            if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical( $tax_atts['taxonomy'] ) ) {
568 568
                 $tax_atts['exclude_tree'] = $exclude;
569 569
             }
570 570
         }
571 571
 
572
-        $dropdown = wp_dropdown_categories($tax_atts);
572
+        $dropdown = wp_dropdown_categories( $tax_atts );
573 573
 
574
-        $add_html = FrmFieldsController::input_html($args['field'], false);
574
+        $add_html = FrmFieldsController::input_html( $args['field'], false );
575 575
 
576 576
         if ( FrmAppHelper::pro_is_installed() ) {
577
-            $add_html .= FrmProFieldsController::input_html($args['field'], false);
577
+            $add_html .= FrmProFieldsController::input_html( $args['field'], false );
578 578
         }
579 579
 
580 580
 		$dropdown = str_replace( "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' class='" . esc_attr( $class ) . "'", "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' " . $add_html, $dropdown );
581 581
 
582
-        if ( is_array($args['field']['value']) ) {
582
+        if ( is_array( $args['field']['value'] ) ) {
583 583
             $skip = true;
584 584
             foreach ( $args['field']['value'] as $v ) {
585 585
 				if ( $skip ) {
586 586
                     $skip = false;
587 587
                     continue;
588 588
                 }
589
-				$dropdown = str_replace(' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown );
590
-                unset($v);
589
+				$dropdown = str_replace( ' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown );
590
+                unset( $v );
591 591
             }
592 592
         }
593 593
 
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
     }
596 596
 
597 597
 	public static function get_term_link( $tax_id ) {
598
-        $tax = get_taxonomy($tax_id);
598
+        $tax = get_taxonomy( $tax_id );
599 599
         if ( ! $tax ) {
600 600
             return;
601 601
         }
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
             __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
605 605
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
606 606
         );
607
-        unset($tax);
607
+        unset( $tax );
608 608
 
609 609
         return $link;
610 610
     }
@@ -615,8 +615,8 @@  discard block
 block discarded – undo
615 615
 			$hide_opt = rtrim( $hide_opt );
616 616
 		}
617 617
 
618
-        if ( is_array($observed_value) ) {
619
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
618
+        if ( is_array( $observed_value ) ) {
619
+            return self::array_value_condition( $observed_value, $cond, $hide_opt );
620 620
         }
621 621
 
622 622
         $m = false;
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
         } else if ( $cond == '<' ) {
630 630
             $m = $observed_value < $hide_opt;
631 631
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
632
-            $m = stripos($observed_value, $hide_opt);
632
+            $m = stripos( $observed_value, $hide_opt );
633 633
             if ( $cond == 'not LIKE' ) {
634 634
                 $m = ( $m === false ) ? true : false;
635 635
             } else {
@@ -642,23 +642,23 @@  discard block
 block discarded – undo
642 642
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
643 643
         $m = false;
644 644
         if ( $cond == '==' ) {
645
-            if ( is_array($hide_opt) ) {
646
-                $m = array_intersect($hide_opt, $observed_value);
647
-                $m = empty($m) ? false : true;
645
+            if ( is_array( $hide_opt ) ) {
646
+                $m = array_intersect( $hide_opt, $observed_value );
647
+                $m = empty( $m ) ? false : true;
648 648
             } else {
649
-                $m = in_array($hide_opt, $observed_value);
649
+                $m = in_array( $hide_opt, $observed_value );
650 650
             }
651 651
         } else if ( $cond == '!=' ) {
652
-            $m = ! in_array($hide_opt, $observed_value);
652
+            $m = ! in_array( $hide_opt, $observed_value );
653 653
         } else if ( $cond == '>' ) {
654
-            $min = min($observed_value);
654
+            $min = min( $observed_value );
655 655
             $m = $min > $hide_opt;
656 656
         } else if ( $cond == '<' ) {
657
-            $max = max($observed_value);
657
+            $max = max( $observed_value );
658 658
             $m = $max < $hide_opt;
659 659
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
660 660
             foreach ( $observed_value as $ob ) {
661
-                $m = strpos($ob, $hide_opt);
661
+                $m = strpos( $ob, $hide_opt );
662 662
                 if ( $m !== false ) {
663 663
                     $m = true;
664 664
                     break;
@@ -679,27 +679,27 @@  discard block
 block discarded – undo
679 679
      * @return string
680 680
      */
681 681
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
682
-        if ( strpos($value, '[sitename]') !== false ) {
682
+        if ( strpos( $value, '[sitename]' ) !== false ) {
683 683
             $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
684
-            $value = str_replace('[sitename]', $new_value, $value);
684
+            $value = str_replace( '[sitename]', $new_value, $value );
685 685
         }
686 686
 
687
-        $value = apply_filters('frm_content', $value, $form, $entry);
688
-        $value = do_shortcode($value);
687
+        $value = apply_filters( 'frm_content', $value, $form, $entry );
688
+        $value = do_shortcode( $value );
689 689
 
690 690
         return $value;
691 691
     }
692 692
 
693 693
 	public static function get_shortcodes( $content, $form_id ) {
694 694
         if ( FrmAppHelper::pro_is_installed() ) {
695
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
695
+            return FrmProDisplaysHelper::get_shortcodes( $content, $form_id );
696 696
         }
697 697
 
698 698
         $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
699 699
 
700
-        $tagregexp = self::allowed_shortcodes($fields);
700
+        $tagregexp = self::allowed_shortcodes( $fields );
701 701
 
702
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
702
+        preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER );
703 703
 
704 704
         return $matches;
705 705
     }
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
             $tagregexp[] = $field->field_key;
718 718
         }
719 719
 
720
-        $tagregexp = implode('|', $tagregexp);
720
+        $tagregexp = implode( '|', $tagregexp );
721 721
         return $tagregexp;
722 722
     }
723 723
 
@@ -729,28 +729,28 @@  discard block
 block discarded – undo
729 729
         );
730 730
 
731 731
         foreach ( $shortcodes[0] as $short_key => $tag ) {
732
-            $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
732
+            $atts = shortcode_parse_atts( $shortcodes[3][$short_key] );
733 733
 
734
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
735
-				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
736
-                $tags = explode(' ', $tag);
737
-                if ( is_array($tags) ) {
734
+            if ( ! empty( $shortcodes[3][$short_key] ) ) {
735
+				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][$short_key] );
736
+                $tags = explode( ' ', $tag );
737
+                if ( is_array( $tags ) ) {
738 738
                     $tag = $tags[0];
739 739
                 }
740 740
             } else {
741
-                $tag = $shortcodes[2][ $short_key ];
741
+                $tag = $shortcodes[2][$short_key];
742 742
             }
743 743
 
744 744
             switch ( $tag ) {
745 745
                 case 'id':
746 746
                 case 'key':
747 747
                 case 'ip':
748
-                    $replace_with = $shortcode_values[ $tag ];
748
+                    $replace_with = $shortcode_values[$tag];
749 749
                 break;
750 750
 
751 751
                 case 'user_agent':
752 752
                 case 'user-agent':
753
-                    $entry->description = maybe_unserialize($entry->description);
753
+                    $entry->description = maybe_unserialize( $entry->description );
754 754
 					$replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] );
755 755
                 break;
756 756
 
@@ -758,25 +758,25 @@  discard block
 block discarded – undo
758 758
                 case 'created-at':
759 759
                 case 'updated_at':
760 760
                 case 'updated-at':
761
-                    if ( isset($atts['format']) ) {
761
+                    if ( isset( $atts['format'] ) ) {
762 762
                         $time_format = ' ';
763 763
                     } else {
764
-                        $atts['format'] = get_option('date_format');
764
+                        $atts['format'] = get_option( 'date_format' );
765 765
                         $time_format = '';
766 766
                     }
767 767
 
768
-                    $this_tag = str_replace('-', '_', $tag);
769
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
770
-                    unset($this_tag);
768
+                    $this_tag = str_replace( '-', '_', $tag );
769
+                    $replace_with = FrmAppHelper::get_formatted_time( $entry->{$this_tag}, $atts['format'], $time_format );
770
+                    unset( $this_tag );
771 771
                 break;
772 772
 
773 773
                 case 'created_by':
774 774
                 case 'created-by':
775 775
                 case 'updated_by':
776 776
                 case 'updated-by':
777
-                    $this_tag = str_replace('-', '_', $tag);
777
+                    $this_tag = str_replace( '-', '_', $tag );
778 778
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
779
-                    unset($this_tag);
779
+                    unset( $this_tag );
780 780
                 break;
781 781
 
782 782
                 case 'admin_email':
@@ -793,16 +793,16 @@  discard block
 block discarded – undo
793 793
                         break;
794 794
                     }
795 795
 
796
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
796
+                    $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
797 797
 
798 798
                     $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
799 799
 
800 800
                     $atts['entry_id'] = $entry->id;
801 801
                     $atts['entry_key'] = $entry->item_key;
802 802
 
803
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
803
+                    if ( isset( $atts['show'] ) && $atts['show'] == 'field_label' ) {
804 804
                         $replace_with = $field->name;
805
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
805
+                    } else if ( isset( $atts['show'] ) && $atts['show'] == 'description' ) {
806 806
                         $replace_with = $field->description;
807 807
 					} else {
808 808
 						$string_value = $replace_with;
@@ -817,15 +817,15 @@  discard block
 block discarded – undo
817 817
 						}
818 818
 					}
819 819
 
820
-                    unset($field);
820
+                    unset( $field );
821 821
                 break;
822 822
             }
823 823
 
824
-            if ( isset($replace_with) ) {
825
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
824
+            if ( isset( $replace_with ) ) {
825
+                $content = str_replace( $shortcodes[0][$short_key], $replace_with, $content );
826 826
             }
827 827
 
828
-            unset($atts, $conditional, $replace_with);
828
+            unset( $atts, $conditional, $replace_with );
829 829
 		}
830 830
 
831 831
 		return $content;
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
         $new_value = '';
842 842
         switch ( $tag ) {
843 843
             case 'admin_email':
844
-                $new_value = get_option('admin_email');
844
+                $new_value = get_option( 'admin_email' );
845 845
                 break;
846 846
             case 'siteurl':
847 847
                 $new_value = FrmAppHelper::site_url();
@@ -867,28 +867,28 @@  discard block
 block discarded – undo
867 867
      * @return string|array
868 868
      */
869 869
     public static function process_get_shortcode( $atts, $return_array = false ) {
870
-        if ( ! isset($atts['param']) ) {
870
+        if ( ! isset( $atts['param'] ) ) {
871 871
             return '';
872 872
         }
873 873
 
874
-        if ( strpos($atts['param'], '&#91;') ) {
875
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
876
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
874
+        if ( strpos( $atts['param'], '&#91;' ) ) {
875
+            $atts['param'] = str_replace( '&#91;', '[', $atts['param'] );
876
+            $atts['param'] = str_replace( '&#93;', ']', $atts['param'] );
877 877
         }
878 878
 
879
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
879
+        $new_value = FrmAppHelper::get_param( $atts['param'], '' );
880 880
         $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
881 881
 
882 882
         if ( $new_value == '' ) {
883
-            if ( ! isset($atts['prev_val']) ) {
883
+            if ( ! isset( $atts['prev_val'] ) ) {
884 884
                 $atts['prev_val'] = '';
885 885
             }
886 886
 
887
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
887
+            $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val'];
888 888
         }
889 889
 
890
-        if ( is_array($new_value) && ! $return_array ) {
891
-            $new_value = implode(', ', $new_value);
890
+        if ( is_array( $new_value ) && ! $return_array ) {
891
+            $new_value = implode( ', ', $new_value );
892 892
         }
893 893
 
894 894
         return $new_value;
@@ -901,12 +901,12 @@  discard block
 block discarded – undo
901 901
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
902 902
 
903 903
         if ( $field->type == 'textarea' || $field->type == 'rte' ) {
904
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
905
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
906
-                if ( is_array($replace_with) ) {
907
-                    $replace_with = implode("\n", $replace_with);
904
+            $autop = isset( $atts['wpautop'] ) ? $atts['wpautop'] : true;
905
+            if ( apply_filters( 'frm_use_wpautop', $autop ) ) {
906
+                if ( is_array( $replace_with ) ) {
907
+                    $replace_with = implode( "\n", $replace_with );
908 908
                 }
909
-                $replace_with = wpautop($replace_with);
909
+                $replace_with = wpautop( $replace_with );
910 910
             }
911 911
 			unset( $autop );
912 912
 		} else if ( is_array( $replace_with ) ) {
@@ -928,14 +928,14 @@  discard block
 block discarded – undo
928 928
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
929 929
 
930 930
         $field_types = array();
931
-        if ( in_array($type, $single_input) ) {
931
+        if ( in_array( $type, $single_input ) ) {
932 932
             self::field_types_for_input( $single_input, $field_selection, $field_types );
933
-        } else if ( in_array($type, $multiple_input) ) {
933
+        } else if ( in_array( $type, $multiple_input ) ) {
934 934
             self::field_types_for_input( $multiple_input, $field_selection, $field_types );
935
-        } else if ( in_array($type, $other_type) ) {
935
+        } else if ( in_array( $type, $other_type ) ) {
936 936
             self::field_types_for_input( $other_type, $field_selection, $field_types );
937
-		} else if ( isset( $field_selection[ $type ] ) ) {
938
-            $field_types[ $type ] = $field_selection[ $type ];
937
+		} else if ( isset( $field_selection[$type] ) ) {
938
+            $field_types[$type] = $field_selection[$type];
939 939
         }
940 940
 
941 941
         return $field_types;
@@ -943,8 +943,8 @@  discard block
 block discarded – undo
943 943
 
944 944
     private static function field_types_for_input( $inputs, $fields, &$field_types ) {
945 945
         foreach ( $inputs as $input ) {
946
-            $field_types[ $input ] = $fields[ $input ];
947
-            unset($input);
946
+            $field_types[$input] = $fields[$input];
947
+            unset( $input );
948 948
         }
949 949
     }
950 950
 
@@ -989,21 +989,21 @@  discard block
 block discarded – undo
989 989
 		// Check posted vals before checking saved values
990 990
 
991 991
 		// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
992
-		if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) {
992
+		if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) {
993 993
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
994
-				$other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) : '';
994
+				$other_val = isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) : '';
995 995
 			} else {
996
-				$other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] );
996
+				$other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] );
997 997
 			}
998 998
 			return $other_val;
999 999
 
1000
-		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) {
1000
+		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) {
1001 1001
 			// For normal fields
1002 1002
 
1003 1003
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
1004
-				$other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : '';
1004
+				$other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : '';
1005 1005
 			} else {
1006
-				$other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] );
1006
+				$other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] );
1007 1007
 			}
1008 1008
 			return $other_val;
1009 1009
 		}
@@ -1012,8 +1012,8 @@  discard block
 block discarded – undo
1012 1012
 		if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) {
1013 1013
 			// Check if there is an "other" val in saved value and make sure the
1014 1014
 			// "other" val is not equal to the Other checkbox option
1015
-			if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
1016
-				$other_val = $field['value'][ $opt_key ];
1015
+			if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) {
1016
+				$other_val = $field['value'][$opt_key];
1017 1017
 			}
1018 1018
 		} else {
1019 1019
 			/**
@@ -1025,8 +1025,8 @@  discard block
 block discarded – undo
1025 1025
 				// Multi-select dropdowns - key is not preserved
1026 1026
 				if ( is_array( $field['value'] ) ) {
1027 1027
 					$o_key = array_search( $temp_val, $field['value'] );
1028
-					if ( isset( $field['value'][ $o_key ] ) ) {
1029
-						unset( $field['value'][ $o_key ], $o_key );
1028
+					if ( isset( $field['value'][$o_key] ) ) {
1029
+						unset( $field['value'][$o_key], $o_key );
1030 1030
 					}
1031 1031
 				} else if ( $temp_val == $field['value'] ) {
1032 1032
 					// For radio and regular dropdowns
@@ -1083,7 +1083,7 @@  discard block
 block discarded – undo
1083 1083
 	private static function set_other_name( $args, &$other_args ) {
1084 1084
 		//Set up name for other field
1085 1085
 		$other_args['name'] = str_replace( '[]', '', $args['field_name'] );
1086
-		$other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']);
1086
+		$other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] );
1087 1087
 		$other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']';
1088 1088
 
1089 1089
 		//Converts item_meta[field_id] => item_meta[other][field_id] and
@@ -1109,7 +1109,7 @@  discard block
 block discarded – undo
1109 1109
 		// Count should only be greater than 3 if inside of a repeating section
1110 1110
 		if ( count( $temp_array ) > 3 ) {
1111 1111
 			$parent = str_replace( ']', '', $temp_array[1] );
1112
-			$pointer = str_replace( ']', '', $temp_array[2]);
1112
+			$pointer = str_replace( ']', '', $temp_array[2] );
1113 1113
 		}
1114 1114
 
1115 1115
 		// Get text for "other" text field
@@ -1228,15 +1228,15 @@  discard block
 block discarded – undo
1228 1228
 			$replace_with[] = '[' . $new . ']';
1229 1229
 			$replace[] = '[' . $old . ' ';
1230 1230
 			$replace_with[] = '[' . $new . ' ';
1231
-            unset($old, $new);
1231
+            unset( $old, $new );
1232 1232
         }
1233 1233
 		if ( is_array( $val ) ) {
1234 1234
 			foreach ( $val as $k => $v ) {
1235
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1236
-                unset($k, $v);
1235
+                $val[$k] = str_replace( $replace, $replace_with, $v );
1236
+                unset( $k, $v );
1237 1237
             }
1238 1238
         } else {
1239
-            $val = str_replace($replace, $replace_with, $val);
1239
+            $val = str_replace( $replace, $replace_with, $val );
1240 1240
         }
1241 1241
 
1242 1242
         return $val;
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
             'DC' => 'District of Columbia',
1250 1250
             'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1251 1251
             'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1252
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1252
+            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland',
1253 1253
             'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1254 1254
             'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1255 1255
             'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
@@ -1340,35 +1340,35 @@  discard block
 block discarded – undo
1340 1340
     }
1341 1341
 
1342 1342
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1343
-		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1343
+		$prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries();
1344 1344
 
1345 1345
         $states = FrmFieldsHelper::get_us_states();
1346
-        $state_abv = array_keys($states);
1347
-        sort($state_abv);
1348
-		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1346
+        $state_abv = array_keys( $states );
1347
+        sort( $state_abv );
1348
+		$prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv;
1349 1349
 
1350
-        $states = array_values($states);
1351
-        sort($states);
1352
-		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1353
-        unset($state_abv, $states);
1350
+        $states = array_values( $states );
1351
+        sort( $states );
1352
+		$prepop[__( 'U.S. States', 'formidable' )] = $states;
1353
+        unset( $state_abv, $states );
1354 1354
 
1355
-		$prepop[ __( 'Age', 'formidable' ) ] = array(
1355
+		$prepop[__( 'Age', 'formidable' )] = array(
1356 1356
             __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1357 1357
             __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1358 1358
             __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1359 1359
         );
1360 1360
 
1361
-		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1361
+		$prepop[__( 'Satisfaction', 'formidable' )] = array(
1362 1362
             __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1363 1363
             __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1364 1364
         );
1365 1365
 
1366
-		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1366
+		$prepop[__( 'Importance', 'formidable' )] = array(
1367 1367
             __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1368 1368
             __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1369 1369
         );
1370 1370
 
1371
-		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1371
+		$prepop[__( 'Agreement', 'formidable' )] = array(
1372 1372
             __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1373 1373
             __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1374 1374
         );
Please login to merge, or discard this patch.
classes/helpers/FrmXMLHelper.php 2 patches
Indentation   +570 added lines, -570 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,99 +127,99 @@  discard block
 block discarded – undo
127 127
 		self::put_child_forms_first( $forms );
128 128
 
129 129
 		foreach ( $forms as $item ) {
130
-            $form = array(
131
-                'id'            => (int) $item->id,
132
-                'form_key'      => (string) $item->form_key,
133
-                'name'          => (string) $item->name,
134
-                'description'   => (string) $item->description,
135
-                'options'       => (string) $item->options,
136
-                'logged_in'     => (int) $item->logged_in,
137
-                'is_template'   => (int) $item->is_template,
138
-                'default_template' => (int) $item->default_template,
139
-                'editable'      => (int) $item->editable,
140
-                'status'        => (string) $item->status,
141
-                'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0,
142
-                'created_at'    => date('Y-m-d H:i:s', strtotime((string) $item->created_at)),
143
-            );
144
-
145
-            $form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
130
+			$form = array(
131
+				'id'            => (int) $item->id,
132
+				'form_key'      => (string) $item->form_key,
133
+				'name'          => (string) $item->name,
134
+				'description'   => (string) $item->description,
135
+				'options'       => (string) $item->options,
136
+				'logged_in'     => (int) $item->logged_in,
137
+				'is_template'   => (int) $item->is_template,
138
+				'default_template' => (int) $item->default_template,
139
+				'editable'      => (int) $item->editable,
140
+				'status'        => (string) $item->status,
141
+				'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0,
142
+				'created_at'    => date('Y-m-d H:i:s', strtotime((string) $item->created_at)),
143
+			);
144
+
145
+			$form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
146 146
 
147 147
 			self::update_custom_style_setting_on_import( $form );
148 148
 
149
-            // if template, allow to edit if form keys match, otherwise, creation date must also match
149
+			// if template, allow to edit if form keys match, otherwise, creation date must also match
150 150
 			$edit_query = array( 'form_key' => $form['form_key'], 'is_template' => $form['is_template'] );
151
-            if ( ! $form['is_template'] ) {
152
-                $edit_query['created_at'] = $form['created_at'];
153
-            }
151
+			if ( ! $form['is_template'] ) {
152
+				$edit_query['created_at'] = $form['created_at'];
153
+			}
154 154
 
155
-            $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
155
+			$edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
156 156
 
157
-            $this_form = FrmForm::getAll($edit_query, '', 1);
158
-            unset($edit_query);
157
+			$this_form = FrmForm::getAll($edit_query, '', 1);
158
+			unset($edit_query);
159 159
 
160
-            if ( ! empty( $this_form ) ) {
161
-                $old_id = $form_id = $this_form->id;
162
-                FrmForm::update($form_id, $form );
163
-                $imported['updated']['forms']++;
164
-                // Keep track of whether this specific form was updated or not
160
+			if ( ! empty( $this_form ) ) {
161
+				$old_id = $form_id = $this_form->id;
162
+				FrmForm::update($form_id, $form );
163
+				$imported['updated']['forms']++;
164
+				// Keep track of whether this specific form was updated or not
165 165
 				$imported['form_status'][ $form_id ] = 'updated';
166 166
 
167 167
 				$form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' );
168
-                $old_fields = array();
169
-                foreach ( $form_fields as $f ) {
168
+				$old_fields = array();
169
+				foreach ( $form_fields as $f ) {
170 170
 					$old_fields[ $f->id ] = $f;
171 171
 					$old_fields[ $f->field_key ] = $f->id;
172
-                    unset($f);
173
-                }
174
-                $form_fields = $old_fields;
175
-                unset($old_fields);
176
-            } else {
177
-                $old_id = false;
178
-                //form does not exist, so create it
172
+					unset($f);
173
+				}
174
+				$form_fields = $old_fields;
175
+				unset($old_fields);
176
+			} else {
177
+				$old_id = false;
178
+				//form does not exist, so create it
179 179
 				$form_id = FrmForm::create( $form );
180
-                if ( $form_id ) {
181
-                    $imported['imported']['forms']++;
182
-                    // Keep track of whether this specific form was updated or not
180
+				if ( $form_id ) {
181
+					$imported['imported']['forms']++;
182
+					// Keep track of whether this specific form was updated or not
183 183
 					$imported['form_status'][ $form_id ] = 'imported';
184 184
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
185
-                }
186
-            }
185
+				}
186
+			}
187 187
 
188
-    		self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported );
188
+			self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported );
189 189
 
190
-    		// Delete any fields attached to this form that were not included in the template
191
-    		if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
190
+			// Delete any fields attached to this form that were not included in the template
191
+			if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
192 192
 				foreach ( $form_fields as $field ) {
193
-                    if ( is_object($field) ) {
194
-                        FrmField::destroy($field->id);
195
-                    }
196
-                    unset($field);
197
-                }
198
-                unset($form_fields);
199
-            }
200
-
201
-		    // Update field ids/keys to new ones
193
+					if ( is_object($field) ) {
194
+						FrmField::destroy($field->id);
195
+					}
196
+					unset($field);
197
+				}
198
+				unset($form_fields);
199
+			}
200
+
201
+			// Update field ids/keys to new ones
202 202
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
203 203
 
204 204
 			$imported['forms'][ (int) $item->id ] = $form_id;
205 205
 
206
-            // Send pre 2.0 form options through function that creates actions
207
-            self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
206
+			// Send pre 2.0 form options through function that creates actions
207
+			self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
208 208
 
209
-		    unset($form, $item);
209
+			unset($form, $item);
210 210
 		}
211 211
 
212 212
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
213 213
 
214 214
 		return $imported;
215
-    }
215
+	}
216 216
 
217 217
 	/**
218
-	* Put child forms first so they will be imported before parents
219
-	*
220
-	* @since 2.0.16
221
-	* @param array $forms
222
-	*/
218
+	 * Put child forms first so they will be imported before parents
219
+	 *
220
+	 * @since 2.0.16
221
+	 * @param array $forms
222
+	 */
223 223
 	private static function put_child_forms_first( &$forms ) {
224 224
 		$child_forms = array();
225 225
 		$regular_forms = array();
@@ -238,13 +238,13 @@  discard block
 block discarded – undo
238 238
 	}
239 239
 
240 240
 	/**
241
-	* Keep track of all imported child forms
242
-	*
243
-	* @since 2.0.16
244
-	* @param int $form_id
245
-	* @param int $parent_form_id
246
-	* @param array $child_forms
247
-	*/
241
+	 * Keep track of all imported child forms
242
+	 *
243
+	 * @since 2.0.16
244
+	 * @param int $form_id
245
+	 * @param int $parent_form_id
246
+	 * @param array $child_forms
247
+	 */
248 248
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
249 249
 		if ( $parent_form_id ) {
250 250
 			$child_forms[ $form_id ] = $parent_form_id;
@@ -252,13 +252,13 @@  discard block
 block discarded – undo
252 252
 	}
253 253
 
254 254
 	/**
255
-	* Update the parent_form_id on imported child forms
256
-	* Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
257
-	*
258
-	* @since 2.0.6
259
-	* @param array $imported_forms
260
-	* @param array $child_forms
261
-	*/
255
+	 * Update the parent_form_id on imported child forms
256
+	 * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
257
+	 *
258
+	 * @since 2.0.6
259
+	 * @param array $imported_forms
260
+	 * @param array $child_forms
261
+	 */
262 262
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
263 263
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
264 264
 
@@ -272,40 +272,40 @@  discard block
 block discarded – undo
272 272
 	}
273 273
 
274 274
 	/**
275
-	* Import all fields for a form
276
-	* @since 2.0.13
277
-	*
278
-	* TODO: Cut down on params
279
-	*/
275
+	 * Import all fields for a form
276
+	 * @since 2.0.13
277
+	 *
278
+	 * TODO: Cut down on params
279
+	 */
280 280
 	private static function import_xml_fields( $xml_fields, $form_id, $this_form, &$form_fields, &$imported ) {
281 281
 		$in_section = 0;
282 282
 
283 283
 		foreach ( $xml_fields as $field ) {
284
-		    $f = array(
285
-		        'id'            => (int) $field->id,
286
-		        'field_key'     => (string) $field->field_key,
287
-		        'name'          => (string) $field->name,
288
-		        'description'   => (string) $field->description,
289
-		        'type'          => (string) $field->type,
290
-		        'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
291
-		        'field_order'   => (int) $field->field_order,
292
-		        'form_id'       => (int) $form_id,
293
-		        'required'      => (int) $field->required,
294
-		        'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
284
+			$f = array(
285
+				'id'            => (int) $field->id,
286
+				'field_key'     => (string) $field->field_key,
287
+				'name'          => (string) $field->name,
288
+				'description'   => (string) $field->description,
289
+				'type'          => (string) $field->type,
290
+				'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
291
+				'field_order'   => (int) $field->field_order,
292
+				'form_id'       => (int) $form_id,
293
+				'required'      => (int) $field->required,
294
+				'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
295 295
 				'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
296
-		    );
297
-
298
-		    if ( is_array($f['default_value']) && in_array($f['type'], array(
299
-		        'text', 'email', 'url', 'textarea',
300
-		        'number','phone', 'date', 'time',
301
-		        'hidden', 'password', 'tag', 'image',
302
-		    )) ) {
303
-		        if ( count($f['default_value']) === 1 ) {
296
+			);
297
+
298
+			if ( is_array($f['default_value']) && in_array($f['type'], array(
299
+				'text', 'email', 'url', 'textarea',
300
+				'number','phone', 'date', 'time',
301
+				'hidden', 'password', 'tag', 'image',
302
+			)) ) {
303
+				if ( count($f['default_value']) === 1 ) {
304 304
 					$f['default_value'] = '[' . reset( $f['default_value'] ) . ']';
305
-		        } else {
306
-		            $f['default_value'] = reset($f['default_value']);
307
-		        }
308
-		    }
305
+				} else {
306
+					$f['default_value'] = reset($f['default_value']);
307
+				}
308
+			}
309 309
 
310 310
 			self::maybe_update_form_select( $f, $imported );
311 311
 
@@ -368,12 +368,12 @@  discard block
 block discarded – undo
368 368
 	}
369 369
 
370 370
 	/**
371
-	* Switch the form_select on a repeating field or embedded form if it needs to be switched
372
-	*
373
-	* @since 2.0.16
374
-	* @param array $f
375
-	* @param array $imported
376
-	*/
371
+	 * Switch the form_select on a repeating field or embedded form if it needs to be switched
372
+	 *
373
+	 * @since 2.0.16
374
+	 * @param array $f
375
+	 * @param array $imported
376
+	 */
377 377
 	private static function maybe_update_form_select( &$f, $imported ) {
378 378
 		if ( ! isset( $imported['forms'] ) ) {
379 379
 			return;
@@ -404,12 +404,12 @@  discard block
 block discarded – undo
404 404
 	}
405 405
 
406 406
 	/**
407
-	* Updates the custom style setting on import
408
-	*
409
-	* @since 2.0.19
410
-	* @param array $form
411
-	*
412
-	*/
407
+	 * Updates the custom style setting on import
408
+	 *
409
+	 * @since 2.0.19
410
+	 * @param array $form
411
+	 *
412
+	 */
413 413
 	private static function update_custom_style_setting_on_import( &$form ) {
414 414
 		if ( ! isset( $form['options']['custom_style'] ) ) {
415 415
 			return;
@@ -439,16 +439,16 @@  discard block
 block discarded – undo
439 439
 	}
440 440
 
441 441
 	public static function import_xml_views( $views, $imported ) {
442
-        $imported['posts'] = array();
443
-        $form_action_type = FrmFormActionsController::$action_post_type;
442
+		$imported['posts'] = array();
443
+		$form_action_type = FrmFormActionsController::$action_post_type;
444 444
 
445
-        $post_types = array(
446
-            'frm_display' => 'views',
447
-            $form_action_type => 'actions',
448
-            'frm_styles'    => 'styles',
449
-        );
445
+		$post_types = array(
446
+			'frm_display' => 'views',
447
+			$form_action_type => 'actions',
448
+			'frm_styles'    => 'styles',
449
+		);
450 450
 
451
-        foreach ( $views as $item ) {
451
+		foreach ( $views as $item ) {
452 452
 			$post = array(
453 453
 				'post_title'    => (string) $item->title,
454 454
 				'post_name'     => (string) $item->post_name,
@@ -467,52 +467,52 @@  discard block
 block discarded – undo
467 467
 				'post_date'     => (string) $item->post_date,
468 468
 				'post_date_gmt' => (string) $item->post_date_gmt,
469 469
 				'ping_status'   => (string) $item->ping_status,
470
-                'postmeta'      => array(),
471
-                'tax_input'     => array(),
470
+				'postmeta'      => array(),
471
+				'tax_input'     => array(),
472 472
 			);
473 473
 
474
-            $old_id = $post['post_id'];
475
-            self::populate_post($post, $item, $imported);
474
+			$old_id = $post['post_id'];
475
+			self::populate_post($post, $item, $imported);
476 476
 
477 477
 			unset($item);
478 478
 
479 479
 			$post_id = false;
480
-            if ( $post['post_type'] == $form_action_type ) {
481
-                $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
480
+			if ( $post['post_type'] == $form_action_type ) {
481
+				$action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
482 482
 				if ( $action_control ) {
483 483
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
484 484
 				}
485
-                unset($action_control);
486
-            } else if ( $post['post_type'] == 'frm_styles' ) {
487
-                // Properly encode post content before inserting the post
488
-                $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
489
-                $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
490
-
491
-                // Create/update post now
492
-                $post_id = wp_insert_post( $post );
493
-            } else {
494
-                // Create/update post now
495
-                $post_id = wp_insert_post( $post );
496
-            }
497
-
498
-            if ( ! is_numeric($post_id) ) {
499
-                continue;
500
-            }
501
-
502
-            self::update_postmeta($post, $post_id);
503
-
504
-            $this_type = 'posts';
485
+				unset($action_control);
486
+			} else if ( $post['post_type'] == 'frm_styles' ) {
487
+				// Properly encode post content before inserting the post
488
+				$post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
489
+				$post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
490
+
491
+				// Create/update post now
492
+				$post_id = wp_insert_post( $post );
493
+			} else {
494
+				// Create/update post now
495
+				$post_id = wp_insert_post( $post );
496
+			}
497
+
498
+			if ( ! is_numeric($post_id) ) {
499
+				continue;
500
+			}
501
+
502
+			self::update_postmeta($post, $post_id);
503
+
504
+			$this_type = 'posts';
505 505
 			if ( isset( $post_types[ $post['post_type'] ] ) ) {
506 506
 				$this_type = $post_types[ $post['post_type'] ];
507
-            }
507
+			}
508 508
 
509
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
510
-                $imported['updated'][ $this_type ]++;
511
-            } else {
512
-                $imported['imported'][ $this_type ]++;
513
-            }
509
+			if ( isset($post['ID']) && $post_id == $post['ID'] ) {
510
+				$imported['updated'][ $this_type ]++;
511
+			} else {
512
+				$imported['imported'][ $this_type ]++;
513
+			}
514 514
 
515
-            unset($post);
515
+			unset($post);
516 516
 
517 517
 			$imported['posts'][ (int) $old_id ] = $post_id;
518 518
 		}
@@ -520,157 +520,157 @@  discard block
 block discarded – undo
520 520
 		self::maybe_update_stylesheet( $imported );
521 521
 
522 522
 		return $imported;
523
-    }
523
+	}
524 524
 
525
-    private static function populate_post( &$post, $item, $imported ) {
525
+	private static function populate_post( &$post, $item, $imported ) {
526 526
 		if ( isset($item->attachment_url) ) {
527 527
 			$post['attachment_url'] = (string) $item->attachment_url;
528 528
 		}
529 529
 
530 530
 		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
531
-		    // update to new form id
532
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
531
+			// update to new form id
532
+			$post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
533 533
 		}
534 534
 
535 535
 		foreach ( $item->postmeta as $meta ) {
536
-		    self::populate_postmeta($post, $meta, $imported);
536
+			self::populate_postmeta($post, $meta, $imported);
537 537
 			unset($meta);
538 538
 		}
539 539
 
540
-        self::populate_taxonomies($post, $item);
540
+		self::populate_taxonomies($post, $item);
541 541
 
542
-        self::maybe_editing_post($post);
543
-    }
542
+		self::maybe_editing_post($post);
543
+	}
544 544
 
545
-    private static function populate_postmeta( &$post, $meta, $imported ) {
546
-        global $frm_duplicate_ids;
545
+	private static function populate_postmeta( &$post, $meta, $imported ) {
546
+		global $frm_duplicate_ids;
547 547
 
548
-	    $m = array(
548
+		$m = array(
549 549
 			'key'   => (string) $meta->meta_key,
550 550
 			'value' => (string) $meta->meta_value,
551 551
 		);
552 552
 
553 553
 		//switch old form and field ids to new ones
554 554
 		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
555
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
555
+			$m['value'] = $imported['forms'][ (int) $m['value'] ];
556 556
 		} else {
557
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
557
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
558 558
 
559
-		    if ( ! empty($frm_duplicate_ids) ) {
559
+			if ( ! empty($frm_duplicate_ids) ) {
560 560
 
561
-		        if ( $m['key'] == 'frm_dyncontent' ) {
562
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
563
-    		    } else if ( $m['key'] == 'frm_options' ) {
561
+				if ( $m['key'] == 'frm_dyncontent' ) {
562
+					$m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
563
+				} else if ( $m['key'] == 'frm_options' ) {
564 564
 
565 565
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
566 566
 						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
567 567
 							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
568
-    		            }
569
-    		        }
570
-
571
-                    $check_dup_array = array();
572
-    		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
573
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
574
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
575
-    		            } else if ( is_array( $m['value']['order_by'] ) ) {
576
-                            $check_dup_array[] = 'order_by';
577
-    		            }
578
-    		        }
579
-
580
-    		        if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
581
-    		            $check_dup_array[] = 'where';
582
-    		        }
583
-
584
-                    foreach ( $check_dup_array as $check_k ) {
568
+						}
569
+					}
570
+
571
+					$check_dup_array = array();
572
+					if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
573
+						if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
574
+							$m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
575
+						} else if ( is_array( $m['value']['order_by'] ) ) {
576
+							$check_dup_array[] = 'order_by';
577
+						}
578
+					}
579
+
580
+					if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
581
+						$check_dup_array[] = 'where';
582
+					}
583
+
584
+					foreach ( $check_dup_array as $check_k ) {
585 585
 						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
586 586
 							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
587 587
 								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
588
-		                    }
589
-		                    unset($mk, $mv);
590
-		                }
591
-                    }
592
-    		    }
593
-		    }
588
+							}
589
+							unset($mk, $mv);
590
+						}
591
+					}
592
+				}
593
+			}
594 594
 		}
595 595
 
596 596
 		if ( ! is_array($m['value']) ) {
597
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
597
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
598 598
 		}
599 599
 
600 600
 		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
601
-    }
602
-
603
-    /**
604
-     * Add terms to post
605
-     * @param array $post by reference
606
-     * @param object $item The XML object data
607
-     */
608
-    private static function populate_taxonomies( &$post, $item ) {
601
+	}
602
+
603
+	/**
604
+	 * Add terms to post
605
+	 * @param array $post by reference
606
+	 * @param object $item The XML object data
607
+	 */
608
+	private static function populate_taxonomies( &$post, $item ) {
609 609
 		foreach ( $item->category as $c ) {
610 610
 			$att = $c->attributes();
611 611
 			if ( ! isset( $att['nicename'] ) ) {
612
-                continue;
613
-            }
614
-
615
-		    $taxonomy = (string) $att['domain'];
616
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
617
-		        $name = (string) $att['nicename'];
618
-		        $h_term = get_term_by('slug', $name, $taxonomy);
619
-		        if ( $h_term ) {
620
-		            $name = $h_term->term_id;
621
-		        }
622
-		        unset($h_term);
623
-		    } else {
624
-		        $name = (string) $c;
625
-		    }
612
+				continue;
613
+			}
614
+
615
+			$taxonomy = (string) $att['domain'];
616
+			if ( is_taxonomy_hierarchical($taxonomy) ) {
617
+				$name = (string) $att['nicename'];
618
+				$h_term = get_term_by('slug', $name, $taxonomy);
619
+				if ( $h_term ) {
620
+					$name = $h_term->term_id;
621
+				}
622
+				unset($h_term);
623
+			} else {
624
+				$name = (string) $c;
625
+			}
626 626
 
627 627
 			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
628 628
 				$post['tax_input'][ $taxonomy ] = array();
629 629
 			}
630 630
 
631 631
 			$post['tax_input'][ $taxonomy ][] = $name;
632
-		    unset($name);
632
+			unset($name);
633 633
 		}
634
-    }
634
+	}
635 635
 
636
-    /**
637
-     * Edit post if the key and created time match
638
-     */
639
-    private static function maybe_editing_post( &$post ) {
636
+	/**
637
+	 * Edit post if the key and created time match
638
+	 */
639
+	private static function maybe_editing_post( &$post ) {
640 640
 		$match_by = array(
641
-		    'post_type'     => $post['post_type'],
642
-		    'name'          => $post['post_name'],
643
-		    'post_status'   => $post['post_status'],
644
-		    'posts_per_page' => 1,
641
+			'post_type'     => $post['post_type'],
642
+			'name'          => $post['post_name'],
643
+			'post_status'   => $post['post_status'],
644
+			'posts_per_page' => 1,
645 645
 		);
646 646
 
647 647
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
648
-		    $match_by['include'] = $post['post_id'];
649
-		    unset($match_by['name']);
648
+			$match_by['include'] = $post['post_id'];
649
+			unset($match_by['name']);
650 650
 		}
651 651
 
652 652
 		$editing = get_posts($match_by);
653 653
 
654
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
655
-            // set the id of the post to edit
656
-            $post['ID'] = current($editing)->ID;
657
-        }
658
-    }
654
+		if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
655
+			// set the id of the post to edit
656
+			$post['ID'] = current($editing)->ID;
657
+		}
658
+	}
659 659
 
660
-    private static function update_postmeta( &$post, $post_id ) {
661
-        foreach ( $post['postmeta'] as $k => $v ) {
662
-            if ( '_edit_last' == $k ) {
663
-                $v = FrmAppHelper::get_user_id_param($v);
664
-            } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
665
-                //change the attachment ID
666
-                $v = FrmProXMLHelper::get_file_id($v);
667
-            }
660
+	private static function update_postmeta( &$post, $post_id ) {
661
+		foreach ( $post['postmeta'] as $k => $v ) {
662
+			if ( '_edit_last' == $k ) {
663
+				$v = FrmAppHelper::get_user_id_param($v);
664
+			} else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
665
+				//change the attachment ID
666
+				$v = FrmProXMLHelper::get_file_id($v);
667
+			}
668 668
 
669
-            update_post_meta($post_id, $k, $v);
669
+			update_post_meta($post_id, $k, $v);
670 670
 
671
-            unset($k, $v);
672
-        }
673
-    }
671
+			unset($k, $v);
672
+		}
673
+	}
674 674
 
675 675
 	private static function maybe_update_stylesheet( $imported ) {
676 676
 		if ( ( isset( $imported['imported']['styles'] ) && ! empty( $imported['imported']['styles'] ) ) || ( isset( $imported['updated']['styles'] ) && ! empty( $imported['updated']['styles'] ) ) ) {
@@ -681,72 +681,72 @@  discard block
 block discarded – undo
681 681
 		}
682 682
 	}
683 683
 
684
-    /**
685
-     * @param string $message
686
-     */
684
+	/**
685
+	 * @param string $message
686
+	 */
687 687
 	public static function parse_message( $result, &$message, &$errors ) {
688
-        if ( is_wp_error($result) ) {
689
-            $errors[] = $result->get_error_message();
690
-        } else if ( ! $result ) {
691
-            return;
692
-        }
693
-
694
-        if ( ! is_array($result) ) {
695
-            $message = is_string( $result ) ? $result : print_r( $result, 1 );
696
-            return;
697
-        }
698
-
699
-        $t_strings = array(
700
-            'imported'  => __( 'Imported', 'formidable' ),
701
-            'updated'   => __( 'Updated', 'formidable' ),
702
-        );
703
-
704
-        $message = '<ul>';
705
-        foreach ( $result as $type => $results ) {
688
+		if ( is_wp_error($result) ) {
689
+			$errors[] = $result->get_error_message();
690
+		} else if ( ! $result ) {
691
+			return;
692
+		}
693
+
694
+		if ( ! is_array($result) ) {
695
+			$message = is_string( $result ) ? $result : print_r( $result, 1 );
696
+			return;
697
+		}
698
+
699
+		$t_strings = array(
700
+			'imported'  => __( 'Imported', 'formidable' ),
701
+			'updated'   => __( 'Updated', 'formidable' ),
702
+		);
703
+
704
+		$message = '<ul>';
705
+		foreach ( $result as $type => $results ) {
706 706
 			if ( ! isset( $t_strings[ $type ] ) ) {
707
-                // only print imported and updated
708
-                continue;
709
-            }
707
+				// only print imported and updated
708
+				continue;
709
+			}
710 710
 
711
-            $s_message = array();
712
-            foreach ( $results as $k => $m ) {
713
-                self::item_count_message($m, $k, $s_message);
714
-                unset($k, $m);
715
-            }
711
+			$s_message = array();
712
+			foreach ( $results as $k => $m ) {
713
+				self::item_count_message($m, $k, $s_message);
714
+				unset($k, $m);
715
+			}
716 716
 
717
-            if ( ! empty($s_message) ) {
717
+			if ( ! empty($s_message) ) {
718 718
 				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
719
-                $message .= implode(', ', $s_message);
720
-                $message .= '</li>';
721
-            }
722
-        }
723
-
724
-        if ( $message == '<ul>' ) {
725
-            $message = '';
726
-            $errors[] = __( 'Nothing was imported or updated', 'formidable' );
727
-        } else {
728
-            $message .= '</ul>';
729
-        }
730
-    }
719
+				$message .= implode(', ', $s_message);
720
+				$message .= '</li>';
721
+			}
722
+		}
723
+
724
+		if ( $message == '<ul>' ) {
725
+			$message = '';
726
+			$errors[] = __( 'Nothing was imported or updated', 'formidable' );
727
+		} else {
728
+			$message .= '</ul>';
729
+		}
730
+	}
731 731
 
732 732
 	public static function item_count_message( $m, $type, &$s_message ) {
733
-        if ( ! $m ) {
734
-            return;
735
-        }
736
-
737
-        $strings = array(
738
-            'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
739
-            'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
740
-            'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
741
-            'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
742
-            'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
743
-            'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
744
-            'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
745
-            'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
746
-        );
733
+		if ( ! $m ) {
734
+			return;
735
+		}
736
+
737
+		$strings = array(
738
+			'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
739
+			'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
740
+			'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
741
+			'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
742
+			'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
743
+			'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
744
+			'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
745
+			'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
746
+		);
747 747
 
748 748
 		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
749
-    }
749
+	}
750 750
 
751 751
 	/**
752 752
 	 * Prepare the form options for export
@@ -777,16 +777,16 @@  discard block
 block discarded – undo
777 777
 	}
778 778
 
779 779
 	public static function cdata( $str ) {
780
-	    $str = maybe_unserialize($str);
781
-	    if ( is_array($str) ) {
782
-	        $str = json_encode($str);
780
+		$str = maybe_unserialize($str);
781
+		if ( is_array($str) ) {
782
+			$str = json_encode($str);
783 783
 		} else if ( seems_utf8( $str ) == false ) {
784 784
 			$str = utf8_encode( $str );
785 785
 		}
786 786
 
787
-        if ( is_numeric($str) ) {
788
-            return $str;
789
-        }
787
+		if ( is_numeric($str) ) {
788
+			return $str;
789
+		}
790 790
 
791 791
 		self::remove_invalid_characters_from_xml( $str );
792 792
 
@@ -807,58 +807,58 @@  discard block
 block discarded – undo
807 807
 		$str = str_replace( '\x1F', '', $str );
808 808
 	}
809 809
 
810
-    public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
811
-        // Get post type
812
-        $post_type = FrmFormActionsController::$action_post_type;
813
-
814
-        // Set up imported index, if not set up yet
815
-        if ( ! isset( $imported['imported']['actions'] ) ) {
816
-            $imported['imported']['actions'] = 0;
817
-        }
818
-
819
-        // Migrate post settings to action
820
-        self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
821
-
822
-        // Migrate email settings to action
823
-        self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
824
-    }
825
-
826
-    /**
827
-    * Migrate post settings to form action
828
-    *
829
-    * @param string $post_type
830
-    */
831
-    private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
832
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
833
-            return;
834
-        }
835
-
836
-        $new_action = array(
837
-            'post_type'     => $post_type,
838
-            'post_excerpt'  => 'wppost',
810
+	public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
811
+		// Get post type
812
+		$post_type = FrmFormActionsController::$action_post_type;
813
+
814
+		// Set up imported index, if not set up yet
815
+		if ( ! isset( $imported['imported']['actions'] ) ) {
816
+			$imported['imported']['actions'] = 0;
817
+		}
818
+
819
+		// Migrate post settings to action
820
+		self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
821
+
822
+		// Migrate email settings to action
823
+		self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
824
+	}
825
+
826
+	/**
827
+	 * Migrate post settings to form action
828
+	 *
829
+	 * @param string $post_type
830
+	 */
831
+	private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
832
+		if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
833
+			return;
834
+		}
835
+
836
+		$new_action = array(
837
+			'post_type'     => $post_type,
838
+			'post_excerpt'  => 'wppost',
839 839
 			'post_title'    => __( 'Create Posts', 'formidable' ),
840
-            'menu_order'    => $form_id,
841
-            'post_status'   => 'publish',
842
-            'post_content'  => array(),
840
+			'menu_order'    => $form_id,
841
+			'post_status'   => 'publish',
842
+			'post_content'  => array(),
843 843
 			'post_name'     => $form_id . '_wppost_1',
844
-        );
844
+		);
845 845
 
846
-        $post_settings = array(
847
-            'post_type', 'post_category', 'post_content',
848
-            'post_excerpt', 'post_title', 'post_name', 'post_date',
846
+		$post_settings = array(
847
+			'post_type', 'post_category', 'post_content',
848
+			'post_excerpt', 'post_title', 'post_name', 'post_date',
849 849
 			'post_status', 'post_custom_fields', 'post_password',
850
-        );
850
+		);
851 851
 
852
-        foreach ( $post_settings as $post_setting ) {
852
+		foreach ( $post_settings as $post_setting ) {
853 853
 			if ( isset( $form_options[ $post_setting ] ) ) {
854 854
 				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
855
-            }
856
-            unset($post_setting);
857
-        }
855
+			}
856
+			unset($post_setting);
857
+		}
858 858
 
859 859
 		$new_action['event'] = array( 'create', 'update' );
860 860
 
861
-        if ( $switch ) {
861
+		if ( $switch ) {
862 862
 			// Fields with string or int saved
863 863
 			$basic_fields = array( 'post_title', 'post_content', 'post_excerpt', 'post_password', 'post_date', 'post_status' );
864 864
 
@@ -866,22 +866,22 @@  discard block
 block discarded – undo
866 866
 			$array_fields = array( 'post_category', 'post_custom_fields' );
867 867
 
868 868
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
869
-        }
870
-        $new_action['post_content'] = json_encode($new_action['post_content']);
869
+		}
870
+		$new_action['post_content'] = json_encode($new_action['post_content']);
871 871
 
872
-        $exists = get_posts( array(
873
-            'name'          => $new_action['post_name'],
874
-            'post_type'     => $new_action['post_type'],
875
-            'post_status'   => $new_action['post_status'],
876
-            'numberposts'   => 1,
877
-        ) );
872
+		$exists = get_posts( array(
873
+			'name'          => $new_action['post_name'],
874
+			'post_type'     => $new_action['post_type'],
875
+			'post_status'   => $new_action['post_status'],
876
+			'numberposts'   => 1,
877
+		) );
878 878
 
879
-        if ( ! $exists ) {
879
+		if ( ! $exists ) {
880 880
 			// this isn't an email, but we need to use a class that will always be included
881 881
 			FrmAppHelper::save_json_post( $new_action );
882
-            $imported['imported']['actions']++;
883
-        }
884
-    }
882
+			$imported['imported']['actions']++;
883
+		}
884
+	}
885 885
 
886 886
 	/**
887 887
 	 * Switch old field IDs for new field IDs in emails and post
@@ -894,211 +894,211 @@  discard block
 block discarded – undo
894 894
 	 * @return string $post_content - new field IDs
895 895
 	 */
896 896
 	private static function switch_action_field_ids( $post_content, $basic_fields, $array_fields = array() ) {
897
-        global $frm_duplicate_ids;
897
+		global $frm_duplicate_ids;
898 898
 
899
-        // If there aren't IDs that were switched, end now
900
-        if ( ! $frm_duplicate_ids ) {
901
-            return;
902
-        }
899
+		// If there aren't IDs that were switched, end now
900
+		if ( ! $frm_duplicate_ids ) {
901
+			return;
902
+		}
903 903
 
904
-        // Get old IDs
905
-        $old = array_keys( $frm_duplicate_ids );
904
+		// Get old IDs
905
+		$old = array_keys( $frm_duplicate_ids );
906 906
 
907
-        // Get new IDs
908
-        $new = array_values( $frm_duplicate_ids );
907
+		// Get new IDs
908
+		$new = array_values( $frm_duplicate_ids );
909 909
 
910
-        // Do a str_replace with each item to set the new IDs
911
-        foreach ( $post_content as $key => $setting ) {
912
-            if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
913
-                // Replace old IDs with new IDs
910
+		// Do a str_replace with each item to set the new IDs
911
+		foreach ( $post_content as $key => $setting ) {
912
+			if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
913
+				// Replace old IDs with new IDs
914 914
 				$post_content[ $key ] = str_replace( $old, $new, $setting );
915
-            } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
916
-                foreach ( $setting as $k => $val ) {
917
-                    // Replace old IDs with new IDs
915
+			} else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
916
+				foreach ( $setting as $k => $val ) {
917
+					// Replace old IDs with new IDs
918 918
 					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
919
-                }
920
-            }
921
-            unset( $key, $setting );
922
-        }
923
-        return $post_content;
924
-    }
925
-
926
-    private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
927
-        // No old notifications or autoresponders to carry over
919
+				}
920
+			}
921
+			unset( $key, $setting );
922
+		}
923
+		return $post_content;
924
+	}
925
+
926
+	private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
927
+		// No old notifications or autoresponders to carry over
928 928
 		if ( ! isset( $form_options['auto_responder'] ) && ! isset( $form_options['notification'] ) && ! isset( $form_options['email_to'] ) ) {
929
-            return;
930
-        }
929
+			return;
930
+		}
931 931
 
932
-        // Initialize notifications array
933
-        $notifications = array();
932
+		// Initialize notifications array
933
+		$notifications = array();
934 934
 
935
-        // Migrate regular notifications
936
-        self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
935
+		// Migrate regular notifications
936
+		self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
937 937
 
938
-        // Migrate autoresponders
939
-        self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
938
+		// Migrate autoresponders
939
+		self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
940 940
 
941
-        if (  empty( $notifications ) ) {
942
-            return;
943
-        }
941
+		if (  empty( $notifications ) ) {
942
+			return;
943
+		}
944 944
 
945
-        foreach ( $notifications as $new_notification ) {
946
-            $new_notification['post_type']      = $post_type;
947
-            $new_notification['post_excerpt']   = 'email';
945
+		foreach ( $notifications as $new_notification ) {
946
+			$new_notification['post_type']      = $post_type;
947
+			$new_notification['post_excerpt']   = 'email';
948 948
 			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
949
-            $new_notification['menu_order']     = $form_id;
950
-            $new_notification['post_status']    = 'publish';
949
+			$new_notification['menu_order']     = $form_id;
950
+			$new_notification['post_status']    = 'publish';
951 951
 
952
-            // Switch field IDs and keys, if needed
953
-            if ( $switch ) {
952
+			// Switch field IDs and keys, if needed
953
+			if ( $switch ) {
954 954
 
955 955
 				// Switch field IDs in email conditional logic
956 956
 				self::switch_email_contition_field_ids( $new_notification['post_content'] );
957 957
 
958 958
 				// Switch all other field IDs in email
959
-                $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
960
-            }
961
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
962
-
963
-            $exists = get_posts( array(
964
-                'name'          => $new_notification['post_name'],
965
-                'post_type'     => $new_notification['post_type'],
966
-                'post_status'   => $new_notification['post_status'],
967
-                'numberposts'   => 1,
968
-            ) );
969
-
970
-            if ( empty($exists) ) {
959
+				$new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
960
+			}
961
+			$new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
962
+
963
+			$exists = get_posts( array(
964
+				'name'          => $new_notification['post_name'],
965
+				'post_type'     => $new_notification['post_type'],
966
+				'post_status'   => $new_notification['post_status'],
967
+				'numberposts'   => 1,
968
+			) );
969
+
970
+			if ( empty($exists) ) {
971 971
 				FrmAppHelper::save_json_post( $new_notification );
972
-                $imported['imported']['actions']++;
973
-            }
974
-            unset($new_notification);
975
-        }
976
-    }
977
-
978
-    private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
979
-        if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
980
-            // add old settings into notification array
972
+				$imported['imported']['actions']++;
973
+			}
974
+			unset($new_notification);
975
+		}
976
+	}
977
+
978
+	private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
979
+		if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
980
+			// add old settings into notification array
981 981
 			$form_options['notification'] = array( 0 => $form_options );
982
-        } else if ( isset( $form_options['notification']['email_to'] ) ) {
983
-            // make sure it's in the correct format
982
+		} else if ( isset( $form_options['notification']['email_to'] ) ) {
983
+			// make sure it's in the correct format
984 984
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
985
-        }
985
+		}
986 986
 
987
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
988
-            foreach ( $form_options['notification'] as $email_key => $notification ) {
987
+		if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
988
+			foreach ( $form_options['notification'] as $email_key => $notification ) {
989 989
 
990
-                $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
990
+				$atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
991 991
 
992
-                // Format the email data
993
-                self::format_email_data( $atts, $notification );
992
+				// Format the email data
993
+				self::format_email_data( $atts, $notification );
994 994
 
995 995
 				if ( isset( $notification['twilio'] ) && $notification['twilio'] ) {
996 996
 					do_action( 'frm_create_twilio_action', $atts, $notification );
997 997
 				}
998 998
 
999
-                // Setup the new notification
1000
-                $new_notification = array();
1001
-                self::setup_new_notification( $new_notification, $notification, $atts );
999
+				// Setup the new notification
1000
+				$new_notification = array();
1001
+				self::setup_new_notification( $new_notification, $notification, $atts );
1002 1002
 
1003
-                $notifications[] = $new_notification;
1004
-            }
1005
-        }
1006
-    }
1003
+				$notifications[] = $new_notification;
1004
+			}
1005
+		}
1006
+	}
1007 1007
 
1008
-    private static function format_email_data( &$atts, $notification ) {
1009
-        // Format email_to
1010
-        self::format_email_to_data( $atts, $notification );
1008
+	private static function format_email_data( &$atts, $notification ) {
1009
+		// Format email_to
1010
+		self::format_email_to_data( $atts, $notification );
1011 1011
 
1012
-        // Format the reply to email and name
1013
-        $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
1014
-        foreach ( $reply_fields as $f => $val ) {
1012
+		// Format the reply to email and name
1013
+		$reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
1014
+		foreach ( $reply_fields as $f => $val ) {
1015 1015
 			if ( isset( $notification[ $f ] ) ) {
1016 1016
 				$atts[ $f ] = $notification[ $f ];
1017 1017
 				if ( 'custom' == $notification[ $f ] ) {
1018 1018
 					$atts[ $f ] = $notification[ 'cust_' . $f ];
1019 1019
 				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
1020 1020
 					$atts[ $f ] = '[' . $atts[ $f ] . ']';
1021
-                }
1022
-            }
1023
-            unset( $f, $val );
1024
-        }
1021
+				}
1022
+			}
1023
+			unset( $f, $val );
1024
+		}
1025 1025
 
1026
-        // Format event
1026
+		// Format event
1027 1027
 		$atts['event'] = array( 'create' );
1028
-        if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1029
-            $atts['event'][] = 'update';
1030
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1028
+		if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1029
+			$atts['event'][] = 'update';
1030
+		} else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1031 1031
 			$atts['event'] = array( 'update' );
1032
-        }
1033
-    }
1032
+		}
1033
+	}
1034 1034
 
1035
-    private static function format_email_to_data( &$atts, $notification ) {
1036
-        if ( isset( $notification['email_to'] ) ) {
1035
+	private static function format_email_to_data( &$atts, $notification ) {
1036
+		if ( isset( $notification['email_to'] ) ) {
1037 1037
 			$atts['email_to'] = preg_split( '/ (,|;) /', $notification['email_to'] );
1038
-        } else {
1039
-            $atts['email_to'] = array();
1040
-        }
1038
+		} else {
1039
+			$atts['email_to'] = array();
1040
+		}
1041 1041
 
1042
-        if ( isset( $notification['also_email_to'] ) ) {
1043
-            $email_fields = (array) $notification['also_email_to'];
1044
-            $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1045
-            unset( $email_fields );
1046
-        }
1042
+		if ( isset( $notification['also_email_to'] ) ) {
1043
+			$email_fields = (array) $notification['also_email_to'];
1044
+			$atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1045
+			unset( $email_fields );
1046
+		}
1047 1047
 
1048
-        foreach ( $atts['email_to'] as $key => $email_field ) {
1048
+		foreach ( $atts['email_to'] as $key => $email_field ) {
1049 1049
 
1050
-            if ( is_numeric( $email_field ) ) {
1050
+			if ( is_numeric( $email_field ) ) {
1051 1051
 				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1052
-            }
1052
+			}
1053 1053
 
1054
-            if ( strpos( $email_field, '|') ) {
1055
-                $email_opt = explode( '|', $email_field );
1056
-                if ( isset( $email_opt[0] ) ) {
1054
+			if ( strpos( $email_field, '|') ) {
1055
+				$email_opt = explode( '|', $email_field );
1056
+				if ( isset( $email_opt[0] ) ) {
1057 1057
 					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1058
-                }
1059
-                unset( $email_opt );
1060
-            }
1061
-        }
1062
-        $atts['email_to'] = implode(', ', $atts['email_to']);
1063
-    }
1064
-
1065
-    private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1066
-        // Set up new notification
1067
-        $new_notification = array(
1068
-            'post_content'  => array(
1069
-                'email_to'      => $atts['email_to'],
1070
-                'event'         => $atts['event'],
1071
-            ),
1058
+				}
1059
+				unset( $email_opt );
1060
+			}
1061
+		}
1062
+		$atts['email_to'] = implode(', ', $atts['email_to']);
1063
+	}
1064
+
1065
+	private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1066
+		// Set up new notification
1067
+		$new_notification = array(
1068
+			'post_content'  => array(
1069
+				'email_to'      => $atts['email_to'],
1070
+				'event'         => $atts['event'],
1071
+			),
1072 1072
 			'post_name'         => $atts['form_id'] . '_email_' . $atts['email_key'],
1073
-        );
1073
+		);
1074 1074
 
1075
-        // Add more fields to the new notification
1076
-        $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1077
-        foreach ( $add_fields as $add_field ) {
1075
+		// Add more fields to the new notification
1076
+		$add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1077
+		foreach ( $add_fields as $add_field ) {
1078 1078
 			if ( isset( $notification[ $add_field ] ) ) {
1079 1079
 				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1080
-            } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1080
+			} else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1081 1081
 				$new_notification['post_content'][ $add_field ] = 0;
1082
-            } else {
1082
+			} else {
1083 1083
 				$new_notification['post_content'][ $add_field ] = '';
1084
-            }
1085
-            unset( $add_field );
1086
-        }
1084
+			}
1085
+			unset( $add_field );
1086
+		}
1087 1087
 
1088 1088
 		// Set reply to
1089 1089
 		$new_notification['post_content']['reply_to'] = $atts['reply_to'];
1090 1090
 
1091
-        // Set from
1091
+		// Set from
1092 1092
 		if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) {
1093 1093
 			$new_notification['post_content']['from'] = ( empty( $atts['reply_to_name'] ) ? '[sitename]' : $atts['reply_to_name'] ) . ' <' . ( empty( $atts['reply_to'] ) ? '[admin_email]' : $atts['reply_to'] ) . '>';
1094
-        }
1095
-    }
1094
+		}
1095
+	}
1096 1096
 
1097 1097
 	/**
1098
-	* Switch field IDs in pre-2.0 email conditional logic
1099
-	*
1100
-	* @param $post_content array, pass by reference
1101
-	*/
1098
+	 * Switch field IDs in pre-2.0 email conditional logic
1099
+	 *
1100
+	 * @param $post_content array, pass by reference
1101
+	 */
1102 1102
 	private static function switch_email_contition_field_ids( &$post_content ) {
1103 1103
 		// Switch field IDs in conditional logic
1104 1104
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
@@ -1111,36 +1111,36 @@  discard block
 block discarded – undo
1111 1111
 		}
1112 1112
 	}
1113 1113
 
1114
-    private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1115
-        if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1116
-            // migrate autoresponder
1117
-
1118
-            $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1119
-            if ( strpos($email_field, '|') ) {
1120
-                // data from entries field
1121
-                $email_field = explode('|', $email_field);
1122
-                if ( isset($email_field[1]) ) {
1123
-                    $email_field = $email_field[1];
1124
-                }
1125
-            }
1126
-            if ( is_numeric($email_field) && ! empty($email_field) ) {
1114
+	private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1115
+		if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1116
+			// migrate autoresponder
1117
+
1118
+			$email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1119
+			if ( strpos($email_field, '|') ) {
1120
+				// data from entries field
1121
+				$email_field = explode('|', $email_field);
1122
+				if ( isset($email_field[1]) ) {
1123
+					$email_field = $email_field[1];
1124
+				}
1125
+			}
1126
+			if ( is_numeric($email_field) && ! empty($email_field) ) {
1127 1127
 				$email_field = '[' . $email_field . ']';
1128
-            }
1129
-
1130
-            $notification = $form_options;
1131
-            $new_notification2 = array(
1132
-                'post_content'  => array(
1133
-                    'email_message' => $notification['ar_email_message'],
1134
-                    'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1135
-                    'email_to'      => $email_field,
1136
-                    'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1137
-                    'inc_user_info' => 0,
1138
-                ),
1128
+			}
1129
+
1130
+			$notification = $form_options;
1131
+			$new_notification2 = array(
1132
+				'post_content'  => array(
1133
+					'email_message' => $notification['ar_email_message'],
1134
+					'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1135
+					'email_to'      => $email_field,
1136
+					'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1137
+					'inc_user_info' => 0,
1138
+				),
1139 1139
 				'post_name'     => $form_id . '_email_' . count( $notifications ),
1140
-            );
1140
+			);
1141 1141
 
1142
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1143
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1142
+			$reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1143
+			$reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1144 1144
 
1145 1145
 			if ( ! empty( $reply_to ) ) {
1146 1146
 				$new_notification2['post_content']['reply_to'] = $reply_to;
@@ -1150,9 +1150,9 @@  discard block
 block discarded – undo
1150 1150
 				$new_notification2['post_content']['from'] = ( empty( $reply_to_name ) ? '[sitename]' : $reply_to_name ) . ' <' . ( empty( $reply_to ) ? '[admin_email]' : $reply_to ) . '>';
1151 1151
 			}
1152 1152
 
1153
-            $notifications[] = $new_notification2;
1154
-            unset( $new_notification2 );
1155
-        }
1156
-    }
1153
+			$notifications[] = $new_notification2;
1154
+			unset( $new_notification2 );
1155
+		}
1156
+	}
1157 1157
 }
1158 1158
 
Please login to merge, or discard this patch.
Spacing   +164 added lines, -164 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,21 +67,21 @@  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
     }
81 81
 
82 82
 	public static function import_xml_terms( $terms, $imported ) {
83 83
         foreach ( $terms as $t ) {
84
-			if ( term_exists((string) $t->term_slug, (string) $t->term_taxonomy) ) {
84
+			if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) {
85 85
 			    continue;
86 86
 			}
87 87
 
@@ -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 );
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
                 'default_template' => (int) $item->default_template,
139 139
                 'editable'      => (int) $item->editable,
140 140
                 'status'        => (string) $item->status,
141
-                'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0,
142
-                'created_at'    => date('Y-m-d H:i:s', strtotime((string) $item->created_at)),
141
+                'parent_form_id' => isset( $item->parent_form_id ) ? (int) $item->parent_form_id : 0,
142
+                'created_at'    => date( 'Y-m-d H:i:s', strtotime( (string) $item->created_at ) ),
143 143
             );
144 144
 
145
-            $form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
145
+            $form['options'] = FrmAppHelper::maybe_json_decode( $form['options'] );
146 146
 
147 147
 			self::update_custom_style_setting_on_import( $form );
148 148
 
@@ -152,35 +152,35 @@  discard block
 block discarded – undo
152 152
                 $edit_query['created_at'] = $form['created_at'];
153 153
             }
154 154
 
155
-            $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
155
+            $edit_query = apply_filters( 'frm_match_xml_form', $edit_query, $form );
156 156
 
157
-            $this_form = FrmForm::getAll($edit_query, '', 1);
158
-            unset($edit_query);
157
+            $this_form = FrmForm::getAll( $edit_query, '', 1 );
158
+            unset( $edit_query );
159 159
 
160 160
             if ( ! empty( $this_form ) ) {
161 161
                 $old_id = $form_id = $this_form->id;
162
-                FrmForm::update($form_id, $form );
163
-                $imported['updated']['forms']++;
162
+                FrmForm::update( $form_id, $form );
163
+                $imported['updated']['forms'] ++;
164 164
                 // Keep track of whether this specific form was updated or not
165
-				$imported['form_status'][ $form_id ] = 'updated';
165
+				$imported['form_status'][$form_id] = 'updated';
166 166
 
167 167
 				$form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' );
168 168
                 $old_fields = array();
169 169
                 foreach ( $form_fields as $f ) {
170
-					$old_fields[ $f->id ] = $f;
171
-					$old_fields[ $f->field_key ] = $f->id;
172
-                    unset($f);
170
+					$old_fields[$f->id] = $f;
171
+					$old_fields[$f->field_key] = $f->id;
172
+                    unset( $f );
173 173
                 }
174 174
                 $form_fields = $old_fields;
175
-                unset($old_fields);
175
+                unset( $old_fields );
176 176
             } else {
177 177
                 $old_id = false;
178 178
                 //form does not exist, so create it
179 179
 				$form_id = FrmForm::create( $form );
180 180
                 if ( $form_id ) {
181
-                    $imported['imported']['forms']++;
181
+                    $imported['imported']['forms'] ++;
182 182
                     // Keep track of whether this specific form was updated or not
183
-					$imported['form_status'][ $form_id ] = 'imported';
183
+					$imported['form_status'][$form_id] = 'imported';
184 184
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
185 185
                 }
186 186
             }
@@ -190,23 +190,23 @@  discard block
 block discarded – undo
190 190
     		// Delete any fields attached to this form that were not included in the template
191 191
     		if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
192 192
 				foreach ( $form_fields as $field ) {
193
-                    if ( is_object($field) ) {
194
-                        FrmField::destroy($field->id);
193
+                    if ( is_object( $field ) ) {
194
+                        FrmField::destroy( $field->id );
195 195
                     }
196
-                    unset($field);
196
+                    unset( $field );
197 197
                 }
198
-                unset($form_fields);
198
+                unset( $form_fields );
199 199
             }
200 200
 
201 201
 		    // Update field ids/keys to new ones
202 202
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
203 203
 
204
-			$imported['forms'][ (int) $item->id ] = $form_id;
204
+			$imported['forms'][(int) $item->id] = $form_id;
205 205
 
206 206
             // Send pre 2.0 form options through function that creates actions
207 207
             self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
208 208
 
209
-		    unset($form, $item);
209
+		    unset( $form, $item );
210 210
 		}
211 211
 
212 212
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 		$regular_forms = array();
226 226
 
227 227
 		foreach ( $forms as $form ) {
228
-			$parent_form_id = isset( $form->parent_form_id) ? (int) $form->parent_form_id : 0;
228
+			$parent_form_id = isset( $form->parent_form_id ) ? (int) $form->parent_form_id : 0;
229 229
 
230 230
 			if ( $parent_form_id ) {
231 231
 				$child_forms[] = $form;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	*/
248 248
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
249 249
 		if ( $parent_form_id ) {
250
-			$child_forms[ $form_id ] = $parent_form_id;
250
+			$child_forms[$form_id] = $parent_form_id;
251 251
 		}
252 252
 	}
253 253
 
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
263 263
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
264 264
 
265
-			if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) {
265
+			if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) {
266 266
 				// Update all children with this old parent_form_id
267
-				$new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ];
267
+				$new_parent_form_id = (int) $imported_forms[$old_parent_form_id];
268 268
 
269 269
 				FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) );
270 270
 			}
@@ -287,49 +287,49 @@  discard block
 block discarded – undo
287 287
 		        'name'          => (string) $field->name,
288 288
 		        'description'   => (string) $field->description,
289 289
 		        'type'          => (string) $field->type,
290
-		        'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
290
+		        'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value ),
291 291
 		        'field_order'   => (int) $field->field_order,
292 292
 		        'form_id'       => (int) $form_id,
293 293
 		        'required'      => (int) $field->required,
294
-		        'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
294
+		        'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options ),
295 295
 				'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
296 296
 		    );
297 297
 
298
-		    if ( is_array($f['default_value']) && in_array($f['type'], array(
298
+		    if ( is_array( $f['default_value'] ) && in_array( $f['type'], array(
299 299
 		        'text', 'email', 'url', 'textarea',
300
-		        'number','phone', 'date', 'time',
300
+		        'number', 'phone', 'date', 'time',
301 301
 		        'hidden', 'password', 'tag', 'image',
302
-		    )) ) {
303
-		        if ( count($f['default_value']) === 1 ) {
302
+		    ) ) ) {
303
+		        if ( count( $f['default_value'] ) === 1 ) {
304 304
 					$f['default_value'] = '[' . reset( $f['default_value'] ) . ']';
305 305
 		        } else {
306
-		            $f['default_value'] = reset($f['default_value']);
306
+		            $f['default_value'] = reset( $f['default_value'] );
307 307
 		        }
308 308
 		    }
309 309
 
310 310
 			self::maybe_update_form_select( $f, $imported );
311 311
 
312
-			if ( ! empty($this_form) ) {
312
+			if ( ! empty( $this_form ) ) {
313 313
 				// check for field to edit by field id
314
-				if ( isset( $form_fields[ $f['id'] ] ) ) {
314
+				if ( isset( $form_fields[$f['id']] ) ) {
315 315
 					FrmField::update( $f['id'], $f );
316
-					$imported['updated']['fields']++;
316
+					$imported['updated']['fields'] ++;
317 317
 
318
-					unset( $form_fields[ $f['id'] ] );
318
+					unset( $form_fields[$f['id']] );
319 319
 
320 320
 					//unset old field key
321
-					if ( isset( $form_fields[ $f['field_key'] ] ) ) {
322
-						unset( $form_fields[ $f['field_key'] ] );
321
+					if ( isset( $form_fields[$f['field_key']] ) ) {
322
+						unset( $form_fields[$f['field_key']] );
323 323
 					}
324
-				} else if ( isset( $form_fields[ $f['field_key'] ] ) ) {
324
+				} else if ( isset( $form_fields[$f['field_key']] ) ) {
325 325
 					// check for field to edit by field key
326
-					unset($f['id']);
326
+					unset( $f['id'] );
327 327
 
328
-					FrmField::update( $form_fields[ $f['field_key'] ], $f );
329
-					$imported['updated']['fields']++;
328
+					FrmField::update( $form_fields[$f['field_key']], $f );
329
+					$imported['updated']['fields'] ++;
330 330
 
331
-					unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id
332
-					unset( $form_fields[ $f['field_key'] ] ); //unset old field key
331
+					unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id
332
+					unset( $form_fields[$f['field_key']] ); //unset old field key
333 333
 				} else {
334 334
 					// if no matching field id or key in this form, create the field
335 335
 					self::maybe_update_in_section_variable( $in_section, $f );
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 		if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) {
383 383
 			if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) {
384 384
 				$form_select = $f['field_options']['form_select'];
385
-				if ( isset( $imported['forms'][ $form_select ] ) ) {
386
-					$f['field_options']['form_select'] = $imported['forms'][ $form_select ];
385
+				if ( isset( $imported['forms'][$form_select] ) ) {
386
+					$f['field_options']['form_select'] = $imported['forms'][$form_select];
387 387
 				}
388 388
 			}
389 389
 		}
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 	private static function create_imported_field( $f, &$imported ) {
400 400
 		$new_id = FrmField::create( $f );
401 401
 		if ( $new_id != false ) {
402
-			$imported['imported']['fields']++;
402
+			$imported['imported']['fields'] ++;
403 403
 		}
404 404
 	}
405 405
 
@@ -460,8 +460,8 @@  discard block
 block discarded – undo
460 460
 				'post_id'       => (int) $item->post_id,
461 461
 				'post_parent'   => (int) $item->post_parent,
462 462
 				'menu_order'    => (int) $item->menu_order,
463
-				'post_content'  => FrmFieldsHelper::switch_field_ids((string) $item->content),
464
-				'post_excerpt'  => FrmFieldsHelper::switch_field_ids((string) $item->excerpt),
463
+				'post_content'  => FrmFieldsHelper::switch_field_ids( (string) $item->content ),
464
+				'post_excerpt'  => FrmFieldsHelper::switch_field_ids( (string) $item->excerpt ),
465 465
 				'is_sticky'     => (string) $item->is_sticky,
466 466
 				'comment_status' => (string) $item->comment_status,
467 467
 				'post_date'     => (string) $item->post_date,
@@ -472,9 +472,9 @@  discard block
 block discarded – undo
472 472
 			);
473 473
 
474 474
             $old_id = $post['post_id'];
475
-            self::populate_post($post, $item, $imported);
475
+            self::populate_post( $post, $item, $imported );
476 476
 
477
-			unset($item);
477
+			unset( $item );
478 478
 
479 479
 			$post_id = false;
480 480
             if ( $post['post_type'] == $form_action_type ) {
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 				if ( $action_control ) {
483 483
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
484 484
 				}
485
-                unset($action_control);
485
+                unset( $action_control );
486 486
             } else if ( $post['post_type'] == 'frm_styles' ) {
487 487
                 // Properly encode post content before inserting the post
488 488
                 $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
@@ -495,26 +495,26 @@  discard block
 block discarded – undo
495 495
                 $post_id = wp_insert_post( $post );
496 496
             }
497 497
 
498
-            if ( ! is_numeric($post_id) ) {
498
+            if ( ! is_numeric( $post_id ) ) {
499 499
                 continue;
500 500
             }
501 501
 
502
-            self::update_postmeta($post, $post_id);
502
+            self::update_postmeta( $post, $post_id );
503 503
 
504 504
             $this_type = 'posts';
505
-			if ( isset( $post_types[ $post['post_type'] ] ) ) {
506
-				$this_type = $post_types[ $post['post_type'] ];
505
+			if ( isset( $post_types[$post['post_type']] ) ) {
506
+				$this_type = $post_types[$post['post_type']];
507 507
             }
508 508
 
509
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
510
-                $imported['updated'][ $this_type ]++;
509
+            if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) {
510
+                $imported['updated'][$this_type] ++;
511 511
             } else {
512
-                $imported['imported'][ $this_type ]++;
512
+                $imported['imported'][$this_type] ++;
513 513
             }
514 514
 
515
-            unset($post);
515
+            unset( $post );
516 516
 
517
-			$imported['posts'][ (int) $old_id ] = $post_id;
517
+			$imported['posts'][(int) $old_id] = $post_id;
518 518
 		}
519 519
 
520 520
 		self::maybe_update_stylesheet( $imported );
@@ -523,23 +523,23 @@  discard block
 block discarded – undo
523 523
     }
524 524
 
525 525
     private static function populate_post( &$post, $item, $imported ) {
526
-		if ( isset($item->attachment_url) ) {
526
+		if ( isset( $item->attachment_url ) ) {
527 527
 			$post['attachment_url'] = (string) $item->attachment_url;
528 528
 		}
529 529
 
530
-		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
530
+		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) {
531 531
 		    // update to new form id
532
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
532
+		    $post['menu_order'] = $imported['forms'][(int) $post['menu_order']];
533 533
 		}
534 534
 
535 535
 		foreach ( $item->postmeta as $meta ) {
536
-		    self::populate_postmeta($post, $meta, $imported);
537
-			unset($meta);
536
+		    self::populate_postmeta( $post, $meta, $imported );
537
+			unset( $meta );
538 538
 		}
539 539
 
540
-        self::populate_taxonomies($post, $item);
540
+        self::populate_taxonomies( $post, $item );
541 541
 
542
-        self::maybe_editing_post($post);
542
+        self::maybe_editing_post( $post );
543 543
     }
544 544
 
545 545
     private static function populate_postmeta( &$post, $meta, $imported ) {
@@ -551,27 +551,27 @@  discard block
 block discarded – undo
551 551
 		);
552 552
 
553 553
 		//switch old form and field ids to new ones
554
-		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
555
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
554
+		if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) {
555
+		    $m['value'] = $imported['forms'][(int) $m['value']];
556 556
 		} else {
557
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
557
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
558 558
 
559
-		    if ( ! empty($frm_duplicate_ids) ) {
559
+		    if ( ! empty( $frm_duplicate_ids ) ) {
560 560
 
561 561
 		        if ( $m['key'] == 'frm_dyncontent' ) {
562
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
562
+		            $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] );
563 563
     		    } else if ( $m['key'] == 'frm_options' ) {
564 564
 
565 565
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
566
-						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
567
-							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
566
+						if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) {
567
+							$m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]];
568 568
     		            }
569 569
     		        }
570 570
 
571 571
                     $check_dup_array = array();
572 572
     		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
573
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
574
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
573
+    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) {
574
+    		                $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']];
575 575
     		            } else if ( is_array( $m['value']['order_by'] ) ) {
576 576
                             $check_dup_array[] = 'order_by';
577 577
     		            }
@@ -582,22 +582,22 @@  discard block
 block discarded – undo
582 582
     		        }
583 583
 
584 584
                     foreach ( $check_dup_array as $check_k ) {
585
-						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
586
-							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
587
-								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
585
+						foreach ( (array) $m['value'][$check_k] as $mk => $mv ) {
586
+							if ( isset( $frm_duplicate_ids[$mv] ) ) {
587
+								$m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv];
588 588
 		                    }
589
-		                    unset($mk, $mv);
589
+		                    unset( $mk, $mv );
590 590
 		                }
591 591
                     }
592 592
     		    }
593 593
 		    }
594 594
 		}
595 595
 
596
-		if ( ! is_array($m['value']) ) {
597
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
596
+		if ( ! is_array( $m['value'] ) ) {
597
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
598 598
 		}
599 599
 
600
-		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
600
+		$post['postmeta'][(string) $meta->meta_key] = $m['value'];
601 601
     }
602 602
 
603 603
     /**
@@ -613,23 +613,23 @@  discard block
 block discarded – undo
613 613
             }
614 614
 
615 615
 		    $taxonomy = (string) $att['domain'];
616
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
616
+		    if ( is_taxonomy_hierarchical( $taxonomy ) ) {
617 617
 		        $name = (string) $att['nicename'];
618
-		        $h_term = get_term_by('slug', $name, $taxonomy);
618
+		        $h_term = get_term_by( 'slug', $name, $taxonomy );
619 619
 		        if ( $h_term ) {
620 620
 		            $name = $h_term->term_id;
621 621
 		        }
622
-		        unset($h_term);
622
+		        unset( $h_term );
623 623
 		    } else {
624 624
 		        $name = (string) $c;
625 625
 		    }
626 626
 
627
-			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
628
-				$post['tax_input'][ $taxonomy ] = array();
627
+			if ( ! isset( $post['tax_input'][$taxonomy] ) ) {
628
+				$post['tax_input'][$taxonomy] = array();
629 629
 			}
630 630
 
631
-			$post['tax_input'][ $taxonomy ][] = $name;
632
-		    unset($name);
631
+			$post['tax_input'][$taxonomy][] = $name;
632
+		    unset( $name );
633 633
 		}
634 634
     }
635 635
 
@@ -646,29 +646,29 @@  discard block
 block discarded – undo
646 646
 
647 647
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
648 648
 		    $match_by['include'] = $post['post_id'];
649
-		    unset($match_by['name']);
649
+		    unset( $match_by['name'] );
650 650
 		}
651 651
 
652
-		$editing = get_posts($match_by);
652
+		$editing = get_posts( $match_by );
653 653
 
654
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
654
+        if ( ! empty( $editing ) && current( $editing )->post_date == $post['post_date'] ) {
655 655
             // set the id of the post to edit
656
-            $post['ID'] = current($editing)->ID;
656
+            $post['ID'] = current( $editing )->ID;
657 657
         }
658 658
     }
659 659
 
660 660
     private static function update_postmeta( &$post, $post_id ) {
661 661
         foreach ( $post['postmeta'] as $k => $v ) {
662 662
             if ( '_edit_last' == $k ) {
663
-                $v = FrmAppHelper::get_user_id_param($v);
663
+                $v = FrmAppHelper::get_user_id_param( $v );
664 664
             } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
665 665
                 //change the attachment ID
666
-                $v = FrmProXMLHelper::get_file_id($v);
666
+                $v = FrmProXMLHelper::get_file_id( $v );
667 667
             }
668 668
 
669
-            update_post_meta($post_id, $k, $v);
669
+            update_post_meta( $post_id, $k, $v );
670 670
 
671
-            unset($k, $v);
671
+            unset( $k, $v );
672 672
         }
673 673
     }
674 674
 
@@ -685,13 +685,13 @@  discard block
 block discarded – undo
685 685
      * @param string $message
686 686
      */
687 687
 	public static function parse_message( $result, &$message, &$errors ) {
688
-        if ( is_wp_error($result) ) {
688
+        if ( is_wp_error( $result ) ) {
689 689
             $errors[] = $result->get_error_message();
690 690
         } else if ( ! $result ) {
691 691
             return;
692 692
         }
693 693
 
694
-        if ( ! is_array($result) ) {
694
+        if ( ! is_array( $result ) ) {
695 695
             $message = is_string( $result ) ? $result : print_r( $result, 1 );
696 696
             return;
697 697
         }
@@ -703,20 +703,20 @@  discard block
 block discarded – undo
703 703
 
704 704
         $message = '<ul>';
705 705
         foreach ( $result as $type => $results ) {
706
-			if ( ! isset( $t_strings[ $type ] ) ) {
706
+			if ( ! isset( $t_strings[$type] ) ) {
707 707
                 // only print imported and updated
708 708
                 continue;
709 709
             }
710 710
 
711 711
             $s_message = array();
712 712
             foreach ( $results as $k => $m ) {
713
-                self::item_count_message($m, $k, $s_message);
714
-                unset($k, $m);
713
+                self::item_count_message( $m, $k, $s_message );
714
+                unset( $k, $m );
715 715
             }
716 716
 
717
-            if ( ! empty($s_message) ) {
718
-				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
719
-                $message .= implode(', ', $s_message);
717
+            if ( ! empty( $s_message ) ) {
718
+				$message .= '<li><strong>' . $t_strings[$type] . ':</strong> ';
719
+                $message .= implode( ', ', $s_message );
720 720
                 $message .= '</li>';
721 721
             }
722 722
         }
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
             'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
746 746
         );
747 747
 
748
-		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
748
+		$s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type );
749 749
     }
750 750
 
751 751
 	/**
@@ -777,14 +777,14 @@  discard block
 block discarded – undo
777 777
 	}
778 778
 
779 779
 	public static function cdata( $str ) {
780
-	    $str = maybe_unserialize($str);
781
-	    if ( is_array($str) ) {
782
-	        $str = json_encode($str);
780
+	    $str = maybe_unserialize( $str );
781
+	    if ( is_array( $str ) ) {
782
+	        $str = json_encode( $str );
783 783
 		} else if ( seems_utf8( $str ) == false ) {
784 784
 			$str = utf8_encode( $str );
785 785
 		}
786 786
 
787
-        if ( is_numeric($str) ) {
787
+        if ( is_numeric( $str ) ) {
788 788
             return $str;
789 789
         }
790 790
 
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
     * @param string $post_type
830 830
     */
831 831
     private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
832
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
832
+        if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) {
833 833
             return;
834 834
         }
835 835
 
@@ -850,10 +850,10 @@  discard block
 block discarded – undo
850 850
         );
851 851
 
852 852
         foreach ( $post_settings as $post_setting ) {
853
-			if ( isset( $form_options[ $post_setting ] ) ) {
854
-				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
853
+			if ( isset( $form_options[$post_setting] ) ) {
854
+				$new_action['post_content'][$post_setting] = $form_options[$post_setting];
855 855
             }
856
-            unset($post_setting);
856
+            unset( $post_setting );
857 857
         }
858 858
 
859 859
 		$new_action['event'] = array( 'create', 'update' );
@@ -867,7 +867,7 @@  discard block
 block discarded – undo
867 867
 
868 868
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
869 869
         }
870
-        $new_action['post_content'] = json_encode($new_action['post_content']);
870
+        $new_action['post_content'] = json_encode( $new_action['post_content'] );
871 871
 
872 872
         $exists = get_posts( array(
873 873
             'name'          => $new_action['post_name'],
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
         if ( ! $exists ) {
880 880
 			// this isn't an email, but we need to use a class that will always be included
881 881
 			FrmAppHelper::save_json_post( $new_action );
882
-            $imported['imported']['actions']++;
882
+            $imported['imported']['actions'] ++;
883 883
         }
884 884
     }
885 885
 
@@ -911,11 +911,11 @@  discard block
 block discarded – undo
911 911
         foreach ( $post_content as $key => $setting ) {
912 912
             if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
913 913
                 // Replace old IDs with new IDs
914
-				$post_content[ $key ] = str_replace( $old, $new, $setting );
914
+				$post_content[$key] = str_replace( $old, $new, $setting );
915 915
             } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
916 916
                 foreach ( $setting as $k => $val ) {
917 917
                     // Replace old IDs with new IDs
918
-					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
918
+					$post_content[$key][$k] = str_replace( $old, $new, $val );
919 919
                 }
920 920
             }
921 921
             unset( $key, $setting );
@@ -938,14 +938,14 @@  discard block
 block discarded – undo
938 938
         // Migrate autoresponders
939 939
         self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
940 940
 
941
-        if (  empty( $notifications ) ) {
941
+        if ( empty( $notifications ) ) {
942 942
             return;
943 943
         }
944 944
 
945 945
         foreach ( $notifications as $new_notification ) {
946 946
             $new_notification['post_type']      = $post_type;
947 947
             $new_notification['post_excerpt']   = 'email';
948
-			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
948
+			$new_notification['post_title'] = __( 'Email Notification', 'formidable' );
949 949
             $new_notification['menu_order']     = $form_id;
950 950
             $new_notification['post_status']    = 'publish';
951 951
 
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
 				// Switch all other field IDs in email
959 959
                 $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
960 960
             }
961
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
961
+            $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
962 962
 
963 963
             $exists = get_posts( array(
964 964
                 'name'          => $new_notification['post_name'],
@@ -967,11 +967,11 @@  discard block
 block discarded – undo
967 967
                 'numberposts'   => 1,
968 968
             ) );
969 969
 
970
-            if ( empty($exists) ) {
970
+            if ( empty( $exists ) ) {
971 971
 				FrmAppHelper::save_json_post( $new_notification );
972
-                $imported['imported']['actions']++;
972
+                $imported['imported']['actions'] ++;
973 973
             }
974
-            unset($new_notification);
974
+            unset( $new_notification );
975 975
         }
976 976
     }
977 977
 
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
985 985
         }
986 986
 
987
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
987
+        if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) {
988 988
             foreach ( $form_options['notification'] as $email_key => $notification ) {
989 989
 
990 990
                 $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
@@ -1012,12 +1012,12 @@  discard block
 block discarded – undo
1012 1012
         // Format the reply to email and name
1013 1013
         $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
1014 1014
         foreach ( $reply_fields as $f => $val ) {
1015
-			if ( isset( $notification[ $f ] ) ) {
1016
-				$atts[ $f ] = $notification[ $f ];
1017
-				if ( 'custom' == $notification[ $f ] ) {
1018
-					$atts[ $f ] = $notification[ 'cust_' . $f ];
1019
-				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
1020
-					$atts[ $f ] = '[' . $atts[ $f ] . ']';
1015
+			if ( isset( $notification[$f] ) ) {
1016
+				$atts[$f] = $notification[$f];
1017
+				if ( 'custom' == $notification[$f] ) {
1018
+					$atts[$f] = $notification['cust_' . $f];
1019
+				} else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) {
1020
+					$atts[$f] = '[' . $atts[$f] . ']';
1021 1021
                 }
1022 1022
             }
1023 1023
             unset( $f, $val );
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 		$atts['event'] = array( 'create' );
1028 1028
         if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1029 1029
             $atts['event'][] = 'update';
1030
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1030
+        } else if ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) {
1031 1031
 			$atts['event'] = array( 'update' );
1032 1032
         }
1033 1033
     }
@@ -1048,18 +1048,18 @@  discard block
 block discarded – undo
1048 1048
         foreach ( $atts['email_to'] as $key => $email_field ) {
1049 1049
 
1050 1050
             if ( is_numeric( $email_field ) ) {
1051
-				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1051
+				$atts['email_to'][$key] = '[' . $email_field . ']';
1052 1052
             }
1053 1053
 
1054
-            if ( strpos( $email_field, '|') ) {
1054
+            if ( strpos( $email_field, '|' ) ) {
1055 1055
                 $email_opt = explode( '|', $email_field );
1056 1056
                 if ( isset( $email_opt[0] ) ) {
1057
-					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1057
+					$atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1058 1058
                 }
1059 1059
                 unset( $email_opt );
1060 1060
             }
1061 1061
         }
1062
-        $atts['email_to'] = implode(', ', $atts['email_to']);
1062
+        $atts['email_to'] = implode( ', ', $atts['email_to'] );
1063 1063
     }
1064 1064
 
1065 1065
     private static function setup_new_notification( &$new_notification, $notification, $atts ) {
@@ -1075,12 +1075,12 @@  discard block
 block discarded – undo
1075 1075
         // Add more fields to the new notification
1076 1076
         $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1077 1077
         foreach ( $add_fields as $add_field ) {
1078
-			if ( isset( $notification[ $add_field ] ) ) {
1079
-				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1078
+			if ( isset( $notification[$add_field] ) ) {
1079
+				$new_notification['post_content'][$add_field] = $notification[$add_field];
1080 1080
             } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1081
-				$new_notification['post_content'][ $add_field ] = 0;
1081
+				$new_notification['post_content'][$add_field] = 0;
1082 1082
             } else {
1083
-				$new_notification['post_content'][ $add_field ] = '';
1083
+				$new_notification['post_content'][$add_field] = '';
1084 1084
             }
1085 1085
             unset( $add_field );
1086 1086
         }
@@ -1104,26 +1104,26 @@  discard block
 block discarded – undo
1104 1104
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
1105 1105
 			foreach ( $post_content['conditions'] as $email_key => $val ) {
1106 1106
 				if ( is_numeric( $email_key ) ) {
1107
-					$post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1107
+					$post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1108 1108
 				}
1109
-				unset( $email_key, $val);
1109
+				unset( $email_key, $val );
1110 1110
 			}
1111 1111
 		}
1112 1112
 	}
1113 1113
 
1114 1114
     private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1115
-        if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1115
+        if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) {
1116 1116
             // migrate autoresponder
1117 1117
 
1118
-            $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1119
-            if ( strpos($email_field, '|') ) {
1118
+            $email_field = isset( $form_options['ar_email_to'] ) ? $form_options['ar_email_to'] : 0;
1119
+            if ( strpos( $email_field, '|' ) ) {
1120 1120
                 // data from entries field
1121
-                $email_field = explode('|', $email_field);
1122
-                if ( isset($email_field[1]) ) {
1121
+                $email_field = explode( '|', $email_field );
1122
+                if ( isset( $email_field[1] ) ) {
1123 1123
                     $email_field = $email_field[1];
1124 1124
                 }
1125 1125
             }
1126
-            if ( is_numeric($email_field) && ! empty($email_field) ) {
1126
+            if ( is_numeric( $email_field ) && ! empty( $email_field ) ) {
1127 1127
 				$email_field = '[' . $email_field . ']';
1128 1128
             }
1129 1129
 
@@ -1131,16 +1131,16 @@  discard block
 block discarded – undo
1131 1131
             $new_notification2 = array(
1132 1132
                 'post_content'  => array(
1133 1133
                     'email_message' => $notification['ar_email_message'],
1134
-                    'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1134
+                    'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '',
1135 1135
                     'email_to'      => $email_field,
1136
-                    'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1136
+                    'plain_text'    => isset( $notification['ar_plain_text'] ) ? $notification['ar_plain_text'] : 0,
1137 1137
                     'inc_user_info' => 0,
1138 1138
                 ),
1139 1139
 				'post_name'     => $form_id . '_email_' . count( $notifications ),
1140 1140
             );
1141 1141
 
1142
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1143
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1142
+            $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : '';
1143
+            $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : '';
1144 1144
 
1145 1145
 			if ( ! empty( $reply_to ) ) {
1146 1146
 				$new_notification2['post_content']['reply_to'] = $reply_to;
Please login to merge, or discard this patch.