Completed
Push — master ( cf7f66...9ae722 )
by Jamie
04:12
created
classes/helpers/FrmAppHelper.php 2 patches
Doc Comments   +10 added lines, -1 removed lines patch added patch discarded remove patch
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 	 * Sanitize the value, and allow some HTML
363 363
 	 * @since 2.0
364 364
 	 * @param string $value
365
-	 * @param array $allowed
365
+	 * @param string[] $allowed
366 366
 	 * @return string
367 367
 	 */
368 368
 	public static function kses( $value, $allowed = array() ) {
@@ -779,6 +779,9 @@  discard block
 block discarded – undo
779 779
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
780 780
     }
781 781
 
782
+	/**
783
+	 * @param string $function
784
+	 */
782 785
 	public static function recursive_function_map( $value, $function ) {
783 786
 		if ( is_array( $value ) ) {
784 787
 			$original_function = $function;
@@ -1198,6 +1201,9 @@  discard block
 block discarded – undo
1198 1201
         return $sub . (($len < $original_len) ? $continue : '');
1199 1202
     }
1200 1203
 
1204
+	/**
1205
+	 * @param string[] $function_names
1206
+	 */
1201 1207
 	public static function mb_function( $function_names, $args ) {
1202 1208
 		$mb_function_name = $function_names[0];
1203 1209
 		$function_name = $function_names[1];
@@ -1231,6 +1237,9 @@  discard block
 block discarded – undo
1231 1237
         return $formatted;
1232 1238
     }
1233 1239
 
1240
+	/**
1241
+	 * @param string $time_format
1242
+	 */
1234 1243
 	private static function add_time_to_date( $time_format, $date ) {
1235 1244
 		if ( empty( $time_format ) ) {
1236 1245
 			$time_format = get_option('time_format');
Please login to merge, or discard this patch.
Indentation   +1040 added lines, -1040 removed lines patch added patch discarded remove patch
@@ -12,50 +12,50 @@  discard block
 block discarded – undo
12 12
 	 */
13 13
 	public static $plug_version = '2.02.06';
14 14
 
15
-    /**
16
-     * @since 1.07.02
17
-     *
18
-     * @param none
19
-     * @return string The version of this plugin
20
-     */
21
-    public static function plugin_version() {
22
-        return self::$plug_version;
23
-    }
24
-
25
-    public static function plugin_folder() {
26
-        return basename(self::plugin_path());
27
-    }
28
-
29
-    public static function plugin_path() {
30
-        return dirname(dirname(dirname(__FILE__)));
31
-    }
32
-
33
-    public static function plugin_url() {
34
-        //prevously FRM_URL constant
15
+	/**
16
+	 * @since 1.07.02
17
+	 *
18
+	 * @param none
19
+	 * @return string The version of this plugin
20
+	 */
21
+	public static function plugin_version() {
22
+		return self::$plug_version;
23
+	}
24
+
25
+	public static function plugin_folder() {
26
+		return basename(self::plugin_path());
27
+	}
28
+
29
+	public static function plugin_path() {
30
+		return dirname(dirname(dirname(__FILE__)));
31
+	}
32
+
33
+	public static function plugin_url() {
34
+		//prevously FRM_URL constant
35 35
 		return plugins_url( '', self::plugin_path() . '/formidable.php' );
36
-    }
36
+	}
37 37
 
38 38
 	public static function relative_plugin_url() {
39 39
 		return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() );
40 40
 	}
41 41
 
42
-    /**
43
-     * @return string Site URL
44
-     */
45
-    public static function site_url() {
46
-        return site_url();
47
-    }
48
-
49
-    /**
50
-     * Get the name of this site
51
-     * Used for [sitename] shortcode
52
-     *
53
-     * @since 2.0
54
-     * @return string
55
-     */
56
-    public static function site_name() {
57
-        return get_option('blogname');
58
-    }
42
+	/**
43
+	 * @return string Site URL
44
+	 */
45
+	public static function site_url() {
46
+		return site_url();
47
+	}
48
+
49
+	/**
50
+	 * Get the name of this site
51
+	 * Used for [sitename] shortcode
52
+	 *
53
+	 * @since 2.0
54
+	 * @return string
55
+	 */
56
+	public static function site_name() {
57
+		return get_option('blogname');
58
+	}
59 59
 
60 60
 	public static function make_affiliate_url( $url ) {
61 61
 		$affiliate_id = self::get_affiliate();
@@ -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() {
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,102 +161,102 @@  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 mixed $value - value to check
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 mixed $value - value to check
181 181
 	 * @param string
182
-     * @return boolean
183
-     */
184
-    public static function is_empty_value( $value, $empty = '' ) {
185
-        return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
186
-    }
187
-
188
-    public static function is_not_empty_value( $value, $empty = '' ) {
189
-        return ! self::is_empty_value( $value, $empty );
190
-    }
191
-
192
-    /**
193
-     * Get any value from the $_SERVER
194
-     *
195
-     * @since 2.0
196
-     * @param string $value
197
-     * @return string
198
-     */
182
+	 * @return boolean
183
+	 */
184
+	public static function is_empty_value( $value, $empty = '' ) {
185
+		return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
186
+	}
187
+
188
+	public static function is_not_empty_value( $value, $empty = '' ) {
189
+		return ! self::is_empty_value( $value, $empty );
190
+	}
191
+
192
+	/**
193
+	 * Get any value from the $_SERVER
194
+	 *
195
+	 * @since 2.0
196
+	 * @param string $value
197
+	 * @return string
198
+	 */
199 199
 	public static function get_server_value( $value ) {
200
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
201
-    }
202
-
203
-    /**
204
-     * Check for the IP address in several places
205
-     * Used by [ip] shortcode
206
-     *
207
-     * @return string The IP address of the current user
208
-     */
209
-    public static function get_ip_address() {
200
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
201
+	}
202
+
203
+	/**
204
+	 * Check for the IP address in several places
205
+	 * Used by [ip] shortcode
206
+	 *
207
+	 * @return string The IP address of the current user
208
+	 */
209
+	public static function get_ip_address() {
210 210
 		$ip = '';
211
-        foreach ( array(
212
-            'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
213
-            'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
214
-        ) as $key ) {
215
-            if ( ! isset( $_SERVER[ $key ] ) ) {
216
-                continue;
217
-            }
218
-
219
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
220
-                $ip = trim($ip); // just to be safe
221
-
222
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
223
-                    return $ip;
224
-                }
225
-            }
226
-        }
211
+		foreach ( array(
212
+			'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
213
+			'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
214
+		) as $key ) {
215
+			if ( ! isset( $_SERVER[ $key ] ) ) {
216
+				continue;
217
+			}
218
+
219
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
220
+				$ip = trim($ip); // just to be safe
221
+
222
+				if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
223
+					return $ip;
224
+				}
225
+			}
226
+		}
227 227
 
228 228
 		return sanitize_text_field( $ip );
229
-    }
229
+	}
230 230
 
231
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
232
-        if ( strpos($param, '[') ) {
233
-            $params = explode('[', $param);
234
-            $param = $params[0];
235
-        }
231
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
232
+		if ( strpos($param, '[') ) {
233
+			$params = explode('[', $param);
234
+			$param = $params[0];
235
+		}
236 236
 
237 237
 		if ( $src == 'get' ) {
238
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
239
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
240
-                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
241
-            }
238
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
239
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
240
+				$value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
241
+			}
242 242
 			self::sanitize_value( $sanitize, $value );
243 243
 		} else {
244
-            $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
245
-        }
244
+			$value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
245
+		}
246 246
 
247 247
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
248
-            foreach ( $params as $k => $p ) {
249
-                if ( ! $k || ! is_array($value) ) {
250
-                    continue;
251
-                }
248
+			foreach ( $params as $k => $p ) {
249
+				if ( ! $k || ! is_array($value) ) {
250
+					continue;
251
+				}
252 252
 
253
-                $p = trim($p, ']');
254
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
255
-            }
256
-        }
253
+				$p = trim($p, ']');
254
+				$value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
255
+			}
256
+		}
257 257
 
258
-        return $value;
259
-    }
258
+		return $value;
259
+	}
260 260
 
261 261
 	/**
262 262
 	 *
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 */
280 280
 	public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) {
281 281
 		return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
282
-    }
282
+	}
283 283
 
284 284
 	/**
285 285
 	 * Get a GET/POST/REQUEST value and sanitize it
@@ -315,12 +315,12 @@  discard block
 block discarded – undo
315 315
 	}
316 316
 
317 317
 	/**
318
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
319
-	*
320
-	* @since 2.0.8
321
-	* @param string $value
322
-	* @return string $value
323
-	*/
318
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
319
+	 *
320
+	 * @since 2.0.8
321
+	 * @param string $value
322
+	 * @return string $value
323
+	 */
324 324
 	public static function preserve_backslashes( $value ) {
325 325
 		// If backslashes have already been added, don't add them again
326 326
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -342,14 +342,14 @@  discard block
 block discarded – undo
342 342
 		}
343 343
 	}
344 344
 
345
-    public static function sanitize_request( $sanitize_method, &$values ) {
346
-        $temp_values = $values;
347
-        foreach ( $temp_values as $k => $val ) {
348
-            if ( isset( $sanitize_method[ $k ] ) ) {
345
+	public static function sanitize_request( $sanitize_method, &$values ) {
346
+		$temp_values = $values;
347
+		foreach ( $temp_values as $k => $val ) {
348
+			if ( isset( $sanitize_method[ $k ] ) ) {
349 349
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
350
-            }
351
-        }
352
-    }
350
+			}
351
+		}
352
+	}
353 353
 
354 354
 	public static function sanitize_array( &$values ) {
355 355
 		$temp_values = $values;
@@ -367,12 +367,12 @@  discard block
 block discarded – undo
367 367
 	 */
368 368
 	public static function kses( $value, $allowed = array() ) {
369 369
 		$html = array(
370
-		    'a' => array(
370
+			'a' => array(
371 371
 				'href'  => array(),
372 372
 				'title' => array(),
373 373
 				'id'    => array(),
374 374
 				'class' => array(),
375
-		    ),
375
+			),
376 376
 		);
377 377
 
378 378
 		$allowed_html = array();
@@ -383,126 +383,126 @@  discard block
 block discarded – undo
383 383
 		return wp_kses( $value, $allowed_html );
384 384
 	}
385 385
 
386
-    /**
387
-     * Used when switching the action for a bulk action
388
-     * @since 2.0
389
-     */
390
-    public static function remove_get_action() {
391
-        if ( ! isset($_GET) ) {
392
-            return;
393
-        }
386
+	/**
387
+	 * Used when switching the action for a bulk action
388
+	 * @since 2.0
389
+	 */
390
+	public static function remove_get_action() {
391
+		if ( ! isset($_GET) ) {
392
+			return;
393
+		}
394 394
 
395
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
396
-        if ( ! empty( $new_action ) ) {
395
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
396
+		if ( ! empty( $new_action ) ) {
397 397
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
398
-        }
399
-    }
400
-
401
-    /**
402
-     * Check the WP query for a parameter
403
-     *
404
-     * @since 2.0
405
-     * @return string|array
406
-     */
407
-    public static function get_query_var( $value, $param ) {
408
-        if ( $value != '' ) {
409
-            return $value;
410
-        }
411
-
412
-        global $wp_query;
413
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
414
-            $value = $wp_query->query_vars[ $param ];
415
-        }
416
-
417
-        return $value;
418
-    }
419
-
420
-    /**
421
-     * @param string $type
422
-     */
423
-    public static function trigger_hook_load( $type, $object = null ) {
424
-        // only load the form hooks once
398
+		}
399
+	}
400
+
401
+	/**
402
+	 * Check the WP query for a parameter
403
+	 *
404
+	 * @since 2.0
405
+	 * @return string|array
406
+	 */
407
+	public static function get_query_var( $value, $param ) {
408
+		if ( $value != '' ) {
409
+			return $value;
410
+		}
411
+
412
+		global $wp_query;
413
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
414
+			$value = $wp_query->query_vars[ $param ];
415
+		}
416
+
417
+		return $value;
418
+	}
419
+
420
+	/**
421
+	 * @param string $type
422
+	 */
423
+	public static function trigger_hook_load( $type, $object = null ) {
424
+		// only load the form hooks once
425 425
 		$hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
426
-        if ( ! $hooks_loaded ) {
426
+		if ( ! $hooks_loaded ) {
427 427
 			do_action( 'frm_load_' . $type . '_hooks' );
428
-        }
429
-    }
430
-
431
-    /**
432
-     * Check cache before fetching values and saving to cache
433
-     *
434
-     * @since 2.0
435
-     *
436
-     * @param string $cache_key The unique name for this cache
437
-     * @param string $group The name of the cache group
438
-     * @param string $query If blank, don't run a db call
439
-     * @param string $type The wpdb function to use with this query
440
-     * @return mixed $results The cache or query results
441
-     */
442
-    public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
443
-        $results = wp_cache_get($cache_key, $group);
444
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
445
-            return $results;
446
-        }
447
-
448
-        if ( 'get_posts' == $type ) {
449
-            $results = get_posts($query);
428
+		}
429
+	}
430
+
431
+	/**
432
+	 * Check cache before fetching values and saving to cache
433
+	 *
434
+	 * @since 2.0
435
+	 *
436
+	 * @param string $cache_key The unique name for this cache
437
+	 * @param string $group The name of the cache group
438
+	 * @param string $query If blank, don't run a db call
439
+	 * @param string $type The wpdb function to use with this query
440
+	 * @return mixed $results The cache or query results
441
+	 */
442
+	public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
443
+		$results = wp_cache_get($cache_key, $group);
444
+		if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
445
+			return $results;
446
+		}
447
+
448
+		if ( 'get_posts' == $type ) {
449
+			$results = get_posts($query);
450 450
 		} else if ( 'get_associative_results' == $type ) {
451 451
 			global $wpdb;
452 452
 			$results = $wpdb->get_results( $query, OBJECT_K );
453
-        } else {
454
-            global $wpdb;
455
-            $results = $wpdb->{$type}($query);
456
-        }
453
+		} else {
454
+			global $wpdb;
455
+			$results = $wpdb->{$type}($query);
456
+		}
457 457
 
458 458
 		if ( ! self::prevent_caching() ) {
459 459
 			wp_cache_set( $cache_key, $results, $group, $time );
460 460
 		}
461 461
 
462
-        return $results;
463
-    }
462
+		return $results;
463
+	}
464 464
 
465
-    /**
466
-     * Data that should be stored for a long time can be stored in a transient.
467
-     * First check the cache, then check the transient
468
-     * @since 2.0
469
-     * @return mixed The cached value or false
470
-     */
465
+	/**
466
+	 * Data that should be stored for a long time can be stored in a transient.
467
+	 * First check the cache, then check the transient
468
+	 * @since 2.0
469
+	 * @return mixed The cached value or false
470
+	 */
471 471
 	public static function check_cache_and_transient( $cache_key ) {
472
-        // check caching layer first
473
-        $results = self::check_cache( $cache_key );
474
-        if ( $results ) {
475
-            return $results;
476
-        }
477
-
478
-        // then check the transient
479
-        $results = get_transient($cache_key);
480
-        if ( $results ) {
481
-            wp_cache_set($cache_key, $results);
482
-        }
483
-
484
-        return $results;
485
-    }
486
-
487
-    /**
488
-     * @since 2.0
489
-     * @param string $cache_key
490
-     */
472
+		// check caching layer first
473
+		$results = self::check_cache( $cache_key );
474
+		if ( $results ) {
475
+			return $results;
476
+		}
477
+
478
+		// then check the transient
479
+		$results = get_transient($cache_key);
480
+		if ( $results ) {
481
+			wp_cache_set($cache_key, $results);
482
+		}
483
+
484
+		return $results;
485
+	}
486
+
487
+	/**
488
+	 * @since 2.0
489
+	 * @param string $cache_key
490
+	 */
491 491
 	public static function delete_cache_and_transient( $cache_key, $group = 'default' ) {
492 492
 		delete_transient($cache_key);
493 493
 		wp_cache_delete( $cache_key, $group );
494 494
 	}
495 495
 
496
-    /**
497
-     * Delete all caching in a single group
498
-     *
499
-     * @since 2.0
500
-     *
501
-     * @param string $group The name of the cache group
502
-     * @return boolean True or False
503
-     */
496
+	/**
497
+	 * Delete all caching in a single group
498
+	 *
499
+	 * @since 2.0
500
+	 *
501
+	 * @param string $group The name of the cache group
502
+	 * @return boolean True or False
503
+	 */
504 504
 	public static function cache_delete_group( $group ) {
505
-    	global $wp_object_cache;
505
+		global $wp_object_cache;
506 506
 
507 507
 		if ( is_callable( array( $wp_object_cache, '__get' ) ) ) {
508 508
 			$group_cache = $wp_object_cache->__get('cache');
@@ -522,37 +522,37 @@  discard block
 block discarded – undo
522 522
 			return true;
523 523
 		}
524 524
 
525
-    	return false;
526
-    }
525
+		return false;
526
+	}
527 527
 
528
-    /**
529
-     * Check a value from a shortcode to see if true or false.
530
-     * True when value is 1, true, 'true', 'yes'
531
-     *
532
-     * @since 1.07.10
533
-     *
534
-     * @param string $value The value to compare
535
-     * @return boolean True or False
536
-     */
528
+	/**
529
+	 * Check a value from a shortcode to see if true or false.
530
+	 * True when value is 1, true, 'true', 'yes'
531
+	 *
532
+	 * @since 1.07.10
533
+	 *
534
+	 * @param string $value The value to compare
535
+	 * @return boolean True or False
536
+	 */
537 537
 	public static function is_true( $value ) {
538
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
539
-    }
538
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
539
+	}
540 540
 
541
-    /**
542
-     * Used to filter shortcode in text widgets
543
-     */
544
-    public static function widget_text_filter_callback( $matches ) {
545
-        return do_shortcode( $matches[0] );
546
-    }
541
+	/**
542
+	 * Used to filter shortcode in text widgets
543
+	 */
544
+	public static function widget_text_filter_callback( $matches ) {
545
+		return do_shortcode( $matches[0] );
546
+	}
547 547
 
548
-    public static function get_pages() {
548
+	public static function get_pages() {
549 549
 		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
550
-    }
550
+	}
551 551
 
552
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
553
-        $pages = self::get_pages();
552
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
553
+		$pages = self::get_pages();
554 554
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
555
-    ?>
555
+	?>
556 556
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
557 557
             <option value=""> </option>
558 558
             <?php foreach ( $pages as $page ) { ?>
@@ -562,108 +562,108 @@  discard block
 block discarded – undo
562 562
             <?php } ?>
563 563
         </select>
564 564
     <?php
565
-    }
565
+	}
566 566
 
567 567
 	public static function post_edit_link( $post_id ) {
568
-        $post = get_post($post_id);
569
-        if ( $post ) {
568
+		$post = get_post($post_id);
569
+		if ( $post ) {
570 570
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
571 571
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
572
-        }
573
-        return '';
574
-    }
572
+		}
573
+		return '';
574
+	}
575 575
 
576 576
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
577
-    ?>
577
+	?>
578 578
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
579
-            echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
580
-            ?> class="frm_multiselect">
579
+			echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
580
+			?> class="frm_multiselect">
581 581
             <?php self::roles_options($capability); ?>
582 582
         </select>
583 583
     <?php
584
-    }
584
+	}
585 585
 
586 586
 	public static function roles_options( $capability ) {
587
-        global $frm_vars;
588
-        if ( isset($frm_vars['editable_roles']) ) {
589
-            $editable_roles = $frm_vars['editable_roles'];
590
-        } else {
591
-            $editable_roles = get_editable_roles();
592
-            $frm_vars['editable_roles'] = $editable_roles;
593
-        }
594
-
595
-        foreach ( $editable_roles as $role => $details ) {
596
-            $name = translate_user_role($details['name'] ); ?>
587
+		global $frm_vars;
588
+		if ( isset($frm_vars['editable_roles']) ) {
589
+			$editable_roles = $frm_vars['editable_roles'];
590
+		} else {
591
+			$editable_roles = get_editable_roles();
592
+			$frm_vars['editable_roles'] = $editable_roles;
593
+		}
594
+
595
+		foreach ( $editable_roles as $role => $details ) {
596
+			$name = translate_user_role($details['name'] ); ?>
597 597
         <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
598 598
 <?php
599
-            unset($role, $details);
600
-        }
601
-    }
599
+			unset($role, $details);
600
+		}
601
+	}
602 602
 
603 603
 	public static function frm_capabilities( $type = 'auto' ) {
604
-        $cap = array(
605
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
606
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
607
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
608
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
609
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
610
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
611
-        );
604
+		$cap = array(
605
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
606
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
607
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
608
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
609
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
610
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
611
+		);
612 612
 
613 613
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
614
-            return $cap;
615
-        }
614
+			return $cap;
615
+		}
616 616
 
617
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
618
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
619
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
620
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
617
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
618
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
619
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
620
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
621 621
 
622
-        return $cap;
623
-    }
622
+		return $cap;
623
+	}
624 624
 
625 625
 	public static function user_has_permission( $needed_role ) {
626
-        if ( $needed_role == '-1' ) {
627
-            return false;
626
+		if ( $needed_role == '-1' ) {
627
+			return false;
628 628
 		}
629 629
 
630
-        // $needed_role will be equal to blank if "Logged-in users" is selected
631
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
632
-            return true;
633
-        }
630
+		// $needed_role will be equal to blank if "Logged-in users" is selected
631
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
632
+			return true;
633
+		}
634 634
 
635
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
636
-        foreach ( $roles as $role ) {
635
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
636
+		foreach ( $roles as $role ) {
637 637
 			if ( current_user_can( $role ) ) {
638
-        		return true;
638
+				return true;
639 639
 			}
640
-        	if ( $role == $needed_role ) {
641
-        		break;
640
+			if ( $role == $needed_role ) {
641
+				break;
642 642
 			}
643
-        }
644
-        return false;
645
-    }
646
-
647
-    /**
648
-     * Make sure administrators can see Formidable menu
649
-     *
650
-     * @since 2.0
651
-     */
652
-    public static function maybe_add_permissions() {
643
+		}
644
+		return false;
645
+	}
646
+
647
+	/**
648
+	 * Make sure administrators can see Formidable menu
649
+	 *
650
+	 * @since 2.0
651
+	 */
652
+	public static function maybe_add_permissions() {
653 653
 		self::force_capability( 'frm_view_entries' );
654 654
 
655
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
656
-            return;
657
-        }
655
+		if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
656
+			return;
657
+		}
658 658
 
659 659
 		$user_id = get_current_user_id();
660 660
 		$user = new WP_User( $user_id );
661
-        $frm_roles = self::frm_capabilities();
662
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
661
+		$frm_roles = self::frm_capabilities();
662
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
663 663
 			$user->add_cap( $frm_role );
664
-            unset($frm_role, $frm_role_description);
665
-        }
666
-    }
664
+			unset($frm_role, $frm_role_description);
665
+		}
666
+	}
667 667
 
668 668
 	/**
669 669
 	 * Make sure admins have permission to see the menu items
@@ -679,28 +679,28 @@  discard block
 block discarded – undo
679 679
 		}
680 680
 	}
681 681
 
682
-    /**
683
-     * Check if the user has permision for action.
684
-     * Return permission message and stop the action if no permission
685
-     * @since 2.0
686
-     * @param string $permission
687
-     */
682
+	/**
683
+	 * Check if the user has permision for action.
684
+	 * Return permission message and stop the action if no permission
685
+	 * @since 2.0
686
+	 * @param string $permission
687
+	 */
688 688
 	public static function permission_check( $permission, $show_message = 'show' ) {
689
-        $permission_error = self::permission_nonce_error($permission);
690
-        if ( $permission_error !== false ) {
691
-            if ( 'hide' == $show_message ) {
692
-                $permission_error = '';
693
-            }
694
-            wp_die($permission_error);
695
-        }
696
-    }
697
-
698
-    /**
699
-     * Check user permission and nonce
700
-     * @since 2.0
701
-     * @param string $permission
702
-     * @return false|string The permission message or false if allowed
703
-     */
689
+		$permission_error = self::permission_nonce_error($permission);
690
+		if ( $permission_error !== false ) {
691
+			if ( 'hide' == $show_message ) {
692
+				$permission_error = '';
693
+			}
694
+			wp_die($permission_error);
695
+		}
696
+	}
697
+
698
+	/**
699
+	 * Check user permission and nonce
700
+	 * @since 2.0
701
+	 * @param string $permission
702
+	 * @return false|string The permission message or false if allowed
703
+	 */
704 704
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
705 705
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
706 706
 			$frm_settings = self::get_settings();
@@ -708,23 +708,23 @@  discard block
 block discarded – undo
708 708
 		}
709 709
 
710 710
 		$error = false;
711
-        if ( empty($nonce_name) ) {
712
-            return $error;
713
-        }
711
+		if ( empty($nonce_name) ) {
712
+			return $error;
713
+		}
714 714
 
715
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
716
-            $frm_settings = self::get_settings();
717
-            $error = $frm_settings->admin_permission;
718
-        }
715
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
716
+			$frm_settings = self::get_settings();
717
+			$error = $frm_settings->admin_permission;
718
+		}
719 719
 
720
-        return $error;
721
-    }
720
+		return $error;
721
+	}
722 722
 
723
-    public static function checked( $values, $current ) {
723
+	public static function checked( $values, $current ) {
724 724
 		if ( self::check_selected( $values, $current ) ) {
725
-            echo ' checked="checked"';
725
+			echo ' checked="checked"';
726 726
 		}
727
-    }
727
+	}
728 728
 
729 729
 	public static function check_selected( $values, $current ) {
730 730
 		$values = self::recursive_function_map( $values, 'trim' );
@@ -734,50 +734,50 @@  discard block
 block discarded – undo
734 734
 		return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current );
735 735
 	}
736 736
 
737
-    /**
738
-    * Check if current field option is an "other" option
739
-    *
740
-    * @since 2.0
741
-    *
742
-    * @param string $opt_key
743
-    * @return boolean Returns true if current field option is an "Other" option
744
-    */
745
-    public static function is_other_opt( $opt_key ) {
746
-        _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
747
-        return FrmFieldsHelper::is_other_opt( $opt_key );
748
-    }
749
-
750
-    /**
751
-    * Get value that belongs in "Other" text box
752
-    *
753
-    * @since 2.0
754
-    *
755
-    * @param string $opt_key
756
-    * @param array $field
757
-    * @return string $other_val
758
-    */
759
-    public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
737
+	/**
738
+	 * Check if current field option is an "other" option
739
+	 *
740
+	 * @since 2.0
741
+	 *
742
+	 * @param string $opt_key
743
+	 * @return boolean Returns true if current field option is an "Other" option
744
+	 */
745
+	public static function is_other_opt( $opt_key ) {
746
+		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
747
+		return FrmFieldsHelper::is_other_opt( $opt_key );
748
+	}
749
+
750
+	/**
751
+	 * Get value that belongs in "Other" text box
752
+	 *
753
+	 * @since 2.0
754
+	 *
755
+	 * @param string $opt_key
756
+	 * @param array $field
757
+	 * @return string $other_val
758
+	 */
759
+	public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
760 760
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' );
761 761
 		return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) );
762
-    }
763
-
764
-    /**
765
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
766
-    * Intended for front-end use
767
-    *
768
-    * @since 2.0
769
-    *
770
-    * @param array $field
771
-    * @param boolean $other_opt
772
-    * @param string $checked
773
-    * @param array $args should include opt_key and field name
774
-    * @return string $other_val
775
-    */
776
-    public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
762
+	}
763
+
764
+	/**
765
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
766
+	 * Intended for front-end use
767
+	 *
768
+	 * @since 2.0
769
+	 *
770
+	 * @param array $field
771
+	 * @param boolean $other_opt
772
+	 * @param string $checked
773
+	 * @param array $args should include opt_key and field name
774
+	 * @return string $other_val
775
+	 */
776
+	public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
777 777
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' );
778 778
 		$args['field'] = $field;
779 779
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
780
-    }
780
+	}
781 781
 
782 782
 	public static function recursive_function_map( $value, $function ) {
783 783
 		if ( is_array( $value ) ) {
@@ -807,24 +807,24 @@  discard block
 block discarded – undo
807 807
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
808 808
 	}
809 809
 
810
-    /**
811
-     * Flatten a multi-dimensional array
812
-     */
810
+	/**
811
+	 * Flatten a multi-dimensional array
812
+	 */
813 813
 	public static function array_flatten( $array, $keys = 'keep' ) {
814
-        $return = array();
815
-        foreach ( $array as $key => $value ) {
816
-            if ( is_array($value) ) {
814
+		$return = array();
815
+		foreach ( $array as $key => $value ) {
816
+			if ( is_array($value) ) {
817 817
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
818
-            } else {
818
+			} else {
819 819
 				if ( $keys == 'keep' ) {
820 820
 					$return[ $key ] = $value;
821 821
 				} else {
822 822
 					$return[] = $value;
823 823
 				}
824
-            }
825
-        }
826
-        return $return;
827
-    }
824
+			}
825
+		}
826
+		return $return;
827
+	}
828 828
 
829 829
 	public static function esc_textarea( $text, $is_rich_text = false ) {
830 830
 		$safe_text = str_replace( '&quot;', '"', $text );
@@ -835,308 +835,308 @@  discard block
 block discarded – undo
835 835
 		return apply_filters( 'esc_textarea', $safe_text, $text );
836 836
 	}
837 837
 
838
-    /**
839
-     * Add auto paragraphs to text areas
840
-     * @since 2.0
841
-     */
838
+	/**
839
+	 * Add auto paragraphs to text areas
840
+	 * @since 2.0
841
+	 */
842 842
 	public static function use_wpautop( $content ) {
843
-        if ( apply_filters('frm_use_wpautop', true) ) {
844
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
845
-        }
846
-        return $content;
847
-    }
843
+		if ( apply_filters('frm_use_wpautop', true) ) {
844
+			$content = wpautop(str_replace( '<br>', '<br />', $content));
845
+		}
846
+		return $content;
847
+	}
848 848
 
849 849
 	public static function replace_quotes( $val ) {
850
-        //Replace double quotes
850
+		//Replace double quotes
851 851
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
852
-        //Replace single quotes
853
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
854
-        return $val;
855
-    }
856
-
857
-    /**
858
-     * @since 2.0
859
-     * @return string The base Google APIS url for the current version of jQuery UI
860
-     */
861
-    public static function jquery_ui_base_url() {
852
+		//Replace single quotes
853
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
854
+		return $val;
855
+	}
856
+
857
+	/**
858
+	 * @since 2.0
859
+	 * @return string The base Google APIS url for the current version of jQuery UI
860
+	 */
861
+	public static function jquery_ui_base_url() {
862 862
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core');
863
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
864
-        return $url;
865
-    }
863
+		$url = apply_filters('frm_jquery_ui_base_url', $url);
864
+		return $url;
865
+	}
866 866
 
867
-    /**
868
-     * @param string $handle
869
-     */
867
+	/**
868
+	 * @param string $handle
869
+	 */
870 870
 	public static function script_version( $handle ) {
871
-        global $wp_scripts;
872
-    	if ( ! $wp_scripts ) {
873
-    	    return false;
874
-    	}
871
+		global $wp_scripts;
872
+		if ( ! $wp_scripts ) {
873
+			return false;
874
+		}
875 875
 
876
-        $ver = 0;
876
+		$ver = 0;
877 877
 
878
-        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
879
-            return $ver;
880
-        }
878
+		if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
879
+			return $ver;
880
+		}
881 881
 
882
-        $query = $wp_scripts->registered[ $handle ];
883
-    	if ( is_object( $query ) ) {
884
-    	    $ver = $query->ver;
885
-    	}
882
+		$query = $wp_scripts->registered[ $handle ];
883
+		if ( is_object( $query ) ) {
884
+			$ver = $query->ver;
885
+		}
886 886
 
887
-    	return $ver;
888
-    }
887
+		return $ver;
888
+	}
889 889
 
890 890
 	public static function js_redirect( $url ) {
891 891
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
892
-    }
892
+	}
893 893
 
894 894
 	public static function get_user_id_param( $user_id ) {
895
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
896
-            return $user_id;
897
-        }
895
+		if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
896
+			return $user_id;
897
+		}
898 898
 
899 899
 		if ( $user_id == 'current' ) {
900 900
 			$user_id = get_current_user_id();
901 901
 		} else {
902
-            if ( is_email($user_id) ) {
903
-                $user = get_user_by('email', $user_id);
904
-            } else {
905
-                $user = get_user_by('login', $user_id);
906
-            }
902
+			if ( is_email($user_id) ) {
903
+				$user = get_user_by('email', $user_id);
904
+			} else {
905
+				$user = get_user_by('login', $user_id);
906
+			}
907 907
 
908
-            if ( $user ) {
909
-                $user_id = $user->ID;
910
-            }
911
-            unset($user);
912
-        }
908
+			if ( $user ) {
909
+				$user_id = $user->ID;
910
+			}
911
+			unset($user);
912
+		}
913 913
 
914
-        return $user_id;
915
-    }
914
+		return $user_id;
915
+	}
916 916
 
917 917
 	public static function get_file_contents( $filename, $atts = array() ) {
918
-        if ( ! is_file($filename) ) {
919
-            return false;
920
-        }
921
-
922
-        extract($atts);
923
-        ob_start();
924
-        include($filename);
925
-        $contents = ob_get_contents();
926
-        ob_end_clean();
927
-        return $contents;
928
-    }
929
-
930
-    /**
931
-     * @param string $table_name
932
-     * @param string $column
918
+		if ( ! is_file($filename) ) {
919
+			return false;
920
+		}
921
+
922
+		extract($atts);
923
+		ob_start();
924
+		include($filename);
925
+		$contents = ob_get_contents();
926
+		ob_end_clean();
927
+		return $contents;
928
+	}
929
+
930
+	/**
931
+	 * @param string $table_name
932
+	 * @param string $column
933 933
 	 * @param int $id
934 934
 	 * @param int $num_chars
935
-     */
936
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
937
-        $key = '';
935
+	 */
936
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
937
+		$key = '';
938 938
 
939
-        if ( ! empty( $name ) ) {
940
-            $key = sanitize_key($name);
941
-        }
939
+		if ( ! empty( $name ) ) {
940
+			$key = sanitize_key($name);
941
+		}
942 942
 
943 943
 		if ( empty( $key ) ) {
944
-            $max_slug_value = pow(36, $num_chars);
945
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
946
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
947
-        }
944
+			$max_slug_value = pow(36, $num_chars);
945
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
946
+			$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
947
+		}
948 948
 
949 949
 		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
950 950
 			$key = $key . 'a';
951
-        }
951
+		}
952 952
 
953 953
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
954 954
 
955
-        if ( $key_check || is_numeric($key_check) ) {
956
-            $suffix = 2;
955
+		if ( $key_check || is_numeric($key_check) ) {
956
+			$suffix = 2;
957 957
 			do {
958 958
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
959 959
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
960 960
 				$suffix++;
961 961
 			} while ($key_check || is_numeric($key_check));
962 962
 			$key = $alt_post_name;
963
-        }
964
-        return $key;
965
-    }
966
-
967
-    /**
968
-     * Editing a Form or Entry
969
-     * @param string $table
970
-     * @return bool|array
971
-     */
972
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
973
-        if ( ! $record ) {
974
-            return false;
975
-        }
976
-
977
-        if ( empty($post_values) ) {
978
-            $post_values = stripslashes_deep($_POST);
979
-        }
963
+		}
964
+		return $key;
965
+	}
966
+
967
+	/**
968
+	 * Editing a Form or Entry
969
+	 * @param string $table
970
+	 * @return bool|array
971
+	 */
972
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
973
+		if ( ! $record ) {
974
+			return false;
975
+		}
976
+
977
+		if ( empty($post_values) ) {
978
+			$post_values = stripslashes_deep($_POST);
979
+		}
980 980
 
981 981
 		$values = array( 'id' => $record->id, 'fields' => array() );
982 982
 
983 983
 		foreach ( array( 'name', 'description' ) as $var ) {
984
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
984
+			$default_val = isset($record->{$var}) ? $record->{$var} : '';
985 985
 			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
986
-            unset($var, $default_val);
987
-        }
988
-
989
-        $values['description'] = self::use_wpautop($values['description']);
990
-        $frm_settings = self::get_settings();
991
-        $is_form_builder = self::is_admin_page('formidable' );
992
-
993
-        foreach ( (array) $fields as $field ) {
994
-            // Make sure to filter default values (for placeholder text), but not on the form builder page
995
-            if ( ! $is_form_builder ) {
996
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
997
-            }
986
+			unset($var, $default_val);
987
+		}
988
+
989
+		$values['description'] = self::use_wpautop($values['description']);
990
+		$frm_settings = self::get_settings();
991
+		$is_form_builder = self::is_admin_page('formidable' );
992
+
993
+		foreach ( (array) $fields as $field ) {
994
+			// Make sure to filter default values (for placeholder text), but not on the form builder page
995
+			if ( ! $is_form_builder ) {
996
+				$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
997
+			}
998 998
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
999 999
 			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
1000
-        }
1000
+		}
1001 1001
 
1002
-        self::fill_form_opts($record, $table, $post_values, $values);
1002
+		self::fill_form_opts($record, $table, $post_values, $values);
1003 1003
 
1004
-        if ( $table == 'entries' ) {
1005
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1006
-        } else if ( $table == 'forms' ) {
1007
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1008
-        }
1004
+		if ( $table == 'entries' ) {
1005
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1006
+		} else if ( $table == 'forms' ) {
1007
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1008
+		}
1009 1009
 
1010
-        return $values;
1011
-    }
1010
+		return $values;
1011
+	}
1012 1012
 
1013 1013
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
1014
-        $post_values = $args['post_values'];
1015
-
1016
-        if ( $args['default'] ) {
1017
-            $meta_value = $field->default_value;
1018
-        } else {
1019
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1020
-                if ( ! isset($field->field_options['custom_field']) ) {
1021
-                    $field->field_options['custom_field'] = '';
1022
-                }
1014
+		$post_values = $args['post_values'];
1015
+
1016
+		if ( $args['default'] ) {
1017
+			$meta_value = $field->default_value;
1018
+		} else {
1019
+			if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1020
+				if ( ! isset($field->field_options['custom_field']) ) {
1021
+					$field->field_options['custom_field'] = '';
1022
+				}
1023 1023
 				$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 ) );
1024
-            } else {
1024
+			} else {
1025 1025
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1026
-            }
1027
-        }
1026
+			}
1027
+		}
1028 1028
 
1029 1029
 		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1030
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1031
-
1032
-        $field_array = array(
1033
-            'id'            => $field->id,
1034
-            'value'         => $new_value,
1035
-            'default_value' => $field->default_value,
1036
-            'name'          => $field->name,
1037
-            'description'   => $field->description,
1038
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1039
-            'options'       => $field->options,
1040
-            'required'      => $field->required,
1041
-            'field_key'     => $field->field_key,
1042
-            'field_order'   => $field->field_order,
1043
-            'form_id'       => $field->form_id,
1030
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1031
+
1032
+		$field_array = array(
1033
+			'id'            => $field->id,
1034
+			'value'         => $new_value,
1035
+			'default_value' => $field->default_value,
1036
+			'name'          => $field->name,
1037
+			'description'   => $field->description,
1038
+			'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1039
+			'options'       => $field->options,
1040
+			'required'      => $field->required,
1041
+			'field_key'     => $field->field_key,
1042
+			'field_order'   => $field->field_order,
1043
+			'form_id'       => $field->form_id,
1044 1044
 			'parent_form_id' => $args['parent_form_id'],
1045
-        );
1045
+		);
1046 1046
 
1047
-        $args['field_type'] = $field_type;
1048
-        self::fill_field_opts($field, $field_array, $args);
1047
+		$args['field_type'] = $field_type;
1048
+		self::fill_field_opts($field, $field_array, $args);
1049 1049
 		// Track the original field's type
1050 1050
 		$field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type;
1051 1051
 
1052
-        $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1052
+		$field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1053 1053
 
1054
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1055
-            $field_array['unique_msg'] = '';
1056
-        }
1054
+		if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1055
+			$field_array['unique_msg'] = '';
1056
+		}
1057 1057
 
1058
-        $field_array = array_merge( $field->field_options, $field_array );
1058
+		$field_array = array_merge( $field->field_options, $field_array );
1059 1059
 
1060
-        $values['fields'][ $field->id ] = $field_array;
1061
-    }
1060
+		$values['fields'][ $field->id ] = $field_array;
1061
+	}
1062 1062
 
1063 1063
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1064
-        $post_values = $args['post_values'];
1065
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1064
+		$post_values = $args['post_values'];
1065
+		$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1066 1066
 
1067
-        foreach ( $opt_defaults as $opt => $default_opt ) {
1067
+		foreach ( $opt_defaults as $opt => $default_opt ) {
1068 1068
 			$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 );
1069
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1070
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1071
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1072
-                if ( $args['field_type'] == 'captcha' ) {
1073
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1074
-                } else {
1075
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1076
-                }
1077
-            }
1078
-        }
1079
-
1080
-        if ( $field_array['custom_html'] == '' ) {
1081
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1082
-        }
1083
-    }
1084
-
1085
-    /**
1086
-     * @param string $table
1087
-     */
1069
+			if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1070
+				$field_array[ $opt ] = $args['frm_settings']->blank_msg;
1071
+			} else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1072
+				if ( $args['field_type'] == 'captcha' ) {
1073
+					$field_array[ $opt ] = $args['frm_settings']->re_msg;
1074
+				} else {
1075
+					$field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1076
+				}
1077
+			}
1078
+		}
1079
+
1080
+		if ( $field_array['custom_html'] == '' ) {
1081
+			$field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1082
+		}
1083
+	}
1084
+
1085
+	/**
1086
+	 * @param string $table
1087
+	 */
1088 1088
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1089
-        if ( $table == 'entries' ) {
1090
-            $form = $record->form_id;
1089
+		if ( $table == 'entries' ) {
1090
+			$form = $record->form_id;
1091 1091
 			FrmForm::maybe_get_form( $form );
1092
-        } else {
1093
-            $form = $record;
1094
-        }
1092
+		} else {
1093
+			$form = $record;
1094
+		}
1095 1095
 
1096
-        if ( ! $form ) {
1097
-            return;
1098
-        }
1096
+		if ( ! $form ) {
1097
+			return;
1098
+		}
1099 1099
 
1100
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1100
+		$values['form_name'] = isset($record->form_id) ? $form->name : '';
1101 1101
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1102 1102
 
1103
-        if ( ! is_array($form->options) ) {
1104
-            return;
1105
-        }
1103
+		if ( ! is_array($form->options) ) {
1104
+			return;
1105
+		}
1106 1106
 
1107
-        foreach ( $form->options as $opt => $value ) {
1108
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1109
-        }
1107
+		foreach ( $form->options as $opt => $value ) {
1108
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1109
+		}
1110 1110
 
1111
-        self::fill_form_defaults($post_values, $values);
1112
-    }
1111
+		self::fill_form_defaults($post_values, $values);
1112
+	}
1113 1113
 
1114
-    /**
1115
-     * Set to POST value or default
1116
-     */
1114
+	/**
1115
+	 * Set to POST value or default
1116
+	 */
1117 1117
 	private static function fill_form_defaults( $post_values, array &$values ) {
1118
-        $form_defaults = FrmFormsHelper::get_default_opts();
1118
+		$form_defaults = FrmFormsHelper::get_default_opts();
1119 1119
 
1120
-        foreach ( $form_defaults as $opt => $default ) {
1121
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1120
+		foreach ( $form_defaults as $opt => $default ) {
1121
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1122 1122
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1123
-            }
1123
+			}
1124 1124
 
1125
-            unset($opt, $defaut);
1126
-        }
1125
+			unset($opt, $defaut);
1126
+		}
1127 1127
 
1128
-        if ( ! isset($values['custom_style']) ) {
1129
-            $frm_settings = self::get_settings();
1128
+		if ( ! isset($values['custom_style']) ) {
1129
+			$frm_settings = self::get_settings();
1130 1130
 			$values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' );
1131
-        }
1131
+		}
1132 1132
 
1133 1133
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1134 1134
 			if ( ! isset( $values[ $h . '_html' ] ) ) {
1135 1135
 				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1136
-            }
1137
-            unset($h);
1138
-        }
1139
-    }
1136
+			}
1137
+			unset($h);
1138
+		}
1139
+	}
1140 1140
 
1141 1141
 	public static function get_meta_value( $field_id, $entry ) {
1142 1142
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryMeta::get_meta_value' );
@@ -1144,59 +1144,59 @@  discard block
 block discarded – undo
1144 1144
 	}
1145 1145
 
1146 1146
 	public static function insert_opt_html( $args ) {
1147
-        $class = '';
1148
-        if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1149
-            $class .= 'show_frm_not_email_to';
1150
-        }
1151
-    ?>
1147
+		$class = '';
1148
+		if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1149
+			$class .= 'show_frm_not_email_to';
1150
+		}
1151
+	?>
1152 1152
 <li>
1153 1153
     <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>
1154 1154
     <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>
1155 1155
     <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>
1156 1156
 </li>
1157 1157
     <?php
1158
-    }
1158
+	}
1159 1159
 
1160 1160
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1161
-        if ( is_array( $str ) ) {
1162
-            return '';
1161
+		if ( is_array( $str ) ) {
1162
+			return '';
1163 1163
 		}
1164 1164
 
1165
-        $length = (int) $length;
1165
+		$length = (int) $length;
1166 1166
 		$str = wp_strip_all_tags( $str );
1167 1167
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1168 1168
 
1169 1169
 		if ( $length == 0 ) {
1170
-            return '';
1171
-        } else if ( $length <= 10 ) {
1170
+			return '';
1171
+		} else if ( $length <= 10 ) {
1172 1172
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1173
-            return $sub . (($length < $original_len) ? $continue : '');
1174
-        }
1173
+			return $sub . (($length < $original_len) ? $continue : '');
1174
+		}
1175 1175
 
1176
-        $sub = '';
1177
-        $len = 0;
1176
+		$sub = '';
1177
+		$len = 0;
1178 1178
 
1179 1179
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1180 1180
 
1181 1181
 		foreach ( $words as $word ) {
1182
-            $part = (($sub != '') ? ' ' : '') . $word;
1182
+			$part = (($sub != '') ? ' ' : '') . $word;
1183 1183
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1184
-            if ( $total_len > $length && str_word_count($sub) ) {
1185
-                break;
1186
-            }
1184
+			if ( $total_len > $length && str_word_count($sub) ) {
1185
+				break;
1186
+			}
1187 1187
 
1188
-            $sub .= $part;
1188
+			$sub .= $part;
1189 1189
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1190 1190
 
1191
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1192
-                break;
1193
-            }
1191
+			if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1192
+				break;
1193
+			}
1194 1194
 
1195
-            unset($total_len, $word);
1196
-        }
1195
+			unset($total_len, $word);
1196
+		}
1197 1197
 
1198
-        return $sub . (($len < $original_len) ? $continue : '');
1199
-    }
1198
+		return $sub . (($len < $original_len) ? $continue : '');
1199
+	}
1200 1200
 
1201 1201
 	public static function mb_function( $function_names, $args ) {
1202 1202
 		$mb_function_name = $function_names[0];
@@ -1208,18 +1208,18 @@  discard block
 block discarded – undo
1208 1208
 	}
1209 1209
 
1210 1210
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1211
-        if ( empty($date) ) {
1212
-            return $date;
1213
-        }
1211
+		if ( empty($date) ) {
1212
+			return $date;
1213
+		}
1214 1214
 
1215
-        if ( empty($date_format) ) {
1216
-            $date_format = get_option('date_format');
1217
-        }
1215
+		if ( empty($date_format) ) {
1216
+			$date_format = get_option('date_format');
1217
+		}
1218 1218
 
1219
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1220
-            $frmpro_settings = new FrmProSettings();
1221
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1222
-        }
1219
+		if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1220
+			$frmpro_settings = new FrmProSettings();
1221
+			$date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1222
+		}
1223 1223
 
1224 1224
 		$formatted = self::get_localized_date( $date_format, $date );
1225 1225
 
@@ -1228,8 +1228,8 @@  discard block
 block discarded – undo
1228 1228
 			$formatted .= self::add_time_to_date( $time_format, $date );
1229 1229
 		}
1230 1230
 
1231
-        return $formatted;
1232
-    }
1231
+		return $formatted;
1232
+	}
1233 1233
 
1234 1234
 	private static function add_time_to_date( $time_format, $date ) {
1235 1235
 		if ( empty( $time_format ) ) {
@@ -1310,61 +1310,61 @@  discard block
 block discarded – undo
1310 1310
 		);
1311 1311
 	}
1312 1312
 
1313
-    /**
1314
-     * Added for < WP 4.0 compatability
1315
-     *
1316
-     * @since 1.07.10
1317
-     *
1318
-     * @param string $term The value to escape
1319
-     * @return string The escaped value
1320
-     */
1313
+	/**
1314
+	 * Added for < WP 4.0 compatability
1315
+	 *
1316
+	 * @since 1.07.10
1317
+	 *
1318
+	 * @param string $term The value to escape
1319
+	 * @return string The escaped value
1320
+	 */
1321 1321
 	public static function esc_like( $term ) {
1322
-        global $wpdb;
1323
-        if ( method_exists($wpdb, 'esc_like') ) {
1322
+		global $wpdb;
1323
+		if ( method_exists($wpdb, 'esc_like') ) {
1324 1324
 			// WP 4.0
1325
-            $term = $wpdb->esc_like( $term );
1326
-        } else {
1327
-            $term = like_escape( $term );
1328
-        }
1325
+			$term = $wpdb->esc_like( $term );
1326
+		} else {
1327
+			$term = like_escape( $term );
1328
+		}
1329 1329
 
1330
-        return $term;
1331
-    }
1330
+		return $term;
1331
+	}
1332 1332
 
1333
-    /**
1334
-     * @param string $order_query
1335
-     */
1333
+	/**
1334
+	 * @param string $order_query
1335
+	 */
1336 1336
 	public static function esc_order( $order_query ) {
1337
-        if ( empty($order_query) ) {
1338
-            return '';
1339
-        }
1340
-
1341
-        // remove ORDER BY before santizing
1342
-        $order_query = strtolower($order_query);
1343
-        if ( strpos($order_query, 'order by') !== false ) {
1344
-            $order_query = str_replace('order by', '', $order_query);
1345
-        }
1346
-
1347
-        $order_query = explode(' ', trim($order_query));
1348
-
1349
-        $order_fields = array(
1350
-            'id', 'form_key', 'name', 'description',
1351
-            'parent_form_id', 'logged_in', 'is_template',
1352
-            'default_template', 'status', 'created_at',
1353
-        );
1354
-
1355
-        $order = trim(trim(reset($order_query), ','));
1356
-        if ( ! in_array($order, $order_fields) ) {
1357
-            return '';
1358
-        }
1359
-
1360
-        $order_by = '';
1361
-        if ( count($order_query) > 1 ) {
1337
+		if ( empty($order_query) ) {
1338
+			return '';
1339
+		}
1340
+
1341
+		// remove ORDER BY before santizing
1342
+		$order_query = strtolower($order_query);
1343
+		if ( strpos($order_query, 'order by') !== false ) {
1344
+			$order_query = str_replace('order by', '', $order_query);
1345
+		}
1346
+
1347
+		$order_query = explode(' ', trim($order_query));
1348
+
1349
+		$order_fields = array(
1350
+			'id', 'form_key', 'name', 'description',
1351
+			'parent_form_id', 'logged_in', 'is_template',
1352
+			'default_template', 'status', 'created_at',
1353
+		);
1354
+
1355
+		$order = trim(trim(reset($order_query), ','));
1356
+		if ( ! in_array($order, $order_fields) ) {
1357
+			return '';
1358
+		}
1359
+
1360
+		$order_by = '';
1361
+		if ( count($order_query) > 1 ) {
1362 1362
 			$order_by = end( $order_query );
1363 1363
 			self::esc_order_by( $order_by );
1364
-        }
1364
+		}
1365 1365
 
1366 1366
 		return ' ORDER BY ' . $order . ' ' . $order_by;
1367
-    }
1367
+	}
1368 1368
 
1369 1369
 	/**
1370 1370
 	 * Make sure this is ordering by either ASC or DESC
@@ -1376,169 +1376,169 @@  discard block
 block discarded – undo
1376 1376
 		}
1377 1377
 	}
1378 1378
 
1379
-    /**
1380
-     * @param string $limit
1381
-     */
1379
+	/**
1380
+	 * @param string $limit
1381
+	 */
1382 1382
 	public static function esc_limit( $limit ) {
1383
-        if ( empty($limit) ) {
1384
-            return '';
1385
-        }
1383
+		if ( empty($limit) ) {
1384
+			return '';
1385
+		}
1386 1386
 
1387
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1388
-        if ( is_numeric($limit) ) {
1387
+		$limit = trim(str_replace(' limit', '', strtolower($limit)));
1388
+		if ( is_numeric($limit) ) {
1389 1389
 			return ' LIMIT ' . $limit;
1390
-        }
1390
+		}
1391 1391
 
1392
-        $limit = explode(',', trim($limit));
1393
-        foreach ( $limit as $k => $l ) {
1394
-            if ( is_numeric( $l ) ) {
1395
-                $limit[ $k ] = $l;
1396
-            }
1397
-        }
1392
+		$limit = explode(',', trim($limit));
1393
+		foreach ( $limit as $k => $l ) {
1394
+			if ( is_numeric( $l ) ) {
1395
+				$limit[ $k ] = $l;
1396
+			}
1397
+		}
1398 1398
 
1399
-        $limit = implode(',', $limit);
1399
+		$limit = implode(',', $limit);
1400 1400
 		return ' LIMIT ' . $limit;
1401
-    }
1402
-
1403
-    /**
1404
-     * Get an array of values ready to go through $wpdb->prepare
1405
-     * @since 2.0
1406
-     */
1407
-    public static function prepare_array_values( $array, $type = '%s' ) {
1408
-        $placeholders = array_fill(0, count($array), $type);
1409
-        return implode(', ', $placeholders);
1410
-    }
1411
-
1412
-    public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1413
-        if ( empty($where) ) {
1414
-            return '';
1415
-        }
1401
+	}
1402
+
1403
+	/**
1404
+	 * Get an array of values ready to go through $wpdb->prepare
1405
+	 * @since 2.0
1406
+	 */
1407
+	public static function prepare_array_values( $array, $type = '%s' ) {
1408
+		$placeholders = array_fill(0, count($array), $type);
1409
+		return implode(', ', $placeholders);
1410
+	}
1411
+
1412
+	public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1413
+		if ( empty($where) ) {
1414
+			return '';
1415
+		}
1416 1416
 
1417 1417
 		if ( is_array( $where ) ) {
1418
-            global $wpdb;
1419
-            FrmDb::get_where_clause_and_values( $where, $starts_with );
1418
+			global $wpdb;
1419
+			FrmDb::get_where_clause_and_values( $where, $starts_with );
1420 1420
 			$where = $wpdb->prepare( $where['where'], $where['values'] );
1421 1421
 		} else {
1422
-            $where = $starts_with . $where;
1423
-        }
1422
+			$where = $starts_with . $where;
1423
+		}
1424 1424
 
1425
-        return $where;
1426
-    }
1425
+		return $where;
1426
+	}
1427 1427
 
1428
-    // Pagination Methods
1428
+	// Pagination Methods
1429 1429
 
1430
-    /**
1431
-     * @param integer $current_p
1432
-     */
1430
+	/**
1431
+	 * @param integer $current_p
1432
+	 */
1433 1433
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1434 1434
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1435 1435
 	}
1436 1436
 
1437
-    /**
1438
-     * @param integer $current_p
1439
-     */
1440
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1441
-        if ( $current_p == 1 ) {
1442
-            return 1;
1443
-        } else {
1444
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1445
-        }
1446
-    }
1437
+	/**
1438
+	 * @param integer $current_p
1439
+	 */
1440
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1441
+		if ( $current_p == 1 ) {
1442
+			return 1;
1443
+		} else {
1444
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1445
+		}
1446
+	}
1447 1447
 
1448 1448
 	/**
1449 1449
 	 * @return array
1450 1450
 	 */
1451 1451
 	public static function json_to_array( $json_vars ) {
1452
-        $vars = array();
1453
-        foreach ( $json_vars as $jv ) {
1454
-            $jv_name = explode('[', $jv['name']);
1455
-            $last = count($jv_name) - 1;
1456
-            foreach ( $jv_name as $p => $n ) {
1457
-                $name = trim($n, ']');
1458
-                if ( ! isset($l1) ) {
1459
-                    $l1 = $name;
1460
-                }
1461
-
1462
-                if ( ! isset($l2) ) {
1463
-                    $l2 = $name;
1464
-                }
1465
-
1466
-                if ( ! isset($l3) ) {
1467
-                    $l3 = $name;
1468
-                }
1469
-
1470
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1471
-
1472
-                switch ( $p ) {
1473
-                    case 0:
1474
-                        $l1 = $name;
1475
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1476
-                    break;
1477
-
1478
-                    case 1:
1479
-                        $l2 = $name;
1480
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1481
-                    break;
1482
-
1483
-                    case 2:
1484
-                        $l3 = $name;
1485
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1486
-                    break;
1487
-
1488
-                    case 3:
1489
-                        $l4 = $name;
1490
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1491
-                    break;
1492
-                }
1493
-
1494
-                unset($this_val, $n);
1495
-            }
1496
-
1497
-            unset($last, $jv);
1498
-        }
1499
-
1500
-        return $vars;
1501
-    }
1502
-
1503
-    /**
1504
-     * @param string $name
1505
-     * @param string $l1
1506
-     */
1507
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1508
-        if ( $name == '' ) {
1509
-            $vars[] = $val;
1510
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1511
-            $vars[ $l1 ] = $val;
1512
-        }
1513
-    }
1452
+		$vars = array();
1453
+		foreach ( $json_vars as $jv ) {
1454
+			$jv_name = explode('[', $jv['name']);
1455
+			$last = count($jv_name) - 1;
1456
+			foreach ( $jv_name as $p => $n ) {
1457
+				$name = trim($n, ']');
1458
+				if ( ! isset($l1) ) {
1459
+					$l1 = $name;
1460
+				}
1461
+
1462
+				if ( ! isset($l2) ) {
1463
+					$l2 = $name;
1464
+				}
1465
+
1466
+				if ( ! isset($l3) ) {
1467
+					$l3 = $name;
1468
+				}
1469
+
1470
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1471
+
1472
+				switch ( $p ) {
1473
+					case 0:
1474
+						$l1 = $name;
1475
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1476
+					break;
1477
+
1478
+					case 1:
1479
+						$l2 = $name;
1480
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1481
+					break;
1482
+
1483
+					case 2:
1484
+						$l3 = $name;
1485
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1486
+					break;
1487
+
1488
+					case 3:
1489
+						$l4 = $name;
1490
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1491
+					break;
1492
+				}
1493
+
1494
+				unset($this_val, $n);
1495
+			}
1496
+
1497
+			unset($last, $jv);
1498
+		}
1499
+
1500
+		return $vars;
1501
+	}
1502
+
1503
+	/**
1504
+	 * @param string $name
1505
+	 * @param string $l1
1506
+	 */
1507
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1508
+		if ( $name == '' ) {
1509
+			$vars[] = $val;
1510
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1511
+			$vars[ $l1 ] = $val;
1512
+		}
1513
+	}
1514 1514
 
1515 1515
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1516
-        $tooltips = array(
1517
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1518
-            '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' ),
1519
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1520
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1521
-            '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' ),
1522
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1523
-            '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() ) ),
1524
-        );
1525
-
1526
-        if ( ! isset( $tooltips[ $name ] ) ) {
1527
-            return;
1528
-        }
1529
-
1530
-        if ( 'open' == $class ) {
1531
-            echo ' frm_help"';
1532
-        } else {
1533
-            echo ' class="frm_help"';
1534
-        }
1516
+		$tooltips = array(
1517
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1518
+			'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' ),
1519
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1520
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1521
+			'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' ),
1522
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1523
+			'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() ) ),
1524
+		);
1525
+
1526
+		if ( ! isset( $tooltips[ $name ] ) ) {
1527
+			return;
1528
+		}
1529
+
1530
+		if ( 'open' == $class ) {
1531
+			echo ' frm_help"';
1532
+		} else {
1533
+			echo ' class="frm_help"';
1534
+		}
1535 1535
 
1536 1536
 		echo ' title="' . esc_attr( $tooltips[ $name ] );
1537 1537
 
1538
-        if ( 'open' != $class ) {
1539
-            echo '"';
1540
-        }
1541
-    }
1538
+		if ( 'open' != $class ) {
1539
+			echo '"';
1540
+		}
1541
+	}
1542 1542
 
1543 1543
 	/**
1544 1544
 	 * Add the current_page class to that page in the form nav
@@ -1554,35 +1554,35 @@  discard block
 block discarded – undo
1554 1554
 		}
1555 1555
 	}
1556 1556
 
1557
-    /**
1558
-     * Prepare and json_encode post content
1559
-     *
1560
-     * @since 2.0
1561
-     *
1562
-     * @param array $post_content
1563
-     * @return string $post_content ( json encoded array )
1564
-     */
1565
-    public static function prepare_and_encode( $post_content ) {
1566
-        //Loop through array to strip slashes and add only the needed ones
1557
+	/**
1558
+	 * Prepare and json_encode post content
1559
+	 *
1560
+	 * @since 2.0
1561
+	 *
1562
+	 * @param array $post_content
1563
+	 * @return string $post_content ( json encoded array )
1564
+	 */
1565
+	public static function prepare_and_encode( $post_content ) {
1566
+		//Loop through array to strip slashes and add only the needed ones
1567 1567
 		foreach ( $post_content as $key => $val ) {
1568 1568
 			// Replace problematic characters (like &quot;)
1569 1569
 			$val = str_replace( '&quot;', '"', $val );
1570 1570
 
1571 1571
 			self::prepare_action_slashes( $val, $key, $post_content );
1572
-            unset( $key, $val );
1573
-        }
1572
+			unset( $key, $val );
1573
+		}
1574 1574
 
1575
-        // json_encode the array
1576
-        $post_content = json_encode( $post_content );
1575
+		// json_encode the array
1576
+		$post_content = json_encode( $post_content );
1577 1577
 
1578
-	    // add extra slashes for \r\n since WP strips them
1578
+		// add extra slashes for \r\n since WP strips them
1579 1579
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1580 1580
 
1581
-        // allow for &quot
1582
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1581
+		// allow for &quot
1582
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1583 1583
 
1584
-        return $post_content;
1585
-    }
1584
+		return $post_content;
1585
+	}
1586 1586
 
1587 1587
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1588 1588
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1650,64 +1650,64 @@  discard block
 block discarded – undo
1650 1650
 	}
1651 1651
 
1652 1652
 	public static function maybe_json_decode( $string ) {
1653
-        if ( is_array($string) ) {
1654
-            return $string;
1655
-        }
1653
+		if ( is_array($string) ) {
1654
+			return $string;
1655
+		}
1656 1656
 
1657
-        $new_string = json_decode($string, true);
1658
-        if ( function_exists('json_last_error') ) {
1657
+		$new_string = json_decode($string, true);
1658
+		if ( function_exists('json_last_error') ) {
1659 1659
 			// php 5.3+
1660
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1661
-                $string = $new_string;
1662
-            }
1663
-        } else if ( isset($new_string) ) {
1660
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1661
+				$string = $new_string;
1662
+			}
1663
+		} else if ( isset($new_string) ) {
1664 1664
 			// php < 5.3 fallback
1665
-            $string = $new_string;
1666
-        }
1667
-        return $string;
1668
-    }
1669
-
1670
-    /**
1671
-     * @since 1.07.10
1672
-     *
1673
-     * @param string $post_type The name of the post type that may need to be highlighted
1674
-     * echo The javascript to open and highlight the Formidable menu
1675
-     */
1665
+			$string = $new_string;
1666
+		}
1667
+		return $string;
1668
+	}
1669
+
1670
+	/**
1671
+	 * @since 1.07.10
1672
+	 *
1673
+	 * @param string $post_type The name of the post type that may need to be highlighted
1674
+	 * echo The javascript to open and highlight the Formidable menu
1675
+	 */
1676 1676
 	public static function maybe_highlight_menu( $post_type ) {
1677
-        global $post;
1677
+		global $post;
1678 1678
 
1679
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1680
-            return;
1681
-        }
1679
+		if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1680
+			return;
1681
+		}
1682 1682
 
1683
-        if ( is_object($post) && $post->post_type != $post_type ) {
1684
-            return;
1685
-        }
1683
+		if ( is_object($post) && $post->post_type != $post_type ) {
1684
+			return;
1685
+		}
1686 1686
 
1687
-        self::load_admin_wide_js();
1688
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1689
-    }
1687
+		self::load_admin_wide_js();
1688
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1689
+	}
1690 1690
 
1691
-    /**
1692
-     * Load the JS file on non-Formidable pages in the admin area
1693
-     * @since 2.0
1694
-     */
1691
+	/**
1692
+	 * Load the JS file on non-Formidable pages in the admin area
1693
+	 * @since 2.0
1694
+	 */
1695 1695
 	public static function load_admin_wide_js( $load = true ) {
1696
-        $version = FrmAppHelper::plugin_version();
1696
+		$version = FrmAppHelper::plugin_version();
1697 1697
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1698 1698
 
1699
-        wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1699
+		wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1700 1700
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1701
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1701
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1702 1702
 			'url'          => FrmAppHelper::plugin_url(),
1703 1703
 			'loading'      => __( 'Loading&hellip;' ),
1704 1704
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
1705
-        ) );
1705
+		) );
1706 1706
 
1707 1707
 		if ( $load ) {
1708 1708
 			wp_enqueue_script( 'formidable_admin_global' );
1709 1709
 		}
1710
-    }
1710
+	}
1711 1711
 
1712 1712
 	/**
1713 1713
 	 * @since 2.0.9
@@ -1716,9 +1716,9 @@  discard block
 block discarded – undo
1716 1716
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1717 1717
 	}
1718 1718
 
1719
-    /**
1720
-     * @param string $location
1721
-     */
1719
+	/**
1720
+	 * @param string $location
1721
+	 */
1722 1722
 	public static function localize_script( $location ) {
1723 1723
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1724 1724
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1770,81 +1770,81 @@  discard block
 block discarded – undo
1770 1770
 		}
1771 1771
 	}
1772 1772
 
1773
-    /**
1773
+	/**
1774 1774
 	 * echo the message on the plugins listing page
1775
-     * @since 1.07.10
1776
-     *
1777
-     * @param float $min_version The version the add-on requires
1778
-     */
1775
+	 * @since 1.07.10
1776
+	 *
1777
+	 * @param float $min_version The version the add-on requires
1778
+	 */
1779 1779
 	public static function min_version_notice( $min_version ) {
1780
-        $frm_version = self::plugin_version();
1780
+		$frm_version = self::plugin_version();
1781 1781
 
1782
-        // check if Formidable meets minimum requirements
1783
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1784
-            return;
1785
-        }
1782
+		// check if Formidable meets minimum requirements
1783
+		if ( version_compare($frm_version, $min_version, '>=') ) {
1784
+			return;
1785
+		}
1786 1786
 
1787
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1787
+		$wp_list_table = _get_list_table('WP_Plugins_List_Table');
1788 1788
 		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">' .
1789
-        __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1790
-        '</div></td></tr>';
1791
-    }
1792
-
1793
-    public static function locales( $type = 'date' ) {
1794
-        $locales = array(
1795
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1796
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1797
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1798
-            'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1799
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1800
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1801
-            'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1802
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1803
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1804
-            'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1805
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1806
-            'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1807
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1808
-            'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1809
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1810
-            'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1811
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1812
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1813
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1814
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1815
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1816
-            'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1817
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1818
-            'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1819
-            'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1820
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1821
-            'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1822
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1823
-            'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1824
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1825
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1826
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1827
-        );
1828
-
1829
-        if ( $type == 'captcha' ) {
1830
-            // remove the languages unavailable for the captcha
1831
-            $unset = array(
1832
-                '', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1833
-                'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1834
-                'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1835
-            );
1836
-        } else {
1837
-            // remove the languages unavailable for the datepicker
1838
-            $unset = array(
1839
-                'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1840
-                'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1841
-                'es-419', 'tr',
1842
-            );
1843
-        }
1844
-
1845
-        $locales = array_diff_key($locales, array_flip($unset));
1846
-        $locales = apply_filters('frm_locales', $locales);
1847
-
1848
-        return $locales;
1849
-    }
1789
+		__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1790
+		'</div></td></tr>';
1791
+	}
1792
+
1793
+	public static function locales( $type = 'date' ) {
1794
+		$locales = array(
1795
+			'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1796
+			'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1797
+			'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1798
+			'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1799
+			'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1800
+			'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1801
+			'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1802
+			'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1803
+			'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1804
+			'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1805
+			'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1806
+			'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1807
+			'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1808
+			'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1809
+			'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1810
+			'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1811
+			'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1812
+			'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1813
+			'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1814
+			'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1815
+			'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1816
+			'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1817
+			'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1818
+			'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1819
+			'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1820
+			'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1821
+			'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1822
+			'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1823
+			'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1824
+			'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1825
+			'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1826
+			'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1827
+		);
1828
+
1829
+		if ( $type == 'captcha' ) {
1830
+			// remove the languages unavailable for the captcha
1831
+			$unset = array(
1832
+				'', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1833
+				'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1834
+				'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1835
+			);
1836
+		} else {
1837
+			// remove the languages unavailable for the datepicker
1838
+			$unset = array(
1839
+				'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1840
+				'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1841
+				'es-419', 'tr',
1842
+			);
1843
+		}
1844
+
1845
+		$locales = array_diff_key($locales, array_flip($unset));
1846
+		$locales = apply_filters('frm_locales', $locales);
1847
+
1848
+		return $locales;
1849
+	}
1850 1850
 }
Please login to merge, or discard this patch.