Completed
Push — master ( 54eb7f...5d7e04 )
by Jamie
03:28
created
classes/helpers/FrmAppHelper.php 3 patches
Doc Comments   +10 added lines, -1 removed lines patch added patch discarded remove patch
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 	 * Sanitize the value, and allow some HTML
363 363
 	 * @since 2.0
364 364
 	 * @param string $value
365
-	 * @param array $allowed
365
+	 * @param string[] $allowed
366 366
 	 * @return string
367 367
 	 */
368 368
 	public static function kses( $value, $allowed = array() ) {
@@ -779,6 +779,9 @@  discard block
 block discarded – undo
779 779
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
780 780
     }
781 781
 
782
+	/**
783
+	 * @param string $function
784
+	 */
782 785
 	public static function recursive_function_map( $value, $function ) {
783 786
 		if ( is_array( $value ) ) {
784 787
 			$original_function = $function;
@@ -1198,6 +1201,9 @@  discard block
 block discarded – undo
1198 1201
         return $sub . (($len < $original_len) ? $continue : '');
1199 1202
     }
1200 1203
 
1204
+	/**
1205
+	 * @param string[] $function_names
1206
+	 */
1201 1207
 	public static function mb_function( $function_names, $args ) {
1202 1208
 		$mb_function_name = $function_names[0];
1203 1209
 		$function_name = $function_names[1];
@@ -1231,6 +1237,9 @@  discard block
 block discarded – undo
1231 1237
         return $formatted;
1232 1238
     }
1233 1239
 
1240
+	/**
1241
+	 * @param string $time_format
1242
+	 */
1234 1243
 	private static function add_time_to_date( $time_format, $date ) {
1235 1244
 		if ( empty( $time_format ) ) {
1236 1245
 			$time_format = get_option('time_format');
Please login to merge, or discard this patch.
Indentation   +1041 added lines, -1041 removed lines patch added patch discarded remove patch
@@ -12,50 +12,50 @@  discard block
 block discarded – undo
12 12
 	 */
13 13
 	public static $plug_version = '2.02.06';
14 14
 
15
-    /**
16
-     * @since 1.07.02
17
-     *
18
-     * @param none
19
-     * @return string The version of this plugin
20
-     */
21
-    public static function plugin_version() {
22
-        return self::$plug_version;
23
-    }
24
-
25
-    public static function plugin_folder() {
26
-        return basename(self::plugin_path());
27
-    }
28
-
29
-    public static function plugin_path() {
30
-        return dirname(dirname(dirname(__FILE__)));
31
-    }
32
-
33
-    public static function plugin_url() {
34
-        //prevously FRM_URL constant
15
+	/**
16
+	 * @since 1.07.02
17
+	 *
18
+	 * @param none
19
+	 * @return string The version of this plugin
20
+	 */
21
+	public static function plugin_version() {
22
+		return self::$plug_version;
23
+	}
24
+
25
+	public static function plugin_folder() {
26
+		return basename(self::plugin_path());
27
+	}
28
+
29
+	public static function plugin_path() {
30
+		return dirname(dirname(dirname(__FILE__)));
31
+	}
32
+
33
+	public static function plugin_url() {
34
+		//prevously FRM_URL constant
35 35
 		return plugins_url( '', self::plugin_path() . '/formidable.php' );
36
-    }
36
+	}
37 37
 
38 38
 	public static function relative_plugin_url() {
39 39
 		return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() );
40 40
 	}
41 41
 
42
-    /**
43
-     * @return string Site URL
44
-     */
45
-    public static function site_url() {
46
-        return site_url();
47
-    }
48
-
49
-    /**
50
-     * Get the name of this site
51
-     * Used for [sitename] shortcode
52
-     *
53
-     * @since 2.0
54
-     * @return string
55
-     */
56
-    public static function site_name() {
57
-        return get_option('blogname');
58
-    }
42
+	/**
43
+	 * @return string Site URL
44
+	 */
45
+	public static function site_url() {
46
+		return site_url();
47
+	}
48
+
49
+	/**
50
+	 * Get the name of this site
51
+	 * Used for [sitename] shortcode
52
+	 *
53
+	 * @since 2.0
54
+	 * @return string
55
+	 */
56
+	public static function site_name() {
57
+		return get_option('blogname');
58
+	}
59 59
 
60 60
 	public static function make_affiliate_url( $url ) {
61 61
 		$affiliate_id = self::get_affiliate();
@@ -76,83 +76,83 @@  discard block
 block discarded – undo
76 76
 		return $affiliate_id;
77 77
 	}
78 78
 
79
-    /**
80
-     * Get the Formidable settings
81
-     *
82
-     * @since 2.0
83
-     *
84
-     * @param None
85
-     * @return FrmSettings $frm_setings
86
-     */
87
-    public static function get_settings() {
88
-        global $frm_settings;
89
-        if ( empty($frm_settings) ) {
90
-            $frm_settings = new FrmSettings();
91
-        }
92
-        return $frm_settings;
93
-    }
79
+	/**
80
+	 * Get the Formidable settings
81
+	 *
82
+	 * @since 2.0
83
+	 *
84
+	 * @param None
85
+	 * @return FrmSettings $frm_setings
86
+	 */
87
+	public static function get_settings() {
88
+		global $frm_settings;
89
+		if ( empty($frm_settings) ) {
90
+			$frm_settings = new FrmSettings();
91
+		}
92
+		return $frm_settings;
93
+	}
94 94
 
95 95
 	public static function get_menu_name() {
96 96
 		$frm_settings = FrmAppHelper::get_settings();
97 97
 		return $frm_settings->menu;
98 98
 	}
99 99
 
100
-    /**
101
-     * Show a message in place of pro features
102
-     *
103
-     * @since 2.0
104
-     */
100
+	/**
101
+	 * Show a message in place of pro features
102
+	 *
103
+	 * @since 2.0
104
+	 */
105 105
 	public static function update_message() {
106 106
 		_deprecated_function( __FUNCTION__, '2.0.19' );
107
-    }
108
-
109
-    public static function pro_is_installed() {
110
-        return apply_filters('frm_pro_installed', false);
111
-    }
112
-
113
-    /**
114
-     * Check for certain page in Formidable settings
115
-     *
116
-     * @since 2.0
117
-     *
118
-     * @param string $page The name of the page to check
119
-     * @return boolean
120
-     */
107
+	}
108
+
109
+	public static function pro_is_installed() {
110
+		return apply_filters('frm_pro_installed', false);
111
+	}
112
+
113
+	/**
114
+	 * Check for certain page in Formidable settings
115
+	 *
116
+	 * @since 2.0
117
+	 *
118
+	 * @param string $page The name of the page to check
119
+	 * @return boolean
120
+	 */
121 121
 	public static function is_admin_page( $page = 'formidable' ) {
122
-        global $pagenow;
122
+		global $pagenow;
123 123
 		$get_page = self::simple_get( 'page', 'sanitize_title' );
124
-        if ( $pagenow ) {
124
+		if ( $pagenow ) {
125 125
 			return $pagenow == 'admin.php' && $get_page == $page;
126
-        }
126
+		}
127 127
 
128 128
 		return is_admin() && $get_page == $page;
129
-    }
130
-
131
-    /**
132
-     * Check for the form preview page
133
-     *
134
-     * @since 2.0
135
-     *
136
-     * @param None
137
-     * @return boolean
138
-     */
139
-    public static function is_preview_page() {
140
-        global $pagenow;
129
+	}
130
+
131
+	/**
132
+	 * Check for the form preview page
133
+	 *
134
+	 * @since 2.0
135
+	 *
136
+	 * @param None
137
+	 * @return boolean
138
+	 */
139
+	public static function is_preview_page() {
140
+		global $pagenow;
141 141
 		$action = FrmAppHelper::simple_get( 'action', 'sanitize_title' );
142 142
 		return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
143
-    }
144
-
145
-    /**
146
-     * Check for ajax except the form preview page
147
-     *
148
-     * @since 2.0
149
-     *
150
-     * @param None
151
-     * @return boolean
152
-     */
153
-    public static function doing_ajax() {
154
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
155
-    }
143
+	}
144
+
145
+	/**
146
+	 * Check for ajax except the form preview page
147
+	 *
148
+	 * @since 2.0
149
+	 *
150
+	 * @param None
151
+	 * @return boolean
152
+	 */
153
+	public static function doing_ajax() {
154
+		return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
155
+	}
156 156
 
157 157
 	/**
158 158
 	 * @since 2.0.8
@@ -162,102 +162,102 @@  discard block
 block discarded – undo
162 162
 		return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
163 163
 	}
164 164
 
165
-    /**
166
-     * Check if on an admin page
167
-     *
168
-     * @since 2.0
169
-     *
170
-     * @param None
171
-     * @return boolean
172
-     */
173
-    public static function is_admin() {
174
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
175
-    }
176
-
177
-    /**
178
-     * Check if value contains blank value or empty array
179
-     *
180
-     * @since 2.0
181
-     * @param mixed $value - value to check
165
+	/**
166
+	 * Check if on an admin page
167
+	 *
168
+	 * @since 2.0
169
+	 *
170
+	 * @param None
171
+	 * @return boolean
172
+	 */
173
+	public static function is_admin() {
174
+		return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
175
+	}
176
+
177
+	/**
178
+	 * Check if value contains blank value or empty array
179
+	 *
180
+	 * @since 2.0
181
+	 * @param mixed $value - value to check
182 182
 	 * @param string
183
-     * @return boolean
184
-     */
185
-    public static function is_empty_value( $value, $empty = '' ) {
186
-        return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
187
-    }
188
-
189
-    public static function is_not_empty_value( $value, $empty = '' ) {
190
-        return ! self::is_empty_value( $value, $empty );
191
-    }
192
-
193
-    /**
194
-     * Get any value from the $_SERVER
195
-     *
196
-     * @since 2.0
197
-     * @param string $value
198
-     * @return string
199
-     */
183
+	 * @return boolean
184
+	 */
185
+	public static function is_empty_value( $value, $empty = '' ) {
186
+		return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
187
+	}
188
+
189
+	public static function is_not_empty_value( $value, $empty = '' ) {
190
+		return ! self::is_empty_value( $value, $empty );
191
+	}
192
+
193
+	/**
194
+	 * Get any value from the $_SERVER
195
+	 *
196
+	 * @since 2.0
197
+	 * @param string $value
198
+	 * @return string
199
+	 */
200 200
 	public static function get_server_value( $value ) {
201
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
202
-    }
203
-
204
-    /**
205
-     * Check for the IP address in several places
206
-     * Used by [ip] shortcode
207
-     *
208
-     * @return string The IP address of the current user
209
-     */
210
-    public static function get_ip_address() {
201
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
202
+	}
203
+
204
+	/**
205
+	 * Check for the IP address in several places
206
+	 * Used by [ip] shortcode
207
+	 *
208
+	 * @return string The IP address of the current user
209
+	 */
210
+	public static function get_ip_address() {
211 211
 		$ip = '';
212
-        foreach ( array(
213
-            'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
214
-            'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
215
-        ) as $key ) {
216
-            if ( ! isset( $_SERVER[ $key ] ) ) {
217
-                continue;
218
-            }
219
-
220
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
221
-                $ip = trim($ip); // just to be safe
222
-
223
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
224
-                    return $ip;
225
-                }
226
-            }
227
-        }
212
+		foreach ( array(
213
+			'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
214
+			'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
215
+		) as $key ) {
216
+			if ( ! isset( $_SERVER[ $key ] ) ) {
217
+				continue;
218
+			}
219
+
220
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
221
+				$ip = trim($ip); // just to be safe
222
+
223
+				if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
224
+					return $ip;
225
+				}
226
+			}
227
+		}
228 228
 
229 229
 		return sanitize_text_field( $ip );
230
-    }
230
+	}
231 231
 
232
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
233
-        if ( strpos($param, '[') ) {
234
-            $params = explode('[', $param);
235
-            $param = $params[0];
236
-        }
232
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
233
+		if ( strpos($param, '[') ) {
234
+			$params = explode('[', $param);
235
+			$param = $params[0];
236
+		}
237 237
 
238 238
 		if ( $src == 'get' ) {
239
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
240
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
241
-                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
242
-            }
239
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
240
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
241
+				$value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
242
+			}
243 243
 			self::sanitize_value( $sanitize, $value );
244 244
 		} else {
245
-            $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
246
-        }
245
+			$value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
246
+		}
247 247
 
248 248
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
249
-            foreach ( $params as $k => $p ) {
250
-                if ( ! $k || ! is_array($value) ) {
251
-                    continue;
252
-                }
249
+			foreach ( $params as $k => $p ) {
250
+				if ( ! $k || ! is_array($value) ) {
251
+					continue;
252
+				}
253 253
 
254
-                $p = trim($p, ']');
255
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
256
-            }
257
-        }
254
+				$p = trim($p, ']');
255
+				$value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
256
+			}
257
+		}
258 258
 
259
-        return $value;
260
-    }
259
+		return $value;
260
+	}
261 261
 
262 262
 	public static function get_post_param( $param, $default = '', $sanitize = '' ) {
263 263
 		return self::get_simple_request( array( 'type' => 'post', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	 */
274 274
 	public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) {
275 275
 		return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
276
-    }
276
+	}
277 277
 
278 278
 	/**
279 279
 	 * Get a GET/POST/REQUEST value and sanitize it
@@ -309,12 +309,12 @@  discard block
 block discarded – undo
309 309
 	}
310 310
 
311 311
 	/**
312
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
313
-	*
314
-	* @since 2.0.8
315
-	* @param string $value
316
-	* @return string $value
317
-	*/
312
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
313
+	 *
314
+	 * @since 2.0.8
315
+	 * @param string $value
316
+	 * @return string $value
317
+	 */
318 318
 	public static function preserve_backslashes( $value ) {
319 319
 		// If backslashes have already been added, don't add them again
320 320
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -336,14 +336,14 @@  discard block
 block discarded – undo
336 336
 		}
337 337
 	}
338 338
 
339
-    public static function sanitize_request( $sanitize_method, &$values ) {
340
-        $temp_values = $values;
341
-        foreach ( $temp_values as $k => $val ) {
342
-            if ( isset( $sanitize_method[ $k ] ) ) {
339
+	public static function sanitize_request( $sanitize_method, &$values ) {
340
+		$temp_values = $values;
341
+		foreach ( $temp_values as $k => $val ) {
342
+			if ( isset( $sanitize_method[ $k ] ) ) {
343 343
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
344
-            }
345
-        }
346
-    }
344
+			}
345
+		}
346
+	}
347 347
 
348 348
 	public static function sanitize_array( &$values ) {
349 349
 		$temp_values = $values;
@@ -361,12 +361,12 @@  discard block
 block discarded – undo
361 361
 	 */
362 362
 	public static function kses( $value, $allowed = array() ) {
363 363
 		$html = array(
364
-		    'a' => array(
364
+			'a' => array(
365 365
 				'href'  => array(),
366 366
 				'title' => array(),
367 367
 				'id'    => array(),
368 368
 				'class' => array(),
369
-		    ),
369
+			),
370 370
 		);
371 371
 
372 372
 		$allowed_html = array();
@@ -377,126 +377,126 @@  discard block
 block discarded – undo
377 377
 		return wp_kses( $value, $allowed_html );
378 378
 	}
379 379
 
380
-    /**
381
-     * Used when switching the action for a bulk action
382
-     * @since 2.0
383
-     */
384
-    public static function remove_get_action() {
385
-        if ( ! isset($_GET) ) {
386
-            return;
387
-        }
380
+	/**
381
+	 * Used when switching the action for a bulk action
382
+	 * @since 2.0
383
+	 */
384
+	public static function remove_get_action() {
385
+		if ( ! isset($_GET) ) {
386
+			return;
387
+		}
388 388
 
389
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
390
-        if ( ! empty( $new_action ) ) {
389
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
390
+		if ( ! empty( $new_action ) ) {
391 391
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
392
-        }
393
-    }
394
-
395
-    /**
396
-     * Check the WP query for a parameter
397
-     *
398
-     * @since 2.0
399
-     * @return string|array
400
-     */
401
-    public static function get_query_var( $value, $param ) {
402
-        if ( $value != '' ) {
403
-            return $value;
404
-        }
405
-
406
-        global $wp_query;
407
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
408
-            $value = $wp_query->query_vars[ $param ];
409
-        }
410
-
411
-        return $value;
412
-    }
413
-
414
-    /**
415
-     * @param string $type
416
-     */
417
-    public static function trigger_hook_load( $type, $object = null ) {
418
-        // only load the form hooks once
392
+		}
393
+	}
394
+
395
+	/**
396
+	 * Check the WP query for a parameter
397
+	 *
398
+	 * @since 2.0
399
+	 * @return string|array
400
+	 */
401
+	public static function get_query_var( $value, $param ) {
402
+		if ( $value != '' ) {
403
+			return $value;
404
+		}
405
+
406
+		global $wp_query;
407
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
408
+			$value = $wp_query->query_vars[ $param ];
409
+		}
410
+
411
+		return $value;
412
+	}
413
+
414
+	/**
415
+	 * @param string $type
416
+	 */
417
+	public static function trigger_hook_load( $type, $object = null ) {
418
+		// only load the form hooks once
419 419
 		$hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
420
-        if ( ! $hooks_loaded ) {
420
+		if ( ! $hooks_loaded ) {
421 421
 			do_action( 'frm_load_' . $type . '_hooks' );
422
-        }
423
-    }
424
-
425
-    /**
426
-     * Check cache before fetching values and saving to cache
427
-     *
428
-     * @since 2.0
429
-     *
430
-     * @param string $cache_key The unique name for this cache
431
-     * @param string $group The name of the cache group
432
-     * @param string $query If blank, don't run a db call
433
-     * @param string $type The wpdb function to use with this query
434
-     * @return mixed $results The cache or query results
435
-     */
436
-    public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
437
-        $results = wp_cache_get($cache_key, $group);
438
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
439
-            return $results;
440
-        }
441
-
442
-        if ( 'get_posts' == $type ) {
443
-            $results = get_posts($query);
422
+		}
423
+	}
424
+
425
+	/**
426
+	 * Check cache before fetching values and saving to cache
427
+	 *
428
+	 * @since 2.0
429
+	 *
430
+	 * @param string $cache_key The unique name for this cache
431
+	 * @param string $group The name of the cache group
432
+	 * @param string $query If blank, don't run a db call
433
+	 * @param string $type The wpdb function to use with this query
434
+	 * @return mixed $results The cache or query results
435
+	 */
436
+	public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
437
+		$results = wp_cache_get($cache_key, $group);
438
+		if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
439
+			return $results;
440
+		}
441
+
442
+		if ( 'get_posts' == $type ) {
443
+			$results = get_posts($query);
444 444
 		} else if ( 'get_associative_results' == $type ) {
445 445
 			global $wpdb;
446 446
 			$results = $wpdb->get_results( $query, OBJECT_K );
447
-        } else {
448
-            global $wpdb;
449
-            $results = $wpdb->{$type}($query);
450
-        }
447
+		} else {
448
+			global $wpdb;
449
+			$results = $wpdb->{$type}($query);
450
+		}
451 451
 
452 452
 		if ( ! self::prevent_caching() ) {
453 453
 			wp_cache_set( $cache_key, $results, $group, $time );
454 454
 		}
455 455
 
456
-        return $results;
457
-    }
456
+		return $results;
457
+	}
458 458
 
459
-    /**
460
-     * Data that should be stored for a long time can be stored in a transient.
461
-     * First check the cache, then check the transient
462
-     * @since 2.0
463
-     * @return mixed The cached value or false
464
-     */
459
+	/**
460
+	 * Data that should be stored for a long time can be stored in a transient.
461
+	 * First check the cache, then check the transient
462
+	 * @since 2.0
463
+	 * @return mixed The cached value or false
464
+	 */
465 465
 	public static function check_cache_and_transient( $cache_key ) {
466
-        // check caching layer first
467
-        $results = self::check_cache( $cache_key );
468
-        if ( $results ) {
469
-            return $results;
470
-        }
471
-
472
-        // then check the transient
473
-        $results = get_transient($cache_key);
474
-        if ( $results ) {
475
-            wp_cache_set($cache_key, $results);
476
-        }
477
-
478
-        return $results;
479
-    }
480
-
481
-    /**
482
-     * @since 2.0
483
-     * @param string $cache_key
484
-     */
466
+		// check caching layer first
467
+		$results = self::check_cache( $cache_key );
468
+		if ( $results ) {
469
+			return $results;
470
+		}
471
+
472
+		// then check the transient
473
+		$results = get_transient($cache_key);
474
+		if ( $results ) {
475
+			wp_cache_set($cache_key, $results);
476
+		}
477
+
478
+		return $results;
479
+	}
480
+
481
+	/**
482
+	 * @since 2.0
483
+	 * @param string $cache_key
484
+	 */
485 485
 	public static function delete_cache_and_transient( $cache_key, $group = 'default' ) {
486 486
 		delete_transient($cache_key);
487 487
 		wp_cache_delete( $cache_key, $group );
488 488
 	}
489 489
 
490
-    /**
491
-     * Delete all caching in a single group
492
-     *
493
-     * @since 2.0
494
-     *
495
-     * @param string $group The name of the cache group
496
-     * @return boolean True or False
497
-     */
490
+	/**
491
+	 * Delete all caching in a single group
492
+	 *
493
+	 * @since 2.0
494
+	 *
495
+	 * @param string $group The name of the cache group
496
+	 * @return boolean True or False
497
+	 */
498 498
 	public static function cache_delete_group( $group ) {
499
-    	global $wp_object_cache;
499
+		global $wp_object_cache;
500 500
 
501 501
 		if ( is_callable( array( $wp_object_cache, '__get' ) ) ) {
502 502
 			$group_cache = $wp_object_cache->__get('cache');
@@ -514,37 +514,37 @@  discard block
 block discarded – undo
514 514
 			// When using redis: if ( is_callable( array( $wp_object_cache, 'redis_status' ) ) && $wp_object_cache->redis_status() )
515 515
 		}
516 516
 
517
-    	return false;
518
-    }
517
+		return false;
518
+	}
519 519
 
520
-    /**
521
-     * Check a value from a shortcode to see if true or false.
522
-     * True when value is 1, true, 'true', 'yes'
523
-     *
524
-     * @since 1.07.10
525
-     *
526
-     * @param string $value The value to compare
527
-     * @return boolean True or False
528
-     */
520
+	/**
521
+	 * Check a value from a shortcode to see if true or false.
522
+	 * True when value is 1, true, 'true', 'yes'
523
+	 *
524
+	 * @since 1.07.10
525
+	 *
526
+	 * @param string $value The value to compare
527
+	 * @return boolean True or False
528
+	 */
529 529
 	public static function is_true( $value ) {
530
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
531
-    }
530
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
531
+	}
532 532
 
533
-    /**
534
-     * Used to filter shortcode in text widgets
535
-     */
536
-    public static function widget_text_filter_callback( $matches ) {
537
-        return do_shortcode( $matches[0] );
538
-    }
533
+	/**
534
+	 * Used to filter shortcode in text widgets
535
+	 */
536
+	public static function widget_text_filter_callback( $matches ) {
537
+		return do_shortcode( $matches[0] );
538
+	}
539 539
 
540
-    public static function get_pages() {
540
+	public static function get_pages() {
541 541
 		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
542
-    }
542
+	}
543 543
 
544
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
545
-        $pages = self::get_pages();
544
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
545
+		$pages = self::get_pages();
546 546
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
547
-    ?>
547
+	?>
548 548
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
549 549
             <option value=""> </option>
550 550
             <?php foreach ( $pages as $page ) { ?>
@@ -554,108 +554,108 @@  discard block
 block discarded – undo
554 554
             <?php } ?>
555 555
         </select>
556 556
     <?php
557
-    }
557
+	}
558 558
 
559 559
 	public static function post_edit_link( $post_id ) {
560
-        $post = get_post($post_id);
561
-        if ( $post ) {
560
+		$post = get_post($post_id);
561
+		if ( $post ) {
562 562
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
563 563
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
564
-        }
565
-        return '';
566
-    }
564
+		}
565
+		return '';
566
+	}
567 567
 
568 568
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
569
-    ?>
569
+	?>
570 570
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
571
-            echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
572
-            ?> class="frm_multiselect">
571
+			echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
572
+			?> class="frm_multiselect">
573 573
             <?php self::roles_options($capability); ?>
574 574
         </select>
575 575
     <?php
576
-    }
576
+	}
577 577
 
578 578
 	public static function roles_options( $capability ) {
579
-        global $frm_vars;
580
-        if ( isset($frm_vars['editable_roles']) ) {
581
-            $editable_roles = $frm_vars['editable_roles'];
582
-        } else {
583
-            $editable_roles = get_editable_roles();
584
-            $frm_vars['editable_roles'] = $editable_roles;
585
-        }
586
-
587
-        foreach ( $editable_roles as $role => $details ) {
588
-            $name = translate_user_role($details['name'] ); ?>
579
+		global $frm_vars;
580
+		if ( isset($frm_vars['editable_roles']) ) {
581
+			$editable_roles = $frm_vars['editable_roles'];
582
+		} else {
583
+			$editable_roles = get_editable_roles();
584
+			$frm_vars['editable_roles'] = $editable_roles;
585
+		}
586
+
587
+		foreach ( $editable_roles as $role => $details ) {
588
+			$name = translate_user_role($details['name'] ); ?>
589 589
         <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
590 590
 <?php
591
-            unset($role, $details);
592
-        }
593
-    }
591
+			unset($role, $details);
592
+		}
593
+	}
594 594
 
595 595
 	public static function frm_capabilities( $type = 'auto' ) {
596
-        $cap = array(
597
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
598
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
599
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
600
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
601
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
602
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
603
-        );
596
+		$cap = array(
597
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
598
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
599
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
600
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
601
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
602
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
603
+		);
604 604
 
605 605
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
606
-            return $cap;
607
-        }
606
+			return $cap;
607
+		}
608 608
 
609
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
610
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
611
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
612
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
609
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
610
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
611
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
612
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
613 613
 
614
-        return $cap;
615
-    }
614
+		return $cap;
615
+	}
616 616
 
617 617
 	public static function user_has_permission( $needed_role ) {
618
-        if ( $needed_role == '-1' ) {
619
-            return false;
618
+		if ( $needed_role == '-1' ) {
619
+			return false;
620 620
 		}
621 621
 
622
-        // $needed_role will be equal to blank if "Logged-in users" is selected
623
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
624
-            return true;
625
-        }
622
+		// $needed_role will be equal to blank if "Logged-in users" is selected
623
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
624
+			return true;
625
+		}
626 626
 
627
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
628
-        foreach ( $roles as $role ) {
627
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
628
+		foreach ( $roles as $role ) {
629 629
 			if ( current_user_can( $role ) ) {
630
-        		return true;
630
+				return true;
631 631
 			}
632
-        	if ( $role == $needed_role ) {
633
-        		break;
632
+			if ( $role == $needed_role ) {
633
+				break;
634 634
 			}
635
-        }
636
-        return false;
637
-    }
638
-
639
-    /**
640
-     * Make sure administrators can see Formidable menu
641
-     *
642
-     * @since 2.0
643
-     */
644
-    public static function maybe_add_permissions() {
635
+		}
636
+		return false;
637
+	}
638
+
639
+	/**
640
+	 * Make sure administrators can see Formidable menu
641
+	 *
642
+	 * @since 2.0
643
+	 */
644
+	public static function maybe_add_permissions() {
645 645
 		self::force_capability( 'frm_view_entries' );
646 646
 
647
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
648
-            return;
649
-        }
647
+		if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
648
+			return;
649
+		}
650 650
 
651 651
 		$user_id = get_current_user_id();
652 652
 		$user = new WP_User( $user_id );
653
-        $frm_roles = self::frm_capabilities();
654
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
653
+		$frm_roles = self::frm_capabilities();
654
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
655 655
 			$user->add_cap( $frm_role );
656
-            unset($frm_role, $frm_role_description);
657
-        }
658
-    }
656
+			unset($frm_role, $frm_role_description);
657
+		}
658
+	}
659 659
 
660 660
 	/**
661 661
 	 * Make sure admins have permission to see the menu items
@@ -671,28 +671,28 @@  discard block
 block discarded – undo
671 671
 		}
672 672
 	}
673 673
 
674
-    /**
675
-     * Check if the user has permision for action.
676
-     * Return permission message and stop the action if no permission
677
-     * @since 2.0
678
-     * @param string $permission
679
-     */
674
+	/**
675
+	 * Check if the user has permision for action.
676
+	 * Return permission message and stop the action if no permission
677
+	 * @since 2.0
678
+	 * @param string $permission
679
+	 */
680 680
 	public static function permission_check( $permission, $show_message = 'show' ) {
681
-        $permission_error = self::permission_nonce_error($permission);
682
-        if ( $permission_error !== false ) {
683
-            if ( 'hide' == $show_message ) {
684
-                $permission_error = '';
685
-            }
686
-            wp_die($permission_error);
687
-        }
688
-    }
689
-
690
-    /**
691
-     * Check user permission and nonce
692
-     * @since 2.0
693
-     * @param string $permission
694
-     * @return false|string The permission message or false if allowed
695
-     */
681
+		$permission_error = self::permission_nonce_error($permission);
682
+		if ( $permission_error !== false ) {
683
+			if ( 'hide' == $show_message ) {
684
+				$permission_error = '';
685
+			}
686
+			wp_die($permission_error);
687
+		}
688
+	}
689
+
690
+	/**
691
+	 * Check user permission and nonce
692
+	 * @since 2.0
693
+	 * @param string $permission
694
+	 * @return false|string The permission message or false if allowed
695
+	 */
696 696
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
697 697
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
698 698
 			$frm_settings = self::get_settings();
@@ -700,23 +700,23 @@  discard block
 block discarded – undo
700 700
 		}
701 701
 
702 702
 		$error = false;
703
-        if ( empty($nonce_name) ) {
704
-            return $error;
705
-        }
703
+		if ( empty($nonce_name) ) {
704
+			return $error;
705
+		}
706 706
 
707
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
708
-            $frm_settings = self::get_settings();
709
-            $error = $frm_settings->admin_permission;
710
-        }
707
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
708
+			$frm_settings = self::get_settings();
709
+			$error = $frm_settings->admin_permission;
710
+		}
711 711
 
712
-        return $error;
713
-    }
712
+		return $error;
713
+	}
714 714
 
715
-    public static function checked( $values, $current ) {
715
+	public static function checked( $values, $current ) {
716 716
 		if ( self::check_selected( $values, $current ) ) {
717
-            echo ' checked="checked"';
717
+			echo ' checked="checked"';
718 718
 		}
719
-    }
719
+	}
720 720
 
721 721
 	public static function check_selected( $values, $current ) {
722 722
 		$values = self::recursive_function_map( $values, 'trim' );
@@ -726,50 +726,50 @@  discard block
 block discarded – undo
726 726
 		return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current );
727 727
 	}
728 728
 
729
-    /**
730
-    * Check if current field option is an "other" option
731
-    *
732
-    * @since 2.0
733
-    *
734
-    * @param string $opt_key
735
-    * @return boolean Returns true if current field option is an "Other" option
736
-    */
737
-    public static function is_other_opt( $opt_key ) {
738
-        _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
739
-        return FrmFieldsHelper::is_other_opt( $opt_key );
740
-    }
741
-
742
-    /**
743
-    * Get value that belongs in "Other" text box
744
-    *
745
-    * @since 2.0
746
-    *
747
-    * @param string $opt_key
748
-    * @param array $field
749
-    * @return string $other_val
750
-    */
751
-    public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
729
+	/**
730
+	 * Check if current field option is an "other" option
731
+	 *
732
+	 * @since 2.0
733
+	 *
734
+	 * @param string $opt_key
735
+	 * @return boolean Returns true if current field option is an "Other" option
736
+	 */
737
+	public static function is_other_opt( $opt_key ) {
738
+		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
739
+		return FrmFieldsHelper::is_other_opt( $opt_key );
740
+	}
741
+
742
+	/**
743
+	 * Get value that belongs in "Other" text box
744
+	 *
745
+	 * @since 2.0
746
+	 *
747
+	 * @param string $opt_key
748
+	 * @param array $field
749
+	 * @return string $other_val
750
+	 */
751
+	public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
752 752
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' );
753 753
 		return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) );
754
-    }
755
-
756
-    /**
757
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
758
-    * Intended for front-end use
759
-    *
760
-    * @since 2.0
761
-    *
762
-    * @param array $field
763
-    * @param boolean $other_opt
764
-    * @param string $checked
765
-    * @param array $args should include opt_key and field name
766
-    * @return string $other_val
767
-    */
768
-    public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
754
+	}
755
+
756
+	/**
757
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
758
+	 * Intended for front-end use
759
+	 *
760
+	 * @since 2.0
761
+	 *
762
+	 * @param array $field
763
+	 * @param boolean $other_opt
764
+	 * @param string $checked
765
+	 * @param array $args should include opt_key and field name
766
+	 * @return string $other_val
767
+	 */
768
+	public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
769 769
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' );
770 770
 		$args['field'] = $field;
771 771
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
772
-    }
772
+	}
773 773
 
774 774
 	public static function recursive_function_map( $value, $function ) {
775 775
 		if ( is_array( $value ) ) {
@@ -799,24 +799,24 @@  discard block
 block discarded – undo
799 799
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
800 800
 	}
801 801
 
802
-    /**
803
-     * Flatten a multi-dimensional array
804
-     */
802
+	/**
803
+	 * Flatten a multi-dimensional array
804
+	 */
805 805
 	public static function array_flatten( $array, $keys = 'keep' ) {
806
-        $return = array();
807
-        foreach ( $array as $key => $value ) {
808
-            if ( is_array($value) ) {
806
+		$return = array();
807
+		foreach ( $array as $key => $value ) {
808
+			if ( is_array($value) ) {
809 809
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
810
-            } else {
810
+			} else {
811 811
 				if ( $keys == 'keep' ) {
812 812
 					$return[ $key ] = $value;
813 813
 				} else {
814 814
 					$return[] = $value;
815 815
 				}
816
-            }
817
-        }
818
-        return $return;
819
-    }
816
+			}
817
+		}
818
+		return $return;
819
+	}
820 820
 
821 821
 	public static function esc_textarea( $text, $is_rich_text = false ) {
822 822
 		$safe_text = str_replace( '&quot;', '"', $text );
@@ -827,308 +827,308 @@  discard block
 block discarded – undo
827 827
 		return apply_filters( 'esc_textarea', $safe_text, $text );
828 828
 	}
829 829
 
830
-    /**
831
-     * Add auto paragraphs to text areas
832
-     * @since 2.0
833
-     */
830
+	/**
831
+	 * Add auto paragraphs to text areas
832
+	 * @since 2.0
833
+	 */
834 834
 	public static function use_wpautop( $content ) {
835
-        if ( apply_filters('frm_use_wpautop', true) ) {
836
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
837
-        }
838
-        return $content;
839
-    }
835
+		if ( apply_filters('frm_use_wpautop', true) ) {
836
+			$content = wpautop(str_replace( '<br>', '<br />', $content));
837
+		}
838
+		return $content;
839
+	}
840 840
 
841 841
 	public static function replace_quotes( $val ) {
842
-        //Replace double quotes
842
+		//Replace double quotes
843 843
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
844
-        //Replace single quotes
845
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
846
-        return $val;
847
-    }
848
-
849
-    /**
850
-     * @since 2.0
851
-     * @return string The base Google APIS url for the current version of jQuery UI
852
-     */
853
-    public static function jquery_ui_base_url() {
844
+		//Replace single quotes
845
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
846
+		return $val;
847
+	}
848
+
849
+	/**
850
+	 * @since 2.0
851
+	 * @return string The base Google APIS url for the current version of jQuery UI
852
+	 */
853
+	public static function jquery_ui_base_url() {
854 854
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core');
855
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
856
-        return $url;
857
-    }
855
+		$url = apply_filters('frm_jquery_ui_base_url', $url);
856
+		return $url;
857
+	}
858 858
 
859
-    /**
860
-     * @param string $handle
861
-     */
859
+	/**
860
+	 * @param string $handle
861
+	 */
862 862
 	public static function script_version( $handle ) {
863
-        global $wp_scripts;
864
-    	if ( ! $wp_scripts ) {
865
-    	    return false;
866
-    	}
863
+		global $wp_scripts;
864
+		if ( ! $wp_scripts ) {
865
+			return false;
866
+		}
867 867
 
868
-        $ver = 0;
868
+		$ver = 0;
869 869
 
870
-        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
871
-            return $ver;
872
-        }
870
+		if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
871
+			return $ver;
872
+		}
873 873
 
874
-        $query = $wp_scripts->registered[ $handle ];
875
-    	if ( is_object( $query ) ) {
876
-    	    $ver = $query->ver;
877
-    	}
874
+		$query = $wp_scripts->registered[ $handle ];
875
+		if ( is_object( $query ) ) {
876
+			$ver = $query->ver;
877
+		}
878 878
 
879
-    	return $ver;
880
-    }
879
+		return $ver;
880
+	}
881 881
 
882 882
 	public static function js_redirect( $url ) {
883 883
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
884
-    }
884
+	}
885 885
 
886 886
 	public static function get_user_id_param( $user_id ) {
887
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
888
-            return $user_id;
889
-        }
887
+		if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
888
+			return $user_id;
889
+		}
890 890
 
891 891
 		if ( $user_id == 'current' ) {
892 892
 			$user_id = get_current_user_id();
893 893
 		} else {
894
-            if ( is_email($user_id) ) {
895
-                $user = get_user_by('email', $user_id);
896
-            } else {
897
-                $user = get_user_by('login', $user_id);
898
-            }
894
+			if ( is_email($user_id) ) {
895
+				$user = get_user_by('email', $user_id);
896
+			} else {
897
+				$user = get_user_by('login', $user_id);
898
+			}
899 899
 
900
-            if ( $user ) {
901
-                $user_id = $user->ID;
902
-            }
903
-            unset($user);
904
-        }
900
+			if ( $user ) {
901
+				$user_id = $user->ID;
902
+			}
903
+			unset($user);
904
+		}
905 905
 
906
-        return $user_id;
907
-    }
906
+		return $user_id;
907
+	}
908 908
 
909 909
 	public static function get_file_contents( $filename, $atts = array() ) {
910
-        if ( ! is_file($filename) ) {
911
-            return false;
912
-        }
913
-
914
-        extract($atts);
915
-        ob_start();
916
-        include($filename);
917
-        $contents = ob_get_contents();
918
-        ob_end_clean();
919
-        return $contents;
920
-    }
921
-
922
-    /**
923
-     * @param string $table_name
924
-     * @param string $column
910
+		if ( ! is_file($filename) ) {
911
+			return false;
912
+		}
913
+
914
+		extract($atts);
915
+		ob_start();
916
+		include($filename);
917
+		$contents = ob_get_contents();
918
+		ob_end_clean();
919
+		return $contents;
920
+	}
921
+
922
+	/**
923
+	 * @param string $table_name
924
+	 * @param string $column
925 925
 	 * @param int $id
926 926
 	 * @param int $num_chars
927
-     */
928
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
929
-        $key = '';
927
+	 */
928
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
929
+		$key = '';
930 930
 
931
-        if ( ! empty( $name ) ) {
932
-            $key = sanitize_key($name);
933
-        }
931
+		if ( ! empty( $name ) ) {
932
+			$key = sanitize_key($name);
933
+		}
934 934
 
935 935
 		if ( empty( $key ) ) {
936
-            $max_slug_value = pow(36, $num_chars);
937
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
938
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
939
-        }
936
+			$max_slug_value = pow(36, $num_chars);
937
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
938
+			$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
939
+		}
940 940
 
941 941
 		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
942 942
 			$key = $key . 'a';
943
-        }
943
+		}
944 944
 
945 945
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
946 946
 
947
-        if ( $key_check || is_numeric($key_check) ) {
948
-            $suffix = 2;
947
+		if ( $key_check || is_numeric($key_check) ) {
948
+			$suffix = 2;
949 949
 			do {
950 950
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
951 951
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
952 952
 				$suffix++;
953 953
 			} while ($key_check || is_numeric($key_check));
954 954
 			$key = $alt_post_name;
955
-        }
956
-        return $key;
957
-    }
958
-
959
-    /**
960
-     * Editing a Form or Entry
961
-     * @param string $table
962
-     * @return bool|array
963
-     */
964
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
965
-        if ( ! $record ) {
966
-            return false;
967
-        }
968
-
969
-        if ( empty($post_values) ) {
970
-            $post_values = stripslashes_deep($_POST);
971
-        }
955
+		}
956
+		return $key;
957
+	}
958
+
959
+	/**
960
+	 * Editing a Form or Entry
961
+	 * @param string $table
962
+	 * @return bool|array
963
+	 */
964
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
965
+		if ( ! $record ) {
966
+			return false;
967
+		}
968
+
969
+		if ( empty($post_values) ) {
970
+			$post_values = stripslashes_deep($_POST);
971
+		}
972 972
 
973 973
 		$values = array( 'id' => $record->id, 'fields' => array() );
974 974
 
975 975
 		foreach ( array( 'name', 'description' ) as $var ) {
976
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
976
+			$default_val = isset($record->{$var}) ? $record->{$var} : '';
977 977
 			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
978
-            unset($var, $default_val);
979
-        }
980
-
981
-        $values['description'] = self::use_wpautop($values['description']);
982
-        $frm_settings = self::get_settings();
983
-        $is_form_builder = self::is_admin_page('formidable' );
984
-
985
-        foreach ( (array) $fields as $field ) {
986
-            // Make sure to filter default values (for placeholder text), but not on the form builder page
987
-            if ( ! $is_form_builder ) {
988
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
989
-            }
978
+			unset($var, $default_val);
979
+		}
980
+
981
+		$values['description'] = self::use_wpautop($values['description']);
982
+		$frm_settings = self::get_settings();
983
+		$is_form_builder = self::is_admin_page('formidable' );
984
+
985
+		foreach ( (array) $fields as $field ) {
986
+			// Make sure to filter default values (for placeholder text), but not on the form builder page
987
+			if ( ! $is_form_builder ) {
988
+				$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
989
+			}
990 990
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
991 991
 			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
992
-        }
992
+		}
993 993
 
994
-        self::fill_form_opts($record, $table, $post_values, $values);
994
+		self::fill_form_opts($record, $table, $post_values, $values);
995 995
 
996
-        if ( $table == 'entries' ) {
997
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
998
-        } else if ( $table == 'forms' ) {
999
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1000
-        }
996
+		if ( $table == 'entries' ) {
997
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
998
+		} else if ( $table == 'forms' ) {
999
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1000
+		}
1001 1001
 
1002
-        return $values;
1003
-    }
1002
+		return $values;
1003
+	}
1004 1004
 
1005 1005
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
1006
-        $post_values = $args['post_values'];
1007
-
1008
-        if ( $args['default'] ) {
1009
-            $meta_value = $field->default_value;
1010
-        } else {
1011
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1012
-                if ( ! isset($field->field_options['custom_field']) ) {
1013
-                    $field->field_options['custom_field'] = '';
1014
-                }
1006
+		$post_values = $args['post_values'];
1007
+
1008
+		if ( $args['default'] ) {
1009
+			$meta_value = $field->default_value;
1010
+		} else {
1011
+			if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1012
+				if ( ! isset($field->field_options['custom_field']) ) {
1013
+					$field->field_options['custom_field'] = '';
1014
+				}
1015 1015
 				$meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) );
1016
-            } else {
1016
+			} else {
1017 1017
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1018
-            }
1019
-        }
1018
+			}
1019
+		}
1020 1020
 
1021 1021
 		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1022
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1023
-
1024
-        $field_array = array(
1025
-            'id'            => $field->id,
1026
-            'value'         => $new_value,
1027
-            'default_value' => $field->default_value,
1028
-            'name'          => $field->name,
1029
-            'description'   => $field->description,
1030
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1031
-            'options'       => $field->options,
1032
-            'required'      => $field->required,
1033
-            'field_key'     => $field->field_key,
1034
-            'field_order'   => $field->field_order,
1035
-            'form_id'       => $field->form_id,
1022
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1023
+
1024
+		$field_array = array(
1025
+			'id'            => $field->id,
1026
+			'value'         => $new_value,
1027
+			'default_value' => $field->default_value,
1028
+			'name'          => $field->name,
1029
+			'description'   => $field->description,
1030
+			'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1031
+			'options'       => $field->options,
1032
+			'required'      => $field->required,
1033
+			'field_key'     => $field->field_key,
1034
+			'field_order'   => $field->field_order,
1035
+			'form_id'       => $field->form_id,
1036 1036
 			'parent_form_id' => $args['parent_form_id'],
1037
-        );
1037
+		);
1038 1038
 
1039
-        $args['field_type'] = $field_type;
1040
-        self::fill_field_opts($field, $field_array, $args);
1039
+		$args['field_type'] = $field_type;
1040
+		self::fill_field_opts($field, $field_array, $args);
1041 1041
 		// Track the original field's type
1042 1042
 		$field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type;
1043 1043
 
1044
-        $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1044
+		$field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1045 1045
 
1046
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1047
-            $field_array['unique_msg'] = '';
1048
-        }
1046
+		if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1047
+			$field_array['unique_msg'] = '';
1048
+		}
1049 1049
 
1050
-        $field_array = array_merge( $field->field_options, $field_array );
1050
+		$field_array = array_merge( $field->field_options, $field_array );
1051 1051
 
1052
-        $values['fields'][ $field->id ] = $field_array;
1053
-    }
1052
+		$values['fields'][ $field->id ] = $field_array;
1053
+	}
1054 1054
 
1055 1055
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1056
-        $post_values = $args['post_values'];
1057
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1056
+		$post_values = $args['post_values'];
1057
+		$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1058 1058
 
1059
-        foreach ( $opt_defaults as $opt => $default_opt ) {
1059
+		foreach ( $opt_defaults as $opt => $default_opt ) {
1060 1060
 			$field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt );
1061
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1062
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1063
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1064
-                if ( $args['field_type'] == 'captcha' ) {
1065
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1066
-                } else {
1067
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1068
-                }
1069
-            }
1070
-        }
1071
-
1072
-        if ( $field_array['custom_html'] == '' ) {
1073
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1074
-        }
1075
-    }
1076
-
1077
-    /**
1078
-     * @param string $table
1079
-     */
1061
+			if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1062
+				$field_array[ $opt ] = $args['frm_settings']->blank_msg;
1063
+			} else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1064
+				if ( $args['field_type'] == 'captcha' ) {
1065
+					$field_array[ $opt ] = $args['frm_settings']->re_msg;
1066
+				} else {
1067
+					$field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1068
+				}
1069
+			}
1070
+		}
1071
+
1072
+		if ( $field_array['custom_html'] == '' ) {
1073
+			$field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1074
+		}
1075
+	}
1076
+
1077
+	/**
1078
+	 * @param string $table
1079
+	 */
1080 1080
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1081
-        if ( $table == 'entries' ) {
1082
-            $form = $record->form_id;
1081
+		if ( $table == 'entries' ) {
1082
+			$form = $record->form_id;
1083 1083
 			FrmForm::maybe_get_form( $form );
1084
-        } else {
1085
-            $form = $record;
1086
-        }
1084
+		} else {
1085
+			$form = $record;
1086
+		}
1087 1087
 
1088
-        if ( ! $form ) {
1089
-            return;
1090
-        }
1088
+		if ( ! $form ) {
1089
+			return;
1090
+		}
1091 1091
 
1092
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1092
+		$values['form_name'] = isset($record->form_id) ? $form->name : '';
1093 1093
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1094 1094
 
1095
-        if ( ! is_array($form->options) ) {
1096
-            return;
1097
-        }
1095
+		if ( ! is_array($form->options) ) {
1096
+			return;
1097
+		}
1098 1098
 
1099
-        foreach ( $form->options as $opt => $value ) {
1100
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1101
-        }
1099
+		foreach ( $form->options as $opt => $value ) {
1100
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1101
+		}
1102 1102
 
1103
-        self::fill_form_defaults($post_values, $values);
1104
-    }
1103
+		self::fill_form_defaults($post_values, $values);
1104
+	}
1105 1105
 
1106
-    /**
1107
-     * Set to POST value or default
1108
-     */
1106
+	/**
1107
+	 * Set to POST value or default
1108
+	 */
1109 1109
 	private static function fill_form_defaults( $post_values, array &$values ) {
1110
-        $form_defaults = FrmFormsHelper::get_default_opts();
1110
+		$form_defaults = FrmFormsHelper::get_default_opts();
1111 1111
 
1112
-        foreach ( $form_defaults as $opt => $default ) {
1113
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1112
+		foreach ( $form_defaults as $opt => $default ) {
1113
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1114 1114
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1115
-            }
1115
+			}
1116 1116
 
1117
-            unset($opt, $defaut);
1118
-        }
1117
+			unset($opt, $defaut);
1118
+		}
1119 1119
 
1120
-        if ( ! isset($values['custom_style']) ) {
1121
-            $frm_settings = self::get_settings();
1120
+		if ( ! isset($values['custom_style']) ) {
1121
+			$frm_settings = self::get_settings();
1122 1122
 			$values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' );
1123
-        }
1123
+		}
1124 1124
 
1125 1125
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1126 1126
 			if ( ! isset( $values[ $h . '_html' ] ) ) {
1127 1127
 				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1128
-            }
1129
-            unset($h);
1130
-        }
1131
-    }
1128
+			}
1129
+			unset($h);
1130
+		}
1131
+	}
1132 1132
 
1133 1133
 	public static function get_meta_value( $field_id, $entry ) {
1134 1134
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryMeta::get_meta_value' );
@@ -1136,59 +1136,59 @@  discard block
 block discarded – undo
1136 1136
 	}
1137 1137
 
1138 1138
 	public static function insert_opt_html( $args ) {
1139
-        $class = '';
1140
-        if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1141
-            $class .= 'show_frm_not_email_to';
1142
-        }
1143
-    ?>
1139
+		$class = '';
1140
+		if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1141
+			$class .= 'show_frm_not_email_to';
1142
+		}
1143
+	?>
1144 1144
 <li>
1145 1145
     <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a>
1146 1146
     <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a>
1147 1147
     <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a>
1148 1148
 </li>
1149 1149
     <?php
1150
-    }
1150
+	}
1151 1151
 
1152 1152
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1153
-        if ( is_array( $str ) ) {
1154
-            return '';
1153
+		if ( is_array( $str ) ) {
1154
+			return '';
1155 1155
 		}
1156 1156
 
1157
-        $length = (int) $length;
1157
+		$length = (int) $length;
1158 1158
 		$str = wp_strip_all_tags( $str );
1159 1159
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1160 1160
 
1161 1161
 		if ( $length == 0 ) {
1162
-            return '';
1163
-        } else if ( $length <= 10 ) {
1162
+			return '';
1163
+		} else if ( $length <= 10 ) {
1164 1164
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1165
-            return $sub . (($length < $original_len) ? $continue : '');
1166
-        }
1165
+			return $sub . (($length < $original_len) ? $continue : '');
1166
+		}
1167 1167
 
1168
-        $sub = '';
1169
-        $len = 0;
1168
+		$sub = '';
1169
+		$len = 0;
1170 1170
 
1171 1171
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1172 1172
 
1173 1173
 		foreach ( $words as $word ) {
1174
-            $part = (($sub != '') ? ' ' : '') . $word;
1174
+			$part = (($sub != '') ? ' ' : '') . $word;
1175 1175
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1176
-            if ( $total_len > $length && str_word_count($sub) ) {
1177
-                break;
1178
-            }
1176
+			if ( $total_len > $length && str_word_count($sub) ) {
1177
+				break;
1178
+			}
1179 1179
 
1180
-            $sub .= $part;
1180
+			$sub .= $part;
1181 1181
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1182 1182
 
1183
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1184
-                break;
1185
-            }
1183
+			if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1184
+				break;
1185
+			}
1186 1186
 
1187
-            unset($total_len, $word);
1188
-        }
1187
+			unset($total_len, $word);
1188
+		}
1189 1189
 
1190
-        return $sub . (($len < $original_len) ? $continue : '');
1191
-    }
1190
+		return $sub . (($len < $original_len) ? $continue : '');
1191
+	}
1192 1192
 
1193 1193
 	public static function mb_function( $function_names, $args ) {
1194 1194
 		$mb_function_name = $function_names[0];
@@ -1200,18 +1200,18 @@  discard block
 block discarded – undo
1200 1200
 	}
1201 1201
 
1202 1202
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1203
-        if ( empty($date) ) {
1204
-            return $date;
1205
-        }
1203
+		if ( empty($date) ) {
1204
+			return $date;
1205
+		}
1206 1206
 
1207
-        if ( empty($date_format) ) {
1208
-            $date_format = get_option('date_format');
1209
-        }
1207
+		if ( empty($date_format) ) {
1208
+			$date_format = get_option('date_format');
1209
+		}
1210 1210
 
1211
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1212
-            $frmpro_settings = new FrmProSettings();
1213
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1214
-        }
1211
+		if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1212
+			$frmpro_settings = new FrmProSettings();
1213
+			$date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1214
+		}
1215 1215
 
1216 1216
 		$formatted = self::get_localized_date( $date_format, $date );
1217 1217
 
@@ -1220,8 +1220,8 @@  discard block
 block discarded – undo
1220 1220
 			$formatted .= self::add_time_to_date( $time_format, $date );
1221 1221
 		}
1222 1222
 
1223
-        return $formatted;
1224
-    }
1223
+		return $formatted;
1224
+	}
1225 1225
 
1226 1226
 	private static function add_time_to_date( $time_format, $date ) {
1227 1227
 		if ( empty( $time_format ) ) {
@@ -1302,61 +1302,61 @@  discard block
 block discarded – undo
1302 1302
 		);
1303 1303
 	}
1304 1304
 
1305
-    /**
1306
-     * Added for < WP 4.0 compatability
1307
-     *
1308
-     * @since 1.07.10
1309
-     *
1310
-     * @param string $term The value to escape
1311
-     * @return string The escaped value
1312
-     */
1305
+	/**
1306
+	 * Added for < WP 4.0 compatability
1307
+	 *
1308
+	 * @since 1.07.10
1309
+	 *
1310
+	 * @param string $term The value to escape
1311
+	 * @return string The escaped value
1312
+	 */
1313 1313
 	public static function esc_like( $term ) {
1314
-        global $wpdb;
1315
-        if ( method_exists($wpdb, 'esc_like') ) {
1314
+		global $wpdb;
1315
+		if ( method_exists($wpdb, 'esc_like') ) {
1316 1316
 			// WP 4.0
1317
-            $term = $wpdb->esc_like( $term );
1318
-        } else {
1319
-            $term = like_escape( $term );
1320
-        }
1317
+			$term = $wpdb->esc_like( $term );
1318
+		} else {
1319
+			$term = like_escape( $term );
1320
+		}
1321 1321
 
1322
-        return $term;
1323
-    }
1322
+		return $term;
1323
+	}
1324 1324
 
1325
-    /**
1326
-     * @param string $order_query
1327
-     */
1325
+	/**
1326
+	 * @param string $order_query
1327
+	 */
1328 1328
 	public static function esc_order( $order_query ) {
1329
-        if ( empty($order_query) ) {
1330
-            return '';
1331
-        }
1332
-
1333
-        // remove ORDER BY before santizing
1334
-        $order_query = strtolower($order_query);
1335
-        if ( strpos($order_query, 'order by') !== false ) {
1336
-            $order_query = str_replace('order by', '', $order_query);
1337
-        }
1338
-
1339
-        $order_query = explode(' ', trim($order_query));
1340
-
1341
-        $order_fields = array(
1342
-            'id', 'form_key', 'name', 'description',
1343
-            'parent_form_id', 'logged_in', 'is_template',
1344
-            'default_template', 'status', 'created_at',
1345
-        );
1346
-
1347
-        $order = trim(trim(reset($order_query), ','));
1348
-        if ( ! in_array($order, $order_fields) ) {
1349
-            return '';
1350
-        }
1351
-
1352
-        $order_by = '';
1353
-        if ( count($order_query) > 1 ) {
1329
+		if ( empty($order_query) ) {
1330
+			return '';
1331
+		}
1332
+
1333
+		// remove ORDER BY before santizing
1334
+		$order_query = strtolower($order_query);
1335
+		if ( strpos($order_query, 'order by') !== false ) {
1336
+			$order_query = str_replace('order by', '', $order_query);
1337
+		}
1338
+
1339
+		$order_query = explode(' ', trim($order_query));
1340
+
1341
+		$order_fields = array(
1342
+			'id', 'form_key', 'name', 'description',
1343
+			'parent_form_id', 'logged_in', 'is_template',
1344
+			'default_template', 'status', 'created_at',
1345
+		);
1346
+
1347
+		$order = trim(trim(reset($order_query), ','));
1348
+		if ( ! in_array($order, $order_fields) ) {
1349
+			return '';
1350
+		}
1351
+
1352
+		$order_by = '';
1353
+		if ( count($order_query) > 1 ) {
1354 1354
 			$order_by = end( $order_query );
1355 1355
 			self::esc_order_by( $order_by );
1356
-        }
1356
+		}
1357 1357
 
1358 1358
 		return ' ORDER BY ' . $order . ' ' . $order_by;
1359
-    }
1359
+	}
1360 1360
 
1361 1361
 	/**
1362 1362
 	 * Make sure this is ordering by either ASC or DESC
@@ -1368,169 +1368,169 @@  discard block
 block discarded – undo
1368 1368
 		}
1369 1369
 	}
1370 1370
 
1371
-    /**
1372
-     * @param string $limit
1373
-     */
1371
+	/**
1372
+	 * @param string $limit
1373
+	 */
1374 1374
 	public static function esc_limit( $limit ) {
1375
-        if ( empty($limit) ) {
1376
-            return '';
1377
-        }
1375
+		if ( empty($limit) ) {
1376
+			return '';
1377
+		}
1378 1378
 
1379
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1380
-        if ( is_numeric($limit) ) {
1379
+		$limit = trim(str_replace(' limit', '', strtolower($limit)));
1380
+		if ( is_numeric($limit) ) {
1381 1381
 			return ' LIMIT ' . $limit;
1382
-        }
1382
+		}
1383 1383
 
1384
-        $limit = explode(',', trim($limit));
1385
-        foreach ( $limit as $k => $l ) {
1386
-            if ( is_numeric( $l ) ) {
1387
-                $limit[ $k ] = $l;
1388
-            }
1389
-        }
1384
+		$limit = explode(',', trim($limit));
1385
+		foreach ( $limit as $k => $l ) {
1386
+			if ( is_numeric( $l ) ) {
1387
+				$limit[ $k ] = $l;
1388
+			}
1389
+		}
1390 1390
 
1391
-        $limit = implode(',', $limit);
1391
+		$limit = implode(',', $limit);
1392 1392
 		return ' LIMIT ' . $limit;
1393
-    }
1394
-
1395
-    /**
1396
-     * Get an array of values ready to go through $wpdb->prepare
1397
-     * @since 2.0
1398
-     */
1399
-    public static function prepare_array_values( $array, $type = '%s' ) {
1400
-        $placeholders = array_fill(0, count($array), $type);
1401
-        return implode(', ', $placeholders);
1402
-    }
1403
-
1404
-    public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1405
-        if ( empty($where) ) {
1406
-            return '';
1407
-        }
1393
+	}
1394
+
1395
+	/**
1396
+	 * Get an array of values ready to go through $wpdb->prepare
1397
+	 * @since 2.0
1398
+	 */
1399
+	public static function prepare_array_values( $array, $type = '%s' ) {
1400
+		$placeholders = array_fill(0, count($array), $type);
1401
+		return implode(', ', $placeholders);
1402
+	}
1403
+
1404
+	public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1405
+		if ( empty($where) ) {
1406
+			return '';
1407
+		}
1408 1408
 
1409 1409
 		if ( is_array( $where ) ) {
1410
-            global $wpdb;
1411
-            FrmDb::get_where_clause_and_values( $where, $starts_with );
1410
+			global $wpdb;
1411
+			FrmDb::get_where_clause_and_values( $where, $starts_with );
1412 1412
 			$where = $wpdb->prepare( $where['where'], $where['values'] );
1413 1413
 		} else {
1414
-            $where = $starts_with . $where;
1415
-        }
1414
+			$where = $starts_with . $where;
1415
+		}
1416 1416
 
1417
-        return $where;
1418
-    }
1417
+		return $where;
1418
+	}
1419 1419
 
1420
-    // Pagination Methods
1420
+	// Pagination Methods
1421 1421
 
1422
-    /**
1423
-     * @param integer $current_p
1424
-     */
1422
+	/**
1423
+	 * @param integer $current_p
1424
+	 */
1425 1425
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1426 1426
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1427 1427
 	}
1428 1428
 
1429
-    /**
1430
-     * @param integer $current_p
1431
-     */
1432
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1433
-        if ( $current_p == 1 ) {
1434
-            return 1;
1435
-        } else {
1436
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1437
-        }
1438
-    }
1429
+	/**
1430
+	 * @param integer $current_p
1431
+	 */
1432
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1433
+		if ( $current_p == 1 ) {
1434
+			return 1;
1435
+		} else {
1436
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1437
+		}
1438
+	}
1439 1439
 
1440 1440
 	/**
1441 1441
 	 * @return array
1442 1442
 	 */
1443 1443
 	public static function json_to_array( $json_vars ) {
1444
-        $vars = array();
1445
-        foreach ( $json_vars as $jv ) {
1446
-            $jv_name = explode('[', $jv['name']);
1447
-            $last = count($jv_name) - 1;
1448
-            foreach ( $jv_name as $p => $n ) {
1449
-                $name = trim($n, ']');
1450
-                if ( ! isset($l1) ) {
1451
-                    $l1 = $name;
1452
-                }
1453
-
1454
-                if ( ! isset($l2) ) {
1455
-                    $l2 = $name;
1456
-                }
1457
-
1458
-                if ( ! isset($l3) ) {
1459
-                    $l3 = $name;
1460
-                }
1461
-
1462
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1463
-
1464
-                switch ( $p ) {
1465
-                    case 0:
1466
-                        $l1 = $name;
1467
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1468
-                    break;
1469
-
1470
-                    case 1:
1471
-                        $l2 = $name;
1472
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1473
-                    break;
1474
-
1475
-                    case 2:
1476
-                        $l3 = $name;
1477
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1478
-                    break;
1479
-
1480
-                    case 3:
1481
-                        $l4 = $name;
1482
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1483
-                    break;
1484
-                }
1485
-
1486
-                unset($this_val, $n);
1487
-            }
1488
-
1489
-            unset($last, $jv);
1490
-        }
1491
-
1492
-        return $vars;
1493
-    }
1494
-
1495
-    /**
1496
-     * @param string $name
1497
-     * @param string $l1
1498
-     */
1499
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1500
-        if ( $name == '' ) {
1501
-            $vars[] = $val;
1502
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1503
-            $vars[ $l1 ] = $val;
1504
-        }
1505
-    }
1444
+		$vars = array();
1445
+		foreach ( $json_vars as $jv ) {
1446
+			$jv_name = explode('[', $jv['name']);
1447
+			$last = count($jv_name) - 1;
1448
+			foreach ( $jv_name as $p => $n ) {
1449
+				$name = trim($n, ']');
1450
+				if ( ! isset($l1) ) {
1451
+					$l1 = $name;
1452
+				}
1453
+
1454
+				if ( ! isset($l2) ) {
1455
+					$l2 = $name;
1456
+				}
1457
+
1458
+				if ( ! isset($l3) ) {
1459
+					$l3 = $name;
1460
+				}
1461
+
1462
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1463
+
1464
+				switch ( $p ) {
1465
+					case 0:
1466
+						$l1 = $name;
1467
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1468
+					break;
1469
+
1470
+					case 1:
1471
+						$l2 = $name;
1472
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1473
+					break;
1474
+
1475
+					case 2:
1476
+						$l3 = $name;
1477
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1478
+					break;
1479
+
1480
+					case 3:
1481
+						$l4 = $name;
1482
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1483
+					break;
1484
+				}
1485
+
1486
+				unset($this_val, $n);
1487
+			}
1488
+
1489
+			unset($last, $jv);
1490
+		}
1491
+
1492
+		return $vars;
1493
+	}
1494
+
1495
+	/**
1496
+	 * @param string $name
1497
+	 * @param string $l1
1498
+	 */
1499
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1500
+		if ( $name == '' ) {
1501
+			$vars[] = $val;
1502
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1503
+			$vars[ $l1 ] = $val;
1504
+		}
1505
+	}
1506 1506
 
1507 1507
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1508
-        $tooltips = array(
1509
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1510
-            'email_to'      => __( 'Add one or more recipient addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].  [admin_email] is the address set in WP General Settings.', 'formidable' ),
1511
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1512
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1513
-            'reply_to'      => __( 'If you would like a different reply to address than the "from" address, add a single address here.  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1514
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1515
-            'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ),
1516
-        );
1517
-
1518
-        if ( ! isset( $tooltips[ $name ] ) ) {
1519
-            return;
1520
-        }
1521
-
1522
-        if ( 'open' == $class ) {
1523
-            echo ' frm_help"';
1524
-        } else {
1525
-            echo ' class="frm_help"';
1526
-        }
1508
+		$tooltips = array(
1509
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1510
+			'email_to'      => __( 'Add one or more recipient addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].  [admin_email] is the address set in WP General Settings.', 'formidable' ),
1511
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1512
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1513
+			'reply_to'      => __( 'If you would like a different reply to address than the "from" address, add a single address here.  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1514
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1515
+			'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ),
1516
+		);
1517
+
1518
+		if ( ! isset( $tooltips[ $name ] ) ) {
1519
+			return;
1520
+		}
1521
+
1522
+		if ( 'open' == $class ) {
1523
+			echo ' frm_help"';
1524
+		} else {
1525
+			echo ' class="frm_help"';
1526
+		}
1527 1527
 
1528 1528
 		echo ' title="' . esc_attr( $tooltips[ $name ] );
1529 1529
 
1530
-        if ( 'open' != $class ) {
1531
-            echo '"';
1532
-        }
1533
-    }
1530
+		if ( 'open' != $class ) {
1531
+			echo '"';
1532
+		}
1533
+	}
1534 1534
 
1535 1535
 	/**
1536 1536
 	 * Add the current_page class to that page in the form nav
@@ -1546,35 +1546,35 @@  discard block
 block discarded – undo
1546 1546
 		}
1547 1547
 	}
1548 1548
 
1549
-    /**
1550
-     * Prepare and json_encode post content
1551
-     *
1552
-     * @since 2.0
1553
-     *
1554
-     * @param array $post_content
1555
-     * @return string $post_content ( json encoded array )
1556
-     */
1557
-    public static function prepare_and_encode( $post_content ) {
1558
-        //Loop through array to strip slashes and add only the needed ones
1549
+	/**
1550
+	 * Prepare and json_encode post content
1551
+	 *
1552
+	 * @since 2.0
1553
+	 *
1554
+	 * @param array $post_content
1555
+	 * @return string $post_content ( json encoded array )
1556
+	 */
1557
+	public static function prepare_and_encode( $post_content ) {
1558
+		//Loop through array to strip slashes and add only the needed ones
1559 1559
 		foreach ( $post_content as $key => $val ) {
1560 1560
 			// Replace problematic characters (like &quot;)
1561 1561
 			$val = str_replace( '&quot;', '"', $val );
1562 1562
 
1563 1563
 			self::prepare_action_slashes( $val, $key, $post_content );
1564
-            unset( $key, $val );
1565
-        }
1564
+			unset( $key, $val );
1565
+		}
1566 1566
 
1567
-        // json_encode the array
1568
-        $post_content = json_encode( $post_content );
1567
+		// json_encode the array
1568
+		$post_content = json_encode( $post_content );
1569 1569
 
1570
-	    // add extra slashes for \r\n since WP strips them
1570
+		// add extra slashes for \r\n since WP strips them
1571 1571
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1572 1572
 
1573
-        // allow for &quot
1574
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1573
+		// allow for &quot
1574
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1575 1575
 
1576
-        return $post_content;
1577
-    }
1576
+		return $post_content;
1577
+	}
1578 1578
 
1579 1579
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1580 1580
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1642,64 +1642,64 @@  discard block
 block discarded – undo
1642 1642
 	}
1643 1643
 
1644 1644
 	public static function maybe_json_decode( $string ) {
1645
-        if ( is_array($string) ) {
1646
-            return $string;
1647
-        }
1645
+		if ( is_array($string) ) {
1646
+			return $string;
1647
+		}
1648 1648
 
1649
-        $new_string = json_decode($string, true);
1650
-        if ( function_exists('json_last_error') ) {
1649
+		$new_string = json_decode($string, true);
1650
+		if ( function_exists('json_last_error') ) {
1651 1651
 			// php 5.3+
1652
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1653
-                $string = $new_string;
1654
-            }
1655
-        } else if ( isset($new_string) ) {
1652
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1653
+				$string = $new_string;
1654
+			}
1655
+		} else if ( isset($new_string) ) {
1656 1656
 			// php < 5.3 fallback
1657
-            $string = $new_string;
1658
-        }
1659
-        return $string;
1660
-    }
1661
-
1662
-    /**
1663
-     * @since 1.07.10
1664
-     *
1665
-     * @param string $post_type The name of the post type that may need to be highlighted
1666
-     * echo The javascript to open and highlight the Formidable menu
1667
-     */
1657
+			$string = $new_string;
1658
+		}
1659
+		return $string;
1660
+	}
1661
+
1662
+	/**
1663
+	 * @since 1.07.10
1664
+	 *
1665
+	 * @param string $post_type The name of the post type that may need to be highlighted
1666
+	 * echo The javascript to open and highlight the Formidable menu
1667
+	 */
1668 1668
 	public static function maybe_highlight_menu( $post_type ) {
1669
-        global $post;
1669
+		global $post;
1670 1670
 
1671
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1672
-            return;
1673
-        }
1671
+		if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1672
+			return;
1673
+		}
1674 1674
 
1675
-        if ( is_object($post) && $post->post_type != $post_type ) {
1676
-            return;
1677
-        }
1675
+		if ( is_object($post) && $post->post_type != $post_type ) {
1676
+			return;
1677
+		}
1678 1678
 
1679
-        self::load_admin_wide_js();
1680
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1681
-    }
1679
+		self::load_admin_wide_js();
1680
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1681
+	}
1682 1682
 
1683
-    /**
1684
-     * Load the JS file on non-Formidable pages in the admin area
1685
-     * @since 2.0
1686
-     */
1683
+	/**
1684
+	 * Load the JS file on non-Formidable pages in the admin area
1685
+	 * @since 2.0
1686
+	 */
1687 1687
 	public static function load_admin_wide_js( $load = true ) {
1688
-        $version = FrmAppHelper::plugin_version();
1688
+		$version = FrmAppHelper::plugin_version();
1689 1689
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1690 1690
 
1691
-        wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1691
+		wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1692 1692
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1693
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1693
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1694 1694
 			'url'          => FrmAppHelper::plugin_url(),
1695 1695
 			'loading'      => __( 'Loading&hellip;' ),
1696 1696
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
1697
-        ) );
1697
+		) );
1698 1698
 
1699 1699
 		if ( $load ) {
1700 1700
 			wp_enqueue_script( 'formidable_admin_global' );
1701 1701
 		}
1702
-    }
1702
+	}
1703 1703
 
1704 1704
 	/**
1705 1705
 	 * @since 2.0.9
@@ -1708,9 +1708,9 @@  discard block
 block discarded – undo
1708 1708
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1709 1709
 	}
1710 1710
 
1711
-    /**
1712
-     * @param string $location
1713
-     */
1711
+	/**
1712
+	 * @param string $location
1713
+	 */
1714 1714
 	public static function localize_script( $location ) {
1715 1715
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1716 1716
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1763,81 +1763,81 @@  discard block
 block discarded – undo
1763 1763
 		}
1764 1764
 	}
1765 1765
 
1766
-    /**
1766
+	/**
1767 1767
 	 * echo the message on the plugins listing page
1768
-     * @since 1.07.10
1769
-     *
1770
-     * @param float $min_version The version the add-on requires
1771
-     */
1768
+	 * @since 1.07.10
1769
+	 *
1770
+	 * @param float $min_version The version the add-on requires
1771
+	 */
1772 1772
 	public static function min_version_notice( $min_version ) {
1773
-        $frm_version = self::plugin_version();
1773
+		$frm_version = self::plugin_version();
1774 1774
 
1775
-        // check if Formidable meets minimum requirements
1776
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1777
-            return;
1778
-        }
1775
+		// check if Formidable meets minimum requirements
1776
+		if ( version_compare($frm_version, $min_version, '>=') ) {
1777
+			return;
1778
+		}
1779 1779
 
1780
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1780
+		$wp_list_table = _get_list_table('WP_Plugins_List_Table');
1781 1781
 		echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' .
1782
-        __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1783
-        '</div></td></tr>';
1784
-    }
1785
-
1786
-    public static function locales( $type = 'date' ) {
1787
-        $locales = array(
1788
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1789
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1790
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1791
-            'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1792
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1793
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1794
-            'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1795
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1796
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1797
-            'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1798
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1799
-            'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1800
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1801
-            'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1802
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1803
-            'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1804
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1805
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1806
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1807
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1808
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1809
-            'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1810
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1811
-            'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1812
-            'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1813
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1814
-            'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1815
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1816
-            'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1817
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1818
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1819
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1820
-        );
1821
-
1822
-        if ( $type == 'captcha' ) {
1823
-            // remove the languages unavailable for the captcha
1824
-            $unset = array(
1825
-                '', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1826
-                'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1827
-                'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1828
-            );
1829
-        } else {
1830
-            // remove the languages unavailable for the datepicker
1831
-            $unset = array(
1832
-                'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1833
-                'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1834
-                'es-419', 'tr',
1835
-            );
1836
-        }
1837
-
1838
-        $locales = array_diff_key($locales, array_flip($unset));
1839
-        $locales = apply_filters('frm_locales', $locales);
1840
-
1841
-        return $locales;
1842
-    }
1782
+		__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1783
+		'</div></td></tr>';
1784
+	}
1785
+
1786
+	public static function locales( $type = 'date' ) {
1787
+		$locales = array(
1788
+			'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1789
+			'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1790
+			'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1791
+			'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1792
+			'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1793
+			'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1794
+			'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1795
+			'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1796
+			'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1797
+			'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1798
+			'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1799
+			'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1800
+			'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1801
+			'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1802
+			'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1803
+			'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1804
+			'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1805
+			'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1806
+			'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1807
+			'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1808
+			'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1809
+			'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1810
+			'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1811
+			'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1812
+			'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1813
+			'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1814
+			'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1815
+			'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1816
+			'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1817
+			'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1818
+			'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1819
+			'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1820
+		);
1821
+
1822
+		if ( $type == 'captcha' ) {
1823
+			// remove the languages unavailable for the captcha
1824
+			$unset = array(
1825
+				'', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1826
+				'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1827
+				'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1828
+			);
1829
+		} else {
1830
+			// remove the languages unavailable for the datepicker
1831
+			$unset = array(
1832
+				'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1833
+				'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1834
+				'es-419', 'tr',
1835
+			);
1836
+		}
1837
+
1838
+		$locales = array_diff_key($locales, array_flip($unset));
1839
+		$locales = apply_filters('frm_locales', $locales);
1840
+
1841
+		return $locales;
1842
+	}
1843 1843
 }
Please login to merge, or discard this patch.
Spacing   +209 added lines, -209 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
 
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
     }
24 24
 
25 25
     public static function plugin_folder() {
26
-        return basename(self::plugin_path());
26
+        return basename( self::plugin_path() );
27 27
     }
28 28
 
29 29
     public static function plugin_path() {
30
-        return dirname(dirname(dirname(__FILE__)));
30
+        return dirname( dirname( dirname( __FILE__ ) ) );
31 31
     }
32 32
 
33 33
     public static function plugin_url() {
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      * @return string
55 55
      */
56 56
     public static function site_name() {
57
-        return get_option('blogname');
57
+        return get_option( 'blogname' );
58 58
     }
59 59
 
60 60
 	public static function make_affiliate_url( $url ) {
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
 	public static function get_affiliate() {
69 69
 		return '';
70
-		$affiliate_id = apply_filters( 'frm_affiliate_link', get_option('frm_aff') );
70
+		$affiliate_id = apply_filters( 'frm_affiliate_link', get_option( 'frm_aff' ) );
71 71
 		$affiliate_id = strtolower( $affiliate_id );
72 72
 		$allowed_affiliates = array();
73 73
 		if ( ! in_array( $affiliate_id, $allowed_affiliates ) ) {
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public static function get_settings() {
88 88
         global $frm_settings;
89
-        if ( empty($frm_settings) ) {
89
+        if ( empty( $frm_settings ) ) {
90 90
             $frm_settings = new FrmSettings();
91 91
         }
92 92
         return $frm_settings;
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     }
108 108
 
109 109
     public static function pro_is_installed() {
110
-        return apply_filters('frm_pro_installed', false);
110
+        return apply_filters( 'frm_pro_installed', false );
111 111
     }
112 112
 
113 113
     /**
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      * @return boolean
152 152
      */
153 153
     public static function doing_ajax() {
154
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
154
+        return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page();
155 155
     }
156 156
 
157 157
 	/**
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
      * @return boolean
172 172
      */
173 173
     public static function is_admin() {
174
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
174
+        return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX );
175 175
     }
176 176
 
177 177
     /**
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
      * @return string
199 199
      */
200 200
 	public static function get_server_value( $value ) {
201
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
201
+        return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : '';
202 202
     }
203 203
 
204 204
     /**
@@ -213,14 +213,14 @@  discard block
 block discarded – undo
213 213
             'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
214 214
             'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
215 215
         ) as $key ) {
216
-            if ( ! isset( $_SERVER[ $key ] ) ) {
216
+            if ( ! isset( $_SERVER[$key] ) ) {
217 217
                 continue;
218 218
             }
219 219
 
220
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
221
-                $ip = trim($ip); // just to be safe
220
+            foreach ( explode( ',', $_SERVER[$key] ) as $ip ) {
221
+                $ip = trim( $ip ); // just to be safe
222 222
 
223
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
223
+                if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
224 224
                     return $ip;
225 225
                 }
226 226
             }
@@ -230,15 +230,15 @@  discard block
 block discarded – undo
230 230
     }
231 231
 
232 232
     public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
233
-        if ( strpos($param, '[') ) {
234
-            $params = explode('[', $param);
233
+        if ( strpos( $param, '[' ) ) {
234
+            $params = explode( '[', $param );
235 235
             $param = $params[0];
236 236
         }
237 237
 
238 238
 		if ( $src == 'get' ) {
239
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
240
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
241
-                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
239
+            $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default );
240
+            if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) {
241
+                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[$param] ) ) );
242 242
             }
243 243
 			self::sanitize_value( $sanitize, $value );
244 244
 		} else {
@@ -247,12 +247,12 @@  discard block
 block discarded – undo
247 247
 
248 248
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
249 249
             foreach ( $params as $k => $p ) {
250
-                if ( ! $k || ! is_array($value) ) {
250
+                if ( ! $k || ! is_array( $value ) ) {
251 251
                     continue;
252 252
                 }
253 253
 
254
-                $p = trim($p, ']');
255
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
254
+                $p = trim( $p, ']' );
255
+                $value = isset( $value[$p] ) ? $value[$p] : $default;
256 256
             }
257 257
         }
258 258
 
@@ -291,16 +291,16 @@  discard block
 block discarded – undo
291 291
 
292 292
 		$value = $args['default'];
293 293
 		if ( $args['type'] == 'get' ) {
294
-			if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
295
-				$value = $_GET[ $args['param'] ];
294
+			if ( $_GET && isset( $_GET[$args['param']] ) ) {
295
+				$value = $_GET[$args['param']];
296 296
 			}
297 297
 		} else if ( $args['type'] == 'post' ) {
298
-			if ( isset( $_POST[ $args['param'] ] ) ) {
299
-				$value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) );
298
+			if ( isset( $_POST[$args['param']] ) ) {
299
+				$value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) );
300 300
 			}
301 301
 		} else {
302
-			if ( isset( $_REQUEST[ $args['param'] ] ) ) {
303
-				$value = $_REQUEST[ $args['param'] ];
302
+			if ( isset( $_REQUEST[$args['param']] ) ) {
303
+				$value = $_REQUEST[$args['param']];
304 304
 			}
305 305
 		}
306 306
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 			if ( is_array( $value ) ) {
329 329
 				$temp_values = $value;
330 330
 				foreach ( $temp_values as $k => $v ) {
331
-					FrmAppHelper::sanitize_value( $sanitize, $value[ $k ] );
331
+					FrmAppHelper::sanitize_value( $sanitize, $value[$k] );
332 332
 				}
333 333
 			} else {
334 334
 				$value = call_user_func( $sanitize, $value );
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
     public static function sanitize_request( $sanitize_method, &$values ) {
340 340
         $temp_values = $values;
341 341
         foreach ( $temp_values as $k => $val ) {
342
-            if ( isset( $sanitize_method[ $k ] ) ) {
343
-				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
342
+            if ( isset( $sanitize_method[$k] ) ) {
343
+				$values[$k] = call_user_func( $sanitize_method[$k], $val );
344 344
             }
345 345
         }
346 346
     }
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 	public static function sanitize_array( &$values ) {
349 349
 		$temp_values = $values;
350 350
 		foreach ( $temp_values as $k => $val ) {
351
-			$values[ $k ] = wp_kses_post( $val );
351
+			$values[$k] = wp_kses_post( $val );
352 352
 		}
353 353
 	}
354 354
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 
372 372
 		$allowed_html = array();
373 373
 		foreach ( $allowed as $a ) {
374
-			$allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
374
+			$allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array();
375 375
 		}
376 376
 
377 377
 		return wp_kses( $value, $allowed_html );
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
      * @since 2.0
383 383
      */
384 384
     public static function remove_get_action() {
385
-        if ( ! isset($_GET) ) {
385
+        if ( ! isset( $_GET ) ) {
386 386
             return;
387 387
         }
388 388
 
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
         }
405 405
 
406 406
         global $wp_query;
407
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
408
-            $value = $wp_query->query_vars[ $param ];
407
+        if ( isset( $wp_query->query_vars[$param] ) ) {
408
+            $value = $wp_query->query_vars[$param];
409 409
         }
410 410
 
411 411
         return $value;
@@ -434,19 +434,19 @@  discard block
 block discarded – undo
434 434
      * @return mixed $results The cache or query results
435 435
      */
436 436
     public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
437
-        $results = wp_cache_get($cache_key, $group);
438
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
437
+        $results = wp_cache_get( $cache_key, $group );
438
+        if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) {
439 439
             return $results;
440 440
         }
441 441
 
442 442
         if ( 'get_posts' == $type ) {
443
-            $results = get_posts($query);
443
+            $results = get_posts( $query );
444 444
 		} else if ( 'get_associative_results' == $type ) {
445 445
 			global $wpdb;
446 446
 			$results = $wpdb->get_results( $query, OBJECT_K );
447 447
         } else {
448 448
             global $wpdb;
449
-            $results = $wpdb->{$type}($query);
449
+            $results = $wpdb->{$type}( $query );
450 450
         }
451 451
 
452 452
 		if ( ! self::prevent_caching() ) {
@@ -470,9 +470,9 @@  discard block
 block discarded – undo
470 470
         }
471 471
 
472 472
         // then check the transient
473
-        $results = get_transient($cache_key);
473
+        $results = get_transient( $cache_key );
474 474
         if ( $results ) {
475
-            wp_cache_set($cache_key, $results);
475
+            wp_cache_set( $cache_key, $results );
476 476
         }
477 477
 
478 478
         return $results;
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
      * @param string $cache_key
484 484
      */
485 485
 	public static function delete_cache_and_transient( $cache_key, $group = 'default' ) {
486
-		delete_transient($cache_key);
486
+		delete_transient( $cache_key );
487 487
 		wp_cache_delete( $cache_key, $group );
488 488
 	}
489 489
 
@@ -499,10 +499,10 @@  discard block
 block discarded – undo
499 499
     	global $wp_object_cache;
500 500
 
501 501
 		if ( is_callable( array( $wp_object_cache, '__get' ) ) ) {
502
-			$group_cache = $wp_object_cache->__get('cache');
502
+			$group_cache = $wp_object_cache->__get( 'cache' );
503 503
 
504
-			if ( isset( $group_cache[ $group ] ) ) {
505
-				foreach ( $group_cache[ $group ] as $k => $v ) {
504
+			if ( isset( $group_cache[$group] ) ) {
505
+				foreach ( $group_cache[$group] as $k => $v ) {
506 506
 					wp_cache_delete( $k, $group );
507 507
 				}
508 508
 				return true;
@@ -538,17 +538,17 @@  discard block
 block discarded – undo
538 538
     }
539 539
 
540 540
     public static function get_pages() {
541
-		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
541
+		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) );
542 542
     }
543 543
 
544 544
     public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
545 545
         $pages = self::get_pages();
546 546
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
547 547
     ?>
548
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
548
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
549 549
             <option value=""> </option>
550 550
             <?php foreach ( $pages as $page ) { ?>
551
-				<option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>>
551
+				<option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>>
552 552
 					<?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?>
553 553
 				</option>
554 554
             <?php } ?>
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
     }
558 558
 
559 559
 	public static function post_edit_link( $post_id ) {
560
-        $post = get_post($post_id);
560
+        $post = get_post( $post_id );
561 561
         if ( $post ) {
562 562
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
563 563
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
@@ -567,17 +567,17 @@  discard block
 block discarded – undo
567 567
 
568 568
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
569 569
     ?>
570
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
570
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php
571 571
             echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
572 572
             ?> class="frm_multiselect">
573
-            <?php self::roles_options($capability); ?>
573
+            <?php self::roles_options( $capability ); ?>
574 574
         </select>
575 575
     <?php
576 576
     }
577 577
 
578 578
 	public static function roles_options( $capability ) {
579 579
         global $frm_vars;
580
-        if ( isset($frm_vars['editable_roles']) ) {
580
+        if ( isset( $frm_vars['editable_roles'] ) ) {
581 581
             $editable_roles = $frm_vars['editable_roles'];
582 582
         } else {
583 583
             $editable_roles = get_editable_roles();
@@ -585,10 +585,10 @@  discard block
 block discarded – undo
585 585
         }
586 586
 
587 587
         foreach ( $editable_roles as $role => $details ) {
588
-            $name = translate_user_role($details['name'] ); ?>
589
-        <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
588
+            $name = translate_user_role( $details['name'] ); ?>
589
+        <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option>
590 590
 <?php
591
-            unset($role, $details);
591
+            unset( $role, $details );
592 592
         }
593 593
     }
594 594
 
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
     public static function maybe_add_permissions() {
645 645
 		self::force_capability( 'frm_view_entries' );
646 646
 
647
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
647
+        if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
648 648
             return;
649 649
         }
650 650
 
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
         $frm_roles = self::frm_capabilities();
654 654
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
655 655
 			$user->add_cap( $frm_role );
656
-            unset($frm_role, $frm_role_description);
656
+            unset( $frm_role, $frm_role_description );
657 657
         }
658 658
     }
659 659
 
@@ -678,12 +678,12 @@  discard block
 block discarded – undo
678 678
      * @param string $permission
679 679
      */
680 680
 	public static function permission_check( $permission, $show_message = 'show' ) {
681
-        $permission_error = self::permission_nonce_error($permission);
681
+        $permission_error = self::permission_nonce_error( $permission );
682 682
         if ( $permission_error !== false ) {
683 683
             if ( 'hide' == $show_message ) {
684 684
                 $permission_error = '';
685 685
             }
686
-            wp_die($permission_error);
686
+            wp_die( $permission_error );
687 687
         }
688 688
     }
689 689
 
@@ -700,11 +700,11 @@  discard block
 block discarded – undo
700 700
 		}
701 701
 
702 702
 		$error = false;
703
-        if ( empty($nonce_name) ) {
703
+        if ( empty( $nonce_name ) ) {
704 704
             return $error;
705 705
         }
706 706
 
707
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
707
+        if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) {
708 708
             $frm_settings = self::get_settings();
709 709
             $error = $frm_settings->admin_permission;
710 710
         }
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
 			} else {
785 785
 				foreach ( $value as $k => $v ) {
786 786
 					if ( ! is_array( $v ) ) {
787
-						$value[ $k ] = call_user_func( $original_function, $v );
787
+						$value[$k] = call_user_func( $original_function, $v );
788 788
 					}
789 789
 				}
790 790
 			}
@@ -805,11 +805,11 @@  discard block
 block discarded – undo
805 805
 	public static function array_flatten( $array, $keys = 'keep' ) {
806 806
         $return = array();
807 807
         foreach ( $array as $key => $value ) {
808
-            if ( is_array($value) ) {
808
+            if ( is_array( $value ) ) {
809 809
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
810 810
             } else {
811 811
 				if ( $keys == 'keep' ) {
812
-					$return[ $key ] = $value;
812
+					$return[$key] = $value;
813 813
 				} else {
814 814
 					$return[] = $value;
815 815
 				}
@@ -832,8 +832,8 @@  discard block
 block discarded – undo
832 832
      * @since 2.0
833 833
      */
834 834
 	public static function use_wpautop( $content ) {
835
-        if ( apply_filters('frm_use_wpautop', true) ) {
836
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
835
+        if ( apply_filters( 'frm_use_wpautop', true ) ) {
836
+            $content = wpautop( str_replace( '<br>', '<br />', $content ) );
837 837
         }
838 838
         return $content;
839 839
     }
@@ -851,8 +851,8 @@  discard block
 block discarded – undo
851 851
      * @return string The base Google APIS url for the current version of jQuery UI
852 852
      */
853 853
     public static function jquery_ui_base_url() {
854
-		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core');
855
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
854
+		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core' );
855
+        $url = apply_filters( 'frm_jquery_ui_base_url', $url );
856 856
         return $url;
857 857
     }
858 858
 
@@ -867,11 +867,11 @@  discard block
 block discarded – undo
867 867
 
868 868
         $ver = 0;
869 869
 
870
-        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
870
+        if ( ! isset( $wp_scripts->registered[$handle] ) ) {
871 871
             return $ver;
872 872
         }
873 873
 
874
-        $query = $wp_scripts->registered[ $handle ];
874
+        $query = $wp_scripts->registered[$handle];
875 875
     	if ( is_object( $query ) ) {
876 876
     	    $ver = $query->ver;
877 877
     	}
@@ -884,36 +884,36 @@  discard block
 block discarded – undo
884 884
     }
885 885
 
886 886
 	public static function get_user_id_param( $user_id ) {
887
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
887
+        if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
888 888
             return $user_id;
889 889
         }
890 890
 
891 891
 		if ( $user_id == 'current' ) {
892 892
 			$user_id = get_current_user_id();
893 893
 		} else {
894
-            if ( is_email($user_id) ) {
895
-                $user = get_user_by('email', $user_id);
894
+            if ( is_email( $user_id ) ) {
895
+                $user = get_user_by( 'email', $user_id );
896 896
             } else {
897
-                $user = get_user_by('login', $user_id);
897
+                $user = get_user_by( 'login', $user_id );
898 898
             }
899 899
 
900 900
             if ( $user ) {
901 901
                 $user_id = $user->ID;
902 902
             }
903
-            unset($user);
903
+            unset( $user );
904 904
         }
905 905
 
906 906
         return $user_id;
907 907
     }
908 908
 
909 909
 	public static function get_file_contents( $filename, $atts = array() ) {
910
-        if ( ! is_file($filename) ) {
910
+        if ( ! is_file( $filename ) ) {
911 911
             return false;
912 912
         }
913 913
 
914
-        extract($atts);
914
+        extract( $atts );
915 915
         ob_start();
916
-        include($filename);
916
+        include( $filename );
917 917
         $contents = ob_get_contents();
918 918
         ob_end_clean();
919 919
         return $contents;
@@ -929,28 +929,28 @@  discard block
 block discarded – undo
929 929
         $key = '';
930 930
 
931 931
         if ( ! empty( $name ) ) {
932
-            $key = sanitize_key($name);
932
+            $key = sanitize_key( $name );
933 933
         }
934 934
 
935 935
 		if ( empty( $key ) ) {
936
-            $max_slug_value = pow(36, $num_chars);
936
+            $max_slug_value = pow( 36, $num_chars );
937 937
             $min_slug_value = 37; // we want to have at least 2 characters in the slug
938
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
938
+            $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
939 939
         }
940 940
 
941
-		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
941
+		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
942 942
 			$key = $key . 'a';
943 943
         }
944 944
 
945 945
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
946 946
 
947
-        if ( $key_check || is_numeric($key_check) ) {
947
+        if ( $key_check || is_numeric( $key_check ) ) {
948 948
             $suffix = 2;
949 949
 			do {
950 950
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
951 951
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
952
-				$suffix++;
953
-			} while ($key_check || is_numeric($key_check));
952
+				$suffix ++;
953
+			} while ( $key_check || is_numeric( $key_check ) );
954 954
 			$key = $alt_post_name;
955 955
         }
956 956
         return $key;
@@ -966,32 +966,32 @@  discard block
 block discarded – undo
966 966
             return false;
967 967
         }
968 968
 
969
-        if ( empty($post_values) ) {
970
-            $post_values = stripslashes_deep($_POST);
969
+        if ( empty( $post_values ) ) {
970
+            $post_values = stripslashes_deep( $_POST );
971 971
         }
972 972
 
973 973
 		$values = array( 'id' => $record->id, 'fields' => array() );
974 974
 
975 975
 		foreach ( array( 'name', 'description' ) as $var ) {
976
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
977
-			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
978
-            unset($var, $default_val);
976
+            $default_val = isset( $record->{$var}) ? $record->{$var} : '';
977
+			$values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
978
+            unset( $var, $default_val );
979 979
         }
980 980
 
981
-        $values['description'] = self::use_wpautop($values['description']);
981
+        $values['description'] = self::use_wpautop( $values['description'] );
982 982
         $frm_settings = self::get_settings();
983
-        $is_form_builder = self::is_admin_page('formidable' );
983
+        $is_form_builder = self::is_admin_page( 'formidable' );
984 984
 
985 985
         foreach ( (array) $fields as $field ) {
986 986
             // Make sure to filter default values (for placeholder text), but not on the form builder page
987 987
             if ( ! $is_form_builder ) {
988
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
988
+                $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true );
989 989
             }
990 990
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
991
-			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
991
+			self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) );
992 992
         }
993 993
 
994
-        self::fill_form_opts($record, $table, $post_values, $values);
994
+        self::fill_form_opts( $record, $table, $post_values, $values );
995 995
 
996 996
         if ( $table == 'entries' ) {
997 997
             $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
@@ -1008,8 +1008,8 @@  discard block
 block discarded – undo
1008 1008
         if ( $args['default'] ) {
1009 1009
             $meta_value = $field->default_value;
1010 1010
         } else {
1011
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1012
-                if ( ! isset($field->field_options['custom_field']) ) {
1011
+            if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
1012
+                if ( ! isset( $field->field_options['custom_field'] ) ) {
1013 1013
                     $field->field_options['custom_field'] = '';
1014 1014
                 }
1015 1015
 				$meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) );
@@ -1018,8 +1018,8 @@  discard block
 block discarded – undo
1018 1018
             }
1019 1019
         }
1020 1020
 
1021
-		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1022
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1021
+		$field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type;
1022
+        $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value;
1023 1023
 
1024 1024
         $field_array = array(
1025 1025
             'id'            => $field->id,
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
             'default_value' => $field->default_value,
1028 1028
             'name'          => $field->name,
1029 1029
             'description'   => $field->description,
1030
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1030
+            'type'          => apply_filters( 'frm_field_type', $field_type, $field, $new_value ),
1031 1031
             'options'       => $field->options,
1032 1032
             'required'      => $field->required,
1033 1033
             'field_key'     => $field->field_key,
@@ -1037,40 +1037,40 @@  discard block
 block discarded – undo
1037 1037
         );
1038 1038
 
1039 1039
         $args['field_type'] = $field_type;
1040
-        self::fill_field_opts($field, $field_array, $args);
1040
+        self::fill_field_opts( $field, $field_array, $args );
1041 1041
 		// Track the original field's type
1042 1042
 		$field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type;
1043 1043
 
1044 1044
         $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1045 1045
 
1046
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1046
+        if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1047 1047
             $field_array['unique_msg'] = '';
1048 1048
         }
1049 1049
 
1050 1050
         $field_array = array_merge( $field->field_options, $field_array );
1051 1051
 
1052
-        $values['fields'][ $field->id ] = $field_array;
1052
+        $values['fields'][$field->id] = $field_array;
1053 1053
     }
1054 1054
 
1055 1055
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1056 1056
         $post_values = $args['post_values'];
1057
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1057
+        $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
1058 1058
 
1059 1059
         foreach ( $opt_defaults as $opt => $default_opt ) {
1060
-			$field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt );
1061
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1062
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1063
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1060
+			$field_array[$opt] = ( $post_values && isset( $post_values['field_options'][$opt . '_' . $field->id] ) ) ? maybe_unserialize( $post_values['field_options'][$opt . '_' . $field->id] ) : ( isset( $field->field_options[$opt] ) ? $field->field_options[$opt] : $default_opt );
1061
+            if ( $opt == 'blank' && $field_array[$opt] == '' ) {
1062
+                $field_array[$opt] = $args['frm_settings']->blank_msg;
1063
+            } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) {
1064 1064
                 if ( $args['field_type'] == 'captcha' ) {
1065
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1065
+                    $field_array[$opt] = $args['frm_settings']->re_msg;
1066 1066
                 } else {
1067
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1067
+                    $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1068 1068
                 }
1069 1069
             }
1070 1070
         }
1071 1071
 
1072 1072
         if ( $field_array['custom_html'] == '' ) {
1073
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1073
+            $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] );
1074 1074
         }
1075 1075
     }
1076 1076
 
@@ -1089,18 +1089,18 @@  discard block
 block discarded – undo
1089 1089
             return;
1090 1090
         }
1091 1091
 
1092
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1092
+        $values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1093 1093
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1094 1094
 
1095
-        if ( ! is_array($form->options) ) {
1095
+        if ( ! is_array( $form->options ) ) {
1096 1096
             return;
1097 1097
         }
1098 1098
 
1099 1099
         foreach ( $form->options as $opt => $value ) {
1100
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1100
+            $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value;
1101 1101
         }
1102 1102
 
1103
-        self::fill_form_defaults($post_values, $values);
1103
+        self::fill_form_defaults( $post_values, $values );
1104 1104
     }
1105 1105
 
1106 1106
     /**
@@ -1110,23 +1110,23 @@  discard block
 block discarded – undo
1110 1110
         $form_defaults = FrmFormsHelper::get_default_opts();
1111 1111
 
1112 1112
         foreach ( $form_defaults as $opt => $default ) {
1113
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1114
-				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1113
+            if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) {
1114
+				$values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default;
1115 1115
             }
1116 1116
 
1117
-            unset($opt, $defaut);
1117
+            unset( $opt, $defaut );
1118 1118
         }
1119 1119
 
1120
-        if ( ! isset($values['custom_style']) ) {
1120
+        if ( ! isset( $values['custom_style'] ) ) {
1121 1121
             $frm_settings = self::get_settings();
1122 1122
 			$values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' );
1123 1123
         }
1124 1124
 
1125 1125
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1126
-			if ( ! isset( $values[ $h . '_html' ] ) ) {
1127
-				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1126
+			if ( ! isset( $values[$h . '_html'] ) ) {
1127
+				$values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) );
1128 1128
             }
1129
-            unset($h);
1129
+            unset( $h );
1130 1130
         }
1131 1131
     }
1132 1132
 
@@ -1142,9 +1142,9 @@  discard block
 block discarded – undo
1142 1142
         }
1143 1143
     ?>
1144 1144
 <li>
1145
-    <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a>
1146
-    <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a>
1147
-    <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a>
1145
+    <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['id'] ) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a>
1146
+    <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['key'] ) ?>" >[<?php echo esc_attr( self::truncate( $args['key'], 10 ) ) ?>]</a>
1147
+    <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['id'] ) ?>" ><?php echo esc_attr( self::truncate( $args['name'], 60 ) ) ?></a>
1148 1148
 </li>
1149 1149
     <?php
1150 1150
     }
@@ -1162,7 +1162,7 @@  discard block
 block discarded – undo
1162 1162
             return '';
1163 1163
         } else if ( $length <= 10 ) {
1164 1164
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1165
-            return $sub . (($length < $original_len) ? $continue : '');
1165
+            return $sub . ( ( $length < $original_len ) ? $continue : '' );
1166 1166
         }
1167 1167
 
1168 1168
         $sub = '';
@@ -1171,23 +1171,23 @@  discard block
 block discarded – undo
1171 1171
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1172 1172
 
1173 1173
 		foreach ( $words as $word ) {
1174
-            $part = (($sub != '') ? ' ' : '') . $word;
1174
+            $part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1175 1175
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1176
-            if ( $total_len > $length && str_word_count($sub) ) {
1176
+            if ( $total_len > $length && str_word_count( $sub ) ) {
1177 1177
                 break;
1178 1178
             }
1179 1179
 
1180 1180
             $sub .= $part;
1181 1181
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1182 1182
 
1183
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1183
+            if ( str_word_count( $sub ) > $minword && $total_len >= $length ) {
1184 1184
                 break;
1185 1185
             }
1186 1186
 
1187
-            unset($total_len, $word);
1187
+            unset( $total_len, $word );
1188 1188
         }
1189 1189
 
1190
-        return $sub . (($len < $original_len) ? $continue : '');
1190
+        return $sub . ( ( $len < $original_len ) ? $continue : '' );
1191 1191
     }
1192 1192
 
1193 1193
 	public static function mb_function( $function_names, $args ) {
@@ -1200,17 +1200,17 @@  discard block
 block discarded – undo
1200 1200
 	}
1201 1201
 
1202 1202
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1203
-        if ( empty($date) ) {
1203
+        if ( empty( $date ) ) {
1204 1204
             return $date;
1205 1205
         }
1206 1206
 
1207
-        if ( empty($date_format) ) {
1208
-            $date_format = get_option('date_format');
1207
+        if ( empty( $date_format ) ) {
1208
+            $date_format = get_option( 'date_format' );
1209 1209
         }
1210 1210
 
1211
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1211
+        if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1212 1212
             $frmpro_settings = new FrmProSettings();
1213
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1213
+            $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1214 1214
         }
1215 1215
 
1216 1216
 		$formatted = self::get_localized_date( $date_format, $date );
@@ -1225,7 +1225,7 @@  discard block
 block discarded – undo
1225 1225
 
1226 1226
 	private static function add_time_to_date( $time_format, $date ) {
1227 1227
 		if ( empty( $time_format ) ) {
1228
-			$time_format = get_option('time_format');
1228
+			$time_format = get_option( 'time_format' );
1229 1229
 		}
1230 1230
 
1231 1231
 		$trimmed_format = trim( $time_format );
@@ -1271,10 +1271,10 @@  discard block
 block discarded – undo
1271 1271
 		$time_strings = self::get_time_strings();
1272 1272
 
1273 1273
 		foreach ( $time_strings as $k => $v ) {
1274
-			if ( $diff[ $k ] ) {
1275
-				$time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] );
1274
+			if ( $diff[$k] ) {
1275
+				$time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] );
1276 1276
 			} else {
1277
-				unset( $time_strings[ $k ] );
1277
+				unset( $time_strings[$k] );
1278 1278
 			}
1279 1279
 		}
1280 1280
 
@@ -1312,7 +1312,7 @@  discard block
 block discarded – undo
1312 1312
      */
1313 1313
 	public static function esc_like( $term ) {
1314 1314
         global $wpdb;
1315
-        if ( method_exists($wpdb, 'esc_like') ) {
1315
+        if ( method_exists( $wpdb, 'esc_like' ) ) {
1316 1316
 			// WP 4.0
1317 1317
             $term = $wpdb->esc_like( $term );
1318 1318
         } else {
@@ -1326,17 +1326,17 @@  discard block
 block discarded – undo
1326 1326
      * @param string $order_query
1327 1327
      */
1328 1328
 	public static function esc_order( $order_query ) {
1329
-        if ( empty($order_query) ) {
1329
+        if ( empty( $order_query ) ) {
1330 1330
             return '';
1331 1331
         }
1332 1332
 
1333 1333
         // remove ORDER BY before santizing
1334
-        $order_query = strtolower($order_query);
1335
-        if ( strpos($order_query, 'order by') !== false ) {
1336
-            $order_query = str_replace('order by', '', $order_query);
1334
+        $order_query = strtolower( $order_query );
1335
+        if ( strpos( $order_query, 'order by' ) !== false ) {
1336
+            $order_query = str_replace( 'order by', '', $order_query );
1337 1337
         }
1338 1338
 
1339
-        $order_query = explode(' ', trim($order_query));
1339
+        $order_query = explode( ' ', trim( $order_query ) );
1340 1340
 
1341 1341
         $order_fields = array(
1342 1342
             'id', 'form_key', 'name', 'description',
@@ -1344,13 +1344,13 @@  discard block
 block discarded – undo
1344 1344
             'default_template', 'status', 'created_at',
1345 1345
         );
1346 1346
 
1347
-        $order = trim(trim(reset($order_query), ','));
1348
-        if ( ! in_array($order, $order_fields) ) {
1347
+        $order = trim( trim( reset( $order_query ), ',' ) );
1348
+        if ( ! in_array( $order, $order_fields ) ) {
1349 1349
             return '';
1350 1350
         }
1351 1351
 
1352 1352
         $order_by = '';
1353
-        if ( count($order_query) > 1 ) {
1353
+        if ( count( $order_query ) > 1 ) {
1354 1354
 			$order_by = end( $order_query );
1355 1355
 			self::esc_order_by( $order_by );
1356 1356
         }
@@ -1372,23 +1372,23 @@  discard block
 block discarded – undo
1372 1372
      * @param string $limit
1373 1373
      */
1374 1374
 	public static function esc_limit( $limit ) {
1375
-        if ( empty($limit) ) {
1375
+        if ( empty( $limit ) ) {
1376 1376
             return '';
1377 1377
         }
1378 1378
 
1379
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1380
-        if ( is_numeric($limit) ) {
1379
+        $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) );
1380
+        if ( is_numeric( $limit ) ) {
1381 1381
 			return ' LIMIT ' . $limit;
1382 1382
         }
1383 1383
 
1384
-        $limit = explode(',', trim($limit));
1384
+        $limit = explode( ',', trim( $limit ) );
1385 1385
         foreach ( $limit as $k => $l ) {
1386 1386
             if ( is_numeric( $l ) ) {
1387
-                $limit[ $k ] = $l;
1387
+                $limit[$k] = $l;
1388 1388
             }
1389 1389
         }
1390 1390
 
1391
-        $limit = implode(',', $limit);
1391
+        $limit = implode( ',', $limit );
1392 1392
 		return ' LIMIT ' . $limit;
1393 1393
     }
1394 1394
 
@@ -1397,12 +1397,12 @@  discard block
 block discarded – undo
1397 1397
      * @since 2.0
1398 1398
      */
1399 1399
     public static function prepare_array_values( $array, $type = '%s' ) {
1400
-        $placeholders = array_fill(0, count($array), $type);
1401
-        return implode(', ', $placeholders);
1400
+        $placeholders = array_fill( 0, count( $array ), $type );
1401
+        return implode( ', ', $placeholders );
1402 1402
     }
1403 1403
 
1404 1404
     public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1405
-        if ( empty($where) ) {
1405
+        if ( empty( $where ) ) {
1406 1406
             return '';
1407 1407
         }
1408 1408
 
@@ -1443,19 +1443,19 @@  discard block
 block discarded – undo
1443 1443
 	public static function json_to_array( $json_vars ) {
1444 1444
         $vars = array();
1445 1445
         foreach ( $json_vars as $jv ) {
1446
-            $jv_name = explode('[', $jv['name']);
1447
-            $last = count($jv_name) - 1;
1446
+            $jv_name = explode( '[', $jv['name'] );
1447
+            $last = count( $jv_name ) - 1;
1448 1448
             foreach ( $jv_name as $p => $n ) {
1449
-                $name = trim($n, ']');
1450
-                if ( ! isset($l1) ) {
1449
+                $name = trim( $n, ']' );
1450
+                if ( ! isset( $l1 ) ) {
1451 1451
                     $l1 = $name;
1452 1452
                 }
1453 1453
 
1454
-                if ( ! isset($l2) ) {
1454
+                if ( ! isset( $l2 ) ) {
1455 1455
                     $l2 = $name;
1456 1456
                 }
1457 1457
 
1458
-                if ( ! isset($l3) ) {
1458
+                if ( ! isset( $l3 ) ) {
1459 1459
                     $l3 = $name;
1460 1460
                 }
1461 1461
 
@@ -1469,24 +1469,24 @@  discard block
 block discarded – undo
1469 1469
 
1470 1470
                     case 1:
1471 1471
                         $l2 = $name;
1472
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1472
+                        self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] );
1473 1473
                     break;
1474 1474
 
1475 1475
                     case 2:
1476 1476
                         $l3 = $name;
1477
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1477
+                        self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] );
1478 1478
                     break;
1479 1479
 
1480 1480
                     case 3:
1481 1481
                         $l4 = $name;
1482
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1482
+                        self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] );
1483 1483
                     break;
1484 1484
                 }
1485 1485
 
1486
-                unset($this_val, $n);
1486
+                unset( $this_val, $n );
1487 1487
             }
1488 1488
 
1489
-            unset($last, $jv);
1489
+            unset( $last, $jv );
1490 1490
         }
1491 1491
 
1492 1492
         return $vars;
@@ -1499,8 +1499,8 @@  discard block
 block discarded – undo
1499 1499
     public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1500 1500
         if ( $name == '' ) {
1501 1501
             $vars[] = $val;
1502
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1503
-            $vars[ $l1 ] = $val;
1502
+        } else if ( ! isset( $vars[$l1] ) ) {
1503
+            $vars[$l1] = $val;
1504 1504
         }
1505 1505
     }
1506 1506
 
@@ -1515,7 +1515,7 @@  discard block
 block discarded – undo
1515 1515
             'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ),
1516 1516
         );
1517 1517
 
1518
-        if ( ! isset( $tooltips[ $name ] ) ) {
1518
+        if ( ! isset( $tooltips[$name] ) ) {
1519 1519
             return;
1520 1520
         }
1521 1521
 
@@ -1525,7 +1525,7 @@  discard block
 block discarded – undo
1525 1525
             echo ' class="frm_help"';
1526 1526
         }
1527 1527
 
1528
-		echo ' title="' . esc_attr( $tooltips[ $name ] );
1528
+		echo ' title="' . esc_attr( $tooltips[$name] );
1529 1529
 
1530 1530
         if ( 'open' != $class ) {
1531 1531
             echo '"';
@@ -1577,13 +1577,13 @@  discard block
 block discarded – undo
1577 1577
     }
1578 1578
 
1579 1579
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1580
-		if ( ! isset( $post_content[ $key ] ) ) {
1580
+		if ( ! isset( $post_content[$key] ) ) {
1581 1581
 			return;
1582 1582
 		}
1583 1583
 
1584 1584
 		if ( is_array( $val ) ) {
1585 1585
 			foreach ( $val as $k1 => $v1 ) {
1586
-				self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] );
1586
+				self::prepare_action_slashes( $v1, $k1, $post_content[$key] );
1587 1587
 				unset( $k1, $v1 );
1588 1588
 			}
1589 1589
 		} else {
@@ -1591,7 +1591,7 @@  discard block
 block discarded – undo
1591 1591
 			$val = stripslashes( $val );
1592 1592
 
1593 1593
 			// Add backslashes before double quotes and forward slashes only
1594
-			$post_content[ $key ] = addcslashes( $val, '"\\/' );
1594
+			$post_content[$key] = addcslashes( $val, '"\\/' );
1595 1595
 		}
1596 1596
 	}
1597 1597
 
@@ -1608,7 +1608,7 @@  discard block
 block discarded – undo
1608 1608
 		$settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] );
1609 1609
 
1610 1610
 		if ( empty( $settings['ID'] ) ) {
1611
-			unset( $settings['ID']);
1611
+			unset( $settings['ID'] );
1612 1612
 		}
1613 1613
 
1614 1614
 		// delete all caches for this group
@@ -1642,17 +1642,17 @@  discard block
 block discarded – undo
1642 1642
 	}
1643 1643
 
1644 1644
 	public static function maybe_json_decode( $string ) {
1645
-        if ( is_array($string) ) {
1645
+        if ( is_array( $string ) ) {
1646 1646
             return $string;
1647 1647
         }
1648 1648
 
1649
-        $new_string = json_decode($string, true);
1650
-        if ( function_exists('json_last_error') ) {
1649
+        $new_string = json_decode( $string, true );
1650
+        if ( function_exists( 'json_last_error' ) ) {
1651 1651
 			// php 5.3+
1652 1652
             if ( json_last_error() == JSON_ERROR_NONE ) {
1653 1653
                 $string = $new_string;
1654 1654
             }
1655
-        } else if ( isset($new_string) ) {
1655
+        } else if ( isset( $new_string ) ) {
1656 1656
 			// php < 5.3 fallback
1657 1657
             $string = $new_string;
1658 1658
         }
@@ -1668,11 +1668,11 @@  discard block
 block discarded – undo
1668 1668
 	public static function maybe_highlight_menu( $post_type ) {
1669 1669
         global $post;
1670 1670
 
1671
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1671
+        if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1672 1672
             return;
1673 1673
         }
1674 1674
 
1675
-        if ( is_object($post) && $post->post_type != $post_type ) {
1675
+        if ( is_object( $post ) && $post->post_type != $post_type ) {
1676 1676
             return;
1677 1677
         }
1678 1678
 
@@ -1773,11 +1773,11 @@  discard block
 block discarded – undo
1773 1773
         $frm_version = self::plugin_version();
1774 1774
 
1775 1775
         // check if Formidable meets minimum requirements
1776
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1776
+        if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1777 1777
             return;
1778 1778
         }
1779 1779
 
1780
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1780
+        $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1781 1781
 		echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' .
1782 1782
         __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1783 1783
         '</div></td></tr>';
@@ -1785,38 +1785,38 @@  discard block
 block discarded – undo
1785 1785
 
1786 1786
     public static function locales( $type = 'date' ) {
1787 1787
         $locales = array(
1788
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1789
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1790
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1788
+            'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ),
1789
+            'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ),
1790
+            'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ),
1791 1791
             'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1792
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1793
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1792
+            'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ),
1793
+            'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1794 1794
             'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1795
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1796
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1795
+            'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ),
1796
+            'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ),
1797 1797
             'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1798
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1798
+            'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ),
1799 1799
             'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1800
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1800
+            'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ),
1801 1801
             'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1802
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1802
+            'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ),
1803 1803
             'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1804
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1805
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1806
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1807
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1808
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1804
+            'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ),
1805
+            'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ),
1806
+            'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ),
1807
+            'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ),
1808
+            'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ),
1809 1809
             'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1810
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1810
+            'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ),
1811 1811
             'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1812 1812
             'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1813
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1813
+            'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ),
1814 1814
             'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1815
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1815
+            'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ),
1816 1816
             'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1817
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1818
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1819
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1817
+            'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ),
1818
+            'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ),
1819
+            'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ),
1820 1820
         );
1821 1821
 
1822 1822
         if ( $type == 'captcha' ) {
@@ -1835,8 +1835,8 @@  discard block
 block discarded – undo
1835 1835
             );
1836 1836
         }
1837 1837
 
1838
-        $locales = array_diff_key($locales, array_flip($unset));
1839
-        $locales = apply_filters('frm_locales', $locales);
1838
+        $locales = array_diff_key( $locales, array_flip( $unset ) );
1839
+        $locales = apply_filters( 'frm_locales', $locales );
1840 1840
 
1841 1841
         return $locales;
1842 1842
     }
Please login to merge, or discard this patch.
classes/models/FrmField.php 2 patches
Indentation   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 }
5 5
 
6 6
 class FrmField {
7
-    static $use_cache = true;
7
+	static $use_cache = true;
8 8
 	static $transient_size = 200;
9 9
 
10 10
 	public static function field_selection() {
@@ -51,39 +51,39 @@  discard block
 block discarded – undo
51 51
 		));
52 52
 	}
53 53
 
54
-    public static function create( $values, $return = true ) {
55
-        global $wpdb, $frm_duplicate_ids;
54
+	public static function create( $values, $return = true ) {
55
+		global $wpdb, $frm_duplicate_ids;
56 56
 
57
-        $new_values = array();
58
-        $key = isset($values['field_key']) ? $values['field_key'] : $values['name'];
57
+		$new_values = array();
58
+		$key = isset($values['field_key']) ? $values['field_key'] : $values['name'];
59 59
 		$new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' );
60 60
 
61 61
 		foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) {
62 62
 			$new_values[ $col ] = $values[ $col ];
63
-        }
63
+		}
64 64
 
65
-        $new_values['options'] = $values['options'];
65
+		$new_values['options'] = $values['options'];
66 66
 
67
-        $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null;
68
-        $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0;
69
-        $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null;
70
-        $new_values['field_options'] = $values['field_options'];
71
-        $new_values['created_at'] = current_time('mysql', 1);
67
+		$new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null;
68
+		$new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0;
69
+		$new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null;
70
+		$new_values['field_options'] = $values['field_options'];
71
+		$new_values['created_at'] = current_time('mysql', 1);
72 72
 
73 73
 		if ( isset( $values['id'] ) ) {
74 74
 			$frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key'];
75
-            $new_values = apply_filters('frm_duplicated_field', $new_values);
76
-        }
75
+			$new_values = apply_filters('frm_duplicated_field', $new_values);
76
+		}
77 77
 
78 78
 		foreach ( $new_values as $k => $v ) {
79
-            if ( is_array( $v ) ) {
79
+			if ( is_array( $v ) ) {
80 80
 				$new_values[ $k ] = serialize( $v );
81 81
 			}
82
-            unset( $k, $v );
83
-        }
82
+			unset( $k, $v );
83
+		}
84 84
 
85
-        //if(isset($values['id']) and is_numeric($values['id']))
86
-        //    $new_values['id'] = $values['id'];
85
+		//if(isset($values['id']) and is_numeric($values['id']))
86
+		//    $new_values['id'] = $values['id'];
87 87
 
88 88
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_fields', $new_values );
89 89
 		$new_id = 0;
@@ -104,22 +104,22 @@  discard block
 block discarded – undo
104 104
 		} else {
105 105
 			return false;
106 106
 		}
107
-    }
107
+	}
108 108
 
109
-    public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) {
110
-        global $frm_duplicate_ids;
109
+	public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) {
110
+		global $frm_duplicate_ids;
111 111
 
112 112
 		$where = array( array( 'or' => 1, 'fi.form_id' => $old_form_id, 'fr.parent_form_id' => $old_form_id ) );
113 113
 		$fields = self::getAll( $where, 'field_order', '', $blog_id );
114 114
 
115
-        foreach ( (array) $fields as $field ) {
116
-            $new_key = ($copy_keys) ? $field->field_key : '';
117
-            if ( $copy_keys && substr($field->field_key, -1) == 2 ) {
118
-                $new_key = rtrim($new_key, 2);
119
-            }
115
+		foreach ( (array) $fields as $field ) {
116
+			$new_key = ($copy_keys) ? $field->field_key : '';
117
+			if ( $copy_keys && substr($field->field_key, -1) == 2 ) {
118
+				$new_key = rtrim($new_key, 2);
119
+			}
120 120
 
121
-            $values = array();
122
-            FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key );
121
+			$values = array();
122
+			FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key );
123 123
 
124 124
 			// If this is a repeating section, create new form
125 125
 			if ( self::is_repeating_field( $field ) ) {
@@ -138,16 +138,16 @@  discard block
 block discarded – undo
138 138
 				$values['form_id'] = $new_repeat_form_id;
139 139
 			}
140 140
 
141
-            $values = apply_filters('frm_duplicated_field', $values);
142
-            $new_id = self::create($values);
143
-            $frm_duplicate_ids[ $field->id ] = $new_id;
144
-            $frm_duplicate_ids[ $field->field_key ] = $new_id;
145
-            unset($field);
146
-        }
147
-    }
141
+			$values = apply_filters('frm_duplicated_field', $values);
142
+			$new_id = self::create($values);
143
+			$frm_duplicate_ids[ $field->id ] = $new_id;
144
+			$frm_duplicate_ids[ $field->field_key ] = $new_id;
145
+			unset($field);
146
+		}
147
+	}
148 148
 
149 149
 	public static function update( $id, $values ) {
150
-        global $wpdb;
150
+		global $wpdb;
151 151
 
152 152
 		$id = absint( $id );
153 153
 
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 			$values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id );
156 156
 		}
157 157
 
158
-        if ( isset($values['required']) ) {
159
-            $values['required'] = (int) $values['required'];
160
-        }
158
+		if ( isset($values['required']) ) {
159
+			$values['required'] = (int) $values['required'];
160
+		}
161 161
 
162 162
 		self::preserve_format_option_backslashes( $values );
163 163
 
@@ -174,41 +174,41 @@  discard block
 block discarded – undo
174 174
 
175 175
 		$query_results = $wpdb->update( $wpdb->prefix . 'frm_fields', $values, array( 'id' => $id ) );
176 176
 
177
-        $form_id = 0;
177
+		$form_id = 0;
178 178
 		if ( isset( $values['form_id'] ) ) {
179
-            $form_id = absint( $values['form_id'] );
179
+			$form_id = absint( $values['form_id'] );
180 180
 		} else {
181
-            $field = self::getOne($id);
182
-            if ( $field ) {
183
-                $form_id = $field->form_id;
184
-            }
185
-            unset($field);
186
-        }
187
-        unset($values);
181
+			$field = self::getOne($id);
182
+			if ( $field ) {
183
+				$form_id = $field->form_id;
184
+			}
185
+			unset($field);
186
+		}
187
+		unset($values);
188 188
 
189 189
 		if ( $query_results ) {
190
-            wp_cache_delete( $id, 'frm_field' );
191
-            if ( $form_id ) {
192
-                self::delete_form_transient( $form_id );
193
-            }
194
-        }
190
+			wp_cache_delete( $id, 'frm_field' );
191
+			if ( $form_id ) {
192
+				self::delete_form_transient( $form_id );
193
+			}
194
+		}
195 195
 
196
-        return $query_results;
197
-    }
196
+		return $query_results;
197
+	}
198 198
 
199 199
 	/**
200
-	* Keep backslashes in the phone format option
201
-	*
202
-	* @since 2.0.8
203
-	* @param $values array - pass by reference
204
-	*/
200
+	 * Keep backslashes in the phone format option
201
+	 *
202
+	 * @since 2.0.8
203
+	 * @param $values array - pass by reference
204
+	 */
205 205
 	private static function preserve_format_option_backslashes( &$values ) {
206 206
 		if ( isset( $values['field_options']['format'] ) ) {
207 207
 			$values['field_options']['format'] = FrmAppHelper::preserve_backslashes( $values['field_options']['format'] );
208 208
 		}
209 209
 	}
210 210
 
211
-    public static function destroy( $id ) {
211
+	public static function destroy( $id ) {
212 212
 		global $wpdb;
213 213
 
214 214
 		do_action( 'frm_before_destroy_field', $id );
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 
224 224
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id=%d', $id ) );
225 225
 		return $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_fields WHERE id=%d', $id ) );
226
-    }
226
+	}
227 227
 
228 228
 	public static function delete_form_transient( $form_id ) {
229 229
 		$form_id = absint( $form_id );
@@ -236,17 +236,17 @@  discard block
 block discarded – undo
236 236
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_' . $form_id . 'ex%', '_transient_frm_form_fields_' . $form_id . 'ex%', '_transient_timeout_frm_form_fields_' . $form_id . 'in%', '_transient_frm_form_fields_' . $form_id . 'in%' ) );
237 237
 
238 238
 		$cache_key = serialize( array( 'fi.form_id' => $form_id ) ) . 'field_orderlb';
239
-        wp_cache_delete($cache_key, 'frm_field');
239
+		wp_cache_delete($cache_key, 'frm_field');
240 240
 
241 241
 		// this cache key is autogenerated in FrmDb::get_var
242 242
 		wp_cache_delete( '(__fi.form_id=%d_OR_fr.parent_form_id=%d_)__' . $form_id . '_' . $form_id . '_ORDER_BY_field_orderfi.*__fr.name_as_form_name_results', 'frm_field' );
243 243
 		wp_cache_delete( '1_' . $form_id . '_' . $form_id . '_ORDER_BY_field_orderfi.*__fr.name_as_form_name_results', 'frm_field' );
244 244
 
245
-        $form = FrmForm::getOne($form_id);
246
-        if ( $form && $form->parent_form_id ) {
247
-            self::delete_form_transient( $form->parent_form_id );
248
-        }
249
-    }
245
+		$form = FrmForm::getOne($form_id);
246
+		if ( $form && $form->parent_form_id ) {
247
+			self::delete_form_transient( $form->parent_form_id );
248
+		}
249
+	}
250 250
 
251 251
 	/**
252 252
 	 * If $field is numeric, get the field object
@@ -262,131 +262,131 @@  discard block
 block discarded – undo
262 262
 			return;
263 263
 		}
264 264
 
265
-        global $wpdb;
265
+		global $wpdb;
266 266
 
267
-        $where = is_numeric($id) ? 'id=%d' : 'field_key=%s';
267
+		$where = is_numeric($id) ? 'id=%d' : 'field_key=%s';
268 268
 		$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id );
269 269
 
270
-        $results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
270
+		$results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
271 271
 
272
-        if ( empty($results) ) {
273
-            return $results;
274
-        }
272
+		if ( empty($results) ) {
273
+			return $results;
274
+		}
275 275
 
276
-        if ( is_numeric($id) ) {
277
-            wp_cache_set( $results->field_key, $results, 'frm_field' );
278
-        } else if ( $results ) {
279
-            wp_cache_set( $results->id, $results, 'frm_field' );
280
-        }
276
+		if ( is_numeric($id) ) {
277
+			wp_cache_set( $results->field_key, $results, 'frm_field' );
278
+		} else if ( $results ) {
279
+			wp_cache_set( $results->id, $results, 'frm_field' );
280
+		}
281 281
 
282 282
 		self::prepare_options( $results );
283 283
 
284
-        return stripslashes_deep($results);
285
-    }
284
+		return stripslashes_deep($results);
285
+	}
286 286
 
287
-    /**
288
-     * Get the field type by key or id
289
-     * @param int|string The field id or key
287
+	/**
288
+	 * Get the field type by key or id
289
+	 * @param int|string The field id or key
290 290
 	 * @param mixed $col The name of the column in the fields database table
291
-     */
292
-    public static function &get_type( $id, $col = 'type' ) {
293
-        $field = FrmAppHelper::check_cache( $id, 'frm_field' );
294
-        if ( $field ) {
295
-            $type = $field->{$col};
296
-        } else {
297
-            $type = FrmDb::get_var( 'frm_fields', array( 'or' => 1, 'id' => $id, 'field_key' => $id ), $col );
298
-        }
299
-
300
-        return $type;
301
-    }
291
+	 */
292
+	public static function &get_type( $id, $col = 'type' ) {
293
+		$field = FrmAppHelper::check_cache( $id, 'frm_field' );
294
+		if ( $field ) {
295
+			$type = $field->{$col};
296
+		} else {
297
+			$type = FrmDb::get_var( 'frm_fields', array( 'or' => 1, 'id' => $id, 'field_key' => $id ), $col );
298
+		}
299
+
300
+		return $type;
301
+	}
302 302
 
303 303
 	public static function get_all_types_in_form( $form_id, $type, $limit = '', $inc_sub = 'exclude' ) {
304
-        if ( ! $form_id ) {
305
-            return array();
306
-        }
304
+		if ( ! $form_id ) {
305
+			return array();
306
+		}
307 307
 
308 308
 		$results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_sub, 'inc_repeat' => $inc_sub ) );
309 309
 		if ( ! empty( $results ) ) {
310
-            $fields = array();
311
-            $count = 0;
312
-            foreach ( $results as $result ) {
313
-                if ( $type != $result->type ) {
314
-                    continue;
315
-                }
310
+			$fields = array();
311
+			$count = 0;
312
+			foreach ( $results as $result ) {
313
+				if ( $type != $result->type ) {
314
+					continue;
315
+				}
316 316
 
317 317
 				$fields[ $result->id ] = $result;
318
-                $count++;
319
-                if ( $limit == 1 ) {
320
-                    $fields = $result;
321
-                    break;
322
-                }
318
+				$count++;
319
+				if ( $limit == 1 ) {
320
+					$fields = $result;
321
+					break;
322
+				}
323 323
 
324
-                if ( ! empty($limit) && $count >= $limit ) {
325
-                    break;
326
-                }
324
+				if ( ! empty($limit) && $count >= $limit ) {
325
+					break;
326
+				}
327 327
 
328
-                unset($result);
329
-            }
330
-            return stripslashes_deep($fields);
331
-        }
328
+				unset($result);
329
+			}
330
+			return stripslashes_deep($fields);
331
+		}
332 332
 
333
-        self::$use_cache = false;
333
+		self::$use_cache = false;
334 334
 
335 335
 		$where = array( 'fi.form_id' => (int) $form_id, 'fi.type' => $type );
336 336
 		self::maybe_include_repeating_fields( $inc_sub, $where );
337 337
 		$results = self::getAll( $where, 'field_order', $limit );
338
-        self::$use_cache = true;
339
-        self::include_sub_fields($results, $inc_sub, $type);
338
+		self::$use_cache = true;
339
+		self::include_sub_fields($results, $inc_sub, $type);
340 340
 
341
-        return $results;
342
-    }
341
+		return $results;
342
+	}
343 343
 
344 344
 	public static function get_all_for_form( $form_id, $limit = '', $inc_embed = 'exclude', $inc_repeat = 'include' ) {
345
-        if ( ! (int) $form_id ) {
346
-            return array();
347
-        }
345
+		if ( ! (int) $form_id ) {
346
+			return array();
347
+		}
348 348
 
349 349
 		$results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) );
350 350
 		if ( ! empty( $results ) ) {
351
-            if ( empty($limit) ) {
351
+			if ( empty($limit) ) {
352 352
 				return $results;
353
-            }
353
+			}
354 354
 
355
-            $fields = array();
356
-            $count = 0;
357
-            foreach ( $results as $result ) {
355
+			$fields = array();
356
+			$count = 0;
357
+			foreach ( $results as $result ) {
358 358
 				$fields[ $result->id ] = $result;
359
-                if ( ! empty($limit) && $count >= $limit ) {
360
-                    break;
361
-                }
362
-            }
359
+				if ( ! empty($limit) && $count >= $limit ) {
360
+					break;
361
+				}
362
+			}
363 363
 
364 364
 			return $fields;
365
-        }
365
+		}
366 366
 
367
-        self::$use_cache = false;
367
+		self::$use_cache = false;
368 368
 
369 369
 		$where = array( 'fi.form_id' => absint( $form_id ) );
370 370
 		self::maybe_include_repeating_fields( $inc_repeat, $where );
371 371
 		$results = self::getAll( $where, 'field_order', $limit );
372 372
 
373
-        self::$use_cache = true;
373
+		self::$use_cache = true;
374 374
 
375 375
 		self::include_sub_fields( $results, $inc_embed, 'all' );
376 376
 
377
-        if ( empty($limit) ) {
377
+		if ( empty($limit) ) {
378 378
 			self::set_field_transient( $results, $form_id, 0, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) );
379
-        }
379
+		}
380 380
 
381 381
 		return $results;
382
-    }
382
+	}
383 383
 
384 384
 	/**
385
-	* If repeating fields should be included, adjust $where accordingly
386
-	*
387
-	* @param string $inc_repeat
388
-	* @param array $where - pass by reference
389
-	*/
385
+	 * If repeating fields should be included, adjust $where accordingly
386
+	 *
387
+	 * @param string $inc_repeat
388
+	 * @param array $where - pass by reference
389
+	 */
390 390
 	private static function maybe_include_repeating_fields( $inc_repeat, &$where ) {
391 391
 		if ( $inc_repeat == 'include' ) {
392 392
 			$form_id = $where['fi.form_id'];
@@ -397,77 +397,77 @@  discard block
 block discarded – undo
397 397
 
398 398
 	public static function include_sub_fields( &$results, $inc_embed, $type = 'all' ) {
399 399
 		if ( 'include' != $inc_embed || empty( $results ) ) {
400
-            return;
401
-        }
400
+			return;
401
+		}
402 402
 
403
-        $form_fields = $results;
403
+		$form_fields = $results;
404 404
 		$index_offset = 1;
405
-        foreach ( $form_fields as $k => $field ) {
406
-            if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) {
407
-                continue;
408
-            }
409
-
410
-            if ( $type == 'all' ) {
411
-                $sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
412
-            } else {
413
-                $sub_fields = self::get_all_types_in_form($field->form_id, $type);
414
-            }
415
-
416
-            if ( ! empty($sub_fields) ) {
405
+		foreach ( $form_fields as $k => $field ) {
406
+			if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) {
407
+				continue;
408
+			}
409
+
410
+			if ( $type == 'all' ) {
411
+				$sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
412
+			} else {
413
+				$sub_fields = self::get_all_types_in_form($field->form_id, $type);
414
+			}
415
+
416
+			if ( ! empty($sub_fields) ) {
417 417
 				$index = $k + $index_offset;
418 418
 				$index_offset += count( $sub_fields );
419 419
 				array_splice($results, $index, 0, $sub_fields);
420
-            }
421
-            unset($field, $sub_fields);
422
-        }
423
-    }
420
+			}
421
+			unset($field, $sub_fields);
422
+		}
423
+	}
424 424
 
425 425
 	public static function getAll( $where = array(), $order_by = '', $limit = '', $blog_id = false ) {
426 426
 		$cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id;
427
-        if ( self::$use_cache ) {
428
-            // make sure old cache doesn't get saved as a transient
429
-            $results = wp_cache_get($cache_key, 'frm_field');
430
-            if ( false !== $results ) {
431
-                return stripslashes_deep($results);
432
-            }
433
-        }
434
-
435
-        global $wpdb;
436
-
437
-        if ( $blog_id && is_multisite() ) {
438
-            global $wpmuBaseTablePrefix;
439
-            if ( $wpmuBaseTablePrefix ) {
427
+		if ( self::$use_cache ) {
428
+			// make sure old cache doesn't get saved as a transient
429
+			$results = wp_cache_get($cache_key, 'frm_field');
430
+			if ( false !== $results ) {
431
+				return stripslashes_deep($results);
432
+			}
433
+		}
434
+
435
+		global $wpdb;
436
+
437
+		if ( $blog_id && is_multisite() ) {
438
+			global $wpmuBaseTablePrefix;
439
+			if ( $wpmuBaseTablePrefix ) {
440 440
 				$prefix = $wpmuBaseTablePrefix . $blog_id . '_';
441
-            } else {
442
-                $prefix = $wpdb->get_blog_prefix( $blog_id );
443
-            }
441
+			} else {
442
+				$prefix = $wpdb->get_blog_prefix( $blog_id );
443
+			}
444 444
 
445 445
 			$table_name = $prefix . 'frm_fields';
446 446
 			$form_table_name = $prefix . 'frm_forms';
447 447
 		} else {
448 448
 			$table_name = $wpdb->prefix . 'frm_fields';
449 449
 			$form_table_name = $wpdb->prefix . 'frm_forms';
450
-        }
450
+		}
451 451
 
452 452
 		if ( ! empty( $order_by ) && strpos( $order_by, 'ORDER BY' ) === false ) {
453 453
 			$order_by = ' ORDER BY ' . $order_by;
454 454
 		}
455 455
 
456
-        $limit = FrmAppHelper::esc_limit($limit);
456
+		$limit = FrmAppHelper::esc_limit($limit);
457 457
 
458
-        $query = "SELECT fi.*, fr.name as form_name  FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
459
-        $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results';
458
+		$query = "SELECT fi.*, fr.name as form_name  FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
459
+		$query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results';
460 460
 
461
-        if ( is_array($where) ) {
462
-            $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type );
461
+		if ( is_array($where) ) {
462
+			$results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type );
463 463
 		} else {
464 464
 			// if the query is not an array, then it has already been prepared
465
-            $query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
465
+			$query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
466 466
 
467 467
 			$function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results';
468 468
 			$results = $wpdb->$function_name( $query );
469
-        }
470
-        unset( $where );
469
+		}
470
+		unset( $where );
471 471
 
472 472
 		self::format_field_results( $results );
473 473
 
@@ -566,21 +566,21 @@  discard block
 block discarded – undo
566 566
 
567 567
 	public static function getIds( $where = '', $order_by = '', $limit = '' ) {
568 568
 		_deprecated_function( __FUNCTION__, '2.0' );
569
-        global $wpdb;
570
-        if ( ! empty($order_by) && ! strpos($order_by, 'ORDER BY') !== false ) {
569
+		global $wpdb;
570
+		if ( ! empty($order_by) && ! strpos($order_by, 'ORDER BY') !== false ) {
571 571
 			$order_by = ' ORDER BY ' . $order_by;
572
-        }
572
+		}
573 573
 
574 574
 		$query = 'SELECT fi.id  FROM ' . $wpdb->prefix . 'frm_fields fi ' .
575 575
 			'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON fi.form_id=fr.id' .
576 576
 			FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
577 577
 
578
-        $method = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'get_var' : 'get_col';
578
+		$method = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'get_var' : 'get_col';
579 579
 		$cache_key = 'getIds_' . maybe_serialize( $where ) . $order_by . $limit;
580
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_field', $query, $method);
580
+		$results = FrmAppHelper::check_cache($cache_key, 'frm_field', $query, $method);
581 581
 
582
-        return $results;
583
-    }
582
+		return $results;
583
+	}
584 584
 
585 585
 	public static function is_no_save_field( $type ) {
586 586
 		return in_array( $type, self::no_save_fields() );
@@ -723,8 +723,8 @@  discard block
 block discarded – undo
723 723
 	}
724 724
 
725 725
 	/**
726
-	* @since 2.0.09
727
-	*/
726
+	 * @since 2.0.09
727
+	 */
728 728
 	public static function is_repeating_field( $field ) {
729 729
 		if ( is_array( $field ) ) {
730 730
 			$is_repeating_field = ( 'divider' == $field['type'] );
@@ -734,14 +734,14 @@  discard block
 block discarded – undo
734 734
 		return ( $is_repeating_field && self::is_option_true( $field, 'repeat' ) );
735 735
 	}
736 736
 
737
-    /**
738
-     * @param string $key
739
-     * @return int field id
740
-     */
737
+	/**
738
+	 * @param string $key
739
+	 * @return int field id
740
+	 */
741 741
 	public static function get_id_by_key( $key ) {
742
-        $id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) );
743
-        return $id;
744
-    }
742
+		$id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) );
743
+		return $id;
744
+	}
745 745
 
746 746
 	/**
747 747
 	 * @param string $id
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 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
 
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 	static $transient_size = 200;
9 9
 
10 10
 	public static function field_selection() {
11
-		$fields = apply_filters('frm_available_fields', array(
11
+		$fields = apply_filters( 'frm_available_fields', array(
12 12
 			'text'      => __( 'Single Line Text', 'formidable' ),
13 13
 			'textarea'  => __( 'Paragraph Text', 'formidable' ),
14 14
 			'checkbox'  => __( 'Checkboxes', 'formidable' ),
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
 			'email'     => __( 'Email Address', 'formidable' ),
18 18
 			'url'       => __( 'Website/URL', 'formidable' ),
19 19
 			'captcha'   => __( 'reCAPTCHA', 'formidable' ),
20
-		));
20
+		) );
21 21
 
22 22
 		return $fields;
23 23
 	}
24 24
 
25 25
 	public static function pro_field_selection() {
26
-		return apply_filters('frm_pro_available_fields', array(
26
+		return apply_filters( 'frm_pro_available_fields', array(
27 27
 			'end_divider' => array(
28 28
 				'name'  => __( 'End Section', 'formidable' ),
29 29
 				'switch_from' => 'divider',
@@ -48,36 +48,36 @@  discard block
 block discarded – undo
48 48
 			'tag'       => __( 'Tags', 'formidable' ),
49 49
 			'credit_card' => __( 'Credit Card', 'formidable' ),
50 50
 			'address'   => __( 'Address', 'formidable' ),
51
-		));
51
+		) );
52 52
 	}
53 53
 
54 54
     public static function create( $values, $return = true ) {
55 55
         global $wpdb, $frm_duplicate_ids;
56 56
 
57 57
         $new_values = array();
58
-        $key = isset($values['field_key']) ? $values['field_key'] : $values['name'];
58
+        $key = isset( $values['field_key'] ) ? $values['field_key'] : $values['name'];
59 59
 		$new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' );
60 60
 
61 61
 		foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) {
62
-			$new_values[ $col ] = $values[ $col ];
62
+			$new_values[$col] = $values[$col];
63 63
         }
64 64
 
65 65
         $new_values['options'] = $values['options'];
66 66
 
67
-        $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null;
68
-        $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0;
69
-        $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null;
67
+        $new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null;
68
+        $new_values['required'] = isset( $values['required'] ) ? (int) $values['required'] : 0;
69
+        $new_values['form_id'] = isset( $values['form_id'] ) ? (int) $values['form_id'] : null;
70 70
         $new_values['field_options'] = $values['field_options'];
71
-        $new_values['created_at'] = current_time('mysql', 1);
71
+        $new_values['created_at'] = current_time( 'mysql', 1 );
72 72
 
73 73
 		if ( isset( $values['id'] ) ) {
74
-			$frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key'];
75
-            $new_values = apply_filters('frm_duplicated_field', $new_values);
74
+			$frm_duplicate_ids[$values['field_key']] = $new_values['field_key'];
75
+            $new_values = apply_filters( 'frm_duplicated_field', $new_values );
76 76
         }
77 77
 
78 78
 		foreach ( $new_values as $k => $v ) {
79 79
             if ( is_array( $v ) ) {
80
-				$new_values[ $k ] = serialize( $v );
80
+				$new_values[$k] = serialize( $v );
81 81
 			}
82 82
             unset( $k, $v );
83 83
         }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
 		if ( $query_results ) {
100 100
 			if ( isset( $values['id'] ) ) {
101
-				$frm_duplicate_ids[ $values['id'] ] = $new_id;
101
+				$frm_duplicate_ids[$values['id']] = $new_id;
102 102
 			}
103 103
 			return $new_id;
104 104
 		} else {
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 		$fields = self::getAll( $where, 'field_order', '', $blog_id );
114 114
 
115 115
         foreach ( (array) $fields as $field ) {
116
-            $new_key = ($copy_keys) ? $field->field_key : '';
117
-            if ( $copy_keys && substr($field->field_key, -1) == 2 ) {
118
-                $new_key = rtrim($new_key, 2);
116
+            $new_key = ( $copy_keys ) ? $field->field_key : '';
117
+            if ( $copy_keys && substr( $field->field_key, -1 ) == 2 ) {
118
+                $new_key = rtrim( $new_key, 2 );
119 119
             }
120 120
 
121 121
             $values = array();
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
 				$values['form_id'] = $new_repeat_form_id;
139 139
 			}
140 140
 
141
-            $values = apply_filters('frm_duplicated_field', $values);
142
-            $new_id = self::create($values);
143
-            $frm_duplicate_ids[ $field->id ] = $new_id;
144
-            $frm_duplicate_ids[ $field->field_key ] = $new_id;
145
-            unset($field);
141
+            $values = apply_filters( 'frm_duplicated_field', $values );
142
+            $new_id = self::create( $values );
143
+            $frm_duplicate_ids[$field->id] = $new_id;
144
+            $frm_duplicate_ids[$field->field_key] = $new_id;
145
+            unset( $field );
146 146
         }
147 147
     }
148 148
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 			$values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id );
156 156
 		}
157 157
 
158
-        if ( isset($values['required']) ) {
158
+        if ( isset( $values['required'] ) ) {
159 159
             $values['required'] = (int) $values['required'];
160 160
         }
161 161
 
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 
168 168
 		// serialize array values
169 169
 		foreach ( array( 'default_value', 'field_options', 'options' ) as $opt ) {
170
-			if ( isset( $values[ $opt ] ) && is_array( $values[ $opt ] ) ) {
171
-				$values[ $opt ] = serialize( $values[ $opt ] );
170
+			if ( isset( $values[$opt] ) && is_array( $values[$opt] ) ) {
171
+				$values[$opt] = serialize( $values[$opt] );
172 172
 			}
173 173
 		}
174 174
 
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
 		if ( isset( $values['form_id'] ) ) {
179 179
             $form_id = absint( $values['form_id'] );
180 180
 		} else {
181
-            $field = self::getOne($id);
181
+            $field = self::getOne( $id );
182 182
             if ( $field ) {
183 183
                 $form_id = $field->form_id;
184 184
             }
185
-            unset($field);
185
+            unset( $field );
186 186
         }
187
-        unset($values);
187
+        unset( $values );
188 188
 
189 189
 		if ( $query_results ) {
190 190
             wp_cache_delete( $id, 'frm_field' );
@@ -236,13 +236,13 @@  discard block
 block discarded – undo
236 236
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_' . $form_id . 'ex%', '_transient_frm_form_fields_' . $form_id . 'ex%', '_transient_timeout_frm_form_fields_' . $form_id . 'in%', '_transient_frm_form_fields_' . $form_id . 'in%' ) );
237 237
 
238 238
 		$cache_key = serialize( array( 'fi.form_id' => $form_id ) ) . 'field_orderlb';
239
-        wp_cache_delete($cache_key, 'frm_field');
239
+        wp_cache_delete( $cache_key, 'frm_field' );
240 240
 
241 241
 		// this cache key is autogenerated in FrmDb::get_var
242 242
 		wp_cache_delete( '(__fi.form_id=%d_OR_fr.parent_form_id=%d_)__' . $form_id . '_' . $form_id . '_ORDER_BY_field_orderfi.*__fr.name_as_form_name_results', 'frm_field' );
243 243
 		wp_cache_delete( '1_' . $form_id . '_' . $form_id . '_ORDER_BY_field_orderfi.*__fr.name_as_form_name_results', 'frm_field' );
244 244
 
245
-        $form = FrmForm::getOne($form_id);
245
+        $form = FrmForm::getOne( $form_id );
246 246
         if ( $form && $form->parent_form_id ) {
247 247
             self::delete_form_transient( $form->parent_form_id );
248 248
         }
@@ -264,16 +264,16 @@  discard block
 block discarded – undo
264 264
 
265 265
         global $wpdb;
266 266
 
267
-        $where = is_numeric($id) ? 'id=%d' : 'field_key=%s';
267
+        $where = is_numeric( $id ) ? 'id=%d' : 'field_key=%s';
268 268
 		$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id );
269 269
 
270 270
         $results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
271 271
 
272
-        if ( empty($results) ) {
272
+        if ( empty( $results ) ) {
273 273
             return $results;
274 274
         }
275 275
 
276
-        if ( is_numeric($id) ) {
276
+        if ( is_numeric( $id ) ) {
277 277
             wp_cache_set( $results->field_key, $results, 'frm_field' );
278 278
         } else if ( $results ) {
279 279
             wp_cache_set( $results->id, $results, 'frm_field' );
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 
282 282
 		self::prepare_options( $results );
283 283
 
284
-        return stripslashes_deep($results);
284
+        return stripslashes_deep( $results );
285 285
     }
286 286
 
287 287
     /**
@@ -314,20 +314,20 @@  discard block
 block discarded – undo
314 314
                     continue;
315 315
                 }
316 316
 
317
-				$fields[ $result->id ] = $result;
318
-                $count++;
317
+				$fields[$result->id] = $result;
318
+                $count ++;
319 319
                 if ( $limit == 1 ) {
320 320
                     $fields = $result;
321 321
                     break;
322 322
                 }
323 323
 
324
-                if ( ! empty($limit) && $count >= $limit ) {
324
+                if ( ! empty( $limit ) && $count >= $limit ) {
325 325
                     break;
326 326
                 }
327 327
 
328
-                unset($result);
328
+                unset( $result );
329 329
             }
330
-            return stripslashes_deep($fields);
330
+            return stripslashes_deep( $fields );
331 331
         }
332 332
 
333 333
         self::$use_cache = false;
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 		self::maybe_include_repeating_fields( $inc_sub, $where );
337 337
 		$results = self::getAll( $where, 'field_order', $limit );
338 338
         self::$use_cache = true;
339
-        self::include_sub_fields($results, $inc_sub, $type);
339
+        self::include_sub_fields( $results, $inc_sub, $type );
340 340
 
341 341
         return $results;
342 342
     }
@@ -348,15 +348,15 @@  discard block
 block discarded – undo
348 348
 
349 349
 		$results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) );
350 350
 		if ( ! empty( $results ) ) {
351
-            if ( empty($limit) ) {
351
+            if ( empty( $limit ) ) {
352 352
 				return $results;
353 353
             }
354 354
 
355 355
             $fields = array();
356 356
             $count = 0;
357 357
             foreach ( $results as $result ) {
358
-				$fields[ $result->id ] = $result;
359
-                if ( ! empty($limit) && $count >= $limit ) {
358
+				$fields[$result->id] = $result;
359
+                if ( ! empty( $limit ) && $count >= $limit ) {
360 360
                     break;
361 361
                 }
362 362
             }
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 
375 375
 		self::include_sub_fields( $results, $inc_embed, 'all' );
376 376
 
377
-        if ( empty($limit) ) {
377
+        if ( empty( $limit ) ) {
378 378
 			self::set_field_transient( $results, $form_id, 0, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) );
379 379
         }
380 380
 
@@ -403,22 +403,22 @@  discard block
 block discarded – undo
403 403
         $form_fields = $results;
404 404
 		$index_offset = 1;
405 405
         foreach ( $form_fields as $k => $field ) {
406
-            if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) {
406
+            if ( 'form' != $field->type || ! isset( $field->field_options['form_select'] ) ) {
407 407
                 continue;
408 408
             }
409 409
 
410 410
             if ( $type == 'all' ) {
411 411
                 $sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
412 412
             } else {
413
-                $sub_fields = self::get_all_types_in_form($field->form_id, $type);
413
+                $sub_fields = self::get_all_types_in_form( $field->form_id, $type );
414 414
             }
415 415
 
416
-            if ( ! empty($sub_fields) ) {
416
+            if ( ! empty( $sub_fields ) ) {
417 417
 				$index = $k + $index_offset;
418 418
 				$index_offset += count( $sub_fields );
419
-				array_splice($results, $index, 0, $sub_fields);
419
+				array_splice( $results, $index, 0, $sub_fields );
420 420
             }
421
-            unset($field, $sub_fields);
421
+            unset( $field, $sub_fields );
422 422
         }
423 423
     }
424 424
 
@@ -426,9 +426,9 @@  discard block
 block discarded – undo
426 426
 		$cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id;
427 427
         if ( self::$use_cache ) {
428 428
             // make sure old cache doesn't get saved as a transient
429
-            $results = wp_cache_get($cache_key, 'frm_field');
429
+            $results = wp_cache_get( $cache_key, 'frm_field' );
430 430
             if ( false !== $results ) {
431
-                return stripslashes_deep($results);
431
+                return stripslashes_deep( $results );
432 432
             }
433 433
         }
434 434
 
@@ -453,16 +453,16 @@  discard block
 block discarded – undo
453 453
 			$order_by = ' ORDER BY ' . $order_by;
454 454
 		}
455 455
 
456
-        $limit = FrmAppHelper::esc_limit($limit);
456
+        $limit = FrmAppHelper::esc_limit( $limit );
457 457
 
458 458
         $query = "SELECT fi.*, fr.name as form_name  FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
459 459
         $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results';
460 460
 
461
-        if ( is_array($where) ) {
461
+        if ( is_array( $where ) ) {
462 462
             $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type );
463 463
 		} else {
464 464
 			// if the query is not an array, then it has already been prepared
465
-            $query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
465
+            $query .= FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
466 466
 
467 467
 			$function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results';
468 468
 			$results = $wpdb->$function_name( $query );
@@ -485,9 +485,9 @@  discard block
 block discarded – undo
485 485
 				wp_cache_set( $result->id, $result, 'frm_field' );
486 486
 				wp_cache_set( $result->field_key, $result, 'frm_field' );
487 487
 
488
-				$results[ $r_key ]->field_options = maybe_unserialize( $result->field_options );
489
-				$results[ $r_key ]->options = maybe_unserialize( $result->options );
490
-				$results[ $r_key ]->default_value = maybe_unserialize( $result->default_value );
488
+				$results[$r_key]->field_options = maybe_unserialize( $result->field_options );
489
+				$results[$r_key]->options = maybe_unserialize( $result->options );
490
+				$results[$r_key]->default_value = maybe_unserialize( $result->default_value );
491 491
 
492 492
 				unset( $r_key, $result );
493 493
 			}
@@ -506,8 +506,8 @@  discard block
 block discarded – undo
506 506
 	private static function prepare_options( &$results ) {
507 507
 		$results->field_options = maybe_unserialize( $results->field_options );
508 508
 
509
-		$results->options = maybe_unserialize($results->options);
510
-		$results->default_value = maybe_unserialize($results->default_value);
509
+		$results->options = maybe_unserialize( $results->options );
510
+		$results->default_value = maybe_unserialize( $results->default_value );
511 511
 	}
512 512
 
513 513
 	/**
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 
535 535
 			if ( count( $next_fields ) >= self::$transient_size ) {
536 536
 				// if this transient is full, check for another
537
-				$next++;
537
+				$next ++;
538 538
 				self::get_next_transient( $fields, $base_name, $next );
539 539
 			}
540 540
 		}
@@ -560,14 +560,14 @@  discard block
 block discarded – undo
560 560
 				return;
561 561
 			}
562 562
 
563
-			$next++;
563
+			$next ++;
564 564
 		}
565 565
 	}
566 566
 
567 567
 	public static function getIds( $where = '', $order_by = '', $limit = '' ) {
568 568
 		_deprecated_function( __FUNCTION__, '2.0' );
569 569
         global $wpdb;
570
-        if ( ! empty($order_by) && ! strpos($order_by, 'ORDER BY') !== false ) {
570
+        if ( ! empty( $order_by ) && ! strpos( $order_by, 'ORDER BY' ) !== false ) {
571 571
 			$order_by = ' ORDER BY ' . $order_by;
572 572
         }
573 573
 
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 
578 578
         $method = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'get_var' : 'get_col';
579 579
 		$cache_key = 'getIds_' . maybe_serialize( $where ) . $order_by . $limit;
580
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_field', $query, $method);
580
+        $results = FrmAppHelper::check_cache( $cache_key, 'frm_field', $query, $method );
581 581
 
582 582
         return $results;
583 583
     }
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
 			$is_multi_value_field = (
609 609
 				$field['type'] == 'checkbox' ||
610 610
 				$field['type'] == 'address' ||
611
-				( $field['type'] == 'data' && isset($field['data_type']) && $field['data_type'] == 'checkbox' ) ||
612
-				( $field['type'] == 'lookup' && isset($field['data_type']) && $field['data_type'] == 'checkbox' ) ||
611
+				( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'checkbox' ) ||
612
+				( $field['type'] == 'lookup' && isset( $field['data_type'] ) && $field['data_type'] == 'checkbox' ) ||
613 613
 				self::is_multiple_select( $field )
614 614
 			);
615 615
 
@@ -634,9 +634,9 @@  discard block
 block discarded – undo
634 634
 	 */
635 635
 	public static function is_multiple_select( $field ) {
636 636
 		if ( is_array( $field ) ) {
637
-			return self::is_option_true( $field, 'multiple' ) && ( ( $field['type'] == 'select' || ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'select') ) );
637
+			return self::is_option_true( $field, 'multiple' ) && ( ( $field['type'] == 'select' || ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'select' ) ) );
638 638
 		} else {
639
-			return self::is_option_true( $field, 'multiple' ) && ( ( $field->type == 'select' || ( $field->type == 'data' && isset($field->field_options['data_type'] ) && $field->field_options['data_type'] == 'select') ) );
639
+			return self::is_option_true( $field, 'multiple' ) && ( ( $field->type == 'select' || ( $field->type == 'data' && isset( $field->field_options['data_type'] ) && $field->field_options['data_type'] == 'select' ) ) );
640 640
 		}
641 641
 	}
642 642
 
@@ -683,23 +683,23 @@  discard block
 block discarded – undo
683 683
 	}
684 684
 
685 685
 	public static function is_option_true_in_array( $field, $option ) {
686
-		return isset( $field[ $option ] ) && $field[ $option ];
686
+		return isset( $field[$option] ) && $field[$option];
687 687
 	}
688 688
 
689 689
 	public static function is_option_true_in_object( $field, $option ) {
690
-		return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ];
690
+		return isset( $field->field_options[$option] ) && $field->field_options[$option];
691 691
 	}
692 692
 
693 693
 	public static function is_option_empty_in_array( $field, $option ) {
694
-		return ! isset( $field[ $option ] ) || empty( $field[ $option ] );
694
+		return ! isset( $field[$option] ) || empty( $field[$option] );
695 695
 	}
696 696
 
697 697
 	public static function is_option_empty_in_object( $field, $option ) {
698
-		return ! isset( $field->field_options[ $option ] ) || empty( $field->field_options[ $option ] );
698
+		return ! isset( $field->field_options[$option] ) || empty( $field->field_options[$option] );
699 699
 	}
700 700
 
701 701
 	public static function is_option_value_in_object( $field, $option ) {
702
-		return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ] != '';
702
+		return isset( $field->field_options[$option] ) && $field->field_options[$option] != '';
703 703
 	}
704 704
 
705 705
 	/**
@@ -715,11 +715,11 @@  discard block
 block discarded – undo
715 715
 	}
716 716
 
717 717
 	public static function get_option_in_array( $field, $option ) {
718
-		return $field[ $option ];
718
+		return $field[$option];
719 719
 	}
720 720
 
721 721
 	public static function get_option_in_object( $field, $option ) {
722
-		return isset( $field->field_options[ $option ] ) ? $field->field_options[ $option ] : '';
722
+		return isset( $field->field_options[$option] ) ? $field->field_options[$option] : '';
723 723
 	}
724 724
 
725 725
 	/**
Please login to merge, or discard this patch.
classes/models/FrmForm.php 2 patches
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
3
-    die('You are not allowed to call this page directly.');
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+    die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
6 6
 class FrmForm {
@@ -15,24 +15,24 @@  discard block
 block discarded – undo
15 15
 			'form_key'      => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ),
16 16
             'name'          => $values['name'],
17 17
             'description'   => $values['description'],
18
-            'status'        => isset($values['status']) ? $values['status'] : 'draft',
19
-            'logged_in'     => isset($values['logged_in']) ? $values['logged_in'] : 0,
20
-            'is_template'   => isset($values['is_template']) ? (int) $values['is_template'] : 0,
18
+            'status'        => isset( $values['status'] ) ? $values['status'] : 'draft',
19
+            'logged_in'     => isset( $values['logged_in'] ) ? $values['logged_in'] : 0,
20
+            'is_template'   => isset( $values['is_template'] ) ? (int) $values['is_template'] : 0,
21 21
 			'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0,
22
-            'editable'      => isset($values['editable']) ? (int) $values['editable'] : 0,
23
-            'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0,
24
-            'created_at'    => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1),
22
+            'editable'      => isset( $values['editable'] ) ? (int) $values['editable'] : 0,
23
+            'default_template' => isset( $values['default_template'] ) ? (int) $values['default_template'] : 0,
24
+            'created_at'    => isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ),
25 25
         );
26 26
 
27 27
         $options = array();
28 28
 		FrmFormsHelper::fill_form_options( $options, $values );
29 29
 
30
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
31
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
32
-        $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
30
+        $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' );
31
+        $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' );
32
+        $options['submit_html'] = isset( $values['options']['submit_html'] ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' );
33 33
 
34
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
35
-        $new_values['options'] = serialize($options);
34
+        $options = apply_filters( 'frm_form_options_before_update', $options, $values );
35
+        $new_values['options'] = serialize( $options );
36 36
 
37 37
         //if(isset($values['id']) && is_numeric($values['id']))
38 38
         //    $new_values['id'] = $values['id'];
@@ -67,22 +67,22 @@  discard block
 block discarded – undo
67 67
             'status'        => $template ? 'published' : 'draft',
68 68
             'logged_in'     => $values->logged_in ? $values->logged_in : 0,
69 69
             'editable'      => $values->editable ? $values->editable : 0,
70
-            'created_at'    => current_time('mysql', 1),
70
+            'created_at'    => current_time( 'mysql', 1 ),
71 71
             'is_template'   => $template ? 1 : 0,
72 72
         );
73 73
 
74 74
         if ( $blog_id ) {
75 75
             $new_values['status'] = 'published';
76
-            $new_options = maybe_unserialize($values->options);
77
-            $new_options['email_to'] = get_option('admin_email');
76
+            $new_options = maybe_unserialize( $values->options );
77
+            $new_options['email_to'] = get_option( 'admin_email' );
78 78
             $new_options['copy'] = false;
79 79
             $new_values['options'] = $new_options;
80 80
         } else {
81 81
             $new_values['options'] = $values->options;
82 82
         }
83 83
 
84
-        if ( is_array($new_values['options']) ) {
85
-            $new_values['options'] = serialize($new_values['options']);
84
+        if ( is_array( $new_values['options'] ) ) {
85
+            $new_values['options'] = serialize( $new_values['options'] );
86 86
         }
87 87
 
88 88
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 			self::clear_form_cache();
93 93
 
94 94
             $form_id = $wpdb->insert_id;
95
-            FrmField::duplicate($id, $form_id, $copy_keys, $blog_id);
95
+            FrmField::duplicate( $id, $form_id, $copy_keys, $blog_id );
96 96
 
97 97
             // update form settings after fields are created
98 98
 			do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) );
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
     }
104 104
 
105 105
 	public static function after_duplicate( $form_id, $values ) {
106
-        $new_opts = $values['options'] = maybe_unserialize($values['options']);
106
+        $new_opts = $values['options'] = maybe_unserialize( $values['options'] );
107 107
 
108
-        if ( isset($new_opts['success_msg']) ) {
109
-            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
108
+        if ( isset( $new_opts['success_msg'] ) ) {
109
+            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids( $new_opts['success_msg'] );
110 110
         }
111 111
 
112
-        $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
112
+        $new_opts = apply_filters( 'frm_after_duplicate_form_values', $new_opts, $form_id );
113 113
 
114 114
         if ( $new_opts != $values['options'] ) {
115 115
             global $wpdb;
@@ -127,17 +127,17 @@  discard block
 block discarded – undo
127 127
             $values['status'] = 'published';
128 128
         }
129 129
 
130
-        if ( isset($values['form_key']) ) {
130
+        if ( isset( $values['form_key'] ) ) {
131 131
 			$values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id );
132 132
         }
133 133
 
134 134
         $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
135 135
 
136
-        $new_values = self::set_update_options( array(), $values);
136
+        $new_values = self::set_update_options( array(), $values );
137 137
 
138 138
         foreach ( $values as $value_key => $value ) {
139
-            if ( in_array($value_key, $form_fields) ) {
140
-				$new_values[ $value_key ] = $value;
139
+            if ( in_array( $value_key, $form_fields ) ) {
140
+				$new_values[$value_key] = $value;
141 141
             }
142 142
         }
143 143
 
@@ -153,9 +153,9 @@  discard block
 block discarded – undo
153 153
         } else {
154 154
             $query_results = true;
155 155
         }
156
-        unset($new_values);
156
+        unset( $new_values );
157 157
 
158
-        $values = self::update_fields($id, $values);
158
+        $values = self::update_fields( $id, $values );
159 159
 
160 160
 		do_action( 'frm_update_form', $id, $values );
161 161
 		do_action( 'frm_update_form_' . $id, $values );
@@ -167,20 +167,20 @@  discard block
 block discarded – undo
167 167
      * @return array
168 168
      */
169 169
 	public static function set_update_options( $new_values, $values ) {
170
-        if ( ! isset($values['options']) ) {
170
+        if ( ! isset( $values['options'] ) ) {
171 171
             return $new_values;
172 172
         }
173 173
 
174 174
         $options = array();
175 175
 		FrmFormsHelper::fill_form_options( $options, $values );
176 176
 
177
-        $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
178
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
179
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
180
-        $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
177
+        $options['custom_style'] = isset( $values['options']['custom_style'] ) ? $values['options']['custom_style'] : 0;
178
+        $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' );
179
+        $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' );
180
+        $options['submit_html'] = ( isset( $values['options']['submit_html'] ) && $values['options']['submit_html'] != '' ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' );
181 181
 
182
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
183
-        $new_values['options'] = serialize($options);
182
+        $options = apply_filters( 'frm_form_options_before_update', $options, $values );
183
+        $new_values['options'] = serialize( $options );
184 184
 
185 185
         return $new_values;
186 186
     }
@@ -191,54 +191,54 @@  discard block
 block discarded – undo
191 191
      */
192 192
 	public static function update_fields( $id, $values ) {
193 193
 
194
-        if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
194
+        if ( ! isset( $values['options'] ) && ! isset( $values['item_meta'] ) && ! isset( $values['field_options'] ) ) {
195 195
             return $values;
196 196
         }
197 197
 
198
-        $all_fields = FrmField::get_all_for_form($id);
199
-        if ( empty($all_fields) ) {
198
+        $all_fields = FrmField::get_all_for_form( $id );
199
+        if ( empty( $all_fields ) ) {
200 200
             return $values;
201 201
         }
202 202
 
203
-        if ( ! isset($values['item_meta']) ) {
203
+        if ( ! isset( $values['item_meta'] ) ) {
204 204
             $values['item_meta'] = array();
205 205
         }
206 206
 
207 207
         $field_array = array();
208
-        $existing_keys = array_keys($values['item_meta']);
208
+        $existing_keys = array_keys( $values['item_meta'] );
209 209
         foreach ( $all_fields as $fid ) {
210
-            if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
211
-				$values['item_meta'][ $fid->id ] = '';
210
+            if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) {
211
+				$values['item_meta'][$fid->id] = '';
212 212
             }
213
-			$field_array[ $fid->id ] = $fid;
213
+			$field_array[$fid->id] = $fid;
214 214
         }
215
-        unset($all_fields);
215
+        unset( $all_fields );
216 216
 
217 217
         foreach ( $values['item_meta'] as $field_id => $default_value ) {
218
-			if ( isset( $field_array[ $field_id ] ) ) {
219
-				$field = $field_array[ $field_id ];
218
+			if ( isset( $field_array[$field_id] ) ) {
219
+				$field = $field_array[$field_id];
220 220
             } else {
221
-                $field = FrmField::getOne($field_id);
221
+                $field = FrmField::getOne( $field_id );
222 222
             }
223 223
 
224 224
             if ( ! $field ) {
225 225
                 continue;
226 226
             }
227 227
 
228
-			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) );
228
+			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) );
229 229
 			if ( $is_settings_page ) {
230 230
                 //updating the settings page
231
-				if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) {
232
-					$field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) );
233
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
231
+				if ( isset( $values['field_options']['custom_html_' . $field_id] ) ) {
232
+					$field->field_options['custom_html'] = isset( $values['field_options']['custom_html_' . $field_id] ) ? $values['field_options']['custom_html_' . $field_id] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) );
233
+                    $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values );
234 234
 					FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
235 235
                 } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
236 236
                     $prev_opts = $field->field_options;
237
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
237
+                    $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values );
238 238
                     if ( $prev_opts != $field->field_options ) {
239 239
 						FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
240 240
                     }
241
-                    unset($prev_opts);
241
+                    unset( $prev_opts );
242 242
                 }
243 243
             }
244 244
 
@@ -252,23 +252,23 @@  discard block
 block discarded – undo
252 252
 			$update_options = apply_filters( 'frm_field_options_to_update', $update_options );
253 253
 
254 254
 			foreach ( $update_options as $opt => $default ) {
255
-				$field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default;
255
+				$field->field_options[$opt] = isset( $values['field_options'][$opt . '_' . $field_id] ) ? trim( sanitize_text_field( $values['field_options'][$opt . '_' . $field_id] ) ) : $default;
256 256
             }
257 257
 
258
-            $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
259
-			$default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
260
-			$field_key = isset( $values['field_options'][ 'field_key_' . $field_id ] ) ? $values['field_options'][ 'field_key_' . $field_id ] : $field->field_key;
261
-			$required = isset( $values['field_options'][ 'required_' . $field_id ] ) ? $values['field_options'][ 'required_' . $field_id ] : false;
262
-			$field_type = isset( $values['field_options'][ 'type_' . $field_id ] ) ? $values['field_options'][ 'type_' . $field_id ] : $field->type;
263
-			$field_description = isset( $values['field_options'][ 'description_' . $field_id ] ) ? $values['field_options'][ 'description_' . $field_id ] : $field->description;
258
+            $field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values );
259
+			$default_value = maybe_serialize( $values['item_meta'][$field_id] );
260
+			$field_key = isset( $values['field_options']['field_key_' . $field_id] ) ? $values['field_options']['field_key_' . $field_id] : $field->field_key;
261
+			$required = isset( $values['field_options']['required_' . $field_id] ) ? $values['field_options']['required_' . $field_id] : false;
262
+			$field_type = isset( $values['field_options']['type_' . $field_id] ) ? $values['field_options']['type_' . $field_id] : $field->type;
263
+			$field_description = isset( $values['field_options']['description_' . $field_id] ) ? $values['field_options']['description_' . $field_id] : $field->description;
264 264
 
265
-            FrmField::update($field_id, array(
265
+            FrmField::update( $field_id, array(
266 266
                 'field_key' => $field_key, 'type' => $field_type,
267 267
                 'default_value' => $default_value, 'field_options' => $field->field_options,
268 268
                 'description' => $field_description, 'required' => $required,
269 269
             ) );
270 270
 
271
-            FrmField::delete_form_transient($field->form_id);
271
+            FrmField::delete_form_transient( $field->form_id );
272 272
         }
273 273
 		self::clear_form_cache();
274 274
 
@@ -281,17 +281,17 @@  discard block
 block discarded – undo
281 281
      */
282 282
 	public static function set_status( $id, $status ) {
283 283
         if ( 'trash' == $status ) {
284
-            return self::trash($id);
284
+            return self::trash( $id );
285 285
         }
286 286
 
287
-		$statuses  = array( 'published', 'draft', 'trash' );
287
+		$statuses = array( 'published', 'draft', 'trash' );
288 288
         if ( ! in_array( $status, $statuses ) ) {
289 289
             return false;
290 290
         }
291 291
 
292 292
         global $wpdb;
293 293
 
294
-        if ( is_array($id) ) {
294
+        if ( is_array( $id ) ) {
295 295
 			$where = array( 'id' => $id );
296 296
 			FrmDb::get_where_clause_and_values( $where );
297 297
 			array_unshift( $where['values'], $status );
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
             return self::destroy( $id );
317 317
         }
318 318
 
319
-        $form = self::getOne($id);
319
+        $form = self::getOne( $id );
320 320
         if ( ! $form ) {
321 321
             return false;
322 322
         }
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 	public static function destroy( $id ) {
345 345
         global $wpdb;
346 346
 
347
-        $form = self::getOne($id);
347
+        $form = self::getOne( $id );
348 348
         if ( ! $form ) {
349 349
             return false;
350 350
         }
@@ -353,8 +353,8 @@  discard block
 block discarded – undo
353 353
         // Disconnect the entries from this form
354 354
 		$entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) );
355 355
         foreach ( $entries as $entry_id ) {
356
-            FrmEntry::destroy($entry_id);
357
-            unset($entry_id);
356
+            FrmEntry::destroy( $entry_id );
357
+            unset( $entry_id );
358 358
         }
359 359
 
360 360
         // Disconnect the fields from this form
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
         if ( $query_results ) {
365 365
             // Delete all form actions linked to this form
366 366
             $action_control = FrmFormActionsController::get_form_actions( 'email' );
367
-            $action_control->destroy($id, 'all');
367
+            $action_control->destroy( $id, 'all' );
368 368
 
369 369
 			// Clear form caching
370 370
 			self::clear_form_cache();
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 			$form->options = maybe_unserialize( $form->options );
399 399
 			if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) {
400 400
 				self::destroy( $form->id );
401
-				$count++;
401
+				$count ++;
402 402
 			}
403 403
 
404 404
 			unset( $form );
@@ -412,15 +412,15 @@  discard block
 block discarded – undo
412 412
     public static function &getName( $id ) {
413 413
         global $wpdb;
414 414
 
415
-        $form = FrmAppHelper::check_cache($id, 'frm_form');
415
+        $form = FrmAppHelper::check_cache( $id, 'frm_form' );
416 416
         if ( $form ) {
417
-            $r = stripslashes($form->name);
417
+            $r = stripslashes( $form->name );
418 418
             return $r;
419 419
         }
420 420
 
421 421
         $query_key = is_numeric( $id ) ? 'id' : 'form_key';
422 422
         $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
423
-        $r = stripslashes($r);
423
+        $r = stripslashes( $r );
424 424
 
425 425
         return $r;
426 426
     }
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
      */
441 441
 	public static function &getKeyById( $id ) {
442 442
         $id = (int) $id;
443
-        $cache = FrmAppHelper::check_cache($id, 'frm_form');
443
+        $cache = FrmAppHelper::check_cache( $id, 'frm_form' );
444 444
         if ( $cache ) {
445 445
             return $cache->form_key;
446 446
         }
@@ -474,17 +474,17 @@  discard block
 block discarded – undo
474 474
 			$table_name = $prefix . 'frm_forms';
475 475
         } else {
476 476
 			$table_name = $wpdb->prefix . 'frm_forms';
477
-            $cache = wp_cache_get($id, 'frm_form');
477
+            $cache = wp_cache_get( $id, 'frm_form' );
478 478
             if ( $cache ) {
479
-                if ( isset($cache->options) ) {
480
-                    $cache->options = maybe_unserialize($cache->options);
479
+                if ( isset( $cache->options ) ) {
480
+                    $cache->options = maybe_unserialize( $cache->options );
481 481
                 }
482 482
 
483
-                return stripslashes_deep($cache);
483
+                return stripslashes_deep( $cache );
484 484
             }
485 485
         }
486 486
 
487
-        if ( is_numeric($id) ) {
487
+        if ( is_numeric( $id ) ) {
488 488
             $where = array( 'id' => $id );
489 489
         } else {
490 490
             $where = array( 'form_key' => $id );
@@ -492,11 +492,11 @@  discard block
 block discarded – undo
492 492
 
493 493
         $results = FrmDb::get_row( $table_name, $where );
494 494
 
495
-        if ( isset($results->options) ) {
496
-            wp_cache_set($results->id, $results, 'frm_form');
497
-            $results->options = maybe_unserialize($results->options);
495
+        if ( isset( $results->options ) ) {
496
+            wp_cache_set( $results->id, $results, 'frm_form' );
497
+            $results->options = maybe_unserialize( $results->options );
498 498
         }
499
-        return stripslashes_deep($results);
499
+        return stripslashes_deep( $results );
500 500
     }
501 501
 
502 502
     /**
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 			$results = reset( $results );
526 526
 		}
527 527
 
528
-        return stripslashes_deep($results);
528
+        return stripslashes_deep( $results );
529 529
     }
530 530
 
531 531
 	/**
@@ -565,19 +565,19 @@  discard block
 block discarded – undo
565 565
     	foreach ( $results as $row ) {
566 566
             if ( 'trash' != $row->status ) {
567 567
     	        if ( $row->is_template ) {
568
-					$counts['template']++;
568
+					$counts['template'] ++;
569 569
     	        } else {
570
-					$counts['published']++;
570
+					$counts['published'] ++;
571 571
     	        }
572 572
     	    } else {
573
-				$counts['trash']++;
573
+				$counts['trash'] ++;
574 574
         	}
575 575
 
576 576
     	    if ( 'draft' == $row->status ) {
577
-				$counts['draft']++;
577
+				$counts['draft'] ++;
578 578
     	    }
579 579
 
580
-    		unset($row);
580
+    		unset( $row );
581 581
     	}
582 582
 
583 583
     	$counts = (object) $counts;
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 	public static function validate( $values ) {
604 604
         $errors = array();
605 605
 
606
-        return apply_filters('frm_validate_form', $errors, $values);
606
+        return apply_filters( 'frm_validate_form', $errors, $values );
607 607
     }
608 608
 
609 609
 	public static function get_params( $form = null ) {
@@ -615,11 +615,11 @@  discard block
 block discarded – undo
615 615
 			self::maybe_get_form( $form );
616 616
 		}
617 617
 
618
-		if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) {
619
-			return $frm_vars['form_params'][ $form->id ];
618
+		if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][$form->id] ) ) {
619
+			return $frm_vars['form_params'][$form->id];
620 620
 		}
621 621
 
622
-		$action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
622
+		$action_var = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
623 623
 		$action = apply_filters( 'frm_show_new_entry_page', FrmAppHelper::get_param( $action_var, 'new', 'get', 'sanitize_title' ), $form );
624 624
 
625 625
 		$default_values = array(
@@ -637,15 +637,15 @@  discard block
 block discarded – undo
637 637
 			//if there are two forms on the same page, make sure not to submit both
638 638
 			foreach ( $default_values as $var => $default ) {
639 639
 				if ( $var == 'action' ) {
640
-					$values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
640
+					$values[$var] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
641 641
 				} else {
642
-					$values[ $var ] = FrmAppHelper::get_param( $var, $default );
642
+					$values[$var] = FrmAppHelper::get_param( $var, $default );
643 643
 				}
644 644
 				unset( $var, $default );
645 645
 			}
646 646
 		} else {
647 647
 			foreach ( $default_values as $var => $default ) {
648
-				$values[ $var ] = $default;
648
+				$values[$var] = $default;
649 649
 				unset( $var, $default );
650 650
 			}
651 651
 		}
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 	public static function list_page_params() {
661 661
 		$values = array();
662 662
 		foreach ( array( 'template' => 0, 'id' => '', 'paged' => 1, 'form' => '', 'search' => '', 'sort' => '', 'sdir' => '' ) as $var => $default ) {
663
-			$values[ $var ] = FrmAppHelper::get_param( $var, $default );
663
+			$values[$var] = FrmAppHelper::get_param( $var, $default );
664 664
 		}
665 665
 
666 666
 		return $values;
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
 			'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'fid' => '',
681 681
 			'keep_post' => '',
682 682
 		) as $var => $default ) {
683
-			$values[ $var ] = FrmAppHelper::get_param( $var, $default );
683
+			$values[$var] = FrmAppHelper::get_param( $var, $default );
684 684
 		}
685 685
 
686 686
 		return $values;
@@ -722,16 +722,16 @@  discard block
 block discarded – undo
722 722
 		$small_form = new stdClass();
723 723
 		foreach ( array( 'id', 'form_key', 'name' ) as $var ) {
724 724
 			$small_form->{$var} = $form->{$var};
725
-			unset($var);
725
+			unset( $var );
726 726
 		}
727 727
 
728 728
 		$frm_vars['forms_loaded'][] = $small_form;
729 729
 
730
-		if ( $this_load && empty($global_load) ) {
730
+		if ( $this_load && empty( $global_load ) ) {
731 731
 			$global_load = $frm_vars['load_css'] = true;
732 732
 		}
733 733
 
734
-		return ( ( ! isset($frm_vars['css_loaded']) || ! $frm_vars['css_loaded'] ) && $global_load );
734
+		return ( ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) && $global_load );
735 735
 	}
736 736
 
737 737
 	public static function show_submit( $form ) {
Please login to merge, or discard this patch.
Indentation   +340 added lines, -340 removed lines patch added patch discarded remove patch
@@ -1,387 +1,387 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined('ABSPATH') ) {
3
-    die('You are not allowed to call this page directly.');
3
+	die('You are not allowed to call this page directly.');
4 4
 }
5 5
 
6 6
 class FrmForm {
7 7
 
8
-    /**
9
-     * @return int|boolean id on success or false on failure
10
-     */
11
-    public static function create( $values ) {
12
-        global $wpdb;
8
+	/**
9
+	 * @return int|boolean id on success or false on failure
10
+	 */
11
+	public static function create( $values ) {
12
+		global $wpdb;
13 13
 
14
-        $new_values = array(
14
+		$new_values = array(
15 15
 			'form_key'      => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ),
16
-            'name'          => $values['name'],
17
-            'description'   => $values['description'],
18
-            'status'        => isset($values['status']) ? $values['status'] : 'draft',
19
-            'logged_in'     => isset($values['logged_in']) ? $values['logged_in'] : 0,
20
-            'is_template'   => isset($values['is_template']) ? (int) $values['is_template'] : 0,
16
+			'name'          => $values['name'],
17
+			'description'   => $values['description'],
18
+			'status'        => isset($values['status']) ? $values['status'] : 'draft',
19
+			'logged_in'     => isset($values['logged_in']) ? $values['logged_in'] : 0,
20
+			'is_template'   => isset($values['is_template']) ? (int) $values['is_template'] : 0,
21 21
 			'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0,
22
-            'editable'      => isset($values['editable']) ? (int) $values['editable'] : 0,
23
-            'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0,
24
-            'created_at'    => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1),
25
-        );
22
+			'editable'      => isset($values['editable']) ? (int) $values['editable'] : 0,
23
+			'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0,
24
+			'created_at'    => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1),
25
+		);
26 26
 
27 27
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
28 28
 		FrmFormsHelper::fill_form_options( $options, $values );
29 29
 
30
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
31
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
32
-        $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
30
+		$options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
31
+		$options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
32
+		$options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
33 33
 
34
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
35
-        $new_values['options'] = serialize($options);
34
+		$options = apply_filters('frm_form_options_before_update', $options, $values);
35
+		$new_values['options'] = serialize($options);
36 36
 
37
-        //if(isset($values['id']) && is_numeric($values['id']))
38
-        //    $new_values['id'] = $values['id'];
37
+		//if(isset($values['id']) && is_numeric($values['id']))
38
+		//    $new_values['id'] = $values['id'];
39 39
 
40 40
 		$wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
41 41
 
42
-        $id = $wpdb->insert_id;
42
+		$id = $wpdb->insert_id;
43 43
 
44 44
 		// Clear form caching
45 45
 		self::clear_form_cache();
46 46
 
47
-        return $id;
48
-    }
47
+		return $id;
48
+	}
49 49
 
50
-    /**
51
-     * @return int|boolean ID on success or false on failure
52
-     */
53
-    public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) {
54
-        global $wpdb;
50
+	/**
51
+	 * @return int|boolean ID on success or false on failure
52
+	 */
53
+	public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) {
54
+		global $wpdb;
55 55
 
56
-        $values = self::getOne( $id, $blog_id );
57
-        if ( ! $values ) {
58
-            return false;
59
-        }
56
+		$values = self::getOne( $id, $blog_id );
57
+		if ( ! $values ) {
58
+			return false;
59
+		}
60 60
 
61
-        $new_key = $copy_keys ? $values->form_key : '';
61
+		$new_key = $copy_keys ? $values->form_key : '';
62 62
 
63
-        $new_values = array(
63
+		$new_values = array(
64 64
 			'form_key'      => FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_forms', 'form_key' ),
65
-            'name'          => $values->name,
66
-            'description'   => $values->description,
67
-            'status'        => $template ? 'published' : 'draft',
68
-            'logged_in'     => $values->logged_in ? $values->logged_in : 0,
69
-            'editable'      => $values->editable ? $values->editable : 0,
70
-            'created_at'    => current_time('mysql', 1),
71
-            'is_template'   => $template ? 1 : 0,
72
-        );
73
-
74
-        if ( $blog_id ) {
75
-            $new_values['status'] = 'published';
76
-            $new_options = maybe_unserialize($values->options);
77
-            $new_options['email_to'] = get_option('admin_email');
78
-            $new_options['copy'] = false;
79
-            $new_values['options'] = $new_options;
80
-        } else {
81
-            $new_values['options'] = $values->options;
82
-        }
83
-
84
-        if ( is_array($new_values['options']) ) {
85
-            $new_values['options'] = serialize($new_values['options']);
86
-        }
65
+			'name'          => $values->name,
66
+			'description'   => $values->description,
67
+			'status'        => $template ? 'published' : 'draft',
68
+			'logged_in'     => $values->logged_in ? $values->logged_in : 0,
69
+			'editable'      => $values->editable ? $values->editable : 0,
70
+			'created_at'    => current_time('mysql', 1),
71
+			'is_template'   => $template ? 1 : 0,
72
+		);
73
+
74
+		if ( $blog_id ) {
75
+			$new_values['status'] = 'published';
76
+			$new_options = maybe_unserialize($values->options);
77
+			$new_options['email_to'] = get_option('admin_email');
78
+			$new_options['copy'] = false;
79
+			$new_values['options'] = $new_options;
80
+		} else {
81
+			$new_values['options'] = $values->options;
82
+		}
83
+
84
+		if ( is_array($new_values['options']) ) {
85
+			$new_values['options'] = serialize($new_values['options']);
86
+		}
87 87
 
88 88
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
89 89
 
90
-        if ( $query_results ) {
90
+		if ( $query_results ) {
91 91
 			// Clear form caching
92 92
 			self::clear_form_cache();
93 93
 
94
-            $form_id = $wpdb->insert_id;
95
-            FrmField::duplicate($id, $form_id, $copy_keys, $blog_id);
94
+			$form_id = $wpdb->insert_id;
95
+			FrmField::duplicate($id, $form_id, $copy_keys, $blog_id);
96 96
 
97
-            // update form settings after fields are created
97
+			// update form settings after fields are created
98 98
 			do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) );
99
-            return $form_id;
100
-        }
99
+			return $form_id;
100
+		}
101 101
 
102
-        return false;
103
-    }
102
+		return false;
103
+	}
104 104
 
105 105
 	public static function after_duplicate( $form_id, $values ) {
106
-        $new_opts = $values['options'] = maybe_unserialize($values['options']);
106
+		$new_opts = $values['options'] = maybe_unserialize($values['options']);
107 107
 
108
-        if ( isset($new_opts['success_msg']) ) {
109
-            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
110
-        }
108
+		if ( isset($new_opts['success_msg']) ) {
109
+			$new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
110
+		}
111 111
 
112
-        $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
112
+		$new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
113 113
 
114
-        if ( $new_opts != $values['options'] ) {
115
-            global $wpdb;
114
+		if ( $new_opts != $values['options'] ) {
115
+			global $wpdb;
116 116
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $new_opts ) ), array( 'id' => $form_id ) );
117
-        }
118
-    }
117
+		}
118
+	}
119 119
 
120
-    /**
121
-     * @return int|boolean
122
-     */
123
-    public static function update( $id, $values, $create_link = false ) {
124
-        global $wpdb;
120
+	/**
121
+	 * @return int|boolean
122
+	 */
123
+	public static function update( $id, $values, $create_link = false ) {
124
+		global $wpdb;
125 125
 
126
-        if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) {
127
-            $values['status'] = 'published';
128
-        }
126
+		if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) {
127
+			$values['status'] = 'published';
128
+		}
129 129
 
130
-        if ( isset($values['form_key']) ) {
130
+		if ( isset($values['form_key']) ) {
131 131
 			$values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id );
132
-        }
132
+		}
133 133
 
134
-        $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
134
+		$form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
135 135
 
136
-        $new_values = self::set_update_options( array(), $values);
136
+		$new_values = self::set_update_options( array(), $values);
137 137
 
138
-        foreach ( $values as $value_key => $value ) {
139
-            if ( in_array($value_key, $form_fields) ) {
138
+		foreach ( $values as $value_key => $value ) {
139
+			if ( in_array($value_key, $form_fields) ) {
140 140
 				$new_values[ $value_key ] = $value;
141
-            }
142
-        }
141
+			}
142
+		}
143 143
 
144
-        if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) {
145
-            $new_values['status'] = $values['new_status'];
146
-        }
144
+		if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) {
145
+			$new_values['status'] = $values['new_status'];
146
+		}
147 147
 
148
-        if ( ! empty( $new_values ) ) {
148
+		if ( ! empty( $new_values ) ) {
149 149
 			$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $id ) );
150
-            if ( $query_results ) {
150
+			if ( $query_results ) {
151 151
 				self::clear_form_cache();
152
-            }
153
-        } else {
154
-            $query_results = true;
155
-        }
156
-        unset($new_values);
152
+			}
153
+		} else {
154
+			$query_results = true;
155
+		}
156
+		unset($new_values);
157 157
 
158
-        $values = self::update_fields($id, $values);
158
+		$values = self::update_fields($id, $values);
159 159
 
160 160
 		do_action( 'frm_update_form', $id, $values );
161 161
 		do_action( 'frm_update_form_' . $id, $values );
162 162
 
163
-        return $query_results;
164
-    }
163
+		return $query_results;
164
+	}
165 165
 
166
-    /**
167
-     * @return array
168
-     */
166
+	/**
167
+	 * @return array
168
+	 */
169 169
 	public static function set_update_options( $new_values, $values ) {
170
-        if ( ! isset($values['options']) ) {
171
-            return $new_values;
172
-        }
170
+		if ( ! isset($values['options']) ) {
171
+			return $new_values;
172
+		}
173 173
 
174 174
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
175 175
 		FrmFormsHelper::fill_form_options( $options, $values );
176 176
 
177
-        $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
178
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
179
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
180
-        $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
177
+		$options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
178
+		$options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
179
+		$options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
180
+		$options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
181 181
 
182
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
183
-        $new_values['options'] = serialize($options);
182
+		$options = apply_filters('frm_form_options_before_update', $options, $values);
183
+		$new_values['options'] = serialize($options);
184 184
 
185
-        return $new_values;
186
-    }
185
+		return $new_values;
186
+	}
187 187
 
188 188
 
189
-    /**
190
-     * @return array
191
-     */
189
+	/**
190
+	 * @return array
191
+	 */
192 192
 	public static function update_fields( $id, $values ) {
193 193
 
194
-        if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
195
-            return $values;
196
-        }
194
+		if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
195
+			return $values;
196
+		}
197 197
 
198
-        $all_fields = FrmField::get_all_for_form($id);
199
-        if ( empty($all_fields) ) {
200
-            return $values;
201
-        }
198
+		$all_fields = FrmField::get_all_for_form($id);
199
+		if ( empty($all_fields) ) {
200
+			return $values;
201
+		}
202 202
 
203
-        if ( ! isset($values['item_meta']) ) {
204
-            $values['item_meta'] = array();
205
-        }
203
+		if ( ! isset($values['item_meta']) ) {
204
+			$values['item_meta'] = array();
205
+		}
206 206
 
207
-        $field_array = array();
208
-        $existing_keys = array_keys($values['item_meta']);
209
-        foreach ( $all_fields as $fid ) {
210
-            if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
207
+		$field_array = array();
208
+		$existing_keys = array_keys($values['item_meta']);
209
+		foreach ( $all_fields as $fid ) {
210
+			if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
211 211
 				$values['item_meta'][ $fid->id ] = '';
212
-            }
212
+			}
213 213
 			$field_array[ $fid->id ] = $fid;
214
-        }
215
-        unset($all_fields);
214
+		}
215
+		unset($all_fields);
216 216
 
217
-        foreach ( $values['item_meta'] as $field_id => $default_value ) {
217
+		foreach ( $values['item_meta'] as $field_id => $default_value ) {
218 218
 			if ( isset( $field_array[ $field_id ] ) ) {
219 219
 				$field = $field_array[ $field_id ];
220
-            } else {
221
-                $field = FrmField::getOne($field_id);
222
-            }
220
+			} else {
221
+				$field = FrmField::getOne($field_id);
222
+			}
223 223
 
224
-            if ( ! $field ) {
225
-                continue;
226
-            }
224
+			if ( ! $field ) {
225
+				continue;
226
+			}
227 227
 
228 228
 			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) );
229 229
 			if ( $is_settings_page ) {
230
-                //updating the settings page
230
+				//updating the settings page
231 231
 				if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) {
232 232
 					$field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) );
233
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
233
+					$field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
234 234
 					FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
235
-                } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
236
-                    $prev_opts = $field->field_options;
237
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
238
-                    if ( $prev_opts != $field->field_options ) {
235
+				} else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
236
+					$prev_opts = $field->field_options;
237
+					$field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
238
+					if ( $prev_opts != $field->field_options ) {
239 239
 						FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
240
-                    }
241
-                    unset($prev_opts);
242
-                }
243
-            }
240
+					}
241
+					unset($prev_opts);
242
+				}
243
+			}
244 244
 
245 245
 			if ( $is_settings_page && ! defined( 'WP_IMPORTING' ) ) {
246
-                continue;
247
-            }
246
+				continue;
247
+			}
248 248
 
249
-            //updating the form
249
+			//updating the form
250 250
 			$update_options = FrmFieldsHelper::get_default_field_opts( $field->type, $field, true );
251 251
 			unset( $update_options['custom_html'] ); // don't check for POST html
252 252
 			$update_options = apply_filters( 'frm_field_options_to_update', $update_options );
253 253
 
254 254
 			foreach ( $update_options as $opt => $default ) {
255 255
 				$field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default;
256
-            }
256
+			}
257 257
 
258
-            $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
258
+			$field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
259 259
 			$default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
260 260
 			$field_key = isset( $values['field_options'][ 'field_key_' . $field_id ] ) ? $values['field_options'][ 'field_key_' . $field_id ] : $field->field_key;
261 261
 			$required = isset( $values['field_options'][ 'required_' . $field_id ] ) ? $values['field_options'][ 'required_' . $field_id ] : false;
262 262
 			$field_type = isset( $values['field_options'][ 'type_' . $field_id ] ) ? $values['field_options'][ 'type_' . $field_id ] : $field->type;
263 263
 			$field_description = isset( $values['field_options'][ 'description_' . $field_id ] ) ? $values['field_options'][ 'description_' . $field_id ] : $field->description;
264 264
 
265
-            FrmField::update($field_id, array(
266
-                'field_key' => $field_key, 'type' => $field_type,
267
-                'default_value' => $default_value, 'field_options' => $field->field_options,
268
-                'description' => $field_description, 'required' => $required,
269
-            ) );
265
+			FrmField::update($field_id, array(
266
+				'field_key' => $field_key, 'type' => $field_type,
267
+				'default_value' => $default_value, 'field_options' => $field->field_options,
268
+				'description' => $field_description, 'required' => $required,
269
+			) );
270 270
 
271
-            FrmField::delete_form_transient($field->form_id);
272
-        }
271
+			FrmField::delete_form_transient($field->form_id);
272
+		}
273 273
 		self::clear_form_cache();
274 274
 
275
-        return $values;
276
-    }
275
+		return $values;
276
+	}
277 277
 
278
-    /**
279
-     * @param string $status
280
-     * @return int|boolean
281
-     */
278
+	/**
279
+	 * @param string $status
280
+	 * @return int|boolean
281
+	 */
282 282
 	public static function set_status( $id, $status ) {
283
-        if ( 'trash' == $status ) {
284
-            return self::trash($id);
285
-        }
283
+		if ( 'trash' == $status ) {
284
+			return self::trash($id);
285
+		}
286 286
 
287 287
 		$statuses  = array( 'published', 'draft', 'trash' );
288
-        if ( ! in_array( $status, $statuses ) ) {
289
-            return false;
290
-        }
288
+		if ( ! in_array( $status, $statuses ) ) {
289
+			return false;
290
+		}
291 291
 
292
-        global $wpdb;
292
+		global $wpdb;
293 293
 
294
-        if ( is_array($id) ) {
294
+		if ( is_array($id) ) {
295 295
 			$where = array( 'id' => $id, 'parent_form_id' => $id, 'or' => 1 );
296 296
 			FrmDb::get_where_clause_and_values( $where );
297 297
 			array_unshift( $where['values'], $status );
298 298
 
299 299
 			$query_results = $wpdb->query( $wpdb->prepare( 'UPDATE ' . $wpdb->prefix . 'frm_forms SET status = %s ' . $where['where'], $where['values'] ) );
300
-        } else {
300
+		} else {
301 301
 			$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'id' => $id ) );
302 302
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'parent_form_id' => $id ) );
303
-        }
303
+		}
304 304
 
305
-        if ( $query_results ) {
305
+		if ( $query_results ) {
306 306
 			self::clear_form_cache();
307
-        }
307
+		}
308 308
 
309
-        return $query_results;
310
-    }
309
+		return $query_results;
310
+	}
311 311
 
312
-    /**
313
-     * @return int|boolean
314
-     */
312
+	/**
313
+	 * @return int|boolean
314
+	 */
315 315
 	public static function trash( $id ) {
316
-        if ( ! EMPTY_TRASH_DAYS ) {
317
-            return self::destroy( $id );
318
-        }
316
+		if ( ! EMPTY_TRASH_DAYS ) {
317
+			return self::destroy( $id );
318
+		}
319 319
 
320
-        $form = self::getOne($id);
321
-        if ( ! $form ) {
322
-            return false;
323
-        }
320
+		$form = self::getOne($id);
321
+		if ( ! $form ) {
322
+			return false;
323
+		}
324 324
 
325
-        $options = $form->options;
326
-        $options['trash_time'] = time();
325
+		$options = $form->options;
326
+		$options['trash_time'] = time();
327 327
 
328
-        global $wpdb;
329
-        $query_results = $wpdb->update(
328
+		global $wpdb;
329
+		$query_results = $wpdb->update(
330 330
 			$wpdb->prefix . 'frm_forms',
331 331
 			array( 'status' => 'trash', 'options' => serialize( $options ) ),
332 332
 			array( 'id' => $id )
333
-        );
333
+		);
334 334
 
335
-        $wpdb->update(
335
+		$wpdb->update(
336 336
 			$wpdb->prefix . 'frm_forms',
337 337
 			array( 'status' => 'trash', 'options' => serialize( $options ) ),
338 338
 			array( 'parent_form_id' => $id )
339
-        );
339
+		);
340 340
 
341
-        if ( $query_results ) {
341
+		if ( $query_results ) {
342 342
 			self::clear_form_cache();
343
-        }
343
+		}
344 344
 
345
-        return $query_results;
346
-    }
345
+		return $query_results;
346
+	}
347 347
 
348
-    /**
349
-     * @return int|boolean
350
-     */
348
+	/**
349
+	 * @return int|boolean
350
+	 */
351 351
 	public static function destroy( $id ) {
352
-        global $wpdb;
352
+		global $wpdb;
353 353
 
354
-        $form = self::getOne($id);
355
-        if ( ! $form ) {
356
-            return false;
357
-        }
354
+		$form = self::getOne($id);
355
+		if ( ! $form ) {
356
+			return false;
357
+		}
358 358
 		$id = $form->id;
359 359
 
360
-        // Disconnect the entries from this form
360
+		// Disconnect the entries from this form
361 361
 		$entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) );
362
-        foreach ( $entries as $entry_id ) {
363
-            FrmEntry::destroy($entry_id);
364
-            unset($entry_id);
365
-        }
362
+		foreach ( $entries as $entry_id ) {
363
+			FrmEntry::destroy($entry_id);
364
+			unset($entry_id);
365
+		}
366 366
 
367
-        // Disconnect the fields from this form
367
+		// Disconnect the fields from this form
368 368
 		$wpdb->query( $wpdb->prepare( 'DELETE fi FROM ' . $wpdb->prefix . 'frm_fields AS fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id) WHERE fi.form_id=%d OR parent_form_id=%d', $id, $id ) );
369 369
 
370 370
 		$query_results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id ) );
371
-        if ( $query_results ) {
372
-            // Delete all form actions linked to this form
373
-            $action_control = FrmFormActionsController::get_form_actions( 'email' );
374
-            $action_control->destroy($id, 'all');
371
+		if ( $query_results ) {
372
+			// Delete all form actions linked to this form
373
+			$action_control = FrmFormActionsController::get_form_actions( 'email' );
374
+			$action_control->destroy($id, 'all');
375 375
 
376 376
 			// Clear form caching
377 377
 			self::clear_form_cache();
378 378
 
379 379
 			do_action( 'frm_destroy_form', $id );
380 380
 			do_action( 'frm_destroy_form_' . $id );
381
-        }
381
+		}
382 382
 
383
-        return $query_results;
384
-    }
383
+		return $query_results;
384
+	}
385 385
 
386 386
 	/**
387 387
 	 * Delete trashed forms based on how long they have been trashed
@@ -413,49 +413,49 @@  discard block
 block discarded – undo
413 413
 		return $count;
414 414
 	}
415 415
 
416
-    /**
417
-     * @return string form name
418
-     */
419
-    public static function &getName( $id ) {
420
-        global $wpdb;
421
-
422
-        $form = FrmAppHelper::check_cache($id, 'frm_form');
423
-        if ( $form ) {
424
-            $r = stripslashes($form->name);
425
-            return $r;
426
-        }
427
-
428
-        $query_key = is_numeric( $id ) ? 'id' : 'form_key';
429
-        $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
430
-        $r = stripslashes($r);
431
-
432
-        return $r;
433
-    }
434
-
435
-    /**
436
-     * @param string $key
437
-     * @return int form id
438
-     */
416
+	/**
417
+	 * @return string form name
418
+	 */
419
+	public static function &getName( $id ) {
420
+		global $wpdb;
421
+
422
+		$form = FrmAppHelper::check_cache($id, 'frm_form');
423
+		if ( $form ) {
424
+			$r = stripslashes($form->name);
425
+			return $r;
426
+		}
427
+
428
+		$query_key = is_numeric( $id ) ? 'id' : 'form_key';
429
+		$r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
430
+		$r = stripslashes($r);
431
+
432
+		return $r;
433
+	}
434
+
435
+	/**
436
+	 * @param string $key
437
+	 * @return int form id
438
+	 */
439 439
 	public static function &getIdByKey( $key ) {
440
-        $id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) );
441
-        return $id;
442
-    }
443
-
444
-    /**
445
-     * @param int $id
446
-     * @return string form key
447
-     */
440
+		$id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) );
441
+		return $id;
442
+	}
443
+
444
+	/**
445
+	 * @param int $id
446
+	 * @return string form key
447
+	 */
448 448
 	public static function &getKeyById( $id ) {
449
-        $id = (int) $id;
450
-        $cache = FrmAppHelper::check_cache($id, 'frm_form');
451
-        if ( $cache ) {
452
-            return $cache->form_key;
453
-        }
449
+		$id = (int) $id;
450
+		$cache = FrmAppHelper::check_cache($id, 'frm_form');
451
+		if ( $cache ) {
452
+			return $cache->form_key;
453
+		}
454 454
 
455
-        $key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' );
455
+		$key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' );
456 456
 
457
-        return $key;
458
-    }
457
+		return $key;
458
+	}
459 459
 
460 460
 	/**
461 461
 	 * If $form is numeric, get the form object
@@ -468,47 +468,47 @@  discard block
 block discarded – undo
468 468
 		}
469 469
 	}
470 470
 
471
-    /**
472
-     * @return object form
473
-     */
474
-    public static function getOne( $id, $blog_id = false ) {
475
-        global $wpdb;
471
+	/**
472
+	 * @return object form
473
+	 */
474
+	public static function getOne( $id, $blog_id = false ) {
475
+		global $wpdb;
476 476
 
477
-        if ( $blog_id && is_multisite() ) {
478
-            global $wpmuBaseTablePrefix;
477
+		if ( $blog_id && is_multisite() ) {
478
+			global $wpmuBaseTablePrefix;
479 479
 			$prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix . $blog_id . '_' : $wpdb->get_blog_prefix( $blog_id );
480 480
 
481 481
 			$table_name = $prefix . 'frm_forms';
482
-        } else {
482
+		} else {
483 483
 			$table_name = $wpdb->prefix . 'frm_forms';
484
-            $cache = wp_cache_get($id, 'frm_form');
485
-            if ( $cache ) {
486
-                if ( isset($cache->options) ) {
487
-                    $cache->options = maybe_unserialize($cache->options);
488
-                }
489
-
490
-                return stripslashes_deep($cache);
491
-            }
492
-        }
493
-
494
-        if ( is_numeric($id) ) {
495
-            $where = array( 'id' => $id );
496
-        } else {
497
-            $where = array( 'form_key' => $id );
498
-        }
499
-
500
-        $results = FrmDb::get_row( $table_name, $where );
501
-
502
-        if ( isset($results->options) ) {
503
-            wp_cache_set($results->id, $results, 'frm_form');
504
-            $results->options = maybe_unserialize($results->options);
505
-        }
506
-        return stripslashes_deep($results);
507
-    }
508
-
509
-    /**
510
-     * @return object|array of objects
511
-     */
484
+			$cache = wp_cache_get($id, 'frm_form');
485
+			if ( $cache ) {
486
+				if ( isset($cache->options) ) {
487
+					$cache->options = maybe_unserialize($cache->options);
488
+				}
489
+
490
+				return stripslashes_deep($cache);
491
+			}
492
+		}
493
+
494
+		if ( is_numeric($id) ) {
495
+			$where = array( 'id' => $id );
496
+		} else {
497
+			$where = array( 'form_key' => $id );
498
+		}
499
+
500
+		$results = FrmDb::get_row( $table_name, $where );
501
+
502
+		if ( isset($results->options) ) {
503
+			wp_cache_set($results->id, $results, 'frm_form');
504
+			$results->options = maybe_unserialize($results->options);
505
+		}
506
+		return stripslashes_deep($results);
507
+	}
508
+
509
+	/**
510
+	 * @return object|array of objects
511
+	 */
512 512
 	public static function getAll( $where = array(), $order_by = '', $limit = '' ) {
513 513
 		if ( is_array( $where ) && ! empty( $where ) ) {
514 514
 			$results = FrmDb::get_results( 'frm_forms', $where, '*', array( 'order_by' => $order_by, 'limit' => $limit ) );
@@ -532,8 +532,8 @@  discard block
 block discarded – undo
532 532
 			$results = reset( $results );
533 533
 		}
534 534
 
535
-        return stripslashes_deep($results);
536
-    }
535
+		return stripslashes_deep($results);
536
+	}
537 537
 
538 538
 	/**
539 539
 	 * Get all published forms
@@ -551,47 +551,47 @@  discard block
 block discarded – undo
551 551
 		return $forms;
552 552
 	}
553 553
 
554
-    /**
555
-     * @return int count of forms
556
-     */
557
-    public static function &get_count() {
558
-    	global $wpdb;
554
+	/**
555
+	 * @return int count of forms
556
+	 */
557
+	public static function &get_count() {
558
+		global $wpdb;
559 559
 
560
-    	$cache_key = 'frm_form_counts';
560
+		$cache_key = 'frm_form_counts';
561 561
 
562
-    	$counts = wp_cache_get( $cache_key, 'counts' );
563
-    	if ( false !== $counts ) {
564
-    	    return $counts;
565
-    	}
562
+		$counts = wp_cache_get( $cache_key, 'counts' );
563
+		if ( false !== $counts ) {
564
+			return $counts;
565
+		}
566 566
 
567
-        $results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' );
567
+		$results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' );
568 568
 
569 569
 		$statuses = array( 'published', 'draft', 'template', 'trash' );
570
-    	$counts = array_fill_keys( $statuses, 0 );
570
+		$counts = array_fill_keys( $statuses, 0 );
571 571
 
572
-    	foreach ( $results as $row ) {
573
-            if ( 'trash' != $row->status ) {
574
-    	        if ( $row->is_template ) {
572
+		foreach ( $results as $row ) {
573
+			if ( 'trash' != $row->status ) {
574
+				if ( $row->is_template ) {
575 575
 					$counts['template']++;
576
-    	        } else {
576
+				} else {
577 577
 					$counts['published']++;
578
-    	        }
579
-    	    } else {
578
+				}
579
+			} else {
580 580
 				$counts['trash']++;
581
-        	}
581
+			}
582 582
 
583
-    	    if ( 'draft' == $row->status ) {
583
+			if ( 'draft' == $row->status ) {
584 584
 				$counts['draft']++;
585
-    	    }
585
+			}
586 586
 
587
-    		unset($row);
588
-    	}
587
+			unset($row);
588
+		}
589 589
 
590
-    	$counts = (object) $counts;
591
-    	wp_cache_set( $cache_key, $counts, 'counts' );
590
+		$counts = (object) $counts;
591
+		wp_cache_set( $cache_key, $counts, 'counts' );
592 592
 
593
-    	return $counts;
594
-    }
593
+		return $counts;
594
+	}
595 595
 
596 596
 	/**
597 597
 	 * Clear form caching
@@ -604,14 +604,14 @@  discard block
 block discarded – undo
604 604
 		FrmAppHelper::cache_delete_group( 'frm_form' );
605 605
 	}
606 606
 
607
-    /**
608
-     * @return array of errors
609
-     */
607
+	/**
608
+	 * @return array of errors
609
+	 */
610 610
 	public static function validate( $values ) {
611
-        $errors = array();
611
+		$errors = array();
612 612
 
613
-        return apply_filters('frm_validate_form', $errors, $values);
614
-    }
613
+		return apply_filters('frm_validate_form', $errors, $values);
614
+	}
615 615
 
616 616
 	public static function get_params( $form = null ) {
617 617
 		global $frm_vars;
Please login to merge, or discard this patch.
classes/models/FrmNotification.php 2 patches
Indentation   +256 added lines, -256 removed lines patch added patch discarded remove patch
@@ -2,160 +2,160 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmNotification {
4 4
 	public function __construct() {
5
-        if ( ! defined('ABSPATH') ) {
6
-            die('You are not allowed to call this page directly.');
7
-        }
8
-        add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3);
9
-    }
5
+		if ( ! defined('ABSPATH') ) {
6
+			die('You are not allowed to call this page directly.');
7
+		}
8
+		add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3);
9
+	}
10 10
 
11 11
 	public static function trigger_email( $action, $entry, $form ) {
12
-        $notification = $action->post_content;
13
-        $email_key = $action->ID;
14
-
15
-        // Set the subject
16
-        if ( empty($notification['email_subject']) ) {
17
-            $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]');
18
-        }
19
-
20
-        $plain_text = $notification['plain_text'] ? true : false;
21
-
22
-        //Filter these fields
23
-        $filter_fields = array(
24
-            'email_to', 'cc', 'bcc',
25
-            'reply_to', 'from',
26
-            'email_subject', 'email_message',
27
-        );
28
-
29
-        add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false'));
30
-
31
-        //Get all values in entry in order to get User ID field ID
32
-        $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' );
33
-        $user_id_field = $user_id_key = '';
34
-        foreach ( $values as $value ) {
35
-            if ( $value->field_type == 'user_id' ) {
36
-                $user_id_field = $value->field_id;
37
-                $user_id_key = $value->field_key;
38
-                break;
39
-            }
40
-            unset($value);
41
-        }
42
-
43
-        //Filter and prepare the email fields
44
-        foreach ( $filter_fields as $f ) {
45
-            //Don't allow empty From
12
+		$notification = $action->post_content;
13
+		$email_key = $action->ID;
14
+
15
+		// Set the subject
16
+		if ( empty($notification['email_subject']) ) {
17
+			$notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]');
18
+		}
19
+
20
+		$plain_text = $notification['plain_text'] ? true : false;
21
+
22
+		//Filter these fields
23
+		$filter_fields = array(
24
+			'email_to', 'cc', 'bcc',
25
+			'reply_to', 'from',
26
+			'email_subject', 'email_message',
27
+		);
28
+
29
+		add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false'));
30
+
31
+		//Get all values in entry in order to get User ID field ID
32
+		$values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' );
33
+		$user_id_field = $user_id_key = '';
34
+		foreach ( $values as $value ) {
35
+			if ( $value->field_type == 'user_id' ) {
36
+				$user_id_field = $value->field_id;
37
+				$user_id_key = $value->field_key;
38
+				break;
39
+			}
40
+			unset($value);
41
+		}
42
+
43
+		//Filter and prepare the email fields
44
+		foreach ( $filter_fields as $f ) {
45
+			//Don't allow empty From
46 46
 			if ( $f == 'from' && empty( $notification[ $f ] ) ) {
47 47
 				$notification[ $f ] = '[admin_email]';
48 48
 			} else if ( in_array( $f, array( 'email_to', 'cc', 'bcc', 'reply_to', 'from' ) ) ) {
49 49
 				//Remove brackets
50
-                //Add a space in case there isn't one
50
+				//Add a space in case there isn't one
51 51
 				$notification[ $f ] = str_replace( '<', ' ', $notification[ $f ] );
52 52
 				$notification[ $f ] = str_replace( array( '"', '>' ), '', $notification[ $f ] );
53 53
 
54
-                //Switch userID shortcode to email address
54
+				//Switch userID shortcode to email address
55 55
 				if ( strpos( $notification[ $f ], '[' . $user_id_field . ']' ) !== false || strpos( $notification[ $f ], '[' . $user_id_key . ']' ) !== false ) {
56 56
 					$user_data = get_userdata( $entry->metas[ $user_id_field ] );
57
-                    $user_email = $user_data->user_email;
57
+					$user_email = $user_data->user_email;
58 58
 					$notification[ $f ] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[ $f ] );
59
-                }
60
-            }
59
+				}
60
+			}
61 61
 
62 62
 			$notification[ $f ] = FrmFieldsHelper::basic_replace_shortcodes( $notification[ $f ], $form, $entry );
63
-        }
63
+		}
64 64
 
65
-        //Put recipients, cc, and bcc into an array if they aren't empty
65
+		//Put recipients, cc, and bcc into an array if they aren't empty
66 66
 		$to_emails = self::explode_emails( $notification['email_to'] );
67 67
 		$cc = self::explode_emails( $notification['cc'] );
68 68
 		$bcc = self::explode_emails( $notification['bcc'] );
69 69
 
70
-        $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form'));
70
+		$to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form'));
71 71
 
72
-        // Stop now if there aren't any recipients
73
-        if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) {
74
-            return;
75
-        }
72
+		// Stop now if there aren't any recipients
73
+		if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) {
74
+			return;
75
+		}
76 76
 
77
-        $to_emails = array_unique( (array) $to_emails );
77
+		$to_emails = array_unique( (array) $to_emails );
78 78
 
79
-        $prev_mail_body = $mail_body = $notification['email_message'];
80
-        $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array(
81
-            'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text,
82
-            'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false),
83
-        ) );
79
+		$prev_mail_body = $mail_body = $notification['email_message'];
80
+		$mail_body = FrmEntriesHelper::replace_default_message($mail_body, array(
81
+			'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text,
82
+			'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false),
83
+		) );
84 84
 
85
-        // Add the user info if it isn't already included
86
-        if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) {
87
-            $data = maybe_unserialize($entry->description);
85
+		// Add the user info if it isn't already included
86
+		if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) {
87
+			$data = maybe_unserialize($entry->description);
88 88
 			$mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n";
89 89
 			$mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $entry->ip . "\r\n";
90 90
 			$mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntryFormat::get_browser( $data['browser'] ) . "\r\n";
91 91
 			$mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n";
92
-        }
93
-        unset($prev_mail_body);
94
-
95
-        // Add attachments
96
-        $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') );
97
-
98
-        if ( ! empty($notification['email_subject']) ) {
99
-            $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key'));
100
-        }
101
-
102
-        // check for a phone number
103
-        foreach ( (array) $to_emails as $email_key => $e ) {
104
-            if ( $e != '[admin_email]' && ! is_email($e) ) {
105
-                $e = explode(' ', $e);
106
-
107
-                //If to_email has name <[email protected]> format
108
-                if ( is_email(end($e)) ) {
109
-                    continue;
110
-                }
111
-
112
-                do_action('frm_send_to_not_email', array(
113
-                    'e'         => $e,
114
-                    'subject'   => $notification['email_subject'],
115
-                    'mail_body' => $mail_body,
116
-                    'reply_to'  => $notification['reply_to'],
117
-                    'from'      => $notification['from'],
118
-                    'plain_text' => $plain_text,
119
-                    'attachments' => $attachments,
120
-                    'form'      => $form,
121
-                    'email_key' => $email_key,
122
-                ) );
92
+		}
93
+		unset($prev_mail_body);
94
+
95
+		// Add attachments
96
+		$attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') );
97
+
98
+		if ( ! empty($notification['email_subject']) ) {
99
+			$notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key'));
100
+		}
101
+
102
+		// check for a phone number
103
+		foreach ( (array) $to_emails as $email_key => $e ) {
104
+			if ( $e != '[admin_email]' && ! is_email($e) ) {
105
+				$e = explode(' ', $e);
106
+
107
+				//If to_email has name <[email protected]> format
108
+				if ( is_email(end($e)) ) {
109
+					continue;
110
+				}
111
+
112
+				do_action('frm_send_to_not_email', array(
113
+					'e'         => $e,
114
+					'subject'   => $notification['email_subject'],
115
+					'mail_body' => $mail_body,
116
+					'reply_to'  => $notification['reply_to'],
117
+					'from'      => $notification['from'],
118
+					'plain_text' => $plain_text,
119
+					'attachments' => $attachments,
120
+					'form'      => $form,
121
+					'email_key' => $email_key,
122
+				) );
123 123
 
124 124
 				unset( $to_emails[ $email_key ] );
125
-            }
126
-        }
127
-
128
-        // Send the email now
129
-        $sent_to = self::send_email( array(
130
-            'to_email'      => $to_emails,
131
-            'subject'       => $notification['email_subject'],
132
-            'message'       => $mail_body,
133
-            'from'          => $notification['from'],
134
-            'plain_text'    => $plain_text,
135
-            'reply_to'      => $notification['reply_to'],
136
-            'attachments'   => $attachments,
137
-            'cc'            => $cc,
138
-            'bcc'           => $bcc,
139
-        ) );
140
-
141
-        return $sent_to;
142
-    }
125
+			}
126
+		}
127
+
128
+		// Send the email now
129
+		$sent_to = self::send_email( array(
130
+			'to_email'      => $to_emails,
131
+			'subject'       => $notification['email_subject'],
132
+			'message'       => $mail_body,
133
+			'from'          => $notification['from'],
134
+			'plain_text'    => $plain_text,
135
+			'reply_to'      => $notification['reply_to'],
136
+			'attachments'   => $attachments,
137
+			'cc'            => $cc,
138
+			'bcc'           => $bcc,
139
+		) );
140
+
141
+		return $sent_to;
142
+	}
143 143
 
144 144
 	public function entry_created( $entry_id, $form_id ) {
145 145
 		$new_function = 'FrmFormActionsController::trigger_actions("create", ' . $form_id . ', ' . $entry_id . ', "email")';
146 146
 		_deprecated_function( __FUNCTION__, '2.0', $new_function );
147
-        FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email');
148
-    }
147
+		FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email');
148
+	}
149 149
 
150 150
 	public function send_notification_email( $to_email, $subject, $message, $from = '', $from_name = '', $plain_text = true, $attachments = array(), $reply_to = '' ) {
151
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' );
151
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' );
152 152
 
153
-        return self::send_email(compact(
154
-            'to_email', 'subject', 'message',
155
-            'from', 'from_name', 'plain_text',
156
-            'attachments', 'reply_to'
157
-        ));
158
-    }
153
+		return self::send_email(compact(
154
+			'to_email', 'subject', 'message',
155
+			'from', 'from_name', 'plain_text',
156
+			'attachments', 'reply_to'
157
+		));
158
+	}
159 159
 
160 160
 	/**
161 161
 	 * Extract the emails from cc and bcc. Allow separation by , or ;.
@@ -173,53 +173,53 @@  discard block
 block discarded – undo
173 173
 		return $emails;
174 174
 	}
175 175
 
176
-    /**
177
-    * Put To, BCC, CC, Reply To, and From fields in Name <[email protected]> format
178
-    * Formats that should work: Name, "Name", [email protected], <[email protected]>, Name <[email protected]>,
179
-    * "Name" <[email protected]>, Name [email protected], "Name" [email protected], Name<[email protected]>, "Name"<[email protected]>
180
-    * "First Last" <[email protected]>
181
-    *
182
-    * Things that won't work: First Last (with no email entered)
183
-    * @since 2.0
184
-    * @param array $atts array of email fields, pass by reference
185
-    * @param $admin_email
186
-    */
187
-    private static function format_email_fields( &$atts, $admin_email ) {
188
-
189
-        // If from is empty or is set to admin_email, set it now
190
-        $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from'];
191
-
192
-        // Filter values in these fields
176
+	/**
177
+	 * Put To, BCC, CC, Reply To, and From fields in Name <[email protected]> format
178
+	 * Formats that should work: Name, "Name", [email protected], <[email protected]>, Name <[email protected]>,
179
+	 * "Name" <[email protected]>, Name [email protected], "Name" [email protected], Name<[email protected]>, "Name"<[email protected]>
180
+	 * "First Last" <[email protected]>
181
+	 *
182
+	 * Things that won't work: First Last (with no email entered)
183
+	 * @since 2.0
184
+	 * @param array $atts array of email fields, pass by reference
185
+	 * @param $admin_email
186
+	 */
187
+	private static function format_email_fields( &$atts, $admin_email ) {
188
+
189
+		// If from is empty or is set to admin_email, set it now
190
+		$atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from'];
191
+
192
+		// Filter values in these fields
193 193
 		$filter_fields = array( 'to_email', 'bcc', 'cc', 'from', 'reply_to' );
194 194
 
195
-        foreach ( $filter_fields as $f ) {
196
-            // If empty, just skip it
195
+		foreach ( $filter_fields as $f ) {
196
+			// If empty, just skip it
197 197
 			if ( empty( $atts[ $f ] ) ) {
198
-                continue;
199
-            }
198
+				continue;
199
+			}
200 200
 
201
-            // to_email, cc, and bcc can be an array
201
+			// to_email, cc, and bcc can be an array
202 202
 			if ( is_array( $atts[ $f ] ) ) {
203 203
 				foreach ( $atts[ $f ] as $key => $val ) {
204
-                    self::format_single_field( $atts, $f, $val, $key );
205
-                    unset( $key, $val );
206
-                }
207
-                unset($f);
208
-                continue;
209
-            }
204
+					self::format_single_field( $atts, $f, $val, $key );
205
+					unset( $key, $val );
206
+				}
207
+				unset($f);
208
+				continue;
209
+			}
210 210
 
211 211
 			self::format_single_field( $atts, $f, $atts[ $f ] );
212
-        }
212
+		}
213 213
 
214
-        // If reply-to isn't set, make it match the from settings
215
-        if ( empty( $atts['reply_to'] ) ) {
216
-            $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] );
217
-        }
214
+		// If reply-to isn't set, make it match the from settings
215
+		if ( empty( $atts['reply_to'] ) ) {
216
+			$atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] );
217
+		}
218 218
 
219
-        if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) {
220
-            $atts['to_email'] = $admin_email;
221
-        }
222
-    }
219
+		if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) {
220
+			$atts['to_email'] = $admin_email;
221
+		}
222
+	}
223 223
 
224 224
 	private static function get_email_from_formatted_string( $value ) {
225 225
 		if ( strpos( $value, '<' ) !== false ) {
@@ -229,48 +229,48 @@  discard block
 block discarded – undo
229 229
 		return $value;
230 230
 	}
231 231
 
232
-    /**
233
-    * Format individual email fields
234
-    *
235
-    * @since 2.0
236
-    * @param array $atts pass by reference
237
-    * @param string $f (to, from, reply_to, etc)
238
-    * @param string $val value saved in field
239
-    * @param int $key if in array, this will be set
240
-    */
241
-    private static function format_single_field( &$atts, $f, $val, $key = false ) {
242
-        $val = trim($val);
243
-
244
-        // If just a plain email is used
245
-        if ( is_email($val) ) {
246
-            // add sender's name if not included in $from
247
-            if ( $f == 'from' ) {
232
+	/**
233
+	 * Format individual email fields
234
+	 *
235
+	 * @since 2.0
236
+	 * @param array $atts pass by reference
237
+	 * @param string $f (to, from, reply_to, etc)
238
+	 * @param string $val value saved in field
239
+	 * @param int $key if in array, this will be set
240
+	 */
241
+	private static function format_single_field( &$atts, $f, $val, $key = false ) {
242
+		$val = trim($val);
243
+
244
+		// If just a plain email is used
245
+		if ( is_email($val) ) {
246
+			// add sender's name if not included in $from
247
+			if ( $f == 'from' ) {
248 248
 				$part_2 = $atts[ $f ];
249
-                $part_1  = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
250
-            } else {
251
-                return;
252
-            }
253
-        } else {
254
-            $parts = explode(' ', $val);
255
-            $part_2 = end($parts);
256
-
257
-            // If inputted correcly, $part_2 should be an email
258
-            if ( is_email( $part_2 ) ) {
259
-                $part_1 = trim( str_replace( $part_2, '', $val ) );
260
-            } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) {
249
+				$part_1  = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
250
+			} else {
251
+				return;
252
+			}
253
+		} else {
254
+			$parts = explode(' ', $val);
255
+			$part_2 = end($parts);
256
+
257
+			// If inputted correcly, $part_2 should be an email
258
+			if ( is_email( $part_2 ) ) {
259
+				$part_1 = trim( str_replace( $part_2, '', $val ) );
260
+			} else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) {
261 261
 				// In case someone just puts a name in the From or Reply To field
262 262
 				$part_1 = $val;
263
-                $part_2 = get_option('admin_email');
264
-            } else {
263
+				$part_2 = get_option('admin_email');
264
+			} else {
265 265
 				// In case someone just puts a name in any other email field
266
-                if ( false !== $key ) {
266
+				if ( false !== $key ) {
267 267
 					unset( $atts[ $f ][ $key ] );
268
-                    return;
269
-                }
268
+					return;
269
+				}
270 270
 				$atts[ $f ] = '';
271
-                return;
272
-            }
273
-        }
271
+				return;
272
+			}
273
+		}
274 274
 
275 275
 		// if sending the email from a yahoo address, change it to the WordPress default
276 276
 		if ( $f == 'from' && strpos( $part_2, '@yahoo.com' ) ) {
@@ -283,110 +283,110 @@  discard block
 block discarded – undo
283 283
 			$part_2 = 'wordpress@' . $sitename;
284 284
 		}
285 285
 
286
-        // Set up formatted value
286
+		// Set up formatted value
287 287
 		$final_val = str_replace( '"', '', $part_1 ) . ' <' . $part_2 . '>';
288 288
 
289
-        // If value is an array
290
-        if ( false !== $key ) {
289
+		// If value is an array
290
+		if ( false !== $key ) {
291 291
 			$atts[ $f ][ $key ] = $final_val;
292
-            return;
293
-        }
292
+			return;
293
+		}
294 294
 		$atts[ $f ] = $final_val;
295
-    }
295
+	}
296 296
 
297 297
 	public static function send_email( $atts ) {
298
-        $admin_email = get_option('admin_email');
299
-        $defaults = array(
300
-            'to_email'      => $admin_email,
301
-            'subject'       => '',
302
-            'message'       => '',
303
-            'from'          => $admin_email,
304
-            'from_name'     => '',
305
-            'cc'            => '',
306
-            'bcc'           => '',
307
-            'plain_text'    => true,
308
-            'reply_to'      => $admin_email,
309
-            'attachments'   => array(),
310
-        );
311
-        $atts = wp_parse_args($atts, $defaults);
312
-
313
-        // Put To, BCC, CC, Reply To, and From fields in the correct format
314
-        self::format_email_fields( $atts, $admin_email );
315
-
316
-        $recipient      = $atts['to_email']; //recipient
317
-        $header         = array();
318
-        $header[]       = 'From: ' . $atts['from'];
319
-
320
-        //Allow for cc and bcc arrays
298
+		$admin_email = get_option('admin_email');
299
+		$defaults = array(
300
+			'to_email'      => $admin_email,
301
+			'subject'       => '',
302
+			'message'       => '',
303
+			'from'          => $admin_email,
304
+			'from_name'     => '',
305
+			'cc'            => '',
306
+			'bcc'           => '',
307
+			'plain_text'    => true,
308
+			'reply_to'      => $admin_email,
309
+			'attachments'   => array(),
310
+		);
311
+		$atts = wp_parse_args($atts, $defaults);
312
+
313
+		// Put To, BCC, CC, Reply To, and From fields in the correct format
314
+		self::format_email_fields( $atts, $admin_email );
315
+
316
+		$recipient      = $atts['to_email']; //recipient
317
+		$header         = array();
318
+		$header[]       = 'From: ' . $atts['from'];
319
+
320
+		//Allow for cc and bcc arrays
321 321
 		$array_fields = array( 'CC' => $atts['cc'], 'BCC' => $atts['bcc'] );
322 322
 		$cc = array( 'CC' => array(), 'BCC' => array() );
323
-        foreach ( $array_fields as $key => $a_field ) {
324
-            if ( empty($a_field) ) {
325
-                continue;
326
-            }
323
+		foreach ( $array_fields as $key => $a_field ) {
324
+			if ( empty($a_field) ) {
325
+				continue;
326
+			}
327 327
 
328 328
 			foreach ( (array) $a_field as $email ) {
329 329
 				$cc[ $key ][] = $email;
330
-            }
331
-            unset($key, $a_field);
332
-        }
330
+			}
331
+			unset($key, $a_field);
332
+		}
333 333
 		$cc = array_filter( $cc ); // remove cc and bcc if they are empty
334 334
 
335 335
 		foreach ( $cc as $k => $v ) {
336 336
 			$header[] = $k . ': ' . implode( ',', $v );
337 337
 		}
338 338
 
339
-        $content_type   = $atts['plain_text'] ? 'text/plain' : 'text/html';
340
-        $charset        = get_option('blog_charset');
339
+		$content_type   = $atts['plain_text'] ? 'text/plain' : 'text/html';
340
+		$charset        = get_option('blog_charset');
341 341
 
342 342
 		$header[]       = 'Reply-To: ' . $atts['reply_to'];
343 343
 		$header[]       = 'Content-Type: ' . $content_type . '; charset="' . esc_attr( $charset ) . '"';
344
-        $atts['subject'] = wp_specialchars_decode(strip_tags(stripslashes($atts['subject'])), ENT_QUOTES );
344
+		$atts['subject'] = wp_specialchars_decode(strip_tags(stripslashes($atts['subject'])), ENT_QUOTES );
345 345
 
346
-        $message        = do_shortcode($atts['message']);
346
+		$message        = do_shortcode($atts['message']);
347 347
 
348
-        if ( $atts['plain_text'] ) {
349
-            //$message    = wordwrap($message, 70, "\r\n"); //in case any lines are longer than 70 chars
350
-            $message    = wp_specialchars_decode(strip_tags($message), ENT_QUOTES );
351
-        } else {
348
+		if ( $atts['plain_text'] ) {
349
+			//$message    = wordwrap($message, 70, "\r\n"); //in case any lines are longer than 70 chars
350
+			$message    = wp_specialchars_decode(strip_tags($message), ENT_QUOTES );
351
+		} else {
352 352
 			// remove line breaks in HTML emails to prevent conflicts with Mandrill
353
-        	add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' );
354
-        }
353
+			add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' );
354
+		}
355 355
 		$message = apply_filters( 'frm_email_message', $message, $atts );
356 356
 
357
-        $header         = apply_filters('frm_email_header', $header, array(
357
+		$header         = apply_filters('frm_email_header', $header, array(
358 358
 			'to_email' => $atts['to_email'], 'subject' => $atts['subject'],
359 359
 		) );
360 360
 
361
-        if ( apply_filters('frm_encode_subject', 1, $atts['subject'] ) ) {
361
+		if ( apply_filters('frm_encode_subject', 1, $atts['subject'] ) ) {
362 362
 			$atts['subject'] = '=?' . $charset . '?B?' . base64_encode( $atts['subject'] ) . '?=';
363
-        }
363
+		}
364 364
 
365
-        remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' );
366
-        remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter');
365
+		remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' );
366
+		remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter');
367 367
 
368
-        $sent = wp_mail($recipient, $atts['subject'], $message, $header, $atts['attachments']);
369
-        if ( ! $sent ) {
368
+		$sent = wp_mail($recipient, $atts['subject'], $message, $header, $atts['attachments']);
369
+		if ( ! $sent ) {
370 370
 			$header = 'From: ' . $atts['from'] . "\r\n";
371
-            $recipient = implode(',', (array) $recipient);
372
-            $sent = mail($recipient, $atts['subject'], $message, $header);
373
-        }
371
+			$recipient = implode(',', (array) $recipient);
372
+			$sent = mail($recipient, $atts['subject'], $message, $header);
373
+		}
374 374
 
375 375
 		// remove the filter now so other emails can still use it
376 376
 		remove_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' );
377 377
 
378
-        do_action('frm_notification', $recipient, $atts['subject'], $message);
378
+		do_action('frm_notification', $recipient, $atts['subject'], $message);
379 379
 
380
-        if ( $sent ) {
380
+		if ( $sent ) {
381 381
 			$sent_to = array_merge( (array) $atts['to_email'], (array) $atts['cc'], (array) $atts['bcc'] );
382
-            $sent_to = array_filter( $sent_to );
383
-            if ( apply_filters('frm_echo_emails', false) ) {
384
-                $temp = str_replace('<', '&lt;', $sent_to);
382
+			$sent_to = array_filter( $sent_to );
383
+			if ( apply_filters('frm_echo_emails', false) ) {
384
+				$temp = str_replace('<', '&lt;', $sent_to);
385 385
 				echo ' ' . FrmAppHelper::kses( implode(', ', (array) $temp ) );
386
-            }
387
-            return $sent_to;
388
-        }
389
-    }
386
+			}
387
+			return $sent_to;
388
+		}
389
+	}
390 390
 
391 391
 	/**
392 392
 	 * This function should only be fired when Mandrill is sending an HTML email
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -2,10 +2,10 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmNotification {
4 4
 	public function __construct() {
5
-        if ( ! defined('ABSPATH') ) {
6
-            die('You are not allowed to call this page directly.');
5
+        if ( ! defined( 'ABSPATH' ) ) {
6
+            die( 'You are not allowed to call this page directly.' );
7 7
         }
8
-        add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3);
8
+        add_action( 'frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3 );
9 9
     }
10 10
 
11 11
 	public static function trigger_email( $action, $entry, $form ) {
@@ -13,8 +13,8 @@  discard block
 block discarded – undo
13 13
         $email_key = $action->ID;
14 14
 
15 15
         // Set the subject
16
-        if ( empty($notification['email_subject']) ) {
17
-            $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]');
16
+        if ( empty( $notification['email_subject'] ) ) {
17
+            $notification['email_subject'] = sprintf( __( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]' );
18 18
         }
19 19
 
20 20
         $plain_text = $notification['plain_text'] ? true : false;
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
             'email_subject', 'email_message',
27 27
         );
28 28
 
29
-        add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false'));
29
+        add_filter( 'frm_plain_text_email', ( $plain_text ? '__return_true' : '__return_false' ) );
30 30
 
31 31
         //Get all values in entry in order to get User ID field ID
32 32
         $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' );
@@ -37,29 +37,29 @@  discard block
 block discarded – undo
37 37
                 $user_id_key = $value->field_key;
38 38
                 break;
39 39
             }
40
-            unset($value);
40
+            unset( $value );
41 41
         }
42 42
 
43 43
         //Filter and prepare the email fields
44 44
         foreach ( $filter_fields as $f ) {
45 45
             //Don't allow empty From
46
-			if ( $f == 'from' && empty( $notification[ $f ] ) ) {
47
-				$notification[ $f ] = '[admin_email]';
46
+			if ( $f == 'from' && empty( $notification[$f] ) ) {
47
+				$notification[$f] = '[admin_email]';
48 48
 			} else if ( in_array( $f, array( 'email_to', 'cc', 'bcc', 'reply_to', 'from' ) ) ) {
49 49
 				//Remove brackets
50 50
                 //Add a space in case there isn't one
51
-				$notification[ $f ] = str_replace( '<', ' ', $notification[ $f ] );
52
-				$notification[ $f ] = str_replace( array( '"', '>' ), '', $notification[ $f ] );
51
+				$notification[$f] = str_replace( '<', ' ', $notification[$f] );
52
+				$notification[$f] = str_replace( array( '"', '>' ), '', $notification[$f] );
53 53
 
54 54
                 //Switch userID shortcode to email address
55
-				if ( strpos( $notification[ $f ], '[' . $user_id_field . ']' ) !== false || strpos( $notification[ $f ], '[' . $user_id_key . ']' ) !== false ) {
56
-					$user_data = get_userdata( $entry->metas[ $user_id_field ] );
55
+				if ( strpos( $notification[$f], '[' . $user_id_field . ']' ) !== false || strpos( $notification[$f], '[' . $user_id_key . ']' ) !== false ) {
56
+					$user_data = get_userdata( $entry->metas[$user_id_field] );
57 57
                     $user_email = $user_data->user_email;
58
-					$notification[ $f ] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[ $f ] );
58
+					$notification[$f] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[$f] );
59 59
                 }
60 60
             }
61 61
 
62
-			$notification[ $f ] = FrmFieldsHelper::basic_replace_shortcodes( $notification[ $f ], $form, $entry );
62
+			$notification[$f] = FrmFieldsHelper::basic_replace_shortcodes( $notification[$f], $form, $entry );
63 63
         }
64 64
 
65 65
         //Put recipients, cc, and bcc into an array if they aren't empty
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		$cc = self::explode_emails( $notification['cc'] );
68 68
 		$bcc = self::explode_emails( $notification['bcc'] );
69 69
 
70
-        $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form'));
70
+        $to_emails = apply_filters( 'frm_to_email', $to_emails, $values, $form->id, compact( 'email_key', 'entry', 'form' ) );
71 71
 
72 72
         // Stop now if there aren't any recipients
73 73
         if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) {
@@ -77,39 +77,39 @@  discard block
 block discarded – undo
77 77
         $to_emails = array_unique( (array) $to_emails );
78 78
 
79 79
         $prev_mail_body = $mail_body = $notification['email_message'];
80
-        $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array(
80
+        $mail_body = FrmEntriesHelper::replace_default_message( $mail_body, array(
81 81
             'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text,
82
-            'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false),
82
+            'user_info' => ( isset( $notification['inc_user_info'] ) ? $notification['inc_user_info'] : false ),
83 83
         ) );
84 84
 
85 85
         // Add the user info if it isn't already included
86 86
         if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) {
87
-            $data = maybe_unserialize($entry->description);
87
+            $data = maybe_unserialize( $entry->description );
88 88
 			$mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n";
89 89
 			$mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $entry->ip . "\r\n";
90 90
 			$mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntryFormat::get_browser( $data['browser'] ) . "\r\n";
91 91
 			$mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n";
92 92
         }
93
-        unset($prev_mail_body);
93
+        unset( $prev_mail_body );
94 94
 
95 95
         // Add attachments
96
-        $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') );
96
+        $attachments = apply_filters( 'frm_notification_attachment', array(), $form, compact( 'entry', 'email_key' ) );
97 97
 
98
-        if ( ! empty($notification['email_subject']) ) {
99
-            $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key'));
98
+        if ( ! empty( $notification['email_subject'] ) ) {
99
+            $notification['email_subject'] = apply_filters( 'frm_email_subject', $notification['email_subject'], compact( 'form', 'entry', 'email_key' ) );
100 100
         }
101 101
 
102 102
         // check for a phone number
103 103
         foreach ( (array) $to_emails as $email_key => $e ) {
104
-            if ( $e != '[admin_email]' && ! is_email($e) ) {
105
-                $e = explode(' ', $e);
104
+            if ( $e != '[admin_email]' && ! is_email( $e ) ) {
105
+                $e = explode( ' ', $e );
106 106
 
107 107
                 //If to_email has name <[email protected]> format
108
-                if ( is_email(end($e)) ) {
108
+                if ( is_email( end( $e ) ) ) {
109 109
                     continue;
110 110
                 }
111 111
 
112
-                do_action('frm_send_to_not_email', array(
112
+                do_action( 'frm_send_to_not_email', array(
113 113
                     'e'         => $e,
114 114
                     'subject'   => $notification['email_subject'],
115 115
                     'mail_body' => $mail_body,
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                     'email_key' => $email_key,
122 122
                 ) );
123 123
 
124
-				unset( $to_emails[ $email_key ] );
124
+				unset( $to_emails[$email_key] );
125 125
             }
126 126
         }
127 127
 
@@ -144,17 +144,17 @@  discard block
 block discarded – undo
144 144
 	public function entry_created( $entry_id, $form_id ) {
145 145
 		$new_function = 'FrmFormActionsController::trigger_actions("create", ' . $form_id . ', ' . $entry_id . ', "email")';
146 146
 		_deprecated_function( __FUNCTION__, '2.0', $new_function );
147
-        FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email');
147
+        FrmFormActionsController::trigger_actions( 'create', $form_id, $entry_id, 'email' );
148 148
     }
149 149
 
150 150
 	public function send_notification_email( $to_email, $subject, $message, $from = '', $from_name = '', $plain_text = true, $attachments = array(), $reply_to = '' ) {
151 151
         _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' );
152 152
 
153
-        return self::send_email(compact(
153
+        return self::send_email( compact(
154 154
             'to_email', 'subject', 'message',
155 155
             'from', 'from_name', 'plain_text',
156 156
             'attachments', 'reply_to'
157
-        ));
157
+        ) );
158 158
     }
159 159
 
160 160
 	/**
@@ -187,28 +187,28 @@  discard block
 block discarded – undo
187 187
     private static function format_email_fields( &$atts, $admin_email ) {
188 188
 
189 189
         // If from is empty or is set to admin_email, set it now
190
-        $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from'];
190
+        $atts['from'] = ( empty( $atts['from'] ) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from'];
191 191
 
192 192
         // Filter values in these fields
193 193
 		$filter_fields = array( 'to_email', 'bcc', 'cc', 'from', 'reply_to' );
194 194
 
195 195
         foreach ( $filter_fields as $f ) {
196 196
             // If empty, just skip it
197
-			if ( empty( $atts[ $f ] ) ) {
197
+			if ( empty( $atts[$f] ) ) {
198 198
                 continue;
199 199
             }
200 200
 
201 201
             // to_email, cc, and bcc can be an array
202
-			if ( is_array( $atts[ $f ] ) ) {
203
-				foreach ( $atts[ $f ] as $key => $val ) {
202
+			if ( is_array( $atts[$f] ) ) {
203
+				foreach ( $atts[$f] as $key => $val ) {
204 204
                     self::format_single_field( $atts, $f, $val, $key );
205 205
                     unset( $key, $val );
206 206
                 }
207
-                unset($f);
207
+                unset( $f );
208 208
                 continue;
209 209
             }
210 210
 
211
-			self::format_single_field( $atts, $f, $atts[ $f ] );
211
+			self::format_single_field( $atts, $f, $atts[$f] );
212 212
         }
213 213
 
214 214
         // If reply-to isn't set, make it match the from settings
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
             $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] );
217 217
         }
218 218
 
219
-        if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) {
219
+        if ( ! is_array( $atts['to_email'] ) && '[admin_email]' == $atts['to_email'] ) {
220 220
             $atts['to_email'] = $admin_email;
221 221
         }
222 222
     }
@@ -239,20 +239,20 @@  discard block
 block discarded – undo
239 239
     * @param int $key if in array, this will be set
240 240
     */
241 241
     private static function format_single_field( &$atts, $f, $val, $key = false ) {
242
-        $val = trim($val);
242
+        $val = trim( $val );
243 243
 
244 244
         // If just a plain email is used
245
-        if ( is_email($val) ) {
245
+        if ( is_email( $val ) ) {
246 246
             // add sender's name if not included in $from
247 247
             if ( $f == 'from' ) {
248
-				$part_2 = $atts[ $f ];
249
-                $part_1  = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
248
+				$part_2 = $atts[$f];
249
+                $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
250 250
             } else {
251 251
                 return;
252 252
             }
253 253
         } else {
254
-            $parts = explode(' ', $val);
255
-            $part_2 = end($parts);
254
+            $parts = explode( ' ', $val );
255
+            $part_2 = end( $parts );
256 256
 
257 257
             // If inputted correcly, $part_2 should be an email
258 258
             if ( is_email( $part_2 ) ) {
@@ -260,14 +260,14 @@  discard block
 block discarded – undo
260 260
             } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) {
261 261
 				// In case someone just puts a name in the From or Reply To field
262 262
 				$part_1 = $val;
263
-                $part_2 = get_option('admin_email');
263
+                $part_2 = get_option( 'admin_email' );
264 264
             } else {
265 265
 				// In case someone just puts a name in any other email field
266 266
                 if ( false !== $key ) {
267
-					unset( $atts[ $f ][ $key ] );
267
+					unset( $atts[$f][$key] );
268 268
                     return;
269 269
                 }
270
-				$atts[ $f ] = '';
270
+				$atts[$f] = '';
271 271
                 return;
272 272
             }
273 273
         }
@@ -288,14 +288,14 @@  discard block
 block discarded – undo
288 288
 
289 289
         // If value is an array
290 290
         if ( false !== $key ) {
291
-			$atts[ $f ][ $key ] = $final_val;
291
+			$atts[$f][$key] = $final_val;
292 292
             return;
293 293
         }
294
-		$atts[ $f ] = $final_val;
294
+		$atts[$f] = $final_val;
295 295
     }
296 296
 
297 297
 	public static function send_email( $atts ) {
298
-        $admin_email = get_option('admin_email');
298
+        $admin_email = get_option( 'admin_email' );
299 299
         $defaults = array(
300 300
             'to_email'      => $admin_email,
301 301
             'subject'       => '',
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
             'reply_to'      => $admin_email,
309 309
             'attachments'   => array(),
310 310
         );
311
-        $atts = wp_parse_args($atts, $defaults);
311
+        $atts = wp_parse_args( $atts, $defaults );
312 312
 
313 313
         // Put To, BCC, CC, Reply To, and From fields in the correct format
314 314
         self::format_email_fields( $atts, $admin_email );
@@ -321,14 +321,14 @@  discard block
 block discarded – undo
321 321
 		$array_fields = array( 'CC' => $atts['cc'], 'BCC' => $atts['bcc'] );
322 322
 		$cc = array( 'CC' => array(), 'BCC' => array() );
323 323
         foreach ( $array_fields as $key => $a_field ) {
324
-            if ( empty($a_field) ) {
324
+            if ( empty( $a_field ) ) {
325 325
                 continue;
326 326
             }
327 327
 
328 328
 			foreach ( (array) $a_field as $email ) {
329
-				$cc[ $key ][] = $email;
329
+				$cc[$key][] = $email;
330 330
             }
331
-            unset($key, $a_field);
331
+            unset( $key, $a_field );
332 332
         }
333 333
 		$cc = array_filter( $cc ); // remove cc and bcc if they are empty
334 334
 
@@ -337,52 +337,52 @@  discard block
 block discarded – undo
337 337
 		}
338 338
 
339 339
         $content_type   = $atts['plain_text'] ? 'text/plain' : 'text/html';
340
-        $charset        = get_option('blog_charset');
340
+        $charset        = get_option( 'blog_charset' );
341 341
 
342 342
 		$header[]       = 'Reply-To: ' . $atts['reply_to'];
343 343
 		$header[]       = 'Content-Type: ' . $content_type . '; charset="' . esc_attr( $charset ) . '"';
344
-        $atts['subject'] = wp_specialchars_decode(strip_tags(stripslashes($atts['subject'])), ENT_QUOTES );
344
+        $atts['subject'] = wp_specialchars_decode( strip_tags( stripslashes( $atts['subject'] ) ), ENT_QUOTES );
345 345
 
346
-        $message        = do_shortcode($atts['message']);
346
+        $message = do_shortcode( $atts['message'] );
347 347
 
348 348
         if ( $atts['plain_text'] ) {
349 349
             //$message    = wordwrap($message, 70, "\r\n"); //in case any lines are longer than 70 chars
350
-            $message    = wp_specialchars_decode(strip_tags($message), ENT_QUOTES );
350
+            $message = wp_specialchars_decode( strip_tags( $message ), ENT_QUOTES );
351 351
         } else {
352 352
 			// remove line breaks in HTML emails to prevent conflicts with Mandrill
353 353
         	add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' );
354 354
         }
355 355
 		$message = apply_filters( 'frm_email_message', $message, $atts );
356 356
 
357
-        $header         = apply_filters('frm_email_header', $header, array(
357
+        $header = apply_filters( 'frm_email_header', $header, array(
358 358
 			'to_email' => $atts['to_email'], 'subject' => $atts['subject'],
359 359
 		) );
360 360
 
361
-        if ( apply_filters('frm_encode_subject', 1, $atts['subject'] ) ) {
361
+        if ( apply_filters( 'frm_encode_subject', 1, $atts['subject'] ) ) {
362 362
 			$atts['subject'] = '=?' . $charset . '?B?' . base64_encode( $atts['subject'] ) . '?=';
363 363
         }
364 364
 
365
-        remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' );
366
-        remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter');
365
+        remove_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' );
366
+        remove_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
367 367
 
368
-        $sent = wp_mail($recipient, $atts['subject'], $message, $header, $atts['attachments']);
368
+        $sent = wp_mail( $recipient, $atts['subject'], $message, $header, $atts['attachments'] );
369 369
         if ( ! $sent ) {
370 370
 			$header = 'From: ' . $atts['from'] . "\r\n";
371
-            $recipient = implode(',', (array) $recipient);
372
-            $sent = mail($recipient, $atts['subject'], $message, $header);
371
+            $recipient = implode( ',', (array) $recipient );
372
+            $sent = mail( $recipient, $atts['subject'], $message, $header );
373 373
         }
374 374
 
375 375
 		// remove the filter now so other emails can still use it
376 376
 		remove_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' );
377 377
 
378
-        do_action('frm_notification', $recipient, $atts['subject'], $message);
378
+        do_action( 'frm_notification', $recipient, $atts['subject'], $message );
379 379
 
380 380
         if ( $sent ) {
381 381
 			$sent_to = array_merge( (array) $atts['to_email'], (array) $atts['cc'], (array) $atts['bcc'] );
382 382
             $sent_to = array_filter( $sent_to );
383
-            if ( apply_filters('frm_echo_emails', false) ) {
384
-                $temp = str_replace('<', '&lt;', $sent_to);
385
-				echo ' ' . FrmAppHelper::kses( implode(', ', (array) $temp ) );
383
+            if ( apply_filters( 'frm_echo_emails', false ) ) {
384
+                $temp = str_replace( '<', '&lt;', $sent_to );
385
+				echo ' ' . FrmAppHelper::kses( implode( ', ', (array) $temp ) );
386 386
             }
387 387
             return $sent_to;
388 388
         }
Please login to merge, or discard this patch.
classes/controllers/FrmXMLController.php 2 patches
Indentation   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -2,109 +2,109 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmXMLController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		add_submenu_page( 'formidable', 'Formidable | ' . __( 'Import/Export', 'formidable' ), __( 'Import/Export', 'formidable' ), 'frm_edit_forms', 'formidable-import', 'FrmXMLController::route' );
7
-    }
7
+	}
8 8
 
9
-    public static function add_default_templates() {
9
+	public static function add_default_templates() {
10 10
 		if ( ! function_exists( 'libxml_disable_entity_loader' ) ) {
11
-    		// XML import is not enabled on your server
12
-    		return;
13
-    	}
11
+			// XML import is not enabled on your server
12
+			return;
13
+		}
14 14
 
15
-        $set_err = libxml_use_internal_errors(true);
16
-        $loader = libxml_disable_entity_loader( true );
15
+		$set_err = libxml_use_internal_errors(true);
16
+		$loader = libxml_disable_entity_loader( true );
17 17
 
18 18
 		$files = apply_filters( 'frm_default_templates_files', array( FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml' ) );
19 19
 
20
-        foreach ( (array) $files as $file ) {
21
-            FrmXMLHelper::import_xml($file);
22
-            unset($file);
23
-        }
24
-        /*
20
+		foreach ( (array) $files as $file ) {
21
+			FrmXMLHelper::import_xml($file);
22
+			unset($file);
23
+		}
24
+		/*
25 25
         if(is_wp_error($result))
26 26
             $errors[] = $result->get_error_message();
27 27
         else if($result)
28 28
             $message = $result;
29 29
         */
30 30
 
31
-        unset( $files );
31
+		unset( $files );
32 32
 
33
-        libxml_use_internal_errors( $set_err );
34
-    	libxml_disable_entity_loader( $loader );
35
-    }
33
+		libxml_use_internal_errors( $set_err );
34
+		libxml_disable_entity_loader( $loader );
35
+	}
36 36
 
37
-    public static function route() {
38
-        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
37
+	public static function route() {
38
+		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
39 39
 		$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
40 40
 		if ( $action == 'import_xml' ) {
41
-            return self::import_xml();
41
+			return self::import_xml();
42 42
 		} else if ( $action == 'export_xml' ) {
43
-            return self::export_xml();
44
-        } else {
45
-            if ( apply_filters( 'frm_xml_route', true, $action ) ) {
46
-                return self::form();
47
-            }
48
-        }
49
-    }
50
-
51
-    public static function form( $errors = array(), $message = '' ) {
43
+			return self::export_xml();
44
+		} else {
45
+			if ( apply_filters( 'frm_xml_route', true, $action ) ) {
46
+				return self::form();
47
+			}
48
+		}
49
+	}
50
+
51
+	public static function form( $errors = array(), $message = '' ) {
52 52
 		$where = array(
53 53
 			'status' => array( null, '', 'published' ),
54 54
 		);
55 55
 		$forms = FrmForm::getAll( $where, 'name' );
56 56
 
57
-        $export_types = apply_filters( 'frm_xml_export_types',
58
-            array( 'forms' => __( 'Forms', 'formidable' ), 'items' => __( 'Entries', 'formidable' ) )
59
-        );
57
+		$export_types = apply_filters( 'frm_xml_export_types',
58
+			array( 'forms' => __( 'Forms', 'formidable' ), 'items' => __( 'Entries', 'formidable' ) )
59
+		);
60 60
 
61
-        $export_format = apply_filters( 'frm_export_formats', array(
62
-            'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ),
61
+		$export_format = apply_filters( 'frm_export_formats', array(
62
+			'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ),
63 63
 			'csv' => array( 'name' => 'CSV', 'support' => 'items', 'count' => 'single' ),
64
-        ) );
64
+		) );
65 65
 
66 66
 		include( FrmAppHelper::plugin_path() . '/classes/views/xml/import_form.php' );
67
-    }
67
+	}
68 68
 
69
-    public static function import_xml() {
70
-        $errors = array();
71
-        $message = '';
69
+	public static function import_xml() {
70
+		$errors = array();
71
+		$message = '';
72 72
 
73
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce');
74
-        if ( $permission_error !== false ) {
75
-            $errors[] = $permission_error;
76
-            self::form($errors);
77
-            return;
78
-        }
73
+		$permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce');
74
+		if ( $permission_error !== false ) {
75
+			$errors[] = $permission_error;
76
+			self::form($errors);
77
+			return;
78
+		}
79 79
 
80
-        if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
81
-            $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' );
82
-            self::form($errors);
83
-            return;
84
-        }
80
+		if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
81
+			$errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' );
82
+			self::form($errors);
83
+			return;
84
+		}
85 85
 
86
-        $file = $_FILES['frm_import_file']['tmp_name'];
86
+		$file = $_FILES['frm_import_file']['tmp_name'];
87 87
 
88
-        if ( ! is_uploaded_file( $file ) ) {
89
-            unset($file);
90
-            $errors[] = __( 'The file does not exist, please try again.', 'formidable' );
91
-            self::form($errors);
92
-            return;
93
-        }
88
+		if ( ! is_uploaded_file( $file ) ) {
89
+			unset($file);
90
+			$errors[] = __( 'The file does not exist, please try again.', 'formidable' );
91
+			self::form($errors);
92
+			return;
93
+		}
94 94
 
95
-        //add_filter('upload_mimes', 'FrmXMLController::allow_mime');
95
+		//add_filter('upload_mimes', 'FrmXMLController::allow_mime');
96 96
 
97
-        $export_format = apply_filters('frm_export_formats', array(
97
+		$export_format = apply_filters('frm_export_formats', array(
98 98
 			'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ),
99 99
 		) );
100 100
 
101
-        $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION));
102
-        if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) {
103
-            // allow other file types to be imported
101
+		$file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION));
102
+		if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) {
103
+			// allow other file types to be imported
104 104
 			do_action( 'frm_before_import_' . $file_type );
105
-            return;
106
-        }
107
-        unset($file_type);
105
+			return;
106
+		}
107
+		unset($file_type);
108 108
 
109 109
 		if ( ! function_exists( 'libxml_disable_entity_loader' ) ) {
110 110
 			$errors[] = __( 'XML import is not enabled on your server.', 'formidable' );
@@ -123,145 +123,145 @@  discard block
 block discarded – undo
123 123
 		libxml_use_internal_errors( $set_err );
124 124
 		libxml_disable_entity_loader( $loader );
125 125
 
126
-        self::form($errors, $message);
127
-    }
126
+		self::form($errors, $message);
127
+	}
128 128
 
129
-    public static function export_xml() {
130
-        $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' );
131
-        if ( ! empty($error) ) {
132
-            wp_die( $error );
133
-        }
129
+	public static function export_xml() {
130
+		$error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' );
131
+		if ( ! empty($error) ) {
132
+			wp_die( $error );
133
+		}
134 134
 
135 135
 		$ids = FrmAppHelper::get_post_param( 'frm_export_forms', array() );
136 136
 		$type = FrmAppHelper::get_post_param( 'type', array() );
137 137
 		$format = FrmAppHelper::get_post_param( 'format', 'xml', 'sanitize_title' );
138 138
 
139
-        if ( ! headers_sent() && ! $type ) {
140
-            wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) );
141
-            die();
142
-        }
139
+		if ( ! headers_sent() && ! $type ) {
140
+			wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) );
141
+			die();
142
+		}
143 143
 
144
-        if ( $format == 'xml' ) {
145
-            self::generate_xml($type, compact('ids'));
144
+		if ( $format == 'xml' ) {
145
+			self::generate_xml($type, compact('ids'));
146 146
 		} if ( $format == 'csv' ) {
147 147
 			self::generate_csv( compact('ids') );
148
-        } else {
148
+		} else {
149 149
 			do_action( 'frm_export_format_' . $format, compact('ids') );
150
-        }
150
+		}
151 151
 
152
-        wp_die();
153
-    }
152
+		wp_die();
153
+	}
154 154
 
155 155
 	public static function generate_xml( $type, $args = array() ) {
156
-    	global $wpdb;
156
+		global $wpdb;
157 157
 
158
-	    self::prepare_types_array( $type );
158
+		self::prepare_types_array( $type );
159 159
 
160
-	    $tables = array(
160
+		$tables = array(
161 161
 			'items'     => $wpdb->prefix . 'frm_items',
162 162
 			'forms'     => $wpdb->prefix . 'frm_forms',
163
-	        'posts'     => $wpdb->posts,
164
-	        'styles'    => $wpdb->posts,
165
-	        'actions'   => $wpdb->posts,
166
-	    );
163
+			'posts'     => $wpdb->posts,
164
+			'styles'    => $wpdb->posts,
165
+			'actions'   => $wpdb->posts,
166
+		);
167 167
 
168 168
 		$defaults = array( 'ids' => false );
169
-	    $args = wp_parse_args( $args, $defaults );
169
+		$args = wp_parse_args( $args, $defaults );
170 170
 
171
-        $sitename = sanitize_key( get_bloginfo( 'name' ) );
171
+		$sitename = sanitize_key( get_bloginfo( 'name' ) );
172 172
 
173
-    	if ( ! empty( $sitename ) ) {
173
+		if ( ! empty( $sitename ) ) {
174 174
 			$sitename .= '.';
175 175
 		}
176
-    	$filename = $sitename . 'formidable.' . date( 'Y-m-d' ) . '.xml';
176
+		$filename = $sitename . 'formidable.' . date( 'Y-m-d' ) . '.xml';
177 177
 
178
-    	header( 'Content-Description: File Transfer' );
179
-    	header( 'Content-Disposition: attachment; filename=' . $filename );
180
-    	header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
178
+		header( 'Content-Description: File Transfer' );
179
+		header( 'Content-Disposition: attachment; filename=' . $filename );
180
+		header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
181 181
 
182
-        //make sure ids are numeric
183
-    	if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) {
184
-	        $args['ids'] = array_filter( $args['ids'], 'is_numeric' );
185
-	    }
182
+		//make sure ids are numeric
183
+		if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) {
184
+			$args['ids'] = array_filter( $args['ids'], 'is_numeric' );
185
+		}
186 186
 
187
-	    $records = array();
187
+		$records = array();
188 188
 
189 189
 		foreach ( $type as $tb_type ) {
190
-            $where = array();
190
+			$where = array();
191 191
 			$join = '';
192
-            $table = $tables[ $tb_type ];
192
+			$table = $tables[ $tb_type ];
193 193
 
194 194
 			$select = $table . '.id';
195
-            $query_vars = array();
195
+			$query_vars = array();
196 196
 
197
-            switch ( $tb_type ) {
198
-                case 'forms':
199
-                    //add forms
200
-                    if ( $args['ids'] ) {
197
+			switch ( $tb_type ) {
198
+				case 'forms':
199
+					//add forms
200
+					if ( $args['ids'] ) {
201 201
 						$where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table . '.parent_form_id' => $args['ids'] );
202
-                	} else {
202
+					} else {
203 203
 						$where[ $table . '.status !' ] = 'draft';
204
-                	}
205
-                break;
206
-                case 'actions':
204
+					}
205
+				break;
206
+				case 'actions':
207 207
 					$select = $table . '.ID';
208 208
 					$where['post_type'] = FrmFormActionsController::$action_post_type;
209
-                    if ( ! empty($args['ids']) ) {
209
+					if ( ! empty($args['ids']) ) {
210 210
 						$where['menu_order'] = $args['ids'];
211
-                    }
212
-                break;
213
-                case 'items':
214
-                    //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)";
215
-                    if ( $args['ids'] ) {
211
+					}
212
+				break;
213
+				case 'items':
214
+					//$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)";
215
+					if ( $args['ids'] ) {
216 216
 						$where[ $table . '.form_id' ] = $args['ids'];
217
-                    }
218
-                break;
219
-                case 'styles':
220
-                    // Loop through all exported forms and get their selected style IDs
217
+					}
218
+				break;
219
+				case 'styles':
220
+					// Loop through all exported forms and get their selected style IDs
221 221
 					$frm_style = new FrmStyle();
222 222
 					$default_style = $frm_style->get_default_style();
223
-                    $form_ids = $args['ids'];
224
-                    $style_ids = array();
225
-                    foreach ( $form_ids as $form_id ) {
226
-                        $form_data = FrmForm::getOne( $form_id );
227
-                        // For forms that have not been updated while running 2.0, check if custom_style is set
228
-                        if ( isset( $form_data->options['custom_style'] ) ) {
223
+					$form_ids = $args['ids'];
224
+					$style_ids = array();
225
+					foreach ( $form_ids as $form_id ) {
226
+						$form_data = FrmForm::getOne( $form_id );
227
+						// For forms that have not been updated while running 2.0, check if custom_style is set
228
+						if ( isset( $form_data->options['custom_style'] ) ) {
229 229
 							if ( $form_data->options['custom_style'] == 1 ) {
230 230
 								$style_ids[] = $default_style->ID;
231 231
 							} else {
232 232
 								$style_ids[] = $form_data->options['custom_style'];
233 233
 							}
234
-                        }
235
-                        unset( $form_id, $form_data );
236
-                    }
234
+						}
235
+						unset( $form_id, $form_data );
236
+					}
237 237
 					$select = $table . '.ID';
238
-                    $where['post_type'] = 'frm_styles';
239
-
240
-                    // Only export selected styles
241
-                    if ( ! empty( $style_ids ) ) {
242
-                        $where['ID'] = $style_ids;
243
-                    }
244
-                break;
245
-                default:
238
+					$where['post_type'] = 'frm_styles';
239
+
240
+					// Only export selected styles
241
+					if ( ! empty( $style_ids ) ) {
242
+						$where['ID'] = $style_ids;
243
+					}
244
+				break;
245
+				default:
246 246
 					$select = $table . '.ID';
247
-                    $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)';
248
-                    $where['pm.meta_key'] = 'frm_form_id';
249
-
250
-                    if ( empty($args['ids']) ) {
251
-                        $where['pm.meta_value >'] = 1;
252
-                    } else {
253
-                        $where['pm.meta_value'] = $args['ids'];
254
-                    }
255
-                break;
256
-            }
247
+					$join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)';
248
+					$where['pm.meta_key'] = 'frm_form_id';
249
+
250
+					if ( empty($args['ids']) ) {
251
+						$where['pm.meta_value >'] = 1;
252
+					} else {
253
+						$where['pm.meta_value'] = $args['ids'];
254
+					}
255
+				break;
256
+			}
257 257
 
258 258
 			$records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select );
259
-            unset($tb_type);
260
-        }
259
+			unset($tb_type);
260
+		}
261 261
 
262 262
 		echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo('charset') ) . "\" ?>\n";
263 263
 		include( FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php' );
264
-    }
264
+	}
265 265
 
266 266
 	private static function prepare_types_array( &$type ) {
267 267
 		$type = (array) $type;
@@ -342,14 +342,14 @@  discard block
 block discarded – undo
342 342
 	}
343 343
 
344 344
 	/**
345
-	* Get the fields that should be included in the CSV export
346
-	*
347
-	* @since 2.0.19
348
-	*
349
-	* @param int $form_id
350
-	* @param object $form
351
-	* @return array $csv_fields
352
-	*/
345
+	 * Get the fields that should be included in the CSV export
346
+	 *
347
+	 * @since 2.0.19
348
+	 *
349
+	 * @param int $form_id
350
+	 * @param object $form
351
+	 * @return array $csv_fields
352
+	 */
353 353
 	private static function get_fields_for_csv_export( $form_id, $form ) {
354 354
 		// Phase frm_csv_field_ids out by 2.01.05
355 355
 		$csv_field_ids = apply_filters( 'frm_csv_field_ids', '', $form_id, array( 'form' => $form ) );
@@ -379,16 +379,16 @@  discard block
 block discarded – undo
379 379
 	}
380 380
 
381 381
 	public static function allow_mime( $mimes ) {
382
-        if ( ! isset( $mimes['csv'] ) ) {
383
-            // allow csv files
384
-            $mimes['csv'] = 'text/csv';
385
-        }
386
-
387
-        if ( ! isset( $mimes['xml'] ) ) {
388
-            // allow xml
389
-            $mimes['xml'] = 'text/xml';
390
-        }
391
-
392
-        return $mimes;
393
-    }
382
+		if ( ! isset( $mimes['csv'] ) ) {
383
+			// allow csv files
384
+			$mimes['csv'] = 'text/csv';
385
+		}
386
+
387
+		if ( ! isset( $mimes['xml'] ) ) {
388
+			// allow xml
389
+			$mimes['xml'] = 'text/xml';
390
+		}
391
+
392
+		return $mimes;
393
+	}
394 394
 }
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
     		return;
13 13
     	}
14 14
 
15
-        $set_err = libxml_use_internal_errors(true);
15
+        $set_err = libxml_use_internal_errors( true );
16 16
         $loader = libxml_disable_entity_loader( true );
17 17
 
18 18
 		$files = apply_filters( 'frm_default_templates_files', array( FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml' ) );
19 19
 
20 20
         foreach ( (array) $files as $file ) {
21
-            FrmXMLHelper::import_xml($file);
22
-            unset($file);
21
+            FrmXMLHelper::import_xml( $file );
22
+            unset( $file );
23 23
         }
24 24
         /*
25 25
         if(is_wp_error($result))
@@ -70,41 +70,41 @@  discard block
 block discarded – undo
70 70
         $errors = array();
71 71
         $message = '';
72 72
 
73
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce');
73
+        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'import-xml', 'import-xml-nonce' );
74 74
         if ( $permission_error !== false ) {
75 75
             $errors[] = $permission_error;
76
-            self::form($errors);
76
+            self::form( $errors );
77 77
             return;
78 78
         }
79 79
 
80
-        if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
80
+        if ( ! isset( $_FILES ) || ! isset( $_FILES['frm_import_file'] ) || empty( $_FILES['frm_import_file']['name'] ) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
81 81
             $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' );
82
-            self::form($errors);
82
+            self::form( $errors );
83 83
             return;
84 84
         }
85 85
 
86 86
         $file = $_FILES['frm_import_file']['tmp_name'];
87 87
 
88 88
         if ( ! is_uploaded_file( $file ) ) {
89
-            unset($file);
89
+            unset( $file );
90 90
             $errors[] = __( 'The file does not exist, please try again.', 'formidable' );
91
-            self::form($errors);
91
+            self::form( $errors );
92 92
             return;
93 93
         }
94 94
 
95 95
         //add_filter('upload_mimes', 'FrmXMLController::allow_mime');
96 96
 
97
-        $export_format = apply_filters('frm_export_formats', array(
97
+        $export_format = apply_filters( 'frm_export_formats', array(
98 98
 			'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ),
99 99
 		) );
100 100
 
101
-        $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION));
102
-        if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) {
101
+        $file_type = strtolower( pathinfo( $_FILES['frm_import_file']['name'], PATHINFO_EXTENSION ) );
102
+        if ( $file_type != 'xml' && isset( $export_format[$file_type] ) ) {
103 103
             // allow other file types to be imported
104 104
 			do_action( 'frm_before_import_' . $file_type );
105 105
             return;
106 106
         }
107
-        unset($file_type);
107
+        unset( $file_type );
108 108
 
109 109
 		if ( ! function_exists( 'libxml_disable_entity_loader' ) ) {
110 110
 			$errors[] = __( 'XML import is not enabled on your server.', 'formidable' );
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
 		libxml_use_internal_errors( $set_err );
124 124
 		libxml_disable_entity_loader( $loader );
125 125
 
126
-        self::form($errors, $message);
126
+        self::form( $errors, $message );
127 127
     }
128 128
 
129 129
     public static function export_xml() {
130 130
         $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' );
131
-        if ( ! empty($error) ) {
131
+        if ( ! empty( $error ) ) {
132 132
             wp_die( $error );
133 133
         }
134 134
 
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
         }
143 143
 
144 144
         if ( $format == 'xml' ) {
145
-            self::generate_xml($type, compact('ids'));
145
+            self::generate_xml( $type, compact( 'ids' ) );
146 146
 		} if ( $format == 'csv' ) {
147
-			self::generate_csv( compact('ids') );
147
+			self::generate_csv( compact( 'ids' ) );
148 148
         } else {
149
-			do_action( 'frm_export_format_' . $format, compact('ids') );
149
+			do_action( 'frm_export_format_' . $format, compact( 'ids' ) );
150 150
         }
151 151
 
152 152
         wp_die();
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		foreach ( $type as $tb_type ) {
190 190
             $where = array();
191 191
 			$join = '';
192
-            $table = $tables[ $tb_type ];
192
+            $table = $tables[$tb_type];
193 193
 
194 194
 			$select = $table . '.id';
195 195
             $query_vars = array();
@@ -200,20 +200,20 @@  discard block
 block discarded – undo
200 200
                     if ( $args['ids'] ) {
201 201
 						$where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table . '.parent_form_id' => $args['ids'] );
202 202
                 	} else {
203
-						$where[ $table . '.status !' ] = 'draft';
203
+						$where[$table . '.status !'] = 'draft';
204 204
                 	}
205 205
                 break;
206 206
                 case 'actions':
207 207
 					$select = $table . '.ID';
208 208
 					$where['post_type'] = FrmFormActionsController::$action_post_type;
209
-                    if ( ! empty($args['ids']) ) {
209
+                    if ( ! empty( $args['ids'] ) ) {
210 210
 						$where['menu_order'] = $args['ids'];
211 211
                     }
212 212
                 break;
213 213
                 case 'items':
214 214
                     //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)";
215 215
                     if ( $args['ids'] ) {
216
-						$where[ $table . '.form_id' ] = $args['ids'];
216
+						$where[$table . '.form_id'] = $args['ids'];
217 217
                     }
218 218
                 break;
219 219
                 case 'styles':
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
                     $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)';
248 248
                     $where['pm.meta_key'] = 'frm_form_id';
249 249
 
250
-                    if ( empty($args['ids']) ) {
250
+                    if ( empty( $args['ids'] ) ) {
251 251
                         $where['pm.meta_value >'] = 1;
252 252
                     } else {
253 253
                         $where['pm.meta_value'] = $args['ids'];
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
                 break;
256 256
             }
257 257
 
258
-			$records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select );
259
-            unset($tb_type);
258
+			$records[$tb_type] = FrmDb::get_col( $table . $join, $where, $select );
259
+            unset( $tb_type );
260 260
         }
261 261
 
262
-		echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo('charset') ) . "\" ?>\n";
262
+		echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo( 'charset' ) ) . "\" ?>\n";
263 263
 		include( FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php' );
264 264
     }
265 265
 
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
 			$fid = FrmAppHelper::get_param( 'fid', '', 'get', 'sanitize_text_field' );
298 298
 		}
299 299
 
300
-		set_time_limit(0); //Remove time limit to execute this function
301
-		$mem_limit = str_replace('M', '', ini_get('memory_limit'));
300
+		set_time_limit( 0 ); //Remove time limit to execute this function
301
+		$mem_limit = str_replace( 'M', '', ini_get( 'memory_limit' ) );
302 302
 		if ( (int) $mem_limit < 256 ) {
303
-			ini_set('memory_limit', '256M');
303
+			ini_set( 'memory_limit', '256M' );
304 304
 		}
305 305
 
306 306
 		global $wpdb;
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 			$no_export_fields = FrmField::no_save_fields();
371 371
 			foreach ( $csv_fields as $k => $f ) {
372 372
 				if ( in_array( $f->type, $no_export_fields ) ) {
373
-					unset( $csv_fields[ $k ] );
373
+					unset( $csv_fields[$k] );
374 374
 				}
375 375
 			}
376 376
 		}
Please login to merge, or discard this patch.
classes/helpers/FrmFieldsHelper.php 2 patches
Indentation   +714 added lines, -714 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 ( in_array( $type, array( 'data', 'lookup' ) ) ) {
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 ( in_array( $type, array( 'data', 'lookup' ) ) ) {
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();
@@ -183,21 +183,21 @@  discard block
 block discarded – undo
183 183
 		return $msg;
184 184
 	}
185 185
 
186
-    public static function get_form_fields( $form_id, $error = false ) {
187
-        $fields = FrmField::get_all_for_form($form_id);
188
-        $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error);
189
-        return $fields;
190
-    }
186
+	public static function get_form_fields( $form_id, $error = false ) {
187
+		$fields = FrmField::get_all_for_form($form_id);
188
+		$fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error);
189
+		return $fields;
190
+	}
191 191
 
192 192
 	public static function get_default_html( $type = 'text' ) {
193 193
 		if ( apply_filters( 'frm_normal_field_type_html', true, $type ) ) {
194 194
 			$input = ( in_array( $type, array( 'radio', 'checkbox', 'data' ) ) ) ? '<div class="frm_opt_container">[input]</div>' : '[input]';
195
-            $for = '';
195
+			$for = '';
196 196
 			if ( ! in_array( $type, array( 'radio', 'checkbox', 'data', 'scale' ) ) ) {
197
-                $for = 'for="field_[key]"';
198
-            }
197
+				$for = 'for="field_[key]"';
198
+			}
199 199
 
200
-            $default_html = <<<DEFAULT_HTML
200
+			$default_html = <<<DEFAULT_HTML
201 201
 <div id="frm_field_[id]_container" class="frm_form_field form-field [required_class][error_class]">
202 202
     <label $for class="frm_primary_label">[field_name]
203 203
         <span class="frm_required">[required_label]</span>
@@ -207,138 +207,138 @@  discard block
 block discarded – undo
207 207
     [if error]<div class="frm_error">[error]</div>[/if error]
208 208
 </div>
209 209
 DEFAULT_HTML;
210
-        } else {
210
+		} else {
211 211
 			$default_html = apply_filters('frm_other_custom_html', '', $type);
212
-        }
212
+		}
213 213
 
214
-        return apply_filters('frm_custom_html', $default_html, $type);
215
-    }
214
+		return apply_filters('frm_custom_html', $default_html, $type);
215
+	}
216 216
 
217 217
 	public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) {
218
-        $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
218
+		$html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
219 219
 
220
-        $defaults = array(
220
+		$defaults = array(
221 221
 			'field_name'    => 'item_meta[' . $field['id'] . ']',
222 222
 			'field_id'      => $field['id'],
223
-            'field_plus_id' => '',
224
-            'section_id'    => '',
225
-        );
226
-        $args = wp_parse_args($args, $defaults);
227
-        $field_name = $args['field_name'];
228
-        $field_id = $args['field_id'];
229
-        $html_id = self::get_html_id($field, $args['field_plus_id']);
223
+			'field_plus_id' => '',
224
+			'section_id'    => '',
225
+		);
226
+		$args = wp_parse_args($args, $defaults);
227
+		$field_name = $args['field_name'];
228
+		$field_id = $args['field_id'];
229
+		$html_id = self::get_html_id($field, $args['field_plus_id']);
230 230
 
231
-        if ( FrmField::is_multiple_select($field) ) {
232
-            $field_name .= '[]';
233
-        }
231
+		if ( FrmField::is_multiple_select($field) ) {
232
+			$field_name .= '[]';
233
+		}
234 234
 
235
-        //replace [id]
236
-        $html = str_replace('[id]', $field_id, $html);
235
+		//replace [id]
236
+		$html = str_replace('[id]', $field_id, $html);
237 237
 
238
-        // Remove the for attribute for captcha
239
-        if ( $field['type'] == 'captcha' ) {
240
-            $html = str_replace(' for="field_[key]"', '', $html);
241
-        }
238
+		// Remove the for attribute for captcha
239
+		if ( $field['type'] == 'captcha' ) {
240
+			$html = str_replace(' for="field_[key]"', '', $html);
241
+		}
242 242
 
243
-        // set the label for
244
-        $html = str_replace('field_[key]', $html_id, $html);
243
+		// set the label for
244
+		$html = str_replace('field_[key]', $html_id, $html);
245 245
 
246
-        //replace [key]
247
-        $html = str_replace('[key]', $field['field_key'], $html);
246
+		//replace [key]
247
+		$html = str_replace('[key]', $field['field_key'], $html);
248 248
 
249
-        //replace [description] and [required_label] and [error]
249
+		//replace [description] and [required_label] and [error]
250 250
 		$required = FrmField::is_required( $field ) ? $field['required_indicator'] : '';
251
-        if ( ! is_array( $errors ) ) {
252
-            $errors = array();
253
-        }
251
+		if ( ! is_array( $errors ) ) {
252
+			$errors = array();
253
+		}
254 254
 		$error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false;
255 255
 
256
-        //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
257
-        if ( $field['type'] == 'divider' ) {
258
-            if ( FrmField::is_option_true( $field, 'description' ) ) {
259
-                $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
260
-            } else {
261
-                $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
262
-            }
263
-        }
256
+		//If field type is section heading, add class so a bottom margin can be added to either the h3 or description
257
+		if ( $field['type'] == 'divider' ) {
258
+			if ( FrmField::is_option_true( $field, 'description' ) ) {
259
+				$html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
260
+			} else {
261
+				$html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
262
+			}
263
+		}
264 264
 
265 265
 		foreach ( array( 'description' => $field['description'], 'required_label' => $required, 'error' => $error ) as $code => $value ) {
266
-            self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html );
267
-        }
266
+			self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html );
267
+		}
268 268
 
269
-        //replace [required_class]
269
+		//replace [required_class]
270 270
 		$required_class = FrmField::is_required( $field ) ? ' frm_required_field' : '';
271
-        $html = str_replace('[required_class]', $required_class, $html);
271
+		$html = str_replace('[required_class]', $required_class, $html);
272 272
 
273
-        //replace [label_position]
274
-        $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
275
-        $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
273
+		//replace [label_position]
274
+		$field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
275
+		$field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
276 276
 		$html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html );
277 277
 
278
-        //replace [field_name]
279
-        $html = str_replace('[field_name]', $field['name'], $html);
278
+		//replace [field_name]
279
+		$html = str_replace('[field_name]', $field['name'], $html);
280 280
 
281 281
 		self::add_field_div_classes( $field_id, $field, $errors, $html );
282 282
 
283
-        //replace [entry_key]
284
-        $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
285
-        $html = str_replace('[entry_key]', $entry_key, $html);
283
+		//replace [entry_key]
284
+		$entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
285
+		$html = str_replace('[entry_key]', $entry_key, $html);
286 286
 
287
-        //replace [input]
288
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
289
-        global $frm_vars;
290
-        $frm_settings = FrmAppHelper::get_settings();
287
+		//replace [input]
288
+		preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
289
+		global $frm_vars;
290
+		$frm_settings = FrmAppHelper::get_settings();
291 291
 
292
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
293
-            $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
292
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
293
+			$atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
294 294
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
295 295
 
296
-            $replace_with = '';
296
+			$replace_with = '';
297 297
 
298
-            if ( $tag == 'input' ) {
299
-                if ( isset($atts['opt']) ) {
300
-                    $atts['opt']--;
301
-                }
298
+			if ( $tag == 'input' ) {
299
+				if ( isset($atts['opt']) ) {
300
+					$atts['opt']--;
301
+				}
302 302
 
303
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
304
-                if ( isset($atts['class']) ) {
305
-                    unset($atts['class']);
306
-                }
303
+				$field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
304
+				if ( isset($atts['class']) ) {
305
+					unset($atts['class']);
306
+				}
307 307
 
308
-                $field['shortcodes'] = $atts;
309
-                ob_start();
308
+				$field['shortcodes'] = $atts;
309
+				ob_start();
310 310
 				include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' );
311
-                $replace_with = ob_get_contents();
312
-                ob_end_clean();
313
-            } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
314
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
315
-            }
311
+				$replace_with = ob_get_contents();
312
+				ob_end_clean();
313
+			} else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
314
+				$replace_with = FrmProEntriesController::entry_delete_link($atts);
315
+			}
316 316
 
317
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
318
-        }
317
+			$html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
318
+		}
319 319
 
320 320
 		if ( $form ) {
321
-            $form = (array) $form;
321
+			$form = (array) $form;
322 322
 
323
-            //replace [form_key]
324
-            $html = str_replace('[form_key]', $form['form_key'], $html);
323
+			//replace [form_key]
324
+			$html = str_replace('[form_key]', $form['form_key'], $html);
325 325
 
326
-            //replace [form_name]
327
-            $html = str_replace('[form_name]', $form['name'], $html);
328
-        }
329
-        $html .= "\n";
326
+			//replace [form_name]
327
+			$html = str_replace('[form_name]', $form['name'], $html);
328
+		}
329
+		$html .= "\n";
330 330
 
331
-        //Return html if conf_field to prevent loop
332
-        if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
333
-            return $html;
334
-        }
331
+		//Return html if conf_field to prevent loop
332
+		if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
333
+			return $html;
334
+		}
335 335
 
336
-        //If field is in repeating section
337
-        if ( $args['section_id'] ) {
338
-            $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'] ));
339
-        } else {
340
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
341
-        }
336
+		//If field is in repeating section
337
+		if ( $args['section_id'] ) {
338
+			$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'] ));
339
+		} else {
340
+			$html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
341
+		}
342 342
 
343 343
 		self::remove_collapse_shortcode( $html );
344 344
 
@@ -346,8 +346,8 @@  discard block
 block discarded – undo
346 346
 			$html = do_shortcode( $html );
347 347
 		}
348 348
 
349
-        return $html;
350
-    }
349
+		return $html;
350
+	}
351 351
 
352 352
 	/**
353 353
 	 * Add classes to a field div
@@ -401,46 +401,46 @@  discard block
 block discarded – undo
401 401
 		return $classes;
402 402
 	}
403 403
 
404
-    public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
405
-        if ( $no_vars ) {
404
+	public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
405
+		if ( $no_vars ) {
406 406
 			$html = str_replace( '[if ' . $code . ']', '', $html );
407 407
 			$html = str_replace( '[/if ' . $code . ']', '', $html );
408
-        } else {
408
+		} else {
409 409
 			$html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html );
410
-        }
410
+		}
411 411
 
412 412
 		$html = str_replace( '[' . $code . ']', $replace_with, $html );
413
-    }
413
+	}
414 414
 
415 415
 	public static function get_shortcode_tag( $shortcodes, $short_key, $args ) {
416 416
 		$args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) );
417
-        if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
418
-            $args['conditional_check'] = true;
419
-        }
420
-
421
-        $prefix = '';
422
-        if ( $args['conditional_check'] ) {
423
-            if ( $args['conditional'] ) {
424
-                $prefix = 'if ';
425
-            } else if ( $args['foreach'] ) {
426
-                $prefix = 'foreach ';
427
-            }
428
-        }
429
-
430
-        $with_tags = $args['conditional_check'] ? 3 : 2;
431
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
432
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
433
-            $tag = str_replace(']', '', $tag);
434
-            $tags = explode(' ', $tag);
435
-            if ( is_array($tags) ) {
436
-                $tag = $tags[0];
437
-            }
438
-        } else {
439
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
440
-        }
441
-
442
-        return $tag;
443
-    }
417
+		if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
418
+			$args['conditional_check'] = true;
419
+		}
420
+
421
+		$prefix = '';
422
+		if ( $args['conditional_check'] ) {
423
+			if ( $args['conditional'] ) {
424
+				$prefix = 'if ';
425
+			} else if ( $args['foreach'] ) {
426
+				$prefix = 'foreach ';
427
+			}
428
+		}
429
+
430
+		$with_tags = $args['conditional_check'] ? 3 : 2;
431
+		if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
432
+			$tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
433
+			$tag = str_replace(']', '', $tag);
434
+			$tags = explode(' ', $tag);
435
+			if ( is_array($tags) ) {
436
+				$tag = $tags[0];
437
+			}
438
+		} else {
439
+			$tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
440
+		}
441
+
442
+		return $tag;
443
+	}
444 444
 
445 445
 	/**
446 446
 	 * Remove [collapse_this] if it's still included after all processing
@@ -465,51 +465,51 @@  discard block
 block discarded – undo
465 465
 			$class_prefix = 'frm-';
466 466
 		}
467 467
 
468
-        if ( $lang != 'en' ) {
468
+		if ( $lang != 'en' ) {
469 469
 			$api_js_url .= '&hl=' . $lang;
470
-        }
470
+		}
471 471
 		$api_js_url = apply_filters( 'frm_recaptcha_js_url', $api_js_url );
472 472
 
473
-        wp_register_script( 'recaptcha-api', $api_js_url, '', true );
474
-        wp_enqueue_script( 'recaptcha-api' );
473
+		wp_register_script( 'recaptcha-api', $api_js_url, '', true );
474
+		wp_enqueue_script( 'recaptcha-api' );
475 475
 
476 476
 ?>
477 477
 <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>
478 478
 <?php
479
-    }
479
+	}
480 480
 
481 481
 	public static function show_single_option( $field ) {
482
-        $field_name = $field['name'];
483
-        $html_id = self::get_html_id($field);
484
-        foreach ( $field['options'] as $opt_key => $opt ) {
485
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
486
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
482
+		$field_name = $field['name'];
483
+		$html_id = self::get_html_id($field);
484
+		foreach ( $field['options'] as $opt_key => $opt ) {
485
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
486
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
487 487
 
488
-            // If this is an "Other" option, get the HTML for it
488
+			// If this is an "Other" option, get the HTML for it
489 489
 			if ( self::is_other_opt( $opt_key ) ) {
490
-                // Get string for Other text field, if needed
490
+				// Get string for Other text field, if needed
491 491
 				$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
492 492
 				require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
493
-            } else {
493
+			} else {
494 494
 				require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
495
-            }
496
-        }
497
-    }
495
+			}
496
+		}
497
+	}
498 498
 
499 499
 	public static function get_term_link( $tax_id ) {
500
-        $tax = get_taxonomy($tax_id);
501
-        if ( ! $tax ) {
502
-            return;
503
-        }
500
+		$tax = get_taxonomy($tax_id);
501
+		if ( ! $tax ) {
502
+			return;
503
+		}
504 504
 
505
-        $link = sprintf(
506
-            __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
505
+		$link = sprintf(
506
+			__( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
507 507
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
508
-        );
509
-        unset($tax);
508
+		);
509
+		unset($tax);
510 510
 
511
-        return $link;
512
-    }
511
+		return $link;
512
+	}
513 513
 
514 514
 	public static function value_meets_condition( $observed_value, $cond, $hide_opt ) {
515 515
 		// Remove white space from hide_opt
@@ -520,195 +520,195 @@  discard block
 block discarded – undo
520 520
 		$observed_value = wp_kses_post( $observed_value );
521 521
 		$hide_opt = wp_kses_post( $hide_opt );
522 522
 
523
-        if ( is_array($observed_value) ) {
524
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
525
-        }
526
-
527
-        $m = false;
528
-        if ( $cond == '==' ) {
529
-            $m = $observed_value == $hide_opt;
530
-        } else if ( $cond == '!=' ) {
531
-            $m = $observed_value != $hide_opt;
532
-        } else if ( $cond == '>' ) {
533
-            $m = $observed_value > $hide_opt;
534
-        } else if ( $cond == '<' ) {
535
-            $m = $observed_value < $hide_opt;
536
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
537
-            $m = stripos($observed_value, $hide_opt);
538
-            if ( $cond == 'not LIKE' ) {
539
-                $m = ( $m === false ) ? true : false;
540
-            } else {
541
-                $m = ( $m === false ) ? false : true;
542
-            }
543
-        }
544
-        return $m;
545
-    }
523
+		if ( is_array($observed_value) ) {
524
+			return self::array_value_condition($observed_value, $cond, $hide_opt);
525
+		}
526
+
527
+		$m = false;
528
+		if ( $cond == '==' ) {
529
+			$m = $observed_value == $hide_opt;
530
+		} else if ( $cond == '!=' ) {
531
+			$m = $observed_value != $hide_opt;
532
+		} else if ( $cond == '>' ) {
533
+			$m = $observed_value > $hide_opt;
534
+		} else if ( $cond == '<' ) {
535
+			$m = $observed_value < $hide_opt;
536
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
537
+			$m = stripos($observed_value, $hide_opt);
538
+			if ( $cond == 'not LIKE' ) {
539
+				$m = ( $m === false ) ? true : false;
540
+			} else {
541
+				$m = ( $m === false ) ? false : true;
542
+			}
543
+		}
544
+		return $m;
545
+	}
546 546
 
547 547
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
548
-        $m = false;
549
-        if ( $cond == '==' ) {
550
-            if ( is_array($hide_opt) ) {
551
-                $m = array_intersect($hide_opt, $observed_value);
552
-                $m = empty($m) ? false : true;
553
-            } else {
554
-                $m = in_array($hide_opt, $observed_value);
555
-            }
556
-        } else if ( $cond == '!=' ) {
557
-            $m = ! in_array($hide_opt, $observed_value);
558
-        } else if ( $cond == '>' ) {
559
-            $min = min($observed_value);
560
-            $m = $min > $hide_opt;
561
-        } else if ( $cond == '<' ) {
562
-            $max = max($observed_value);
563
-            $m = $max < $hide_opt;
564
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
565
-            foreach ( $observed_value as $ob ) {
566
-                $m = strpos($ob, $hide_opt);
567
-                if ( $m !== false ) {
568
-                    $m = true;
569
-                    break;
570
-                }
571
-            }
572
-
573
-            if ( $cond == 'not LIKE' ) {
574
-                $m = ( $m === false ) ? true : false;
575
-            }
576
-        }
577
-
578
-        return $m;
579
-    }
580
-
581
-    /**
582
-     * Replace a few basic shortcodes and field ids
583
-     * @since 2.0
584
-     * @return string
585
-     */
548
+		$m = false;
549
+		if ( $cond == '==' ) {
550
+			if ( is_array($hide_opt) ) {
551
+				$m = array_intersect($hide_opt, $observed_value);
552
+				$m = empty($m) ? false : true;
553
+			} else {
554
+				$m = in_array($hide_opt, $observed_value);
555
+			}
556
+		} else if ( $cond == '!=' ) {
557
+			$m = ! in_array($hide_opt, $observed_value);
558
+		} else if ( $cond == '>' ) {
559
+			$min = min($observed_value);
560
+			$m = $min > $hide_opt;
561
+		} else if ( $cond == '<' ) {
562
+			$max = max($observed_value);
563
+			$m = $max < $hide_opt;
564
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
565
+			foreach ( $observed_value as $ob ) {
566
+				$m = strpos($ob, $hide_opt);
567
+				if ( $m !== false ) {
568
+					$m = true;
569
+					break;
570
+				}
571
+			}
572
+
573
+			if ( $cond == 'not LIKE' ) {
574
+				$m = ( $m === false ) ? true : false;
575
+			}
576
+		}
577
+
578
+		return $m;
579
+	}
580
+
581
+	/**
582
+	 * Replace a few basic shortcodes and field ids
583
+	 * @since 2.0
584
+	 * @return string
585
+	 */
586 586
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
587
-        if ( strpos($value, '[sitename]') !== false ) {
588
-            $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
589
-            $value = str_replace('[sitename]', $new_value, $value);
590
-        }
587
+		if ( strpos($value, '[sitename]') !== false ) {
588
+			$new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
589
+			$value = str_replace('[sitename]', $new_value, $value);
590
+		}
591 591
 
592
-        $value = apply_filters('frm_content', $value, $form, $entry);
593
-        $value = do_shortcode($value);
592
+		$value = apply_filters('frm_content', $value, $form, $entry);
593
+		$value = do_shortcode($value);
594 594
 
595
-        return $value;
596
-    }
595
+		return $value;
596
+	}
597 597
 
598 598
 	public static function get_shortcodes( $content, $form_id ) {
599
-        if ( FrmAppHelper::pro_is_installed() ) {
600
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
601
-        }
599
+		if ( FrmAppHelper::pro_is_installed() ) {
600
+			return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
601
+		}
602 602
 
603
-        $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
603
+		$fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
604 604
 
605
-        $tagregexp = self::allowed_shortcodes($fields);
605
+		$tagregexp = self::allowed_shortcodes($fields);
606 606
 
607
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
607
+		preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
608 608
 
609
-        return $matches;
610
-    }
609
+		return $matches;
610
+	}
611 611
 
612 612
 	public static function allowed_shortcodes( $fields = array() ) {
613
-        $tagregexp = array(
614
-            'editlink', 'id', 'key', 'ip',
615
-            'siteurl', 'sitename', 'admin_email',
616
-            'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
613
+		$tagregexp = array(
614
+			'editlink', 'id', 'key', 'ip',
615
+			'siteurl', 'sitename', 'admin_email',
616
+			'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
617 617
 			'parent[-|_]id',
618
-        );
618
+		);
619 619
 
620
-        foreach ( $fields as $field ) {
621
-            $tagregexp[] = $field->id;
622
-            $tagregexp[] = $field->field_key;
623
-        }
620
+		foreach ( $fields as $field ) {
621
+			$tagregexp[] = $field->id;
622
+			$tagregexp[] = $field->field_key;
623
+		}
624 624
 
625
-        $tagregexp = implode('|', $tagregexp);
626
-        return $tagregexp;
627
-    }
625
+		$tagregexp = implode('|', $tagregexp);
626
+		return $tagregexp;
627
+	}
628 628
 
629 629
 	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
630
-        $shortcode_values = array(
631
-           'id'     => $entry->id,
632
-           'key'    => $entry->item_key,
633
-           'ip'     => $entry->ip,
634
-        );
630
+		$shortcode_values = array(
631
+		   'id'     => $entry->id,
632
+		   'key'    => $entry->item_key,
633
+		   'ip'     => $entry->ip,
634
+		);
635 635
 
636
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
637
-            $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
636
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
637
+			$atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
638 638
 
639
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
639
+			if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
640 640
 				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
641
-                $tags = explode(' ', $tag);
642
-                if ( is_array($tags) ) {
643
-                    $tag = $tags[0];
644
-                }
645
-            } else {
646
-                $tag = $shortcodes[2][ $short_key ];
647
-            }
648
-
649
-            switch ( $tag ) {
650
-                case 'id':
651
-                case 'key':
652
-                case 'ip':
653
-                    $replace_with = $shortcode_values[ $tag ];
654
-                break;
655
-
656
-                case 'user_agent':
657
-                case 'user-agent':
658
-                    $entry->description = maybe_unserialize($entry->description);
641
+				$tags = explode(' ', $tag);
642
+				if ( is_array($tags) ) {
643
+					$tag = $tags[0];
644
+				}
645
+			} else {
646
+				$tag = $shortcodes[2][ $short_key ];
647
+			}
648
+
649
+			switch ( $tag ) {
650
+				case 'id':
651
+				case 'key':
652
+				case 'ip':
653
+					$replace_with = $shortcode_values[ $tag ];
654
+				break;
655
+
656
+				case 'user_agent':
657
+				case 'user-agent':
658
+					$entry->description = maybe_unserialize($entry->description);
659 659
 					$replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] );
660
-                break;
661
-
662
-                case 'created_at':
663
-                case 'created-at':
664
-                case 'updated_at':
665
-                case 'updated-at':
666
-                    if ( isset($atts['format']) ) {
667
-                        $time_format = ' ';
668
-                    } else {
669
-                        $atts['format'] = get_option('date_format');
670
-                        $time_format = '';
671
-                    }
672
-
673
-                    $this_tag = str_replace('-', '_', $tag);
674
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
675
-                    unset($this_tag);
676
-                break;
677
-
678
-                case 'created_by':
679
-                case 'created-by':
680
-                case 'updated_by':
681
-                case 'updated-by':
682
-                    $this_tag = str_replace('-', '_', $tag);
660
+				break;
661
+
662
+				case 'created_at':
663
+				case 'created-at':
664
+				case 'updated_at':
665
+				case 'updated-at':
666
+					if ( isset($atts['format']) ) {
667
+						$time_format = ' ';
668
+					} else {
669
+						$atts['format'] = get_option('date_format');
670
+						$time_format = '';
671
+					}
672
+
673
+					$this_tag = str_replace('-', '_', $tag);
674
+					$replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
675
+					unset($this_tag);
676
+				break;
677
+
678
+				case 'created_by':
679
+				case 'created-by':
680
+				case 'updated_by':
681
+				case 'updated-by':
682
+					$this_tag = str_replace('-', '_', $tag);
683 683
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
684
-                    unset($this_tag);
685
-                break;
686
-
687
-                case 'admin_email':
688
-                case 'siteurl':
689
-                case 'frmurl':
690
-                case 'sitename':
691
-                case 'get':
692
-                    $replace_with = self::dynamic_default_values( $tag, $atts );
693
-                break;
694
-
695
-                default:
696
-                    $field = FrmField::getOne( $tag );
697
-                    if ( ! $field ) {
698
-                        break;
699
-                    }
700
-
701
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
702
-
703
-                    $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
704
-
705
-                    $atts['entry_id'] = $entry->id;
706
-                    $atts['entry_key'] = $entry->item_key;
707
-
708
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
709
-                        $replace_with = $field->name;
710
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
711
-                        $replace_with = $field->description;
684
+					unset($this_tag);
685
+				break;
686
+
687
+				case 'admin_email':
688
+				case 'siteurl':
689
+				case 'frmurl':
690
+				case 'sitename':
691
+				case 'get':
692
+					$replace_with = self::dynamic_default_values( $tag, $atts );
693
+				break;
694
+
695
+				default:
696
+					$field = FrmField::getOne( $tag );
697
+					if ( ! $field ) {
698
+						break;
699
+					}
700
+
701
+					$sep = isset($atts['sep']) ? $atts['sep'] : ', ';
702
+
703
+					$replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
704
+
705
+					$atts['entry_id'] = $entry->id;
706
+					$atts['entry_key'] = $entry->item_key;
707
+
708
+					if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
709
+						$replace_with = $field->name;
710
+					} else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
711
+						$replace_with = $field->description;
712 712
 					} else {
713 713
 						$string_value = $replace_with;
714 714
 						if ( is_array( $replace_with ) ) {
@@ -722,82 +722,82 @@  discard block
 block discarded – undo
722 722
 						}
723 723
 					}
724 724
 
725
-                    unset($field);
726
-                break;
727
-            }
725
+					unset($field);
726
+				break;
727
+			}
728 728
 
729
-            if ( isset($replace_with) ) {
730
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
731
-            }
729
+			if ( isset($replace_with) ) {
730
+				$content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
731
+			}
732 732
 
733
-            unset($atts, $conditional, $replace_with);
733
+			unset($atts, $conditional, $replace_with);
734 734
 		}
735 735
 
736 736
 		return $content;
737
-    }
738
-
739
-    /**
740
-     * Get the value to replace a few standard shortcodes
741
-     *
742
-     * @since 2.0
743
-     * @return string
744
-     */
745
-    public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
746
-        $new_value = '';
747
-        switch ( $tag ) {
748
-            case 'admin_email':
749
-                $new_value = get_option('admin_email');
750
-                break;
751
-            case 'siteurl':
752
-                $new_value = FrmAppHelper::site_url();
753
-                break;
754
-            case 'frmurl':
755
-                $new_value = FrmAppHelper::plugin_url();
756
-                break;
757
-            case 'sitename':
758
-                $new_value = FrmAppHelper::site_name();
759
-                break;
760
-            case 'get':
761
-                $new_value = self::process_get_shortcode( $atts, $return_array );
762
-                break;
763
-        }
764
-
765
-        return $new_value;
766
-    }
767
-
768
-    /**
769
-     * Process the [get] shortcode
770
-     *
771
-     * @since 2.0
772
-     * @return string|array
773
-     */
774
-    public static function process_get_shortcode( $atts, $return_array = false ) {
775
-        if ( ! isset($atts['param']) ) {
776
-            return '';
777
-        }
778
-
779
-        if ( strpos($atts['param'], '&#91;') ) {
780
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
781
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
782
-        }
783
-
784
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
785
-        $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
786
-
787
-        if ( $new_value == '' ) {
788
-            if ( ! isset($atts['prev_val']) ) {
789
-                $atts['prev_val'] = '';
790
-            }
791
-
792
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
793
-        }
794
-
795
-        if ( is_array($new_value) && ! $return_array ) {
796
-            $new_value = implode(', ', $new_value);
797
-        }
798
-
799
-        return $new_value;
800
-    }
737
+	}
738
+
739
+	/**
740
+	 * Get the value to replace a few standard shortcodes
741
+	 *
742
+	 * @since 2.0
743
+	 * @return string
744
+	 */
745
+	public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
746
+		$new_value = '';
747
+		switch ( $tag ) {
748
+			case 'admin_email':
749
+				$new_value = get_option('admin_email');
750
+				break;
751
+			case 'siteurl':
752
+				$new_value = FrmAppHelper::site_url();
753
+				break;
754
+			case 'frmurl':
755
+				$new_value = FrmAppHelper::plugin_url();
756
+				break;
757
+			case 'sitename':
758
+				$new_value = FrmAppHelper::site_name();
759
+				break;
760
+			case 'get':
761
+				$new_value = self::process_get_shortcode( $atts, $return_array );
762
+				break;
763
+		}
764
+
765
+		return $new_value;
766
+	}
767
+
768
+	/**
769
+	 * Process the [get] shortcode
770
+	 *
771
+	 * @since 2.0
772
+	 * @return string|array
773
+	 */
774
+	public static function process_get_shortcode( $atts, $return_array = false ) {
775
+		if ( ! isset($atts['param']) ) {
776
+			return '';
777
+		}
778
+
779
+		if ( strpos($atts['param'], '&#91;') ) {
780
+			$atts['param'] = str_replace('&#91;', '[', $atts['param']);
781
+			$atts['param'] = str_replace('&#93;', ']', $atts['param']);
782
+		}
783
+
784
+		$new_value = FrmAppHelper::get_param($atts['param'], '');
785
+		$new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
786
+
787
+		if ( $new_value == '' ) {
788
+			if ( ! isset($atts['prev_val']) ) {
789
+				$atts['prev_val'] = '';
790
+			}
791
+
792
+			$new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
793
+		}
794
+
795
+		if ( is_array($new_value) && ! $return_array ) {
796
+			$new_value = implode(', ', $new_value);
797
+		}
798
+
799
+		return $new_value;
800
+	}
801 801
 
802 802
 	public static function get_display_value( $replace_with, $field, $atts = array() ) {
803 803
 		$sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
@@ -805,14 +805,14 @@  discard block
 block discarded – undo
805 805
 		$replace_with = apply_filters( 'frm_get_' . $field->type . '_display_value', $replace_with, $field, $atts );
806 806
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
807 807
 
808
-        if ( $field->type == 'textarea' || $field->type == 'rte' ) {
809
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
810
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
811
-                if ( is_array($replace_with) ) {
812
-                    $replace_with = implode("\n", $replace_with);
813
-                }
814
-                $replace_with = wpautop($replace_with);
815
-            }
808
+		if ( $field->type == 'textarea' || $field->type == 'rte' ) {
809
+			$autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
810
+			if ( apply_filters('frm_use_wpautop', $autop) ) {
811
+				if ( is_array($replace_with) ) {
812
+					$replace_with = implode("\n", $replace_with);
813
+				}
814
+				$replace_with = wpautop($replace_with);
815
+			}
816 816
 			unset( $autop );
817 817
 		} else if ( is_array( $replace_with ) ) {
818 818
 			$replace_with = implode( $sep, $replace_with );
@@ -822,58 +822,58 @@  discard block
 block discarded – undo
822 822
 	}
823 823
 
824 824
 	public static function get_field_types( $type ) {
825
-        $single_input = array(
826
-            'text', 'textarea', 'rte', 'number', 'email', 'url',
827
-            'image', 'file', 'date', 'phone', 'hidden', 'time',
828
-            'user_id', 'tag', 'password',
829
-        );
825
+		$single_input = array(
826
+			'text', 'textarea', 'rte', 'number', 'email', 'url',
827
+			'image', 'file', 'date', 'phone', 'hidden', 'time',
828
+			'user_id', 'tag', 'password',
829
+		);
830 830
 		$multiple_input = array( 'radio', 'checkbox', 'select', 'scale', 'lookup' );
831 831
 		$other_type = array( 'html', 'break' );
832 832
 
833 833
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
834 834
 
835
-        $field_types = array();
836
-        if ( in_array($type, $single_input) ) {
837
-            self::field_types_for_input( $single_input, $field_selection, $field_types );
838
-        } else if ( in_array($type, $multiple_input) ) {
839
-            self::field_types_for_input( $multiple_input, $field_selection, $field_types );
840
-        } else if ( in_array($type, $other_type) ) {
841
-            self::field_types_for_input( $other_type, $field_selection, $field_types );
835
+		$field_types = array();
836
+		if ( in_array($type, $single_input) ) {
837
+			self::field_types_for_input( $single_input, $field_selection, $field_types );
838
+		} else if ( in_array($type, $multiple_input) ) {
839
+			self::field_types_for_input( $multiple_input, $field_selection, $field_types );
840
+		} else if ( in_array($type, $other_type) ) {
841
+			self::field_types_for_input( $other_type, $field_selection, $field_types );
842 842
 		} else if ( isset( $field_selection[ $type ] ) ) {
843
-            $field_types[ $type ] = $field_selection[ $type ];
844
-        }
843
+			$field_types[ $type ] = $field_selection[ $type ];
844
+		}
845 845
 
846 846
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
847
-        return $field_types;
848
-    }
849
-
850
-    private static function field_types_for_input( $inputs, $fields, &$field_types ) {
851
-        foreach ( $inputs as $input ) {
852
-            $field_types[ $input ] = $fields[ $input ];
853
-            unset($input);
854
-        }
855
-    }
856
-
857
-    /**
858
-    * Check if current field option is an "other" option
859
-    *
860
-    * @since 2.0.6
861
-    *
862
-    * @param string $opt_key
863
-    * @return boolean Returns true if current field option is an "Other" option
864
-    */
865
-    public static function is_other_opt( $opt_key ) {
866
-        return $opt_key && strpos( $opt_key, 'other' ) !== false;
867
-    }
868
-
869
-    /**
870
-    * Get value that belongs in "Other" text box
871
-    *
872
-    * @since 2.0.6
873
-    *
874
-    * @param array $args
875
-    */
876
-    public static function get_other_val( $args ) {
847
+		return $field_types;
848
+	}
849
+
850
+	private static function field_types_for_input( $inputs, $fields, &$field_types ) {
851
+		foreach ( $inputs as $input ) {
852
+			$field_types[ $input ] = $fields[ $input ];
853
+			unset($input);
854
+		}
855
+	}
856
+
857
+	/**
858
+	 * Check if current field option is an "other" option
859
+	 *
860
+	 * @since 2.0.6
861
+	 *
862
+	 * @param string $opt_key
863
+	 * @return boolean Returns true if current field option is an "Other" option
864
+	 */
865
+	public static function is_other_opt( $opt_key ) {
866
+		return $opt_key && strpos( $opt_key, 'other' ) !== false;
867
+	}
868
+
869
+	/**
870
+	 * Get value that belongs in "Other" text box
871
+	 *
872
+	 * @since 2.0.6
873
+	 *
874
+	 * @param array $args
875
+	 */
876
+	public static function get_other_val( $args ) {
877 877
 		$defaults = array(
878 878
 			'opt_key' => 0, 'field' => array(),
879 879
 			'parent' => false, 'pointer' => false,
@@ -949,20 +949,20 @@  discard block
 block discarded – undo
949 949
 		}
950 950
 
951 951
 		return $other_val;
952
-    }
953
-
954
-    /**
955
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
956
-    * Intended for front-end use
957
-    *
958
-    * @since 2.0.6
959
-    *
960
-    * @param array $args should include field, opt_key and field name
961
-    * @param boolean $other_opt
962
-    * @param string $checked
963
-    * @return string $other_val
964
-    */
965
-    public static function prepare_other_input( $args, &$other_opt, &$checked ) {
952
+	}
953
+
954
+	/**
955
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
956
+	 * Intended for front-end use
957
+	 *
958
+	 * @since 2.0.6
959
+	 *
960
+	 * @param array $args should include field, opt_key and field name
961
+	 * @param boolean $other_opt
962
+	 * @param string $checked
963
+	 * @return string $other_val
964
+	 */
965
+	public static function prepare_other_input( $args, &$other_opt, &$checked ) {
966 966
 		//Check if this is an "Other" option
967 967
 		if ( ! self::is_other_opt( $args['opt_key'] ) ) {
968 968
 			return;
@@ -978,8 +978,8 @@  discard block
 block discarded – undo
978 978
 			$checked = 'checked="checked" ';
979 979
 		}
980 980
 
981
-        return $other_args;
982
-    }
981
+		return $other_args;
982
+	}
983 983
 
984 984
 	/**
985 985
 	 * @param array $args
@@ -1028,8 +1028,8 @@  discard block
 block discarded – undo
1028 1028
 	 * @since 2.0.6
1029 1029
 	 */
1030 1030
 	public static function include_other_input( $args ) {
1031
-        if ( ! $args['other_opt'] ) {
1032
-        	return;
1031
+		if ( ! $args['other_opt'] ) {
1032
+			return;
1033 1033
 		}
1034 1034
 
1035 1035
 		$classes = array( 'frm_other_input' );
@@ -1050,15 +1050,15 @@  discard block
 block discarded – undo
1050 1050
 	}
1051 1051
 
1052 1052
 	/**
1053
-	* Get the HTML id for an "Other" text field
1054
-	* Note: This does not affect fields in repeating sections
1055
-	*
1056
-	* @since 2.0.08
1057
-	* @param string $type - field type
1058
-	* @param string $html_id
1059
-	* @param string|boolean $opt_key
1060
-	* @return string $other_id
1061
-	*/
1053
+	 * Get the HTML id for an "Other" text field
1054
+	 * Note: This does not affect fields in repeating sections
1055
+	 *
1056
+	 * @since 2.0.08
1057
+	 * @param string $type - field type
1058
+	 * @param string $html_id
1059
+	 * @param string|boolean $opt_key
1060
+	 * @return string $other_id
1061
+	 */
1062 1062
 	public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) {
1063 1063
 		$other_id = $html_id;
1064 1064
 
@@ -1116,10 +1116,10 @@  discard block
 block discarded – undo
1116 1116
 	}
1117 1117
 
1118 1118
 	public static function switch_field_ids( $val ) {
1119
-        global $frm_duplicate_ids;
1120
-        $replace = array();
1121
-        $replace_with = array();
1122
-        foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1119
+		global $frm_duplicate_ids;
1120
+		$replace = array();
1121
+		$replace_with = array();
1122
+		foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1123 1123
 			$replace[] = '[if ' . $old . ']';
1124 1124
 			$replace_with[] = '[if ' . $new . ']';
1125 1125
 			$replace[] = '[if ' . $old . ' ';
@@ -1134,153 +1134,153 @@  discard block
 block discarded – undo
1134 1134
 			$replace_with[] = '[' . $new . ']';
1135 1135
 			$replace[] = '[' . $old . ' ';
1136 1136
 			$replace_with[] = '[' . $new . ' ';
1137
-            unset($old, $new);
1138
-        }
1137
+			unset($old, $new);
1138
+		}
1139 1139
 		if ( is_array( $val ) ) {
1140 1140
 			foreach ( $val as $k => $v ) {
1141
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1142
-                unset($k, $v);
1143
-            }
1144
-        } else {
1145
-            $val = str_replace($replace, $replace_with, $val);
1146
-        }
1147
-
1148
-        return $val;
1149
-    }
1150
-
1151
-    public static function get_us_states() {
1152
-        return apply_filters( 'frm_us_states', array(
1153
-            'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1154
-            'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1155
-            'DC' => 'District of Columbia',
1156
-            'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1157
-            'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1158
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1159
-            'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1160
-            'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1161
-            'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1162
-            'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1163
-            'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1164
-            'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1165
-            'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1166
-            'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1167
-        ) );
1168
-    }
1169
-
1170
-    public static function get_countries() {
1171
-        return apply_filters( 'frm_countries', array(
1172
-            __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1173
-            __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1174
-            __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1175
-            __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1176
-            __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1177
-            __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1178
-            __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1179
-            __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1180
-            __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1181
-            __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1182
-            __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1183
-            __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1184
-            __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1185
-            __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1186
-            __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1187
-            __( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1188
-            __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1189
-            __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1190
-            __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1191
-            __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1192
-            __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1193
-            __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1194
-            __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1195
-            __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1196
-            __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1197
-            __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1198
-            __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1199
-            __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1200
-            __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1201
-            __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1202
-            __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1203
-            __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1204
-            __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1205
-            __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1206
-            __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1207
-            __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1208
-            __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1209
-            __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1210
-            __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1211
-            __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1212
-            __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1213
-            __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1214
-            __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1215
-            __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1216
-            __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1217
-            __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1218
-            __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1219
-            __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1220
-            __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1221
-            __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1222
-            __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1223
-            __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1224
-            __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1225
-            __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1226
-            __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1227
-            __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1228
-            __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1229
-            __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1230
-            __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1231
-            __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1232
-            __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1233
-            __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1234
-            __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1235
-            __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1236
-            __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1237
-            __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1238
-            __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1239
-            __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1240
-            __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1241
-            __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1242
-            __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1243
-            __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1244
-            __( 'Zimbabwe', 'formidable' ),
1245
-        ) );
1246
-    }
1141
+				$val[ $k ] = str_replace( $replace, $replace_with, $v );
1142
+				unset($k, $v);
1143
+			}
1144
+		} else {
1145
+			$val = str_replace($replace, $replace_with, $val);
1146
+		}
1147
+
1148
+		return $val;
1149
+	}
1150
+
1151
+	public static function get_us_states() {
1152
+		return apply_filters( 'frm_us_states', array(
1153
+			'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1154
+			'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1155
+			'DC' => 'District of Columbia',
1156
+			'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1157
+			'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1158
+			'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1159
+			'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1160
+			'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1161
+			'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1162
+			'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1163
+			'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1164
+			'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1165
+			'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1166
+			'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1167
+		) );
1168
+	}
1169
+
1170
+	public static function get_countries() {
1171
+		return apply_filters( 'frm_countries', array(
1172
+			__( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1173
+			__( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1174
+			__( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1175
+			__( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1176
+			__( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1177
+			__( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1178
+			__( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1179
+			__( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1180
+			__( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1181
+			__( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1182
+			__( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1183
+			__( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1184
+			__( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1185
+			__( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1186
+			__( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1187
+			__( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1188
+			__( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1189
+			__( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1190
+			__( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1191
+			__( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1192
+			__( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1193
+			__( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1194
+			__( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1195
+			__( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1196
+			__( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1197
+			__( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1198
+			__( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1199
+			__( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1200
+			__( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1201
+			__( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1202
+			__( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1203
+			__( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1204
+			__( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1205
+			__( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1206
+			__( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1207
+			__( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1208
+			__( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1209
+			__( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1210
+			__( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1211
+			__( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1212
+			__( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1213
+			__( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1214
+			__( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1215
+			__( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1216
+			__( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1217
+			__( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1218
+			__( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1219
+			__( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1220
+			__( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1221
+			__( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1222
+			__( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1223
+			__( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1224
+			__( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1225
+			__( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1226
+			__( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1227
+			__( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1228
+			__( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1229
+			__( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1230
+			__( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1231
+			__( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1232
+			__( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1233
+			__( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1234
+			__( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1235
+			__( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1236
+			__( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1237
+			__( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1238
+			__( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1239
+			__( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1240
+			__( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1241
+			__( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1242
+			__( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1243
+			__( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1244
+			__( 'Zimbabwe', 'formidable' ),
1245
+		) );
1246
+	}
1247 1247
 
1248 1248
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1249 1249
 		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1250 1250
 
1251
-        $states = FrmFieldsHelper::get_us_states();
1252
-        $state_abv = array_keys($states);
1253
-        sort($state_abv);
1251
+		$states = FrmFieldsHelper::get_us_states();
1252
+		$state_abv = array_keys($states);
1253
+		sort($state_abv);
1254 1254
 		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1255 1255
 
1256
-        $states = array_values($states);
1257
-        sort($states);
1256
+		$states = array_values($states);
1257
+		sort($states);
1258 1258
 		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1259
-        unset($state_abv, $states);
1259
+		unset($state_abv, $states);
1260 1260
 
1261 1261
 		$prepop[ __( 'Age', 'formidable' ) ] = array(
1262
-            __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1263
-            __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1264
-            __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1265
-        );
1262
+			__( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1263
+			__( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1264
+			__( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1265
+		);
1266 1266
 
1267 1267
 		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1268
-            __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1269
-            __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1270
-        );
1268
+			__( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1269
+			__( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1270
+		);
1271 1271
 
1272 1272
 		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1273
-            __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1274
-            __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1275
-        );
1273
+			__( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1274
+			__( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1275
+		);
1276 1276
 
1277 1277
 		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1278
-            __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1279
-            __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1280
-        );
1278
+			__( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1279
+			__( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1280
+		);
1281 1281
 
1282 1282
 		$prepop = apply_filters( 'frm_bulk_field_choices', $prepop );
1283
-    }
1283
+	}
1284 1284
 
1285 1285
 	public static function field_selection() {
1286 1286
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::field_selection' );
@@ -1317,10 +1317,10 @@  discard block
 block discarded – undo
1317 1317
 		return FrmField::is_required( $field );
1318 1318
 	}
1319 1319
 
1320
-    public static function maybe_get_field( &$field ) {
1320
+	public static function maybe_get_field( &$field ) {
1321 1321
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' );
1322 1322
 		FrmField::maybe_get_field( $field );
1323
-    }
1323
+	}
1324 1324
 
1325 1325
 	public static function dropdown_categories( $args ) {
1326 1326
 		_deprecated_function( __FUNCTION__, '2.02.07', 'FrmProPost::get_category_dropdown' );
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
 
@@ -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 ( in_array( $type, array( 'data', 'lookup' ) ) ) {
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
 
@@ -171,21 +171,21 @@  discard block
 block discarded – undo
171 171
 
172 172
 		$conf_msg = __( 'The entered values do not match', 'formidable' );
173 173
 		$defaults = array(
174
-			'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __('%s must be unique', 'formidable' ), $field_name ) ),
175
-			'invalid'   => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __('%s is invalid', 'formidable' ), $field_name ) ),
174
+			'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __( '%s must be unique', 'formidable' ), $field_name ) ),
175
+			'invalid'   => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __( '%s is invalid', 'formidable' ), $field_name ) ),
176 176
 			'blank'     => array( 'full' => $frm_settings->blank_msg, 'part' => $frm_settings->blank_msg ),
177 177
 			'conf_msg'  => array( 'full' => $conf_msg, 'part' => $conf_msg ),
178 178
 		);
179 179
 
180 180
 		$msg = FrmField::get_option( $field, $error );
181
-		$msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg;
181
+		$msg = empty( $msg ) ? $defaults[$error]['part'] : $msg;
182 182
 		$msg = do_shortcode( $msg );
183 183
 		return $msg;
184 184
 	}
185 185
 
186 186
     public static function get_form_fields( $form_id, $error = false ) {
187
-        $fields = FrmField::get_all_for_form($form_id);
188
-        $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error);
187
+        $fields = FrmField::get_all_for_form( $form_id );
188
+        $fields = apply_filters( 'frm_get_paged_fields', $fields, $form_id, $error );
189 189
         return $fields;
190 190
     }
191 191
 
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
 </div>
209 209
 DEFAULT_HTML;
210 210
         } else {
211
-			$default_html = apply_filters('frm_other_custom_html', '', $type);
211
+			$default_html = apply_filters( 'frm_other_custom_html', '', $type );
212 212
         }
213 213
 
214
-        return apply_filters('frm_custom_html', $default_html, $type);
214
+        return apply_filters( 'frm_custom_html', $default_html, $type );
215 215
     }
216 216
 
217 217
 	public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) {
218
-        $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
218
+        $html = apply_filters( 'frm_before_replace_shortcodes', $html, $field, $errors, $form );
219 219
 
220 220
         $defaults = array(
221 221
 			'field_name'    => 'item_meta[' . $field['id'] . ']',
@@ -223,42 +223,42 @@  discard block
 block discarded – undo
223 223
             'field_plus_id' => '',
224 224
             'section_id'    => '',
225 225
         );
226
-        $args = wp_parse_args($args, $defaults);
226
+        $args = wp_parse_args( $args, $defaults );
227 227
         $field_name = $args['field_name'];
228 228
         $field_id = $args['field_id'];
229
-        $html_id = self::get_html_id($field, $args['field_plus_id']);
229
+        $html_id = self::get_html_id( $field, $args['field_plus_id'] );
230 230
 
231
-        if ( FrmField::is_multiple_select($field) ) {
231
+        if ( FrmField::is_multiple_select( $field ) ) {
232 232
             $field_name .= '[]';
233 233
         }
234 234
 
235 235
         //replace [id]
236
-        $html = str_replace('[id]', $field_id, $html);
236
+        $html = str_replace( '[id]', $field_id, $html );
237 237
 
238 238
         // Remove the for attribute for captcha
239 239
         if ( $field['type'] == 'captcha' ) {
240
-            $html = str_replace(' for="field_[key]"', '', $html);
240
+            $html = str_replace( ' for="field_[key]"', '', $html );
241 241
         }
242 242
 
243 243
         // set the label for
244
-        $html = str_replace('field_[key]', $html_id, $html);
244
+        $html = str_replace( 'field_[key]', $html_id, $html );
245 245
 
246 246
         //replace [key]
247
-        $html = str_replace('[key]', $field['field_key'], $html);
247
+        $html = str_replace( '[key]', $field['field_key'], $html );
248 248
 
249 249
         //replace [description] and [required_label] and [error]
250 250
 		$required = FrmField::is_required( $field ) ? $field['required_indicator'] : '';
251 251
         if ( ! is_array( $errors ) ) {
252 252
             $errors = array();
253 253
         }
254
-		$error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false;
254
+		$error = isset( $errors['field' . $field_id] ) ? $errors['field' . $field_id] : false;
255 255
 
256 256
         //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
257 257
         if ( $field['type'] == 'divider' ) {
258 258
             if ( FrmField::is_option_true( $field, 'description' ) ) {
259 259
                 $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
260 260
             } else {
261
-                $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
261
+                $html = str_replace( '[label_position]', '[label_position] frm_section_spacing', $html );
262 262
             }
263 263
         }
264 264
 
@@ -268,41 +268,41 @@  discard block
 block discarded – undo
268 268
 
269 269
         //replace [required_class]
270 270
 		$required_class = FrmField::is_required( $field ) ? ' frm_required_field' : '';
271
-        $html = str_replace('[required_class]', $required_class, $html);
271
+        $html = str_replace( '[required_class]', $required_class, $html );
272 272
 
273 273
         //replace [label_position]
274
-        $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
274
+        $field['label'] = apply_filters( 'frm_html_label_position', $field['label'], $field, $form );
275 275
         $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
276 276
 		$html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html );
277 277
 
278 278
         //replace [field_name]
279
-        $html = str_replace('[field_name]', $field['name'], $html);
279
+        $html = str_replace( '[field_name]', $field['name'], $html );
280 280
 
281 281
 		self::add_field_div_classes( $field_id, $field, $errors, $html );
282 282
 
283 283
         //replace [entry_key]
284 284
         $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
285
-        $html = str_replace('[entry_key]', $entry_key, $html);
285
+        $html = str_replace( '[entry_key]', $entry_key, $html );
286 286
 
287 287
         //replace [input]
288
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
288
+        preg_match_all( "/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER );
289 289
         global $frm_vars;
290 290
         $frm_settings = FrmAppHelper::get_settings();
291 291
 
292 292
         foreach ( $shortcodes[0] as $short_key => $tag ) {
293
-            $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
293
+            $atts = shortcode_parse_atts( $shortcodes[2][$short_key] );
294 294
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
295 295
 
296 296
             $replace_with = '';
297 297
 
298 298
             if ( $tag == 'input' ) {
299
-                if ( isset($atts['opt']) ) {
300
-                    $atts['opt']--;
299
+                if ( isset( $atts['opt'] ) ) {
300
+                    $atts['opt'] --;
301 301
                 }
302 302
 
303
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
304
-                if ( isset($atts['class']) ) {
305
-                    unset($atts['class']);
303
+                $field['input_class'] = isset( $atts['class'] ) ? $atts['class'] : '';
304
+                if ( isset( $atts['class'] ) ) {
305
+                    unset( $atts['class'] );
306 306
                 }
307 307
 
308 308
                 $field['shortcodes'] = $atts;
@@ -311,33 +311,33 @@  discard block
 block discarded – undo
311 311
                 $replace_with = ob_get_contents();
312 312
                 ob_end_clean();
313 313
             } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
314
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
314
+                $replace_with = FrmProEntriesController::entry_delete_link( $atts );
315 315
             }
316 316
 
317
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
317
+            $html = str_replace( $shortcodes[0][$short_key], $replace_with, $html );
318 318
         }
319 319
 
320 320
 		if ( $form ) {
321 321
             $form = (array) $form;
322 322
 
323 323
             //replace [form_key]
324
-            $html = str_replace('[form_key]', $form['form_key'], $html);
324
+            $html = str_replace( '[form_key]', $form['form_key'], $html );
325 325
 
326 326
             //replace [form_name]
327
-            $html = str_replace('[form_name]', $form['name'], $html);
327
+            $html = str_replace( '[form_name]', $form['name'], $html );
328 328
         }
329 329
         $html .= "\n";
330 330
 
331 331
         //Return html if conf_field to prevent loop
332
-        if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
332
+        if ( isset( $field['conf_field'] ) && $field['conf_field'] == 'stop' ) {
333 333
             return $html;
334 334
         }
335 335
 
336 336
         //If field is in repeating section
337 337
         if ( $args['section_id'] ) {
338
-            $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'] ));
338
+            $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'] ) );
339 339
         } else {
340
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
340
+            $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ) );
341 341
         }
342 342
 
343 343
 		self::remove_collapse_shortcode( $html );
@@ -382,14 +382,14 @@  discard block
 block discarded – undo
382 382
 	 */
383 383
 	private static function get_field_div_classes( $field_id, $field, $errors, $html ) {
384 384
 		// Add error class
385
-		$classes = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : '';
385
+		$classes = isset( $errors['field' . $field_id] ) ? ' frm_blank_field' : '';
386 386
 
387 387
 		// Add label position class
388 388
 		$classes .= ' frm_' . $field['label'] . '_container';
389 389
 
390 390
 		// Add CSS layout classes
391 391
 		if ( ! empty( $field['classes'] ) ) {
392
-			if ( ! strpos( $html, 'frm_form_field ') ) {
392
+			if ( ! strpos( $html, 'frm_form_field ' ) ) {
393 393
 				$classes .= ' frm_form_field';
394 394
 			}
395 395
 			$classes .= ' ' . $field['classes'];
@@ -428,15 +428,15 @@  discard block
 block discarded – undo
428 428
         }
429 429
 
430 430
         $with_tags = $args['conditional_check'] ? 3 : 2;
431
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
432
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
433
-            $tag = str_replace(']', '', $tag);
434
-            $tags = explode(' ', $tag);
435
-            if ( is_array($tags) ) {
431
+        if ( ! empty( $shortcodes[$with_tags][$short_key] ) ) {
432
+            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][$short_key] );
433
+            $tag = str_replace( ']', '', $tag );
434
+            $tags = explode( ' ', $tag );
435
+            if ( is_array( $tags ) ) {
436 436
                 $tag = $tags[0];
437 437
             }
438 438
         } else {
439
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
439
+            $tag = $shortcodes[$with_tags - 1][$short_key];
440 440
         }
441 441
 
442 442
         return $tag;
@@ -480,10 +480,10 @@  discard block
 block discarded – undo
480 480
 
481 481
 	public static function show_single_option( $field ) {
482 482
         $field_name = $field['name'];
483
-        $html_id = self::get_html_id($field);
483
+        $html_id = self::get_html_id( $field );
484 484
         foreach ( $field['options'] as $opt_key => $opt ) {
485
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
486
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
485
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
486
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
487 487
 
488 488
             // If this is an "Other" option, get the HTML for it
489 489
 			if ( self::is_other_opt( $opt_key ) ) {
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
     }
498 498
 
499 499
 	public static function get_term_link( $tax_id ) {
500
-        $tax = get_taxonomy($tax_id);
500
+        $tax = get_taxonomy( $tax_id );
501 501
         if ( ! $tax ) {
502 502
             return;
503 503
         }
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
             __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
507 507
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
508 508
         );
509
-        unset($tax);
509
+        unset( $tax );
510 510
 
511 511
         return $link;
512 512
     }
@@ -520,8 +520,8 @@  discard block
 block discarded – undo
520 520
 		$observed_value = wp_kses_post( $observed_value );
521 521
 		$hide_opt = wp_kses_post( $hide_opt );
522 522
 
523
-        if ( is_array($observed_value) ) {
524
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
523
+        if ( is_array( $observed_value ) ) {
524
+            return self::array_value_condition( $observed_value, $cond, $hide_opt );
525 525
         }
526 526
 
527 527
         $m = false;
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
         } else if ( $cond == '<' ) {
535 535
             $m = $observed_value < $hide_opt;
536 536
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
537
-            $m = stripos($observed_value, $hide_opt);
537
+            $m = stripos( $observed_value, $hide_opt );
538 538
             if ( $cond == 'not LIKE' ) {
539 539
                 $m = ( $m === false ) ? true : false;
540 540
             } else {
@@ -547,23 +547,23 @@  discard block
 block discarded – undo
547 547
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
548 548
         $m = false;
549 549
         if ( $cond == '==' ) {
550
-            if ( is_array($hide_opt) ) {
551
-                $m = array_intersect($hide_opt, $observed_value);
552
-                $m = empty($m) ? false : true;
550
+            if ( is_array( $hide_opt ) ) {
551
+                $m = array_intersect( $hide_opt, $observed_value );
552
+                $m = empty( $m ) ? false : true;
553 553
             } else {
554
-                $m = in_array($hide_opt, $observed_value);
554
+                $m = in_array( $hide_opt, $observed_value );
555 555
             }
556 556
         } else if ( $cond == '!=' ) {
557
-            $m = ! in_array($hide_opt, $observed_value);
557
+            $m = ! in_array( $hide_opt, $observed_value );
558 558
         } else if ( $cond == '>' ) {
559
-            $min = min($observed_value);
559
+            $min = min( $observed_value );
560 560
             $m = $min > $hide_opt;
561 561
         } else if ( $cond == '<' ) {
562
-            $max = max($observed_value);
562
+            $max = max( $observed_value );
563 563
             $m = $max < $hide_opt;
564 564
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
565 565
             foreach ( $observed_value as $ob ) {
566
-                $m = strpos($ob, $hide_opt);
566
+                $m = strpos( $ob, $hide_opt );
567 567
                 if ( $m !== false ) {
568 568
                     $m = true;
569 569
                     break;
@@ -584,27 +584,27 @@  discard block
 block discarded – undo
584 584
      * @return string
585 585
      */
586 586
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
587
-        if ( strpos($value, '[sitename]') !== false ) {
587
+        if ( strpos( $value, '[sitename]' ) !== false ) {
588 588
             $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
589
-            $value = str_replace('[sitename]', $new_value, $value);
589
+            $value = str_replace( '[sitename]', $new_value, $value );
590 590
         }
591 591
 
592
-        $value = apply_filters('frm_content', $value, $form, $entry);
593
-        $value = do_shortcode($value);
592
+        $value = apply_filters( 'frm_content', $value, $form, $entry );
593
+        $value = do_shortcode( $value );
594 594
 
595 595
         return $value;
596 596
     }
597 597
 
598 598
 	public static function get_shortcodes( $content, $form_id ) {
599 599
         if ( FrmAppHelper::pro_is_installed() ) {
600
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
600
+            return FrmProDisplaysHelper::get_shortcodes( $content, $form_id );
601 601
         }
602 602
 
603 603
         $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
604 604
 
605
-        $tagregexp = self::allowed_shortcodes($fields);
605
+        $tagregexp = self::allowed_shortcodes( $fields );
606 606
 
607
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
607
+        preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER );
608 608
 
609 609
         return $matches;
610 610
     }
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
             $tagregexp[] = $field->field_key;
623 623
         }
624 624
 
625
-        $tagregexp = implode('|', $tagregexp);
625
+        $tagregexp = implode( '|', $tagregexp );
626 626
         return $tagregexp;
627 627
     }
628 628
 
@@ -634,28 +634,28 @@  discard block
 block discarded – undo
634 634
         );
635 635
 
636 636
         foreach ( $shortcodes[0] as $short_key => $tag ) {
637
-            $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
637
+            $atts = shortcode_parse_atts( $shortcodes[3][$short_key] );
638 638
 
639
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
640
-				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
641
-                $tags = explode(' ', $tag);
642
-                if ( is_array($tags) ) {
639
+            if ( ! empty( $shortcodes[3][$short_key] ) ) {
640
+				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][$short_key] );
641
+                $tags = explode( ' ', $tag );
642
+                if ( is_array( $tags ) ) {
643 643
                     $tag = $tags[0];
644 644
                 }
645 645
             } else {
646
-                $tag = $shortcodes[2][ $short_key ];
646
+                $tag = $shortcodes[2][$short_key];
647 647
             }
648 648
 
649 649
             switch ( $tag ) {
650 650
                 case 'id':
651 651
                 case 'key':
652 652
                 case 'ip':
653
-                    $replace_with = $shortcode_values[ $tag ];
653
+                    $replace_with = $shortcode_values[$tag];
654 654
                 break;
655 655
 
656 656
                 case 'user_agent':
657 657
                 case 'user-agent':
658
-                    $entry->description = maybe_unserialize($entry->description);
658
+                    $entry->description = maybe_unserialize( $entry->description );
659 659
 					$replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] );
660 660
                 break;
661 661
 
@@ -663,25 +663,25 @@  discard block
 block discarded – undo
663 663
                 case 'created-at':
664 664
                 case 'updated_at':
665 665
                 case 'updated-at':
666
-                    if ( isset($atts['format']) ) {
666
+                    if ( isset( $atts['format'] ) ) {
667 667
                         $time_format = ' ';
668 668
                     } else {
669
-                        $atts['format'] = get_option('date_format');
669
+                        $atts['format'] = get_option( 'date_format' );
670 670
                         $time_format = '';
671 671
                     }
672 672
 
673
-                    $this_tag = str_replace('-', '_', $tag);
674
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
675
-                    unset($this_tag);
673
+                    $this_tag = str_replace( '-', '_', $tag );
674
+                    $replace_with = FrmAppHelper::get_formatted_time( $entry->{$this_tag}, $atts['format'], $time_format );
675
+                    unset( $this_tag );
676 676
                 break;
677 677
 
678 678
                 case 'created_by':
679 679
                 case 'created-by':
680 680
                 case 'updated_by':
681 681
                 case 'updated-by':
682
-                    $this_tag = str_replace('-', '_', $tag);
682
+                    $this_tag = str_replace( '-', '_', $tag );
683 683
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
684
-                    unset($this_tag);
684
+                    unset( $this_tag );
685 685
                 break;
686 686
 
687 687
                 case 'admin_email':
@@ -698,16 +698,16 @@  discard block
 block discarded – undo
698 698
                         break;
699 699
                     }
700 700
 
701
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
701
+                    $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
702 702
 
703 703
                     $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
704 704
 
705 705
                     $atts['entry_id'] = $entry->id;
706 706
                     $atts['entry_key'] = $entry->item_key;
707 707
 
708
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
708
+                    if ( isset( $atts['show'] ) && $atts['show'] == 'field_label' ) {
709 709
                         $replace_with = $field->name;
710
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
710
+                    } else if ( isset( $atts['show'] ) && $atts['show'] == 'description' ) {
711 711
                         $replace_with = $field->description;
712 712
 					} else {
713 713
 						$string_value = $replace_with;
@@ -722,15 +722,15 @@  discard block
 block discarded – undo
722 722
 						}
723 723
 					}
724 724
 
725
-                    unset($field);
725
+                    unset( $field );
726 726
                 break;
727 727
             }
728 728
 
729
-            if ( isset($replace_with) ) {
730
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
729
+            if ( isset( $replace_with ) ) {
730
+                $content = str_replace( $shortcodes[0][$short_key], $replace_with, $content );
731 731
             }
732 732
 
733
-            unset($atts, $conditional, $replace_with);
733
+            unset( $atts, $conditional, $replace_with );
734 734
 		}
735 735
 
736 736
 		return $content;
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
         $new_value = '';
747 747
         switch ( $tag ) {
748 748
             case 'admin_email':
749
-                $new_value = get_option('admin_email');
749
+                $new_value = get_option( 'admin_email' );
750 750
                 break;
751 751
             case 'siteurl':
752 752
                 $new_value = FrmAppHelper::site_url();
@@ -772,28 +772,28 @@  discard block
 block discarded – undo
772 772
      * @return string|array
773 773
      */
774 774
     public static function process_get_shortcode( $atts, $return_array = false ) {
775
-        if ( ! isset($atts['param']) ) {
775
+        if ( ! isset( $atts['param'] ) ) {
776 776
             return '';
777 777
         }
778 778
 
779
-        if ( strpos($atts['param'], '&#91;') ) {
780
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
781
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
779
+        if ( strpos( $atts['param'], '&#91;' ) ) {
780
+            $atts['param'] = str_replace( '&#91;', '[', $atts['param'] );
781
+            $atts['param'] = str_replace( '&#93;', ']', $atts['param'] );
782 782
         }
783 783
 
784
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
784
+        $new_value = FrmAppHelper::get_param( $atts['param'], '' );
785 785
         $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
786 786
 
787 787
         if ( $new_value == '' ) {
788
-            if ( ! isset($atts['prev_val']) ) {
788
+            if ( ! isset( $atts['prev_val'] ) ) {
789 789
                 $atts['prev_val'] = '';
790 790
             }
791 791
 
792
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
792
+            $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val'];
793 793
         }
794 794
 
795
-        if ( is_array($new_value) && ! $return_array ) {
796
-            $new_value = implode(', ', $new_value);
795
+        if ( is_array( $new_value ) && ! $return_array ) {
796
+            $new_value = implode( ', ', $new_value );
797 797
         }
798 798
 
799 799
         return $new_value;
@@ -806,12 +806,12 @@  discard block
 block discarded – undo
806 806
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
807 807
 
808 808
         if ( $field->type == 'textarea' || $field->type == 'rte' ) {
809
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
810
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
811
-                if ( is_array($replace_with) ) {
812
-                    $replace_with = implode("\n", $replace_with);
809
+            $autop = isset( $atts['wpautop'] ) ? $atts['wpautop'] : true;
810
+            if ( apply_filters( 'frm_use_wpautop', $autop ) ) {
811
+                if ( is_array( $replace_with ) ) {
812
+                    $replace_with = implode( "\n", $replace_with );
813 813
                 }
814
-                $replace_with = wpautop($replace_with);
814
+                $replace_with = wpautop( $replace_with );
815 815
             }
816 816
 			unset( $autop );
817 817
 		} else if ( is_array( $replace_with ) ) {
@@ -833,14 +833,14 @@  discard block
 block discarded – undo
833 833
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
834 834
 
835 835
         $field_types = array();
836
-        if ( in_array($type, $single_input) ) {
836
+        if ( in_array( $type, $single_input ) ) {
837 837
             self::field_types_for_input( $single_input, $field_selection, $field_types );
838
-        } else if ( in_array($type, $multiple_input) ) {
838
+        } else if ( in_array( $type, $multiple_input ) ) {
839 839
             self::field_types_for_input( $multiple_input, $field_selection, $field_types );
840
-        } else if ( in_array($type, $other_type) ) {
840
+        } else if ( in_array( $type, $other_type ) ) {
841 841
             self::field_types_for_input( $other_type, $field_selection, $field_types );
842
-		} else if ( isset( $field_selection[ $type ] ) ) {
843
-            $field_types[ $type ] = $field_selection[ $type ];
842
+		} else if ( isset( $field_selection[$type] ) ) {
843
+            $field_types[$type] = $field_selection[$type];
844 844
         }
845 845
 
846 846
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
 
850 850
     private static function field_types_for_input( $inputs, $fields, &$field_types ) {
851 851
         foreach ( $inputs as $input ) {
852
-            $field_types[ $input ] = $fields[ $input ];
853
-            unset($input);
852
+            $field_types[$input] = $fields[$input];
853
+            unset( $input );
854 854
         }
855 855
     }
856 856
 
@@ -895,21 +895,21 @@  discard block
 block discarded – undo
895 895
 		// Check posted vals before checking saved values
896 896
 
897 897
 		// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
898
-		if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) {
898
+		if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) {
899 899
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
900
-				$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 ] ) : '';
900
+				$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] ) : '';
901 901
 			} else {
902
-				$other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] );
902
+				$other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] );
903 903
 			}
904 904
 			return $other_val;
905 905
 
906
-		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) {
906
+		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) {
907 907
 			// For normal fields
908 908
 
909 909
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
910
-				$other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : '';
910
+				$other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : '';
911 911
 			} else {
912
-				$other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] );
912
+				$other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] );
913 913
 			}
914 914
 			return $other_val;
915 915
 		}
@@ -918,8 +918,8 @@  discard block
 block discarded – undo
918 918
 		if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) {
919 919
 			// Check if there is an "other" val in saved value and make sure the
920 920
 			// "other" val is not equal to the Other checkbox option
921
-			if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
922
-				$other_val = $field['value'][ $opt_key ];
921
+			if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) {
922
+				$other_val = $field['value'][$opt_key];
923 923
 			}
924 924
 		} else {
925 925
 			/**
@@ -931,8 +931,8 @@  discard block
 block discarded – undo
931 931
 				// Multi-select dropdowns - key is not preserved
932 932
 				if ( is_array( $field['value'] ) ) {
933 933
 					$o_key = array_search( $temp_val, $field['value'] );
934
-					if ( isset( $field['value'][ $o_key ] ) ) {
935
-						unset( $field['value'][ $o_key ], $o_key );
934
+					if ( isset( $field['value'][$o_key] ) ) {
935
+						unset( $field['value'][$o_key], $o_key );
936 936
 					}
937 937
 				} else if ( $temp_val == $field['value'] ) {
938 938
 					// For radio and regular dropdowns
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
 	private static function set_other_name( $args, &$other_args ) {
990 990
 		//Set up name for other field
991 991
 		$other_args['name'] = str_replace( '[]', '', $args['field_name'] );
992
-		$other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']);
992
+		$other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] );
993 993
 		$other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']';
994 994
 
995 995
 		//Converts item_meta[field_id] => item_meta[other][field_id] and
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
 		// Count should only be greater than 3 if inside of a repeating section
1016 1016
 		if ( count( $temp_array ) > 3 ) {
1017 1017
 			$parent = str_replace( ']', '', $temp_array[1] );
1018
-			$pointer = str_replace( ']', '', $temp_array[2]);
1018
+			$pointer = str_replace( ']', '', $temp_array[2] );
1019 1019
 		}
1020 1020
 
1021 1021
 		// Get text for "other" text field
@@ -1134,15 +1134,15 @@  discard block
 block discarded – undo
1134 1134
 			$replace_with[] = '[' . $new . ']';
1135 1135
 			$replace[] = '[' . $old . ' ';
1136 1136
 			$replace_with[] = '[' . $new . ' ';
1137
-            unset($old, $new);
1137
+            unset( $old, $new );
1138 1138
         }
1139 1139
 		if ( is_array( $val ) ) {
1140 1140
 			foreach ( $val as $k => $v ) {
1141
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1142
-                unset($k, $v);
1141
+                $val[$k] = str_replace( $replace, $replace_with, $v );
1142
+                unset( $k, $v );
1143 1143
             }
1144 1144
         } else {
1145
-            $val = str_replace($replace, $replace_with, $val);
1145
+            $val = str_replace( $replace, $replace_with, $val );
1146 1146
         }
1147 1147
 
1148 1148
         return $val;
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
             'DC' => 'District of Columbia',
1156 1156
             'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1157 1157
             'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1158
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1158
+            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland',
1159 1159
             'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1160 1160
             'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1161 1161
             'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
@@ -1246,35 +1246,35 @@  discard block
 block discarded – undo
1246 1246
     }
1247 1247
 
1248 1248
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1249
-		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1249
+		$prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries();
1250 1250
 
1251 1251
         $states = FrmFieldsHelper::get_us_states();
1252
-        $state_abv = array_keys($states);
1253
-        sort($state_abv);
1254
-		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1252
+        $state_abv = array_keys( $states );
1253
+        sort( $state_abv );
1254
+		$prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv;
1255 1255
 
1256
-        $states = array_values($states);
1257
-        sort($states);
1258
-		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1259
-        unset($state_abv, $states);
1256
+        $states = array_values( $states );
1257
+        sort( $states );
1258
+		$prepop[__( 'U.S. States', 'formidable' )] = $states;
1259
+        unset( $state_abv, $states );
1260 1260
 
1261
-		$prepop[ __( 'Age', 'formidable' ) ] = array(
1261
+		$prepop[__( 'Age', 'formidable' )] = array(
1262 1262
             __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1263 1263
             __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1264 1264
             __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1265 1265
         );
1266 1266
 
1267
-		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1267
+		$prepop[__( 'Satisfaction', 'formidable' )] = array(
1268 1268
             __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1269 1269
             __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1270 1270
         );
1271 1271
 
1272
-		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1272
+		$prepop[__( 'Importance', 'formidable' )] = array(
1273 1273
             __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1274 1274
             __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1275 1275
         );
1276 1276
 
1277
-		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1277
+		$prepop[__( 'Agreement', 'formidable' )] = array(
1278 1278
             __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1279 1279
             __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1280 1280
         );
Please login to merge, or discard this patch.
classes/views/frm-fields/input.php 2 patches
Indentation   +58 added lines, -58 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,58 +53,58 @@  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 62
 	include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/front-end/dropdown-field.php' );
63 63
 } else if ( $field['type'] == 'checkbox' ) {
64
-    $checked_values = $field['value'];
65
-    $read_only = false;
64
+	$checked_values = $field['value'];
65
+	$read_only = false;
66 66
 
67 67
 	if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
68
-        $read_only = true;
69
-        if ( $checked_values ) {
70
-            foreach ( (array) $checked_values as $checked_value ) { ?>
68
+		$read_only = true;
69
+		if ( $checked_values ) {
70
+			foreach ( (array) $checked_values as $checked_value ) { ?>
71 71
 <input type="hidden" value="<?php echo esc_attr( $checked_value ) ?>" name="<?php echo esc_attr( $field_name ) ?>[]" />
72 72
 <?php
73
-            }
74
-        } else { ?>
73
+			}
74
+		} else { ?>
75 75
 <input type="hidden" value="" name="<?php echo esc_attr( $field_name ) ?>[]" />
76 76
 <?php
77
-        }
78
-    }
77
+		}
78
+	}
79 79
 
80
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
80
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
81 81
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
82
-    } else if ( $field['options'] ) {
83
-        foreach ( $field['options'] as $opt_key => $opt ) {
84
-            if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
85
-                continue;
86
-            }
87
-
88
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
89
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
90
-            $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
91
-
92
-            // Check if other opt, and get values for other field if needed
93
-            $other_opt = false;
82
+	} else if ( $field['options'] ) {
83
+		foreach ( $field['options'] as $opt_key => $opt ) {
84
+			if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
85
+				continue;
86
+			}
87
+
88
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
89
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
90
+			$checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
91
+
92
+			// Check if other opt, and get values for other field if needed
93
+			$other_opt = false;
94 94
 			$other_args = FrmFieldsHelper::prepare_other_input( compact( 'field', 'field_name', 'opt_key' ), $other_opt, $checked );
95 95
 
96
-            ?>
96
+			?>
97 97
 			<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
98 98
 
99
-            if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
100
-                ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
101
-            }
99
+			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
100
+				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
101
+			}
102 102
 
103
-            ?><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
103
+			?><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
104 104
 
105
-            if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
105
+			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
106 106
 				echo ' ' . $opt . '</label>';
107
-            }
107
+			}
108 108
 
109 109
 			FrmFieldsHelper::include_other_input( array(
110 110
 				'other_opt' => $other_opt, 'read_only' => $read_only,
@@ -113,17 +113,17 @@  discard block
 block discarded – undo
113 113
 				'html_id' => $html_id, 'opt_key' => $opt_key,
114 114
 			) );
115 115
 
116
-            unset( $other_opt, $other_args, $checked );
116
+			unset( $other_opt, $other_args, $checked );
117 117
 
118
-            ?></div>
118
+			?></div>
119 119
 <?php
120
-        }
121
-    }
120
+		}
121
+	}
122 122
 } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) {
123
-    $frm_settings = FrmAppHelper::get_settings();
124
-    if ( ! empty($frm_settings->pubkey) ) {
125
-        FrmFieldsHelper::display_recaptcha($field);
126
-    }
123
+	$frm_settings = FrmAppHelper::get_settings();
124
+	if ( ! empty($frm_settings->pubkey) ) {
125
+		FrmFieldsHelper::display_recaptcha($field);
126
+	}
127 127
 } else {
128 128
 	do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) );
129 129
 	do_action( 'frm_form_field_' . $field['type'], $field, $field_name, compact( 'errors', 'html_id' ) );
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 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'] ) {
@@ -77,17 +77,17 @@  discard block
 block discarded – undo
77 77
         }
78 78
     }
79 79
 
80
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
80
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
81 81
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
82 82
     } else if ( $field['options'] ) {
83 83
         foreach ( $field['options'] as $opt_key => $opt ) {
84
-            if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
84
+            if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
85 85
                 continue;
86 86
             }
87 87
 
88
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
89
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
90
-            $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
88
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
89
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
90
+            $checked = FrmAppHelper::check_selected( $checked_values, $field_val ) ? ' checked="checked"' : '';
91 91
 
92 92
             // Check if other opt, and get values for other field if needed
93 93
             $other_opt = false;
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
                 ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
101 101
             }
102 102
 
103
-            ?><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
103
+            ?><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
104 104
 
105 105
             if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
106 106
 				echo ' ' . $opt . '</label>';
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
     }
122 122
 } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) {
123 123
     $frm_settings = FrmAppHelper::get_settings();
124
-    if ( ! empty($frm_settings->pubkey) ) {
125
-        FrmFieldsHelper::display_recaptcha($field);
124
+    if ( ! empty( $frm_settings->pubkey ) ) {
125
+        FrmFieldsHelper::display_recaptcha( $field );
126 126
     }
127 127
 } else {
128 128
 	do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) );
Please login to merge, or discard this patch.
classes/views/frm-fields/front-end/dropdown-field.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $read_only = false;
4
-if ( isset($field['post_field']) && $field['post_field'] == 'post_category' && FrmAppHelper::pro_is_installed() ) {
4
+if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' && FrmAppHelper::pro_is_installed() ) {
5 5
 	echo FrmProPost::get_category_dropdown( $field, array( 'location' => 'front', 'name' => $field_name, 'id' => $html_id ) );
6 6
 } else {
7 7
 	if ( FrmAppHelper::pro_is_installed() && FrmField::is_read_only( $field ) ) {
8 8
 		$read_only = true;
9 9
 
10 10
 		echo FrmProDropdownFieldsController::get_hidden_fields_with_readonly_values( $field, $field_name, $html_id ); ?>
11
-		<select <?php do_action('frm_field_input_html', $field) ?>> <?php
11
+		<select <?php do_action( 'frm_field_input_html', $field ) ?>> <?php
12 12
 
13 13
 	} else { ?>
14
-		<select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action('frm_field_input_html', $field) ?>>
14
+		<select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>>
15 15
 	<?php   }
16 16
 
17 17
 	$other_opt = $other_checked = false;
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 			}
27 27
 		}
28 28
 		?>
29
-		<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 esc_html( $opt == '' ? ' ' : $opt ); ?></option>
29
+		<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 esc_html( $opt == '' ? ' ' : $opt ); ?></option>
30 30
 		<?php
31 31
 	} ?>
32 32
 	</select>
Please login to merge, or discard this patch.
classes/views/frm-fields/back-end/dropdown-field.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( isset($field['post_field']) && $field['post_field'] == 'post_category' && FrmAppHelper::pro_is_installed() ) {
3
+if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' && FrmAppHelper::pro_is_installed() ) {
4 4
 	echo FrmProPost::get_category_dropdown( $field, array( 'name' => $field_name, 'id' => 'placeholder_id', 'location' => 'form_builder' ) );
5 5
 } else { ?>
6 6
 	<select name="<?php echo esc_attr( $field_name ) . ( FrmField::is_option_true( $field, 'multiple' ) ? '[]' : '' ); ?>" <?php
7 7
 	echo FrmField::is_option_true( $field, 'size' ) ? 'class="auto_width"' : '';
8 8
 	echo FrmField::is_option_true( $field, 'multiple' ) ? ' multiple="multiple"' : ''; ?> >
9 9
 		<?php foreach ( $field['options'] as $opt_key => $opt ) {
10
-			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
11
-			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
10
+			$field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
11
+			$opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
12 12
 			$selected = ( $field['default_value'] == $field_val || FrmFieldsHelper::get_other_val( array( 'opt_key', 'field' ) ) ) ? ' selected="selected"' : ''; ?>
13 13
 			<option value="<?php echo esc_attr( $field_val ) ?>"<?php echo $selected ?>><?php echo esc_html( $opt ) ?> </option>
14 14
 		<?php } ?>
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
 	<?php
27 27
 
28 28
 	if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) { ?>
29
-		<?php do_action('frm_add_multiple_opts_labels', $field); ?>
30
-		<ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts<?php echo ( count($field['options']) > 10 ) ? ' frm_field_opts_list' : ''; ?>">
31
-			<?php FrmFieldsHelper::show_single_option($field); ?>
29
+		<?php do_action( 'frm_add_multiple_opts_labels', $field ); ?>
30
+		<ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts<?php echo ( count( $field['options'] ) > 10 ) ? ' frm_field_opts_list' : ''; ?>">
31
+			<?php FrmFieldsHelper::show_single_option( $field ); ?>
32 32
 		</ul>
33 33
 		<?php
34 34
 	} ?>
Please login to merge, or discard this patch.