Completed
Push — master ( 81fc5d...34ed40 )
by Stephanie
02:36
created
classes/helpers/FrmAppHelper.php 1 patch
Indentation   +1017 added lines, -1017 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.05.02';
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();
@@ -70,21 +70,21 @@  discard block
 block discarded – undo
70 70
 		return absint( apply_filters( 'frm_affiliate_id', 0 ) );
71 71
 	}
72 72
 
73
-    /**
74
-     * Get the Formidable settings
75
-     *
76
-     * @since 2.0
77
-     *
78
-     * @param None
79
-     * @return FrmSettings $frm_setings
80
-     */
81
-    public static function get_settings() {
82
-        global $frm_settings;
83
-        if ( empty($frm_settings) ) {
84
-            $frm_settings = new FrmSettings();
85
-        }
86
-        return $frm_settings;
87
-    }
73
+	/**
74
+	 * Get the Formidable settings
75
+	 *
76
+	 * @since 2.0
77
+	 *
78
+	 * @param None
79
+	 * @return FrmSettings $frm_setings
80
+	 */
81
+	public static function get_settings() {
82
+		global $frm_settings;
83
+		if ( empty($frm_settings) ) {
84
+			$frm_settings = new FrmSettings();
85
+		}
86
+		return $frm_settings;
87
+	}
88 88
 
89 89
 	public static function get_menu_name() {
90 90
 		$frm_settings = FrmAppHelper::get_settings();
@@ -99,62 +99,62 @@  discard block
 block discarded – undo
99 99
 		return ! $frm_settings->no_ips;
100 100
 	}
101 101
 
102
-    /**
103
-     * Show a message in place of pro features
104
-     *
105
-     * @since 2.0
106
-     */
102
+	/**
103
+	 * Show a message in place of pro features
104
+	 *
105
+	 * @since 2.0
106
+	 */
107 107
 	public static function update_message() {
108 108
 		_deprecated_function( __FUNCTION__, '2.0.19' );
109
-    }
110
-
111
-    public static function pro_is_installed() {
112
-        return apply_filters('frm_pro_installed', false);
113
-    }
114
-
115
-    /**
116
-     * Check for certain page in Formidable settings
117
-     *
118
-     * @since 2.0
119
-     *
120
-     * @param string $page The name of the page to check
121
-     * @return boolean
122
-     */
109
+	}
110
+
111
+	public static function pro_is_installed() {
112
+		return apply_filters('frm_pro_installed', false);
113
+	}
114
+
115
+	/**
116
+	 * Check for certain page in Formidable settings
117
+	 *
118
+	 * @since 2.0
119
+	 *
120
+	 * @param string $page The name of the page to check
121
+	 * @return boolean
122
+	 */
123 123
 	public static function is_admin_page( $page = 'formidable' ) {
124
-        global $pagenow;
124
+		global $pagenow;
125 125
 		$get_page = self::simple_get( 'page', 'sanitize_title' );
126
-        if ( $pagenow ) {
126
+		if ( $pagenow ) {
127 127
 			return $pagenow == 'admin.php' && $get_page == $page;
128
-        }
128
+		}
129 129
 
130 130
 		return is_admin() && $get_page == $page;
131
-    }
132
-
133
-    /**
134
-     * Check for the form preview page
135
-     *
136
-     * @since 2.0
137
-     *
138
-     * @param None
139
-     * @return boolean
140
-     */
141
-    public static function is_preview_page() {
142
-        global $pagenow;
131
+	}
132
+
133
+	/**
134
+	 * Check for the form preview page
135
+	 *
136
+	 * @since 2.0
137
+	 *
138
+	 * @param None
139
+	 * @return boolean
140
+	 */
141
+	public static function is_preview_page() {
142
+		global $pagenow;
143 143
 		$action = FrmAppHelper::simple_get( 'action', 'sanitize_title' );
144 144
 		return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
145
-    }
145
+	}
146 146
 
147
-    /**
148
-     * Check for ajax except the form preview page
149
-     *
150
-     * @since 2.0
151
-     *
152
-     * @param None
153
-     * @return boolean
154
-     */
155
-    public static function doing_ajax() {
156
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
157
-    }
147
+	/**
148
+	 * Check for ajax except the form preview page
149
+	 *
150
+	 * @since 2.0
151
+	 *
152
+	 * @param None
153
+	 * @return boolean
154
+	 */
155
+	public static function doing_ajax() {
156
+		return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
157
+	}
158 158
 
159 159
 	/**
160 160
 	 * @since 2.0.8
@@ -164,102 +164,102 @@  discard block
 block discarded – undo
164 164
 		return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
165 165
 	}
166 166
 
167
-    /**
168
-     * Check if on an admin page
169
-     *
170
-     * @since 2.0
171
-     *
172
-     * @param None
173
-     * @return boolean
174
-     */
175
-    public static function is_admin() {
176
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
177
-    }
178
-
179
-    /**
180
-     * Check if value contains blank value or empty array
181
-     *
182
-     * @since 2.0
183
-     * @param mixed $value - value to check
167
+	/**
168
+	 * Check if on an admin page
169
+	 *
170
+	 * @since 2.0
171
+	 *
172
+	 * @param None
173
+	 * @return boolean
174
+	 */
175
+	public static function is_admin() {
176
+		return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
177
+	}
178
+
179
+	/**
180
+	 * Check if value contains blank value or empty array
181
+	 *
182
+	 * @since 2.0
183
+	 * @param mixed $value - value to check
184 184
 	 * @param string
185
-     * @return boolean
186
-     */
187
-    public static function is_empty_value( $value, $empty = '' ) {
188
-        return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
189
-    }
190
-
191
-    public static function is_not_empty_value( $value, $empty = '' ) {
192
-        return ! self::is_empty_value( $value, $empty );
193
-    }
194
-
195
-    /**
196
-     * Get any value from the $_SERVER
197
-     *
198
-     * @since 2.0
199
-     * @param string $value
200
-     * @return string
201
-     */
185
+	 * @return boolean
186
+	 */
187
+	public static function is_empty_value( $value, $empty = '' ) {
188
+		return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
189
+	}
190
+
191
+	public static function is_not_empty_value( $value, $empty = '' ) {
192
+		return ! self::is_empty_value( $value, $empty );
193
+	}
194
+
195
+	/**
196
+	 * Get any value from the $_SERVER
197
+	 *
198
+	 * @since 2.0
199
+	 * @param string $value
200
+	 * @return string
201
+	 */
202 202
 	public static function get_server_value( $value ) {
203
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
204
-    }
205
-
206
-    /**
207
-     * Check for the IP address in several places
208
-     * Used by [ip] shortcode
209
-     *
210
-     * @return string The IP address of the current user
211
-     */
212
-    public static function get_ip_address() {
203
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
204
+	}
205
+
206
+	/**
207
+	 * Check for the IP address in several places
208
+	 * Used by [ip] shortcode
209
+	 *
210
+	 * @return string The IP address of the current user
211
+	 */
212
+	public static function get_ip_address() {
213 213
 		$ip = '';
214
-        foreach ( array(
215
-            'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
216
-            'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
217
-        ) as $key ) {
218
-            if ( ! isset( $_SERVER[ $key ] ) ) {
219
-                continue;
220
-            }
221
-
222
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
223
-                $ip = trim($ip); // just to be safe
224
-
225
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
226
-                    return $ip;
227
-                }
228
-            }
229
-        }
214
+		foreach ( array(
215
+			'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
216
+			'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
217
+		) as $key ) {
218
+			if ( ! isset( $_SERVER[ $key ] ) ) {
219
+				continue;
220
+			}
221
+
222
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
223
+				$ip = trim($ip); // just to be safe
224
+
225
+				if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
226
+					return $ip;
227
+				}
228
+			}
229
+		}
230 230
 
231 231
 		return sanitize_text_field( $ip );
232
-    }
232
+	}
233 233
 
234
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
235
-        if ( strpos($param, '[') ) {
236
-            $params = explode('[', $param);
237
-            $param = $params[0];
238
-        }
234
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
235
+		if ( strpos($param, '[') ) {
236
+			$params = explode('[', $param);
237
+			$param = $params[0];
238
+		}
239 239
 
240 240
 		if ( $src == 'get' ) {
241
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
242
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
243
-                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
244
-            }
241
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
242
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
243
+				$value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
244
+			}
245 245
 			self::sanitize_value( $sanitize, $value );
246 246
 		} else {
247
-            $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
248
-        }
247
+			$value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
248
+		}
249 249
 
250 250
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
251
-            foreach ( $params as $k => $p ) {
252
-                if ( ! $k || ! is_array($value) ) {
253
-                    continue;
254
-                }
251
+			foreach ( $params as $k => $p ) {
252
+				if ( ! $k || ! is_array($value) ) {
253
+					continue;
254
+				}
255 255
 
256
-                $p = trim($p, ']');
257
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
258
-            }
259
-        }
256
+				$p = trim($p, ']');
257
+				$value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
258
+			}
259
+		}
260 260
 
261
-        return $value;
262
-    }
261
+		return $value;
262
+	}
263 263
 
264 264
 	public static function get_post_param( $param, $default = '', $sanitize = '' ) {
265 265
 		return self::get_simple_request( array( 'type' => 'post', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 	 */
276 276
 	public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) {
277 277
 		return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
278
-    }
278
+	}
279 279
 
280 280
 	/**
281 281
 	 * Get a GET/POST/REQUEST value and sanitize it
@@ -311,12 +311,12 @@  discard block
 block discarded – undo
311 311
 	}
312 312
 
313 313
 	/**
314
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
315
-	*
316
-	* @since 2.0.8
317
-	* @param string $value
318
-	* @return string $value
319
-	*/
314
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
315
+	 *
316
+	 * @since 2.0.8
317
+	 * @param string $value
318
+	 * @return string $value
319
+	 */
320 320
 	public static function preserve_backslashes( $value ) {
321 321
 		// If backslashes have already been added, don't add them again
322 322
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -338,14 +338,14 @@  discard block
 block discarded – undo
338 338
 		}
339 339
 	}
340 340
 
341
-    public static function sanitize_request( $sanitize_method, &$values ) {
342
-        $temp_values = $values;
343
-        foreach ( $temp_values as $k => $val ) {
344
-            if ( isset( $sanitize_method[ $k ] ) ) {
341
+	public static function sanitize_request( $sanitize_method, &$values ) {
342
+		$temp_values = $values;
343
+		foreach ( $temp_values as $k => $val ) {
344
+			if ( isset( $sanitize_method[ $k ] ) ) {
345 345
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
346
-            }
347
-        }
348
-    }
346
+			}
347
+		}
348
+	}
349 349
 
350 350
 	public static function sanitize_array( &$values ) {
351 351
 		$temp_values = $values;
@@ -363,12 +363,12 @@  discard block
 block discarded – undo
363 363
 	 */
364 364
 	public static function kses( $value, $allowed = array() ) {
365 365
 		$html = array(
366
-		    'a' => array(
366
+			'a' => array(
367 367
 				'href'  => array(),
368 368
 				'title' => array(),
369 369
 				'id'    => array(),
370 370
 				'class' => array(),
371
-		    ),
371
+			),
372 372
 		);
373 373
 
374 374
 		$allowed_html = array();
@@ -381,77 +381,77 @@  discard block
 block discarded – undo
381 381
 		return wp_kses( $value, $allowed_html );
382 382
 	}
383 383
 
384
-    /**
385
-     * Used when switching the action for a bulk action
386
-     * @since 2.0
387
-     */
388
-    public static function remove_get_action() {
389
-        if ( ! isset($_GET) ) {
390
-            return;
391
-        }
384
+	/**
385
+	 * Used when switching the action for a bulk action
386
+	 * @since 2.0
387
+	 */
388
+	public static function remove_get_action() {
389
+		if ( ! isset($_GET) ) {
390
+			return;
391
+		}
392 392
 
393
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
394
-        if ( ! empty( $new_action ) ) {
393
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
394
+		if ( ! empty( $new_action ) ) {
395 395
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
396
-        }
397
-    }
398
-
399
-    /**
400
-     * Check the WP query for a parameter
401
-     *
402
-     * @since 2.0
403
-     * @return string|array
404
-     */
405
-    public static function get_query_var( $value, $param ) {
406
-        if ( $value != '' ) {
407
-            return $value;
408
-        }
409
-
410
-        global $wp_query;
411
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
412
-            $value = $wp_query->query_vars[ $param ];
413
-        }
414
-
415
-        return $value;
416
-    }
417
-
418
-    /**
419
-     * @param string $type
420
-     */
421
-    public static function trigger_hook_load( $type, $object = null ) {
422
-        // only load the form hooks once
396
+		}
397
+	}
398
+
399
+	/**
400
+	 * Check the WP query for a parameter
401
+	 *
402
+	 * @since 2.0
403
+	 * @return string|array
404
+	 */
405
+	public static function get_query_var( $value, $param ) {
406
+		if ( $value != '' ) {
407
+			return $value;
408
+		}
409
+
410
+		global $wp_query;
411
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
412
+			$value = $wp_query->query_vars[ $param ];
413
+		}
414
+
415
+		return $value;
416
+	}
417
+
418
+	/**
419
+	 * @param string $type
420
+	 */
421
+	public static function trigger_hook_load( $type, $object = null ) {
422
+		// only load the form hooks once
423 423
 		$hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
424
-        if ( ! $hooks_loaded ) {
424
+		if ( ! $hooks_loaded ) {
425 425
 			do_action( 'frm_load_' . $type . '_hooks' );
426
-        }
427
-    }
428
-
429
-    /**
430
-     * Check cache before fetching values and saving to cache
431
-     *
432
-     * @since 2.0
433
-     *
434
-     * @param string $cache_key The unique name for this cache
435
-     * @param string $group The name of the cache group
436
-     * @param string $query If blank, don't run a db call
437
-     * @param string $type The wpdb function to use with this query
438
-     * @return mixed $results The cache or query results
439
-     */
440
-    public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
441
-        $results = wp_cache_get($cache_key, $group);
442
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
443
-            return $results;
444
-        }
445
-
446
-        if ( 'get_posts' == $type ) {
447
-            $results = get_posts($query);
426
+		}
427
+	}
428
+
429
+	/**
430
+	 * Check cache before fetching values and saving to cache
431
+	 *
432
+	 * @since 2.0
433
+	 *
434
+	 * @param string $cache_key The unique name for this cache
435
+	 * @param string $group The name of the cache group
436
+	 * @param string $query If blank, don't run a db call
437
+	 * @param string $type The wpdb function to use with this query
438
+	 * @return mixed $results The cache or query results
439
+	 */
440
+	public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
441
+		$results = wp_cache_get($cache_key, $group);
442
+		if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
443
+			return $results;
444
+		}
445
+
446
+		if ( 'get_posts' == $type ) {
447
+			$results = get_posts($query);
448 448
 		} else if ( 'get_associative_results' == $type ) {
449 449
 			global $wpdb;
450 450
 			$results = $wpdb->get_results( $query, OBJECT_K );
451
-        } else {
452
-            global $wpdb;
453
-            $results = $wpdb->{$type}($query);
454
-        }
451
+		} else {
452
+			global $wpdb;
453
+			$results = $wpdb->{$type}($query);
454
+		}
455 455
 
456 456
 		self::set_cache( $cache_key, $results, $group, $time );
457 457
 
@@ -484,44 +484,44 @@  discard block
 block discarded – undo
484 484
 		return $cached;
485 485
 	}
486 486
 
487
-    /**
488
-     * Data that should be stored for a long time can be stored in a transient.
489
-     * First check the cache, then check the transient
490
-     * @since 2.0
491
-     * @return mixed The cached value or false
492
-     */
487
+	/**
488
+	 * Data that should be stored for a long time can be stored in a transient.
489
+	 * First check the cache, then check the transient
490
+	 * @since 2.0
491
+	 * @return mixed The cached value or false
492
+	 */
493 493
 	public static function check_cache_and_transient( $cache_key ) {
494
-        // check caching layer first
495
-        $results = self::check_cache( $cache_key );
496
-        if ( $results ) {
497
-            return $results;
498
-        }
499
-
500
-        // then check the transient
501
-        $results = get_transient($cache_key);
502
-        if ( $results ) {
503
-            wp_cache_set($cache_key, $results);
504
-        }
505
-
506
-        return $results;
507
-    }
508
-
509
-    /**
510
-     * @since 2.0
511
-     * @param string $cache_key
512
-     */
494
+		// check caching layer first
495
+		$results = self::check_cache( $cache_key );
496
+		if ( $results ) {
497
+			return $results;
498
+		}
499
+
500
+		// then check the transient
501
+		$results = get_transient($cache_key);
502
+		if ( $results ) {
503
+			wp_cache_set($cache_key, $results);
504
+		}
505
+
506
+		return $results;
507
+	}
508
+
509
+	/**
510
+	 * @since 2.0
511
+	 * @param string $cache_key
512
+	 */
513 513
 	public static function delete_cache_and_transient( $cache_key, $group = 'default' ) {
514 514
 		delete_transient($cache_key);
515 515
 		wp_cache_delete( $cache_key, $group );
516 516
 	}
517 517
 
518
-    /**
519
-     * Delete all caching in a single group
520
-     *
521
-     * @since 2.0
522
-     *
523
-     * @param string $group The name of the cache group
524
-     */
518
+	/**
519
+	 * Delete all caching in a single group
520
+	 *
521
+	 * @since 2.0
522
+	 *
523
+	 * @param string $group The name of the cache group
524
+	 */
525 525
 	public static function cache_delete_group( $group ) {
526 526
 		$cached_keys = self::get_group_cached_keys( $group );
527 527
 
@@ -534,34 +534,34 @@  discard block
 block discarded – undo
534 534
 		}
535 535
 	}
536 536
 
537
-    /**
538
-     * Check a value from a shortcode to see if true or false.
539
-     * True when value is 1, true, 'true', 'yes'
540
-     *
541
-     * @since 1.07.10
542
-     *
543
-     * @param string $value The value to compare
544
-     * @return boolean True or False
545
-     */
537
+	/**
538
+	 * Check a value from a shortcode to see if true or false.
539
+	 * True when value is 1, true, 'true', 'yes'
540
+	 *
541
+	 * @since 1.07.10
542
+	 *
543
+	 * @param string $value The value to compare
544
+	 * @return boolean True or False
545
+	 */
546 546
 	public static function is_true( $value ) {
547
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
548
-    }
547
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
548
+	}
549 549
 
550
-    /**
551
-     * Used to filter shortcode in text widgets
552
-     */
553
-    public static function widget_text_filter_callback( $matches ) {
554
-        return do_shortcode( $matches[0] );
555
-    }
550
+	/**
551
+	 * Used to filter shortcode in text widgets
552
+	 */
553
+	public static function widget_text_filter_callback( $matches ) {
554
+		return do_shortcode( $matches[0] );
555
+	}
556 556
 
557
-    public static function get_pages() {
557
+	public static function get_pages() {
558 558
 		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
559
-    }
559
+	}
560 560
 
561
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
562
-        $pages = self::get_pages();
561
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
562
+		$pages = self::get_pages();
563 563
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
564
-    ?>
564
+	?>
565 565
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
566 566
             <option value=""> </option>
567 567
             <?php foreach ( $pages as $page ) { ?>
@@ -571,108 +571,108 @@  discard block
 block discarded – undo
571 571
             <?php } ?>
572 572
         </select>
573 573
     <?php
574
-    }
574
+	}
575 575
 
576 576
 	public static function post_edit_link( $post_id ) {
577
-        $post = get_post($post_id);
578
-        if ( $post ) {
577
+		$post = get_post($post_id);
578
+		if ( $post ) {
579 579
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
580 580
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
581
-        }
582
-        return '';
583
-    }
581
+		}
582
+		return '';
583
+	}
584 584
 
585 585
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
586
-    ?>
586
+	?>
587 587
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
588
-            echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
589
-            ?> class="frm_multiselect">
588
+			echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
589
+			?> class="frm_multiselect">
590 590
             <?php self::roles_options($capability); ?>
591 591
         </select>
592 592
     <?php
593
-    }
593
+	}
594 594
 
595 595
 	public static function roles_options( $capability ) {
596
-        global $frm_vars;
597
-        if ( isset($frm_vars['editable_roles']) ) {
598
-            $editable_roles = $frm_vars['editable_roles'];
599
-        } else {
600
-            $editable_roles = get_editable_roles();
601
-            $frm_vars['editable_roles'] = $editable_roles;
602
-        }
603
-
604
-        foreach ( $editable_roles as $role => $details ) {
605
-            $name = translate_user_role($details['name'] ); ?>
596
+		global $frm_vars;
597
+		if ( isset($frm_vars['editable_roles']) ) {
598
+			$editable_roles = $frm_vars['editable_roles'];
599
+		} else {
600
+			$editable_roles = get_editable_roles();
601
+			$frm_vars['editable_roles'] = $editable_roles;
602
+		}
603
+
604
+		foreach ( $editable_roles as $role => $details ) {
605
+			$name = translate_user_role($details['name'] ); ?>
606 606
         <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
607 607
 <?php
608
-            unset($role, $details);
609
-        }
610
-    }
608
+			unset($role, $details);
609
+		}
610
+	}
611 611
 
612 612
 	public static function frm_capabilities( $type = 'auto' ) {
613
-        $cap = array(
614
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
615
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
616
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
617
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
618
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
619
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
620
-        );
613
+		$cap = array(
614
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
615
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
616
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
617
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
618
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
619
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
620
+		);
621 621
 
622 622
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
623
-            return $cap;
624
-        }
623
+			return $cap;
624
+		}
625 625
 
626
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
627
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
628
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
629
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
626
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
627
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
628
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
629
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
630 630
 
631
-        return $cap;
632
-    }
631
+		return $cap;
632
+	}
633 633
 
634 634
 	public static function user_has_permission( $needed_role ) {
635
-        if ( $needed_role == '-1' ) {
636
-            return false;
635
+		if ( $needed_role == '-1' ) {
636
+			return false;
637 637
 		}
638 638
 
639
-        // $needed_role will be equal to blank if "Logged-in users" is selected
640
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
641
-            return true;
642
-        }
639
+		// $needed_role will be equal to blank if "Logged-in users" is selected
640
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
641
+			return true;
642
+		}
643 643
 
644
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
645
-        foreach ( $roles as $role ) {
644
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
645
+		foreach ( $roles as $role ) {
646 646
 			if ( current_user_can( $role ) ) {
647
-        		return true;
647
+				return true;
648 648
 			}
649
-        	if ( $role == $needed_role ) {
650
-        		break;
649
+			if ( $role == $needed_role ) {
650
+				break;
651 651
 			}
652
-        }
653
-        return false;
654
-    }
655
-
656
-    /**
657
-     * Make sure administrators can see Formidable menu
658
-     *
659
-     * @since 2.0
660
-     */
661
-    public static function maybe_add_permissions() {
652
+		}
653
+		return false;
654
+	}
655
+
656
+	/**
657
+	 * Make sure administrators can see Formidable menu
658
+	 *
659
+	 * @since 2.0
660
+	 */
661
+	public static function maybe_add_permissions() {
662 662
 		self::force_capability( 'frm_view_entries' );
663 663
 
664
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
665
-            return;
666
-        }
664
+		if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
665
+			return;
666
+		}
667 667
 
668 668
 		$user_id = get_current_user_id();
669 669
 		$user = new WP_User( $user_id );
670
-        $frm_roles = self::frm_capabilities();
671
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
670
+		$frm_roles = self::frm_capabilities();
671
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
672 672
 			$user->add_cap( $frm_role );
673
-            unset($frm_role, $frm_role_description);
674
-        }
675
-    }
673
+			unset($frm_role, $frm_role_description);
674
+		}
675
+	}
676 676
 
677 677
 	/**
678 678
 	 * Make sure admins have permission to see the menu items
@@ -688,28 +688,28 @@  discard block
 block discarded – undo
688 688
 		}
689 689
 	}
690 690
 
691
-    /**
692
-     * Check if the user has permision for action.
693
-     * Return permission message and stop the action if no permission
694
-     * @since 2.0
695
-     * @param string $permission
696
-     */
691
+	/**
692
+	 * Check if the user has permision for action.
693
+	 * Return permission message and stop the action if no permission
694
+	 * @since 2.0
695
+	 * @param string $permission
696
+	 */
697 697
 	public static function permission_check( $permission, $show_message = 'show' ) {
698
-        $permission_error = self::permission_nonce_error($permission);
699
-        if ( $permission_error !== false ) {
700
-            if ( 'hide' == $show_message ) {
701
-                $permission_error = '';
702
-            }
703
-            wp_die($permission_error);
704
-        }
705
-    }
706
-
707
-    /**
708
-     * Check user permission and nonce
709
-     * @since 2.0
710
-     * @param string $permission
711
-     * @return false|string The permission message or false if allowed
712
-     */
698
+		$permission_error = self::permission_nonce_error($permission);
699
+		if ( $permission_error !== false ) {
700
+			if ( 'hide' == $show_message ) {
701
+				$permission_error = '';
702
+			}
703
+			wp_die($permission_error);
704
+		}
705
+	}
706
+
707
+	/**
708
+	 * Check user permission and nonce
709
+	 * @since 2.0
710
+	 * @param string $permission
711
+	 * @return false|string The permission message or false if allowed
712
+	 */
713 713
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
714 714
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
715 715
 			$frm_settings = self::get_settings();
@@ -717,23 +717,23 @@  discard block
 block discarded – undo
717 717
 		}
718 718
 
719 719
 		$error = false;
720
-        if ( empty($nonce_name) ) {
721
-            return $error;
722
-        }
720
+		if ( empty($nonce_name) ) {
721
+			return $error;
722
+		}
723 723
 
724
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
725
-            $frm_settings = self::get_settings();
726
-            $error = $frm_settings->admin_permission;
727
-        }
724
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
725
+			$frm_settings = self::get_settings();
726
+			$error = $frm_settings->admin_permission;
727
+		}
728 728
 
729
-        return $error;
730
-    }
729
+		return $error;
730
+	}
731 731
 
732
-    public static function checked( $values, $current ) {
732
+	public static function checked( $values, $current ) {
733 733
 		if ( self::check_selected( $values, $current ) ) {
734
-            echo ' checked="checked"';
734
+			echo ' checked="checked"';
735 735
 		}
736
-    }
736
+	}
737 737
 
738 738
 	public static function check_selected( $values, $current ) {
739 739
 		$values = self::recursive_function_map( $values, 'trim' );
@@ -743,50 +743,50 @@  discard block
 block discarded – undo
743 743
 		return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current );
744 744
 	}
745 745
 
746
-    /**
747
-    * Check if current field option is an "other" option
748
-    *
749
-    * @since 2.0
750
-    *
751
-    * @param string $opt_key
752
-    * @return boolean Returns true if current field option is an "Other" option
753
-    */
754
-    public static function is_other_opt( $opt_key ) {
755
-        _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
756
-        return FrmFieldsHelper::is_other_opt( $opt_key );
757
-    }
758
-
759
-    /**
760
-    * Get value that belongs in "Other" text box
761
-    *
762
-    * @since 2.0
763
-    *
764
-    * @param string $opt_key
765
-    * @param array $field
766
-    * @return string $other_val
767
-    */
768
-    public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
746
+	/**
747
+	 * Check if current field option is an "other" option
748
+	 *
749
+	 * @since 2.0
750
+	 *
751
+	 * @param string $opt_key
752
+	 * @return boolean Returns true if current field option is an "Other" option
753
+	 */
754
+	public static function is_other_opt( $opt_key ) {
755
+		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
756
+		return FrmFieldsHelper::is_other_opt( $opt_key );
757
+	}
758
+
759
+	/**
760
+	 * Get value that belongs in "Other" text box
761
+	 *
762
+	 * @since 2.0
763
+	 *
764
+	 * @param string $opt_key
765
+	 * @param array $field
766
+	 * @return string $other_val
767
+	 */
768
+	public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
769 769
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' );
770 770
 		return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) );
771
-    }
772
-
773
-    /**
774
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
775
-    * Intended for front-end use
776
-    *
777
-    * @since 2.0
778
-    *
779
-    * @param array $field
780
-    * @param boolean $other_opt
781
-    * @param string $checked
782
-    * @param array $args should include opt_key and field name
783
-    * @return string $other_val
784
-    */
785
-    public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
771
+	}
772
+
773
+	/**
774
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
775
+	 * Intended for front-end use
776
+	 *
777
+	 * @since 2.0
778
+	 *
779
+	 * @param array $field
780
+	 * @param boolean $other_opt
781
+	 * @param string $checked
782
+	 * @param array $args should include opt_key and field name
783
+	 * @return string $other_val
784
+	 */
785
+	public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
786 786
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' );
787 787
 		$args['field'] = $field;
788 788
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
789
-    }
789
+	}
790 790
 
791 791
 	public static function recursive_function_map( $value, $function ) {
792 792
 		if ( is_array( $value ) ) {
@@ -816,24 +816,24 @@  discard block
 block discarded – undo
816 816
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
817 817
 	}
818 818
 
819
-    /**
820
-     * Flatten a multi-dimensional array
821
-     */
819
+	/**
820
+	 * Flatten a multi-dimensional array
821
+	 */
822 822
 	public static function array_flatten( $array, $keys = 'keep' ) {
823
-        $return = array();
824
-        foreach ( $array as $key => $value ) {
825
-            if ( is_array($value) ) {
823
+		$return = array();
824
+		foreach ( $array as $key => $value ) {
825
+			if ( is_array($value) ) {
826 826
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
827
-            } else {
827
+			} else {
828 828
 				if ( $keys == 'keep' ) {
829 829
 					$return[ $key ] = $value;
830 830
 				} else {
831 831
 					$return[] = $value;
832 832
 				}
833
-            }
834
-        }
835
-        return $return;
836
-    }
833
+			}
834
+		}
835
+		return $return;
836
+	}
837 837
 
838 838
 	public static function esc_textarea( $text, $is_rich_text = false ) {
839 839
 		$safe_text = str_replace( '&quot;', '"', $text );
@@ -844,38 +844,38 @@  discard block
 block discarded – undo
844 844
 		return apply_filters( 'esc_textarea', $safe_text, $text );
845 845
 	}
846 846
 
847
-    /**
848
-     * Add auto paragraphs to text areas
849
-     * @since 2.0
850
-     */
847
+	/**
848
+	 * Add auto paragraphs to text areas
849
+	 * @since 2.0
850
+	 */
851 851
 	public static function use_wpautop( $content ) {
852
-        if ( apply_filters('frm_use_wpautop', true) ) {
853
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
854
-        }
855
-        return $content;
856
-    }
852
+		if ( apply_filters('frm_use_wpautop', true) ) {
853
+			$content = wpautop(str_replace( '<br>', '<br />', $content));
854
+		}
855
+		return $content;
856
+	}
857 857
 
858 858
 	public static function replace_quotes( $val ) {
859
-        //Replace double quotes
859
+		//Replace double quotes
860 860
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
861
-        //Replace single quotes
862
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
863
-        return $val;
864
-    }
865
-
866
-    /**
867
-     * @since 2.0
868
-     * @return string The base Google APIS url for the current version of jQuery UI
869
-     */
870
-    public static function jquery_ui_base_url() {
861
+		//Replace single quotes
862
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
863
+		return $val;
864
+	}
865
+
866
+	/**
867
+	 * @since 2.0
868
+	 * @return string The base Google APIS url for the current version of jQuery UI
869
+	 */
870
+	public static function jquery_ui_base_url() {
871 871
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
872
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
873
-        return $url;
874
-    }
872
+		$url = apply_filters('frm_jquery_ui_base_url', $url);
873
+		return $url;
874
+	}
875 875
 
876
-    /**
877
-     * @param string $handle
878
-     */
876
+	/**
877
+	 * @param string $handle
878
+	 */
879 879
 	public static function script_version( $handle, $default = 0 ) {
880 880
 		global $wp_scripts;
881 881
 		if ( ! $wp_scripts ) {
@@ -897,241 +897,241 @@  discard block
 block discarded – undo
897 897
 
898 898
 	public static function js_redirect( $url ) {
899 899
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
900
-    }
900
+	}
901 901
 
902 902
 	public static function get_user_id_param( $user_id ) {
903
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
904
-            return $user_id;
905
-        }
903
+		if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
904
+			return $user_id;
905
+		}
906 906
 
907 907
 		if ( $user_id == 'current' ) {
908 908
 			$user_id = get_current_user_id();
909 909
 		} else {
910
-            if ( is_email($user_id) ) {
911
-                $user = get_user_by('email', $user_id);
912
-            } else {
913
-                $user = get_user_by('login', $user_id);
914
-            }
910
+			if ( is_email($user_id) ) {
911
+				$user = get_user_by('email', $user_id);
912
+			} else {
913
+				$user = get_user_by('login', $user_id);
914
+			}
915 915
 
916
-            if ( $user ) {
917
-                $user_id = $user->ID;
918
-            }
919
-            unset($user);
920
-        }
916
+			if ( $user ) {
917
+				$user_id = $user->ID;
918
+			}
919
+			unset($user);
920
+		}
921 921
 
922
-        return $user_id;
923
-    }
922
+		return $user_id;
923
+	}
924 924
 
925 925
 	public static function get_file_contents( $filename, $atts = array() ) {
926
-        if ( ! is_file($filename) ) {
927
-            return false;
928
-        }
929
-
930
-        extract($atts);
931
-        ob_start();
932
-        include($filename);
933
-        $contents = ob_get_contents();
934
-        ob_end_clean();
935
-        return $contents;
936
-    }
937
-
938
-    /**
939
-     * @param string $table_name
940
-     * @param string $column
926
+		if ( ! is_file($filename) ) {
927
+			return false;
928
+		}
929
+
930
+		extract($atts);
931
+		ob_start();
932
+		include($filename);
933
+		$contents = ob_get_contents();
934
+		ob_end_clean();
935
+		return $contents;
936
+	}
937
+
938
+	/**
939
+	 * @param string $table_name
940
+	 * @param string $column
941 941
 	 * @param int $id
942 942
 	 * @param int $num_chars
943
-     */
944
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
945
-        $key = '';
943
+	 */
944
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
945
+		$key = '';
946 946
 
947
-        if ( ! empty( $name ) ) {
948
-            $key = sanitize_key($name);
949
-        }
947
+		if ( ! empty( $name ) ) {
948
+			$key = sanitize_key($name);
949
+		}
950 950
 
951 951
 		if ( empty( $key ) ) {
952
-            $max_slug_value = pow(36, $num_chars);
953
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
954
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
955
-        }
952
+			$max_slug_value = pow(36, $num_chars);
953
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
954
+			$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
955
+		}
956 956
 
957 957
 		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
958 958
 			$key = $key . 'a';
959
-        }
959
+		}
960 960
 
961 961
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
962 962
 
963
-        if ( $key_check || is_numeric($key_check) ) {
964
-            $suffix = 2;
963
+		if ( $key_check || is_numeric($key_check) ) {
964
+			$suffix = 2;
965 965
 			do {
966 966
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
967 967
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
968 968
 				$suffix++;
969 969
 			} while ( $key_check || is_numeric( $key_check ) );
970 970
 			$key = $alt_post_name;
971
-        }
972
-        return $key;
973
-    }
974
-
975
-    /**
976
-     * Editing a Form or Entry
977
-     * @param string $table
978
-     * @return bool|array
979
-     */
980
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
981
-        if ( ! $record ) {
982
-            return false;
983
-        }
984
-
985
-        if ( empty($post_values) ) {
986
-            $post_values = stripslashes_deep($_POST);
987
-        }
971
+		}
972
+		return $key;
973
+	}
974
+
975
+	/**
976
+	 * Editing a Form or Entry
977
+	 * @param string $table
978
+	 * @return bool|array
979
+	 */
980
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
981
+		if ( ! $record ) {
982
+			return false;
983
+		}
984
+
985
+		if ( empty($post_values) ) {
986
+			$post_values = stripslashes_deep($_POST);
987
+		}
988 988
 
989 989
 		$values = array( 'id' => $record->id, 'fields' => array() );
990 990
 
991 991
 		foreach ( array( 'name', 'description' ) as $var ) {
992
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
992
+			$default_val = isset($record->{$var}) ? $record->{$var} : '';
993 993
 			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
994
-            unset($var, $default_val);
995
-        }
996
-
997
-        $values['description'] = self::use_wpautop($values['description']);
998
-        $frm_settings = self::get_settings();
999
-        $is_form_builder = self::is_admin_page('formidable' );
1000
-
1001
-        foreach ( (array) $fields as $field ) {
1002
-            // Make sure to filter default values (for placeholder text), but not on the form builder page
1003
-            if ( ! $is_form_builder ) {
1004
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
1005
-            }
994
+			unset($var, $default_val);
995
+		}
996
+
997
+		$values['description'] = self::use_wpautop($values['description']);
998
+		$frm_settings = self::get_settings();
999
+		$is_form_builder = self::is_admin_page('formidable' );
1000
+
1001
+		foreach ( (array) $fields as $field ) {
1002
+			// Make sure to filter default values (for placeholder text), but not on the form builder page
1003
+			if ( ! $is_form_builder ) {
1004
+				$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
1005
+			}
1006 1006
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
1007 1007
 			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
1008
-        }
1008
+		}
1009 1009
 
1010
-        self::fill_form_opts($record, $table, $post_values, $values);
1010
+		self::fill_form_opts($record, $table, $post_values, $values);
1011 1011
 
1012
-        if ( $table == 'entries' ) {
1013
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1014
-        } else if ( $table == 'forms' ) {
1015
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1016
-        }
1012
+		if ( $table == 'entries' ) {
1013
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1014
+		} else if ( $table == 'forms' ) {
1015
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1016
+		}
1017 1017
 
1018
-        return $values;
1019
-    }
1018
+		return $values;
1019
+	}
1020 1020
 
1021 1021
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
1022
-        $post_values = $args['post_values'];
1023
-
1024
-        if ( $args['default'] ) {
1025
-            $meta_value = $field->default_value;
1026
-        } else {
1027
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1028
-                if ( ! isset($field->field_options['custom_field']) ) {
1029
-                    $field->field_options['custom_field'] = '';
1030
-                }
1022
+		$post_values = $args['post_values'];
1023
+
1024
+		if ( $args['default'] ) {
1025
+			$meta_value = $field->default_value;
1026
+		} else {
1027
+			if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1028
+				if ( ! isset($field->field_options['custom_field']) ) {
1029
+					$field->field_options['custom_field'] = '';
1030
+				}
1031 1031
 				$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 ) );
1032
-            } else {
1032
+			} else {
1033 1033
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1034
-            }
1035
-        }
1034
+			}
1035
+		}
1036 1036
 
1037 1037
 		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1038
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1039
-
1040
-        $field_array = array(
1041
-            'id'            => $field->id,
1042
-            'value'         => $new_value,
1043
-            'default_value' => $field->default_value,
1044
-            'name'          => $field->name,
1045
-            'description'   => $field->description,
1046
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1047
-            'options'       => $field->options,
1048
-            'required'      => $field->required,
1049
-            'field_key'     => $field->field_key,
1050
-            'field_order'   => $field->field_order,
1051
-            'form_id'       => $field->form_id,
1038
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1039
+
1040
+		$field_array = array(
1041
+			'id'            => $field->id,
1042
+			'value'         => $new_value,
1043
+			'default_value' => $field->default_value,
1044
+			'name'          => $field->name,
1045
+			'description'   => $field->description,
1046
+			'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1047
+			'options'       => $field->options,
1048
+			'required'      => $field->required,
1049
+			'field_key'     => $field->field_key,
1050
+			'field_order'   => $field->field_order,
1051
+			'form_id'       => $field->form_id,
1052 1052
 			'parent_form_id' => $args['parent_form_id'],
1053
-        );
1053
+		);
1054 1054
 
1055
-        $args['field_type'] = $field_type;
1056
-        self::fill_field_opts($field, $field_array, $args);
1055
+		$args['field_type'] = $field_type;
1056
+		self::fill_field_opts($field, $field_array, $args);
1057 1057
 		// Track the original field's type
1058 1058
 		$field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type;
1059 1059
 
1060
-        $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1060
+		$field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1061 1061
 
1062
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1063
-            $field_array['unique_msg'] = '';
1064
-        }
1062
+		if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1063
+			$field_array['unique_msg'] = '';
1064
+		}
1065 1065
 
1066
-        $field_array = array_merge( $field->field_options, $field_array );
1066
+		$field_array = array_merge( $field->field_options, $field_array );
1067 1067
 
1068
-        $values['fields'][ $field->id ] = $field_array;
1069
-    }
1068
+		$values['fields'][ $field->id ] = $field_array;
1069
+	}
1070 1070
 
1071 1071
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1072
-        $post_values = $args['post_values'];
1073
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1072
+		$post_values = $args['post_values'];
1073
+		$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1074 1074
 
1075
-        foreach ( $opt_defaults as $opt => $default_opt ) {
1075
+		foreach ( $opt_defaults as $opt => $default_opt ) {
1076 1076
 			$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 );
1077
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1078
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1079
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1080
-                if ( $args['field_type'] == 'captcha' ) {
1081
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1082
-                } else {
1083
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1084
-                }
1085
-            }
1086
-        }
1087
-
1088
-        if ( $field_array['custom_html'] == '' ) {
1089
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1090
-        }
1091
-    }
1092
-
1093
-    /**
1094
-     * @param string $table
1095
-     */
1077
+			if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1078
+				$field_array[ $opt ] = $args['frm_settings']->blank_msg;
1079
+			} else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1080
+				if ( $args['field_type'] == 'captcha' ) {
1081
+					$field_array[ $opt ] = $args['frm_settings']->re_msg;
1082
+				} else {
1083
+					$field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1084
+				}
1085
+			}
1086
+		}
1087
+
1088
+		if ( $field_array['custom_html'] == '' ) {
1089
+			$field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1090
+		}
1091
+	}
1092
+
1093
+	/**
1094
+	 * @param string $table
1095
+	 */
1096 1096
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1097
-        if ( $table == 'entries' ) {
1098
-            $form = $record->form_id;
1097
+		if ( $table == 'entries' ) {
1098
+			$form = $record->form_id;
1099 1099
 			FrmForm::maybe_get_form( $form );
1100
-        } else {
1101
-            $form = $record;
1102
-        }
1100
+		} else {
1101
+			$form = $record;
1102
+		}
1103 1103
 
1104
-        if ( ! $form ) {
1105
-            return;
1106
-        }
1104
+		if ( ! $form ) {
1105
+			return;
1106
+		}
1107 1107
 
1108
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1108
+		$values['form_name'] = isset($record->form_id) ? $form->name : '';
1109 1109
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1110 1110
 
1111
-        if ( ! is_array($form->options) ) {
1112
-            return;
1113
-        }
1111
+		if ( ! is_array($form->options) ) {
1112
+			return;
1113
+		}
1114 1114
 
1115
-        foreach ( $form->options as $opt => $value ) {
1116
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1117
-        }
1115
+		foreach ( $form->options as $opt => $value ) {
1116
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1117
+		}
1118 1118
 
1119
-        self::fill_form_defaults($post_values, $values);
1120
-    }
1119
+		self::fill_form_defaults($post_values, $values);
1120
+	}
1121 1121
 
1122
-    /**
1123
-     * Set to POST value or default
1124
-     */
1122
+	/**
1123
+	 * Set to POST value or default
1124
+	 */
1125 1125
 	private static function fill_form_defaults( $post_values, array &$values ) {
1126
-        $form_defaults = FrmFormsHelper::get_default_opts();
1126
+		$form_defaults = FrmFormsHelper::get_default_opts();
1127 1127
 
1128
-        foreach ( $form_defaults as $opt => $default ) {
1129
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1128
+		foreach ( $form_defaults as $opt => $default ) {
1129
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1130 1130
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1131
-            }
1131
+			}
1132 1132
 
1133
-            unset($opt, $defaut);
1134
-        }
1133
+			unset($opt, $defaut);
1134
+		}
1135 1135
 
1136 1136
 		if ( ! isset( $values['custom_style'] ) ) {
1137 1137
 			$values['custom_style'] = self::custom_style_value( $post_values );
@@ -1140,10 +1140,10 @@  discard block
 block discarded – undo
1140 1140
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1141 1141
 			if ( ! isset( $values[ $h . '_html' ] ) ) {
1142 1142
 				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1143
-            }
1144
-            unset($h);
1145
-        }
1146
-    }
1143
+			}
1144
+			unset($h);
1145
+		}
1146
+	}
1147 1147
 
1148 1148
 	/**
1149 1149
 	 * @since 2.2.10
@@ -1166,59 +1166,59 @@  discard block
 block discarded – undo
1166 1166
 	}
1167 1167
 
1168 1168
 	public static function insert_opt_html( $args ) {
1169
-        $class = '';
1170
-        if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1171
-            $class .= 'show_frm_not_email_to';
1172
-        }
1173
-    ?>
1169
+		$class = '';
1170
+		if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1171
+			$class .= 'show_frm_not_email_to';
1172
+		}
1173
+	?>
1174 1174
 <li>
1175 1175
     <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>
1176 1176
     <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>
1177 1177
     <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>
1178 1178
 </li>
1179 1179
     <?php
1180
-    }
1180
+	}
1181 1181
 
1182 1182
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1183
-        if ( is_array( $str ) ) {
1184
-            return '';
1183
+		if ( is_array( $str ) ) {
1184
+			return '';
1185 1185
 		}
1186 1186
 
1187
-        $length = (int) $length;
1187
+		$length = (int) $length;
1188 1188
 		$str = wp_strip_all_tags( $str );
1189 1189
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1190 1190
 
1191 1191
 		if ( $length == 0 ) {
1192
-            return '';
1193
-        } else if ( $length <= 10 ) {
1192
+			return '';
1193
+		} else if ( $length <= 10 ) {
1194 1194
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1195
-            return $sub . (($length < $original_len) ? $continue : '');
1196
-        }
1195
+			return $sub . (($length < $original_len) ? $continue : '');
1196
+		}
1197 1197
 
1198
-        $sub = '';
1199
-        $len = 0;
1198
+		$sub = '';
1199
+		$len = 0;
1200 1200
 
1201 1201
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1202 1202
 
1203 1203
 		foreach ( $words as $word ) {
1204
-            $part = (($sub != '') ? ' ' : '') . $word;
1204
+			$part = (($sub != '') ? ' ' : '') . $word;
1205 1205
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1206
-            if ( $total_len > $length && str_word_count($sub) ) {
1207
-                break;
1208
-            }
1206
+			if ( $total_len > $length && str_word_count($sub) ) {
1207
+				break;
1208
+			}
1209 1209
 
1210
-            $sub .= $part;
1210
+			$sub .= $part;
1211 1211
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1212 1212
 
1213
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1214
-                break;
1215
-            }
1213
+			if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1214
+				break;
1215
+			}
1216 1216
 
1217
-            unset($total_len, $word);
1218
-        }
1217
+			unset($total_len, $word);
1218
+		}
1219 1219
 
1220
-        return $sub . (($len < $original_len) ? $continue : '');
1221
-    }
1220
+		return $sub . (($len < $original_len) ? $continue : '');
1221
+	}
1222 1222
 
1223 1223
 	public static function mb_function( $function_names, $args ) {
1224 1224
 		$mb_function_name = $function_names[0];
@@ -1230,18 +1230,18 @@  discard block
 block discarded – undo
1230 1230
 	}
1231 1231
 
1232 1232
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1233
-        if ( empty($date) ) {
1234
-            return $date;
1235
-        }
1233
+		if ( empty($date) ) {
1234
+			return $date;
1235
+		}
1236 1236
 
1237
-        if ( empty($date_format) ) {
1238
-            $date_format = get_option('date_format');
1239
-        }
1237
+		if ( empty($date_format) ) {
1238
+			$date_format = get_option('date_format');
1239
+		}
1240 1240
 
1241
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1242
-            $frmpro_settings = new FrmProSettings();
1243
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1244
-        }
1241
+		if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1242
+			$frmpro_settings = new FrmProSettings();
1243
+			$date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1244
+		}
1245 1245
 
1246 1246
 		$formatted = self::get_localized_date( $date_format, $date );
1247 1247
 
@@ -1250,8 +1250,8 @@  discard block
 block discarded – undo
1250 1250
 			$formatted .= self::add_time_to_date( $time_format, $date );
1251 1251
 		}
1252 1252
 
1253
-        return $formatted;
1254
-    }
1253
+		return $formatted;
1254
+	}
1255 1255
 
1256 1256
 	private static function add_time_to_date( $time_format, $date ) {
1257 1257
 		if ( empty( $time_format ) ) {
@@ -1333,61 +1333,61 @@  discard block
 block discarded – undo
1333 1333
 		);
1334 1334
 	}
1335 1335
 
1336
-    /**
1337
-     * Added for < WP 4.0 compatability
1338
-     *
1339
-     * @since 1.07.10
1340
-     *
1341
-     * @param string $term The value to escape
1342
-     * @return string The escaped value
1343
-     */
1336
+	/**
1337
+	 * Added for < WP 4.0 compatability
1338
+	 *
1339
+	 * @since 1.07.10
1340
+	 *
1341
+	 * @param string $term The value to escape
1342
+	 * @return string The escaped value
1343
+	 */
1344 1344
 	public static function esc_like( $term ) {
1345
-        global $wpdb;
1346
-        if ( method_exists($wpdb, 'esc_like') ) {
1345
+		global $wpdb;
1346
+		if ( method_exists($wpdb, 'esc_like') ) {
1347 1347
 			// WP 4.0
1348
-            $term = $wpdb->esc_like( $term );
1349
-        } else {
1350
-            $term = like_escape( $term );
1351
-        }
1348
+			$term = $wpdb->esc_like( $term );
1349
+		} else {
1350
+			$term = like_escape( $term );
1351
+		}
1352 1352
 
1353
-        return $term;
1354
-    }
1353
+		return $term;
1354
+	}
1355 1355
 
1356
-    /**
1357
-     * @param string $order_query
1358
-     */
1356
+	/**
1357
+	 * @param string $order_query
1358
+	 */
1359 1359
 	public static function esc_order( $order_query ) {
1360
-        if ( empty($order_query) ) {
1361
-            return '';
1362
-        }
1363
-
1364
-        // remove ORDER BY before santizing
1365
-        $order_query = strtolower($order_query);
1366
-        if ( strpos($order_query, 'order by') !== false ) {
1367
-            $order_query = str_replace('order by', '', $order_query);
1368
-        }
1369
-
1370
-        $order_query = explode(' ', trim($order_query));
1371
-
1372
-        $order_fields = array(
1373
-            'id', 'form_key', 'name', 'description',
1374
-            'parent_form_id', 'logged_in', 'is_template',
1375
-            'default_template', 'status', 'created_at',
1376
-        );
1377
-
1378
-        $order = trim(trim(reset($order_query), ','));
1379
-        if ( ! in_array($order, $order_fields) ) {
1380
-            return '';
1381
-        }
1382
-
1383
-        $order_by = '';
1384
-        if ( count($order_query) > 1 ) {
1360
+		if ( empty($order_query) ) {
1361
+			return '';
1362
+		}
1363
+
1364
+		// remove ORDER BY before santizing
1365
+		$order_query = strtolower($order_query);
1366
+		if ( strpos($order_query, 'order by') !== false ) {
1367
+			$order_query = str_replace('order by', '', $order_query);
1368
+		}
1369
+
1370
+		$order_query = explode(' ', trim($order_query));
1371
+
1372
+		$order_fields = array(
1373
+			'id', 'form_key', 'name', 'description',
1374
+			'parent_form_id', 'logged_in', 'is_template',
1375
+			'default_template', 'status', 'created_at',
1376
+		);
1377
+
1378
+		$order = trim(trim(reset($order_query), ','));
1379
+		if ( ! in_array($order, $order_fields) ) {
1380
+			return '';
1381
+		}
1382
+
1383
+		$order_by = '';
1384
+		if ( count($order_query) > 1 ) {
1385 1385
 			$order_by = end( $order_query );
1386 1386
 			self::esc_order_by( $order_by );
1387
-        }
1387
+		}
1388 1388
 
1389 1389
 		return ' ORDER BY ' . $order . ' ' . $order_by;
1390
-    }
1390
+	}
1391 1391
 
1392 1392
 	/**
1393 1393
 	 * Make sure this is ordering by either ASC or DESC
@@ -1399,169 +1399,169 @@  discard block
 block discarded – undo
1399 1399
 		}
1400 1400
 	}
1401 1401
 
1402
-    /**
1403
-     * @param string $limit
1404
-     */
1402
+	/**
1403
+	 * @param string $limit
1404
+	 */
1405 1405
 	public static function esc_limit( $limit ) {
1406
-        if ( empty($limit) ) {
1407
-            return '';
1408
-        }
1406
+		if ( empty($limit) ) {
1407
+			return '';
1408
+		}
1409 1409
 
1410
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1411
-        if ( is_numeric($limit) ) {
1410
+		$limit = trim(str_replace(' limit', '', strtolower($limit)));
1411
+		if ( is_numeric($limit) ) {
1412 1412
 			return ' LIMIT ' . $limit;
1413
-        }
1413
+		}
1414 1414
 
1415
-        $limit = explode(',', trim($limit));
1416
-        foreach ( $limit as $k => $l ) {
1417
-            if ( is_numeric( $l ) ) {
1418
-                $limit[ $k ] = $l;
1419
-            }
1420
-        }
1415
+		$limit = explode(',', trim($limit));
1416
+		foreach ( $limit as $k => $l ) {
1417
+			if ( is_numeric( $l ) ) {
1418
+				$limit[ $k ] = $l;
1419
+			}
1420
+		}
1421 1421
 
1422
-        $limit = implode(',', $limit);
1422
+		$limit = implode(',', $limit);
1423 1423
 		return ' LIMIT ' . $limit;
1424
-    }
1425
-
1426
-    /**
1427
-     * Get an array of values ready to go through $wpdb->prepare
1428
-     * @since 2.0
1429
-     */
1430
-    public static function prepare_array_values( $array, $type = '%s' ) {
1431
-        $placeholders = array_fill(0, count($array), $type);
1432
-        return implode(', ', $placeholders);
1433
-    }
1434
-
1435
-    public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1436
-        if ( empty($where) ) {
1437
-            return '';
1438
-        }
1424
+	}
1425
+
1426
+	/**
1427
+	 * Get an array of values ready to go through $wpdb->prepare
1428
+	 * @since 2.0
1429
+	 */
1430
+	public static function prepare_array_values( $array, $type = '%s' ) {
1431
+		$placeholders = array_fill(0, count($array), $type);
1432
+		return implode(', ', $placeholders);
1433
+	}
1434
+
1435
+	public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1436
+		if ( empty($where) ) {
1437
+			return '';
1438
+		}
1439 1439
 
1440 1440
 		if ( is_array( $where ) ) {
1441
-            global $wpdb;
1442
-            FrmDb::get_where_clause_and_values( $where, $starts_with );
1441
+			global $wpdb;
1442
+			FrmDb::get_where_clause_and_values( $where, $starts_with );
1443 1443
 			$where = $wpdb->prepare( $where['where'], $where['values'] );
1444 1444
 		} else {
1445
-            $where = $starts_with . $where;
1446
-        }
1445
+			$where = $starts_with . $where;
1446
+		}
1447 1447
 
1448
-        return $where;
1449
-    }
1448
+		return $where;
1449
+	}
1450 1450
 
1451
-    // Pagination Methods
1451
+	// Pagination Methods
1452 1452
 
1453
-    /**
1454
-     * @param integer $current_p
1455
-     */
1453
+	/**
1454
+	 * @param integer $current_p
1455
+	 */
1456 1456
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1457 1457
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1458 1458
 	}
1459 1459
 
1460
-    /**
1461
-     * @param integer $current_p
1462
-     */
1463
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1464
-        if ( $current_p == 1 ) {
1465
-            return 1;
1466
-        } else {
1467
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1468
-        }
1469
-    }
1460
+	/**
1461
+	 * @param integer $current_p
1462
+	 */
1463
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1464
+		if ( $current_p == 1 ) {
1465
+			return 1;
1466
+		} else {
1467
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1468
+		}
1469
+	}
1470 1470
 
1471 1471
 	/**
1472 1472
 	 * @return array
1473 1473
 	 */
1474 1474
 	public static function json_to_array( $json_vars ) {
1475
-        $vars = array();
1476
-        foreach ( $json_vars as $jv ) {
1477
-            $jv_name = explode('[', $jv['name']);
1478
-            $last = count($jv_name) - 1;
1479
-            foreach ( $jv_name as $p => $n ) {
1480
-                $name = trim($n, ']');
1481
-                if ( ! isset($l1) ) {
1482
-                    $l1 = $name;
1483
-                }
1484
-
1485
-                if ( ! isset($l2) ) {
1486
-                    $l2 = $name;
1487
-                }
1488
-
1489
-                if ( ! isset($l3) ) {
1490
-                    $l3 = $name;
1491
-                }
1492
-
1493
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1494
-
1495
-                switch ( $p ) {
1496
-                    case 0:
1497
-                        $l1 = $name;
1498
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1499
-                    break;
1500
-
1501
-                    case 1:
1502
-                        $l2 = $name;
1503
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1504
-                    break;
1505
-
1506
-                    case 2:
1507
-                        $l3 = $name;
1508
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1509
-                    break;
1510
-
1511
-                    case 3:
1512
-                        $l4 = $name;
1513
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1514
-                    break;
1515
-                }
1516
-
1517
-                unset($this_val, $n);
1518
-            }
1519
-
1520
-            unset($last, $jv);
1521
-        }
1522
-
1523
-        return $vars;
1524
-    }
1525
-
1526
-    /**
1527
-     * @param string $name
1528
-     * @param string $l1
1529
-     */
1530
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1531
-        if ( $name == '' ) {
1532
-            $vars[] = $val;
1533
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1534
-            $vars[ $l1 ] = $val;
1535
-        }
1536
-    }
1475
+		$vars = array();
1476
+		foreach ( $json_vars as $jv ) {
1477
+			$jv_name = explode('[', $jv['name']);
1478
+			$last = count($jv_name) - 1;
1479
+			foreach ( $jv_name as $p => $n ) {
1480
+				$name = trim($n, ']');
1481
+				if ( ! isset($l1) ) {
1482
+					$l1 = $name;
1483
+				}
1484
+
1485
+				if ( ! isset($l2) ) {
1486
+					$l2 = $name;
1487
+				}
1488
+
1489
+				if ( ! isset($l3) ) {
1490
+					$l3 = $name;
1491
+				}
1492
+
1493
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1494
+
1495
+				switch ( $p ) {
1496
+					case 0:
1497
+						$l1 = $name;
1498
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1499
+					break;
1500
+
1501
+					case 1:
1502
+						$l2 = $name;
1503
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1504
+					break;
1505
+
1506
+					case 2:
1507
+						$l3 = $name;
1508
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1509
+					break;
1510
+
1511
+					case 3:
1512
+						$l4 = $name;
1513
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1514
+					break;
1515
+				}
1516
+
1517
+				unset($this_val, $n);
1518
+			}
1519
+
1520
+			unset($last, $jv);
1521
+		}
1522
+
1523
+		return $vars;
1524
+	}
1525
+
1526
+	/**
1527
+	 * @param string $name
1528
+	 * @param string $l1
1529
+	 */
1530
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1531
+		if ( $name == '' ) {
1532
+			$vars[] = $val;
1533
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1534
+			$vars[ $l1 ] = $val;
1535
+		}
1536
+	}
1537 1537
 
1538 1538
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1539
-        $tooltips = array(
1540
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1541
-            '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' ),
1542
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1543
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1544
-            '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' ),
1545
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1546
-            '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() ) ),
1547
-        );
1548
-
1549
-        if ( ! isset( $tooltips[ $name ] ) ) {
1550
-            return;
1551
-        }
1552
-
1553
-        if ( 'open' == $class ) {
1554
-            echo ' frm_help"';
1555
-        } else {
1556
-            echo ' class="frm_help"';
1557
-        }
1539
+		$tooltips = array(
1540
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1541
+			'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' ),
1542
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1543
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1544
+			'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' ),
1545
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1546
+			'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() ) ),
1547
+		);
1548
+
1549
+		if ( ! isset( $tooltips[ $name ] ) ) {
1550
+			return;
1551
+		}
1552
+
1553
+		if ( 'open' == $class ) {
1554
+			echo ' frm_help"';
1555
+		} else {
1556
+			echo ' class="frm_help"';
1557
+		}
1558 1558
 
1559 1559
 		echo ' title="' . esc_attr( $tooltips[ $name ] );
1560 1560
 
1561
-        if ( 'open' != $class ) {
1562
-            echo '"';
1563
-        }
1564
-    }
1561
+		if ( 'open' != $class ) {
1562
+			echo '"';
1563
+		}
1564
+	}
1565 1565
 
1566 1566
 	/**
1567 1567
 	 * Add the current_page class to that page in the form nav
@@ -1577,35 +1577,35 @@  discard block
 block discarded – undo
1577 1577
 		}
1578 1578
 	}
1579 1579
 
1580
-    /**
1581
-     * Prepare and json_encode post content
1582
-     *
1583
-     * @since 2.0
1584
-     *
1585
-     * @param array $post_content
1586
-     * @return string $post_content ( json encoded array )
1587
-     */
1588
-    public static function prepare_and_encode( $post_content ) {
1589
-        //Loop through array to strip slashes and add only the needed ones
1580
+	/**
1581
+	 * Prepare and json_encode post content
1582
+	 *
1583
+	 * @since 2.0
1584
+	 *
1585
+	 * @param array $post_content
1586
+	 * @return string $post_content ( json encoded array )
1587
+	 */
1588
+	public static function prepare_and_encode( $post_content ) {
1589
+		//Loop through array to strip slashes and add only the needed ones
1590 1590
 		foreach ( $post_content as $key => $val ) {
1591 1591
 			// Replace problematic characters (like &quot;)
1592 1592
 			$val = str_replace( '&quot;', '"', $val );
1593 1593
 
1594 1594
 			self::prepare_action_slashes( $val, $key, $post_content );
1595
-            unset( $key, $val );
1596
-        }
1595
+			unset( $key, $val );
1596
+		}
1597 1597
 
1598
-        // json_encode the array
1599
-        $post_content = json_encode( $post_content );
1598
+		// json_encode the array
1599
+		$post_content = json_encode( $post_content );
1600 1600
 
1601
-	    // add extra slashes for \r\n since WP strips them
1601
+		// add extra slashes for \r\n since WP strips them
1602 1602
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1603 1603
 
1604
-        // allow for &quot
1605
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1604
+		// allow for &quot
1605
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1606 1606
 
1607
-        return $post_content;
1608
-    }
1607
+		return $post_content;
1608
+	}
1609 1609
 
1610 1610
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1611 1611
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1673,64 +1673,64 @@  discard block
 block discarded – undo
1673 1673
 	}
1674 1674
 
1675 1675
 	public static function maybe_json_decode( $string ) {
1676
-        if ( is_array($string) ) {
1677
-            return $string;
1678
-        }
1676
+		if ( is_array($string) ) {
1677
+			return $string;
1678
+		}
1679 1679
 
1680
-        $new_string = json_decode($string, true);
1681
-        if ( function_exists('json_last_error') ) {
1680
+		$new_string = json_decode($string, true);
1681
+		if ( function_exists('json_last_error') ) {
1682 1682
 			// php 5.3+
1683
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1684
-                $string = $new_string;
1685
-            }
1686
-        } else if ( isset($new_string) ) {
1683
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1684
+				$string = $new_string;
1685
+			}
1686
+		} else if ( isset($new_string) ) {
1687 1687
 			// php < 5.3 fallback
1688
-            $string = $new_string;
1689
-        }
1690
-        return $string;
1691
-    }
1692
-
1693
-    /**
1694
-     * @since 1.07.10
1695
-     *
1696
-     * @param string $post_type The name of the post type that may need to be highlighted
1697
-     * echo The javascript to open and highlight the Formidable menu
1698
-     */
1688
+			$string = $new_string;
1689
+		}
1690
+		return $string;
1691
+	}
1692
+
1693
+	/**
1694
+	 * @since 1.07.10
1695
+	 *
1696
+	 * @param string $post_type The name of the post type that may need to be highlighted
1697
+	 * echo The javascript to open and highlight the Formidable menu
1698
+	 */
1699 1699
 	public static function maybe_highlight_menu( $post_type ) {
1700
-        global $post;
1700
+		global $post;
1701 1701
 
1702
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1703
-            return;
1704
-        }
1702
+		if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1703
+			return;
1704
+		}
1705 1705
 
1706
-        if ( is_object($post) && $post->post_type != $post_type ) {
1707
-            return;
1708
-        }
1706
+		if ( is_object($post) && $post->post_type != $post_type ) {
1707
+			return;
1708
+		}
1709 1709
 
1710
-        self::load_admin_wide_js();
1711
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1712
-    }
1710
+		self::load_admin_wide_js();
1711
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1712
+	}
1713 1713
 
1714
-    /**
1715
-     * Load the JS file on non-Formidable pages in the admin area
1716
-     * @since 2.0
1717
-     */
1714
+	/**
1715
+	 * Load the JS file on non-Formidable pages in the admin area
1716
+	 * @since 2.0
1717
+	 */
1718 1718
 	public static function load_admin_wide_js( $load = true ) {
1719
-        $version = FrmAppHelper::plugin_version();
1719
+		$version = FrmAppHelper::plugin_version();
1720 1720
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1721 1721
 
1722
-        wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1722
+		wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1723 1723
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1724
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1724
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1725 1725
 			'url'          => FrmAppHelper::plugin_url(),
1726 1726
 			'loading'      => __( 'Loading&hellip;' ),
1727 1727
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
1728
-        ) );
1728
+		) );
1729 1729
 
1730 1730
 		if ( $load ) {
1731 1731
 			wp_enqueue_script( 'formidable_admin_global' );
1732 1732
 		}
1733
-    }
1733
+	}
1734 1734
 
1735 1735
 	/**
1736 1736
 	 * @since 2.0.9
@@ -1739,9 +1739,9 @@  discard block
 block discarded – undo
1739 1739
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1740 1740
 	}
1741 1741
 
1742
-    /**
1743
-     * @param string $location
1744
-     */
1742
+	/**
1743
+	 * @param string $location
1744
+	 */
1745 1745
 	public static function localize_script( $location ) {
1746 1746
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1747 1747
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1797,81 +1797,81 @@  discard block
 block discarded – undo
1797 1797
 		}
1798 1798
 	}
1799 1799
 
1800
-    /**
1800
+	/**
1801 1801
 	 * echo the message on the plugins listing page
1802
-     * @since 1.07.10
1803
-     *
1804
-     * @param float $min_version The version the add-on requires
1805
-     */
1802
+	 * @since 1.07.10
1803
+	 *
1804
+	 * @param float $min_version The version the add-on requires
1805
+	 */
1806 1806
 	public static function min_version_notice( $min_version ) {
1807
-        $frm_version = self::plugin_version();
1807
+		$frm_version = self::plugin_version();
1808 1808
 
1809
-        // check if Formidable meets minimum requirements
1810
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1811
-            return;
1812
-        }
1809
+		// check if Formidable meets minimum requirements
1810
+		if ( version_compare($frm_version, $min_version, '>=') ) {
1811
+			return;
1812
+		}
1813 1813
 
1814
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1814
+		$wp_list_table = _get_list_table('WP_Plugins_List_Table');
1815 1815
 		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">' .
1816
-        __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1817
-        '</div></td></tr>';
1818
-    }
1819
-
1820
-    public static function locales( $type = 'date' ) {
1821
-        $locales = array(
1822
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1823
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1824
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1825
-            'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1826
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1827
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1828
-            'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1829
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1830
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1831
-            'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1832
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1833
-            'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1834
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1835
-            'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1836
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1837
-            'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1838
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1839
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1840
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1841
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1842
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1843
-            'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1844
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1845
-            'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1846
-            'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1847
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1848
-            'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1849
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1850
-            'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1851
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1852
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1853
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1854
-        );
1855
-
1856
-        if ( $type == 'captcha' ) {
1857
-            // remove the languages unavailable for the captcha
1858
-            $unset = array(
1859
-                '', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1860
-                'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1861
-                'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1862
-            );
1863
-        } else {
1864
-            // remove the languages unavailable for the datepicker
1865
-            $unset = array(
1866
-                'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1867
-                'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1868
-                'es-419', 'tr',
1869
-            );
1870
-        }
1871
-
1872
-        $locales = array_diff_key($locales, array_flip($unset));
1873
-        $locales = apply_filters('frm_locales', $locales);
1874
-
1875
-        return $locales;
1876
-    }
1816
+		__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1817
+		'</div></td></tr>';
1818
+	}
1819
+
1820
+	public static function locales( $type = 'date' ) {
1821
+		$locales = array(
1822
+			'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1823
+			'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1824
+			'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1825
+			'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1826
+			'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1827
+			'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1828
+			'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1829
+			'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1830
+			'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1831
+			'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1832
+			'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1833
+			'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1834
+			'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1835
+			'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1836
+			'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1837
+			'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1838
+			'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1839
+			'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1840
+			'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1841
+			'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1842
+			'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1843
+			'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1844
+			'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1845
+			'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1846
+			'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1847
+			'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1848
+			'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1849
+			'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1850
+			'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1851
+			'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1852
+			'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1853
+			'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1854
+		);
1855
+
1856
+		if ( $type == 'captcha' ) {
1857
+			// remove the languages unavailable for the captcha
1858
+			$unset = array(
1859
+				'', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1860
+				'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1861
+				'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1862
+			);
1863
+		} else {
1864
+			// remove the languages unavailable for the datepicker
1865
+			$unset = array(
1866
+				'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1867
+				'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1868
+				'es-419', 'tr',
1869
+			);
1870
+		}
1871
+
1872
+		$locales = array_diff_key($locales, array_flip($unset));
1873
+		$locales = apply_filters('frm_locales', $locales);
1874
+
1875
+		return $locales;
1876
+	}
1877 1877
 }
Please login to merge, or discard this patch.