Completed
Push — master ( 1ae166...02cc92 )
by Stephanie
04:26 queued 01:44
created
classes/helpers/FrmAppHelper.php 1 patch
Indentation   +877 added lines, -877 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.06';
14 14
 
15
-    /**
16
-     * @since 1.07.02
17
-     *
18
-     * @param none
19
-     * @return string The version of this plugin
20
-     */
21
-    public static function plugin_version() {
22
-        return self::$plug_version;
23
-    }
24
-
25
-    public static function plugin_folder() {
26
-        return basename(self::plugin_path());
27
-    }
28
-
29
-    public static function plugin_path() {
30
-        return dirname(dirname(dirname(__FILE__)));
31
-    }
32
-
33
-    public static function plugin_url() {
34
-        //prevously FRM_URL constant
15
+	/**
16
+	 * @since 1.07.02
17
+	 *
18
+	 * @param none
19
+	 * @return string The version of this plugin
20
+	 */
21
+	public static function plugin_version() {
22
+		return self::$plug_version;
23
+	}
24
+
25
+	public static function plugin_folder() {
26
+		return basename(self::plugin_path());
27
+	}
28
+
29
+	public static function plugin_path() {
30
+		return dirname(dirname(dirname(__FILE__)));
31
+	}
32
+
33
+	public static function plugin_url() {
34
+		//prevously FRM_URL constant
35 35
 		return plugins_url( '', self::plugin_path() . '/formidable.php' );
36
-    }
36
+	}
37 37
 
38 38
 	public static function relative_plugin_url() {
39 39
 		return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() );
40 40
 	}
41 41
 
42
-    /**
43
-     * @return string Site URL
44
-     */
45
-    public static function site_url() {
46
-        return site_url();
47
-    }
48
-
49
-    /**
50
-     * Get the name of this site
51
-     * Used for [sitename] shortcode
52
-     *
53
-     * @since 2.0
54
-     * @return string
55
-     */
56
-    public static function site_name() {
57
-        return get_option('blogname');
58
-    }
42
+	/**
43
+	 * @return string Site URL
44
+	 */
45
+	public static function site_url() {
46
+		return site_url();
47
+	}
48
+
49
+	/**
50
+	 * Get the name of this site
51
+	 * Used for [sitename] shortcode
52
+	 *
53
+	 * @since 2.0
54
+	 * @return string
55
+	 */
56
+	public static function site_name() {
57
+		return get_option('blogname');
58
+	}
59 59
 
60 60
 	public static function make_affiliate_url( $url ) {
61 61
 		$affiliate_id = self::get_affiliate();
@@ -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 self::wp_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 self::wp_doing_ajax() && ! self::is_preview_page();
157
+	}
158 158
 
159 159
 	/**
160 160
 	 * Use the WP 4.7 wp_doing_ajax function
@@ -177,102 +177,102 @@  discard block
 block discarded – undo
177 177
 		return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
178 178
 	}
179 179
 
180
-    /**
181
-     * Check if on an admin page
182
-     *
183
-     * @since 2.0
184
-     *
185
-     * @param None
186
-     * @return boolean
187
-     */
188
-    public static function is_admin() {
189
-        return is_admin() && ! self::wp_doing_ajax();
190
-    }
191
-
192
-    /**
193
-     * Check if value contains blank value or empty array
194
-     *
195
-     * @since 2.0
196
-     * @param mixed $value - value to check
180
+	/**
181
+	 * Check if on an admin page
182
+	 *
183
+	 * @since 2.0
184
+	 *
185
+	 * @param None
186
+	 * @return boolean
187
+	 */
188
+	public static function is_admin() {
189
+		return is_admin() && ! self::wp_doing_ajax();
190
+	}
191
+
192
+	/**
193
+	 * Check if value contains blank value or empty array
194
+	 *
195
+	 * @since 2.0
196
+	 * @param mixed $value - value to check
197 197
 	 * @param string
198
-     * @return boolean
199
-     */
200
-    public static function is_empty_value( $value, $empty = '' ) {
201
-        return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
202
-    }
203
-
204
-    public static function is_not_empty_value( $value, $empty = '' ) {
205
-        return ! self::is_empty_value( $value, $empty );
206
-    }
207
-
208
-    /**
209
-     * Get any value from the $_SERVER
210
-     *
211
-     * @since 2.0
212
-     * @param string $value
213
-     * @return string
214
-     */
198
+	 * @return boolean
199
+	 */
200
+	public static function is_empty_value( $value, $empty = '' ) {
201
+		return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
202
+	}
203
+
204
+	public static function is_not_empty_value( $value, $empty = '' ) {
205
+		return ! self::is_empty_value( $value, $empty );
206
+	}
207
+
208
+	/**
209
+	 * Get any value from the $_SERVER
210
+	 *
211
+	 * @since 2.0
212
+	 * @param string $value
213
+	 * @return string
214
+	 */
215 215
 	public static function get_server_value( $value ) {
216
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
217
-    }
218
-
219
-    /**
220
-     * Check for the IP address in several places
221
-     * Used by [ip] shortcode
222
-     *
223
-     * @return string The IP address of the current user
224
-     */
225
-    public static function get_ip_address() {
216
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
217
+	}
218
+
219
+	/**
220
+	 * Check for the IP address in several places
221
+	 * Used by [ip] shortcode
222
+	 *
223
+	 * @return string The IP address of the current user
224
+	 */
225
+	public static function get_ip_address() {
226 226
 		$ip = '';
227
-        foreach ( array(
228
-            'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
229
-            'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
230
-        ) as $key ) {
231
-            if ( ! isset( $_SERVER[ $key ] ) ) {
232
-                continue;
233
-            }
234
-
235
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
236
-                $ip = trim($ip); // just to be safe
237
-
238
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
239
-                    return $ip;
240
-                }
241
-            }
242
-        }
227
+		foreach ( array(
228
+			'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
229
+			'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
230
+		) as $key ) {
231
+			if ( ! isset( $_SERVER[ $key ] ) ) {
232
+				continue;
233
+			}
234
+
235
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
236
+				$ip = trim($ip); // just to be safe
237
+
238
+				if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
239
+					return $ip;
240
+				}
241
+			}
242
+		}
243 243
 
244 244
 		return sanitize_text_field( $ip );
245
-    }
245
+	}
246 246
 
247
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
248
-        if ( strpos($param, '[') ) {
249
-            $params = explode('[', $param);
250
-            $param = $params[0];
251
-        }
247
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
248
+		if ( strpos($param, '[') ) {
249
+			$params = explode('[', $param);
250
+			$param = $params[0];
251
+		}
252 252
 
253 253
 		if ( $src == 'get' ) {
254
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
255
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
256
-                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
257
-            }
254
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
255
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
256
+				$value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
257
+			}
258 258
 			self::sanitize_value( $sanitize, $value );
259 259
 		} else {
260
-            $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
261
-        }
260
+			$value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
261
+		}
262 262
 
263 263
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
264
-            foreach ( $params as $k => $p ) {
265
-                if ( ! $k || ! is_array($value) ) {
266
-                    continue;
267
-                }
264
+			foreach ( $params as $k => $p ) {
265
+				if ( ! $k || ! is_array($value) ) {
266
+					continue;
267
+				}
268 268
 
269
-                $p = trim($p, ']');
270
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
271
-            }
272
-        }
269
+				$p = trim($p, ']');
270
+				$value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
271
+			}
272
+		}
273 273
 
274
-        return $value;
275
-    }
274
+		return $value;
275
+	}
276 276
 
277 277
 	public static function get_post_param( $param, $default = '', $sanitize = '' ) {
278 278
 		return self::get_simple_request( array( 'type' => 'post', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	 */
289 289
 	public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) {
290 290
 		return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
291
-    }
291
+	}
292 292
 
293 293
 	/**
294 294
 	 * Get a GET/POST/REQUEST value and sanitize it
@@ -324,12 +324,12 @@  discard block
 block discarded – undo
324 324
 	}
325 325
 
326 326
 	/**
327
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
328
-	*
329
-	* @since 2.0.8
330
-	* @param string $value
331
-	* @return string $value
332
-	*/
327
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
328
+	 *
329
+	 * @since 2.0.8
330
+	 * @param string $value
331
+	 * @return string $value
332
+	 */
333 333
 	public static function preserve_backslashes( $value ) {
334 334
 		// If backslashes have already been added, don't add them again
335 335
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -351,14 +351,14 @@  discard block
 block discarded – undo
351 351
 		}
352 352
 	}
353 353
 
354
-    public static function sanitize_request( $sanitize_method, &$values ) {
355
-        $temp_values = $values;
356
-        foreach ( $temp_values as $k => $val ) {
357
-            if ( isset( $sanitize_method[ $k ] ) ) {
354
+	public static function sanitize_request( $sanitize_method, &$values ) {
355
+		$temp_values = $values;
356
+		foreach ( $temp_values as $k => $val ) {
357
+			if ( isset( $sanitize_method[ $k ] ) ) {
358 358
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
359
-            }
360
-        }
361
-    }
359
+			}
360
+		}
361
+	}
362 362
 
363 363
 	public static function sanitize_array( &$values ) {
364 364
 		$temp_values = $values;
@@ -482,80 +482,80 @@  discard block
 block discarded – undo
482 482
 		);
483 483
 	}
484 484
 
485
-    /**
486
-     * Used when switching the action for a bulk action
487
-     * @since 2.0
488
-     */
489
-    public static function remove_get_action() {
490
-        if ( ! isset($_GET) ) {
491
-            return;
492
-        }
485
+	/**
486
+	 * Used when switching the action for a bulk action
487
+	 * @since 2.0
488
+	 */
489
+	public static function remove_get_action() {
490
+		if ( ! isset($_GET) ) {
491
+			return;
492
+		}
493 493
 
494
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
495
-        if ( ! empty( $new_action ) ) {
494
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
495
+		if ( ! empty( $new_action ) ) {
496 496
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
497
-        }
498
-    }
499
-
500
-    /**
501
-     * Check the WP query for a parameter
502
-     *
503
-     * @since 2.0
504
-     * @return string|array
505
-     */
506
-    public static function get_query_var( $value, $param ) {
507
-        if ( $value != '' ) {
508
-            return $value;
509
-        }
510
-
511
-        global $wp_query;
512
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
513
-            $value = $wp_query->query_vars[ $param ];
514
-        }
515
-
516
-        return $value;
517
-    }
518
-
519
-    /**
520
-     * @param string $type
521
-     */
522
-    public static function trigger_hook_load( $type, $object = null ) {
523
-        // only load the form hooks once
497
+		}
498
+	}
499
+
500
+	/**
501
+	 * Check the WP query for a parameter
502
+	 *
503
+	 * @since 2.0
504
+	 * @return string|array
505
+	 */
506
+	public static function get_query_var( $value, $param ) {
507
+		if ( $value != '' ) {
508
+			return $value;
509
+		}
510
+
511
+		global $wp_query;
512
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
513
+			$value = $wp_query->query_vars[ $param ];
514
+		}
515
+
516
+		return $value;
517
+	}
518
+
519
+	/**
520
+	 * @param string $type
521
+	 */
522
+	public static function trigger_hook_load( $type, $object = null ) {
523
+		// only load the form hooks once
524 524
 		$hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
525
-        if ( ! $hooks_loaded ) {
525
+		if ( ! $hooks_loaded ) {
526 526
 			do_action( 'frm_load_' . $type . '_hooks' );
527
-        }
528
-    }
529
-
530
-    /**
531
-     * Check a value from a shortcode to see if true or false.
532
-     * True when value is 1, true, 'true', 'yes'
533
-     *
534
-     * @since 1.07.10
535
-     *
536
-     * @param string $value The value to compare
537
-     * @return boolean True or False
538
-     */
527
+		}
528
+	}
529
+
530
+	/**
531
+	 * Check a value from a shortcode to see if true or false.
532
+	 * True when value is 1, true, 'true', 'yes'
533
+	 *
534
+	 * @since 1.07.10
535
+	 *
536
+	 * @param string $value The value to compare
537
+	 * @return boolean True or False
538
+	 */
539 539
 	public static function is_true( $value ) {
540
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
541
-    }
540
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
541
+	}
542 542
 
543
-    /**
544
-     * Used to filter shortcode in text widgets
545
-     */
546
-    public static function widget_text_filter_callback( $matches ) {
543
+	/**
544
+	 * Used to filter shortcode in text widgets
545
+	 */
546
+	public static function widget_text_filter_callback( $matches ) {
547 547
 		_deprecated_function( __METHOD__, '2.5.4' );
548
-        return do_shortcode( $matches[0] );
549
-    }
548
+		return do_shortcode( $matches[0] );
549
+	}
550 550
 
551
-    public static function get_pages() {
551
+	public static function get_pages() {
552 552
 		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
553
-    }
553
+	}
554 554
 
555
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
556
-        $pages = self::get_pages();
555
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
556
+		$pages = self::get_pages();
557 557
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
558
-    ?>
558
+	?>
559 559
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
560 560
             <option value=""> </option>
561 561
             <?php foreach ( $pages as $page ) { ?>
@@ -565,108 +565,108 @@  discard block
 block discarded – undo
565 565
             <?php } ?>
566 566
         </select>
567 567
     <?php
568
-    }
568
+	}
569 569
 
570 570
 	public static function post_edit_link( $post_id ) {
571
-        $post = get_post($post_id);
572
-        if ( $post ) {
571
+		$post = get_post($post_id);
572
+		if ( $post ) {
573 573
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
574 574
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
575
-        }
576
-        return '';
577
-    }
575
+		}
576
+		return '';
577
+	}
578 578
 
579 579
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
580
-    ?>
580
+	?>
581 581
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
582
-            echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
583
-            ?> class="frm_multiselect">
582
+			echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
583
+			?> class="frm_multiselect">
584 584
             <?php self::roles_options($capability); ?>
585 585
         </select>
586 586
     <?php
587
-    }
587
+	}
588 588
 
589 589
 	public static function roles_options( $capability ) {
590
-        global $frm_vars;
591
-        if ( isset($frm_vars['editable_roles']) ) {
592
-            $editable_roles = $frm_vars['editable_roles'];
593
-        } else {
594
-            $editable_roles = get_editable_roles();
595
-            $frm_vars['editable_roles'] = $editable_roles;
596
-        }
597
-
598
-        foreach ( $editable_roles as $role => $details ) {
599
-            $name = translate_user_role($details['name'] ); ?>
590
+		global $frm_vars;
591
+		if ( isset($frm_vars['editable_roles']) ) {
592
+			$editable_roles = $frm_vars['editable_roles'];
593
+		} else {
594
+			$editable_roles = get_editable_roles();
595
+			$frm_vars['editable_roles'] = $editable_roles;
596
+		}
597
+
598
+		foreach ( $editable_roles as $role => $details ) {
599
+			$name = translate_user_role($details['name'] ); ?>
600 600
         <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
601 601
 <?php
602
-            unset($role, $details);
603
-        }
604
-    }
602
+			unset($role, $details);
603
+		}
604
+	}
605 605
 
606 606
 	public static function frm_capabilities( $type = 'auto' ) {
607
-        $cap = array(
608
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
609
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
610
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
611
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
612
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
613
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
614
-        );
607
+		$cap = array(
608
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
609
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
610
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
611
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
612
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
613
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
614
+		);
615 615
 
616 616
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
617
-            return $cap;
618
-        }
617
+			return $cap;
618
+		}
619 619
 
620
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
621
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
622
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
623
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
620
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
621
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
622
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
623
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
624 624
 
625
-        return $cap;
626
-    }
625
+		return $cap;
626
+	}
627 627
 
628 628
 	public static function user_has_permission( $needed_role ) {
629
-        if ( $needed_role == '-1' ) {
630
-            return false;
629
+		if ( $needed_role == '-1' ) {
630
+			return false;
631 631
 		}
632 632
 
633
-        // $needed_role will be equal to blank if "Logged-in users" is selected
634
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
635
-            return true;
636
-        }
633
+		// $needed_role will be equal to blank if "Logged-in users" is selected
634
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
635
+			return true;
636
+		}
637 637
 
638
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
639
-        foreach ( $roles as $role ) {
638
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
639
+		foreach ( $roles as $role ) {
640 640
 			if ( current_user_can( $role ) ) {
641
-        		return true;
641
+				return true;
642 642
 			}
643
-        	if ( $role == $needed_role ) {
644
-        		break;
643
+			if ( $role == $needed_role ) {
644
+				break;
645 645
 			}
646
-        }
647
-        return false;
648
-    }
649
-
650
-    /**
651
-     * Make sure administrators can see Formidable menu
652
-     *
653
-     * @since 2.0
654
-     */
655
-    public static function maybe_add_permissions() {
646
+		}
647
+		return false;
648
+	}
649
+
650
+	/**
651
+	 * Make sure administrators can see Formidable menu
652
+	 *
653
+	 * @since 2.0
654
+	 */
655
+	public static function maybe_add_permissions() {
656 656
 		self::force_capability( 'frm_view_entries' );
657 657
 
658
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
659
-            return;
660
-        }
658
+		if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
659
+			return;
660
+		}
661 661
 
662 662
 		$user_id = get_current_user_id();
663 663
 		$user = new WP_User( $user_id );
664
-        $frm_roles = self::frm_capabilities();
665
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
664
+		$frm_roles = self::frm_capabilities();
665
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
666 666
 			$user->add_cap( $frm_role );
667
-            unset($frm_role, $frm_role_description);
668
-        }
669
-    }
667
+			unset($frm_role, $frm_role_description);
668
+		}
669
+	}
670 670
 
671 671
 	/**
672 672
 	 * Make sure admins have permission to see the menu items
@@ -682,28 +682,28 @@  discard block
 block discarded – undo
682 682
 		}
683 683
 	}
684 684
 
685
-    /**
686
-     * Check if the user has permision for action.
687
-     * Return permission message and stop the action if no permission
688
-     * @since 2.0
689
-     * @param string $permission
690
-     */
685
+	/**
686
+	 * Check if the user has permision for action.
687
+	 * Return permission message and stop the action if no permission
688
+	 * @since 2.0
689
+	 * @param string $permission
690
+	 */
691 691
 	public static function permission_check( $permission, $show_message = 'show' ) {
692
-        $permission_error = self::permission_nonce_error($permission);
693
-        if ( $permission_error !== false ) {
694
-            if ( 'hide' == $show_message ) {
695
-                $permission_error = '';
696
-            }
697
-            wp_die($permission_error);
698
-        }
699
-    }
700
-
701
-    /**
702
-     * Check user permission and nonce
703
-     * @since 2.0
704
-     * @param string $permission
705
-     * @return false|string The permission message or false if allowed
706
-     */
692
+		$permission_error = self::permission_nonce_error($permission);
693
+		if ( $permission_error !== false ) {
694
+			if ( 'hide' == $show_message ) {
695
+				$permission_error = '';
696
+			}
697
+			wp_die($permission_error);
698
+		}
699
+	}
700
+
701
+	/**
702
+	 * Check user permission and nonce
703
+	 * @since 2.0
704
+	 * @param string $permission
705
+	 * @return false|string The permission message or false if allowed
706
+	 */
707 707
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
708 708
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
709 709
 			$frm_settings = self::get_settings();
@@ -711,23 +711,23 @@  discard block
 block discarded – undo
711 711
 		}
712 712
 
713 713
 		$error = false;
714
-        if ( empty($nonce_name) ) {
715
-            return $error;
716
-        }
714
+		if ( empty($nonce_name) ) {
715
+			return $error;
716
+		}
717 717
 
718
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
719
-            $frm_settings = self::get_settings();
720
-            $error = $frm_settings->admin_permission;
721
-        }
718
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
719
+			$frm_settings = self::get_settings();
720
+			$error = $frm_settings->admin_permission;
721
+		}
722 722
 
723
-        return $error;
724
-    }
723
+		return $error;
724
+	}
725 725
 
726
-    public static function checked( $values, $current ) {
726
+	public static function checked( $values, $current ) {
727 727
 		if ( self::check_selected( $values, $current ) ) {
728
-            echo ' checked="checked"';
728
+			echo ' checked="checked"';
729 729
 		}
730
-    }
730
+	}
731 731
 
732 732
 	public static function check_selected( $values, $current ) {
733 733
 		$values = self::recursive_function_map( $values, 'trim' );
@@ -737,50 +737,50 @@  discard block
 block discarded – undo
737 737
 		return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current );
738 738
 	}
739 739
 
740
-    /**
741
-    * Check if current field option is an "other" option
742
-    *
743
-    * @since 2.0
744
-    *
745
-    * @param string $opt_key
746
-    * @return boolean Returns true if current field option is an "Other" option
747
-    */
748
-    public static function is_other_opt( $opt_key ) {
749
-        _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
750
-        return FrmFieldsHelper::is_other_opt( $opt_key );
751
-    }
752
-
753
-    /**
754
-    * Get value that belongs in "Other" text box
755
-    *
756
-    * @since 2.0
757
-    *
758
-    * @param string $opt_key
759
-    * @param array $field
760
-    * @return string $other_val
761
-    */
762
-    public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
740
+	/**
741
+	 * Check if current field option is an "other" option
742
+	 *
743
+	 * @since 2.0
744
+	 *
745
+	 * @param string $opt_key
746
+	 * @return boolean Returns true if current field option is an "Other" option
747
+	 */
748
+	public static function is_other_opt( $opt_key ) {
749
+		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
750
+		return FrmFieldsHelper::is_other_opt( $opt_key );
751
+	}
752
+
753
+	/**
754
+	 * Get value that belongs in "Other" text box
755
+	 *
756
+	 * @since 2.0
757
+	 *
758
+	 * @param string $opt_key
759
+	 * @param array $field
760
+	 * @return string $other_val
761
+	 */
762
+	public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
763 763
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' );
764 764
 		return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) );
765
-    }
766
-
767
-    /**
768
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
769
-    * Intended for front-end use
770
-    *
771
-    * @since 2.0
772
-    *
773
-    * @param array $field
774
-    * @param boolean $other_opt
775
-    * @param string $checked
776
-    * @param array $args should include opt_key and field name
777
-    * @return string $other_val
778
-    */
779
-    public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
765
+	}
766
+
767
+	/**
768
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
769
+	 * Intended for front-end use
770
+	 *
771
+	 * @since 2.0
772
+	 *
773
+	 * @param array $field
774
+	 * @param boolean $other_opt
775
+	 * @param string $checked
776
+	 * @param array $args should include opt_key and field name
777
+	 * @return string $other_val
778
+	 */
779
+	public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
780 780
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' );
781 781
 		$args['field'] = $field;
782 782
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
783
-    }
783
+	}
784 784
 
785 785
 	public static function recursive_function_map( $value, $function ) {
786 786
 		if ( is_array( $value ) ) {
@@ -810,24 +810,24 @@  discard block
 block discarded – undo
810 810
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
811 811
 	}
812 812
 
813
-    /**
814
-     * Flatten a multi-dimensional array
815
-     */
813
+	/**
814
+	 * Flatten a multi-dimensional array
815
+	 */
816 816
 	public static function array_flatten( $array, $keys = 'keep' ) {
817
-        $return = array();
818
-        foreach ( $array as $key => $value ) {
819
-            if ( is_array($value) ) {
817
+		$return = array();
818
+		foreach ( $array as $key => $value ) {
819
+			if ( is_array($value) ) {
820 820
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
821
-            } else {
821
+			} else {
822 822
 				if ( $keys == 'keep' ) {
823 823
 					$return[ $key ] = $value;
824 824
 				} else {
825 825
 					$return[] = $value;
826 826
 				}
827
-            }
828
-        }
829
-        return $return;
830
-    }
827
+			}
828
+		}
829
+		return $return;
830
+	}
831 831
 
832 832
 	public static function esc_textarea( $text, $is_rich_text = false ) {
833 833
 		$safe_text = str_replace( '&quot;', '"', $text );
@@ -838,38 +838,38 @@  discard block
 block discarded – undo
838 838
 		return apply_filters( 'esc_textarea', $safe_text, $text );
839 839
 	}
840 840
 
841
-    /**
842
-     * Add auto paragraphs to text areas
843
-     * @since 2.0
844
-     */
841
+	/**
842
+	 * Add auto paragraphs to text areas
843
+	 * @since 2.0
844
+	 */
845 845
 	public static function use_wpautop( $content ) {
846
-        if ( apply_filters('frm_use_wpautop', true) ) {
847
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
848
-        }
849
-        return $content;
850
-    }
846
+		if ( apply_filters('frm_use_wpautop', true) ) {
847
+			$content = wpautop(str_replace( '<br>', '<br />', $content));
848
+		}
849
+		return $content;
850
+	}
851 851
 
852 852
 	public static function replace_quotes( $val ) {
853
-        //Replace double quotes
853
+		//Replace double quotes
854 854
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
855
-        //Replace single quotes
856
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
857
-        return $val;
858
-    }
859
-
860
-    /**
861
-     * @since 2.0
862
-     * @return string The base Google APIS url for the current version of jQuery UI
863
-     */
864
-    public static function jquery_ui_base_url() {
855
+		//Replace single quotes
856
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
857
+		return $val;
858
+	}
859
+
860
+	/**
861
+	 * @since 2.0
862
+	 * @return string The base Google APIS url for the current version of jQuery UI
863
+	 */
864
+	public static function jquery_ui_base_url() {
865 865
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
866
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
867
-        return $url;
868
-    }
866
+		$url = apply_filters('frm_jquery_ui_base_url', $url);
867
+		return $url;
868
+	}
869 869
 
870
-    /**
871
-     * @param string $handle
872
-     */
870
+	/**
871
+	 * @param string $handle
872
+	 */
873 873
 	public static function script_version( $handle, $default = 0 ) {
874 874
 		global $wp_scripts;
875 875
 		if ( ! $wp_scripts ) {
@@ -891,242 +891,242 @@  discard block
 block discarded – undo
891 891
 
892 892
 	public static function js_redirect( $url ) {
893 893
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
894
-    }
894
+	}
895 895
 
896 896
 	public static function get_user_id_param( $user_id ) {
897
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
898
-            return $user_id;
899
-        }
897
+		if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
898
+			return $user_id;
899
+		}
900 900
 
901 901
 		$user_id = sanitize_text_field( $user_id );
902 902
 		if ( $user_id == 'current' ) {
903 903
 			$user_id = get_current_user_id();
904 904
 		} else {
905
-            if ( is_email($user_id) ) {
906
-                $user = get_user_by('email', $user_id);
907
-            } else {
908
-                $user = get_user_by('login', $user_id);
909
-            }
905
+			if ( is_email($user_id) ) {
906
+				$user = get_user_by('email', $user_id);
907
+			} else {
908
+				$user = get_user_by('login', $user_id);
909
+			}
910 910
 
911
-            if ( $user ) {
912
-                $user_id = $user->ID;
913
-            }
914
-            unset($user);
915
-        }
911
+			if ( $user ) {
912
+				$user_id = $user->ID;
913
+			}
914
+			unset($user);
915
+		}
916 916
 
917
-        return $user_id;
918
-    }
917
+		return $user_id;
918
+	}
919 919
 
920 920
 	public static function get_file_contents( $filename, $atts = array() ) {
921
-        if ( ! is_file($filename) ) {
922
-            return false;
923
-        }
924
-
925
-        extract($atts);
926
-        ob_start();
927
-        include($filename);
928
-        $contents = ob_get_contents();
929
-        ob_end_clean();
930
-        return $contents;
931
-    }
932
-
933
-    /**
934
-     * @param string $table_name
935
-     * @param string $column
921
+		if ( ! is_file($filename) ) {
922
+			return false;
923
+		}
924
+
925
+		extract($atts);
926
+		ob_start();
927
+		include($filename);
928
+		$contents = ob_get_contents();
929
+		ob_end_clean();
930
+		return $contents;
931
+	}
932
+
933
+	/**
934
+	 * @param string $table_name
935
+	 * @param string $column
936 936
 	 * @param int $id
937 937
 	 * @param int $num_chars
938
-     */
939
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
940
-        $key = '';
938
+	 */
939
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
940
+		$key = '';
941 941
 
942
-        if ( ! empty( $name ) ) {
943
-            $key = sanitize_key($name);
944
-        }
942
+		if ( ! empty( $name ) ) {
943
+			$key = sanitize_key($name);
944
+		}
945 945
 
946 946
 		if ( empty( $key ) ) {
947
-            $max_slug_value = pow(36, $num_chars);
948
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
949
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
950
-        }
947
+			$max_slug_value = pow(36, $num_chars);
948
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
949
+			$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
950
+		}
951 951
 
952 952
 		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
953 953
 			$key = $key . 'a';
954
-        }
954
+		}
955 955
 
956 956
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
957 957
 
958
-        if ( $key_check || is_numeric($key_check) ) {
959
-            $suffix = 2;
958
+		if ( $key_check || is_numeric($key_check) ) {
959
+			$suffix = 2;
960 960
 			do {
961 961
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
962 962
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
963 963
 				$suffix++;
964 964
 			} while ( $key_check || is_numeric( $key_check ) );
965 965
 			$key = $alt_post_name;
966
-        }
967
-        return $key;
968
-    }
969
-
970
-    /**
971
-     * Editing a Form or Entry
972
-     * @param string $table
973
-     * @return bool|array
974
-     */
975
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
976
-        if ( ! $record ) {
977
-            return false;
978
-        }
979
-
980
-        if ( empty($post_values) ) {
981
-            $post_values = stripslashes_deep($_POST);
982
-        }
966
+		}
967
+		return $key;
968
+	}
969
+
970
+	/**
971
+	 * Editing a Form or Entry
972
+	 * @param string $table
973
+	 * @return bool|array
974
+	 */
975
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
976
+		if ( ! $record ) {
977
+			return false;
978
+		}
979
+
980
+		if ( empty($post_values) ) {
981
+			$post_values = stripslashes_deep($_POST);
982
+		}
983 983
 
984 984
 		$values = array( 'id' => $record->id, 'fields' => array() );
985 985
 
986 986
 		foreach ( array( 'name', 'description' ) as $var ) {
987
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
987
+			$default_val = isset($record->{$var}) ? $record->{$var} : '';
988 988
 			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
989
-            unset($var, $default_val);
990
-        }
991
-
992
-        $values['description'] = self::use_wpautop($values['description']);
993
-        $frm_settings = self::get_settings();
994
-        $is_form_builder = self::is_admin_page('formidable' );
995
-
996
-        foreach ( (array) $fields as $field ) {
997
-            // Make sure to filter default values (for placeholder text), but not on the form builder page
998
-            if ( ! $is_form_builder ) {
999
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
1000
-            }
989
+			unset($var, $default_val);
990
+		}
991
+
992
+		$values['description'] = self::use_wpautop($values['description']);
993
+		$frm_settings = self::get_settings();
994
+		$is_form_builder = self::is_admin_page('formidable' );
995
+
996
+		foreach ( (array) $fields as $field ) {
997
+			// Make sure to filter default values (for placeholder text), but not on the form builder page
998
+			if ( ! $is_form_builder ) {
999
+				$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
1000
+			}
1001 1001
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
1002 1002
 			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
1003
-        }
1003
+		}
1004 1004
 
1005
-        self::fill_form_opts($record, $table, $post_values, $values);
1005
+		self::fill_form_opts($record, $table, $post_values, $values);
1006 1006
 
1007
-        if ( $table == 'entries' ) {
1008
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1009
-        } else if ( $table == 'forms' ) {
1010
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1011
-        }
1007
+		if ( $table == 'entries' ) {
1008
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1009
+		} else if ( $table == 'forms' ) {
1010
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1011
+		}
1012 1012
 
1013
-        return $values;
1014
-    }
1013
+		return $values;
1014
+	}
1015 1015
 
1016 1016
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
1017
-        $post_values = $args['post_values'];
1018
-
1019
-        if ( $args['default'] ) {
1020
-            $meta_value = $field->default_value;
1021
-        } else {
1022
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1023
-                if ( ! isset($field->field_options['custom_field']) ) {
1024
-                    $field->field_options['custom_field'] = '';
1025
-                }
1017
+		$post_values = $args['post_values'];
1018
+
1019
+		if ( $args['default'] ) {
1020
+			$meta_value = $field->default_value;
1021
+		} else {
1022
+			if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1023
+				if ( ! isset($field->field_options['custom_field']) ) {
1024
+					$field->field_options['custom_field'] = '';
1025
+				}
1026 1026
 				$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 ) );
1027
-            } else {
1027
+			} else {
1028 1028
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1029
-            }
1030
-        }
1029
+			}
1030
+		}
1031 1031
 
1032 1032
 		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1033
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1034
-
1035
-        $field_array = array(
1036
-            'id'            => $field->id,
1037
-            'value'         => $new_value,
1038
-            'default_value' => $field->default_value,
1039
-            'name'          => $field->name,
1040
-            'description'   => $field->description,
1041
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1042
-            'options'       => $field->options,
1043
-            'required'      => $field->required,
1044
-            'field_key'     => $field->field_key,
1045
-            'field_order'   => $field->field_order,
1046
-            'form_id'       => $field->form_id,
1033
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1034
+
1035
+		$field_array = array(
1036
+			'id'            => $field->id,
1037
+			'value'         => $new_value,
1038
+			'default_value' => $field->default_value,
1039
+			'name'          => $field->name,
1040
+			'description'   => $field->description,
1041
+			'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1042
+			'options'       => $field->options,
1043
+			'required'      => $field->required,
1044
+			'field_key'     => $field->field_key,
1045
+			'field_order'   => $field->field_order,
1046
+			'form_id'       => $field->form_id,
1047 1047
 			'parent_form_id' => $args['parent_form_id'],
1048
-        );
1048
+		);
1049 1049
 
1050
-        $args['field_type'] = $field_type;
1051
-        self::fill_field_opts($field, $field_array, $args);
1050
+		$args['field_type'] = $field_type;
1051
+		self::fill_field_opts($field, $field_array, $args);
1052 1052
 		// Track the original field's type
1053 1053
 		$field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type;
1054 1054
 
1055
-        $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1055
+		$field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1056 1056
 
1057
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1058
-            $field_array['unique_msg'] = '';
1059
-        }
1057
+		if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1058
+			$field_array['unique_msg'] = '';
1059
+		}
1060 1060
 
1061
-        $field_array = array_merge( $field->field_options, $field_array );
1061
+		$field_array = array_merge( $field->field_options, $field_array );
1062 1062
 
1063
-        $values['fields'][ $field->id ] = $field_array;
1064
-    }
1063
+		$values['fields'][ $field->id ] = $field_array;
1064
+	}
1065 1065
 
1066 1066
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1067
-        $post_values = $args['post_values'];
1068
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1067
+		$post_values = $args['post_values'];
1068
+		$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1069 1069
 
1070
-        foreach ( $opt_defaults as $opt => $default_opt ) {
1070
+		foreach ( $opt_defaults as $opt => $default_opt ) {
1071 1071
 			$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 );
1072
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1073
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1074
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1075
-                if ( $args['field_type'] == 'captcha' ) {
1076
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1077
-                } else {
1078
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1079
-                }
1080
-            }
1081
-        }
1082
-
1083
-        if ( $field_array['custom_html'] == '' ) {
1084
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1085
-        }
1086
-    }
1087
-
1088
-    /**
1089
-     * @param string $table
1090
-     */
1072
+			if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1073
+				$field_array[ $opt ] = $args['frm_settings']->blank_msg;
1074
+			} else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1075
+				if ( $args['field_type'] == 'captcha' ) {
1076
+					$field_array[ $opt ] = $args['frm_settings']->re_msg;
1077
+				} else {
1078
+					$field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1079
+				}
1080
+			}
1081
+		}
1082
+
1083
+		if ( $field_array['custom_html'] == '' ) {
1084
+			$field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1085
+		}
1086
+	}
1087
+
1088
+	/**
1089
+	 * @param string $table
1090
+	 */
1091 1091
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1092
-        if ( $table == 'entries' ) {
1093
-            $form = $record->form_id;
1092
+		if ( $table == 'entries' ) {
1093
+			$form = $record->form_id;
1094 1094
 			FrmForm::maybe_get_form( $form );
1095
-        } else {
1096
-            $form = $record;
1097
-        }
1095
+		} else {
1096
+			$form = $record;
1097
+		}
1098 1098
 
1099
-        if ( ! $form ) {
1100
-            return;
1101
-        }
1099
+		if ( ! $form ) {
1100
+			return;
1101
+		}
1102 1102
 
1103
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1103
+		$values['form_name'] = isset($record->form_id) ? $form->name : '';
1104 1104
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1105 1105
 
1106
-        if ( ! is_array($form->options) ) {
1107
-            return;
1108
-        }
1106
+		if ( ! is_array($form->options) ) {
1107
+			return;
1108
+		}
1109 1109
 
1110
-        foreach ( $form->options as $opt => $value ) {
1111
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1112
-        }
1110
+		foreach ( $form->options as $opt => $value ) {
1111
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1112
+		}
1113 1113
 
1114
-        self::fill_form_defaults($post_values, $values);
1115
-    }
1114
+		self::fill_form_defaults($post_values, $values);
1115
+	}
1116 1116
 
1117
-    /**
1118
-     * Set to POST value or default
1119
-     */
1117
+	/**
1118
+	 * Set to POST value or default
1119
+	 */
1120 1120
 	private static function fill_form_defaults( $post_values, array &$values ) {
1121
-        $form_defaults = FrmFormsHelper::get_default_opts();
1121
+		$form_defaults = FrmFormsHelper::get_default_opts();
1122 1122
 
1123
-        foreach ( $form_defaults as $opt => $default ) {
1124
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1123
+		foreach ( $form_defaults as $opt => $default ) {
1124
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1125 1125
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1126
-            }
1126
+			}
1127 1127
 
1128
-            unset($opt, $defaut);
1129
-        }
1128
+			unset($opt, $defaut);
1129
+		}
1130 1130
 
1131 1131
 		if ( ! isset( $values['custom_style'] ) ) {
1132 1132
 			$values['custom_style'] = self::custom_style_value( $post_values );
@@ -1135,10 +1135,10 @@  discard block
 block discarded – undo
1135 1135
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1136 1136
 			if ( ! isset( $values[ $h . '_html' ] ) ) {
1137 1137
 				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1138
-            }
1139
-            unset($h);
1140
-        }
1141
-    }
1138
+			}
1139
+			unset($h);
1140
+		}
1141
+	}
1142 1142
 
1143 1143
 	/**
1144 1144
 	 * @since 2.2.10
@@ -1161,59 +1161,59 @@  discard block
 block discarded – undo
1161 1161
 	}
1162 1162
 
1163 1163
 	public static function insert_opt_html( $args ) {
1164
-        $class = '';
1165
-        if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1166
-            $class .= 'show_frm_not_email_to';
1167
-        }
1168
-    ?>
1164
+		$class = '';
1165
+		if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1166
+			$class .= 'show_frm_not_email_to';
1167
+		}
1168
+	?>
1169 1169
 <li>
1170 1170
     <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>
1171 1171
     <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>
1172 1172
     <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>
1173 1173
 </li>
1174 1174
     <?php
1175
-    }
1175
+	}
1176 1176
 
1177 1177
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1178
-        if ( is_array( $str ) ) {
1179
-            return '';
1178
+		if ( is_array( $str ) ) {
1179
+			return '';
1180 1180
 		}
1181 1181
 
1182
-        $length = (int) $length;
1182
+		$length = (int) $length;
1183 1183
 		$str = wp_strip_all_tags( $str );
1184 1184
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1185 1185
 
1186 1186
 		if ( $length == 0 ) {
1187
-            return '';
1188
-        } else if ( $length <= 10 ) {
1187
+			return '';
1188
+		} else if ( $length <= 10 ) {
1189 1189
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1190
-            return $sub . (($length < $original_len) ? $continue : '');
1191
-        }
1190
+			return $sub . (($length < $original_len) ? $continue : '');
1191
+		}
1192 1192
 
1193
-        $sub = '';
1194
-        $len = 0;
1193
+		$sub = '';
1194
+		$len = 0;
1195 1195
 
1196 1196
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1197 1197
 
1198 1198
 		foreach ( $words as $word ) {
1199
-            $part = (($sub != '') ? ' ' : '') . $word;
1199
+			$part = (($sub != '') ? ' ' : '') . $word;
1200 1200
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1201
-            if ( $total_len > $length && str_word_count($sub) ) {
1202
-                break;
1203
-            }
1201
+			if ( $total_len > $length && str_word_count($sub) ) {
1202
+				break;
1203
+			}
1204 1204
 
1205
-            $sub .= $part;
1205
+			$sub .= $part;
1206 1206
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1207 1207
 
1208
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1209
-                break;
1210
-            }
1208
+			if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1209
+				break;
1210
+			}
1211 1211
 
1212
-            unset($total_len, $word);
1213
-        }
1212
+			unset($total_len, $word);
1213
+		}
1214 1214
 
1215
-        return $sub . (($len < $original_len) ? $continue : '');
1216
-    }
1215
+		return $sub . (($len < $original_len) ? $continue : '');
1216
+	}
1217 1217
 
1218 1218
 	public static function mb_function( $function_names, $args ) {
1219 1219
 		$mb_function_name = $function_names[0];
@@ -1225,18 +1225,18 @@  discard block
 block discarded – undo
1225 1225
 	}
1226 1226
 
1227 1227
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1228
-        if ( empty($date) ) {
1229
-            return $date;
1230
-        }
1228
+		if ( empty($date) ) {
1229
+			return $date;
1230
+		}
1231 1231
 
1232
-        if ( empty($date_format) ) {
1233
-            $date_format = get_option('date_format');
1234
-        }
1232
+		if ( empty($date_format) ) {
1233
+			$date_format = get_option('date_format');
1234
+		}
1235 1235
 
1236
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1237
-            $frmpro_settings = new FrmProSettings();
1238
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1239
-        }
1236
+		if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1237
+			$frmpro_settings = new FrmProSettings();
1238
+			$date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1239
+		}
1240 1240
 
1241 1241
 		$formatted = self::get_localized_date( $date_format, $date );
1242 1242
 
@@ -1245,8 +1245,8 @@  discard block
 block discarded – undo
1245 1245
 			$formatted .= self::add_time_to_date( $time_format, $date );
1246 1246
 		}
1247 1247
 
1248
-        return $formatted;
1249
-    }
1248
+		return $formatted;
1249
+	}
1250 1250
 
1251 1251
 	private static function add_time_to_date( $time_format, $date ) {
1252 1252
 		if ( empty( $time_format ) ) {
@@ -1328,120 +1328,120 @@  discard block
 block discarded – undo
1328 1328
 		);
1329 1329
 	}
1330 1330
 
1331
-    // Pagination Methods
1331
+	// Pagination Methods
1332 1332
 
1333
-    /**
1334
-     * @param integer $current_p
1335
-     */
1333
+	/**
1334
+	 * @param integer $current_p
1335
+	 */
1336 1336
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1337 1337
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1338 1338
 	}
1339 1339
 
1340
-    /**
1341
-     * @param integer $current_p
1342
-     */
1343
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1344
-        if ( $current_p == 1 ) {
1345
-            return 1;
1346
-        } else {
1347
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1348
-        }
1349
-    }
1340
+	/**
1341
+	 * @param integer $current_p
1342
+	 */
1343
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1344
+		if ( $current_p == 1 ) {
1345
+			return 1;
1346
+		} else {
1347
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1348
+		}
1349
+	}
1350 1350
 
1351 1351
 	/**
1352 1352
 	 * @return array
1353 1353
 	 */
1354 1354
 	public static function json_to_array( $json_vars ) {
1355
-        $vars = array();
1356
-        foreach ( $json_vars as $jv ) {
1357
-            $jv_name = explode('[', $jv['name']);
1358
-            $last = count($jv_name) - 1;
1359
-            foreach ( $jv_name as $p => $n ) {
1360
-                $name = trim($n, ']');
1361
-                if ( ! isset($l1) ) {
1362
-                    $l1 = $name;
1363
-                }
1364
-
1365
-                if ( ! isset($l2) ) {
1366
-                    $l2 = $name;
1367
-                }
1368
-
1369
-                if ( ! isset($l3) ) {
1370
-                    $l3 = $name;
1371
-                }
1372
-
1373
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1374
-
1375
-                switch ( $p ) {
1376
-                    case 0:
1377
-                        $l1 = $name;
1378
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1379
-                    break;
1380
-
1381
-                    case 1:
1382
-                        $l2 = $name;
1383
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1384
-                    break;
1385
-
1386
-                    case 2:
1387
-                        $l3 = $name;
1388
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1389
-                    break;
1390
-
1391
-                    case 3:
1392
-                        $l4 = $name;
1393
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1394
-                    break;
1395
-                }
1396
-
1397
-                unset($this_val, $n);
1398
-            }
1399
-
1400
-            unset($last, $jv);
1401
-        }
1402
-
1403
-        return $vars;
1404
-    }
1405
-
1406
-    /**
1407
-     * @param string $name
1408
-     * @param string $l1
1409
-     */
1410
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1411
-        if ( $name == '' ) {
1412
-            $vars[] = $val;
1413
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1414
-            $vars[ $l1 ] = $val;
1415
-        }
1416
-    }
1355
+		$vars = array();
1356
+		foreach ( $json_vars as $jv ) {
1357
+			$jv_name = explode('[', $jv['name']);
1358
+			$last = count($jv_name) - 1;
1359
+			foreach ( $jv_name as $p => $n ) {
1360
+				$name = trim($n, ']');
1361
+				if ( ! isset($l1) ) {
1362
+					$l1 = $name;
1363
+				}
1364
+
1365
+				if ( ! isset($l2) ) {
1366
+					$l2 = $name;
1367
+				}
1368
+
1369
+				if ( ! isset($l3) ) {
1370
+					$l3 = $name;
1371
+				}
1372
+
1373
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1374
+
1375
+				switch ( $p ) {
1376
+					case 0:
1377
+						$l1 = $name;
1378
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1379
+					break;
1380
+
1381
+					case 1:
1382
+						$l2 = $name;
1383
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1384
+					break;
1385
+
1386
+					case 2:
1387
+						$l3 = $name;
1388
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1389
+					break;
1390
+
1391
+					case 3:
1392
+						$l4 = $name;
1393
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1394
+					break;
1395
+				}
1396
+
1397
+				unset($this_val, $n);
1398
+			}
1399
+
1400
+			unset($last, $jv);
1401
+		}
1402
+
1403
+		return $vars;
1404
+	}
1405
+
1406
+	/**
1407
+	 * @param string $name
1408
+	 * @param string $l1
1409
+	 */
1410
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1411
+		if ( $name == '' ) {
1412
+			$vars[] = $val;
1413
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1414
+			$vars[ $l1 ] = $val;
1415
+		}
1416
+	}
1417 1417
 
1418 1418
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1419
-        $tooltips = array(
1420
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1421
-            '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' ),
1422
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1423
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1424
-            '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' ),
1425
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1426
-            '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() ) ),
1427
-        );
1428
-
1429
-        if ( ! isset( $tooltips[ $name ] ) ) {
1430
-            return;
1431
-        }
1432
-
1433
-        if ( 'open' == $class ) {
1434
-            echo ' frm_help"';
1435
-        } else {
1436
-            echo ' class="frm_help"';
1437
-        }
1419
+		$tooltips = array(
1420
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1421
+			'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' ),
1422
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1423
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1424
+			'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' ),
1425
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1426
+			'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() ) ),
1427
+		);
1428
+
1429
+		if ( ! isset( $tooltips[ $name ] ) ) {
1430
+			return;
1431
+		}
1432
+
1433
+		if ( 'open' == $class ) {
1434
+			echo ' frm_help"';
1435
+		} else {
1436
+			echo ' class="frm_help"';
1437
+		}
1438 1438
 
1439 1439
 		echo ' title="' . esc_attr( $tooltips[ $name ] );
1440 1440
 
1441
-        if ( 'open' != $class ) {
1442
-            echo '"';
1443
-        }
1444
-    }
1441
+		if ( 'open' != $class ) {
1442
+			echo '"';
1443
+		}
1444
+	}
1445 1445
 
1446 1446
 	/**
1447 1447
 	 * Add the current_page class to that page in the form nav
@@ -1457,35 +1457,35 @@  discard block
 block discarded – undo
1457 1457
 		}
1458 1458
 	}
1459 1459
 
1460
-    /**
1461
-     * Prepare and json_encode post content
1462
-     *
1463
-     * @since 2.0
1464
-     *
1465
-     * @param array $post_content
1466
-     * @return string $post_content ( json encoded array )
1467
-     */
1468
-    public static function prepare_and_encode( $post_content ) {
1469
-        //Loop through array to strip slashes and add only the needed ones
1460
+	/**
1461
+	 * Prepare and json_encode post content
1462
+	 *
1463
+	 * @since 2.0
1464
+	 *
1465
+	 * @param array $post_content
1466
+	 * @return string $post_content ( json encoded array )
1467
+	 */
1468
+	public static function prepare_and_encode( $post_content ) {
1469
+		//Loop through array to strip slashes and add only the needed ones
1470 1470
 		foreach ( $post_content as $key => $val ) {
1471 1471
 			// Replace problematic characters (like &quot;)
1472 1472
 			$val = str_replace( '&quot;', '"', $val );
1473 1473
 
1474 1474
 			self::prepare_action_slashes( $val, $key, $post_content );
1475
-            unset( $key, $val );
1476
-        }
1475
+			unset( $key, $val );
1476
+		}
1477 1477
 
1478
-        // json_encode the array
1479
-        $post_content = json_encode( $post_content );
1478
+		// json_encode the array
1479
+		$post_content = json_encode( $post_content );
1480 1480
 
1481
-	    // add extra slashes for \r\n since WP strips them
1481
+		// add extra slashes for \r\n since WP strips them
1482 1482
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1483 1483
 
1484
-        // allow for &quot
1485
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1484
+		// allow for &quot
1485
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1486 1486
 
1487
-        return $post_content;
1488
-    }
1487
+		return $post_content;
1488
+	}
1489 1489
 
1490 1490
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1491 1491
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1507,64 +1507,64 @@  discard block
 block discarded – undo
1507 1507
 	}
1508 1508
 
1509 1509
 	public static function maybe_json_decode( $string ) {
1510
-        if ( is_array($string) ) {
1511
-            return $string;
1512
-        }
1510
+		if ( is_array($string) ) {
1511
+			return $string;
1512
+		}
1513 1513
 
1514
-        $new_string = json_decode($string, true);
1515
-        if ( function_exists('json_last_error') ) {
1514
+		$new_string = json_decode($string, true);
1515
+		if ( function_exists('json_last_error') ) {
1516 1516
 			// php 5.3+
1517
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1518
-                $string = $new_string;
1519
-            }
1520
-        } else if ( isset($new_string) ) {
1517
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1518
+				$string = $new_string;
1519
+			}
1520
+		} else if ( isset($new_string) ) {
1521 1521
 			// php < 5.3 fallback
1522
-            $string = $new_string;
1523
-        }
1524
-        return $string;
1525
-    }
1526
-
1527
-    /**
1528
-     * @since 1.07.10
1529
-     *
1530
-     * @param string $post_type The name of the post type that may need to be highlighted
1531
-     * echo The javascript to open and highlight the Formidable menu
1532
-     */
1522
+			$string = $new_string;
1523
+		}
1524
+		return $string;
1525
+	}
1526
+
1527
+	/**
1528
+	 * @since 1.07.10
1529
+	 *
1530
+	 * @param string $post_type The name of the post type that may need to be highlighted
1531
+	 * echo The javascript to open and highlight the Formidable menu
1532
+	 */
1533 1533
 	public static function maybe_highlight_menu( $post_type ) {
1534
-        global $post;
1534
+		global $post;
1535 1535
 
1536
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1537
-            return;
1538
-        }
1536
+		if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1537
+			return;
1538
+		}
1539 1539
 
1540
-        if ( is_object($post) && $post->post_type != $post_type ) {
1541
-            return;
1542
-        }
1540
+		if ( is_object($post) && $post->post_type != $post_type ) {
1541
+			return;
1542
+		}
1543 1543
 
1544
-        self::load_admin_wide_js();
1545
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1546
-    }
1544
+		self::load_admin_wide_js();
1545
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1546
+	}
1547 1547
 
1548
-    /**
1549
-     * Load the JS file on non-Formidable pages in the admin area
1550
-     * @since 2.0
1551
-     */
1548
+	/**
1549
+	 * Load the JS file on non-Formidable pages in the admin area
1550
+	 * @since 2.0
1551
+	 */
1552 1552
 	public static function load_admin_wide_js( $load = true ) {
1553
-        $version = FrmAppHelper::plugin_version();
1553
+		$version = FrmAppHelper::plugin_version();
1554 1554
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1555 1555
 
1556
-        wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1556
+		wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1557 1557
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1558
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1558
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1559 1559
 			'url'          => FrmAppHelper::plugin_url(),
1560 1560
 			'loading'      => __( 'Loading&hellip;' ),
1561 1561
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
1562
-        ) );
1562
+		) );
1563 1563
 
1564 1564
 		if ( $load ) {
1565 1565
 			wp_enqueue_script( 'formidable_admin_global' );
1566 1566
 		}
1567
-    }
1567
+	}
1568 1568
 
1569 1569
 	/**
1570 1570
 	 * @since 2.0.9
@@ -1573,9 +1573,9 @@  discard block
 block discarded – undo
1573 1573
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1574 1574
 	}
1575 1575
 
1576
-    /**
1577
-     * @param string $location
1578
-     */
1576
+	/**
1577
+	 * @param string $location
1578
+	 */
1579 1579
 	public static function localize_script( $location ) {
1580 1580
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1581 1581
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1631,83 +1631,83 @@  discard block
 block discarded – undo
1631 1631
 		}
1632 1632
 	}
1633 1633
 
1634
-    /**
1634
+	/**
1635 1635
 	 * echo the message on the plugins listing page
1636
-     * @since 1.07.10
1637
-     *
1638
-     * @param float $min_version The version the add-on requires
1639
-     */
1636
+	 * @since 1.07.10
1637
+	 *
1638
+	 * @param float $min_version The version the add-on requires
1639
+	 */
1640 1640
 	public static function min_version_notice( $min_version ) {
1641
-        $frm_version = self::plugin_version();
1641
+		$frm_version = self::plugin_version();
1642 1642
 
1643
-        // check if Formidable meets minimum requirements
1644
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1645
-            return;
1646
-        }
1643
+		// check if Formidable meets minimum requirements
1644
+		if ( version_compare($frm_version, $min_version, '>=') ) {
1645
+			return;
1646
+		}
1647 1647
 
1648
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1648
+		$wp_list_table = _get_list_table('WP_Plugins_List_Table');
1649 1649
 		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">' .
1650
-        __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1651
-        '</div></td></tr>';
1652
-    }
1653
-
1654
-    public static function locales( $type = 'date' ) {
1655
-        $locales = array(
1656
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1657
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1658
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1659
-            'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1660
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1661
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1662
-            'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1663
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1664
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1665
-            'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1666
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1667
-            'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1668
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1669
-            'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1670
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1671
-            'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1672
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1673
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1674
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1675
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1676
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1677
-            'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1678
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1679
-            'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1680
-            'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1681
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1682
-            'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1683
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1684
-            'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1685
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1686
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1687
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1688
-        );
1689
-
1690
-        if ( $type == 'captcha' ) {
1691
-            // remove the languages unavailable for the captcha
1692
-            $unset = array(
1693
-                '', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1694
-                'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1695
-                'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1696
-            );
1697
-        } else {
1698
-            // remove the languages unavailable for the datepicker
1699
-            $unset = array(
1700
-                'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1701
-                'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1702
-                'es-419', 'tr',
1703
-            );
1704
-        }
1705
-
1706
-        $locales = array_diff_key($locales, array_flip($unset));
1707
-        $locales = apply_filters('frm_locales', $locales);
1708
-
1709
-        return $locales;
1710
-    }
1650
+		__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1651
+		'</div></td></tr>';
1652
+	}
1653
+
1654
+	public static function locales( $type = 'date' ) {
1655
+		$locales = array(
1656
+			'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1657
+			'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1658
+			'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1659
+			'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1660
+			'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1661
+			'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1662
+			'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1663
+			'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1664
+			'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1665
+			'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1666
+			'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1667
+			'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1668
+			'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1669
+			'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1670
+			'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1671
+			'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1672
+			'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1673
+			'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1674
+			'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1675
+			'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1676
+			'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1677
+			'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1678
+			'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1679
+			'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1680
+			'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1681
+			'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1682
+			'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1683
+			'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1684
+			'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1685
+			'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1686
+			'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1687
+			'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1688
+		);
1689
+
1690
+		if ( $type == 'captcha' ) {
1691
+			// remove the languages unavailable for the captcha
1692
+			$unset = array(
1693
+				'', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1694
+				'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1695
+				'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1696
+			);
1697
+		} else {
1698
+			// remove the languages unavailable for the datepicker
1699
+			$unset = array(
1700
+				'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1701
+				'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1702
+				'es-419', 'tr',
1703
+			);
1704
+		}
1705
+
1706
+		$locales = array_diff_key($locales, array_flip($unset));
1707
+		$locales = apply_filters('frm_locales', $locales);
1708
+
1709
+		return $locales;
1710
+	}
1711 1711
 
1712 1712
 	/**
1713 1713
 	 * Prepare and save settings in styles and actions
Please login to merge, or discard this patch.