Completed
Push — master ( e539f4...ac7d8e )
by Stephanie
12:54
created
classes/helpers/FrmAppHelper.php 1 patch
Indentation   +794 added lines, -794 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.09';
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,81 +177,81 @@  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 227
 		foreach ( array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) {
228
-            if ( ! isset( $_SERVER[ $key ] ) ) {
229
-                continue;
230
-            }
228
+			if ( ! isset( $_SERVER[ $key ] ) ) {
229
+				continue;
230
+			}
231 231
 
232
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
233
-                $ip = trim($ip); // just to be safe
232
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
233
+				$ip = trim($ip); // just to be safe
234 234
 
235
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
236
-                    return sanitize_text_field( $ip );
237
-                }
238
-            }
239
-        }
235
+				if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
236
+					return sanitize_text_field( $ip );
237
+				}
238
+			}
239
+		}
240 240
 
241 241
 		return sanitize_text_field( $ip );
242
-    }
242
+	}
243 243
 
244
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
245
-        if ( strpos($param, '[') ) {
246
-            $params = explode('[', $param);
247
-            $param = $params[0];
248
-        }
244
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
245
+		if ( strpos($param, '[') ) {
246
+			$params = explode('[', $param);
247
+			$param = $params[0];
248
+		}
249 249
 
250 250
 		if ( $src == 'get' ) {
251
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
252
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
253
-                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
254
-            }
251
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
252
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
253
+				$value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
254
+			}
255 255
 			self::sanitize_value( $sanitize, $value );
256 256
 		} else {
257 257
 			$value = self::get_simple_request( array(
@@ -263,18 +263,18 @@  discard block
 block discarded – undo
263 263
 		}
264 264
 
265 265
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
266
-            foreach ( $params as $k => $p ) {
267
-                if ( ! $k || ! is_array($value) ) {
268
-                    continue;
269
-                }
266
+			foreach ( $params as $k => $p ) {
267
+				if ( ! $k || ! is_array($value) ) {
268
+					continue;
269
+				}
270 270
 
271
-                $p = trim($p, ']');
272
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
273
-            }
274
-        }
271
+				$p = trim($p, ']');
272
+				$value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
273
+			}
274
+		}
275 275
 
276
-        return $value;
277
-    }
276
+		return $value;
277
+	}
278 278
 
279 279
 	public static function get_post_param( $param, $default = '', $sanitize = '' ) {
280 280
 		return self::get_simple_request( array(
@@ -338,12 +338,12 @@  discard block
 block discarded – undo
338 338
 	}
339 339
 
340 340
 	/**
341
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
342
-	*
343
-	* @since 2.0.8
344
-	* @param string $value
345
-	* @return string $value
346
-	*/
341
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
342
+	 *
343
+	 * @since 2.0.8
344
+	 * @param string $value
345
+	 * @return string $value
346
+	 */
347 347
 	public static function preserve_backslashes( $value ) {
348 348
 		// If backslashes have already been added, don't add them again
349 349
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -365,14 +365,14 @@  discard block
 block discarded – undo
365 365
 		}
366 366
 	}
367 367
 
368
-    public static function sanitize_request( $sanitize_method, &$values ) {
369
-        $temp_values = $values;
370
-        foreach ( $temp_values as $k => $val ) {
371
-            if ( isset( $sanitize_method[ $k ] ) ) {
368
+	public static function sanitize_request( $sanitize_method, &$values ) {
369
+		$temp_values = $values;
370
+		foreach ( $temp_values as $k => $val ) {
371
+			if ( isset( $sanitize_method[ $k ] ) ) {
372 372
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
373
-            }
374
-        }
375
-    }
373
+			}
374
+		}
375
+	}
376 376
 
377 377
 	public static function sanitize_array( &$values ) {
378 378
 		$temp_values = $values;
@@ -496,71 +496,71 @@  discard block
 block discarded – undo
496 496
 		);
497 497
 	}
498 498
 
499
-    /**
500
-     * Used when switching the action for a bulk action
501
-     * @since 2.0
502
-     */
503
-    public static function remove_get_action() {
504
-        if ( ! isset($_GET) ) {
505
-            return;
506
-        }
499
+	/**
500
+	 * Used when switching the action for a bulk action
501
+	 * @since 2.0
502
+	 */
503
+	public static function remove_get_action() {
504
+		if ( ! isset($_GET) ) {
505
+			return;
506
+		}
507 507
 
508
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
509
-        if ( ! empty( $new_action ) ) {
508
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
509
+		if ( ! empty( $new_action ) ) {
510 510
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
511
-        }
512
-    }
513
-
514
-    /**
515
-     * Check the WP query for a parameter
516
-     *
517
-     * @since 2.0
518
-     * @return string|array
519
-     */
520
-    public static function get_query_var( $value, $param ) {
521
-        if ( $value != '' ) {
522
-            return $value;
523
-        }
524
-
525
-        global $wp_query;
526
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
527
-            $value = $wp_query->query_vars[ $param ];
528
-        }
529
-
530
-        return $value;
531
-    }
532
-
533
-    /**
534
-     * @param string $type
535
-     */
536
-    public static function trigger_hook_load( $type, $object = null ) {
537
-        // only load the form hooks once
511
+		}
512
+	}
513
+
514
+	/**
515
+	 * Check the WP query for a parameter
516
+	 *
517
+	 * @since 2.0
518
+	 * @return string|array
519
+	 */
520
+	public static function get_query_var( $value, $param ) {
521
+		if ( $value != '' ) {
522
+			return $value;
523
+		}
524
+
525
+		global $wp_query;
526
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
527
+			$value = $wp_query->query_vars[ $param ];
528
+		}
529
+
530
+		return $value;
531
+	}
532
+
533
+	/**
534
+	 * @param string $type
535
+	 */
536
+	public static function trigger_hook_load( $type, $object = null ) {
537
+		// only load the form hooks once
538 538
 		$hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
539
-        if ( ! $hooks_loaded ) {
539
+		if ( ! $hooks_loaded ) {
540 540
 			do_action( 'frm_load_' . $type . '_hooks' );
541
-        }
542
-    }
543
-
544
-    /**
545
-     * Check a value from a shortcode to see if true or false.
546
-     * True when value is 1, true, 'true', 'yes'
547
-     *
548
-     * @since 1.07.10
549
-     *
550
-     * @param string $value The value to compare
551
-     * @return boolean True or False
552
-     */
541
+		}
542
+	}
543
+
544
+	/**
545
+	 * Check a value from a shortcode to see if true or false.
546
+	 * True when value is 1, true, 'true', 'yes'
547
+	 *
548
+	 * @since 1.07.10
549
+	 *
550
+	 * @param string $value The value to compare
551
+	 * @return boolean True or False
552
+	 */
553 553
 	public static function is_true( $value ) {
554
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
555
-    }
554
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
555
+	}
556 556
 
557
-    /**
558
-     * Used to filter shortcode in text widgets
559
-     */
560
-    public static function widget_text_filter_callback( $matches ) {
557
+	/**
558
+	 * Used to filter shortcode in text widgets
559
+	 */
560
+	public static function widget_text_filter_callback( $matches ) {
561 561
 		_deprecated_function( __METHOD__, '2.5.4' );
562
-        return do_shortcode( $matches[0] );
563
-    }
562
+		return do_shortcode( $matches[0] );
563
+	}
564 564
 
565 565
 	public static function get_pages() {
566 566
 		return get_posts( array(
@@ -572,10 +572,10 @@  discard block
 block discarded – undo
572 572
 		) );
573 573
 	}
574 574
 
575
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
576
-        $pages = self::get_pages();
575
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
576
+		$pages = self::get_pages();
577 577
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
578
-    ?>
578
+	?>
579 579
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
580 580
             <option value=""> </option>
581 581
             <?php foreach ( $pages as $page ) { ?>
@@ -585,16 +585,16 @@  discard block
 block discarded – undo
585 585
             <?php } ?>
586 586
         </select>
587 587
     <?php
588
-    }
588
+	}
589 589
 
590 590
 	public static function post_edit_link( $post_id ) {
591
-        $post = get_post($post_id);
592
-        if ( $post ) {
591
+		$post = get_post($post_id);
592
+		if ( $post ) {
593 593
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
594 594
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
595
-        }
596
-        return '';
597
-    }
595
+		}
596
+		return '';
597
+	}
598 598
 
599 599
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
600 600
 		?>
@@ -605,87 +605,87 @@  discard block
 block discarded – undo
605 605
 	}
606 606
 
607 607
 	public static function roles_options( $capability ) {
608
-        global $frm_vars;
609
-        if ( isset($frm_vars['editable_roles']) ) {
610
-            $editable_roles = $frm_vars['editable_roles'];
611
-        } else {
612
-            $editable_roles = get_editable_roles();
613
-            $frm_vars['editable_roles'] = $editable_roles;
614
-        }
615
-
616
-        foreach ( $editable_roles as $role => $details ) {
608
+		global $frm_vars;
609
+		if ( isset($frm_vars['editable_roles']) ) {
610
+			$editable_roles = $frm_vars['editable_roles'];
611
+		} else {
612
+			$editable_roles = get_editable_roles();
613
+			$frm_vars['editable_roles'] = $editable_roles;
614
+		}
615
+
616
+		foreach ( $editable_roles as $role => $details ) {
617 617
 			$name = translate_user_role( $details['name'] );
618 618
 			?>
619 619
         <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
620 620
 <?php
621
-            unset($role, $details);
622
-        }
623
-    }
621
+			unset($role, $details);
622
+		}
623
+	}
624 624
 
625 625
 	public static function frm_capabilities( $type = 'auto' ) {
626
-        $cap = array(
627
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
628
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
629
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
630
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
631
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
632
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
633
-        );
626
+		$cap = array(
627
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
628
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
629
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
630
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
631
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
632
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
633
+		);
634 634
 
635 635
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
636
-            return $cap;
637
-        }
636
+			return $cap;
637
+		}
638 638
 
639
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
640
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
641
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
642
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
639
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
640
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
641
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
642
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
643 643
 
644
-        return $cap;
645
-    }
644
+		return $cap;
645
+	}
646 646
 
647 647
 	public static function user_has_permission( $needed_role ) {
648
-        if ( $needed_role == '-1' ) {
649
-            return false;
648
+		if ( $needed_role == '-1' ) {
649
+			return false;
650 650
 		}
651 651
 
652
-        // $needed_role will be equal to blank if "Logged-in users" is selected
653
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
654
-            return true;
655
-        }
652
+		// $needed_role will be equal to blank if "Logged-in users" is selected
653
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
654
+			return true;
655
+		}
656 656
 
657
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
658
-        foreach ( $roles as $role ) {
657
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
658
+		foreach ( $roles as $role ) {
659 659
 			if ( current_user_can( $role ) ) {
660
-        		return true;
660
+				return true;
661 661
 			}
662
-        	if ( $role == $needed_role ) {
663
-        		break;
662
+			if ( $role == $needed_role ) {
663
+				break;
664 664
 			}
665
-        }
666
-        return false;
667
-    }
668
-
669
-    /**
670
-     * Make sure administrators can see Formidable menu
671
-     *
672
-     * @since 2.0
673
-     */
674
-    public static function maybe_add_permissions() {
665
+		}
666
+		return false;
667
+	}
668
+
669
+	/**
670
+	 * Make sure administrators can see Formidable menu
671
+	 *
672
+	 * @since 2.0
673
+	 */
674
+	public static function maybe_add_permissions() {
675 675
 		self::force_capability( 'frm_view_entries' );
676 676
 
677
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
678
-            return;
679
-        }
677
+		if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
678
+			return;
679
+		}
680 680
 
681 681
 		$user_id = get_current_user_id();
682 682
 		$user = new WP_User( $user_id );
683
-        $frm_roles = self::frm_capabilities();
684
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
683
+		$frm_roles = self::frm_capabilities();
684
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
685 685
 			$user->add_cap( $frm_role );
686
-            unset($frm_role, $frm_role_description);
687
-        }
688
-    }
686
+			unset($frm_role, $frm_role_description);
687
+		}
688
+	}
689 689
 
690 690
 	/**
691 691
 	 * Make sure admins have permission to see the menu items
@@ -701,28 +701,28 @@  discard block
 block discarded – undo
701 701
 		}
702 702
 	}
703 703
 
704
-    /**
705
-     * Check if the user has permision for action.
706
-     * Return permission message and stop the action if no permission
707
-     * @since 2.0
708
-     * @param string $permission
709
-     */
704
+	/**
705
+	 * Check if the user has permision for action.
706
+	 * Return permission message and stop the action if no permission
707
+	 * @since 2.0
708
+	 * @param string $permission
709
+	 */
710 710
 	public static function permission_check( $permission, $show_message = 'show' ) {
711
-        $permission_error = self::permission_nonce_error($permission);
712
-        if ( $permission_error !== false ) {
713
-            if ( 'hide' == $show_message ) {
714
-                $permission_error = '';
715
-            }
716
-            wp_die($permission_error);
717
-        }
718
-    }
719
-
720
-    /**
721
-     * Check user permission and nonce
722
-     * @since 2.0
723
-     * @param string $permission
724
-     * @return false|string The permission message or false if allowed
725
-     */
711
+		$permission_error = self::permission_nonce_error($permission);
712
+		if ( $permission_error !== false ) {
713
+			if ( 'hide' == $show_message ) {
714
+				$permission_error = '';
715
+			}
716
+			wp_die($permission_error);
717
+		}
718
+	}
719
+
720
+	/**
721
+	 * Check user permission and nonce
722
+	 * @since 2.0
723
+	 * @param string $permission
724
+	 * @return false|string The permission message or false if allowed
725
+	 */
726 726
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
727 727
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
728 728
 			$frm_settings = self::get_settings();
@@ -730,23 +730,23 @@  discard block
 block discarded – undo
730 730
 		}
731 731
 
732 732
 		$error = false;
733
-        if ( empty($nonce_name) ) {
734
-            return $error;
735
-        }
733
+		if ( empty($nonce_name) ) {
734
+			return $error;
735
+		}
736 736
 
737
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
738
-            $frm_settings = self::get_settings();
739
-            $error = $frm_settings->admin_permission;
740
-        }
737
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
738
+			$frm_settings = self::get_settings();
739
+			$error = $frm_settings->admin_permission;
740
+		}
741 741
 
742
-        return $error;
743
-    }
742
+		return $error;
743
+	}
744 744
 
745
-    public static function checked( $values, $current ) {
745
+	public static function checked( $values, $current ) {
746 746
 		if ( self::check_selected( $values, $current ) ) {
747
-            echo ' checked="checked"';
747
+			echo ' checked="checked"';
748 748
 		}
749
-    }
749
+	}
750 750
 
751 751
 	public static function check_selected( $values, $current ) {
752 752
 		$values = self::recursive_function_map( $values, 'trim' );
@@ -756,50 +756,50 @@  discard block
 block discarded – undo
756 756
 		return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current );
757 757
 	}
758 758
 
759
-    /**
760
-    * Check if current field option is an "other" option
761
-    *
762
-    * @since 2.0
763
-    *
764
-    * @param string $opt_key
765
-    * @return boolean Returns true if current field option is an "Other" option
766
-    */
767
-    public static function is_other_opt( $opt_key ) {
768
-        _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
769
-        return FrmFieldsHelper::is_other_opt( $opt_key );
770
-    }
771
-
772
-    /**
773
-    * Get value that belongs in "Other" text box
774
-    *
775
-    * @since 2.0
776
-    *
777
-    * @param string $opt_key
778
-    * @param array $field
779
-    * @return string $other_val
780
-    */
781
-    public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
759
+	/**
760
+	 * Check if current field option is an "other" option
761
+	 *
762
+	 * @since 2.0
763
+	 *
764
+	 * @param string $opt_key
765
+	 * @return boolean Returns true if current field option is an "Other" option
766
+	 */
767
+	public static function is_other_opt( $opt_key ) {
768
+		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
769
+		return FrmFieldsHelper::is_other_opt( $opt_key );
770
+	}
771
+
772
+	/**
773
+	 * Get value that belongs in "Other" text box
774
+	 *
775
+	 * @since 2.0
776
+	 *
777
+	 * @param string $opt_key
778
+	 * @param array $field
779
+	 * @return string $other_val
780
+	 */
781
+	public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
782 782
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' );
783 783
 		return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) );
784
-    }
785
-
786
-    /**
787
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
788
-    * Intended for front-end use
789
-    *
790
-    * @since 2.0
791
-    *
792
-    * @param array $field
793
-    * @param boolean $other_opt
794
-    * @param string $checked
795
-    * @param array $args should include opt_key and field name
796
-    * @return string $other_val
797
-    */
798
-    public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
784
+	}
785
+
786
+	/**
787
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
788
+	 * Intended for front-end use
789
+	 *
790
+	 * @since 2.0
791
+	 *
792
+	 * @param array $field
793
+	 * @param boolean $other_opt
794
+	 * @param string $checked
795
+	 * @param array $args should include opt_key and field name
796
+	 * @return string $other_val
797
+	 */
798
+	public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
799 799
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' );
800 800
 		$args['field'] = $field;
801 801
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
802
-    }
802
+	}
803 803
 
804 804
 	public static function recursive_function_map( $value, $function ) {
805 805
 		if ( is_array( $value ) ) {
@@ -829,24 +829,24 @@  discard block
 block discarded – undo
829 829
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
830 830
 	}
831 831
 
832
-    /**
833
-     * Flatten a multi-dimensional array
834
-     */
832
+	/**
833
+	 * Flatten a multi-dimensional array
834
+	 */
835 835
 	public static function array_flatten( $array, $keys = 'keep' ) {
836
-        $return = array();
837
-        foreach ( $array as $key => $value ) {
838
-            if ( is_array($value) ) {
836
+		$return = array();
837
+		foreach ( $array as $key => $value ) {
838
+			if ( is_array($value) ) {
839 839
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
840
-            } else {
840
+			} else {
841 841
 				if ( $keys == 'keep' ) {
842 842
 					$return[ $key ] = $value;
843 843
 				} else {
844 844
 					$return[] = $value;
845 845
 				}
846
-            }
847
-        }
848
-        return $return;
849
-    }
846
+			}
847
+		}
848
+		return $return;
849
+	}
850 850
 
851 851
 	public static function esc_textarea( $text, $is_rich_text = false ) {
852 852
 		$safe_text = str_replace( '&quot;', '"', $text );
@@ -857,38 +857,38 @@  discard block
 block discarded – undo
857 857
 		return apply_filters( 'esc_textarea', $safe_text, $text );
858 858
 	}
859 859
 
860
-    /**
861
-     * Add auto paragraphs to text areas
862
-     * @since 2.0
863
-     */
860
+	/**
861
+	 * Add auto paragraphs to text areas
862
+	 * @since 2.0
863
+	 */
864 864
 	public static function use_wpautop( $content ) {
865
-        if ( apply_filters('frm_use_wpautop', true) ) {
866
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
867
-        }
868
-        return $content;
869
-    }
865
+		if ( apply_filters('frm_use_wpautop', true) ) {
866
+			$content = wpautop(str_replace( '<br>', '<br />', $content));
867
+		}
868
+		return $content;
869
+	}
870 870
 
871 871
 	public static function replace_quotes( $val ) {
872
-        //Replace double quotes
872
+		//Replace double quotes
873 873
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
874
-        //Replace single quotes
875
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
876
-        return $val;
877
-    }
878
-
879
-    /**
880
-     * @since 2.0
881
-     * @return string The base Google APIS url for the current version of jQuery UI
882
-     */
883
-    public static function jquery_ui_base_url() {
874
+		//Replace single quotes
875
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
876
+		return $val;
877
+	}
878
+
879
+	/**
880
+	 * @since 2.0
881
+	 * @return string The base Google APIS url for the current version of jQuery UI
882
+	 */
883
+	public static function jquery_ui_base_url() {
884 884
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
885
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
886
-        return $url;
887
-    }
885
+		$url = apply_filters('frm_jquery_ui_base_url', $url);
886
+		return $url;
887
+	}
888 888
 
889
-    /**
890
-     * @param string $handle
891
-     */
889
+	/**
890
+	 * @param string $handle
891
+	 */
892 892
 	public static function script_version( $handle, $default = 0 ) {
893 893
 		global $wp_scripts;
894 894
 		if ( ! $wp_scripts ) {
@@ -910,75 +910,75 @@  discard block
 block discarded – undo
910 910
 
911 911
 	public static function js_redirect( $url ) {
912 912
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
913
-    }
913
+	}
914 914
 
915 915
 	public static function get_user_id_param( $user_id ) {
916
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
917
-            return $user_id;
918
-        }
916
+		if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
917
+			return $user_id;
918
+		}
919 919
 
920 920
 		$user_id = sanitize_text_field( $user_id );
921 921
 		if ( $user_id == 'current' ) {
922 922
 			$user_id = get_current_user_id();
923 923
 		} else {
924
-            if ( is_email($user_id) ) {
925
-                $user = get_user_by('email', $user_id);
926
-            } else {
927
-                $user = get_user_by('login', $user_id);
928
-            }
924
+			if ( is_email($user_id) ) {
925
+				$user = get_user_by('email', $user_id);
926
+			} else {
927
+				$user = get_user_by('login', $user_id);
928
+			}
929 929
 
930
-            if ( $user ) {
931
-                $user_id = $user->ID;
932
-            }
933
-            unset($user);
934
-        }
930
+			if ( $user ) {
931
+				$user_id = $user->ID;
932
+			}
933
+			unset($user);
934
+		}
935 935
 
936
-        return $user_id;
937
-    }
936
+		return $user_id;
937
+	}
938 938
 
939 939
 	public static function get_file_contents( $filename, $atts = array() ) {
940
-        if ( ! is_file($filename) ) {
941
-            return false;
942
-        }
943
-
944
-        extract($atts);
945
-        ob_start();
946
-        include($filename);
947
-        $contents = ob_get_contents();
948
-        ob_end_clean();
949
-        return $contents;
950
-    }
951
-
952
-    /**
953
-     * @param string $table_name
954
-     * @param string $column
940
+		if ( ! is_file($filename) ) {
941
+			return false;
942
+		}
943
+
944
+		extract($atts);
945
+		ob_start();
946
+		include($filename);
947
+		$contents = ob_get_contents();
948
+		ob_end_clean();
949
+		return $contents;
950
+	}
951
+
952
+	/**
953
+	 * @param string $table_name
954
+	 * @param string $column
955 955
 	 * @param int $id
956 956
 	 * @param int $num_chars
957
-     */
958
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
959
-        $key = '';
957
+	 */
958
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
959
+		$key = '';
960 960
 
961
-        if ( ! empty( $name ) ) {
962
-            $key = sanitize_key($name);
963
-        }
961
+		if ( ! empty( $name ) ) {
962
+			$key = sanitize_key($name);
963
+		}
964 964
 
965 965
 		if ( empty( $key ) ) {
966
-            $max_slug_value = pow(36, $num_chars);
967
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
968
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
969
-        }
966
+			$max_slug_value = pow(36, $num_chars);
967
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
968
+			$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
969
+		}
970 970
 
971 971
 		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
972 972
 			$key = $key . 'a';
973
-        }
973
+		}
974 974
 
975 975
 		$key_check = FrmDb::get_var( $table_name, array(
976 976
 			$column => $key,
977 977
 			'ID !'  => $id,
978 978
 		), $column );
979 979
 
980
-        if ( $key_check || is_numeric($key_check) ) {
981
-            $suffix = 2;
980
+		if ( $key_check || is_numeric($key_check) ) {
981
+			$suffix = 2;
982 982
 			do {
983 983
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
984 984
 				$key_check = FrmDb::get_var( $table_name, array(
@@ -988,23 +988,23 @@  discard block
 block discarded – undo
988 988
 				$suffix++;
989 989
 			} while ( $key_check || is_numeric( $key_check ) );
990 990
 			$key = $alt_post_name;
991
-        }
992
-        return $key;
993
-    }
994
-
995
-    /**
996
-     * Editing a Form or Entry
997
-     * @param string $table
998
-     * @return bool|array
999
-     */
1000
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1001
-        if ( ! $record ) {
1002
-            return false;
1003
-        }
1004
-
1005
-        if ( empty($post_values) ) {
1006
-            $post_values = stripslashes_deep($_POST);
1007
-        }
991
+		}
992
+		return $key;
993
+	}
994
+
995
+	/**
996
+	 * Editing a Form or Entry
997
+	 * @param string $table
998
+	 * @return bool|array
999
+	 */
1000
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1001
+		if ( ! $record ) {
1002
+			return false;
1003
+		}
1004
+
1005
+		if ( empty($post_values) ) {
1006
+			$post_values = stripslashes_deep($_POST);
1007
+		}
1008 1008
 
1009 1009
 		$values = array(
1010 1010
 			'id' => $record->id,
@@ -1012,154 +1012,154 @@  discard block
 block discarded – undo
1012 1012
 		);
1013 1013
 
1014 1014
 		foreach ( array( 'name', 'description' ) as $var ) {
1015
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
1015
+			$default_val = isset($record->{$var}) ? $record->{$var} : '';
1016 1016
 			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
1017
-            unset($var, $default_val);
1018
-        }
1019
-
1020
-        $values['description'] = self::use_wpautop($values['description']);
1021
-        $frm_settings = self::get_settings();
1022
-        $is_form_builder = self::is_admin_page('formidable' );
1023
-
1024
-        foreach ( (array) $fields as $field ) {
1025
-            // Make sure to filter default values (for placeholder text), but not on the form builder page
1026
-            if ( ! $is_form_builder ) {
1027
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
1028
-            }
1017
+			unset($var, $default_val);
1018
+		}
1019
+
1020
+		$values['description'] = self::use_wpautop($values['description']);
1021
+		$frm_settings = self::get_settings();
1022
+		$is_form_builder = self::is_admin_page('formidable' );
1023
+
1024
+		foreach ( (array) $fields as $field ) {
1025
+			// Make sure to filter default values (for placeholder text), but not on the form builder page
1026
+			if ( ! $is_form_builder ) {
1027
+				$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
1028
+			}
1029 1029
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
1030 1030
 			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
1031
-        }
1031
+		}
1032 1032
 
1033
-        self::fill_form_opts($record, $table, $post_values, $values);
1033
+		self::fill_form_opts($record, $table, $post_values, $values);
1034 1034
 
1035
-        if ( $table == 'entries' ) {
1036
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1037
-        } else if ( $table == 'forms' ) {
1038
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1039
-        }
1035
+		if ( $table == 'entries' ) {
1036
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1037
+		} else if ( $table == 'forms' ) {
1038
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1039
+		}
1040 1040
 
1041
-        return $values;
1042
-    }
1041
+		return $values;
1042
+	}
1043 1043
 
1044 1044
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
1045
-        $post_values = $args['post_values'];
1046
-
1047
-        if ( $args['default'] ) {
1048
-            $meta_value = $field->default_value;
1049
-        } else {
1050
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1051
-                if ( ! isset($field->field_options['custom_field']) ) {
1052
-                    $field->field_options['custom_field'] = '';
1053
-                }
1045
+		$post_values = $args['post_values'];
1046
+
1047
+		if ( $args['default'] ) {
1048
+			$meta_value = $field->default_value;
1049
+		} else {
1050
+			if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1051
+				if ( ! isset($field->field_options['custom_field']) ) {
1052
+					$field->field_options['custom_field'] = '';
1053
+				}
1054 1054
 				$meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array(
1055 1055
 					'truncate' => false,
1056 1056
 					'type' => $field->type,
1057 1057
 					'form_id' => $field->form_id,
1058 1058
 					'field' => $field,
1059 1059
 				) );
1060
-            } else {
1060
+			} else {
1061 1061
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1062
-            }
1063
-        }
1062
+			}
1063
+		}
1064 1064
 
1065 1065
 		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1066
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1067
-
1068
-        $field_array = array(
1069
-            'id'            => $field->id,
1070
-            'value'         => $new_value,
1071
-            'default_value' => $field->default_value,
1072
-            'name'          => $field->name,
1073
-            'description'   => $field->description,
1074
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1075
-            'options'       => $field->options,
1076
-            'required'      => $field->required,
1077
-            'field_key'     => $field->field_key,
1078
-            'field_order'   => $field->field_order,
1079
-            'form_id'       => $field->form_id,
1066
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1067
+
1068
+		$field_array = array(
1069
+			'id'            => $field->id,
1070
+			'value'         => $new_value,
1071
+			'default_value' => $field->default_value,
1072
+			'name'          => $field->name,
1073
+			'description'   => $field->description,
1074
+			'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1075
+			'options'       => $field->options,
1076
+			'required'      => $field->required,
1077
+			'field_key'     => $field->field_key,
1078
+			'field_order'   => $field->field_order,
1079
+			'form_id'       => $field->form_id,
1080 1080
 			'parent_form_id' => $args['parent_form_id'],
1081
-        );
1081
+		);
1082 1082
 
1083
-        $args['field_type'] = $field_type;
1084
-        self::fill_field_opts($field, $field_array, $args);
1083
+		$args['field_type'] = $field_type;
1084
+		self::fill_field_opts($field, $field_array, $args);
1085 1085
 		// Track the original field's type
1086 1086
 		$field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type;
1087 1087
 
1088
-        $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1088
+		$field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1089 1089
 
1090
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1091
-            $field_array['unique_msg'] = '';
1092
-        }
1090
+		if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1091
+			$field_array['unique_msg'] = '';
1092
+		}
1093 1093
 
1094
-        $field_array = array_merge( $field->field_options, $field_array );
1094
+		$field_array = array_merge( $field->field_options, $field_array );
1095 1095
 
1096
-        $values['fields'][ $field->id ] = $field_array;
1097
-    }
1096
+		$values['fields'][ $field->id ] = $field_array;
1097
+	}
1098 1098
 
1099 1099
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1100
-        $post_values = $args['post_values'];
1101
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1100
+		$post_values = $args['post_values'];
1101
+		$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1102 1102
 
1103
-        foreach ( $opt_defaults as $opt => $default_opt ) {
1103
+		foreach ( $opt_defaults as $opt => $default_opt ) {
1104 1104
 			$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 );
1105
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1106
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1107
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1108
-                if ( $args['field_type'] == 'captcha' ) {
1109
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1110
-                } else {
1111
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1112
-                }
1113
-            }
1114
-        }
1115
-
1116
-        if ( $field_array['custom_html'] == '' ) {
1117
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1118
-        }
1119
-    }
1120
-
1121
-    /**
1122
-     * @param string $table
1123
-     */
1105
+			if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1106
+				$field_array[ $opt ] = $args['frm_settings']->blank_msg;
1107
+			} else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1108
+				if ( $args['field_type'] == 'captcha' ) {
1109
+					$field_array[ $opt ] = $args['frm_settings']->re_msg;
1110
+				} else {
1111
+					$field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1112
+				}
1113
+			}
1114
+		}
1115
+
1116
+		if ( $field_array['custom_html'] == '' ) {
1117
+			$field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1118
+		}
1119
+	}
1120
+
1121
+	/**
1122
+	 * @param string $table
1123
+	 */
1124 1124
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1125
-        if ( $table == 'entries' ) {
1126
-            $form = $record->form_id;
1125
+		if ( $table == 'entries' ) {
1126
+			$form = $record->form_id;
1127 1127
 			FrmForm::maybe_get_form( $form );
1128
-        } else {
1129
-            $form = $record;
1130
-        }
1128
+		} else {
1129
+			$form = $record;
1130
+		}
1131 1131
 
1132
-        if ( ! $form ) {
1133
-            return;
1134
-        }
1132
+		if ( ! $form ) {
1133
+			return;
1134
+		}
1135 1135
 
1136
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1136
+		$values['form_name'] = isset($record->form_id) ? $form->name : '';
1137 1137
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1138 1138
 
1139
-        if ( ! is_array($form->options) ) {
1140
-            return;
1141
-        }
1139
+		if ( ! is_array($form->options) ) {
1140
+			return;
1141
+		}
1142 1142
 
1143
-        foreach ( $form->options as $opt => $value ) {
1144
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1145
-        }
1143
+		foreach ( $form->options as $opt => $value ) {
1144
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1145
+		}
1146 1146
 
1147
-        self::fill_form_defaults($post_values, $values);
1148
-    }
1147
+		self::fill_form_defaults($post_values, $values);
1148
+	}
1149 1149
 
1150
-    /**
1151
-     * Set to POST value or default
1152
-     */
1150
+	/**
1151
+	 * Set to POST value or default
1152
+	 */
1153 1153
 	private static function fill_form_defaults( $post_values, array &$values ) {
1154
-        $form_defaults = FrmFormsHelper::get_default_opts();
1154
+		$form_defaults = FrmFormsHelper::get_default_opts();
1155 1155
 
1156
-        foreach ( $form_defaults as $opt => $default ) {
1157
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1156
+		foreach ( $form_defaults as $opt => $default ) {
1157
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1158 1158
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1159
-            }
1159
+			}
1160 1160
 
1161
-            unset($opt, $defaut);
1162
-        }
1161
+			unset($opt, $defaut);
1162
+		}
1163 1163
 
1164 1164
 		if ( ! isset( $values['custom_style'] ) ) {
1165 1165
 			$values['custom_style'] = self::custom_style_value( $post_values );
@@ -1168,10 +1168,10 @@  discard block
 block discarded – undo
1168 1168
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1169 1169
 			if ( ! isset( $values[ $h . '_html' ] ) ) {
1170 1170
 				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1171
-            }
1172
-            unset($h);
1173
-        }
1174
-    }
1171
+			}
1172
+			unset($h);
1173
+		}
1174
+	}
1175 1175
 
1176 1176
 	/**
1177 1177
 	 * @since 2.2.10
@@ -1194,59 +1194,59 @@  discard block
 block discarded – undo
1194 1194
 	}
1195 1195
 
1196 1196
 	public static function insert_opt_html( $args ) {
1197
-        $class = '';
1198
-        if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1199
-            $class .= 'show_frm_not_email_to';
1200
-        }
1201
-    ?>
1197
+		$class = '';
1198
+		if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1199
+			$class .= 'show_frm_not_email_to';
1200
+		}
1201
+	?>
1202 1202
 <li>
1203 1203
     <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>
1204 1204
     <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>
1205 1205
     <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>
1206 1206
 </li>
1207 1207
     <?php
1208
-    }
1208
+	}
1209 1209
 
1210 1210
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1211
-        if ( is_array( $str ) ) {
1212
-            return '';
1211
+		if ( is_array( $str ) ) {
1212
+			return '';
1213 1213
 		}
1214 1214
 
1215
-        $length = (int) $length;
1215
+		$length = (int) $length;
1216 1216
 		$str = wp_strip_all_tags( $str );
1217 1217
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1218 1218
 
1219 1219
 		if ( $length == 0 ) {
1220
-            return '';
1221
-        } else if ( $length <= 10 ) {
1220
+			return '';
1221
+		} else if ( $length <= 10 ) {
1222 1222
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1223 1223
 			return $sub . ( ( $length < $original_len ) ? $continue : '' );
1224
-        }
1224
+		}
1225 1225
 
1226
-        $sub = '';
1227
-        $len = 0;
1226
+		$sub = '';
1227
+		$len = 0;
1228 1228
 
1229 1229
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1230 1230
 
1231 1231
 		foreach ( $words as $word ) {
1232 1232
 			$part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1233 1233
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1234
-            if ( $total_len > $length && str_word_count($sub) ) {
1235
-                break;
1236
-            }
1234
+			if ( $total_len > $length && str_word_count($sub) ) {
1235
+				break;
1236
+			}
1237 1237
 
1238
-            $sub .= $part;
1238
+			$sub .= $part;
1239 1239
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1240 1240
 
1241
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1242
-                break;
1243
-            }
1241
+			if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1242
+				break;
1243
+			}
1244 1244
 
1245
-            unset($total_len, $word);
1246
-        }
1245
+			unset($total_len, $word);
1246
+		}
1247 1247
 
1248 1248
 		return $sub . ( ( $len < $original_len ) ? $continue : '' );
1249
-    }
1249
+	}
1250 1250
 
1251 1251
 	public static function mb_function( $function_names, $args ) {
1252 1252
 		$mb_function_name = $function_names[0];
@@ -1258,18 +1258,18 @@  discard block
 block discarded – undo
1258 1258
 	}
1259 1259
 
1260 1260
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1261
-        if ( empty($date) ) {
1262
-            return $date;
1263
-        }
1261
+		if ( empty($date) ) {
1262
+			return $date;
1263
+		}
1264 1264
 
1265
-        if ( empty($date_format) ) {
1266
-            $date_format = get_option('date_format');
1267
-        }
1265
+		if ( empty($date_format) ) {
1266
+			$date_format = get_option('date_format');
1267
+		}
1268 1268
 
1269
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1270
-            $frmpro_settings = new FrmProSettings();
1271
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1272
-        }
1269
+		if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1270
+			$frmpro_settings = new FrmProSettings();
1271
+			$date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1272
+		}
1273 1273
 
1274 1274
 		$formatted = self::get_localized_date( $date_format, $date );
1275 1275
 
@@ -1278,8 +1278,8 @@  discard block
 block discarded – undo
1278 1278
 			$formatted .= self::add_time_to_date( $time_format, $date );
1279 1279
 		}
1280 1280
 
1281
-        return $formatted;
1282
-    }
1281
+		return $formatted;
1282
+	}
1283 1283
 
1284 1284
 	private static function add_time_to_date( $time_format, $date ) {
1285 1285
 		if ( empty( $time_format ) ) {
@@ -1361,119 +1361,119 @@  discard block
 block discarded – undo
1361 1361
 		);
1362 1362
 	}
1363 1363
 
1364
-    // Pagination Methods
1364
+	// Pagination Methods
1365 1365
 
1366
-    /**
1367
-     * @param integer $current_p
1368
-     */
1366
+	/**
1367
+	 * @param integer $current_p
1368
+	 */
1369 1369
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1370 1370
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1371 1371
 	}
1372 1372
 
1373
-    /**
1374
-     * @param integer $current_p
1375
-     */
1376
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1377
-        if ( $current_p == 1 ) {
1378
-            return 1;
1379
-        } else {
1380
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1381
-        }
1382
-    }
1373
+	/**
1374
+	 * @param integer $current_p
1375
+	 */
1376
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1377
+		if ( $current_p == 1 ) {
1378
+			return 1;
1379
+		} else {
1380
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1381
+		}
1382
+	}
1383 1383
 
1384 1384
 	/**
1385 1385
 	 * @return array
1386 1386
 	 */
1387 1387
 	public static function json_to_array( $json_vars ) {
1388
-        $vars = array();
1389
-        foreach ( $json_vars as $jv ) {
1390
-            $jv_name = explode('[', $jv['name']);
1391
-            $last = count($jv_name) - 1;
1392
-            foreach ( $jv_name as $p => $n ) {
1393
-                $name = trim($n, ']');
1394
-                if ( ! isset($l1) ) {
1395
-                    $l1 = $name;
1396
-                }
1397
-
1398
-                if ( ! isset($l2) ) {
1399
-                    $l2 = $name;
1400
-                }
1401
-
1402
-                if ( ! isset($l3) ) {
1403
-                    $l3 = $name;
1404
-                }
1405
-
1406
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1407
-
1408
-                switch ( $p ) {
1409
-                    case 0:
1410
-                        $l1 = $name;
1411
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1388
+		$vars = array();
1389
+		foreach ( $json_vars as $jv ) {
1390
+			$jv_name = explode('[', $jv['name']);
1391
+			$last = count($jv_name) - 1;
1392
+			foreach ( $jv_name as $p => $n ) {
1393
+				$name = trim($n, ']');
1394
+				if ( ! isset($l1) ) {
1395
+					$l1 = $name;
1396
+				}
1397
+
1398
+				if ( ! isset($l2) ) {
1399
+					$l2 = $name;
1400
+				}
1401
+
1402
+				if ( ! isset($l3) ) {
1403
+					$l3 = $name;
1404
+				}
1405
+
1406
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1407
+
1408
+				switch ( $p ) {
1409
+					case 0:
1410
+						$l1 = $name;
1411
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1412 1412
 						break;
1413 1413
 
1414
-                    case 1:
1415
-                        $l2 = $name;
1416
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1414
+					case 1:
1415
+						$l2 = $name;
1416
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1417 1417
 						break;
1418 1418
 
1419
-                    case 2:
1420
-                        $l3 = $name;
1421
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1419
+					case 2:
1420
+						$l3 = $name;
1421
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1422 1422
 						break;
1423 1423
 
1424
-                    case 3:
1425
-                        $l4 = $name;
1426
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1427
-                }
1424
+					case 3:
1425
+						$l4 = $name;
1426
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1427
+				}
1428 1428
 
1429
-                unset($this_val, $n);
1430
-            }
1429
+				unset($this_val, $n);
1430
+			}
1431 1431
 
1432
-            unset($last, $jv);
1433
-        }
1432
+			unset($last, $jv);
1433
+		}
1434 1434
 
1435
-        return $vars;
1436
-    }
1435
+		return $vars;
1436
+	}
1437 1437
 
1438
-    /**
1439
-     * @param string $name
1440
-     * @param string $l1
1441
-     */
1442
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1443
-        if ( $name == '' ) {
1444
-            $vars[] = $val;
1445
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1446
-            $vars[ $l1 ] = $val;
1447
-        }
1448
-    }
1438
+	/**
1439
+	 * @param string $name
1440
+	 * @param string $l1
1441
+	 */
1442
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1443
+		if ( $name == '' ) {
1444
+			$vars[] = $val;
1445
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1446
+			$vars[ $l1 ] = $val;
1447
+		}
1448
+	}
1449 1449
 
1450 1450
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1451
-        $tooltips = array(
1452
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1453
-            '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' ),
1454
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1455
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1456
-            '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' ),
1457
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1458
-            '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() ) ),
1459
-        );
1460
-
1461
-        if ( ! isset( $tooltips[ $name ] ) ) {
1462
-            return;
1463
-        }
1464
-
1465
-        if ( 'open' == $class ) {
1466
-            echo ' frm_help"';
1467
-        } else {
1468
-            echo ' class="frm_help"';
1469
-        }
1451
+		$tooltips = array(
1452
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1453
+			'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' ),
1454
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1455
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1456
+			'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' ),
1457
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1458
+			'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() ) ),
1459
+		);
1460
+
1461
+		if ( ! isset( $tooltips[ $name ] ) ) {
1462
+			return;
1463
+		}
1464
+
1465
+		if ( 'open' == $class ) {
1466
+			echo ' frm_help"';
1467
+		} else {
1468
+			echo ' class="frm_help"';
1469
+		}
1470 1470
 
1471 1471
 		echo ' title="' . esc_attr( $tooltips[ $name ] );
1472 1472
 
1473
-        if ( 'open' != $class ) {
1474
-            echo '"';
1475
-        }
1476
-    }
1473
+		if ( 'open' != $class ) {
1474
+			echo '"';
1475
+		}
1476
+	}
1477 1477
 
1478 1478
 	/**
1479 1479
 	 * Add the current_page class to that page in the form nav
@@ -1489,35 +1489,35 @@  discard block
 block discarded – undo
1489 1489
 		}
1490 1490
 	}
1491 1491
 
1492
-    /**
1493
-     * Prepare and json_encode post content
1494
-     *
1495
-     * @since 2.0
1496
-     *
1497
-     * @param array $post_content
1498
-     * @return string $post_content ( json encoded array )
1499
-     */
1500
-    public static function prepare_and_encode( $post_content ) {
1501
-        //Loop through array to strip slashes and add only the needed ones
1492
+	/**
1493
+	 * Prepare and json_encode post content
1494
+	 *
1495
+	 * @since 2.0
1496
+	 *
1497
+	 * @param array $post_content
1498
+	 * @return string $post_content ( json encoded array )
1499
+	 */
1500
+	public static function prepare_and_encode( $post_content ) {
1501
+		//Loop through array to strip slashes and add only the needed ones
1502 1502
 		foreach ( $post_content as $key => $val ) {
1503 1503
 			// Replace problematic characters (like &quot;)
1504 1504
 			$val = str_replace( '&quot;', '"', $val );
1505 1505
 
1506 1506
 			self::prepare_action_slashes( $val, $key, $post_content );
1507
-            unset( $key, $val );
1508
-        }
1507
+			unset( $key, $val );
1508
+		}
1509 1509
 
1510
-        // json_encode the array
1511
-        $post_content = json_encode( $post_content );
1510
+		// json_encode the array
1511
+		$post_content = json_encode( $post_content );
1512 1512
 
1513
-	    // add extra slashes for \r\n since WP strips them
1513
+		// add extra slashes for \r\n since WP strips them
1514 1514
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1515 1515
 
1516
-        // allow for &quot
1517
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1516
+		// allow for &quot
1517
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1518 1518
 
1519
-        return $post_content;
1520
-    }
1519
+		return $post_content;
1520
+	}
1521 1521
 
1522 1522
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1523 1523
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1539,64 +1539,64 @@  discard block
 block discarded – undo
1539 1539
 	}
1540 1540
 
1541 1541
 	public static function maybe_json_decode( $string ) {
1542
-        if ( is_array($string) ) {
1543
-            return $string;
1544
-        }
1542
+		if ( is_array($string) ) {
1543
+			return $string;
1544
+		}
1545 1545
 
1546
-        $new_string = json_decode($string, true);
1547
-        if ( function_exists('json_last_error') ) {
1546
+		$new_string = json_decode($string, true);
1547
+		if ( function_exists('json_last_error') ) {
1548 1548
 			// php 5.3+
1549
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1550
-                $string = $new_string;
1551
-            }
1552
-        } else if ( isset($new_string) ) {
1549
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1550
+				$string = $new_string;
1551
+			}
1552
+		} else if ( isset($new_string) ) {
1553 1553
 			// php < 5.3 fallback
1554
-            $string = $new_string;
1555
-        }
1556
-        return $string;
1557
-    }
1558
-
1559
-    /**
1560
-     * @since 1.07.10
1561
-     *
1562
-     * @param string $post_type The name of the post type that may need to be highlighted
1563
-     * echo The javascript to open and highlight the Formidable menu
1564
-     */
1554
+			$string = $new_string;
1555
+		}
1556
+		return $string;
1557
+	}
1558
+
1559
+	/**
1560
+	 * @since 1.07.10
1561
+	 *
1562
+	 * @param string $post_type The name of the post type that may need to be highlighted
1563
+	 * echo The javascript to open and highlight the Formidable menu
1564
+	 */
1565 1565
 	public static function maybe_highlight_menu( $post_type ) {
1566
-        global $post;
1566
+		global $post;
1567 1567
 
1568
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1569
-            return;
1570
-        }
1568
+		if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1569
+			return;
1570
+		}
1571 1571
 
1572
-        if ( is_object($post) && $post->post_type != $post_type ) {
1573
-            return;
1574
-        }
1572
+		if ( is_object($post) && $post->post_type != $post_type ) {
1573
+			return;
1574
+		}
1575 1575
 
1576
-        self::load_admin_wide_js();
1577
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1578
-    }
1576
+		self::load_admin_wide_js();
1577
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1578
+	}
1579 1579
 
1580
-    /**
1581
-     * Load the JS file on non-Formidable pages in the admin area
1582
-     * @since 2.0
1583
-     */
1580
+	/**
1581
+	 * Load the JS file on non-Formidable pages in the admin area
1582
+	 * @since 2.0
1583
+	 */
1584 1584
 	public static function load_admin_wide_js( $load = true ) {
1585
-        $version = FrmAppHelper::plugin_version();
1585
+		$version = FrmAppHelper::plugin_version();
1586 1586
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1587 1587
 
1588
-        wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1588
+		wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1589 1589
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1590
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1590
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1591 1591
 			'url'          => FrmAppHelper::plugin_url(),
1592 1592
 			'loading'      => __( 'Loading&hellip;' ),
1593 1593
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
1594
-        ) );
1594
+		) );
1595 1595
 
1596 1596
 		if ( $load ) {
1597 1597
 			wp_enqueue_script( 'formidable_admin_global' );
1598 1598
 		}
1599
-    }
1599
+	}
1600 1600
 
1601 1601
 	/**
1602 1602
 	 * @since 2.0.9
@@ -1605,9 +1605,9 @@  discard block
 block discarded – undo
1605 1605
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1606 1606
 	}
1607 1607
 
1608
-    /**
1609
-     * @param string $location
1610
-     */
1608
+	/**
1609
+	 * @param string $location
1610
+	 */
1611 1611
 	public static function localize_script( $location ) {
1612 1612
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1613 1613
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1663,27 +1663,27 @@  discard block
 block discarded – undo
1663 1663
 		}
1664 1664
 	}
1665 1665
 
1666
-    /**
1666
+	/**
1667 1667
 	 * echo the message on the plugins listing page
1668
-     * @since 1.07.10
1669
-     *
1670
-     * @param float $min_version The version the add-on requires
1671
-     */
1668
+	 * @since 1.07.10
1669
+	 *
1670
+	 * @param float $min_version The version the add-on requires
1671
+	 */
1672 1672
 	public static function min_version_notice( $min_version ) {
1673
-        $frm_version = self::plugin_version();
1673
+		$frm_version = self::plugin_version();
1674 1674
 
1675
-        // check if Formidable meets minimum requirements
1676
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1677
-            return;
1678
-        }
1675
+		// check if Formidable meets minimum requirements
1676
+		if ( version_compare($frm_version, $min_version, '>=') ) {
1677
+			return;
1678
+		}
1679 1679
 
1680
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1680
+		$wp_list_table = _get_list_table('WP_Plugins_List_Table');
1681 1681
 		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">' .
1682
-        __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1683
-        '</div></td></tr>';
1684
-    }
1682
+		__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1683
+		'</div></td></tr>';
1684
+	}
1685 1685
 
1686
-    public static function locales( $type = 'date' ) {
1686
+	public static function locales( $type = 'date' ) {
1687 1687
 		$locales = array(
1688 1688
 			'en' => __( 'English', 'formidable' ),
1689 1689
 			''   => __( 'English/Western', 'formidable' ),
@@ -1759,11 +1759,11 @@  discard block
 block discarded – undo
1759 1759
 			$unset = array( 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', 'es-419', 'tr' );
1760 1760
 		}
1761 1761
 
1762
-        $locales = array_diff_key($locales, array_flip($unset));
1763
-        $locales = apply_filters('frm_locales', $locales);
1762
+		$locales = array_diff_key($locales, array_flip($unset));
1763
+		$locales = apply_filters('frm_locales', $locales);
1764 1764
 
1765
-        return $locales;
1766
-    }
1765
+		return $locales;
1766
+	}
1767 1767
 
1768 1768
 	/**
1769 1769
 	 * Prepare and save settings in styles and actions
Please login to merge, or discard this patch.