Completed
Push — master ( ab0f0a...285dc1 )
by Stephanie
02:39
created
classes/helpers/FrmAppHelper.php 1 patch
Indentation   +1015 added lines, -1015 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.03';
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;
@@ -469,77 +469,77 @@  discard block
 block discarded – undo
469 469
 		);
470 470
 	}
471 471
 
472
-    /**
473
-     * Used when switching the action for a bulk action
474
-     * @since 2.0
475
-     */
476
-    public static function remove_get_action() {
477
-        if ( ! isset($_GET) ) {
478
-            return;
479
-        }
472
+	/**
473
+	 * Used when switching the action for a bulk action
474
+	 * @since 2.0
475
+	 */
476
+	public static function remove_get_action() {
477
+		if ( ! isset($_GET) ) {
478
+			return;
479
+		}
480 480
 
481
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
482
-        if ( ! empty( $new_action ) ) {
481
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
482
+		if ( ! empty( $new_action ) ) {
483 483
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
484
-        }
485
-    }
486
-
487
-    /**
488
-     * Check the WP query for a parameter
489
-     *
490
-     * @since 2.0
491
-     * @return string|array
492
-     */
493
-    public static function get_query_var( $value, $param ) {
494
-        if ( $value != '' ) {
495
-            return $value;
496
-        }
497
-
498
-        global $wp_query;
499
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
500
-            $value = $wp_query->query_vars[ $param ];
501
-        }
502
-
503
-        return $value;
504
-    }
505
-
506
-    /**
507
-     * @param string $type
508
-     */
509
-    public static function trigger_hook_load( $type, $object = null ) {
510
-        // only load the form hooks once
484
+		}
485
+	}
486
+
487
+	/**
488
+	 * Check the WP query for a parameter
489
+	 *
490
+	 * @since 2.0
491
+	 * @return string|array
492
+	 */
493
+	public static function get_query_var( $value, $param ) {
494
+		if ( $value != '' ) {
495
+			return $value;
496
+		}
497
+
498
+		global $wp_query;
499
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
500
+			$value = $wp_query->query_vars[ $param ];
501
+		}
502
+
503
+		return $value;
504
+	}
505
+
506
+	/**
507
+	 * @param string $type
508
+	 */
509
+	public static function trigger_hook_load( $type, $object = null ) {
510
+		// only load the form hooks once
511 511
 		$hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
512
-        if ( ! $hooks_loaded ) {
512
+		if ( ! $hooks_loaded ) {
513 513
 			do_action( 'frm_load_' . $type . '_hooks' );
514
-        }
515
-    }
516
-
517
-    /**
518
-     * Check cache before fetching values and saving to cache
519
-     *
520
-     * @since 2.0
521
-     *
522
-     * @param string $cache_key The unique name for this cache
523
-     * @param string $group The name of the cache group
524
-     * @param string $query If blank, don't run a db call
525
-     * @param string $type The wpdb function to use with this query
526
-     * @return mixed $results The cache or query results
527
-     */
528
-    public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
529
-        $results = wp_cache_get($cache_key, $group);
530
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
531
-            return $results;
532
-        }
533
-
534
-        if ( 'get_posts' == $type ) {
535
-            $results = get_posts($query);
514
+		}
515
+	}
516
+
517
+	/**
518
+	 * Check cache before fetching values and saving to cache
519
+	 *
520
+	 * @since 2.0
521
+	 *
522
+	 * @param string $cache_key The unique name for this cache
523
+	 * @param string $group The name of the cache group
524
+	 * @param string $query If blank, don't run a db call
525
+	 * @param string $type The wpdb function to use with this query
526
+	 * @return mixed $results The cache or query results
527
+	 */
528
+	public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
529
+		$results = wp_cache_get($cache_key, $group);
530
+		if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
531
+			return $results;
532
+		}
533
+
534
+		if ( 'get_posts' == $type ) {
535
+			$results = get_posts($query);
536 536
 		} else if ( 'get_associative_results' == $type ) {
537 537
 			global $wpdb;
538 538
 			$results = $wpdb->get_results( $query, OBJECT_K );
539
-        } else {
540
-            global $wpdb;
541
-            $results = $wpdb->{$type}($query);
542
-        }
539
+		} else {
540
+			global $wpdb;
541
+			$results = $wpdb->{$type}($query);
542
+		}
543 543
 
544 544
 		self::set_cache( $cache_key, $results, $group, $time );
545 545
 
@@ -572,44 +572,44 @@  discard block
 block discarded – undo
572 572
 		return $cached;
573 573
 	}
574 574
 
575
-    /**
576
-     * Data that should be stored for a long time can be stored in a transient.
577
-     * First check the cache, then check the transient
578
-     * @since 2.0
579
-     * @return mixed The cached value or false
580
-     */
575
+	/**
576
+	 * Data that should be stored for a long time can be stored in a transient.
577
+	 * First check the cache, then check the transient
578
+	 * @since 2.0
579
+	 * @return mixed The cached value or false
580
+	 */
581 581
 	public static function check_cache_and_transient( $cache_key ) {
582
-        // check caching layer first
583
-        $results = self::check_cache( $cache_key );
584
-        if ( $results ) {
585
-            return $results;
586
-        }
587
-
588
-        // then check the transient
589
-        $results = get_transient($cache_key);
590
-        if ( $results ) {
591
-            wp_cache_set($cache_key, $results);
592
-        }
593
-
594
-        return $results;
595
-    }
596
-
597
-    /**
598
-     * @since 2.0
599
-     * @param string $cache_key
600
-     */
582
+		// check caching layer first
583
+		$results = self::check_cache( $cache_key );
584
+		if ( $results ) {
585
+			return $results;
586
+		}
587
+
588
+		// then check the transient
589
+		$results = get_transient($cache_key);
590
+		if ( $results ) {
591
+			wp_cache_set($cache_key, $results);
592
+		}
593
+
594
+		return $results;
595
+	}
596
+
597
+	/**
598
+	 * @since 2.0
599
+	 * @param string $cache_key
600
+	 */
601 601
 	public static function delete_cache_and_transient( $cache_key, $group = 'default' ) {
602 602
 		delete_transient($cache_key);
603 603
 		wp_cache_delete( $cache_key, $group );
604 604
 	}
605 605
 
606
-    /**
607
-     * Delete all caching in a single group
608
-     *
609
-     * @since 2.0
610
-     *
611
-     * @param string $group The name of the cache group
612
-     */
606
+	/**
607
+	 * Delete all caching in a single group
608
+	 *
609
+	 * @since 2.0
610
+	 *
611
+	 * @param string $group The name of the cache group
612
+	 */
613 613
 	public static function cache_delete_group( $group ) {
614 614
 		$cached_keys = self::get_group_cached_keys( $group );
615 615
 
@@ -622,34 +622,34 @@  discard block
 block discarded – undo
622 622
 		}
623 623
 	}
624 624
 
625
-    /**
626
-     * Check a value from a shortcode to see if true or false.
627
-     * True when value is 1, true, 'true', 'yes'
628
-     *
629
-     * @since 1.07.10
630
-     *
631
-     * @param string $value The value to compare
632
-     * @return boolean True or False
633
-     */
625
+	/**
626
+	 * Check a value from a shortcode to see if true or false.
627
+	 * True when value is 1, true, 'true', 'yes'
628
+	 *
629
+	 * @since 1.07.10
630
+	 *
631
+	 * @param string $value The value to compare
632
+	 * @return boolean True or False
633
+	 */
634 634
 	public static function is_true( $value ) {
635
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
636
-    }
635
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
636
+	}
637 637
 
638
-    /**
639
-     * Used to filter shortcode in text widgets
640
-     */
641
-    public static function widget_text_filter_callback( $matches ) {
642
-        return do_shortcode( $matches[0] );
643
-    }
638
+	/**
639
+	 * Used to filter shortcode in text widgets
640
+	 */
641
+	public static function widget_text_filter_callback( $matches ) {
642
+		return do_shortcode( $matches[0] );
643
+	}
644 644
 
645
-    public static function get_pages() {
645
+	public static function get_pages() {
646 646
 		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
647
-    }
647
+	}
648 648
 
649
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
650
-        $pages = self::get_pages();
649
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
650
+		$pages = self::get_pages();
651 651
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
652
-    ?>
652
+	?>
653 653
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
654 654
             <option value=""> </option>
655 655
             <?php foreach ( $pages as $page ) { ?>
@@ -659,108 +659,108 @@  discard block
 block discarded – undo
659 659
             <?php } ?>
660 660
         </select>
661 661
     <?php
662
-    }
662
+	}
663 663
 
664 664
 	public static function post_edit_link( $post_id ) {
665
-        $post = get_post($post_id);
666
-        if ( $post ) {
665
+		$post = get_post($post_id);
666
+		if ( $post ) {
667 667
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
668 668
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
669
-        }
670
-        return '';
671
-    }
669
+		}
670
+		return '';
671
+	}
672 672
 
673 673
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
674
-    ?>
674
+	?>
675 675
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
676
-            echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
677
-            ?> class="frm_multiselect">
676
+			echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
677
+			?> class="frm_multiselect">
678 678
             <?php self::roles_options($capability); ?>
679 679
         </select>
680 680
     <?php
681
-    }
681
+	}
682 682
 
683 683
 	public static function roles_options( $capability ) {
684
-        global $frm_vars;
685
-        if ( isset($frm_vars['editable_roles']) ) {
686
-            $editable_roles = $frm_vars['editable_roles'];
687
-        } else {
688
-            $editable_roles = get_editable_roles();
689
-            $frm_vars['editable_roles'] = $editable_roles;
690
-        }
691
-
692
-        foreach ( $editable_roles as $role => $details ) {
693
-            $name = translate_user_role($details['name'] ); ?>
684
+		global $frm_vars;
685
+		if ( isset($frm_vars['editable_roles']) ) {
686
+			$editable_roles = $frm_vars['editable_roles'];
687
+		} else {
688
+			$editable_roles = get_editable_roles();
689
+			$frm_vars['editable_roles'] = $editable_roles;
690
+		}
691
+
692
+		foreach ( $editable_roles as $role => $details ) {
693
+			$name = translate_user_role($details['name'] ); ?>
694 694
         <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
695 695
 <?php
696
-            unset($role, $details);
697
-        }
698
-    }
696
+			unset($role, $details);
697
+		}
698
+	}
699 699
 
700 700
 	public static function frm_capabilities( $type = 'auto' ) {
701
-        $cap = array(
702
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
703
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
704
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
705
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
706
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
707
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
708
-        );
701
+		$cap = array(
702
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
703
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
704
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
705
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
706
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
707
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
708
+		);
709 709
 
710 710
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
711
-            return $cap;
712
-        }
711
+			return $cap;
712
+		}
713 713
 
714
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
715
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
716
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
717
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
714
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
715
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
716
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
717
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
718 718
 
719
-        return $cap;
720
-    }
719
+		return $cap;
720
+	}
721 721
 
722 722
 	public static function user_has_permission( $needed_role ) {
723
-        if ( $needed_role == '-1' ) {
724
-            return false;
723
+		if ( $needed_role == '-1' ) {
724
+			return false;
725 725
 		}
726 726
 
727
-        // $needed_role will be equal to blank if "Logged-in users" is selected
728
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
729
-            return true;
730
-        }
727
+		// $needed_role will be equal to blank if "Logged-in users" is selected
728
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
729
+			return true;
730
+		}
731 731
 
732
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
733
-        foreach ( $roles as $role ) {
732
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
733
+		foreach ( $roles as $role ) {
734 734
 			if ( current_user_can( $role ) ) {
735
-        		return true;
735
+				return true;
736 736
 			}
737
-        	if ( $role == $needed_role ) {
738
-        		break;
737
+			if ( $role == $needed_role ) {
738
+				break;
739 739
 			}
740
-        }
741
-        return false;
742
-    }
743
-
744
-    /**
745
-     * Make sure administrators can see Formidable menu
746
-     *
747
-     * @since 2.0
748
-     */
749
-    public static function maybe_add_permissions() {
740
+		}
741
+		return false;
742
+	}
743
+
744
+	/**
745
+	 * Make sure administrators can see Formidable menu
746
+	 *
747
+	 * @since 2.0
748
+	 */
749
+	public static function maybe_add_permissions() {
750 750
 		self::force_capability( 'frm_view_entries' );
751 751
 
752
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
753
-            return;
754
-        }
752
+		if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
753
+			return;
754
+		}
755 755
 
756 756
 		$user_id = get_current_user_id();
757 757
 		$user = new WP_User( $user_id );
758
-        $frm_roles = self::frm_capabilities();
759
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
758
+		$frm_roles = self::frm_capabilities();
759
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
760 760
 			$user->add_cap( $frm_role );
761
-            unset($frm_role, $frm_role_description);
762
-        }
763
-    }
761
+			unset($frm_role, $frm_role_description);
762
+		}
763
+	}
764 764
 
765 765
 	/**
766 766
 	 * Make sure admins have permission to see the menu items
@@ -776,28 +776,28 @@  discard block
 block discarded – undo
776 776
 		}
777 777
 	}
778 778
 
779
-    /**
780
-     * Check if the user has permision for action.
781
-     * Return permission message and stop the action if no permission
782
-     * @since 2.0
783
-     * @param string $permission
784
-     */
779
+	/**
780
+	 * Check if the user has permision for action.
781
+	 * Return permission message and stop the action if no permission
782
+	 * @since 2.0
783
+	 * @param string $permission
784
+	 */
785 785
 	public static function permission_check( $permission, $show_message = 'show' ) {
786
-        $permission_error = self::permission_nonce_error($permission);
787
-        if ( $permission_error !== false ) {
788
-            if ( 'hide' == $show_message ) {
789
-                $permission_error = '';
790
-            }
791
-            wp_die($permission_error);
792
-        }
793
-    }
794
-
795
-    /**
796
-     * Check user permission and nonce
797
-     * @since 2.0
798
-     * @param string $permission
799
-     * @return false|string The permission message or false if allowed
800
-     */
786
+		$permission_error = self::permission_nonce_error($permission);
787
+		if ( $permission_error !== false ) {
788
+			if ( 'hide' == $show_message ) {
789
+				$permission_error = '';
790
+			}
791
+			wp_die($permission_error);
792
+		}
793
+	}
794
+
795
+	/**
796
+	 * Check user permission and nonce
797
+	 * @since 2.0
798
+	 * @param string $permission
799
+	 * @return false|string The permission message or false if allowed
800
+	 */
801 801
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
802 802
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
803 803
 			$frm_settings = self::get_settings();
@@ -805,23 +805,23 @@  discard block
 block discarded – undo
805 805
 		}
806 806
 
807 807
 		$error = false;
808
-        if ( empty($nonce_name) ) {
809
-            return $error;
810
-        }
808
+		if ( empty($nonce_name) ) {
809
+			return $error;
810
+		}
811 811
 
812
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
813
-            $frm_settings = self::get_settings();
814
-            $error = $frm_settings->admin_permission;
815
-        }
812
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
813
+			$frm_settings = self::get_settings();
814
+			$error = $frm_settings->admin_permission;
815
+		}
816 816
 
817
-        return $error;
818
-    }
817
+		return $error;
818
+	}
819 819
 
820
-    public static function checked( $values, $current ) {
820
+	public static function checked( $values, $current ) {
821 821
 		if ( self::check_selected( $values, $current ) ) {
822
-            echo ' checked="checked"';
822
+			echo ' checked="checked"';
823 823
 		}
824
-    }
824
+	}
825 825
 
826 826
 	public static function check_selected( $values, $current ) {
827 827
 		$values = self::recursive_function_map( $values, 'trim' );
@@ -831,50 +831,50 @@  discard block
 block discarded – undo
831 831
 		return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current );
832 832
 	}
833 833
 
834
-    /**
835
-    * Check if current field option is an "other" option
836
-    *
837
-    * @since 2.0
838
-    *
839
-    * @param string $opt_key
840
-    * @return boolean Returns true if current field option is an "Other" option
841
-    */
842
-    public static function is_other_opt( $opt_key ) {
843
-        _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
844
-        return FrmFieldsHelper::is_other_opt( $opt_key );
845
-    }
846
-
847
-    /**
848
-    * Get value that belongs in "Other" text box
849
-    *
850
-    * @since 2.0
851
-    *
852
-    * @param string $opt_key
853
-    * @param array $field
854
-    * @return string $other_val
855
-    */
856
-    public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
834
+	/**
835
+	 * Check if current field option is an "other" option
836
+	 *
837
+	 * @since 2.0
838
+	 *
839
+	 * @param string $opt_key
840
+	 * @return boolean Returns true if current field option is an "Other" option
841
+	 */
842
+	public static function is_other_opt( $opt_key ) {
843
+		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
844
+		return FrmFieldsHelper::is_other_opt( $opt_key );
845
+	}
846
+
847
+	/**
848
+	 * Get value that belongs in "Other" text box
849
+	 *
850
+	 * @since 2.0
851
+	 *
852
+	 * @param string $opt_key
853
+	 * @param array $field
854
+	 * @return string $other_val
855
+	 */
856
+	public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
857 857
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' );
858 858
 		return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) );
859
-    }
860
-
861
-    /**
862
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
863
-    * Intended for front-end use
864
-    *
865
-    * @since 2.0
866
-    *
867
-    * @param array $field
868
-    * @param boolean $other_opt
869
-    * @param string $checked
870
-    * @param array $args should include opt_key and field name
871
-    * @return string $other_val
872
-    */
873
-    public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
859
+	}
860
+
861
+	/**
862
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
863
+	 * Intended for front-end use
864
+	 *
865
+	 * @since 2.0
866
+	 *
867
+	 * @param array $field
868
+	 * @param boolean $other_opt
869
+	 * @param string $checked
870
+	 * @param array $args should include opt_key and field name
871
+	 * @return string $other_val
872
+	 */
873
+	public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
874 874
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' );
875 875
 		$args['field'] = $field;
876 876
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
877
-    }
877
+	}
878 878
 
879 879
 	public static function recursive_function_map( $value, $function ) {
880 880
 		if ( is_array( $value ) ) {
@@ -904,24 +904,24 @@  discard block
 block discarded – undo
904 904
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
905 905
 	}
906 906
 
907
-    /**
908
-     * Flatten a multi-dimensional array
909
-     */
907
+	/**
908
+	 * Flatten a multi-dimensional array
909
+	 */
910 910
 	public static function array_flatten( $array, $keys = 'keep' ) {
911
-        $return = array();
912
-        foreach ( $array as $key => $value ) {
913
-            if ( is_array($value) ) {
911
+		$return = array();
912
+		foreach ( $array as $key => $value ) {
913
+			if ( is_array($value) ) {
914 914
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
915
-            } else {
915
+			} else {
916 916
 				if ( $keys == 'keep' ) {
917 917
 					$return[ $key ] = $value;
918 918
 				} else {
919 919
 					$return[] = $value;
920 920
 				}
921
-            }
922
-        }
923
-        return $return;
924
-    }
921
+			}
922
+		}
923
+		return $return;
924
+	}
925 925
 
926 926
 	public static function esc_textarea( $text, $is_rich_text = false ) {
927 927
 		$safe_text = str_replace( '&quot;', '"', $text );
@@ -932,38 +932,38 @@  discard block
 block discarded – undo
932 932
 		return apply_filters( 'esc_textarea', $safe_text, $text );
933 933
 	}
934 934
 
935
-    /**
936
-     * Add auto paragraphs to text areas
937
-     * @since 2.0
938
-     */
935
+	/**
936
+	 * Add auto paragraphs to text areas
937
+	 * @since 2.0
938
+	 */
939 939
 	public static function use_wpautop( $content ) {
940
-        if ( apply_filters('frm_use_wpautop', true) ) {
941
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
942
-        }
943
-        return $content;
944
-    }
940
+		if ( apply_filters('frm_use_wpautop', true) ) {
941
+			$content = wpautop(str_replace( '<br>', '<br />', $content));
942
+		}
943
+		return $content;
944
+	}
945 945
 
946 946
 	public static function replace_quotes( $val ) {
947
-        //Replace double quotes
947
+		//Replace double quotes
948 948
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
949
-        //Replace single quotes
950
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
951
-        return $val;
952
-    }
953
-
954
-    /**
955
-     * @since 2.0
956
-     * @return string The base Google APIS url for the current version of jQuery UI
957
-     */
958
-    public static function jquery_ui_base_url() {
949
+		//Replace single quotes
950
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
951
+		return $val;
952
+	}
953
+
954
+	/**
955
+	 * @since 2.0
956
+	 * @return string The base Google APIS url for the current version of jQuery UI
957
+	 */
958
+	public static function jquery_ui_base_url() {
959 959
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
960
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
961
-        return $url;
962
-    }
960
+		$url = apply_filters('frm_jquery_ui_base_url', $url);
961
+		return $url;
962
+	}
963 963
 
964
-    /**
965
-     * @param string $handle
966
-     */
964
+	/**
965
+	 * @param string $handle
966
+	 */
967 967
 	public static function script_version( $handle, $default = 0 ) {
968 968
 		global $wp_scripts;
969 969
 		if ( ! $wp_scripts ) {
@@ -985,241 +985,241 @@  discard block
 block discarded – undo
985 985
 
986 986
 	public static function js_redirect( $url ) {
987 987
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
988
-    }
988
+	}
989 989
 
990 990
 	public static function get_user_id_param( $user_id ) {
991
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
992
-            return $user_id;
993
-        }
991
+		if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
992
+			return $user_id;
993
+		}
994 994
 
995 995
 		if ( $user_id == 'current' ) {
996 996
 			$user_id = get_current_user_id();
997 997
 		} else {
998
-            if ( is_email($user_id) ) {
999
-                $user = get_user_by('email', $user_id);
1000
-            } else {
1001
-                $user = get_user_by('login', $user_id);
1002
-            }
998
+			if ( is_email($user_id) ) {
999
+				$user = get_user_by('email', $user_id);
1000
+			} else {
1001
+				$user = get_user_by('login', $user_id);
1002
+			}
1003 1003
 
1004
-            if ( $user ) {
1005
-                $user_id = $user->ID;
1006
-            }
1007
-            unset($user);
1008
-        }
1004
+			if ( $user ) {
1005
+				$user_id = $user->ID;
1006
+			}
1007
+			unset($user);
1008
+		}
1009 1009
 
1010
-        return $user_id;
1011
-    }
1010
+		return $user_id;
1011
+	}
1012 1012
 
1013 1013
 	public static function get_file_contents( $filename, $atts = array() ) {
1014
-        if ( ! is_file($filename) ) {
1015
-            return false;
1016
-        }
1017
-
1018
-        extract($atts);
1019
-        ob_start();
1020
-        include($filename);
1021
-        $contents = ob_get_contents();
1022
-        ob_end_clean();
1023
-        return $contents;
1024
-    }
1025
-
1026
-    /**
1027
-     * @param string $table_name
1028
-     * @param string $column
1014
+		if ( ! is_file($filename) ) {
1015
+			return false;
1016
+		}
1017
+
1018
+		extract($atts);
1019
+		ob_start();
1020
+		include($filename);
1021
+		$contents = ob_get_contents();
1022
+		ob_end_clean();
1023
+		return $contents;
1024
+	}
1025
+
1026
+	/**
1027
+	 * @param string $table_name
1028
+	 * @param string $column
1029 1029
 	 * @param int $id
1030 1030
 	 * @param int $num_chars
1031
-     */
1032
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
1033
-        $key = '';
1031
+	 */
1032
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
1033
+		$key = '';
1034 1034
 
1035
-        if ( ! empty( $name ) ) {
1036
-            $key = sanitize_key($name);
1037
-        }
1035
+		if ( ! empty( $name ) ) {
1036
+			$key = sanitize_key($name);
1037
+		}
1038 1038
 
1039 1039
 		if ( empty( $key ) ) {
1040
-            $max_slug_value = pow(36, $num_chars);
1041
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
1042
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
1043
-        }
1040
+			$max_slug_value = pow(36, $num_chars);
1041
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
1042
+			$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
1043
+		}
1044 1044
 
1045 1045
 		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
1046 1046
 			$key = $key . 'a';
1047
-        }
1047
+		}
1048 1048
 
1049 1049
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
1050 1050
 
1051
-        if ( $key_check || is_numeric($key_check) ) {
1052
-            $suffix = 2;
1051
+		if ( $key_check || is_numeric($key_check) ) {
1052
+			$suffix = 2;
1053 1053
 			do {
1054 1054
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
1055 1055
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
1056 1056
 				$suffix++;
1057 1057
 			} while ( $key_check || is_numeric( $key_check ) );
1058 1058
 			$key = $alt_post_name;
1059
-        }
1060
-        return $key;
1061
-    }
1062
-
1063
-    /**
1064
-     * Editing a Form or Entry
1065
-     * @param string $table
1066
-     * @return bool|array
1067
-     */
1068
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1069
-        if ( ! $record ) {
1070
-            return false;
1071
-        }
1072
-
1073
-        if ( empty($post_values) ) {
1074
-            $post_values = stripslashes_deep($_POST);
1075
-        }
1059
+		}
1060
+		return $key;
1061
+	}
1062
+
1063
+	/**
1064
+	 * Editing a Form or Entry
1065
+	 * @param string $table
1066
+	 * @return bool|array
1067
+	 */
1068
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1069
+		if ( ! $record ) {
1070
+			return false;
1071
+		}
1072
+
1073
+		if ( empty($post_values) ) {
1074
+			$post_values = stripslashes_deep($_POST);
1075
+		}
1076 1076
 
1077 1077
 		$values = array( 'id' => $record->id, 'fields' => array() );
1078 1078
 
1079 1079
 		foreach ( array( 'name', 'description' ) as $var ) {
1080
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
1080
+			$default_val = isset($record->{$var}) ? $record->{$var} : '';
1081 1081
 			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
1082
-            unset($var, $default_val);
1083
-        }
1084
-
1085
-        $values['description'] = self::use_wpautop($values['description']);
1086
-        $frm_settings = self::get_settings();
1087
-        $is_form_builder = self::is_admin_page('formidable' );
1088
-
1089
-        foreach ( (array) $fields as $field ) {
1090
-            // Make sure to filter default values (for placeholder text), but not on the form builder page
1091
-            if ( ! $is_form_builder ) {
1092
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
1093
-            }
1082
+			unset($var, $default_val);
1083
+		}
1084
+
1085
+		$values['description'] = self::use_wpautop($values['description']);
1086
+		$frm_settings = self::get_settings();
1087
+		$is_form_builder = self::is_admin_page('formidable' );
1088
+
1089
+		foreach ( (array) $fields as $field ) {
1090
+			// Make sure to filter default values (for placeholder text), but not on the form builder page
1091
+			if ( ! $is_form_builder ) {
1092
+				$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
1093
+			}
1094 1094
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
1095 1095
 			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
1096
-        }
1096
+		}
1097 1097
 
1098
-        self::fill_form_opts($record, $table, $post_values, $values);
1098
+		self::fill_form_opts($record, $table, $post_values, $values);
1099 1099
 
1100
-        if ( $table == 'entries' ) {
1101
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1102
-        } else if ( $table == 'forms' ) {
1103
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1104
-        }
1100
+		if ( $table == 'entries' ) {
1101
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1102
+		} else if ( $table == 'forms' ) {
1103
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1104
+		}
1105 1105
 
1106
-        return $values;
1107
-    }
1106
+		return $values;
1107
+	}
1108 1108
 
1109 1109
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
1110
-        $post_values = $args['post_values'];
1111
-
1112
-        if ( $args['default'] ) {
1113
-            $meta_value = $field->default_value;
1114
-        } else {
1115
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1116
-                if ( ! isset($field->field_options['custom_field']) ) {
1117
-                    $field->field_options['custom_field'] = '';
1118
-                }
1110
+		$post_values = $args['post_values'];
1111
+
1112
+		if ( $args['default'] ) {
1113
+			$meta_value = $field->default_value;
1114
+		} else {
1115
+			if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1116
+				if ( ! isset($field->field_options['custom_field']) ) {
1117
+					$field->field_options['custom_field'] = '';
1118
+				}
1119 1119
 				$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 ) );
1120
-            } else {
1120
+			} else {
1121 1121
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1122
-            }
1123
-        }
1122
+			}
1123
+		}
1124 1124
 
1125 1125
 		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1126
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1127
-
1128
-        $field_array = array(
1129
-            'id'            => $field->id,
1130
-            'value'         => $new_value,
1131
-            'default_value' => $field->default_value,
1132
-            'name'          => $field->name,
1133
-            'description'   => $field->description,
1134
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1135
-            'options'       => $field->options,
1136
-            'required'      => $field->required,
1137
-            'field_key'     => $field->field_key,
1138
-            'field_order'   => $field->field_order,
1139
-            'form_id'       => $field->form_id,
1126
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1127
+
1128
+		$field_array = array(
1129
+			'id'            => $field->id,
1130
+			'value'         => $new_value,
1131
+			'default_value' => $field->default_value,
1132
+			'name'          => $field->name,
1133
+			'description'   => $field->description,
1134
+			'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1135
+			'options'       => $field->options,
1136
+			'required'      => $field->required,
1137
+			'field_key'     => $field->field_key,
1138
+			'field_order'   => $field->field_order,
1139
+			'form_id'       => $field->form_id,
1140 1140
 			'parent_form_id' => $args['parent_form_id'],
1141
-        );
1141
+		);
1142 1142
 
1143
-        $args['field_type'] = $field_type;
1144
-        self::fill_field_opts($field, $field_array, $args);
1143
+		$args['field_type'] = $field_type;
1144
+		self::fill_field_opts($field, $field_array, $args);
1145 1145
 		// Track the original field's type
1146 1146
 		$field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type;
1147 1147
 
1148
-        $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1148
+		$field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1149 1149
 
1150
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1151
-            $field_array['unique_msg'] = '';
1152
-        }
1150
+		if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1151
+			$field_array['unique_msg'] = '';
1152
+		}
1153 1153
 
1154
-        $field_array = array_merge( $field->field_options, $field_array );
1154
+		$field_array = array_merge( $field->field_options, $field_array );
1155 1155
 
1156
-        $values['fields'][ $field->id ] = $field_array;
1157
-    }
1156
+		$values['fields'][ $field->id ] = $field_array;
1157
+	}
1158 1158
 
1159 1159
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1160
-        $post_values = $args['post_values'];
1161
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1160
+		$post_values = $args['post_values'];
1161
+		$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1162 1162
 
1163
-        foreach ( $opt_defaults as $opt => $default_opt ) {
1163
+		foreach ( $opt_defaults as $opt => $default_opt ) {
1164 1164
 			$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 );
1165
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1166
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1167
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1168
-                if ( $args['field_type'] == 'captcha' ) {
1169
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1170
-                } else {
1171
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1172
-                }
1173
-            }
1174
-        }
1175
-
1176
-        if ( $field_array['custom_html'] == '' ) {
1177
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1178
-        }
1179
-    }
1180
-
1181
-    /**
1182
-     * @param string $table
1183
-     */
1165
+			if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1166
+				$field_array[ $opt ] = $args['frm_settings']->blank_msg;
1167
+			} else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1168
+				if ( $args['field_type'] == 'captcha' ) {
1169
+					$field_array[ $opt ] = $args['frm_settings']->re_msg;
1170
+				} else {
1171
+					$field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1172
+				}
1173
+			}
1174
+		}
1175
+
1176
+		if ( $field_array['custom_html'] == '' ) {
1177
+			$field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1178
+		}
1179
+	}
1180
+
1181
+	/**
1182
+	 * @param string $table
1183
+	 */
1184 1184
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1185
-        if ( $table == 'entries' ) {
1186
-            $form = $record->form_id;
1185
+		if ( $table == 'entries' ) {
1186
+			$form = $record->form_id;
1187 1187
 			FrmForm::maybe_get_form( $form );
1188
-        } else {
1189
-            $form = $record;
1190
-        }
1188
+		} else {
1189
+			$form = $record;
1190
+		}
1191 1191
 
1192
-        if ( ! $form ) {
1193
-            return;
1194
-        }
1192
+		if ( ! $form ) {
1193
+			return;
1194
+		}
1195 1195
 
1196
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1196
+		$values['form_name'] = isset($record->form_id) ? $form->name : '';
1197 1197
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1198 1198
 
1199
-        if ( ! is_array($form->options) ) {
1200
-            return;
1201
-        }
1199
+		if ( ! is_array($form->options) ) {
1200
+			return;
1201
+		}
1202 1202
 
1203
-        foreach ( $form->options as $opt => $value ) {
1204
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1205
-        }
1203
+		foreach ( $form->options as $opt => $value ) {
1204
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1205
+		}
1206 1206
 
1207
-        self::fill_form_defaults($post_values, $values);
1208
-    }
1207
+		self::fill_form_defaults($post_values, $values);
1208
+	}
1209 1209
 
1210
-    /**
1211
-     * Set to POST value or default
1212
-     */
1210
+	/**
1211
+	 * Set to POST value or default
1212
+	 */
1213 1213
 	private static function fill_form_defaults( $post_values, array &$values ) {
1214
-        $form_defaults = FrmFormsHelper::get_default_opts();
1214
+		$form_defaults = FrmFormsHelper::get_default_opts();
1215 1215
 
1216
-        foreach ( $form_defaults as $opt => $default ) {
1217
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1216
+		foreach ( $form_defaults as $opt => $default ) {
1217
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1218 1218
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1219
-            }
1219
+			}
1220 1220
 
1221
-            unset($opt, $defaut);
1222
-        }
1221
+			unset($opt, $defaut);
1222
+		}
1223 1223
 
1224 1224
 		if ( ! isset( $values['custom_style'] ) ) {
1225 1225
 			$values['custom_style'] = self::custom_style_value( $post_values );
@@ -1228,10 +1228,10 @@  discard block
 block discarded – undo
1228 1228
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1229 1229
 			if ( ! isset( $values[ $h . '_html' ] ) ) {
1230 1230
 				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1231
-            }
1232
-            unset($h);
1233
-        }
1234
-    }
1231
+			}
1232
+			unset($h);
1233
+		}
1234
+	}
1235 1235
 
1236 1236
 	/**
1237 1237
 	 * @since 2.2.10
@@ -1254,59 +1254,59 @@  discard block
 block discarded – undo
1254 1254
 	}
1255 1255
 
1256 1256
 	public static function insert_opt_html( $args ) {
1257
-        $class = '';
1258
-        if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1259
-            $class .= 'show_frm_not_email_to';
1260
-        }
1261
-    ?>
1257
+		$class = '';
1258
+		if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1259
+			$class .= 'show_frm_not_email_to';
1260
+		}
1261
+	?>
1262 1262
 <li>
1263 1263
     <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>
1264 1264
     <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>
1265 1265
     <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>
1266 1266
 </li>
1267 1267
     <?php
1268
-    }
1268
+	}
1269 1269
 
1270 1270
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1271
-        if ( is_array( $str ) ) {
1272
-            return '';
1271
+		if ( is_array( $str ) ) {
1272
+			return '';
1273 1273
 		}
1274 1274
 
1275
-        $length = (int) $length;
1275
+		$length = (int) $length;
1276 1276
 		$str = wp_strip_all_tags( $str );
1277 1277
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1278 1278
 
1279 1279
 		if ( $length == 0 ) {
1280
-            return '';
1281
-        } else if ( $length <= 10 ) {
1280
+			return '';
1281
+		} else if ( $length <= 10 ) {
1282 1282
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1283
-            return $sub . (($length < $original_len) ? $continue : '');
1284
-        }
1283
+			return $sub . (($length < $original_len) ? $continue : '');
1284
+		}
1285 1285
 
1286
-        $sub = '';
1287
-        $len = 0;
1286
+		$sub = '';
1287
+		$len = 0;
1288 1288
 
1289 1289
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1290 1290
 
1291 1291
 		foreach ( $words as $word ) {
1292
-            $part = (($sub != '') ? ' ' : '') . $word;
1292
+			$part = (($sub != '') ? ' ' : '') . $word;
1293 1293
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1294
-            if ( $total_len > $length && str_word_count($sub) ) {
1295
-                break;
1296
-            }
1294
+			if ( $total_len > $length && str_word_count($sub) ) {
1295
+				break;
1296
+			}
1297 1297
 
1298
-            $sub .= $part;
1298
+			$sub .= $part;
1299 1299
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1300 1300
 
1301
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1302
-                break;
1303
-            }
1301
+			if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1302
+				break;
1303
+			}
1304 1304
 
1305
-            unset($total_len, $word);
1306
-        }
1305
+			unset($total_len, $word);
1306
+		}
1307 1307
 
1308
-        return $sub . (($len < $original_len) ? $continue : '');
1309
-    }
1308
+		return $sub . (($len < $original_len) ? $continue : '');
1309
+	}
1310 1310
 
1311 1311
 	public static function mb_function( $function_names, $args ) {
1312 1312
 		$mb_function_name = $function_names[0];
@@ -1318,18 +1318,18 @@  discard block
 block discarded – undo
1318 1318
 	}
1319 1319
 
1320 1320
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1321
-        if ( empty($date) ) {
1322
-            return $date;
1323
-        }
1321
+		if ( empty($date) ) {
1322
+			return $date;
1323
+		}
1324 1324
 
1325
-        if ( empty($date_format) ) {
1326
-            $date_format = get_option('date_format');
1327
-        }
1325
+		if ( empty($date_format) ) {
1326
+			$date_format = get_option('date_format');
1327
+		}
1328 1328
 
1329
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1330
-            $frmpro_settings = new FrmProSettings();
1331
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1332
-        }
1329
+		if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1330
+			$frmpro_settings = new FrmProSettings();
1331
+			$date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1332
+		}
1333 1333
 
1334 1334
 		$formatted = self::get_localized_date( $date_format, $date );
1335 1335
 
@@ -1338,8 +1338,8 @@  discard block
 block discarded – undo
1338 1338
 			$formatted .= self::add_time_to_date( $time_format, $date );
1339 1339
 		}
1340 1340
 
1341
-        return $formatted;
1342
-    }
1341
+		return $formatted;
1342
+	}
1343 1343
 
1344 1344
 	private static function add_time_to_date( $time_format, $date ) {
1345 1345
 		if ( empty( $time_format ) ) {
@@ -1421,61 +1421,61 @@  discard block
 block discarded – undo
1421 1421
 		);
1422 1422
 	}
1423 1423
 
1424
-    /**
1425
-     * Added for < WP 4.0 compatability
1426
-     *
1427
-     * @since 1.07.10
1428
-     *
1429
-     * @param string $term The value to escape
1430
-     * @return string The escaped value
1431
-     */
1424
+	/**
1425
+	 * Added for < WP 4.0 compatability
1426
+	 *
1427
+	 * @since 1.07.10
1428
+	 *
1429
+	 * @param string $term The value to escape
1430
+	 * @return string The escaped value
1431
+	 */
1432 1432
 	public static function esc_like( $term ) {
1433
-        global $wpdb;
1434
-        if ( method_exists($wpdb, 'esc_like') ) {
1433
+		global $wpdb;
1434
+		if ( method_exists($wpdb, 'esc_like') ) {
1435 1435
 			// WP 4.0
1436
-            $term = $wpdb->esc_like( $term );
1437
-        } else {
1438
-            $term = like_escape( $term );
1439
-        }
1436
+			$term = $wpdb->esc_like( $term );
1437
+		} else {
1438
+			$term = like_escape( $term );
1439
+		}
1440 1440
 
1441
-        return $term;
1442
-    }
1441
+		return $term;
1442
+	}
1443 1443
 
1444
-    /**
1445
-     * @param string $order_query
1446
-     */
1444
+	/**
1445
+	 * @param string $order_query
1446
+	 */
1447 1447
 	public static function esc_order( $order_query ) {
1448
-        if ( empty($order_query) ) {
1449
-            return '';
1450
-        }
1451
-
1452
-        // remove ORDER BY before santizing
1453
-        $order_query = strtolower($order_query);
1454
-        if ( strpos($order_query, 'order by') !== false ) {
1455
-            $order_query = str_replace('order by', '', $order_query);
1456
-        }
1457
-
1458
-        $order_query = explode(' ', trim($order_query));
1459
-
1460
-        $order_fields = array(
1461
-            'id', 'form_key', 'name', 'description',
1462
-            'parent_form_id', 'logged_in', 'is_template',
1463
-            'default_template', 'status', 'created_at',
1464
-        );
1465
-
1466
-        $order = trim(trim(reset($order_query), ','));
1467
-        if ( ! in_array($order, $order_fields) ) {
1468
-            return '';
1469
-        }
1470
-
1471
-        $order_by = '';
1472
-        if ( count($order_query) > 1 ) {
1448
+		if ( empty($order_query) ) {
1449
+			return '';
1450
+		}
1451
+
1452
+		// remove ORDER BY before santizing
1453
+		$order_query = strtolower($order_query);
1454
+		if ( strpos($order_query, 'order by') !== false ) {
1455
+			$order_query = str_replace('order by', '', $order_query);
1456
+		}
1457
+
1458
+		$order_query = explode(' ', trim($order_query));
1459
+
1460
+		$order_fields = array(
1461
+			'id', 'form_key', 'name', 'description',
1462
+			'parent_form_id', 'logged_in', 'is_template',
1463
+			'default_template', 'status', 'created_at',
1464
+		);
1465
+
1466
+		$order = trim(trim(reset($order_query), ','));
1467
+		if ( ! in_array($order, $order_fields) ) {
1468
+			return '';
1469
+		}
1470
+
1471
+		$order_by = '';
1472
+		if ( count($order_query) > 1 ) {
1473 1473
 			$order_by = end( $order_query );
1474 1474
 			self::esc_order_by( $order_by );
1475
-        }
1475
+		}
1476 1476
 
1477 1477
 		return ' ORDER BY ' . $order . ' ' . $order_by;
1478
-    }
1478
+	}
1479 1479
 
1480 1480
 	/**
1481 1481
 	 * Make sure this is ordering by either ASC or DESC
@@ -1487,169 +1487,169 @@  discard block
 block discarded – undo
1487 1487
 		}
1488 1488
 	}
1489 1489
 
1490
-    /**
1491
-     * @param string $limit
1492
-     */
1490
+	/**
1491
+	 * @param string $limit
1492
+	 */
1493 1493
 	public static function esc_limit( $limit ) {
1494
-        if ( empty($limit) ) {
1495
-            return '';
1496
-        }
1494
+		if ( empty($limit) ) {
1495
+			return '';
1496
+		}
1497 1497
 
1498
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1499
-        if ( is_numeric($limit) ) {
1498
+		$limit = trim(str_replace(' limit', '', strtolower($limit)));
1499
+		if ( is_numeric($limit) ) {
1500 1500
 			return ' LIMIT ' . $limit;
1501
-        }
1501
+		}
1502 1502
 
1503
-        $limit = explode(',', trim($limit));
1504
-        foreach ( $limit as $k => $l ) {
1505
-            if ( is_numeric( $l ) ) {
1506
-                $limit[ $k ] = $l;
1507
-            }
1508
-        }
1503
+		$limit = explode(',', trim($limit));
1504
+		foreach ( $limit as $k => $l ) {
1505
+			if ( is_numeric( $l ) ) {
1506
+				$limit[ $k ] = $l;
1507
+			}
1508
+		}
1509 1509
 
1510
-        $limit = implode(',', $limit);
1510
+		$limit = implode(',', $limit);
1511 1511
 		return ' LIMIT ' . $limit;
1512
-    }
1513
-
1514
-    /**
1515
-     * Get an array of values ready to go through $wpdb->prepare
1516
-     * @since 2.0
1517
-     */
1518
-    public static function prepare_array_values( $array, $type = '%s' ) {
1519
-        $placeholders = array_fill(0, count($array), $type);
1520
-        return implode(', ', $placeholders);
1521
-    }
1522
-
1523
-    public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1524
-        if ( empty($where) ) {
1525
-            return '';
1526
-        }
1512
+	}
1513
+
1514
+	/**
1515
+	 * Get an array of values ready to go through $wpdb->prepare
1516
+	 * @since 2.0
1517
+	 */
1518
+	public static function prepare_array_values( $array, $type = '%s' ) {
1519
+		$placeholders = array_fill(0, count($array), $type);
1520
+		return implode(', ', $placeholders);
1521
+	}
1522
+
1523
+	public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1524
+		if ( empty($where) ) {
1525
+			return '';
1526
+		}
1527 1527
 
1528 1528
 		if ( is_array( $where ) ) {
1529
-            global $wpdb;
1530
-            FrmDb::get_where_clause_and_values( $where, $starts_with );
1529
+			global $wpdb;
1530
+			FrmDb::get_where_clause_and_values( $where, $starts_with );
1531 1531
 			$where = $wpdb->prepare( $where['where'], $where['values'] );
1532 1532
 		} else {
1533
-            $where = $starts_with . $where;
1534
-        }
1533
+			$where = $starts_with . $where;
1534
+		}
1535 1535
 
1536
-        return $where;
1537
-    }
1536
+		return $where;
1537
+	}
1538 1538
 
1539
-    // Pagination Methods
1539
+	// Pagination Methods
1540 1540
 
1541
-    /**
1542
-     * @param integer $current_p
1543
-     */
1541
+	/**
1542
+	 * @param integer $current_p
1543
+	 */
1544 1544
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1545 1545
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1546 1546
 	}
1547 1547
 
1548
-    /**
1549
-     * @param integer $current_p
1550
-     */
1551
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1552
-        if ( $current_p == 1 ) {
1553
-            return 1;
1554
-        } else {
1555
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1556
-        }
1557
-    }
1548
+	/**
1549
+	 * @param integer $current_p
1550
+	 */
1551
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1552
+		if ( $current_p == 1 ) {
1553
+			return 1;
1554
+		} else {
1555
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1556
+		}
1557
+	}
1558 1558
 
1559 1559
 	/**
1560 1560
 	 * @return array
1561 1561
 	 */
1562 1562
 	public static function json_to_array( $json_vars ) {
1563
-        $vars = array();
1564
-        foreach ( $json_vars as $jv ) {
1565
-            $jv_name = explode('[', $jv['name']);
1566
-            $last = count($jv_name) - 1;
1567
-            foreach ( $jv_name as $p => $n ) {
1568
-                $name = trim($n, ']');
1569
-                if ( ! isset($l1) ) {
1570
-                    $l1 = $name;
1571
-                }
1572
-
1573
-                if ( ! isset($l2) ) {
1574
-                    $l2 = $name;
1575
-                }
1576
-
1577
-                if ( ! isset($l3) ) {
1578
-                    $l3 = $name;
1579
-                }
1580
-
1581
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1582
-
1583
-                switch ( $p ) {
1584
-                    case 0:
1585
-                        $l1 = $name;
1586
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1587
-                    break;
1588
-
1589
-                    case 1:
1590
-                        $l2 = $name;
1591
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1592
-                    break;
1593
-
1594
-                    case 2:
1595
-                        $l3 = $name;
1596
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1597
-                    break;
1598
-
1599
-                    case 3:
1600
-                        $l4 = $name;
1601
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1602
-                    break;
1603
-                }
1604
-
1605
-                unset($this_val, $n);
1606
-            }
1607
-
1608
-            unset($last, $jv);
1609
-        }
1610
-
1611
-        return $vars;
1612
-    }
1613
-
1614
-    /**
1615
-     * @param string $name
1616
-     * @param string $l1
1617
-     */
1618
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1619
-        if ( $name == '' ) {
1620
-            $vars[] = $val;
1621
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1622
-            $vars[ $l1 ] = $val;
1623
-        }
1624
-    }
1563
+		$vars = array();
1564
+		foreach ( $json_vars as $jv ) {
1565
+			$jv_name = explode('[', $jv['name']);
1566
+			$last = count($jv_name) - 1;
1567
+			foreach ( $jv_name as $p => $n ) {
1568
+				$name = trim($n, ']');
1569
+				if ( ! isset($l1) ) {
1570
+					$l1 = $name;
1571
+				}
1572
+
1573
+				if ( ! isset($l2) ) {
1574
+					$l2 = $name;
1575
+				}
1576
+
1577
+				if ( ! isset($l3) ) {
1578
+					$l3 = $name;
1579
+				}
1580
+
1581
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1582
+
1583
+				switch ( $p ) {
1584
+					case 0:
1585
+						$l1 = $name;
1586
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1587
+					break;
1588
+
1589
+					case 1:
1590
+						$l2 = $name;
1591
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1592
+					break;
1593
+
1594
+					case 2:
1595
+						$l3 = $name;
1596
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1597
+					break;
1598
+
1599
+					case 3:
1600
+						$l4 = $name;
1601
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1602
+					break;
1603
+				}
1604
+
1605
+				unset($this_val, $n);
1606
+			}
1607
+
1608
+			unset($last, $jv);
1609
+		}
1610
+
1611
+		return $vars;
1612
+	}
1613
+
1614
+	/**
1615
+	 * @param string $name
1616
+	 * @param string $l1
1617
+	 */
1618
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1619
+		if ( $name == '' ) {
1620
+			$vars[] = $val;
1621
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1622
+			$vars[ $l1 ] = $val;
1623
+		}
1624
+	}
1625 1625
 
1626 1626
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1627
-        $tooltips = array(
1628
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1629
-            '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' ),
1630
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1631
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1632
-            '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' ),
1633
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1634
-            '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() ) ),
1635
-        );
1636
-
1637
-        if ( ! isset( $tooltips[ $name ] ) ) {
1638
-            return;
1639
-        }
1640
-
1641
-        if ( 'open' == $class ) {
1642
-            echo ' frm_help"';
1643
-        } else {
1644
-            echo ' class="frm_help"';
1645
-        }
1627
+		$tooltips = array(
1628
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1629
+			'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' ),
1630
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1631
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1632
+			'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' ),
1633
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1634
+			'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() ) ),
1635
+		);
1636
+
1637
+		if ( ! isset( $tooltips[ $name ] ) ) {
1638
+			return;
1639
+		}
1640
+
1641
+		if ( 'open' == $class ) {
1642
+			echo ' frm_help"';
1643
+		} else {
1644
+			echo ' class="frm_help"';
1645
+		}
1646 1646
 
1647 1647
 		echo ' title="' . esc_attr( $tooltips[ $name ] );
1648 1648
 
1649
-        if ( 'open' != $class ) {
1650
-            echo '"';
1651
-        }
1652
-    }
1649
+		if ( 'open' != $class ) {
1650
+			echo '"';
1651
+		}
1652
+	}
1653 1653
 
1654 1654
 	/**
1655 1655
 	 * Add the current_page class to that page in the form nav
@@ -1665,35 +1665,35 @@  discard block
 block discarded – undo
1665 1665
 		}
1666 1666
 	}
1667 1667
 
1668
-    /**
1669
-     * Prepare and json_encode post content
1670
-     *
1671
-     * @since 2.0
1672
-     *
1673
-     * @param array $post_content
1674
-     * @return string $post_content ( json encoded array )
1675
-     */
1676
-    public static function prepare_and_encode( $post_content ) {
1677
-        //Loop through array to strip slashes and add only the needed ones
1668
+	/**
1669
+	 * Prepare and json_encode post content
1670
+	 *
1671
+	 * @since 2.0
1672
+	 *
1673
+	 * @param array $post_content
1674
+	 * @return string $post_content ( json encoded array )
1675
+	 */
1676
+	public static function prepare_and_encode( $post_content ) {
1677
+		//Loop through array to strip slashes and add only the needed ones
1678 1678
 		foreach ( $post_content as $key => $val ) {
1679 1679
 			// Replace problematic characters (like &quot;)
1680 1680
 			$val = str_replace( '&quot;', '"', $val );
1681 1681
 
1682 1682
 			self::prepare_action_slashes( $val, $key, $post_content );
1683
-            unset( $key, $val );
1684
-        }
1683
+			unset( $key, $val );
1684
+		}
1685 1685
 
1686
-        // json_encode the array
1687
-        $post_content = json_encode( $post_content );
1686
+		// json_encode the array
1687
+		$post_content = json_encode( $post_content );
1688 1688
 
1689
-	    // add extra slashes for \r\n since WP strips them
1689
+		// add extra slashes for \r\n since WP strips them
1690 1690
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1691 1691
 
1692
-        // allow for &quot
1693
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1692
+		// allow for &quot
1693
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1694 1694
 
1695
-        return $post_content;
1696
-    }
1695
+		return $post_content;
1696
+	}
1697 1697
 
1698 1698
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1699 1699
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1761,64 +1761,64 @@  discard block
 block discarded – undo
1761 1761
 	}
1762 1762
 
1763 1763
 	public static function maybe_json_decode( $string ) {
1764
-        if ( is_array($string) ) {
1765
-            return $string;
1766
-        }
1764
+		if ( is_array($string) ) {
1765
+			return $string;
1766
+		}
1767 1767
 
1768
-        $new_string = json_decode($string, true);
1769
-        if ( function_exists('json_last_error') ) {
1768
+		$new_string = json_decode($string, true);
1769
+		if ( function_exists('json_last_error') ) {
1770 1770
 			// php 5.3+
1771
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1772
-                $string = $new_string;
1773
-            }
1774
-        } else if ( isset($new_string) ) {
1771
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1772
+				$string = $new_string;
1773
+			}
1774
+		} else if ( isset($new_string) ) {
1775 1775
 			// php < 5.3 fallback
1776
-            $string = $new_string;
1777
-        }
1778
-        return $string;
1779
-    }
1780
-
1781
-    /**
1782
-     * @since 1.07.10
1783
-     *
1784
-     * @param string $post_type The name of the post type that may need to be highlighted
1785
-     * echo The javascript to open and highlight the Formidable menu
1786
-     */
1776
+			$string = $new_string;
1777
+		}
1778
+		return $string;
1779
+	}
1780
+
1781
+	/**
1782
+	 * @since 1.07.10
1783
+	 *
1784
+	 * @param string $post_type The name of the post type that may need to be highlighted
1785
+	 * echo The javascript to open and highlight the Formidable menu
1786
+	 */
1787 1787
 	public static function maybe_highlight_menu( $post_type ) {
1788
-        global $post;
1788
+		global $post;
1789 1789
 
1790
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1791
-            return;
1792
-        }
1790
+		if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1791
+			return;
1792
+		}
1793 1793
 
1794
-        if ( is_object($post) && $post->post_type != $post_type ) {
1795
-            return;
1796
-        }
1794
+		if ( is_object($post) && $post->post_type != $post_type ) {
1795
+			return;
1796
+		}
1797 1797
 
1798
-        self::load_admin_wide_js();
1799
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1800
-    }
1798
+		self::load_admin_wide_js();
1799
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1800
+	}
1801 1801
 
1802
-    /**
1803
-     * Load the JS file on non-Formidable pages in the admin area
1804
-     * @since 2.0
1805
-     */
1802
+	/**
1803
+	 * Load the JS file on non-Formidable pages in the admin area
1804
+	 * @since 2.0
1805
+	 */
1806 1806
 	public static function load_admin_wide_js( $load = true ) {
1807
-        $version = FrmAppHelper::plugin_version();
1807
+		$version = FrmAppHelper::plugin_version();
1808 1808
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1809 1809
 
1810
-        wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1810
+		wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1811 1811
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1812
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1812
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1813 1813
 			'url'          => FrmAppHelper::plugin_url(),
1814 1814
 			'loading'      => __( 'Loading&hellip;' ),
1815 1815
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
1816
-        ) );
1816
+		) );
1817 1817
 
1818 1818
 		if ( $load ) {
1819 1819
 			wp_enqueue_script( 'formidable_admin_global' );
1820 1820
 		}
1821
-    }
1821
+	}
1822 1822
 
1823 1823
 	/**
1824 1824
 	 * @since 2.0.9
@@ -1827,9 +1827,9 @@  discard block
 block discarded – undo
1827 1827
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1828 1828
 	}
1829 1829
 
1830
-    /**
1831
-     * @param string $location
1832
-     */
1830
+	/**
1831
+	 * @param string $location
1832
+	 */
1833 1833
 	public static function localize_script( $location ) {
1834 1834
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1835 1835
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1885,81 +1885,81 @@  discard block
 block discarded – undo
1885 1885
 		}
1886 1886
 	}
1887 1887
 
1888
-    /**
1888
+	/**
1889 1889
 	 * echo the message on the plugins listing page
1890
-     * @since 1.07.10
1891
-     *
1892
-     * @param float $min_version The version the add-on requires
1893
-     */
1890
+	 * @since 1.07.10
1891
+	 *
1892
+	 * @param float $min_version The version the add-on requires
1893
+	 */
1894 1894
 	public static function min_version_notice( $min_version ) {
1895
-        $frm_version = self::plugin_version();
1895
+		$frm_version = self::plugin_version();
1896 1896
 
1897
-        // check if Formidable meets minimum requirements
1898
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1899
-            return;
1900
-        }
1897
+		// check if Formidable meets minimum requirements
1898
+		if ( version_compare($frm_version, $min_version, '>=') ) {
1899
+			return;
1900
+		}
1901 1901
 
1902
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1902
+		$wp_list_table = _get_list_table('WP_Plugins_List_Table');
1903 1903
 		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">' .
1904
-        __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1905
-        '</div></td></tr>';
1906
-    }
1907
-
1908
-    public static function locales( $type = 'date' ) {
1909
-        $locales = array(
1910
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1911
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1912
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1913
-            'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1914
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1915
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1916
-            'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1917
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1918
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1919
-            'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1920
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1921
-            'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1922
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1923
-            'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1924
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1925
-            'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1926
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1927
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1928
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1929
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1930
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1931
-            'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1932
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1933
-            'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1934
-            'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1935
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1936
-            'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1937
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1938
-            'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1939
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1940
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1941
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1942
-        );
1943
-
1944
-        if ( $type == 'captcha' ) {
1945
-            // remove the languages unavailable for the captcha
1946
-            $unset = array(
1947
-                '', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1948
-                'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1949
-                'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1950
-            );
1951
-        } else {
1952
-            // remove the languages unavailable for the datepicker
1953
-            $unset = array(
1954
-                'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1955
-                'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1956
-                'es-419', 'tr',
1957
-            );
1958
-        }
1959
-
1960
-        $locales = array_diff_key($locales, array_flip($unset));
1961
-        $locales = apply_filters('frm_locales', $locales);
1962
-
1963
-        return $locales;
1964
-    }
1904
+		__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1905
+		'</div></td></tr>';
1906
+	}
1907
+
1908
+	public static function locales( $type = 'date' ) {
1909
+		$locales = array(
1910
+			'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1911
+			'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1912
+			'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1913
+			'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1914
+			'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1915
+			'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1916
+			'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1917
+			'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1918
+			'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1919
+			'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1920
+			'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1921
+			'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1922
+			'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1923
+			'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1924
+			'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1925
+			'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1926
+			'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1927
+			'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1928
+			'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1929
+			'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1930
+			'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1931
+			'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1932
+			'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1933
+			'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1934
+			'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1935
+			'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1936
+			'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1937
+			'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1938
+			'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1939
+			'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1940
+			'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1941
+			'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1942
+		);
1943
+
1944
+		if ( $type == 'captcha' ) {
1945
+			// remove the languages unavailable for the captcha
1946
+			$unset = array(
1947
+				'', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1948
+				'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1949
+				'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1950
+			);
1951
+		} else {
1952
+			// remove the languages unavailable for the datepicker
1953
+			$unset = array(
1954
+				'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1955
+				'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1956
+				'es-419', 'tr',
1957
+			);
1958
+		}
1959
+
1960
+		$locales = array_diff_key($locales, array_flip($unset));
1961
+		$locales = apply_filters('frm_locales', $locales);
1962
+
1963
+		return $locales;
1964
+	}
1965 1965
 }
Please login to merge, or discard this patch.