Completed
Push — master ( d6428c...6abad8 )
by Jamie
03:41
created
classes/helpers/FrmAppHelper.php 2 patches
Indentation   +1092 added lines, -1092 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.01.0rc2';
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();
@@ -75,83 +75,83 @@  discard block
 block discarded – undo
75 75
 		return $affiliate_id;
76 76
 	}
77 77
 
78
-    /**
79
-     * Get the Formidable settings
80
-     *
81
-     * @since 2.0
82
-     *
83
-     * @param None
84
-     * @return FrmSettings $frm_setings
85
-     */
86
-    public static function get_settings() {
87
-        global $frm_settings;
88
-        if ( empty($frm_settings) ) {
89
-            $frm_settings = new FrmSettings();
90
-        }
91
-        return $frm_settings;
92
-    }
78
+	/**
79
+	 * Get the Formidable settings
80
+	 *
81
+	 * @since 2.0
82
+	 *
83
+	 * @param None
84
+	 * @return FrmSettings $frm_setings
85
+	 */
86
+	public static function get_settings() {
87
+		global $frm_settings;
88
+		if ( empty($frm_settings) ) {
89
+			$frm_settings = new FrmSettings();
90
+		}
91
+		return $frm_settings;
92
+	}
93 93
 
94 94
 	public static function get_menu_name() {
95 95
 		$frm_settings = FrmAppHelper::get_settings();
96 96
 		return $frm_settings->menu;
97 97
 	}
98 98
 
99
-    /**
100
-     * Show a message in place of pro features
101
-     *
102
-     * @since 2.0
103
-     */
99
+	/**
100
+	 * Show a message in place of pro features
101
+	 *
102
+	 * @since 2.0
103
+	 */
104 104
 	public static function update_message( $features, $class = '' ) {
105 105
 		_deprecated_function( __FUNCTION__, '2.0.19' );
106
-    }
107
-
108
-    public static function pro_is_installed() {
109
-        return apply_filters('frm_pro_installed', false);
110
-    }
111
-
112
-    /**
113
-     * Check for certain page in Formidable settings
114
-     *
115
-     * @since 2.0
116
-     *
117
-     * @param string $page The name of the page to check
118
-     * @return boolean
119
-     */
106
+	}
107
+
108
+	public static function pro_is_installed() {
109
+		return apply_filters('frm_pro_installed', false);
110
+	}
111
+
112
+	/**
113
+	 * Check for certain page in Formidable settings
114
+	 *
115
+	 * @since 2.0
116
+	 *
117
+	 * @param string $page The name of the page to check
118
+	 * @return boolean
119
+	 */
120 120
 	public static function is_admin_page( $page = 'formidable' ) {
121
-        global $pagenow;
121
+		global $pagenow;
122 122
 		$get_page = self::simple_get( 'page', 'sanitize_title' );
123
-        if ( $pagenow ) {
123
+		if ( $pagenow ) {
124 124
 			return $pagenow == 'admin.php' && $get_page == $page;
125
-        }
125
+		}
126 126
 
127 127
 		return is_admin() && $get_page == $page;
128
-    }
129
-
130
-    /**
131
-     * Check for the form preview page
132
-     *
133
-     * @since 2.0
134
-     *
135
-     * @param None
136
-     * @return boolean
137
-     */
138
-    public static function is_preview_page() {
139
-        global $pagenow;
128
+	}
129
+
130
+	/**
131
+	 * Check for the form preview page
132
+	 *
133
+	 * @since 2.0
134
+	 *
135
+	 * @param None
136
+	 * @return boolean
137
+	 */
138
+	public static function is_preview_page() {
139
+		global $pagenow;
140 140
 		$action = FrmAppHelper::simple_get( 'action', 'sanitize_title' );
141 141
 		return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
142
-    }
142
+	}
143 143
 
144
-    /**
145
-     * Check for ajax except the form preview page
146
-     *
147
-     * @since 2.0
148
-     *
149
-     * @param None
150
-     * @return boolean
151
-     */
152
-    public static function doing_ajax() {
153
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
154
-    }
144
+	/**
145
+	 * Check for ajax except the form preview page
146
+	 *
147
+	 * @since 2.0
148
+	 *
149
+	 * @param None
150
+	 * @return boolean
151
+	 */
152
+	public static function doing_ajax() {
153
+		return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
154
+	}
155 155
 
156 156
 	/**
157 157
 	 * @since 2.0.8
@@ -161,101 +161,101 @@  discard block
 block discarded – undo
161 161
 		return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
162 162
 	}
163 163
 
164
-    /**
165
-     * Check if on an admin page
166
-     *
167
-     * @since 2.0
168
-     *
169
-     * @param None
170
-     * @return boolean
171
-     */
172
-    public static function is_admin() {
173
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
174
-    }
175
-
176
-    /**
177
-     * Check if value contains blank value or empty array
178
-     *
179
-     * @since 2.0
180
-     * @param $value - value to check
181
-     * @return boolean
182
-     */
183
-    public static function is_empty_value( $value, $empty = '' ) {
184
-        return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
185
-    }
186
-
187
-    public static function is_not_empty_value( $value, $empty = '' ) {
188
-        return ! self::is_empty_value( $value, $empty );
189
-    }
190
-
191
-    /**
192
-     * Get any value from the $_SERVER
193
-     *
194
-     * @since 2.0
195
-     * @param string $value
196
-     * @return string
197
-     */
164
+	/**
165
+	 * Check if on an admin page
166
+	 *
167
+	 * @since 2.0
168
+	 *
169
+	 * @param None
170
+	 * @return boolean
171
+	 */
172
+	public static function is_admin() {
173
+		return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
174
+	}
175
+
176
+	/**
177
+	 * Check if value contains blank value or empty array
178
+	 *
179
+	 * @since 2.0
180
+	 * @param $value - value to check
181
+	 * @return boolean
182
+	 */
183
+	public static function is_empty_value( $value, $empty = '' ) {
184
+		return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
185
+	}
186
+
187
+	public static function is_not_empty_value( $value, $empty = '' ) {
188
+		return ! self::is_empty_value( $value, $empty );
189
+	}
190
+
191
+	/**
192
+	 * Get any value from the $_SERVER
193
+	 *
194
+	 * @since 2.0
195
+	 * @param string $value
196
+	 * @return string
197
+	 */
198 198
 	public static function get_server_value( $value ) {
199
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
200
-    }
201
-
202
-    /**
203
-     * Check for the IP address in several places
204
-     * Used by [ip] shortcode
205
-     *
206
-     * @return string The IP address of the current user
207
-     */
208
-    public static function get_ip_address() {
199
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
200
+	}
201
+
202
+	/**
203
+	 * Check for the IP address in several places
204
+	 * Used by [ip] shortcode
205
+	 *
206
+	 * @return string The IP address of the current user
207
+	 */
208
+	public static function get_ip_address() {
209 209
 		$ip = '';
210
-        foreach ( array(
211
-            'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
212
-            'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
213
-        ) as $key ) {
214
-            if ( ! isset( $_SERVER[ $key ] ) ) {
215
-                continue;
216
-            }
217
-
218
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
219
-                $ip = trim($ip); // just to be safe
220
-
221
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
222
-                    return $ip;
223
-                }
224
-            }
225
-        }
210
+		foreach ( array(
211
+			'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
212
+			'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
213
+		) as $key ) {
214
+			if ( ! isset( $_SERVER[ $key ] ) ) {
215
+				continue;
216
+			}
217
+
218
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
219
+				$ip = trim($ip); // just to be safe
220
+
221
+				if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
222
+					return $ip;
223
+				}
224
+			}
225
+		}
226 226
 
227 227
 		return sanitize_text_field( $ip );
228
-    }
228
+	}
229 229
 
230
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
231
-        if ( strpos($param, '[') ) {
232
-            $params = explode('[', $param);
233
-            $param = $params[0];
234
-        }
230
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
231
+		if ( strpos($param, '[') ) {
232
+			$params = explode('[', $param);
233
+			$param = $params[0];
234
+		}
235 235
 
236 236
 		if ( $src == 'get' ) {
237
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
238
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
239
-                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
240
-            }
237
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
238
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
239
+				$value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
240
+			}
241 241
 			self::sanitize_value( $sanitize, $value );
242 242
 		} else {
243
-            $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
244
-        }
243
+			$value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
244
+		}
245 245
 
246 246
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
247
-            foreach ( $params as $k => $p ) {
248
-                if ( ! $k || ! is_array($value) ) {
249
-                    continue;
250
-                }
247
+			foreach ( $params as $k => $p ) {
248
+				if ( ! $k || ! is_array($value) ) {
249
+					continue;
250
+				}
251 251
 
252
-                $p = trim($p, ']');
253
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
254
-            }
255
-        }
252
+				$p = trim($p, ']');
253
+				$value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
254
+			}
255
+		}
256 256
 
257
-        return $value;
258
-    }
257
+		return $value;
258
+	}
259 259
 
260 260
 	/**
261 261
 	 *
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 */
277 277
 	public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) {
278 278
 		return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
279
-    }
279
+	}
280 280
 
281 281
 	/**
282 282
 	 * Get a GET/POST/REQUEST value and sanitize it
@@ -310,12 +310,12 @@  discard block
 block discarded – undo
310 310
 	}
311 311
 
312 312
 	/**
313
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
314
-	*
315
-	* @since 2.0.8
316
-	* @param string $value
317
-	* @return string $value
318
-	*/
313
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
314
+	 *
315
+	 * @since 2.0.8
316
+	 * @param string $value
317
+	 * @return string $value
318
+	 */
319 319
 	public static function preserve_backslashes( $value ) {
320 320
 		// If backslashes have already been added, don't add them again
321 321
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -337,14 +337,14 @@  discard block
 block discarded – undo
337 337
 		}
338 338
 	}
339 339
 
340
-    public static function sanitize_request( $sanitize_method, &$values ) {
341
-        $temp_values = $values;
342
-        foreach ( $temp_values as $k => $val ) {
343
-            if ( isset( $sanitize_method[ $k ] ) ) {
340
+	public static function sanitize_request( $sanitize_method, &$values ) {
341
+		$temp_values = $values;
342
+		foreach ( $temp_values as $k => $val ) {
343
+			if ( isset( $sanitize_method[ $k ] ) ) {
344 344
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
345
-            }
346
-        }
347
-    }
345
+			}
346
+		}
347
+	}
348 348
 
349 349
 	public static function sanitize_array( &$values ) {
350 350
 		$temp_values = $values;
@@ -359,12 +359,12 @@  discard block
 block discarded – undo
359 359
 	 */
360 360
 	public static function kses( $value, $allowed = array() ) {
361 361
 		$html = array(
362
-		    'a' => array(
362
+			'a' => array(
363 363
 				'href'  => array(),
364 364
 				'title' => array(),
365 365
 				'id'    => array(),
366 366
 				'class' => array(),
367
-		    ),
367
+			),
368 368
 		);
369 369
 
370 370
 		$allowed_html = array();
@@ -375,176 +375,176 @@  discard block
 block discarded – undo
375 375
 		return wp_kses( $value, $allowed_html );
376 376
 	}
377 377
 
378
-    /**
379
-     * Used when switching the action for a bulk action
380
-     * @since 2.0
381
-     */
382
-    public static function remove_get_action() {
383
-        if ( ! isset($_GET) ) {
384
-            return;
385
-        }
378
+	/**
379
+	 * Used when switching the action for a bulk action
380
+	 * @since 2.0
381
+	 */
382
+	public static function remove_get_action() {
383
+		if ( ! isset($_GET) ) {
384
+			return;
385
+		}
386 386
 
387
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
388
-        if ( ! empty( $new_action ) ) {
387
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
388
+		if ( ! empty( $new_action ) ) {
389 389
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
390
-        }
391
-    }
392
-
393
-    /**
394
-     * Check the WP query for a parameter
395
-     *
396
-     * @since 2.0
397
-     * @return string|array
398
-     */
399
-    public static function get_query_var( $value, $param ) {
400
-        if ( $value != '' ) {
401
-            return $value;
402
-        }
403
-
404
-        global $wp_query;
405
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
406
-            $value = $wp_query->query_vars[ $param ];
407
-        }
408
-
409
-        return $value;
410
-    }
411
-
412
-    /**
413
-     * @param string $type
414
-     */
415
-    public static function trigger_hook_load( $type, $object = null ) {
416
-        // only load the form hooks once
390
+		}
391
+	}
392
+
393
+	/**
394
+	 * Check the WP query for a parameter
395
+	 *
396
+	 * @since 2.0
397
+	 * @return string|array
398
+	 */
399
+	public static function get_query_var( $value, $param ) {
400
+		if ( $value != '' ) {
401
+			return $value;
402
+		}
403
+
404
+		global $wp_query;
405
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
406
+			$value = $wp_query->query_vars[ $param ];
407
+		}
408
+
409
+		return $value;
410
+	}
411
+
412
+	/**
413
+	 * @param string $type
414
+	 */
415
+	public static function trigger_hook_load( $type, $object = null ) {
416
+		// only load the form hooks once
417 417
 		$hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
418
-        if ( ! $hooks_loaded ) {
418
+		if ( ! $hooks_loaded ) {
419 419
 			do_action( 'frm_load_' . $type . '_hooks' );
420
-        }
421
-    }
422
-
423
-    /**
424
-     * Check cache before fetching values and saving to cache
425
-     *
426
-     * @since 2.0
427
-     *
428
-     * @param string $cache_key The unique name for this cache
429
-     * @param string $group The name of the cache group
430
-     * @param string $query If blank, don't run a db call
431
-     * @param string $type The wpdb function to use with this query
432
-     * @return mixed $results The cache or query results
433
-     */
434
-    public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
435
-        $results = wp_cache_get($cache_key, $group);
436
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
437
-            return $results;
438
-        }
439
-
440
-        if ( 'get_posts' == $type ) {
441
-            $results = get_posts($query);
442
-        } else {
443
-            global $wpdb;
444
-            $results = $wpdb->{$type}($query);
445
-        }
420
+		}
421
+	}
422
+
423
+	/**
424
+	 * Check cache before fetching values and saving to cache
425
+	 *
426
+	 * @since 2.0
427
+	 *
428
+	 * @param string $cache_key The unique name for this cache
429
+	 * @param string $group The name of the cache group
430
+	 * @param string $query If blank, don't run a db call
431
+	 * @param string $type The wpdb function to use with this query
432
+	 * @return mixed $results The cache or query results
433
+	 */
434
+	public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
435
+		$results = wp_cache_get($cache_key, $group);
436
+		if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
437
+			return $results;
438
+		}
439
+
440
+		if ( 'get_posts' == $type ) {
441
+			$results = get_posts($query);
442
+		} else {
443
+			global $wpdb;
444
+			$results = $wpdb->{$type}($query);
445
+		}
446 446
 
447 447
 		if ( ! self::prevent_caching() ) {
448 448
 			wp_cache_set( $cache_key, $results, $group, $time );
449 449
 		}
450 450
 
451
-        return $results;
452
-    }
451
+		return $results;
452
+	}
453 453
 
454
-    /**
455
-     * Data that should be stored for a long time can be stored in a transient.
456
-     * First check the cache, then check the transient
457
-     * @since 2.0
458
-     * @return mixed The cached value or false
459
-     */
454
+	/**
455
+	 * Data that should be stored for a long time can be stored in a transient.
456
+	 * First check the cache, then check the transient
457
+	 * @since 2.0
458
+	 * @return mixed The cached value or false
459
+	 */
460 460
 	public static function check_cache_and_transient( $cache_key ) {
461
-        // check caching layer first
462
-        $results = self::check_cache( $cache_key );
463
-        if ( $results ) {
464
-            return $results;
465
-        }
466
-
467
-        // then check the transient
468
-        $results = get_transient($cache_key);
469
-        if ( $results ) {
470
-            wp_cache_set($cache_key, $results);
471
-        }
472
-
473
-        return $results;
474
-    }
475
-
476
-    /**
477
-     * @since 2.0
478
-     * @param string $cache_key
479
-     */
461
+		// check caching layer first
462
+		$results = self::check_cache( $cache_key );
463
+		if ( $results ) {
464
+			return $results;
465
+		}
466
+
467
+		// then check the transient
468
+		$results = get_transient($cache_key);
469
+		if ( $results ) {
470
+			wp_cache_set($cache_key, $results);
471
+		}
472
+
473
+		return $results;
474
+	}
475
+
476
+	/**
477
+	 * @since 2.0
478
+	 * @param string $cache_key
479
+	 */
480 480
 	public static function delete_cache_and_transient( $cache_key ) {
481
-        delete_transient($cache_key);
482
-        wp_cache_delete($cache_key);
483
-    }
484
-
485
-    /**
486
-     * Delete all caching in a single group
487
-     *
488
-     * @since 2.0
489
-     *
490
-     * @param string $group The name of the cache group
491
-     * @return boolean True or False
492
-     */
481
+		delete_transient($cache_key);
482
+		wp_cache_delete($cache_key);
483
+	}
484
+
485
+	/**
486
+	 * Delete all caching in a single group
487
+	 *
488
+	 * @since 2.0
489
+	 *
490
+	 * @param string $group The name of the cache group
491
+	 * @return boolean True or False
492
+	 */
493 493
 	public static function cache_delete_group( $group ) {
494
-    	global $wp_object_cache;
495
-
496
-        if ( isset( $wp_object_cache->cache[ $group ] ) ) {
497
-            foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) {
498
-                wp_cache_delete($k, $group);
499
-            }
500
-            return true;
501
-        }
502
-
503
-    	return false;
504
-    }
505
-
506
-    /**
507
-     * Check a value from a shortcode to see if true or false.
508
-     * True when value is 1, true, 'true', 'yes'
509
-     *
510
-     * @since 1.07.10
511
-     *
512
-     * @param string $value The value to compare
513
-     * @return boolean True or False
514
-     */
494
+		global $wp_object_cache;
495
+
496
+		if ( isset( $wp_object_cache->cache[ $group ] ) ) {
497
+			foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) {
498
+				wp_cache_delete($k, $group);
499
+			}
500
+			return true;
501
+		}
502
+
503
+		return false;
504
+	}
505
+
506
+	/**
507
+	 * Check a value from a shortcode to see if true or false.
508
+	 * True when value is 1, true, 'true', 'yes'
509
+	 *
510
+	 * @since 1.07.10
511
+	 *
512
+	 * @param string $value The value to compare
513
+	 * @return boolean True or False
514
+	 */
515 515
 	public static function is_true( $value ) {
516
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
517
-    }
516
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
517
+	}
518 518
 
519
-    /**
520
-     * Used to filter shortcode in text widgets
521
-     */
522
-    public static function widget_text_filter_callback( $matches ) {
523
-        return do_shortcode( $matches[0] );
524
-    }
519
+	/**
520
+	 * Used to filter shortcode in text widgets
521
+	 */
522
+	public static function widget_text_filter_callback( $matches ) {
523
+		return do_shortcode( $matches[0] );
524
+	}
525 525
 
526 526
 	public static function load_scripts( $scripts ) {
527
-        _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' );
528
-        foreach ( (array) $scripts as $s ) {
529
-            wp_enqueue_script($s);
530
-        }
531
-    }
527
+		_deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' );
528
+		foreach ( (array) $scripts as $s ) {
529
+			wp_enqueue_script($s);
530
+		}
531
+	}
532 532
 
533 533
 	public static function load_styles( $styles ) {
534
-        _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' );
535
-        foreach ( (array) $styles as $s ) {
536
-            wp_enqueue_style($s);
537
-        }
538
-    }
534
+		_deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' );
535
+		foreach ( (array) $styles as $s ) {
536
+			wp_enqueue_style($s);
537
+		}
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,333 +799,333 @@  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
-    }
820
-
821
-    public static function esc_textarea( $text ) {
822
-        $safe_text = str_replace('&quot;', '"', $text);
823
-        $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
824
-    	return apply_filters( 'esc_textarea', $safe_text, $text );
825
-    }
826
-
827
-    /**
828
-     * Add auto paragraphs to text areas
829
-     * @since 2.0
830
-     */
816
+			}
817
+		}
818
+		return $return;
819
+	}
820
+
821
+	public static function esc_textarea( $text ) {
822
+		$safe_text = str_replace('&quot;', '"', $text);
823
+		$safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
824
+		return apply_filters( 'esc_textarea', $safe_text, $text );
825
+	}
826
+
827
+	/**
828
+	 * Add auto paragraphs to text areas
829
+	 * @since 2.0
830
+	 */
831 831
 	public static function use_wpautop( $content ) {
832
-        if ( apply_filters('frm_use_wpautop', true) ) {
833
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
834
-        }
835
-        return $content;
836
-    }
832
+		if ( apply_filters('frm_use_wpautop', true) ) {
833
+			$content = wpautop(str_replace( '<br>', '<br />', $content));
834
+		}
835
+		return $content;
836
+	}
837 837
 
838 838
 	public static function replace_quotes( $val ) {
839
-        //Replace double quotes
839
+		//Replace double quotes
840 840
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
841
-        //Replace single quotes
842
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
843
-        return $val;
844
-    }
845
-
846
-    /**
847
-     * @since 2.0
848
-     * @return string The base Google APIS url for the current version of jQuery UI
849
-     */
850
-    public static function jquery_ui_base_url() {
841
+		//Replace single quotes
842
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
843
+		return $val;
844
+	}
845
+
846
+	/**
847
+	 * @since 2.0
848
+	 * @return string The base Google APIS url for the current version of jQuery UI
849
+	 */
850
+	public static function jquery_ui_base_url() {
851 851
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core');
852
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
853
-        return $url;
854
-    }
852
+		$url = apply_filters('frm_jquery_ui_base_url', $url);
853
+		return $url;
854
+	}
855 855
 
856
-    /**
857
-     * @param string $handle
858
-     */
856
+	/**
857
+	 * @param string $handle
858
+	 */
859 859
 	public static function script_version( $handle ) {
860
-        global $wp_scripts;
861
-    	if ( ! $wp_scripts ) {
862
-    	    return false;
863
-    	}
860
+		global $wp_scripts;
861
+		if ( ! $wp_scripts ) {
862
+			return false;
863
+		}
864 864
 
865
-        $ver = 0;
865
+		$ver = 0;
866 866
 
867
-        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
868
-            return $ver;
869
-        }
867
+		if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
868
+			return $ver;
869
+		}
870 870
 
871
-        $query = $wp_scripts->registered[ $handle ];
872
-    	if ( is_object( $query ) ) {
873
-    	    $ver = $query->ver;
874
-    	}
871
+		$query = $wp_scripts->registered[ $handle ];
872
+		if ( is_object( $query ) ) {
873
+			$ver = $query->ver;
874
+		}
875 875
 
876
-    	return $ver;
877
-    }
876
+		return $ver;
877
+	}
878 878
 
879 879
 	public static function js_redirect( $url ) {
880 880
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
881
-    }
881
+	}
882 882
 
883 883
 	public static function get_user_id_param( $user_id ) {
884
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
885
-            return $user_id;
886
-        }
884
+		if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
885
+			return $user_id;
886
+		}
887 887
 
888 888
 		if ( $user_id == 'current' ) {
889 889
 			$user_id = get_current_user_id();
890 890
 		} else {
891
-            if ( is_email($user_id) ) {
892
-                $user = get_user_by('email', $user_id);
893
-            } else {
894
-                $user = get_user_by('login', $user_id);
895
-            }
891
+			if ( is_email($user_id) ) {
892
+				$user = get_user_by('email', $user_id);
893
+			} else {
894
+				$user = get_user_by('login', $user_id);
895
+			}
896 896
 
897
-            if ( $user ) {
898
-                $user_id = $user->ID;
899
-            }
900
-            unset($user);
901
-        }
897
+			if ( $user ) {
898
+				$user_id = $user->ID;
899
+			}
900
+			unset($user);
901
+		}
902 902
 
903
-        return $user_id;
904
-    }
903
+		return $user_id;
904
+	}
905 905
 
906 906
 	public static function get_file_contents( $filename, $atts = array() ) {
907
-        if ( ! is_file($filename) ) {
908
-            return false;
909
-        }
910
-
911
-        extract($atts);
912
-        ob_start();
913
-        include($filename);
914
-        $contents = ob_get_contents();
915
-        ob_end_clean();
916
-        return $contents;
917
-    }
918
-
919
-    /**
920
-     * @param string $table_name
921
-     * @param string $column
907
+		if ( ! is_file($filename) ) {
908
+			return false;
909
+		}
910
+
911
+		extract($atts);
912
+		ob_start();
913
+		include($filename);
914
+		$contents = ob_get_contents();
915
+		ob_end_clean();
916
+		return $contents;
917
+	}
918
+
919
+	/**
920
+	 * @param string $table_name
921
+	 * @param string $column
922 922
 	 * @param int $id
923 923
 	 * @param int $num_chars
924
-     */
925
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
926
-        $key = '';
924
+	 */
925
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
926
+		$key = '';
927 927
 
928
-        if ( ! empty( $name ) ) {
929
-            $key = sanitize_key($name);
930
-        }
928
+		if ( ! empty( $name ) ) {
929
+			$key = sanitize_key($name);
930
+		}
931 931
 
932 932
 		if ( empty( $key ) ) {
933
-            $max_slug_value = pow(36, $num_chars);
934
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
935
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
936
-        }
933
+			$max_slug_value = pow(36, $num_chars);
934
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
935
+			$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
936
+		}
937 937
 
938 938
 		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
939 939
 			$key = $key . 'a';
940
-        }
940
+		}
941 941
 
942 942
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
943 943
 
944
-        if ( $key_check || is_numeric($key_check) ) {
945
-            $suffix = 2;
944
+		if ( $key_check || is_numeric($key_check) ) {
945
+			$suffix = 2;
946 946
 			do {
947 947
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
948 948
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
949 949
 				$suffix++;
950 950
 			} while ($key_check || is_numeric($key_check));
951 951
 			$key = $alt_post_name;
952
-        }
953
-        return $key;
954
-    }
955
-
956
-    /**
957
-     * Editing a Form or Entry
958
-     * @param string $table
959
-     * @return bool|array
960
-     */
961
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
962
-        if ( ! $record ) {
963
-            return false;
964
-        }
965
-
966
-        if ( empty($post_values) ) {
967
-            $post_values = stripslashes_deep($_POST);
968
-        }
952
+		}
953
+		return $key;
954
+	}
955
+
956
+	/**
957
+	 * Editing a Form or Entry
958
+	 * @param string $table
959
+	 * @return bool|array
960
+	 */
961
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
962
+		if ( ! $record ) {
963
+			return false;
964
+		}
965
+
966
+		if ( empty($post_values) ) {
967
+			$post_values = stripslashes_deep($_POST);
968
+		}
969 969
 
970 970
 		$values = array( 'id' => $record->id, 'fields' => array() );
971 971
 
972 972
 		foreach ( array( 'name', 'description' ) as $var ) {
973
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
973
+			$default_val = isset($record->{$var}) ? $record->{$var} : '';
974 974
 			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
975
-            unset($var, $default_val);
976
-        }
977
-
978
-        $values['description'] = self::use_wpautop($values['description']);
979
-        $frm_settings = self::get_settings();
980
-        $is_form_builder = self::is_admin_page('formidable' );
981
-
982
-        foreach ( (array) $fields as $field ) {
983
-            // Make sure to filter default values (for placeholder text), but not on the form builder page
984
-            if ( ! $is_form_builder ) {
985
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
986
-            }
975
+			unset($var, $default_val);
976
+		}
977
+
978
+		$values['description'] = self::use_wpautop($values['description']);
979
+		$frm_settings = self::get_settings();
980
+		$is_form_builder = self::is_admin_page('formidable' );
981
+
982
+		foreach ( (array) $fields as $field ) {
983
+			// Make sure to filter default values (for placeholder text), but not on the form builder page
984
+			if ( ! $is_form_builder ) {
985
+				$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
986
+			}
987 987
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
988 988
 			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
989
-        }
989
+		}
990 990
 
991
-        self::fill_form_opts($record, $table, $post_values, $values);
991
+		self::fill_form_opts($record, $table, $post_values, $values);
992 992
 
993
-        if ( $table == 'entries' ) {
994
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
995
-        } else if ( $table == 'forms' ) {
996
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
997
-        }
993
+		if ( $table == 'entries' ) {
994
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
995
+		} else if ( $table == 'forms' ) {
996
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
997
+		}
998 998
 
999
-        return $values;
1000
-    }
999
+		return $values;
1000
+	}
1001 1001
 
1002 1002
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
1003
-        $post_values = $args['post_values'];
1004
-
1005
-        if ( $args['default'] ) {
1006
-            $meta_value = $field->default_value;
1007
-        } else {
1008
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1009
-                if ( ! isset($field->field_options['custom_field']) ) {
1010
-                    $field->field_options['custom_field'] = '';
1011
-                }
1003
+		$post_values = $args['post_values'];
1004
+
1005
+		if ( $args['default'] ) {
1006
+			$meta_value = $field->default_value;
1007
+		} else {
1008
+			if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1009
+				if ( ! isset($field->field_options['custom_field']) ) {
1010
+					$field->field_options['custom_field'] = '';
1011
+				}
1012 1012
 				$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 ) );
1013
-            } else {
1013
+			} else {
1014 1014
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1015
-            }
1016
-        }
1015
+			}
1016
+		}
1017 1017
 
1018 1018
 		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1019
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1020
-
1021
-        $field_array = array(
1022
-            'id'            => $field->id,
1023
-            'value'         => $new_value,
1024
-            'default_value' => $field->default_value,
1025
-            'name'          => $field->name,
1026
-            'description'   => $field->description,
1027
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1028
-            'options'       => $field->options,
1029
-            'required'      => $field->required,
1030
-            'field_key'     => $field->field_key,
1031
-            'field_order'   => $field->field_order,
1032
-            'form_id'       => $field->form_id,
1019
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1020
+
1021
+		$field_array = array(
1022
+			'id'            => $field->id,
1023
+			'value'         => $new_value,
1024
+			'default_value' => $field->default_value,
1025
+			'name'          => $field->name,
1026
+			'description'   => $field->description,
1027
+			'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1028
+			'options'       => $field->options,
1029
+			'required'      => $field->required,
1030
+			'field_key'     => $field->field_key,
1031
+			'field_order'   => $field->field_order,
1032
+			'form_id'       => $field->form_id,
1033 1033
 			'parent_form_id' => $args['parent_form_id'],
1034
-        );
1034
+		);
1035 1035
 
1036
-        $args['field_type'] = $field_type;
1037
-        self::fill_field_opts($field, $field_array, $args);
1036
+		$args['field_type'] = $field_type;
1037
+		self::fill_field_opts($field, $field_array, $args);
1038 1038
 		// Track the original field's type
1039 1039
 		$field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type;
1040 1040
 
1041
-        $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1041
+		$field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1042 1042
 
1043
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1044
-            $field_array['unique_msg'] = '';
1045
-        }
1043
+		if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1044
+			$field_array['unique_msg'] = '';
1045
+		}
1046 1046
 
1047
-        $field_array = array_merge( $field->field_options, $field_array );
1047
+		$field_array = array_merge( $field->field_options, $field_array );
1048 1048
 
1049
-        $values['fields'][ $field->id ] = $field_array;
1050
-    }
1049
+		$values['fields'][ $field->id ] = $field_array;
1050
+	}
1051 1051
 
1052 1052
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1053
-        $post_values = $args['post_values'];
1054
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1053
+		$post_values = $args['post_values'];
1054
+		$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1055 1055
 
1056
-        foreach ( $opt_defaults as $opt => $default_opt ) {
1056
+		foreach ( $opt_defaults as $opt => $default_opt ) {
1057 1057
 			$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 );
1058
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1059
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1060
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1061
-                if ( $args['field_type'] == 'captcha' ) {
1062
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1063
-                } else {
1064
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1065
-                }
1066
-            }
1067
-        }
1068
-
1069
-        if ( $field_array['custom_html'] == '' ) {
1070
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1071
-        }
1072
-    }
1073
-
1074
-    /**
1075
-     * @param string $table
1076
-     */
1058
+			if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1059
+				$field_array[ $opt ] = $args['frm_settings']->blank_msg;
1060
+			} else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1061
+				if ( $args['field_type'] == 'captcha' ) {
1062
+					$field_array[ $opt ] = $args['frm_settings']->re_msg;
1063
+				} else {
1064
+					$field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1065
+				}
1066
+			}
1067
+		}
1068
+
1069
+		if ( $field_array['custom_html'] == '' ) {
1070
+			$field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1071
+		}
1072
+	}
1073
+
1074
+	/**
1075
+	 * @param string $table
1076
+	 */
1077 1077
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1078
-        if ( $table == 'entries' ) {
1079
-            $form = $record->form_id;
1078
+		if ( $table == 'entries' ) {
1079
+			$form = $record->form_id;
1080 1080
 			FrmForm::maybe_get_form( $form );
1081
-        } else {
1082
-            $form = $record;
1083
-        }
1081
+		} else {
1082
+			$form = $record;
1083
+		}
1084 1084
 
1085
-        if ( ! $form ) {
1086
-            return;
1087
-        }
1085
+		if ( ! $form ) {
1086
+			return;
1087
+		}
1088 1088
 
1089
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1089
+		$values['form_name'] = isset($record->form_id) ? $form->name : '';
1090 1090
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1091 1091
 
1092
-        if ( ! is_array($form->options) ) {
1093
-            return;
1094
-        }
1092
+		if ( ! is_array($form->options) ) {
1093
+			return;
1094
+		}
1095 1095
 
1096
-        foreach ( $form->options as $opt => $value ) {
1097
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1098
-        }
1096
+		foreach ( $form->options as $opt => $value ) {
1097
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1098
+		}
1099 1099
 
1100
-        self::fill_form_defaults($post_values, $values);
1101
-    }
1100
+		self::fill_form_defaults($post_values, $values);
1101
+	}
1102 1102
 
1103
-    /**
1104
-     * Set to POST value or default
1105
-     */
1103
+	/**
1104
+	 * Set to POST value or default
1105
+	 */
1106 1106
 	private static function fill_form_defaults( $post_values, array &$values ) {
1107
-        $form_defaults = FrmFormsHelper::get_default_opts();
1107
+		$form_defaults = FrmFormsHelper::get_default_opts();
1108 1108
 
1109
-        foreach ( $form_defaults as $opt => $default ) {
1110
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1109
+		foreach ( $form_defaults as $opt => $default ) {
1110
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1111 1111
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1112
-            }
1112
+			}
1113 1113
 
1114
-            unset($opt, $defaut);
1115
-        }
1114
+			unset($opt, $defaut);
1115
+		}
1116 1116
 
1117
-        if ( ! isset($values['custom_style']) ) {
1118
-            $frm_settings = self::get_settings();
1117
+		if ( ! isset($values['custom_style']) ) {
1118
+			$frm_settings = self::get_settings();
1119 1119
 			$values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' );
1120
-        }
1120
+		}
1121 1121
 
1122 1122
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1123 1123
 			if ( ! isset( $values[ $h . '_html' ] ) ) {
1124 1124
 				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1125
-            }
1126
-            unset($h);
1127
-        }
1128
-    }
1125
+			}
1126
+			unset($h);
1127
+		}
1128
+	}
1129 1129
 
1130 1130
 	public static function get_meta_value( $field_id, $entry ) {
1131 1131
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryMeta::get_meta_value' );
@@ -1133,69 +1133,69 @@  discard block
 block discarded – undo
1133 1133
 	}
1134 1134
 
1135 1135
 	public static function insert_opt_html( $args ) {
1136
-        $class = '';
1137
-        if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1138
-            $class .= 'show_frm_not_email_to';
1139
-        }
1140
-    ?>
1136
+		$class = '';
1137
+		if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1138
+			$class .= 'show_frm_not_email_to';
1139
+		}
1140
+	?>
1141 1141
 <li>
1142 1142
     <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>
1143 1143
     <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>
1144 1144
     <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 1145
 </li>
1146 1146
     <?php
1147
-    }
1147
+	}
1148 1148
 
1149
-    public static function get_us_states() {
1150
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_us_states' );
1151
-        return FrmFieldsHelper::get_us_states();
1152
-    }
1149
+	public static function get_us_states() {
1150
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_us_states' );
1151
+		return FrmFieldsHelper::get_us_states();
1152
+	}
1153 1153
 
1154
-    public static function get_countries() {
1155
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries' );
1156
-        return FrmFieldsHelper::get_countries();
1157
-    }
1154
+	public static function get_countries() {
1155
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries' );
1156
+		return FrmFieldsHelper::get_countries();
1157
+	}
1158 1158
 
1159 1159
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1160
-        if ( is_array( $str ) ) {
1161
-            return '';
1160
+		if ( is_array( $str ) ) {
1161
+			return '';
1162 1162
 		}
1163 1163
 
1164
-        $length = (int) $length;
1164
+		$length = (int) $length;
1165 1165
 		$str = wp_strip_all_tags( $str );
1166 1166
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1167 1167
 
1168 1168
 		if ( $length == 0 ) {
1169
-            return '';
1170
-        } else if ( $length <= 10 ) {
1169
+			return '';
1170
+		} else if ( $length <= 10 ) {
1171 1171
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1172
-            return $sub . (($length < $original_len) ? $continue : '');
1173
-        }
1172
+			return $sub . (($length < $original_len) ? $continue : '');
1173
+		}
1174 1174
 
1175
-        $sub = '';
1176
-        $len = 0;
1175
+		$sub = '';
1176
+		$len = 0;
1177 1177
 
1178 1178
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1179 1179
 
1180 1180
 		foreach ( $words as $word ) {
1181
-            $part = (($sub != '') ? ' ' : '') . $word;
1181
+			$part = (($sub != '') ? ' ' : '') . $word;
1182 1182
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1183
-            if ( $total_len > $length && str_word_count($sub) ) {
1184
-                break;
1185
-            }
1183
+			if ( $total_len > $length && str_word_count($sub) ) {
1184
+				break;
1185
+			}
1186 1186
 
1187
-            $sub .= $part;
1187
+			$sub .= $part;
1188 1188
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1189 1189
 
1190
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1191
-                break;
1192
-            }
1190
+			if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1191
+				break;
1192
+			}
1193 1193
 
1194
-            unset($total_len, $word);
1195
-        }
1194
+			unset($total_len, $word);
1195
+		}
1196 1196
 
1197
-        return $sub . (($len < $original_len) ? $continue : '');
1198
-    }
1197
+		return $sub . (($len < $original_len) ? $continue : '');
1198
+	}
1199 1199
 
1200 1200
 	public static function mb_function( $function_names, $args ) {
1201 1201
 		$mb_function_name = $function_names[0];
@@ -1207,18 +1207,18 @@  discard block
 block discarded – undo
1207 1207
 	}
1208 1208
 
1209 1209
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1210
-        if ( empty($date) ) {
1211
-            return $date;
1212
-        }
1210
+		if ( empty($date) ) {
1211
+			return $date;
1212
+		}
1213 1213
 
1214
-        if ( empty($date_format) ) {
1215
-            $date_format = get_option('date_format');
1216
-        }
1214
+		if ( empty($date_format) ) {
1215
+			$date_format = get_option('date_format');
1216
+		}
1217 1217
 
1218
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1219
-            $frmpro_settings = new FrmProSettings();
1220
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1221
-        }
1218
+		if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1219
+			$frmpro_settings = new FrmProSettings();
1220
+			$date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1221
+		}
1222 1222
 
1223 1223
 		$formatted = self::get_localized_date( $date_format, $date );
1224 1224
 
@@ -1227,8 +1227,8 @@  discard block
 block discarded – undo
1227 1227
 			$formatted .= self::add_time_to_date( $time_format, $date );
1228 1228
 		}
1229 1229
 
1230
-        return $formatted;
1231
-    }
1230
+		return $formatted;
1231
+	}
1232 1232
 
1233 1233
 	private static function add_time_to_date( $time_format, $date ) {
1234 1234
 		if ( empty( $time_format ) ) {
@@ -1309,61 +1309,61 @@  discard block
 block discarded – undo
1309 1309
 		);
1310 1310
 	}
1311 1311
 
1312
-    /**
1313
-     * Added for < WP 4.0 compatability
1314
-     *
1315
-     * @since 1.07.10
1316
-     *
1317
-     * @param string $term The value to escape
1318
-     * @return string The escaped value
1319
-     */
1312
+	/**
1313
+	 * Added for < WP 4.0 compatability
1314
+	 *
1315
+	 * @since 1.07.10
1316
+	 *
1317
+	 * @param string $term The value to escape
1318
+	 * @return string The escaped value
1319
+	 */
1320 1320
 	public static function esc_like( $term ) {
1321
-        global $wpdb;
1322
-        if ( method_exists($wpdb, 'esc_like') ) {
1321
+		global $wpdb;
1322
+		if ( method_exists($wpdb, 'esc_like') ) {
1323 1323
 			// WP 4.0
1324
-            $term = $wpdb->esc_like( $term );
1325
-        } else {
1326
-            $term = like_escape( $term );
1327
-        }
1324
+			$term = $wpdb->esc_like( $term );
1325
+		} else {
1326
+			$term = like_escape( $term );
1327
+		}
1328 1328
 
1329
-        return $term;
1330
-    }
1329
+		return $term;
1330
+	}
1331 1331
 
1332
-    /**
1333
-     * @param string $order_query
1334
-     */
1332
+	/**
1333
+	 * @param string $order_query
1334
+	 */
1335 1335
 	public static function esc_order( $order_query ) {
1336
-        if ( empty($order_query) ) {
1337
-            return '';
1338
-        }
1339
-
1340
-        // remove ORDER BY before santizing
1341
-        $order_query = strtolower($order_query);
1342
-        if ( strpos($order_query, 'order by') !== false ) {
1343
-            $order_query = str_replace('order by', '', $order_query);
1344
-        }
1345
-
1346
-        $order_query = explode(' ', trim($order_query));
1347
-
1348
-        $order_fields = array(
1349
-            'id', 'form_key', 'name', 'description',
1350
-            'parent_form_id', 'logged_in', 'is_template',
1351
-            'default_template', 'status', 'created_at',
1352
-        );
1353
-
1354
-        $order = trim(trim(reset($order_query), ','));
1355
-        if ( ! in_array($order, $order_fields) ) {
1356
-            return '';
1357
-        }
1358
-
1359
-        $order_by = '';
1360
-        if ( count($order_query) > 1 ) {
1336
+		if ( empty($order_query) ) {
1337
+			return '';
1338
+		}
1339
+
1340
+		// remove ORDER BY before santizing
1341
+		$order_query = strtolower($order_query);
1342
+		if ( strpos($order_query, 'order by') !== false ) {
1343
+			$order_query = str_replace('order by', '', $order_query);
1344
+		}
1345
+
1346
+		$order_query = explode(' ', trim($order_query));
1347
+
1348
+		$order_fields = array(
1349
+			'id', 'form_key', 'name', 'description',
1350
+			'parent_form_id', 'logged_in', 'is_template',
1351
+			'default_template', 'status', 'created_at',
1352
+		);
1353
+
1354
+		$order = trim(trim(reset($order_query), ','));
1355
+		if ( ! in_array($order, $order_fields) ) {
1356
+			return '';
1357
+		}
1358
+
1359
+		$order_by = '';
1360
+		if ( count($order_query) > 1 ) {
1361 1361
 			$order_by = end( $order_query );
1362 1362
 			self::esc_order_by( $order_by );
1363
-        }
1363
+		}
1364 1364
 
1365 1365
 		return ' ORDER BY ' . $order . ' ' . $order_by;
1366
-    }
1366
+	}
1367 1367
 
1368 1368
 	/**
1369 1369
 	 * Make sure this is ordering by either ASC or DESC
@@ -1375,183 +1375,183 @@  discard block
 block discarded – undo
1375 1375
 		}
1376 1376
 	}
1377 1377
 
1378
-    /**
1379
-     * @param string $limit
1380
-     */
1378
+	/**
1379
+	 * @param string $limit
1380
+	 */
1381 1381
 	public static function esc_limit( $limit ) {
1382
-        if ( empty($limit) ) {
1383
-            return '';
1384
-        }
1382
+		if ( empty($limit) ) {
1383
+			return '';
1384
+		}
1385 1385
 
1386
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1387
-        if ( is_numeric($limit) ) {
1386
+		$limit = trim(str_replace(' limit', '', strtolower($limit)));
1387
+		if ( is_numeric($limit) ) {
1388 1388
 			return ' LIMIT ' . $limit;
1389
-        }
1389
+		}
1390 1390
 
1391
-        $limit = explode(',', trim($limit));
1392
-        foreach ( $limit as $k => $l ) {
1393
-            if ( is_numeric( $l ) ) {
1394
-                $limit[ $k ] = $l;
1395
-            }
1396
-        }
1391
+		$limit = explode(',', trim($limit));
1392
+		foreach ( $limit as $k => $l ) {
1393
+			if ( is_numeric( $l ) ) {
1394
+				$limit[ $k ] = $l;
1395
+			}
1396
+		}
1397 1397
 
1398
-        $limit = implode(',', $limit);
1398
+		$limit = implode(',', $limit);
1399 1399
 		return ' LIMIT ' . $limit;
1400
-    }
1401
-
1402
-    /**
1403
-     * Get an array of values ready to go through $wpdb->prepare
1404
-     * @since 2.0
1405
-     */
1406
-    public static function prepare_array_values( $array, $type = '%s' ) {
1407
-        $placeholders = array_fill(0, count($array), $type);
1408
-        return implode(', ', $placeholders);
1409
-    }
1410
-
1411
-    public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1412
-        if ( empty($where) ) {
1413
-            return '';
1414
-        }
1400
+	}
1401
+
1402
+	/**
1403
+	 * Get an array of values ready to go through $wpdb->prepare
1404
+	 * @since 2.0
1405
+	 */
1406
+	public static function prepare_array_values( $array, $type = '%s' ) {
1407
+		$placeholders = array_fill(0, count($array), $type);
1408
+		return implode(', ', $placeholders);
1409
+	}
1410
+
1411
+	public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1412
+		if ( empty($where) ) {
1413
+			return '';
1414
+		}
1415 1415
 
1416 1416
 		if ( is_array( $where ) ) {
1417
-            global $wpdb;
1418
-            FrmDb::get_where_clause_and_values( $where, $starts_with );
1417
+			global $wpdb;
1418
+			FrmDb::get_where_clause_and_values( $where, $starts_with );
1419 1419
 			$where = $wpdb->prepare( $where['where'], $where['values'] );
1420 1420
 		} else {
1421
-            $where = $starts_with . $where;
1422
-        }
1421
+			$where = $starts_with . $where;
1422
+		}
1423 1423
 
1424
-        return $where;
1425
-    }
1424
+		return $where;
1425
+	}
1426 1426
 
1427
-    // Pagination Methods
1427
+	// Pagination Methods
1428 1428
 
1429
-    /**
1430
-     * @param integer $current_p
1431
-     */
1429
+	/**
1430
+	 * @param integer $current_p
1431
+	 */
1432 1432
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1433 1433
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1434 1434
 	}
1435 1435
 
1436
-    /**
1437
-     * @param integer $current_p
1438
-     */
1439
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1440
-        if ( $current_p == 1 ) {
1441
-            return 1;
1442
-        } else {
1443
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1444
-        }
1445
-    }
1446
-
1447
-    /**
1448
-     * @param string $table_name
1449
-     */
1450
-    public static function &getRecordCount( $where = '', $table_name ) {
1451
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_count' );
1452
-        $count = FrmDb::get_count( $table_name, $where );
1453
-        return $count;
1454
-    }
1455
-
1456
-    public static function get_referer_info() {
1457
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' );
1458
-        return self::get_server_value('HTTP_REFERER');
1459
-    }
1436
+	/**
1437
+	 * @param integer $current_p
1438
+	 */
1439
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1440
+		if ( $current_p == 1 ) {
1441
+			return 1;
1442
+		} else {
1443
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1444
+		}
1445
+	}
1446
+
1447
+	/**
1448
+	 * @param string $table_name
1449
+	 */
1450
+	public static function &getRecordCount( $where = '', $table_name ) {
1451
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_count' );
1452
+		$count = FrmDb::get_count( $table_name, $where );
1453
+		return $count;
1454
+	}
1455
+
1456
+	public static function get_referer_info() {
1457
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' );
1458
+		return self::get_server_value('HTTP_REFERER');
1459
+	}
1460 1460
 
1461 1461
 	/**
1462 1462
 	 * @return array
1463 1463
 	 */
1464 1464
 	public static function json_to_array( $json_vars ) {
1465
-        $vars = array();
1466
-        foreach ( $json_vars as $jv ) {
1467
-            $jv_name = explode('[', $jv['name']);
1468
-            $last = count($jv_name) - 1;
1469
-            foreach ( $jv_name as $p => $n ) {
1470
-                $name = trim($n, ']');
1471
-                if ( ! isset($l1) ) {
1472
-                    $l1 = $name;
1473
-                }
1474
-
1475
-                if ( ! isset($l2) ) {
1476
-                    $l2 = $name;
1477
-                }
1478
-
1479
-                if ( ! isset($l3) ) {
1480
-                    $l3 = $name;
1481
-                }
1482
-
1483
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1484
-
1485
-                switch ( $p ) {
1486
-                    case 0:
1487
-                        $l1 = $name;
1488
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1489
-                    break;
1490
-
1491
-                    case 1:
1492
-                        $l2 = $name;
1493
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1494
-                    break;
1495
-
1496
-                    case 2:
1497
-                        $l3 = $name;
1498
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1499
-                    break;
1500
-
1501
-                    case 3:
1502
-                        $l4 = $name;
1503
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1504
-                    break;
1505
-                }
1506
-
1507
-                unset($this_val, $n);
1508
-            }
1509
-
1510
-            unset($last, $jv);
1511
-        }
1512
-
1513
-        return $vars;
1514
-    }
1515
-
1516
-    /**
1517
-     * @param string $name
1518
-     * @param string $l1
1519
-     */
1520
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1521
-        if ( $name == '' ) {
1522
-            $vars[] = $val;
1523
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1524
-            $vars[ $l1 ] = $val;
1525
-        }
1526
-    }
1465
+		$vars = array();
1466
+		foreach ( $json_vars as $jv ) {
1467
+			$jv_name = explode('[', $jv['name']);
1468
+			$last = count($jv_name) - 1;
1469
+			foreach ( $jv_name as $p => $n ) {
1470
+				$name = trim($n, ']');
1471
+				if ( ! isset($l1) ) {
1472
+					$l1 = $name;
1473
+				}
1474
+
1475
+				if ( ! isset($l2) ) {
1476
+					$l2 = $name;
1477
+				}
1478
+
1479
+				if ( ! isset($l3) ) {
1480
+					$l3 = $name;
1481
+				}
1482
+
1483
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1484
+
1485
+				switch ( $p ) {
1486
+					case 0:
1487
+						$l1 = $name;
1488
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1489
+					break;
1490
+
1491
+					case 1:
1492
+						$l2 = $name;
1493
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1494
+					break;
1495
+
1496
+					case 2:
1497
+						$l3 = $name;
1498
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1499
+					break;
1500
+
1501
+					case 3:
1502
+						$l4 = $name;
1503
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1504
+					break;
1505
+				}
1506
+
1507
+				unset($this_val, $n);
1508
+			}
1509
+
1510
+			unset($last, $jv);
1511
+		}
1512
+
1513
+		return $vars;
1514
+	}
1515
+
1516
+	/**
1517
+	 * @param string $name
1518
+	 * @param string $l1
1519
+	 */
1520
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1521
+		if ( $name == '' ) {
1522
+			$vars[] = $val;
1523
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1524
+			$vars[ $l1 ] = $val;
1525
+		}
1526
+	}
1527 1527
 
1528 1528
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1529
-        $tooltips = array(
1530
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1531
-            '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' ),
1532
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1533
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1534
-            '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' ),
1535
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1536
-            '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() ) ),
1537
-        );
1538
-
1539
-        if ( ! isset( $tooltips[ $name ] ) ) {
1540
-            return;
1541
-        }
1542
-
1543
-        if ( 'open' == $class ) {
1544
-            echo ' frm_help"';
1545
-        } else {
1546
-            echo ' class="frm_help"';
1547
-        }
1529
+		$tooltips = array(
1530
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1531
+			'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' ),
1532
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1533
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1534
+			'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' ),
1535
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1536
+			'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() ) ),
1537
+		);
1538
+
1539
+		if ( ! isset( $tooltips[ $name ] ) ) {
1540
+			return;
1541
+		}
1542
+
1543
+		if ( 'open' == $class ) {
1544
+			echo ' frm_help"';
1545
+		} else {
1546
+			echo ' class="frm_help"';
1547
+		}
1548 1548
 
1549 1549
 		echo ' title="' . esc_attr( $tooltips[ $name ] );
1550 1550
 
1551
-        if ( 'open' != $class ) {
1552
-            echo '"';
1553
-        }
1554
-    }
1551
+		if ( 'open' != $class ) {
1552
+			echo '"';
1553
+		}
1554
+	}
1555 1555
 
1556 1556
 	/**
1557 1557
 	 * Add the current_page class to that page in the form nav
@@ -1567,35 +1567,35 @@  discard block
 block discarded – undo
1567 1567
 		}
1568 1568
 	}
1569 1569
 
1570
-    /**
1571
-     * Prepare and json_encode post content
1572
-     *
1573
-     * @since 2.0
1574
-     *
1575
-     * @param array $post_content
1576
-     * @return string $post_content ( json encoded array )
1577
-     */
1578
-    public static function prepare_and_encode( $post_content ) {
1579
-        //Loop through array to strip slashes and add only the needed ones
1570
+	/**
1571
+	 * Prepare and json_encode post content
1572
+	 *
1573
+	 * @since 2.0
1574
+	 *
1575
+	 * @param array $post_content
1576
+	 * @return string $post_content ( json encoded array )
1577
+	 */
1578
+	public static function prepare_and_encode( $post_content ) {
1579
+		//Loop through array to strip slashes and add only the needed ones
1580 1580
 		foreach ( $post_content as $key => $val ) {
1581 1581
 			// Replace problematic characters (like &quot;)
1582 1582
 			$val = str_replace( '&quot;', '"', $val );
1583 1583
 
1584 1584
 			self::prepare_action_slashes( $val, $key, $post_content );
1585
-            unset( $key, $val );
1586
-        }
1585
+			unset( $key, $val );
1586
+		}
1587 1587
 
1588
-        // json_encode the array
1589
-        $post_content = json_encode( $post_content );
1588
+		// json_encode the array
1589
+		$post_content = json_encode( $post_content );
1590 1590
 
1591
-	    // add extra slashes for \r\n since WP strips them
1591
+		// add extra slashes for \r\n since WP strips them
1592 1592
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1593 1593
 
1594
-        // allow for &quot
1595
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1594
+		// allow for &quot
1595
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1596 1596
 
1597
-        return $post_content;
1598
-    }
1597
+		return $post_content;
1598
+	}
1599 1599
 
1600 1600
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1601 1601
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1663,64 +1663,64 @@  discard block
 block discarded – undo
1663 1663
 	}
1664 1664
 
1665 1665
 	public static function maybe_json_decode( $string ) {
1666
-        if ( is_array($string) ) {
1667
-            return $string;
1668
-        }
1666
+		if ( is_array($string) ) {
1667
+			return $string;
1668
+		}
1669 1669
 
1670
-        $new_string = json_decode($string, true);
1671
-        if ( function_exists('json_last_error') ) {
1670
+		$new_string = json_decode($string, true);
1671
+		if ( function_exists('json_last_error') ) {
1672 1672
 			// php 5.3+
1673
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1674
-                $string = $new_string;
1675
-            }
1676
-        } else if ( isset($new_string) ) {
1673
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1674
+				$string = $new_string;
1675
+			}
1676
+		} else if ( isset($new_string) ) {
1677 1677
 			// php < 5.3 fallback
1678
-            $string = $new_string;
1679
-        }
1680
-        return $string;
1681
-    }
1682
-
1683
-    /**
1684
-     * @since 1.07.10
1685
-     *
1686
-     * @param string $post_type The name of the post type that may need to be highlighted
1687
-     * echo The javascript to open and highlight the Formidable menu
1688
-     */
1678
+			$string = $new_string;
1679
+		}
1680
+		return $string;
1681
+	}
1682
+
1683
+	/**
1684
+	 * @since 1.07.10
1685
+	 *
1686
+	 * @param string $post_type The name of the post type that may need to be highlighted
1687
+	 * echo The javascript to open and highlight the Formidable menu
1688
+	 */
1689 1689
 	public static function maybe_highlight_menu( $post_type ) {
1690
-        global $post;
1690
+		global $post;
1691 1691
 
1692
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1693
-            return;
1694
-        }
1692
+		if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1693
+			return;
1694
+		}
1695 1695
 
1696
-        if ( is_object($post) && $post->post_type != $post_type ) {
1697
-            return;
1698
-        }
1696
+		if ( is_object($post) && $post->post_type != $post_type ) {
1697
+			return;
1698
+		}
1699 1699
 
1700
-        self::load_admin_wide_js();
1701
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1702
-    }
1700
+		self::load_admin_wide_js();
1701
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1702
+	}
1703 1703
 
1704
-    /**
1705
-     * Load the JS file on non-Formidable pages in the admin area
1706
-     * @since 2.0
1707
-     */
1704
+	/**
1705
+	 * Load the JS file on non-Formidable pages in the admin area
1706
+	 * @since 2.0
1707
+	 */
1708 1708
 	public static function load_admin_wide_js( $load = true ) {
1709
-        $version = FrmAppHelper::plugin_version();
1709
+		$version = FrmAppHelper::plugin_version();
1710 1710
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1711 1711
 
1712
-        wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1712
+		wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1713 1713
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1714
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1714
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1715 1715
 			'url'          => FrmAppHelper::plugin_url(),
1716 1716
 			'loading'      => __( 'Loading&hellip;' ),
1717 1717
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
1718
-        ) );
1718
+		) );
1719 1719
 
1720 1720
 		if ( $load ) {
1721 1721
 			wp_enqueue_script( 'formidable_admin_global' );
1722 1722
 		}
1723
-    }
1723
+	}
1724 1724
 
1725 1725
 	/**
1726 1726
 	 * @since 2.0.9
@@ -1729,9 +1729,9 @@  discard block
 block discarded – undo
1729 1729
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1730 1730
 	}
1731 1731
 
1732
-    /**
1733
-     * @param string $location
1734
-     */
1732
+	/**
1733
+	 * @param string $location
1734
+	 */
1735 1735
 	public static function localize_script( $location ) {
1736 1736
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1737 1737
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1782,81 +1782,81 @@  discard block
 block discarded – undo
1782 1782
 		}
1783 1783
 	}
1784 1784
 
1785
-    /**
1785
+	/**
1786 1786
 	 * echo the message on the plugins listing page
1787
-     * @since 1.07.10
1788
-     *
1789
-     * @param float $min_version The version the add-on requires
1790
-     */
1787
+	 * @since 1.07.10
1788
+	 *
1789
+	 * @param float $min_version The version the add-on requires
1790
+	 */
1791 1791
 	public static function min_version_notice( $min_version ) {
1792
-        $frm_version = self::plugin_version();
1792
+		$frm_version = self::plugin_version();
1793 1793
 
1794
-        // check if Formidable meets minimum requirements
1795
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1796
-            return;
1797
-        }
1794
+		// check if Formidable meets minimum requirements
1795
+		if ( version_compare($frm_version, $min_version, '>=') ) {
1796
+			return;
1797
+		}
1798 1798
 
1799
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1799
+		$wp_list_table = _get_list_table('WP_Plugins_List_Table');
1800 1800
 		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">' .
1801
-        __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1802
-        '</div></td></tr>';
1803
-    }
1804
-
1805
-    public static function locales( $type = 'date' ) {
1806
-        $locales = array(
1807
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1808
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1809
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1810
-            'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1811
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1812
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1813
-            'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1814
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1815
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1816
-            'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1817
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1818
-            'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1819
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1820
-            'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1821
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1822
-            'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1823
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1824
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1825
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1826
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1827
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1828
-            'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1829
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1830
-            'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1831
-            'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1832
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1833
-            'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1834
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1835
-            'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1836
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1837
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1838
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1839
-        );
1840
-
1841
-        if ( $type == 'captcha' ) {
1842
-            // remove the languages unavailable for the captcha
1843
-            $unset = array(
1844
-                '', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1845
-                'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1846
-                'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1847
-            );
1848
-        } else {
1849
-            // remove the languages unavailable for the datepicker
1850
-            $unset = array(
1851
-                'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1852
-                'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1853
-                'es-419', 'tr',
1854
-            );
1855
-        }
1856
-
1857
-        $locales = array_diff_key($locales, array_flip($unset));
1858
-        $locales = apply_filters('frm_locales', $locales);
1859
-
1860
-        return $locales;
1861
-    }
1801
+		__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1802
+		'</div></td></tr>';
1803
+	}
1804
+
1805
+	public static function locales( $type = 'date' ) {
1806
+		$locales = array(
1807
+			'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1808
+			'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1809
+			'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1810
+			'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1811
+			'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1812
+			'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1813
+			'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1814
+			'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1815
+			'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1816
+			'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1817
+			'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1818
+			'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1819
+			'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1820
+			'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1821
+			'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1822
+			'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1823
+			'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1824
+			'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1825
+			'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1826
+			'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1827
+			'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1828
+			'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1829
+			'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1830
+			'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1831
+			'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1832
+			'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1833
+			'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1834
+			'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1835
+			'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1836
+			'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1837
+			'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1838
+			'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1839
+		);
1840
+
1841
+		if ( $type == 'captcha' ) {
1842
+			// remove the languages unavailable for the captcha
1843
+			$unset = array(
1844
+				'', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1845
+				'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1846
+				'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1847
+			);
1848
+		} else {
1849
+			// remove the languages unavailable for the datepicker
1850
+			$unset = array(
1851
+				'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1852
+				'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1853
+				'es-419', 'tr',
1854
+			);
1855
+		}
1856
+
1857
+		$locales = array_diff_key($locales, array_flip($unset));
1858
+		$locales = apply_filters('frm_locales', $locales);
1859
+
1860
+		return $locales;
1861
+	}
1862 1862
 }
Please login to merge, or discard this patch.
Spacing   +214 added lines, -214 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 ) {
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	}
67 67
 
68 68
 	public static function get_affiliate() {
69
-		$affiliate_id = apply_filters( 'frm_affiliate_link', get_option('frm_aff') );
69
+		$affiliate_id = apply_filters( 'frm_affiliate_link', get_option( 'frm_aff' ) );
70 70
 		$affiliate_id = strtolower( $affiliate_id );
71 71
 		$allowed_affiliates = array( 'mojo' );
72 72
 		if ( ! in_array( $affiliate_id, $allowed_affiliates ) ) {
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public static function get_settings() {
87 87
         global $frm_settings;
88
-        if ( empty($frm_settings) ) {
88
+        if ( empty( $frm_settings ) ) {
89 89
             $frm_settings = new FrmSettings();
90 90
         }
91 91
         return $frm_settings;
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
     }
107 107
 
108 108
     public static function pro_is_installed() {
109
-        return apply_filters('frm_pro_installed', false);
109
+        return apply_filters( 'frm_pro_installed', false );
110 110
     }
111 111
 
112 112
     /**
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      * @return boolean
151 151
      */
152 152
     public static function doing_ajax() {
153
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
153
+        return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page();
154 154
     }
155 155
 
156 156
 	/**
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      * @return boolean
171 171
      */
172 172
     public static function is_admin() {
173
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
173
+        return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX );
174 174
     }
175 175
 
176 176
     /**
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
      * @return string
197 197
      */
198 198
 	public static function get_server_value( $value ) {
199
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
199
+        return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : '';
200 200
     }
201 201
 
202 202
     /**
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
             'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
212 212
             'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
213 213
         ) as $key ) {
214
-            if ( ! isset( $_SERVER[ $key ] ) ) {
214
+            if ( ! isset( $_SERVER[$key] ) ) {
215 215
                 continue;
216 216
             }
217 217
 
218
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
219
-                $ip = trim($ip); // just to be safe
218
+            foreach ( explode( ',', $_SERVER[$key] ) as $ip ) {
219
+                $ip = trim( $ip ); // just to be safe
220 220
 
221
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
221
+                if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
222 222
                     return $ip;
223 223
                 }
224 224
             }
@@ -228,15 +228,15 @@  discard block
 block discarded – undo
228 228
     }
229 229
 
230 230
     public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
231
-        if ( strpos($param, '[') ) {
232
-            $params = explode('[', $param);
231
+        if ( strpos( $param, '[' ) ) {
232
+            $params = explode( '[', $param );
233 233
             $param = $params[0];
234 234
         }
235 235
 
236 236
 		if ( $src == 'get' ) {
237
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
238
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
239
-                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
237
+            $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default );
238
+            if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) {
239
+                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[$param] ) ) );
240 240
             }
241 241
 			self::sanitize_value( $sanitize, $value );
242 242
 		} else {
@@ -245,12 +245,12 @@  discard block
 block discarded – undo
245 245
 
246 246
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
247 247
             foreach ( $params as $k => $p ) {
248
-                if ( ! $k || ! is_array($value) ) {
248
+                if ( ! $k || ! is_array( $value ) ) {
249 249
                     continue;
250 250
                 }
251 251
 
252
-                $p = trim($p, ']');
253
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
252
+                $p = trim( $p, ']' );
253
+                $value = isset( $value[$p] ) ? $value[$p] : $default;
254 254
             }
255 255
         }
256 256
 
@@ -292,16 +292,16 @@  discard block
 block discarded – undo
292 292
 
293 293
 		$value = $args['default'];
294 294
 		if ( $args['type'] == 'get' ) {
295
-			if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
296
-				$value = $_GET[ $args['param'] ];
295
+			if ( $_GET && isset( $_GET[$args['param']] ) ) {
296
+				$value = $_GET[$args['param']];
297 297
 			}
298 298
 		} else if ( $args['type'] == 'post' ) {
299
-			if ( isset( $_POST[ $args['param'] ] ) ) {
300
-				$value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) );
299
+			if ( isset( $_POST[$args['param']] ) ) {
300
+				$value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) );
301 301
 			}
302 302
 		} else {
303
-			if ( isset( $_REQUEST[ $args['param'] ] ) ) {
304
-				$value = $_REQUEST[ $args['param'] ];
303
+			if ( isset( $_REQUEST[$args['param']] ) ) {
304
+				$value = $_REQUEST[$args['param']];
305 305
 			}
306 306
 		}
307 307
 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 			if ( is_array( $value ) ) {
330 330
 				$temp_values = $value;
331 331
 				foreach ( $temp_values as $k => $v ) {
332
-					FrmAppHelper::sanitize_value( $sanitize, $value[ $k ] );
332
+					FrmAppHelper::sanitize_value( $sanitize, $value[$k] );
333 333
 				}
334 334
 			} else {
335 335
 				$value = call_user_func( $sanitize, $value );
@@ -340,8 +340,8 @@  discard block
 block discarded – undo
340 340
     public static function sanitize_request( $sanitize_method, &$values ) {
341 341
         $temp_values = $values;
342 342
         foreach ( $temp_values as $k => $val ) {
343
-            if ( isset( $sanitize_method[ $k ] ) ) {
344
-				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
343
+            if ( isset( $sanitize_method[$k] ) ) {
344
+				$values[$k] = call_user_func( $sanitize_method[$k], $val );
345 345
             }
346 346
         }
347 347
     }
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 	public static function sanitize_array( &$values ) {
350 350
 		$temp_values = $values;
351 351
 		foreach ( $temp_values as $k => $val ) {
352
-			$values[ $k ] = wp_kses_post( $val );
352
+			$values[$k] = wp_kses_post( $val );
353 353
 		}
354 354
 	}
355 355
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 
370 370
 		$allowed_html = array();
371 371
 		foreach ( $allowed as $a ) {
372
-			$allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
372
+			$allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array();
373 373
 		}
374 374
 
375 375
 		return wp_kses( $value, $allowed_html );
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
      * @since 2.0
381 381
      */
382 382
     public static function remove_get_action() {
383
-        if ( ! isset($_GET) ) {
383
+        if ( ! isset( $_GET ) ) {
384 384
             return;
385 385
         }
386 386
 
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
         }
403 403
 
404 404
         global $wp_query;
405
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
406
-            $value = $wp_query->query_vars[ $param ];
405
+        if ( isset( $wp_query->query_vars[$param] ) ) {
406
+            $value = $wp_query->query_vars[$param];
407 407
         }
408 408
 
409 409
         return $value;
@@ -432,16 +432,16 @@  discard block
 block discarded – undo
432 432
      * @return mixed $results The cache or query results
433 433
      */
434 434
     public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
435
-        $results = wp_cache_get($cache_key, $group);
436
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
435
+        $results = wp_cache_get( $cache_key, $group );
436
+        if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) {
437 437
             return $results;
438 438
         }
439 439
 
440 440
         if ( 'get_posts' == $type ) {
441
-            $results = get_posts($query);
441
+            $results = get_posts( $query );
442 442
         } else {
443 443
             global $wpdb;
444
-            $results = $wpdb->{$type}($query);
444
+            $results = $wpdb->{$type}( $query );
445 445
         }
446 446
 
447 447
 		if ( ! self::prevent_caching() ) {
@@ -465,9 +465,9 @@  discard block
 block discarded – undo
465 465
         }
466 466
 
467 467
         // then check the transient
468
-        $results = get_transient($cache_key);
468
+        $results = get_transient( $cache_key );
469 469
         if ( $results ) {
470
-            wp_cache_set($cache_key, $results);
470
+            wp_cache_set( $cache_key, $results );
471 471
         }
472 472
 
473 473
         return $results;
@@ -478,8 +478,8 @@  discard block
 block discarded – undo
478 478
      * @param string $cache_key
479 479
      */
480 480
 	public static function delete_cache_and_transient( $cache_key ) {
481
-        delete_transient($cache_key);
482
-        wp_cache_delete($cache_key);
481
+        delete_transient( $cache_key );
482
+        wp_cache_delete( $cache_key );
483 483
     }
484 484
 
485 485
     /**
@@ -493,9 +493,9 @@  discard block
 block discarded – undo
493 493
 	public static function cache_delete_group( $group ) {
494 494
     	global $wp_object_cache;
495 495
 
496
-        if ( isset( $wp_object_cache->cache[ $group ] ) ) {
497
-            foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) {
498
-                wp_cache_delete($k, $group);
496
+        if ( isset( $wp_object_cache->cache[$group] ) ) {
497
+            foreach ( $wp_object_cache->cache[$group] as $k => $v ) {
498
+                wp_cache_delete( $k, $group );
499 499
             }
500 500
             return true;
501 501
         }
@@ -526,29 +526,29 @@  discard block
 block discarded – undo
526 526
 	public static function load_scripts( $scripts ) {
527 527
         _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' );
528 528
         foreach ( (array) $scripts as $s ) {
529
-            wp_enqueue_script($s);
529
+            wp_enqueue_script( $s );
530 530
         }
531 531
     }
532 532
 
533 533
 	public static function load_styles( $styles ) {
534 534
         _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' );
535 535
         foreach ( (array) $styles as $s ) {
536
-            wp_enqueue_style($s);
536
+            wp_enqueue_style( $s );
537 537
         }
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
 				}
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
     }
820 820
 
821 821
     public static function esc_textarea( $text ) {
822
-        $safe_text = str_replace('&quot;', '"', $text);
822
+        $safe_text = str_replace( '&quot;', '"', $text );
823 823
         $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
824 824
     	return apply_filters( 'esc_textarea', $safe_text, $text );
825 825
     }
@@ -829,8 +829,8 @@  discard block
 block discarded – undo
829 829
      * @since 2.0
830 830
      */
831 831
 	public static function use_wpautop( $content ) {
832
-        if ( apply_filters('frm_use_wpautop', true) ) {
833
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
832
+        if ( apply_filters( 'frm_use_wpautop', true ) ) {
833
+            $content = wpautop( str_replace( '<br>', '<br />', $content ) );
834 834
         }
835 835
         return $content;
836 836
     }
@@ -848,8 +848,8 @@  discard block
 block discarded – undo
848 848
      * @return string The base Google APIS url for the current version of jQuery UI
849 849
      */
850 850
     public static function jquery_ui_base_url() {
851
-		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core');
852
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
851
+		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core' );
852
+        $url = apply_filters( 'frm_jquery_ui_base_url', $url );
853 853
         return $url;
854 854
     }
855 855
 
@@ -864,11 +864,11 @@  discard block
 block discarded – undo
864 864
 
865 865
         $ver = 0;
866 866
 
867
-        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
867
+        if ( ! isset( $wp_scripts->registered[$handle] ) ) {
868 868
             return $ver;
869 869
         }
870 870
 
871
-        $query = $wp_scripts->registered[ $handle ];
871
+        $query = $wp_scripts->registered[$handle];
872 872
     	if ( is_object( $query ) ) {
873 873
     	    $ver = $query->ver;
874 874
     	}
@@ -881,36 +881,36 @@  discard block
 block discarded – undo
881 881
     }
882 882
 
883 883
 	public static function get_user_id_param( $user_id ) {
884
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
884
+        if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
885 885
             return $user_id;
886 886
         }
887 887
 
888 888
 		if ( $user_id == 'current' ) {
889 889
 			$user_id = get_current_user_id();
890 890
 		} else {
891
-            if ( is_email($user_id) ) {
892
-                $user = get_user_by('email', $user_id);
891
+            if ( is_email( $user_id ) ) {
892
+                $user = get_user_by( 'email', $user_id );
893 893
             } else {
894
-                $user = get_user_by('login', $user_id);
894
+                $user = get_user_by( 'login', $user_id );
895 895
             }
896 896
 
897 897
             if ( $user ) {
898 898
                 $user_id = $user->ID;
899 899
             }
900
-            unset($user);
900
+            unset( $user );
901 901
         }
902 902
 
903 903
         return $user_id;
904 904
     }
905 905
 
906 906
 	public static function get_file_contents( $filename, $atts = array() ) {
907
-        if ( ! is_file($filename) ) {
907
+        if ( ! is_file( $filename ) ) {
908 908
             return false;
909 909
         }
910 910
 
911
-        extract($atts);
911
+        extract( $atts );
912 912
         ob_start();
913
-        include($filename);
913
+        include( $filename );
914 914
         $contents = ob_get_contents();
915 915
         ob_end_clean();
916 916
         return $contents;
@@ -926,28 +926,28 @@  discard block
 block discarded – undo
926 926
         $key = '';
927 927
 
928 928
         if ( ! empty( $name ) ) {
929
-            $key = sanitize_key($name);
929
+            $key = sanitize_key( $name );
930 930
         }
931 931
 
932 932
 		if ( empty( $key ) ) {
933
-            $max_slug_value = pow(36, $num_chars);
933
+            $max_slug_value = pow( 36, $num_chars );
934 934
             $min_slug_value = 37; // we want to have at least 2 characters in the slug
935
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
935
+            $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
936 936
         }
937 937
 
938
-		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
938
+		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
939 939
 			$key = $key . 'a';
940 940
         }
941 941
 
942 942
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
943 943
 
944
-        if ( $key_check || is_numeric($key_check) ) {
944
+        if ( $key_check || is_numeric( $key_check ) ) {
945 945
             $suffix = 2;
946 946
 			do {
947 947
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
948 948
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
949
-				$suffix++;
950
-			} while ($key_check || is_numeric($key_check));
949
+				$suffix ++;
950
+			} while ( $key_check || is_numeric( $key_check ) );
951 951
 			$key = $alt_post_name;
952 952
         }
953 953
         return $key;
@@ -963,32 +963,32 @@  discard block
 block discarded – undo
963 963
             return false;
964 964
         }
965 965
 
966
-        if ( empty($post_values) ) {
967
-            $post_values = stripslashes_deep($_POST);
966
+        if ( empty( $post_values ) ) {
967
+            $post_values = stripslashes_deep( $_POST );
968 968
         }
969 969
 
970 970
 		$values = array( 'id' => $record->id, 'fields' => array() );
971 971
 
972 972
 		foreach ( array( 'name', 'description' ) as $var ) {
973
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
974
-			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
975
-            unset($var, $default_val);
973
+            $default_val = isset( $record->{$var}) ? $record->{$var} : '';
974
+			$values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
975
+            unset( $var, $default_val );
976 976
         }
977 977
 
978
-        $values['description'] = self::use_wpautop($values['description']);
978
+        $values['description'] = self::use_wpautop( $values['description'] );
979 979
         $frm_settings = self::get_settings();
980
-        $is_form_builder = self::is_admin_page('formidable' );
980
+        $is_form_builder = self::is_admin_page( 'formidable' );
981 981
 
982 982
         foreach ( (array) $fields as $field ) {
983 983
             // Make sure to filter default values (for placeholder text), but not on the form builder page
984 984
             if ( ! $is_form_builder ) {
985
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
985
+                $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true );
986 986
             }
987 987
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
988
-			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
988
+			self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) );
989 989
         }
990 990
 
991
-        self::fill_form_opts($record, $table, $post_values, $values);
991
+        self::fill_form_opts( $record, $table, $post_values, $values );
992 992
 
993 993
         if ( $table == 'entries' ) {
994 994
             $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
@@ -1005,8 +1005,8 @@  discard block
 block discarded – undo
1005 1005
         if ( $args['default'] ) {
1006 1006
             $meta_value = $field->default_value;
1007 1007
         } else {
1008
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1009
-                if ( ! isset($field->field_options['custom_field']) ) {
1008
+            if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
1009
+                if ( ! isset( $field->field_options['custom_field'] ) ) {
1010 1010
                     $field->field_options['custom_field'] = '';
1011 1011
                 }
1012 1012
 				$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 ) );
@@ -1015,8 +1015,8 @@  discard block
 block discarded – undo
1015 1015
             }
1016 1016
         }
1017 1017
 
1018
-		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1019
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1018
+		$field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type;
1019
+        $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value;
1020 1020
 
1021 1021
         $field_array = array(
1022 1022
             'id'            => $field->id,
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
             'default_value' => $field->default_value,
1025 1025
             'name'          => $field->name,
1026 1026
             'description'   => $field->description,
1027
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1027
+            'type'          => apply_filters( 'frm_field_type', $field_type, $field, $new_value ),
1028 1028
             'options'       => $field->options,
1029 1029
             'required'      => $field->required,
1030 1030
             'field_key'     => $field->field_key,
@@ -1034,40 +1034,40 @@  discard block
 block discarded – undo
1034 1034
         );
1035 1035
 
1036 1036
         $args['field_type'] = $field_type;
1037
-        self::fill_field_opts($field, $field_array, $args);
1037
+        self::fill_field_opts( $field, $field_array, $args );
1038 1038
 		// Track the original field's type
1039 1039
 		$field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type;
1040 1040
 
1041 1041
         $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1042 1042
 
1043
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1043
+        if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1044 1044
             $field_array['unique_msg'] = '';
1045 1045
         }
1046 1046
 
1047 1047
         $field_array = array_merge( $field->field_options, $field_array );
1048 1048
 
1049
-        $values['fields'][ $field->id ] = $field_array;
1049
+        $values['fields'][$field->id] = $field_array;
1050 1050
     }
1051 1051
 
1052 1052
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1053 1053
         $post_values = $args['post_values'];
1054
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1054
+        $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
1055 1055
 
1056 1056
         foreach ( $opt_defaults as $opt => $default_opt ) {
1057
-			$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 );
1058
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1059
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1060
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1057
+			$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 );
1058
+            if ( $opt == 'blank' && $field_array[$opt] == '' ) {
1059
+                $field_array[$opt] = $args['frm_settings']->blank_msg;
1060
+            } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) {
1061 1061
                 if ( $args['field_type'] == 'captcha' ) {
1062
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1062
+                    $field_array[$opt] = $args['frm_settings']->re_msg;
1063 1063
                 } else {
1064
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1064
+                    $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1065 1065
                 }
1066 1066
             }
1067 1067
         }
1068 1068
 
1069 1069
         if ( $field_array['custom_html'] == '' ) {
1070
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1070
+            $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] );
1071 1071
         }
1072 1072
     }
1073 1073
 
@@ -1086,18 +1086,18 @@  discard block
 block discarded – undo
1086 1086
             return;
1087 1087
         }
1088 1088
 
1089
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1089
+        $values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1090 1090
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1091 1091
 
1092
-        if ( ! is_array($form->options) ) {
1092
+        if ( ! is_array( $form->options ) ) {
1093 1093
             return;
1094 1094
         }
1095 1095
 
1096 1096
         foreach ( $form->options as $opt => $value ) {
1097
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1097
+            $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value;
1098 1098
         }
1099 1099
 
1100
-        self::fill_form_defaults($post_values, $values);
1100
+        self::fill_form_defaults( $post_values, $values );
1101 1101
     }
1102 1102
 
1103 1103
     /**
@@ -1107,23 +1107,23 @@  discard block
 block discarded – undo
1107 1107
         $form_defaults = FrmFormsHelper::get_default_opts();
1108 1108
 
1109 1109
         foreach ( $form_defaults as $opt => $default ) {
1110
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1111
-				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1110
+            if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) {
1111
+				$values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default;
1112 1112
             }
1113 1113
 
1114
-            unset($opt, $defaut);
1114
+            unset( $opt, $defaut );
1115 1115
         }
1116 1116
 
1117
-        if ( ! isset($values['custom_style']) ) {
1117
+        if ( ! isset( $values['custom_style'] ) ) {
1118 1118
             $frm_settings = self::get_settings();
1119 1119
 			$values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' );
1120 1120
         }
1121 1121
 
1122 1122
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1123
-			if ( ! isset( $values[ $h . '_html' ] ) ) {
1124
-				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1123
+			if ( ! isset( $values[$h . '_html'] ) ) {
1124
+				$values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) );
1125 1125
             }
1126
-            unset($h);
1126
+            unset( $h );
1127 1127
         }
1128 1128
     }
1129 1129
 
@@ -1139,9 +1139,9 @@  discard block
 block discarded – undo
1139 1139
         }
1140 1140
     ?>
1141 1141
 <li>
1142
-    <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>
1143
-    <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>
1144
-    <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>
1142
+    <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>
1143
+    <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>
1144
+    <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 1145
 </li>
1146 1146
     <?php
1147 1147
     }
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
             return '';
1170 1170
         } else if ( $length <= 10 ) {
1171 1171
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1172
-            return $sub . (($length < $original_len) ? $continue : '');
1172
+            return $sub . ( ( $length < $original_len ) ? $continue : '' );
1173 1173
         }
1174 1174
 
1175 1175
         $sub = '';
@@ -1178,23 +1178,23 @@  discard block
 block discarded – undo
1178 1178
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1179 1179
 
1180 1180
 		foreach ( $words as $word ) {
1181
-            $part = (($sub != '') ? ' ' : '') . $word;
1181
+            $part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1182 1182
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1183
-            if ( $total_len > $length && str_word_count($sub) ) {
1183
+            if ( $total_len > $length && str_word_count( $sub ) ) {
1184 1184
                 break;
1185 1185
             }
1186 1186
 
1187 1187
             $sub .= $part;
1188 1188
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1189 1189
 
1190
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1190
+            if ( str_word_count( $sub ) > $minword && $total_len >= $length ) {
1191 1191
                 break;
1192 1192
             }
1193 1193
 
1194
-            unset($total_len, $word);
1194
+            unset( $total_len, $word );
1195 1195
         }
1196 1196
 
1197
-        return $sub . (($len < $original_len) ? $continue : '');
1197
+        return $sub . ( ( $len < $original_len ) ? $continue : '' );
1198 1198
     }
1199 1199
 
1200 1200
 	public static function mb_function( $function_names, $args ) {
@@ -1207,17 +1207,17 @@  discard block
 block discarded – undo
1207 1207
 	}
1208 1208
 
1209 1209
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1210
-        if ( empty($date) ) {
1210
+        if ( empty( $date ) ) {
1211 1211
             return $date;
1212 1212
         }
1213 1213
 
1214
-        if ( empty($date_format) ) {
1215
-            $date_format = get_option('date_format');
1214
+        if ( empty( $date_format ) ) {
1215
+            $date_format = get_option( 'date_format' );
1216 1216
         }
1217 1217
 
1218
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1218
+        if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1219 1219
             $frmpro_settings = new FrmProSettings();
1220
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1220
+            $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1221 1221
         }
1222 1222
 
1223 1223
 		$formatted = self::get_localized_date( $date_format, $date );
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
 
1233 1233
 	private static function add_time_to_date( $time_format, $date ) {
1234 1234
 		if ( empty( $time_format ) ) {
1235
-			$time_format = get_option('time_format');
1235
+			$time_format = get_option( 'time_format' );
1236 1236
 		}
1237 1237
 
1238 1238
 		$trimmed_format = trim( $time_format );
@@ -1278,10 +1278,10 @@  discard block
 block discarded – undo
1278 1278
 		$time_strings = self::get_time_strings();
1279 1279
 
1280 1280
 		foreach ( $time_strings as $k => $v ) {
1281
-			if ( $diff[ $k ] ) {
1282
-				$time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] );
1281
+			if ( $diff[$k] ) {
1282
+				$time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] );
1283 1283
 			} else {
1284
-				unset( $time_strings[ $k ] );
1284
+				unset( $time_strings[$k] );
1285 1285
 			}
1286 1286
 		}
1287 1287
 
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
      */
1320 1320
 	public static function esc_like( $term ) {
1321 1321
         global $wpdb;
1322
-        if ( method_exists($wpdb, 'esc_like') ) {
1322
+        if ( method_exists( $wpdb, 'esc_like' ) ) {
1323 1323
 			// WP 4.0
1324 1324
             $term = $wpdb->esc_like( $term );
1325 1325
         } else {
@@ -1333,17 +1333,17 @@  discard block
 block discarded – undo
1333 1333
      * @param string $order_query
1334 1334
      */
1335 1335
 	public static function esc_order( $order_query ) {
1336
-        if ( empty($order_query) ) {
1336
+        if ( empty( $order_query ) ) {
1337 1337
             return '';
1338 1338
         }
1339 1339
 
1340 1340
         // remove ORDER BY before santizing
1341
-        $order_query = strtolower($order_query);
1342
-        if ( strpos($order_query, 'order by') !== false ) {
1343
-            $order_query = str_replace('order by', '', $order_query);
1341
+        $order_query = strtolower( $order_query );
1342
+        if ( strpos( $order_query, 'order by' ) !== false ) {
1343
+            $order_query = str_replace( 'order by', '', $order_query );
1344 1344
         }
1345 1345
 
1346
-        $order_query = explode(' ', trim($order_query));
1346
+        $order_query = explode( ' ', trim( $order_query ) );
1347 1347
 
1348 1348
         $order_fields = array(
1349 1349
             'id', 'form_key', 'name', 'description',
@@ -1351,13 +1351,13 @@  discard block
 block discarded – undo
1351 1351
             'default_template', 'status', 'created_at',
1352 1352
         );
1353 1353
 
1354
-        $order = trim(trim(reset($order_query), ','));
1355
-        if ( ! in_array($order, $order_fields) ) {
1354
+        $order = trim( trim( reset( $order_query ), ',' ) );
1355
+        if ( ! in_array( $order, $order_fields ) ) {
1356 1356
             return '';
1357 1357
         }
1358 1358
 
1359 1359
         $order_by = '';
1360
-        if ( count($order_query) > 1 ) {
1360
+        if ( count( $order_query ) > 1 ) {
1361 1361
 			$order_by = end( $order_query );
1362 1362
 			self::esc_order_by( $order_by );
1363 1363
         }
@@ -1379,23 +1379,23 @@  discard block
 block discarded – undo
1379 1379
      * @param string $limit
1380 1380
      */
1381 1381
 	public static function esc_limit( $limit ) {
1382
-        if ( empty($limit) ) {
1382
+        if ( empty( $limit ) ) {
1383 1383
             return '';
1384 1384
         }
1385 1385
 
1386
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1387
-        if ( is_numeric($limit) ) {
1386
+        $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) );
1387
+        if ( is_numeric( $limit ) ) {
1388 1388
 			return ' LIMIT ' . $limit;
1389 1389
         }
1390 1390
 
1391
-        $limit = explode(',', trim($limit));
1391
+        $limit = explode( ',', trim( $limit ) );
1392 1392
         foreach ( $limit as $k => $l ) {
1393 1393
             if ( is_numeric( $l ) ) {
1394
-                $limit[ $k ] = $l;
1394
+                $limit[$k] = $l;
1395 1395
             }
1396 1396
         }
1397 1397
 
1398
-        $limit = implode(',', $limit);
1398
+        $limit = implode( ',', $limit );
1399 1399
 		return ' LIMIT ' . $limit;
1400 1400
     }
1401 1401
 
@@ -1404,12 +1404,12 @@  discard block
 block discarded – undo
1404 1404
      * @since 2.0
1405 1405
      */
1406 1406
     public static function prepare_array_values( $array, $type = '%s' ) {
1407
-        $placeholders = array_fill(0, count($array), $type);
1408
-        return implode(', ', $placeholders);
1407
+        $placeholders = array_fill( 0, count( $array ), $type );
1408
+        return implode( ', ', $placeholders );
1409 1409
     }
1410 1410
 
1411 1411
     public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1412
-        if ( empty($where) ) {
1412
+        if ( empty( $where ) ) {
1413 1413
             return '';
1414 1414
         }
1415 1415
 
@@ -1455,7 +1455,7 @@  discard block
 block discarded – undo
1455 1455
 
1456 1456
     public static function get_referer_info() {
1457 1457
         _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' );
1458
-        return self::get_server_value('HTTP_REFERER');
1458
+        return self::get_server_value( 'HTTP_REFERER' );
1459 1459
     }
1460 1460
 
1461 1461
 	/**
@@ -1464,19 +1464,19 @@  discard block
 block discarded – undo
1464 1464
 	public static function json_to_array( $json_vars ) {
1465 1465
         $vars = array();
1466 1466
         foreach ( $json_vars as $jv ) {
1467
-            $jv_name = explode('[', $jv['name']);
1468
-            $last = count($jv_name) - 1;
1467
+            $jv_name = explode( '[', $jv['name'] );
1468
+            $last = count( $jv_name ) - 1;
1469 1469
             foreach ( $jv_name as $p => $n ) {
1470
-                $name = trim($n, ']');
1471
-                if ( ! isset($l1) ) {
1470
+                $name = trim( $n, ']' );
1471
+                if ( ! isset( $l1 ) ) {
1472 1472
                     $l1 = $name;
1473 1473
                 }
1474 1474
 
1475
-                if ( ! isset($l2) ) {
1475
+                if ( ! isset( $l2 ) ) {
1476 1476
                     $l2 = $name;
1477 1477
                 }
1478 1478
 
1479
-                if ( ! isset($l3) ) {
1479
+                if ( ! isset( $l3 ) ) {
1480 1480
                     $l3 = $name;
1481 1481
                 }
1482 1482
 
@@ -1490,24 +1490,24 @@  discard block
 block discarded – undo
1490 1490
 
1491 1491
                     case 1:
1492 1492
                         $l2 = $name;
1493
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1493
+                        self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] );
1494 1494
                     break;
1495 1495
 
1496 1496
                     case 2:
1497 1497
                         $l3 = $name;
1498
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1498
+                        self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] );
1499 1499
                     break;
1500 1500
 
1501 1501
                     case 3:
1502 1502
                         $l4 = $name;
1503
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1503
+                        self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] );
1504 1504
                     break;
1505 1505
                 }
1506 1506
 
1507
-                unset($this_val, $n);
1507
+                unset( $this_val, $n );
1508 1508
             }
1509 1509
 
1510
-            unset($last, $jv);
1510
+            unset( $last, $jv );
1511 1511
         }
1512 1512
 
1513 1513
         return $vars;
@@ -1520,8 +1520,8 @@  discard block
 block discarded – undo
1520 1520
     public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1521 1521
         if ( $name == '' ) {
1522 1522
             $vars[] = $val;
1523
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1524
-            $vars[ $l1 ] = $val;
1523
+        } else if ( ! isset( $vars[$l1] ) ) {
1524
+            $vars[$l1] = $val;
1525 1525
         }
1526 1526
     }
1527 1527
 
@@ -1536,7 +1536,7 @@  discard block
 block discarded – undo
1536 1536
             '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() ) ),
1537 1537
         );
1538 1538
 
1539
-        if ( ! isset( $tooltips[ $name ] ) ) {
1539
+        if ( ! isset( $tooltips[$name] ) ) {
1540 1540
             return;
1541 1541
         }
1542 1542
 
@@ -1546,7 +1546,7 @@  discard block
 block discarded – undo
1546 1546
             echo ' class="frm_help"';
1547 1547
         }
1548 1548
 
1549
-		echo ' title="' . esc_attr( $tooltips[ $name ] );
1549
+		echo ' title="' . esc_attr( $tooltips[$name] );
1550 1550
 
1551 1551
         if ( 'open' != $class ) {
1552 1552
             echo '"';
@@ -1598,13 +1598,13 @@  discard block
 block discarded – undo
1598 1598
     }
1599 1599
 
1600 1600
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1601
-		if ( ! isset( $post_content[ $key ] ) ) {
1601
+		if ( ! isset( $post_content[$key] ) ) {
1602 1602
 			return;
1603 1603
 		}
1604 1604
 
1605 1605
 		if ( is_array( $val ) ) {
1606 1606
 			foreach ( $val as $k1 => $v1 ) {
1607
-				self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] );
1607
+				self::prepare_action_slashes( $v1, $k1, $post_content[$key] );
1608 1608
 				unset( $k1, $v1 );
1609 1609
 			}
1610 1610
 		} else {
@@ -1612,7 +1612,7 @@  discard block
 block discarded – undo
1612 1612
 			$val = stripslashes( $val );
1613 1613
 
1614 1614
 			// Add backslashes before double quotes and forward slashes only
1615
-			$post_content[ $key ] = addcslashes( $val, '"\\/' );
1615
+			$post_content[$key] = addcslashes( $val, '"\\/' );
1616 1616
 		}
1617 1617
 	}
1618 1618
 
@@ -1629,7 +1629,7 @@  discard block
 block discarded – undo
1629 1629
 		$settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] );
1630 1630
 
1631 1631
 		if ( empty( $settings['ID'] ) ) {
1632
-			unset( $settings['ID']);
1632
+			unset( $settings['ID'] );
1633 1633
 		}
1634 1634
 
1635 1635
 		// delete all caches for this group
@@ -1663,17 +1663,17 @@  discard block
 block discarded – undo
1663 1663
 	}
1664 1664
 
1665 1665
 	public static function maybe_json_decode( $string ) {
1666
-        if ( is_array($string) ) {
1666
+        if ( is_array( $string ) ) {
1667 1667
             return $string;
1668 1668
         }
1669 1669
 
1670
-        $new_string = json_decode($string, true);
1671
-        if ( function_exists('json_last_error') ) {
1670
+        $new_string = json_decode( $string, true );
1671
+        if ( function_exists( 'json_last_error' ) ) {
1672 1672
 			// php 5.3+
1673 1673
             if ( json_last_error() == JSON_ERROR_NONE ) {
1674 1674
                 $string = $new_string;
1675 1675
             }
1676
-        } else if ( isset($new_string) ) {
1676
+        } else if ( isset( $new_string ) ) {
1677 1677
 			// php < 5.3 fallback
1678 1678
             $string = $new_string;
1679 1679
         }
@@ -1689,11 +1689,11 @@  discard block
 block discarded – undo
1689 1689
 	public static function maybe_highlight_menu( $post_type ) {
1690 1690
         global $post;
1691 1691
 
1692
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1692
+        if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1693 1693
             return;
1694 1694
         }
1695 1695
 
1696
-        if ( is_object($post) && $post->post_type != $post_type ) {
1696
+        if ( is_object( $post ) && $post->post_type != $post_type ) {
1697 1697
             return;
1698 1698
         }
1699 1699
 
@@ -1792,11 +1792,11 @@  discard block
 block discarded – undo
1792 1792
         $frm_version = self::plugin_version();
1793 1793
 
1794 1794
         // check if Formidable meets minimum requirements
1795
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1795
+        if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1796 1796
             return;
1797 1797
         }
1798 1798
 
1799
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1799
+        $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1800 1800
 		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">' .
1801 1801
         __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1802 1802
         '</div></td></tr>';
@@ -1804,38 +1804,38 @@  discard block
 block discarded – undo
1804 1804
 
1805 1805
     public static function locales( $type = 'date' ) {
1806 1806
         $locales = array(
1807
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1808
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1809
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1807
+            'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ),
1808
+            'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ),
1809
+            'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ),
1810 1810
             'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1811
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1812
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1811
+            'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ),
1812
+            'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1813 1813
             'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1814
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1815
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1814
+            'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ),
1815
+            'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ),
1816 1816
             'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1817
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1817
+            'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ),
1818 1818
             'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1819
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1819
+            'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ),
1820 1820
             'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1821
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1821
+            'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ),
1822 1822
             'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1823
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1824
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1825
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1826
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1827
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1823
+            'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ),
1824
+            'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ),
1825
+            'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ),
1826
+            'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ),
1827
+            'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ),
1828 1828
             'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1829
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1829
+            'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ),
1830 1830
             'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1831 1831
             'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1832
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1832
+            'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ),
1833 1833
             'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1834
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1834
+            'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ),
1835 1835
             'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1836
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1837
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1838
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1836
+            'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ),
1837
+            'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ),
1838
+            'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ),
1839 1839
         );
1840 1840
 
1841 1841
         if ( $type == 'captcha' ) {
@@ -1854,8 +1854,8 @@  discard block
 block discarded – undo
1854 1854
             );
1855 1855
         }
1856 1856
 
1857
-        $locales = array_diff_key($locales, array_flip($unset));
1858
-        $locales = apply_filters('frm_locales', $locales);
1857
+        $locales = array_diff_key( $locales, array_flip( $unset ) );
1858
+        $locales = apply_filters( 'frm_locales', $locales );
1859 1859
 
1860 1860
         return $locales;
1861 1861
     }
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesHelper.php 2 patches
Indentation   +297 added lines, -297 removed lines patch added patch discarded remove patch
@@ -5,69 +5,69 @@  discard block
 block discarded – undo
5 5
 
6 6
 class FrmEntriesHelper {
7 7
 
8
-    public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9
-        $values = array();
8
+	public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9
+		$values = array();
10 10
 		foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) {
11 11
 			$values[ $var ] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' );
12
-        }
13
-
14
-        $values['fields'] = array();
15
-        if ( empty($fields) ) {
16
-            return apply_filters('frm_setup_new_entry', $values);
17
-        }
18
-
19
-        foreach ( (array) $fields as $field ) {
20
-            $new_value = self::get_field_value_for_new_entry( $field, $reset, $args );
21
-
22
-            $field_array = array(
23
-                'id' => $field->id,
24
-                'value' => $new_value,
25
-                'default_value' => $field->default_value,
26
-                'name' => $field->name,
27
-                'description' => $field->description,
28
-                'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
29
-                'options' => $field->options,
30
-                'required' => $field->required,
31
-                'field_key' => $field->field_key,
32
-                'field_order' => $field->field_order,
33
-                'form_id' => $field->form_id,
12
+		}
13
+
14
+		$values['fields'] = array();
15
+		if ( empty($fields) ) {
16
+			return apply_filters('frm_setup_new_entry', $values);
17
+		}
18
+
19
+		foreach ( (array) $fields as $field ) {
20
+			$new_value = self::get_field_value_for_new_entry( $field, $reset, $args );
21
+
22
+			$field_array = array(
23
+				'id' => $field->id,
24
+				'value' => $new_value,
25
+				'default_value' => $field->default_value,
26
+				'name' => $field->name,
27
+				'description' => $field->description,
28
+				'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
29
+				'options' => $field->options,
30
+				'required' => $field->required,
31
+				'field_key' => $field->field_key,
32
+				'field_order' => $field->field_order,
33
+				'form_id' => $field->form_id,
34 34
 				'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id,
35
-	            'reset_value' => $reset,
35
+				'reset_value' => $reset,
36 36
 				'in_embed_form' => isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0',
37
-            );
37
+			);
38 38
 
39
-            $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
40
-            $opt_defaults['required_indicator'] = '';
39
+			$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
40
+			$opt_defaults['required_indicator'] = '';
41 41
 			$opt_defaults['original_type'] = $field->type;
42 42
 
43 43
 			foreach ( $opt_defaults as $opt => $default_opt ) {
44
-                $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
45
-                unset($opt, $default_opt);
46
-            }
44
+				$field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
45
+				unset($opt, $default_opt);
46
+			}
47 47
 
48
-            unset($opt_defaults);
48
+			unset($opt_defaults);
49 49
 
50
-            if ( $field_array['custom_html'] == '' ) {
51
-                $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
52
-            }
50
+			if ( $field_array['custom_html'] == '' ) {
51
+				$field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
52
+			}
53 53
 
54
-            $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args );
55
-            $field_array = array_merge( $field->field_options, $field_array );
54
+			$field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args );
55
+			$field_array = array_merge( $field->field_options, $field_array );
56 56
 
57
-            $values['fields'][] = $field_array;
57
+			$values['fields'][] = $field_array;
58 58
 
59
-            if ( ! $form || ! isset($form->id) ) {
60
-                $form = FrmForm::getOne($field->form_id);
61
-            }
62
-        }
59
+			if ( ! $form || ! isset($form->id) ) {
60
+				$form = FrmForm::getOne($field->form_id);
61
+			}
62
+		}
63 63
 
64
-        $form->options = maybe_unserialize($form->options);
65
-        if ( is_array($form->options) ) {
66
-            foreach ( $form->options as $opt => $value ) {
67
-                $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
68
-                unset($opt, $value);
69
-            }
70
-        }
64
+		$form->options = maybe_unserialize($form->options);
65
+		if ( is_array($form->options) ) {
66
+			foreach ( $form->options as $opt => $value ) {
67
+				$values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
68
+				unset($opt, $value);
69
+			}
70
+		}
71 71
 
72 72
 		$form_defaults = FrmFormsHelper::get_default_opts();
73 73
 
@@ -77,19 +77,19 @@  discard block
 block discarded – undo
77 77
 		$values = array_merge( $form_defaults, $values );
78 78
 
79 79
 		return apply_filters( 'frm_setup_new_entry', $values );
80
-    }
80
+	}
81 81
 
82 82
 	/**
83
-	* Set the value for each field
84
-	* This function is used when the form is first loaded and on all page turns *for a new entry*
85
-	*
86
-	* @since 2.0.13
87
-	*
88
-	* @param object $field - this is passed by reference since it is an object
89
-	* @param boolean $reset
90
-	* @param array $args
91
-	* @return string|array $new_value
92
-	*/
83
+	 * Set the value for each field
84
+	 * This function is used when the form is first loaded and on all page turns *for a new entry*
85
+	 *
86
+	 * @since 2.0.13
87
+	 *
88
+	 * @param object $field - this is passed by reference since it is an object
89
+	 * @param boolean $reset
90
+	 * @param array $args
91
+	 * @return string|array $new_value
92
+	 */
93 93
 	private static function get_field_value_for_new_entry( $field, $reset, $args ) {
94 94
 		//If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array
95 95
 		$return_array = FrmField::is_field_with_multiple_values( $field );
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
 	}
116 116
 
117 117
 	/**
118
-	* Check if a field has a posted value
119
-	*
120
-	* @since 2.01.0
121
-	* @param object $field
122
-	* @param array $args
123
-	* @return boolean $value_is_posted
124
-	*/
118
+	 * Check if a field has a posted value
119
+	 *
120
+	 * @since 2.01.0
121
+	 * @param object $field
122
+	 * @param array $args
123
+	 * @return boolean $value_is_posted
124
+	 */
125 125
 	public static function value_is_posted( $field, $args ) {
126 126
 		$value_is_posted = false;
127 127
 		if ( $_POST ) {
@@ -139,15 +139,15 @@  discard block
 block discarded – undo
139 139
 
140 140
 	public static function setup_edit_vars( $values, $record ) {
141 141
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
142
-        $values['form_id'] = $record->form_id;
143
-        $values['is_draft'] = $record->is_draft;
144
-        return apply_filters('frm_setup_edit_entry_vars', $values, $record);
145
-    }
142
+		$values['form_id'] = $record->form_id;
143
+		$values['is_draft'] = $record->is_draft;
144
+		return apply_filters('frm_setup_edit_entry_vars', $values, $record);
145
+	}
146 146
 
147
-    public static function get_admin_params( $form = null ) {
147
+	public static function get_admin_params( $form = null ) {
148 148
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_admin_params' );
149 149
 		return FrmForm::set_current_form( $form );
150
-    }
150
+	}
151 151
 
152 152
 	public static function set_current_form( $form_id ) {
153 153
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::set_current_form' );
@@ -159,282 +159,282 @@  discard block
 block discarded – undo
159 159
 		return FrmForm::get_current_form( $form_id );
160 160
 	}
161 161
 
162
-    public static function get_current_form_id() {
162
+	public static function get_current_form_id() {
163 163
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_current_form_id' );
164 164
 		return FrmForm::get_current_form_id();
165
-    }
165
+	}
166 166
 
167
-    public static function maybe_get_entry( &$entry ) {
167
+	public static function maybe_get_entry( &$entry ) {
168 168
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntry::maybe_get_entry' );
169 169
 		FrmEntry::maybe_get_entry( $entry );
170
-    }
170
+	}
171 171
 
172 172
 	public static function replace_default_message( $message, $atts ) {
173
-        if ( strpos($message, '[default-message') === false &&
174
-            strpos($message, '[default_message') === false &&
175
-            ! empty( $message ) ) {
176
-            return $message;
177
-        }
178
-
179
-        if ( empty($message) ) {
180
-            $message = '[default-message]';
181
-        }
182
-
183
-        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
184
-
185
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
186
-            $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
187
-            if ( $add_atts ) {
188
-                $this_atts = array_merge($atts, $add_atts);
189
-            } else {
190
-                $this_atts = $atts;
191
-            }
173
+		if ( strpos($message, '[default-message') === false &&
174
+			strpos($message, '[default_message') === false &&
175
+			! empty( $message ) ) {
176
+			return $message;
177
+		}
178
+
179
+		if ( empty($message) ) {
180
+			$message = '[default-message]';
181
+		}
182
+
183
+		preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
184
+
185
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
186
+			$add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
187
+			if ( $add_atts ) {
188
+				$this_atts = array_merge($atts, $add_atts);
189
+			} else {
190
+				$this_atts = $atts;
191
+			}
192 192
 
193 193
 			$default = FrmEntryFormat::show_entry( $this_atts );
194 194
 
195
-            // Add the default message
196
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
197
-        }
195
+			// Add the default message
196
+			$message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
197
+		}
198 198
 
199
-        return $message;
200
-    }
199
+		return $message;
200
+	}
201 201
 
202 202
 	public static function prepare_display_value( $entry, $field, $atts ) {
203 203
 		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
204 204
 
205
-        if ( FrmAppHelper::pro_is_installed() ) {
205
+		if ( FrmAppHelper::pro_is_installed() ) {
206 206
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
207
-        }
207
+		}
208 208
 
209
-        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
210
-            return self::display_value($field_value, $field, $atts);
211
-        }
209
+		if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
210
+			return self::display_value($field_value, $field, $atts);
211
+		}
212 212
 
213
-        // this is an embeded form
214
-        $val = '';
213
+		// this is an embeded form
214
+		$val = '';
215 215
 
216
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
217
-            //this is a repeating section
216
+		if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
217
+			//this is a repeating section
218 218
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
219
-        } else {
220
-            // get all values for this field
221
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
219
+		} else {
220
+			// get all values for this field
221
+			$child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
222 222
 
223
-            if ( $child_values ) {
224
-	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
225
-	        }
226
-	    }
223
+			if ( $child_values ) {
224
+				$child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
225
+			}
226
+		}
227 227
 
228
-	    $field_value = array();
228
+		$field_value = array();
229 229
 
230
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
231
-            return $val;
232
-        }
230
+		if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
231
+			return $val;
232
+		}
233 233
 
234
-        foreach ( $child_entries as $child_entry ) {
235
-            $atts['item_id'] = $child_entry->id;
236
-            $atts['post_id'] = $child_entry->post_id;
234
+		foreach ( $child_entries as $child_entry ) {
235
+			$atts['item_id'] = $child_entry->id;
236
+			$atts['post_id'] = $child_entry->post_id;
237 237
 
238
-            // get the value for this field -- check for post values as well
239
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
238
+			// get the value for this field -- check for post values as well
239
+			$entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
240 240
 
241
-            if ( $entry_val ) {
242
-                // foreach entry get display_value
243
-                $field_value[] = self::display_value($entry_val, $field, $atts);
244
-            }
241
+			if ( $entry_val ) {
242
+				// foreach entry get display_value
243
+				$field_value[] = self::display_value($entry_val, $field, $atts);
244
+			}
245 245
 
246
-            unset($child_entry);
247
-        }
246
+			unset($child_entry);
247
+		}
248 248
 
249
-        $val = implode(', ', (array) $field_value );
249
+		$val = implode(', ', (array) $field_value );
250 250
 		$val = wp_kses_post( $val );
251 251
 
252
-        return $val;
253
-    }
252
+		return $val;
253
+	}
254 254
 
255
-    /**
256
-     * Prepare the saved value for display
257
-     * @return string
258
-     */
255
+	/**
256
+	 * Prepare the saved value for display
257
+	 * @return string
258
+	 */
259 259
 	public static function display_value( $value, $field, $atts = array() ) {
260 260
 
261
-        $defaults = array(
262
-            'type' => '', 'html' => false, 'show_filename' => true,
263
-            'truncate' => false, 'sep' => ', ', 'post_id' => 0,
264
-            'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0,
261
+		$defaults = array(
262
+			'type' => '', 'html' => false, 'show_filename' => true,
263
+			'truncate' => false, 'sep' => ', ', 'post_id' => 0,
264
+			'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0,
265 265
 			'return_array' => false,
266
-        );
266
+		);
267 267
 
268
-        $atts = wp_parse_args( $atts, $defaults );
269
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
268
+		$atts = wp_parse_args( $atts, $defaults );
269
+		$atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
270 270
 
271
-        if ( ! isset($field->field_options['post_field']) ) {
272
-            $field->field_options['post_field'] = '';
273
-        }
271
+		if ( ! isset($field->field_options['post_field']) ) {
272
+			$field->field_options['post_field'] = '';
273
+		}
274 274
 
275
-        if ( ! isset($field->field_options['custom_field']) ) {
276
-            $field->field_options['custom_field'] = '';
277
-        }
275
+		if ( ! isset($field->field_options['custom_field']) ) {
276
+			$field->field_options['custom_field'] = '';
277
+		}
278 278
 
279
-        if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
280
-            $atts['pre_truncate'] = $atts['truncate'];
281
-            $atts['truncate'] = true;
282
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
279
+		if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
280
+			$atts['pre_truncate'] = $atts['truncate'];
281
+			$atts['truncate'] = true;
282
+			$atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
283 283
 
284
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
285
-            $atts['truncate'] = $atts['pre_truncate'];
286
-        }
284
+			$value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
285
+			$atts['truncate'] = $atts['pre_truncate'];
286
+		}
287 287
 
288
-        if ( $value == '' ) {
289
-            return $value;
290
-        }
288
+		if ( $value == '' ) {
289
+			return $value;
290
+		}
291 291
 
292
-        $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
292
+		$value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
293 293
 		$value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) );
294 294
 
295
-        $new_value = '';
295
+		$new_value = '';
296 296
 
297
-        if ( is_array($value) && $atts['type'] != 'file' ) {
298
-            foreach ( $value as $val ) {
299
-                if ( is_array($val) ) {
297
+		if ( is_array($value) && $atts['type'] != 'file' ) {
298
+			foreach ( $value as $val ) {
299
+				if ( is_array($val) ) {
300 300
 					//TODO: add options for display (li or ,)
301
-                    $new_value .= implode($atts['sep'], $val);
302
-                    if ( $atts['type'] != 'data' ) {
303
-                        $new_value .= '<br/>';
304
-                    }
305
-                }
306
-                unset($val);
307
-            }
308
-        }
309
-
310
-        if ( ! empty($new_value) ) {
311
-            $value = $new_value;
312
-        } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
313
-            $value = implode($atts['sep'], $value);
314
-        }
315
-
316
-        if ( $atts['truncate'] && $atts['type'] != 'image' ) {
317
-            $value = FrmAppHelper::truncate($value, 50);
318
-        }
301
+					$new_value .= implode($atts['sep'], $val);
302
+					if ( $atts['type'] != 'data' ) {
303
+						$new_value .= '<br/>';
304
+					}
305
+				}
306
+				unset($val);
307
+			}
308
+		}
309
+
310
+		if ( ! empty($new_value) ) {
311
+			$value = $new_value;
312
+		} else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
313
+			$value = implode($atts['sep'], $value);
314
+		}
315
+
316
+		if ( $atts['truncate'] && $atts['type'] != 'image' ) {
317
+			$value = FrmAppHelper::truncate($value, 50);
318
+		}
319 319
 
320 320
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
321 321
 			$value = wp_kses_post( $value );
322 322
 		}
323 323
 
324
-        return apply_filters('frm_display_value', $value, $field, $atts);
325
-    }
324
+		return apply_filters('frm_display_value', $value, $field, $atts);
325
+	}
326 326
 
327 327
 	public static function set_posted_value( $field, $value, $args ) {
328
-        // If validating a field with "other" opt, set back to prev value now
329
-        if ( isset( $args['other'] ) && $args['other'] ) {
330
-            $value = $args['temp_value'];
331
-        }
332
-        if ( empty($args['parent_field_id']) ) {
333
-            $_POST['item_meta'][ $field->id ] = $value;
334
-        } else {
335
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
336
-        }
337
-    }
328
+		// If validating a field with "other" opt, set back to prev value now
329
+		if ( isset( $args['other'] ) && $args['other'] ) {
330
+			$value = $args['temp_value'];
331
+		}
332
+		if ( empty($args['parent_field_id']) ) {
333
+			$_POST['item_meta'][ $field->id ] = $value;
334
+		} else {
335
+			$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
336
+		}
337
+	}
338 338
 
339 339
 	public static function get_posted_value( $field, &$value, $args ) {
340 340
 		$field_id = is_object( $field ) ? $field->id : $field;
341 341
 
342
-        if ( empty($args['parent_field_id']) ) {
343
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
344
-        } else {
345
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
346
-        }
347
-    }
348
-
349
-    /**
350
-    * Check if field has an "Other" option and if any other values are posted
351
-    *
352
-    * @since 2.0
353
-    *
354
-    * @param object $field
355
-    * @param string|array $value
356
-    * @param array $args
357
-    */
358
-    public static function maybe_set_other_validation( $field, &$value, &$args ) {
359
-        $args['other'] = false;
360
-        if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
361
-            return;
362
-        }
363
-
364
-        // Get other value for fields in repeating section
365
-        self::set_other_repeating_vals( $field, $value, $args );
366
-
367
-        // Check if there are any posted "Other" values
342
+		if ( empty($args['parent_field_id']) ) {
343
+			$value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
344
+		} else {
345
+			$value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
346
+		}
347
+	}
348
+
349
+	/**
350
+	 * Check if field has an "Other" option and if any other values are posted
351
+	 *
352
+	 * @since 2.0
353
+	 *
354
+	 * @param object $field
355
+	 * @param string|array $value
356
+	 * @param array $args
357
+	 */
358
+	public static function maybe_set_other_validation( $field, &$value, &$args ) {
359
+		$args['other'] = false;
360
+		if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
361
+			return;
362
+		}
363
+
364
+		// Get other value for fields in repeating section
365
+		self::set_other_repeating_vals( $field, $value, $args );
366
+
367
+		// Check if there are any posted "Other" values
368 368
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
369 369
 
370
-            // Save original value
371
-            $args['temp_value'] = $value;
372
-            $args['other'] = true;
373
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
374
-
375
-            // Set the validation value now
376
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
377
-        }
378
-    }
379
-
380
-    /**
381
-    * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
382
-    *
383
-    * @since 2.0
384
-    *
385
-    * @param object $field
386
-    * @param string|array $value
387
-    * @param array $args
388
-    */
389
-    public static function set_other_repeating_vals( $field, &$value, &$args ) {
390
-        if ( ! $args['parent_field_id'] ) {
391
-            return;
392
-        }
393
-
394
-        // Check if there are any other posted "other" values for this field
370
+			// Save original value
371
+			$args['temp_value'] = $value;
372
+			$args['other'] = true;
373
+			$other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
374
+
375
+			// Set the validation value now
376
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
377
+		}
378
+	}
379
+
380
+	/**
381
+	 * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
382
+	 *
383
+	 * @since 2.0
384
+	 *
385
+	 * @param object $field
386
+	 * @param string|array $value
387
+	 * @param array $args
388
+	 */
389
+	public static function set_other_repeating_vals( $field, &$value, &$args ) {
390
+		if ( ! $args['parent_field_id'] ) {
391
+			return;
392
+		}
393
+
394
+		// Check if there are any other posted "other" values for this field
395 395
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
396
-            // Save original value
397
-            $args['temp_value'] = $value;
398
-            $args['other'] = true;
399
-
400
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
401
-
402
-            // Set the validation value now
403
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
404
-        }
405
-    }
406
-
407
-    /**
408
-    * Modify value used for validation
409
-    * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
410
-    * It also adds any text from the free text fields to the value
411
-    *
412
-    * Needs to accommodate for times when other opt is selected, but no other free text is entered
413
-    *
414
-    * @since 2.0
415
-    *
416
-    * @param string|array $value
417
-    * @param string|array $other_vals (usually of posted values)
418
-    * @param object $field
419
-    * @param array $args
420
-    */
421
-    public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
422
-        // Checkboxes and multi-select dropdowns
423
-        if ( is_array( $value ) && $field->type == 'checkbox' ) {
424
-            // Combine "Other" values with checked values. "Other" values will override checked box values.
425
-            $value = array_merge( $value, $other_vals );
426
-            $value = array_filter( $value );
427
-            if ( count( $value ) == 0 ) {
428
-                $value = '';
429
-            }
430
-        } else {
396
+			// Save original value
397
+			$args['temp_value'] = $value;
398
+			$args['other'] = true;
399
+
400
+			$other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
401
+
402
+			// Set the validation value now
403
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
404
+		}
405
+	}
406
+
407
+	/**
408
+	 * Modify value used for validation
409
+	 * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
410
+	 * It also adds any text from the free text fields to the value
411
+	 *
412
+	 * Needs to accommodate for times when other opt is selected, but no other free text is entered
413
+	 *
414
+	 * @since 2.0
415
+	 *
416
+	 * @param string|array $value
417
+	 * @param string|array $other_vals (usually of posted values)
418
+	 * @param object $field
419
+	 * @param array $args
420
+	 */
421
+	public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
422
+		// Checkboxes and multi-select dropdowns
423
+		if ( is_array( $value ) && $field->type == 'checkbox' ) {
424
+			// Combine "Other" values with checked values. "Other" values will override checked box values.
425
+			$value = array_merge( $value, $other_vals );
426
+			$value = array_filter( $value );
427
+			if ( count( $value ) == 0 ) {
428
+				$value = '';
429
+			}
430
+		} else {
431 431
 			// Radio and dropdowns
432
-            $other_key = array_filter( array_keys($field->options), 'is_string');
433
-            $other_key = reset( $other_key );
432
+			$other_key = array_filter( array_keys($field->options), 'is_string');
433
+			$other_key = reset( $other_key );
434 434
 
435
-            // Multi-select dropdown
436
-            if ( is_array( $value ) ) {
437
-                $o_key = array_search( $field->options[ $other_key ], $value );
435
+			// Multi-select dropdown
436
+			if ( is_array( $value ) ) {
437
+				$o_key = array_search( $field->options[ $other_key ], $value );
438 438
 
439 439
 				if ( $o_key !== false ) {
440 440
 					// Modify the original value so other key will be preserved
@@ -449,20 +449,20 @@  discard block
 block discarded – undo
449 449
 					$args['temp_value'] = $value;
450 450
 					$value[ $other_key ] = reset( $other_vals );
451 451
 				}
452
-            } else if ( $field->options[ $other_key ] == $value ) {
453
-                $value = $other_vals;
454
-            }
455
-        }
456
-    }
452
+			} else if ( $field->options[ $other_key ] == $value ) {
453
+				$value = $other_vals;
454
+			}
455
+		}
456
+	}
457 457
 
458 458
 	public static function enqueue_scripts( $params ) {
459 459
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormsController::enqueue_scripts' );
460 460
 		FrmFormsController::enqueue_scripts( $params );
461 461
 	}
462 462
 
463
-    // Add submitted values to a string for spam checking
463
+	// Add submitted values to a string for spam checking
464 464
 	public static function entry_array_to_string( $values ) {
465
-        $content = '';
465
+		$content = '';
466 466
 		foreach ( $values['item_meta'] as $val ) {
467 467
 			if ( $content != '' ) {
468 468
 				$content .= "\n\n";
@@ -470,14 +470,14 @@  discard block
 block discarded – undo
470 470
 
471 471
 			if ( is_array($val) ) {
472 472
 				$val = FrmAppHelper::array_flatten( $val );
473
-			    $val = implode(',', $val);
473
+				$val = implode(',', $val);
474 474
 			}
475 475
 
476 476
 			$content .= $val;
477 477
 		}
478 478
 
479 479
 		return $content;
480
-    }
480
+	}
481 481
 
482 482
 	public static function fill_entry_values( $atts, $f, array &$values ) {
483 483
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::fill_entry_values' );
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 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,12 +8,12 @@  discard block
 block discarded – undo
8 8
     public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9 9
         $values = array();
10 10
 		foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) {
11
-			$values[ $var ] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' );
11
+			$values[$var] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' );
12 12
         }
13 13
 
14 14
         $values['fields'] = array();
15
-        if ( empty($fields) ) {
16
-            return apply_filters('frm_setup_new_entry', $values);
15
+        if ( empty( $fields ) ) {
16
+            return apply_filters( 'frm_setup_new_entry', $values );
17 17
         }
18 18
 
19 19
         foreach ( (array) $fields as $field ) {
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
                 'default_value' => $field->default_value,
26 26
                 'name' => $field->name,
27 27
                 'description' => $field->description,
28
-                'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
28
+                'type' => apply_filters( 'frm_field_type', $field->type, $field, $new_value ),
29 29
                 'options' => $field->options,
30 30
                 'required' => $field->required,
31 31
                 'field_key' => $field->field_key,
@@ -36,43 +36,43 @@  discard block
 block discarded – undo
36 36
 				'in_embed_form' => isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0',
37 37
             );
38 38
 
39
-            $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
39
+            $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
40 40
             $opt_defaults['required_indicator'] = '';
41 41
 			$opt_defaults['original_type'] = $field->type;
42 42
 
43 43
 			foreach ( $opt_defaults as $opt => $default_opt ) {
44
-                $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
45
-                unset($opt, $default_opt);
44
+                $field_array[$opt] = ( isset( $field->field_options[$opt] ) && $field->field_options[$opt] != '' ) ? $field->field_options[$opt] : $default_opt;
45
+                unset( $opt, $default_opt );
46 46
             }
47 47
 
48
-            unset($opt_defaults);
48
+            unset( $opt_defaults );
49 49
 
50 50
             if ( $field_array['custom_html'] == '' ) {
51
-                $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
51
+                $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $field->type );
52 52
             }
53 53
 
54
-            $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args );
54
+            $field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field, $args );
55 55
             $field_array = array_merge( $field->field_options, $field_array );
56 56
 
57 57
             $values['fields'][] = $field_array;
58 58
 
59
-            if ( ! $form || ! isset($form->id) ) {
60
-                $form = FrmForm::getOne($field->form_id);
59
+            if ( ! $form || ! isset( $form->id ) ) {
60
+                $form = FrmForm::getOne( $field->form_id );
61 61
             }
62 62
         }
63 63
 
64
-        $form->options = maybe_unserialize($form->options);
65
-        if ( is_array($form->options) ) {
64
+        $form->options = maybe_unserialize( $form->options );
65
+        if ( is_array( $form->options ) ) {
66 66
             foreach ( $form->options as $opt => $value ) {
67
-                $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
68
-                unset($opt, $value);
67
+                $values[$opt] = FrmAppHelper::get_post_param( $opt, $value );
68
+                unset( $opt, $value );
69 69
             }
70 70
         }
71 71
 
72 72
 		$form_defaults = FrmFormsHelper::get_default_opts();
73 73
 
74 74
 		$frm_settings = FrmAppHelper::get_settings();
75
-		$form_defaults['custom_style']  = ( $frm_settings->load_style != 'none' );
75
+		$form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' );
76 76
 
77 77
 		$values = array_merge( $form_defaults, $values );
78 78
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		$return_array = FrmField::is_field_with_multiple_values( $field );
96 96
 
97 97
 		// Do any shortcodes in default value and allow customization of default value
98
-		$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array);
98
+		$field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true, $return_array );
99 99
 		// Calls FrmProFieldsHelper::get_default_value
100 100
 
101 101
 		$new_value = $field->default_value;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		}
109 109
 
110 110
 		if ( ! is_array( $new_value ) ) {
111
-			$new_value = str_replace('"', '&quot;', $new_value);
111
+			$new_value = str_replace( '"', '&quot;', $new_value );
112 112
 		}
113 113
 
114 114
 		return $new_value;
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 		if ( $_POST ) {
128 128
 			$repeating = isset( $args['repeating'] ) && $args['repeating'];
129 129
 			if ( $repeating ) {
130
-				if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) {
130
+				if ( isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] ) ) {
131 131
 					$value_is_posted = true;
132 132
 				}
133
-			} else if ( isset( $_POST['item_meta'][ $field->id ] ) ) {
133
+			} else if ( isset( $_POST['item_meta'][$field->id] ) ) {
134 134
 				$value_is_posted = true;
135 135
 			}
136 136
 		}
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
142 142
         $values['form_id'] = $record->form_id;
143 143
         $values['is_draft'] = $record->is_draft;
144
-        return apply_filters('frm_setup_edit_entry_vars', $values, $record);
144
+        return apply_filters( 'frm_setup_edit_entry_vars', $values, $record );
145 145
     }
146 146
 
147 147
     public static function get_admin_params( $form = null ) {
@@ -170,22 +170,22 @@  discard block
 block discarded – undo
170 170
     }
171 171
 
172 172
 	public static function replace_default_message( $message, $atts ) {
173
-        if ( strpos($message, '[default-message') === false &&
174
-            strpos($message, '[default_message') === false &&
173
+        if ( strpos( $message, '[default-message' ) === false &&
174
+            strpos( $message, '[default_message' ) === false &&
175 175
             ! empty( $message ) ) {
176 176
             return $message;
177 177
         }
178 178
 
179
-        if ( empty($message) ) {
179
+        if ( empty( $message ) ) {
180 180
             $message = '[default-message]';
181 181
         }
182 182
 
183
-        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
183
+        preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
184 184
 
185 185
         foreach ( $shortcodes[0] as $short_key => $tag ) {
186
-            $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
186
+            $add_atts = shortcode_parse_atts( $shortcodes[2][$short_key] );
187 187
             if ( $add_atts ) {
188
-                $this_atts = array_merge($atts, $add_atts);
188
+                $this_atts = array_merge( $atts, $add_atts );
189 189
             } else {
190 190
                 $this_atts = $atts;
191 191
             }
@@ -193,32 +193,32 @@  discard block
 block discarded – undo
193 193
 			$default = FrmEntryFormat::show_entry( $this_atts );
194 194
 
195 195
             // Add the default message
196
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
196
+            $message = str_replace( $shortcodes[0][$short_key], $default, $message );
197 197
         }
198 198
 
199 199
         return $message;
200 200
     }
201 201
 
202 202
 	public static function prepare_display_value( $entry, $field, $atts ) {
203
-		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
203
+		$field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false;
204 204
 
205 205
         if ( FrmAppHelper::pro_is_installed() ) {
206 206
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
207 207
         }
208 208
 
209
-        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
210
-            return self::display_value($field_value, $field, $atts);
209
+        if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) {
210
+            return self::display_value( $field_value, $field, $atts );
211 211
         }
212 212
 
213 213
         // this is an embeded form
214 214
         $val = '';
215 215
 
216
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
216
+	    if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) {
217 217
             //this is a repeating section
218 218
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
219 219
         } else {
220 220
             // get all values for this field
221
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
221
+	        $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false;
222 222
 
223 223
             if ( $child_values ) {
224 224
 	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 
228 228
 	    $field_value = array();
229 229
 
230
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
230
+        if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
231 231
             return $val;
232 232
         }
233 233
 
@@ -236,17 +236,17 @@  discard block
 block discarded – undo
236 236
             $atts['post_id'] = $child_entry->post_id;
237 237
 
238 238
             // get the value for this field -- check for post values as well
239
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
239
+            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field );
240 240
 
241 241
             if ( $entry_val ) {
242 242
                 // foreach entry get display_value
243
-                $field_value[] = self::display_value($entry_val, $field, $atts);
243
+                $field_value[] = self::display_value( $entry_val, $field, $atts );
244 244
             }
245 245
 
246
-            unset($child_entry);
246
+            unset( $child_entry );
247 247
         }
248 248
 
249
-        $val = implode(', ', (array) $field_value );
249
+        $val = implode( ', ', (array) $field_value );
250 250
 		$val = wp_kses_post( $val );
251 251
 
252 252
         return $val;
@@ -266,22 +266,22 @@  discard block
 block discarded – undo
266 266
         );
267 267
 
268 268
         $atts = wp_parse_args( $atts, $defaults );
269
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
269
+        $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value );
270 270
 
271
-        if ( ! isset($field->field_options['post_field']) ) {
271
+        if ( ! isset( $field->field_options['post_field'] ) ) {
272 272
             $field->field_options['post_field'] = '';
273 273
         }
274 274
 
275
-        if ( ! isset($field->field_options['custom_field']) ) {
275
+        if ( ! isset( $field->field_options['custom_field'] ) ) {
276 276
             $field->field_options['custom_field'] = '';
277 277
         }
278 278
 
279 279
         if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
280 280
             $atts['pre_truncate'] = $atts['truncate'];
281 281
             $atts['truncate'] = true;
282
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
282
+            $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0;
283 283
 
284
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
284
+            $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts );
285 285
             $atts['truncate'] = $atts['pre_truncate'];
286 286
         }
287 287
 
@@ -289,39 +289,39 @@  discard block
 block discarded – undo
289 289
             return $value;
290 290
         }
291 291
 
292
-        $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
292
+        $value = apply_filters( 'frm_display_value_custom', maybe_unserialize( $value ), $field, $atts );
293 293
 		$value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) );
294 294
 
295 295
         $new_value = '';
296 296
 
297
-        if ( is_array($value) && $atts['type'] != 'file' ) {
297
+        if ( is_array( $value ) && $atts['type'] != 'file' ) {
298 298
             foreach ( $value as $val ) {
299
-                if ( is_array($val) ) {
299
+                if ( is_array( $val ) ) {
300 300
 					//TODO: add options for display (li or ,)
301
-                    $new_value .= implode($atts['sep'], $val);
301
+                    $new_value .= implode( $atts['sep'], $val );
302 302
                     if ( $atts['type'] != 'data' ) {
303 303
                         $new_value .= '<br/>';
304 304
                     }
305 305
                 }
306
-                unset($val);
306
+                unset( $val );
307 307
             }
308 308
         }
309 309
 
310
-        if ( ! empty($new_value) ) {
310
+        if ( ! empty( $new_value ) ) {
311 311
             $value = $new_value;
312
-        } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
313
-            $value = implode($atts['sep'], $value);
312
+        } else if ( is_array( $value ) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
313
+            $value = implode( $atts['sep'], $value );
314 314
         }
315 315
 
316 316
         if ( $atts['truncate'] && $atts['type'] != 'image' ) {
317
-            $value = FrmAppHelper::truncate($value, 50);
317
+            $value = FrmAppHelper::truncate( $value, 50 );
318 318
         }
319 319
 
320 320
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
321 321
 			$value = wp_kses_post( $value );
322 322
 		}
323 323
 
324
-        return apply_filters('frm_display_value', $value, $field, $atts);
324
+        return apply_filters( 'frm_display_value', $value, $field, $atts );
325 325
     }
326 326
 
327 327
 	public static function set_posted_value( $field, $value, $args ) {
@@ -329,20 +329,20 @@  discard block
 block discarded – undo
329 329
         if ( isset( $args['other'] ) && $args['other'] ) {
330 330
             $value = $args['temp_value'];
331 331
         }
332
-        if ( empty($args['parent_field_id']) ) {
333
-            $_POST['item_meta'][ $field->id ] = $value;
332
+        if ( empty( $args['parent_field_id'] ) ) {
333
+            $_POST['item_meta'][$field->id] = $value;
334 334
         } else {
335
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
335
+            $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value;
336 336
         }
337 337
     }
338 338
 
339 339
 	public static function get_posted_value( $field, &$value, $args ) {
340 340
 		$field_id = is_object( $field ) ? $field->id : $field;
341 341
 
342
-        if ( empty($args['parent_field_id']) ) {
343
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
342
+        if ( empty( $args['parent_field_id'] ) ) {
343
+            $value = isset( $_POST['item_meta'][$field_id] ) ? $_POST['item_meta'][$field_id] : '';
344 344
         } else {
345
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
345
+            $value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] : '';
346 346
         }
347 347
     }
348 348
 
@@ -365,12 +365,12 @@  discard block
 block discarded – undo
365 365
         self::set_other_repeating_vals( $field, $value, $args );
366 366
 
367 367
         // Check if there are any posted "Other" values
368
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
368
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) {
369 369
 
370 370
             // Save original value
371 371
             $args['temp_value'] = $value;
372 372
             $args['other'] = true;
373
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
373
+            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][$field->id] );
374 374
 
375 375
             // Set the validation value now
376 376
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -392,12 +392,12 @@  discard block
 block discarded – undo
392 392
         }
393 393
 
394 394
         // Check if there are any other posted "other" values for this field
395
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
395
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) {
396 396
             // Save original value
397 397
             $args['temp_value'] = $value;
398 398
             $args['other'] = true;
399 399
 
400
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
400
+            $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id];
401 401
 
402 402
             // Set the validation value now
403 403
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -429,27 +429,27 @@  discard block
 block discarded – undo
429 429
             }
430 430
         } else {
431 431
 			// Radio and dropdowns
432
-            $other_key = array_filter( array_keys($field->options), 'is_string');
432
+            $other_key = array_filter( array_keys( $field->options ), 'is_string' );
433 433
             $other_key = reset( $other_key );
434 434
 
435 435
             // Multi-select dropdown
436 436
             if ( is_array( $value ) ) {
437
-                $o_key = array_search( $field->options[ $other_key ], $value );
437
+                $o_key = array_search( $field->options[$other_key], $value );
438 438
 
439 439
 				if ( $o_key !== false ) {
440 440
 					// Modify the original value so other key will be preserved
441
-					$value[ $other_key ] = $value[ $o_key ];
441
+					$value[$other_key] = $value[$o_key];
442 442
 
443 443
 					// By default, the array keys will be numeric for multi-select dropdowns
444 444
 					// If going backwards and forwards between pages, the array key will match the other key
445 445
 					if ( $o_key != $other_key ) {
446
-						unset( $value[ $o_key ] );
446
+						unset( $value[$o_key] );
447 447
 					}
448 448
 
449 449
 					$args['temp_value'] = $value;
450
-					$value[ $other_key ] = reset( $other_vals );
450
+					$value[$other_key] = reset( $other_vals );
451 451
 				}
452
-            } else if ( $field->options[ $other_key ] == $value ) {
452
+            } else if ( $field->options[$other_key] == $value ) {
453 453
                 $value = $other_vals;
454 454
             }
455 455
         }
@@ -468,9 +468,9 @@  discard block
 block discarded – undo
468 468
 				$content .= "\n\n";
469 469
 			}
470 470
 
471
-			if ( is_array($val) ) {
471
+			if ( is_array( $val ) ) {
472 472
 				$val = FrmAppHelper::array_flatten( $val );
473
-			    $val = implode(',', $val);
473
+			    $val = implode( ',', $val );
474 474
 			}
475 475
 
476 476
 			$content .= $val;
@@ -515,6 +515,6 @@  discard block
 block discarded – undo
515 515
 	}
516 516
 
517 517
 	public static function entries_dropdown() {
518
-		_deprecated_function( __FUNCTION__, '1.07.09');
518
+		_deprecated_function( __FUNCTION__, '1.07.09' );
519 519
 	}
520 520
 }
Please login to merge, or discard this patch.