Completed
Push — master ( 8f275d...5a8d2f )
by Stephanie
02:55
created
classes/helpers/FrmAppHelper.php 1 patch
Indentation   +559 added lines, -559 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@  discard block
 block discarded – undo
13 13
 	 */
14 14
 	public static $plug_version = '3.03.02';
15 15
 
16
-    /**
17
-     * @since 1.07.02
18
-     *
19
-     * @param none
20
-     * @return string The version of this plugin
21
-     */
22
-    public static function plugin_version() {
23
-        return self::$plug_version;
24
-    }
16
+	/**
17
+	 * @since 1.07.02
18
+	 *
19
+	 * @param none
20
+	 * @return string The version of this plugin
21
+	 */
22
+	public static function plugin_version() {
23
+		return self::$plug_version;
24
+	}
25 25
 
26 26
 	public static function plugin_folder() {
27 27
 		return basename( self::plugin_path() );
@@ -31,29 +31,29 @@  discard block
 block discarded – undo
31 31
 		return dirname( dirname( dirname( __FILE__ ) ) );
32 32
 	}
33 33
 
34
-    public static function plugin_url() {
35
-        //prevously FRM_URL constant
34
+	public static function plugin_url() {
35
+		//prevously FRM_URL constant
36 36
 		return plugins_url( '', self::plugin_path() . '/formidable.php' );
37
-    }
37
+	}
38 38
 
39 39
 	public static function relative_plugin_url() {
40 40
 		return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() );
41 41
 	}
42 42
 
43
-    /**
44
-     * @return string Site URL
45
-     */
46
-    public static function site_url() {
47
-        return site_url();
48
-    }
49
-
50
-    /**
51
-     * Get the name of this site
52
-     * Used for [sitename] shortcode
53
-     *
54
-     * @since 2.0
55
-     * @return string
56
-     */
43
+	/**
44
+	 * @return string Site URL
45
+	 */
46
+	public static function site_url() {
47
+		return site_url();
48
+	}
49
+
50
+	/**
51
+	 * Get the name of this site
52
+	 * Used for [sitename] shortcode
53
+	 *
54
+	 * @since 2.0
55
+	 * @return string
56
+	 */
57 57
 	public static function site_name() {
58 58
 		return get_option( 'blogname' );
59 59
 	}
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
 		return absint( apply_filters( 'frm_affiliate_id', 0 ) );
72 72
 	}
73 73
 
74
-    /**
75
-     * Get the Formidable settings
76
-     *
77
-     * @since 2.0
78
-     *
79
-     * @param None
80
-     * @return FrmSettings $frm_setings
81
-     */
74
+	/**
75
+	 * Get the Formidable settings
76
+	 *
77
+	 * @since 2.0
78
+	 *
79
+	 * @param None
80
+	 * @return FrmSettings $frm_setings
81
+	 */
82 82
 	public static function get_settings() {
83 83
 		global $frm_settings;
84 84
 		if ( empty( $frm_settings ) ) {
@@ -119,50 +119,50 @@  discard block
 block discarded – undo
119 119
 		return $is_formidable;
120 120
 	}
121 121
 
122
-    /**
123
-     * Check for certain page in Formidable settings
124
-     *
125
-     * @since 2.0
126
-     *
127
-     * @param string $page The name of the page to check
128
-     * @return boolean
129
-     */
122
+	/**
123
+	 * Check for certain page in Formidable settings
124
+	 *
125
+	 * @since 2.0
126
+	 *
127
+	 * @param string $page The name of the page to check
128
+	 * @return boolean
129
+	 */
130 130
 	public static function is_admin_page( $page = 'formidable' ) {
131
-        global $pagenow;
131
+		global $pagenow;
132 132
 		$get_page = self::simple_get( 'page', 'sanitize_title' );
133
-        if ( $pagenow ) {
133
+		if ( $pagenow ) {
134 134
 			// allow this to be true during ajax load i.e. ajax form builder loading
135 135
 			return ( $pagenow == 'admin.php' || $pagenow == 'admin-ajax.php' ) && $get_page == $page;
136
-        }
136
+		}
137 137
 
138 138
 		return is_admin() && $get_page == $page;
139
-    }
140
-
141
-    /**
142
-     * Check for the form preview page
143
-     *
144
-     * @since 2.0
145
-     *
146
-     * @param None
147
-     * @return boolean
148
-     */
149
-    public static function is_preview_page() {
150
-        global $pagenow;
139
+	}
140
+
141
+	/**
142
+	 * Check for the form preview page
143
+	 *
144
+	 * @since 2.0
145
+	 *
146
+	 * @param None
147
+	 * @return boolean
148
+	 */
149
+	public static function is_preview_page() {
150
+		global $pagenow;
151 151
 		$action = FrmAppHelper::simple_get( 'action', 'sanitize_title' );
152 152
 		return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
153
-    }
154
-
155
-    /**
156
-     * Check for ajax except the form preview page
157
-     *
158
-     * @since 2.0
159
-     *
160
-     * @param None
161
-     * @return boolean
162
-     */
163
-    public static function doing_ajax() {
164
-        return self::wp_doing_ajax() && ! self::is_preview_page();
165
-    }
153
+	}
154
+
155
+	/**
156
+	 * Check for ajax except the form preview page
157
+	 *
158
+	 * @since 2.0
159
+	 *
160
+	 * @param None
161
+	 * @return boolean
162
+	 */
163
+	public static function doing_ajax() {
164
+		return self::wp_doing_ajax() && ! self::is_preview_page();
165
+	}
166 166
 
167 167
 	public static function js_suffix() {
168 168
 		return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
@@ -189,81 +189,81 @@  discard block
 block discarded – undo
189 189
 		return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
190 190
 	}
191 191
 
192
-    /**
193
-     * Check if on an admin page
194
-     *
195
-     * @since 2.0
196
-     *
197
-     * @param None
198
-     * @return boolean
199
-     */
200
-    public static function is_admin() {
201
-        return is_admin() && ! self::wp_doing_ajax();
202
-    }
203
-
204
-    /**
205
-     * Check if value contains blank value or empty array
206
-     *
207
-     * @since 2.0
208
-     * @param mixed $value - value to check
192
+	/**
193
+	 * Check if on an admin page
194
+	 *
195
+	 * @since 2.0
196
+	 *
197
+	 * @param None
198
+	 * @return boolean
199
+	 */
200
+	public static function is_admin() {
201
+		return is_admin() && ! self::wp_doing_ajax();
202
+	}
203
+
204
+	/**
205
+	 * Check if value contains blank value or empty array
206
+	 *
207
+	 * @since 2.0
208
+	 * @param mixed $value - value to check
209 209
 	 * @param string
210
-     * @return boolean
211
-     */
212
-    public static function is_empty_value( $value, $empty = '' ) {
213
-        return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
214
-    }
215
-
216
-    public static function is_not_empty_value( $value, $empty = '' ) {
217
-        return ! self::is_empty_value( $value, $empty );
218
-    }
219
-
220
-    /**
221
-     * Get any value from the $_SERVER
222
-     *
223
-     * @since 2.0
224
-     * @param string $value
225
-     * @return string
226
-     */
210
+	 * @return boolean
211
+	 */
212
+	public static function is_empty_value( $value, $empty = '' ) {
213
+		return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
214
+	}
215
+
216
+	public static function is_not_empty_value( $value, $empty = '' ) {
217
+		return ! self::is_empty_value( $value, $empty );
218
+	}
219
+
220
+	/**
221
+	 * Get any value from the $_SERVER
222
+	 *
223
+	 * @since 2.0
224
+	 * @param string $value
225
+	 * @return string
226
+	 */
227 227
 	public static function get_server_value( $value ) {
228
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
229
-    }
230
-
231
-    /**
232
-     * Check for the IP address in several places
233
-     * Used by [ip] shortcode
234
-     *
235
-     * @return string The IP address of the current user
236
-     */
237
-    public static function get_ip_address() {
228
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
229
+	}
230
+
231
+	/**
232
+	 * Check for the IP address in several places
233
+	 * Used by [ip] shortcode
234
+	 *
235
+	 * @return string The IP address of the current user
236
+	 */
237
+	public static function get_ip_address() {
238 238
 		$ip = '';
239 239
 		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 ) {
240
-            if ( ! isset( $_SERVER[ $key ] ) ) {
241
-                continue;
242
-            }
240
+			if ( ! isset( $_SERVER[ $key ] ) ) {
241
+				continue;
242
+			}
243 243
 
244
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
244
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
245 245
 				$ip = trim( $ip ); // just to be safe
246 246
 
247 247
 				if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
248
-                    return sanitize_text_field( $ip );
249
-                }
250
-            }
251
-        }
248
+					return sanitize_text_field( $ip );
249
+				}
250
+			}
251
+		}
252 252
 
253 253
 		return sanitize_text_field( $ip );
254
-    }
254
+	}
255 255
 
256
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
256
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
257 257
 		if ( strpos( $param, '[' ) ) {
258 258
 			$params = explode( '[', $param );
259
-            $param = $params[0];
260
-        }
259
+			$param = $params[0];
260
+		}
261 261
 
262 262
 		if ( $src == 'get' ) {
263
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
264
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
265
-                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
266
-            }
263
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
264
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
265
+				$value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
266
+			}
267 267
 			self::sanitize_value( $sanitize, $value );
268 268
 		} else {
269 269
 			$value = self::get_simple_request( array(
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 			}
286 286
 		}
287 287
 
288
-        return $value;
289
-    }
288
+		return $value;
289
+	}
290 290
 
291 291
 	public static function get_post_param( $param, $default = '', $sanitize = '' ) {
292 292
 		return self::get_simple_request( array(
@@ -350,12 +350,12 @@  discard block
 block discarded – undo
350 350
 	}
351 351
 
352 352
 	/**
353
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
354
-	*
355
-	* @since 2.0.8
356
-	* @param string $value
357
-	* @return string $value
358
-	*/
353
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
354
+	 *
355
+	 * @since 2.0.8
356
+	 * @param string $value
357
+	 * @return string $value
358
+	 */
359 359
 	public static function preserve_backslashes( $value ) {
360 360
 		// If backslashes have already been added, don't add them again
361 361
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -377,14 +377,14 @@  discard block
 block discarded – undo
377 377
 		}
378 378
 	}
379 379
 
380
-    public static function sanitize_request( $sanitize_method, &$values ) {
381
-        $temp_values = $values;
382
-        foreach ( $temp_values as $k => $val ) {
383
-            if ( isset( $sanitize_method[ $k ] ) ) {
380
+	public static function sanitize_request( $sanitize_method, &$values ) {
381
+		$temp_values = $values;
382
+		foreach ( $temp_values as $k => $val ) {
383
+			if ( isset( $sanitize_method[ $k ] ) ) {
384 384
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
385
-            }
386
-        }
387
-    }
385
+			}
386
+		}
387
+	}
388 388
 
389 389
 	/**
390 390
 	 * @deprecated 3.01
@@ -510,39 +510,39 @@  discard block
 block discarded – undo
510 510
 		);
511 511
 	}
512 512
 
513
-    /**
514
-     * Used when switching the action for a bulk action
515
-     * @since 2.0
516
-     */
513
+	/**
514
+	 * Used when switching the action for a bulk action
515
+	 * @since 2.0
516
+	 */
517 517
 	public static function remove_get_action() {
518 518
 		if ( ! isset( $_GET ) ) {
519 519
 			return;
520 520
 		}
521 521
 
522
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
523
-        if ( ! empty( $new_action ) ) {
522
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
523
+		if ( ! empty( $new_action ) ) {
524 524
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
525
-        }
526
-    }
525
+		}
526
+	}
527 527
 
528
-    /**
529
-     * Check the WP query for a parameter
530
-     *
531
-     * @since 2.0
532
-     * @return string|array
533
-     */
534
-    public static function get_query_var( $value, $param ) {
535
-        if ( $value != '' ) {
536
-            return $value;
537
-        }
528
+	/**
529
+	 * Check the WP query for a parameter
530
+	 *
531
+	 * @since 2.0
532
+	 * @return string|array
533
+	 */
534
+	public static function get_query_var( $value, $param ) {
535
+		if ( $value != '' ) {
536
+			return $value;
537
+		}
538 538
 
539
-        global $wp_query;
540
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
541
-            $value = $wp_query->query_vars[ $param ];
542
-        }
539
+		global $wp_query;
540
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
541
+			$value = $wp_query->query_vars[ $param ];
542
+		}
543 543
 
544
-        return $value;
545
-    }
544
+		return $value;
545
+	}
546 546
 
547 547
 	/**
548 548
 	 * @since 3.0
@@ -564,16 +564,16 @@  discard block
 block discarded – undo
564 564
 		}
565 565
 	}
566 566
 
567
-    /**
568
-     * @param string $type
569
-     */
570
-    public static function trigger_hook_load( $type, $object = null ) {
571
-        // only load the form hooks once
567
+	/**
568
+	 * @param string $type
569
+	 */
570
+	public static function trigger_hook_load( $type, $object = null ) {
571
+		// only load the form hooks once
572 572
 		$hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
573
-        if ( ! $hooks_loaded ) {
573
+		if ( ! $hooks_loaded ) {
574 574
 			do_action( 'frm_load_' . $type . '_hooks' );
575
-        }
576
-    }
575
+		}
576
+	}
577 577
 
578 578
 	/**
579 579
 	 * Save all front-end js scripts into a single file
@@ -595,29 +595,29 @@  discard block
 block discarded – undo
595 595
 		$new_file->combine_files( $files );
596 596
 	}
597 597
 
598
-    /**
599
-     * Check a value from a shortcode to see if true or false.
600
-     * True when value is 1, true, 'true', 'yes'
601
-     *
602
-     * @since 1.07.10
603
-     *
604
-     * @param string $value The value to compare
605
-     * @return boolean True or False
606
-     */
598
+	/**
599
+	 * Check a value from a shortcode to see if true or false.
600
+	 * True when value is 1, true, 'true', 'yes'
601
+	 *
602
+	 * @since 1.07.10
603
+	 *
604
+	 * @param string $value The value to compare
605
+	 * @return boolean True or False
606
+	 */
607 607
 	public static function is_true( $value ) {
608
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
609
-    }
608
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
609
+	}
610 610
 
611
-    /**
612
-     * Used to filter shortcode in text widgets
611
+	/**
612
+	 * Used to filter shortcode in text widgets
613 613
 	 *
614 614
 	 * @deprecated 2.5.4
615 615
 	 * @codeCoverageIgnore
616
-     */
617
-    public static function widget_text_filter_callback( $matches ) {
616
+	 */
617
+	public static function widget_text_filter_callback( $matches ) {
618 618
 		_deprecated_function( __METHOD__, '2.5.4' );
619
-        return do_shortcode( $matches[0] );
620
-    }
619
+		return do_shortcode( $matches[0] );
620
+	}
621 621
 
622 622
 	public static function get_pages() {
623 623
 		return get_posts( array(
@@ -629,10 +629,10 @@  discard block
 block discarded – undo
629 629
 		) );
630 630
 	}
631 631
 
632
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
633
-        $pages = self::get_pages();
632
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
633
+		$pages = self::get_pages();
634 634
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
635
-    ?>
635
+	?>
636 636
 		<select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
637 637
             <option value=""> </option>
638 638
             <?php foreach ( $pages as $page ) { ?>
@@ -642,16 +642,16 @@  discard block
 block discarded – undo
642 642
             <?php } ?>
643 643
         </select>
644 644
     <?php
645
-    }
645
+	}
646 646
 
647 647
 	public static function post_edit_link( $post_id ) {
648 648
 		$post = get_post( $post_id );
649
-        if ( $post ) {
649
+		if ( $post ) {
650 650
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
651 651
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
652
-        }
653
-        return '';
654
-    }
652
+		}
653
+		return '';
654
+	}
655 655
 
656 656
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
657 657
 		?>
@@ -662,73 +662,73 @@  discard block
 block discarded – undo
662 662
 	}
663 663
 
664 664
 	public static function roles_options( $capability ) {
665
-        global $frm_vars;
665
+		global $frm_vars;
666 666
 		if ( isset( $frm_vars['editable_roles'] ) ) {
667
-            $editable_roles = $frm_vars['editable_roles'];
668
-        } else {
669
-            $editable_roles = get_editable_roles();
670
-            $frm_vars['editable_roles'] = $editable_roles;
671
-        }
667
+			$editable_roles = $frm_vars['editable_roles'];
668
+		} else {
669
+			$editable_roles = get_editable_roles();
670
+			$frm_vars['editable_roles'] = $editable_roles;
671
+		}
672 672
 
673
-        foreach ( $editable_roles as $role => $details ) {
673
+		foreach ( $editable_roles as $role => $details ) {
674 674
 			$name = translate_user_role( $details['name'] );
675 675
 			?>
676 676
 		<option value="<?php echo esc_attr( $role ); ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ); ?> </option>
677 677
 <?php
678 678
 			unset( $role, $details );
679
-        }
680
-    }
679
+		}
680
+	}
681 681
 
682 682
 	public static function frm_capabilities( $type = 'auto' ) {
683
-        $cap = array(
684
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
685
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
686
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
687
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
688
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
689
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
690
-        );
683
+		$cap = array(
684
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
685
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
686
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
687
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
688
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
689
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
690
+		);
691 691
 
692 692
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
693
-            return $cap;
694
-        }
693
+			return $cap;
694
+		}
695 695
 
696
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
697
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
698
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
699
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
696
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
697
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
698
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
699
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
700 700
 
701
-        return $cap;
702
-    }
701
+		return $cap;
702
+	}
703 703
 
704 704
 	public static function user_has_permission( $needed_role ) {
705
-        if ( $needed_role == '-1' ) {
706
-            return false;
705
+		if ( $needed_role == '-1' ) {
706
+			return false;
707 707
 		}
708 708
 
709
-        // $needed_role will be equal to blank if "Logged-in users" is selected
710
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
711
-            return true;
712
-        }
709
+		// $needed_role will be equal to blank if "Logged-in users" is selected
710
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
711
+			return true;
712
+		}
713 713
 
714
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
715
-        foreach ( $roles as $role ) {
714
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
715
+		foreach ( $roles as $role ) {
716 716
 			if ( current_user_can( $role ) ) {
717
-        		return true;
717
+				return true;
718 718
 			}
719
-        	if ( $role == $needed_role ) {
720
-        		break;
719
+			if ( $role == $needed_role ) {
720
+				break;
721 721
 			}
722
-        }
723
-        return false;
724
-    }
725
-
726
-    /**
727
-     * Make sure administrators can see Formidable menu
728
-     *
729
-     * @since 2.0
730
-     */
731
-    public static function maybe_add_permissions() {
722
+		}
723
+		return false;
724
+	}
725
+
726
+	/**
727
+	 * Make sure administrators can see Formidable menu
728
+	 *
729
+	 * @since 2.0
730
+	 */
731
+	public static function maybe_add_permissions() {
732 732
 		self::force_capability( 'frm_view_entries' );
733 733
 
734 734
 		if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
@@ -737,12 +737,12 @@  discard block
 block discarded – undo
737 737
 
738 738
 		$user_id = get_current_user_id();
739 739
 		$user = new WP_User( $user_id );
740
-        $frm_roles = self::frm_capabilities();
741
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
740
+		$frm_roles = self::frm_capabilities();
741
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
742 742
 			$user->add_cap( $frm_role );
743 743
 			unset( $frm_role, $frm_role_description );
744
-        }
745
-    }
744
+		}
745
+	}
746 746
 
747 747
 	/**
748 748
 	 * Make sure admins have permission to see the menu items
@@ -758,28 +758,28 @@  discard block
 block discarded – undo
758 758
 		}
759 759
 	}
760 760
 
761
-    /**
762
-     * Check if the user has permision for action.
763
-     * Return permission message and stop the action if no permission
764
-     * @since 2.0
765
-     * @param string $permission
766
-     */
761
+	/**
762
+	 * Check if the user has permision for action.
763
+	 * Return permission message and stop the action if no permission
764
+	 * @since 2.0
765
+	 * @param string $permission
766
+	 */
767 767
 	public static function permission_check( $permission, $show_message = 'show' ) {
768 768
 		$permission_error = self::permission_nonce_error( $permission );
769
-        if ( $permission_error !== false ) {
770
-            if ( 'hide' == $show_message ) {
771
-                $permission_error = '';
772
-            }
769
+		if ( $permission_error !== false ) {
770
+			if ( 'hide' == $show_message ) {
771
+				$permission_error = '';
772
+			}
773 773
 			wp_die( esc_html( $permission_error ) );
774
-        }
775
-    }
776
-
777
-    /**
778
-     * Check user permission and nonce
779
-     * @since 2.0
780
-     * @param string $permission
781
-     * @return false|string The permission message or false if allowed
782
-     */
774
+		}
775
+	}
776
+
777
+	/**
778
+	 * Check user permission and nonce
779
+	 * @since 2.0
780
+	 * @param string $permission
781
+	 * @return false|string The permission message or false if allowed
782
+	 */
783 783
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
784 784
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
785 785
 			$frm_settings = self::get_settings();
@@ -788,22 +788,22 @@  discard block
 block discarded – undo
788 788
 
789 789
 		$error = false;
790 790
 		if ( empty( $nonce_name ) ) {
791
-            return $error;
792
-        }
791
+			return $error;
792
+		}
793 793
 
794
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
795
-            $frm_settings = self::get_settings();
796
-            $error = $frm_settings->admin_permission;
797
-        }
794
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
795
+			$frm_settings = self::get_settings();
796
+			$error = $frm_settings->admin_permission;
797
+		}
798 798
 
799
-        return $error;
800
-    }
799
+		return $error;
800
+	}
801 801
 
802
-    public static function checked( $values, $current ) {
802
+	public static function checked( $values, $current ) {
803 803
 		if ( self::check_selected( $values, $current ) ) {
804
-            echo ' checked="checked"';
804
+			echo ' checked="checked"';
805 805
 		}
806
-    }
806
+	}
807 807
 
808 808
 	public static function check_selected( $values, $current ) {
809 809
 		$values = self::recursive_function_map( $values, 'trim' );
@@ -841,24 +841,24 @@  discard block
 block discarded – undo
841 841
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
842 842
 	}
843 843
 
844
-    /**
845
-     * Flatten a multi-dimensional array
846
-     */
844
+	/**
845
+	 * Flatten a multi-dimensional array
846
+	 */
847 847
 	public static function array_flatten( $array, $keys = 'keep' ) {
848
-        $return = array();
849
-        foreach ( $array as $key => $value ) {
848
+		$return = array();
849
+		foreach ( $array as $key => $value ) {
850 850
 			if ( is_array( $value ) ) {
851 851
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
852
-            } else {
852
+			} else {
853 853
 				if ( $keys == 'keep' ) {
854 854
 					$return[ $key ] = $value;
855 855
 				} else {
856 856
 					$return[] = $value;
857 857
 				}
858
-            }
859
-        }
860
-        return $return;
861
-    }
858
+			}
859
+		}
860
+		return $return;
861
+	}
862 862
 
863 863
 	public static function esc_textarea( $text, $is_rich_text = false ) {
864 864
 		$safe_text = str_replace( '&quot;', '"', $text );
@@ -869,10 +869,10 @@  discard block
 block discarded – undo
869 869
 		return apply_filters( 'esc_textarea', $safe_text, $text );
870 870
 	}
871 871
 
872
-    /**
873
-     * Add auto paragraphs to text areas
874
-     * @since 2.0
875
-     */
872
+	/**
873
+	 * Add auto paragraphs to text areas
874
+	 * @since 2.0
875
+	 */
876 876
 	public static function use_wpautop( $content ) {
877 877
 		if ( apply_filters( 'frm_use_wpautop', true ) ) {
878 878
 			$content = wpautop( str_replace( '<br>', '<br />', $content ) );
@@ -881,26 +881,26 @@  discard block
 block discarded – undo
881 881
 	}
882 882
 
883 883
 	public static function replace_quotes( $val ) {
884
-        //Replace double quotes
884
+		//Replace double quotes
885 885
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
886
-        //Replace single quotes
887
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
888
-        return $val;
889
-    }
890
-
891
-    /**
892
-     * @since 2.0
893
-     * @return string The base Google APIS url for the current version of jQuery UI
894
-     */
895
-    public static function jquery_ui_base_url() {
886
+		//Replace single quotes
887
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
888
+		return $val;
889
+	}
890
+
891
+	/**
892
+	 * @since 2.0
893
+	 * @return string The base Google APIS url for the current version of jQuery UI
894
+	 */
895
+	public static function jquery_ui_base_url() {
896 896
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
897 897
 		$url = apply_filters( 'frm_jquery_ui_base_url', $url );
898
-        return $url;
899
-    }
898
+		return $url;
899
+	}
900 900
 
901
-    /**
902
-     * @param string $handle
903
-     */
901
+	/**
902
+	 * @param string $handle
903
+	 */
904 904
 	public static function script_version( $handle, $default = 0 ) {
905 905
 		global $wp_scripts;
906 906
 		if ( ! $wp_scripts ) {
@@ -922,12 +922,12 @@  discard block
 block discarded – undo
922 922
 
923 923
 	public static function js_redirect( $url ) {
924 924
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
925
-    }
925
+	}
926 926
 
927 927
 	public static function get_user_id_param( $user_id ) {
928 928
 		if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
929
-            return $user_id;
930
-        }
929
+			return $user_id;
930
+		}
931 931
 
932 932
 		$user_id = sanitize_text_field( $user_id );
933 933
 		if ( $user_id == 'current' ) {
@@ -939,14 +939,14 @@  discard block
 block discarded – undo
939 939
 				$user = get_user_by( 'login', $user_id );
940 940
 			}
941 941
 
942
-            if ( $user ) {
943
-                $user_id = $user->ID;
944
-            }
942
+			if ( $user ) {
943
+				$user_id = $user->ID;
944
+			}
945 945
 			unset( $user );
946
-        }
946
+		}
947 947
 
948
-        return $user_id;
949
-    }
948
+		return $user_id;
949
+	}
950 950
 
951 951
 	public static function get_file_contents( $filename, $atts = array() ) {
952 952
 		if ( ! is_file( $filename ) ) {
@@ -961,28 +961,28 @@  discard block
 block discarded – undo
961 961
 		return $contents;
962 962
 	}
963 963
 
964
-    /**
965
-     * @param string $table_name
966
-     * @param string $column
964
+	/**
965
+	 * @param string $table_name
966
+	 * @param string $column
967 967
 	 * @param int $id
968 968
 	 * @param int $num_chars
969
-     */
970
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
971
-        $key = '';
969
+	 */
970
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
971
+		$key = '';
972 972
 
973
-        if ( ! empty( $name ) ) {
973
+		if ( ! empty( $name ) ) {
974 974
 			$key = sanitize_key( $name );
975
-        }
975
+		}
976 976
 
977 977
 		if ( empty( $key ) ) {
978 978
 			$max_slug_value = pow( 36, $num_chars );
979
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
979
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
980 980
 			$key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
981
-        }
981
+		}
982 982
 
983 983
 		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
984 984
 			$key = $key . 'a';
985
-        }
985
+		}
986 986
 
987 987
 		$key_check = FrmDb::get_var( $table_name, array(
988 988
 			$column => $key,
@@ -990,7 +990,7 @@  discard block
 block discarded – undo
990 990
 		), $column );
991 991
 
992 992
 		if ( $key_check || is_numeric( $key_check ) ) {
993
-            $suffix = 2;
993
+			$suffix = 2;
994 994
 			do {
995 995
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
996 996
 				$key_check = FrmDb::get_var( $table_name, array(
@@ -1000,19 +1000,19 @@  discard block
 block discarded – undo
1000 1000
 				$suffix++;
1001 1001
 			} while ( $key_check || is_numeric( $key_check ) );
1002 1002
 			$key = $alt_post_name;
1003
-        }
1004
-        return $key;
1005
-    }
1006
-
1007
-    /**
1008
-     * Editing a Form or Entry
1009
-     * @param string $table
1010
-     * @return bool|array
1011
-     */
1012
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1013
-        if ( ! $record ) {
1014
-            return false;
1015
-        }
1003
+		}
1004
+		return $key;
1005
+	}
1006
+
1007
+	/**
1008
+	 * Editing a Form or Entry
1009
+	 * @param string $table
1010
+	 * @return bool|array
1011
+	 */
1012
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1013
+		if ( ! $record ) {
1014
+			return false;
1015
+		}
1016 1016
 
1017 1017
 		if ( empty( $post_values ) ) {
1018 1018
 			$post_values = stripslashes_deep( $_POST );
@@ -1035,14 +1035,14 @@  discard block
 block discarded – undo
1035 1035
 
1036 1036
 		self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) );
1037 1037
 
1038
-        if ( $table == 'entries' ) {
1039
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1040
-        } else if ( $table == 'forms' ) {
1041
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1042
-        }
1038
+		if ( $table == 'entries' ) {
1039
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1040
+		} else if ( $table == 'forms' ) {
1041
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1042
+		}
1043 1043
 
1044
-        return $values;
1045
-    }
1044
+		return $values;
1045
+	}
1046 1046
 
1047 1047
 	private static function prepare_field_arrays( $fields, $record, array &$values, $args ) {
1048 1048
 		if ( ! empty( $fields ) ) {
@@ -1055,46 +1055,46 @@  discard block
 block discarded – undo
1055 1055
 	}
1056 1056
 
1057 1057
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
1058
-        $post_values = $args['post_values'];
1058
+		$post_values = $args['post_values'];
1059 1059
 
1060
-        if ( $args['default'] ) {
1061
-            $meta_value = $field->default_value;
1062
-        } else {
1060
+		if ( $args['default'] ) {
1061
+			$meta_value = $field->default_value;
1062
+		} else {
1063 1063
 			if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
1064 1064
 				if ( ! isset( $field->field_options['custom_field'] ) ) {
1065
-                    $field->field_options['custom_field'] = '';
1066
-                }
1065
+					$field->field_options['custom_field'] = '';
1066
+				}
1067 1067
 				$meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array(
1068 1068
 					'truncate' => false,
1069 1069
 					'type' => $field->type,
1070 1070
 					'form_id' => $field->form_id,
1071 1071
 					'field' => $field,
1072 1072
 				) );
1073
-            } else {
1073
+			} else {
1074 1074
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1075
-            }
1076
-        }
1075
+			}
1076
+		}
1077 1077
 
1078 1078
 		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1079
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1079
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1080 1080
 
1081 1081
 		$field_array = self::start_field_array( $field );
1082 1082
 		$field_array['value'] = $new_value;
1083 1083
 		$field_array['type']  = apply_filters( 'frm_field_type', $field_type, $field, $new_value );
1084 1084
 		$field_array['parent_form_id'] = $args['parent_form_id'];
1085 1085
 
1086
-        $args['field_type'] = $field_type;
1086
+		$args['field_type'] = $field_type;
1087 1087
 
1088 1088
 		FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args );
1089 1089
 
1090 1090
 		if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1091
-            $field_array['unique_msg'] = '';
1092
-        }
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
 	/**
1100 1100
 	 * @since 3.0
@@ -1115,20 +1115,20 @@  discard block
 block discarded – undo
1115 1115
 		);
1116 1116
 	}
1117 1117
 
1118
-    /**
1119
-     * @param string $table
1120
-     */
1118
+	/**
1119
+	 * @param string $table
1120
+	 */
1121 1121
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1122
-        if ( $table == 'entries' ) {
1123
-            $form = $record->form_id;
1122
+		if ( $table == 'entries' ) {
1123
+			$form = $record->form_id;
1124 1124
 			FrmForm::maybe_get_form( $form );
1125
-        } else {
1126
-            $form = $record;
1127
-        }
1125
+		} else {
1126
+			$form = $record;
1127
+		}
1128 1128
 
1129
-        if ( ! $form ) {
1130
-            return;
1131
-        }
1129
+		if ( ! $form ) {
1130
+			return;
1131
+		}
1132 1132
 
1133 1133
 		$values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1134 1134
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
@@ -1137,26 +1137,26 @@  discard block
 block discarded – undo
1137 1137
 			return;
1138 1138
 		}
1139 1139
 
1140
-        foreach ( $form->options as $opt => $value ) {
1141
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1142
-        }
1140
+		foreach ( $form->options as $opt => $value ) {
1141
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1142
+		}
1143 1143
 
1144 1144
 		self::fill_form_defaults( $post_values, $values );
1145
-    }
1145
+	}
1146 1146
 
1147
-    /**
1148
-     * Set to POST value or default
1149
-     */
1147
+	/**
1148
+	 * Set to POST value or default
1149
+	 */
1150 1150
 	private static function fill_form_defaults( $post_values, array &$values ) {
1151
-        $form_defaults = FrmFormsHelper::get_default_opts();
1151
+		$form_defaults = FrmFormsHelper::get_default_opts();
1152 1152
 
1153
-        foreach ( $form_defaults as $opt => $default ) {
1154
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1153
+		foreach ( $form_defaults as $opt => $default ) {
1154
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1155 1155
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1156
-            }
1156
+			}
1157 1157
 
1158 1158
 			unset( $opt, $default );
1159
-        }
1159
+		}
1160 1160
 
1161 1161
 		if ( ! isset( $values['custom_style'] ) ) {
1162 1162
 			$values['custom_style'] = self::custom_style_value( $post_values );
@@ -1165,10 +1165,10 @@  discard block
 block discarded – undo
1165 1165
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1166 1166
 			if ( ! isset( $values[ $h . '_html' ] ) ) {
1167 1167
 				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1168
-            }
1168
+			}
1169 1169
 			unset( $h );
1170
-        }
1171
-    }
1170
+		}
1171
+	}
1172 1172
 
1173 1173
 	/**
1174 1174
 	 * @since 2.2.10
@@ -1191,33 +1191,33 @@  discard block
 block discarded – undo
1191 1191
 		if ( $possible_email_field ) {
1192 1192
 			$class .= 'show_frm_not_email_to';
1193 1193
 		}
1194
-    ?>
1194
+	?>
1195 1195
 <li>
1196 1196
 	<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>
1197 1197
 	<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>
1198 1198
 	<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>
1199 1199
 </li>
1200 1200
     <?php
1201
-    }
1201
+	}
1202 1202
 
1203 1203
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1204
-        if ( is_array( $str ) ) {
1205
-            return '';
1204
+		if ( is_array( $str ) ) {
1205
+			return '';
1206 1206
 		}
1207 1207
 
1208
-        $length = (int) $length;
1208
+		$length = (int) $length;
1209 1209
 		$str = wp_strip_all_tags( $str );
1210 1210
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1211 1211
 
1212 1212
 		if ( $length == 0 ) {
1213
-            return '';
1214
-        } else if ( $length <= 10 ) {
1213
+			return '';
1214
+		} else if ( $length <= 10 ) {
1215 1215
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1216 1216
 			return $sub . ( ( $length < $original_len ) ? $continue : '' );
1217
-        }
1217
+		}
1218 1218
 
1219
-        $sub = '';
1220
-        $len = 0;
1219
+		$sub = '';
1220
+		$len = 0;
1221 1221
 
1222 1222
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1223 1223
 
@@ -1225,21 +1225,21 @@  discard block
 block discarded – undo
1225 1225
 			$part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1226 1226
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1227 1227
 			if ( $total_len > $length && str_word_count( $sub ) ) {
1228
-                break;
1229
-            }
1228
+				break;
1229
+			}
1230 1230
 
1231
-            $sub .= $part;
1231
+			$sub .= $part;
1232 1232
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1233 1233
 
1234 1234
 			if ( str_word_count( $sub ) > $minword && $total_len >= $length ) {
1235
-                break;
1236
-            }
1235
+				break;
1236
+			}
1237 1237
 
1238 1238
 			unset( $total_len, $word );
1239
-        }
1239
+		}
1240 1240
 
1241 1241
 		return $sub . ( ( $len < $original_len ) ? $continue : '' );
1242
-    }
1242
+	}
1243 1243
 
1244 1244
 	public static function mb_function( $function_names, $args ) {
1245 1245
 		$mb_function_name = $function_names[0];
@@ -1252,17 +1252,17 @@  discard block
 block discarded – undo
1252 1252
 
1253 1253
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1254 1254
 		if ( empty( $date ) ) {
1255
-            return $date;
1256
-        }
1255
+			return $date;
1256
+		}
1257 1257
 
1258 1258
 		if ( empty( $date_format ) ) {
1259 1259
 			$date_format = get_option( 'date_format' );
1260 1260
 		}
1261 1261
 
1262 1262
 		if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1263
-            $frmpro_settings = new FrmProSettings();
1263
+			$frmpro_settings = new FrmProSettings();
1264 1264
 			$date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1265
-        }
1265
+		}
1266 1266
 
1267 1267
 		$formatted = self::get_localized_date( $date_format, $date );
1268 1268
 
@@ -1271,8 +1271,8 @@  discard block
 block discarded – undo
1271 1271
 			$formatted .= self::add_time_to_date( $time_format, $date );
1272 1272
 		}
1273 1273
 
1274
-        return $formatted;
1275
-    }
1274
+		return $formatted;
1275
+	}
1276 1276
 
1277 1277
 	private static function add_time_to_date( $time_format, $date ) {
1278 1278
 		if ( empty( $time_format ) ) {
@@ -1354,32 +1354,32 @@  discard block
 block discarded – undo
1354 1354
 		);
1355 1355
 	}
1356 1356
 
1357
-    // Pagination Methods
1357
+	// Pagination Methods
1358 1358
 
1359
-    /**
1360
-     * @param integer $current_p
1361
-     */
1359
+	/**
1360
+	 * @param integer $current_p
1361
+	 */
1362 1362
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1363 1363
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1364 1364
 	}
1365 1365
 
1366
-    /**
1367
-     * @param integer $current_p
1368
-     */
1369
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1370
-        if ( $current_p == 1 ) {
1371
-            return 1;
1372
-        } else {
1373
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1374
-        }
1375
-    }
1366
+	/**
1367
+	 * @param integer $current_p
1368
+	 */
1369
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1370
+		if ( $current_p == 1 ) {
1371
+			return 1;
1372
+		} else {
1373
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1374
+		}
1375
+	}
1376 1376
 
1377 1377
 	/**
1378 1378
 	 * @return array
1379 1379
 	 */
1380 1380
 	public static function json_to_array( $json_vars ) {
1381
-        $vars = array();
1382
-        foreach ( $json_vars as $jv ) {
1381
+		$vars = array();
1382
+		foreach ( $json_vars as $jv ) {
1383 1383
 			$jv_name = explode( '[', $jv['name'] );
1384 1384
 			$last = count( $jv_name ) - 1;
1385 1385
 			foreach ( $jv_name as $p => $n ) {
@@ -1396,77 +1396,77 @@  discard block
 block discarded – undo
1396 1396
 					$l3 = $name;
1397 1397
 				}
1398 1398
 
1399
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1399
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1400 1400
 
1401
-                switch ( $p ) {
1402
-                    case 0:
1403
-                        $l1 = $name;
1404
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1401
+				switch ( $p ) {
1402
+					case 0:
1403
+						$l1 = $name;
1404
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1405 1405
 						break;
1406 1406
 
1407
-                    case 1:
1408
-                        $l2 = $name;
1409
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1407
+					case 1:
1408
+						$l2 = $name;
1409
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1410 1410
 						break;
1411 1411
 
1412
-                    case 2:
1413
-                        $l3 = $name;
1414
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1412
+					case 2:
1413
+						$l3 = $name;
1414
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1415 1415
 						break;
1416 1416
 
1417
-                    case 3:
1418
-                        $l4 = $name;
1419
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1420
-                }
1417
+					case 3:
1418
+						$l4 = $name;
1419
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1420
+				}
1421 1421
 
1422 1422
 				unset( $this_val, $n );
1423
-            }
1423
+			}
1424 1424
 
1425 1425
 			unset( $last, $jv );
1426
-        }
1427
-
1428
-        return $vars;
1429
-    }
1430
-
1431
-    /**
1432
-     * @param string $name
1433
-     * @param string $l1
1434
-     */
1435
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1436
-        if ( $name == '' ) {
1437
-            $vars[] = $val;
1438
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1439
-            $vars[ $l1 ] = $val;
1440
-        }
1441
-    }
1426
+		}
1427
+
1428
+		return $vars;
1429
+	}
1430
+
1431
+	/**
1432
+	 * @param string $name
1433
+	 * @param string $l1
1434
+	 */
1435
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1436
+		if ( $name == '' ) {
1437
+			$vars[] = $val;
1438
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1439
+			$vars[ $l1 ] = $val;
1440
+		}
1441
+	}
1442 1442
 
1443 1443
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1444
-        $tooltips = array(
1445
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1446
-            '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' ),
1447
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1448
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1449
-            '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' ),
1450
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1451
-            '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() ) ),
1452
-        );
1453
-
1454
-        if ( ! isset( $tooltips[ $name ] ) ) {
1455
-            return;
1456
-        }
1457
-
1458
-        if ( 'open' == $class ) {
1459
-            echo ' frm_help"';
1460
-        } else {
1461
-            echo ' class="frm_help"';
1462
-        }
1444
+		$tooltips = array(
1445
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1446
+			'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' ),
1447
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1448
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1449
+			'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' ),
1450
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1451
+			'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() ) ),
1452
+		);
1453
+
1454
+		if ( ! isset( $tooltips[ $name ] ) ) {
1455
+			return;
1456
+		}
1457
+
1458
+		if ( 'open' == $class ) {
1459
+			echo ' frm_help"';
1460
+		} else {
1461
+			echo ' class="frm_help"';
1462
+		}
1463 1463
 
1464 1464
 		echo ' title="' . esc_attr( $tooltips[ $name ] );
1465 1465
 
1466
-        if ( 'open' != $class ) {
1467
-            echo '"';
1468
-        }
1469
-    }
1466
+		if ( 'open' != $class ) {
1467
+			echo '"';
1468
+		}
1469
+	}
1470 1470
 
1471 1471
 	/**
1472 1472
 	 * Add the current_page class to that page in the form nav
@@ -1482,35 +1482,35 @@  discard block
 block discarded – undo
1482 1482
 		}
1483 1483
 	}
1484 1484
 
1485
-    /**
1486
-     * Prepare and json_encode post content
1487
-     *
1488
-     * @since 2.0
1489
-     *
1490
-     * @param array $post_content
1491
-     * @return string $post_content ( json encoded array )
1492
-     */
1493
-    public static function prepare_and_encode( $post_content ) {
1494
-        //Loop through array to strip slashes and add only the needed ones
1485
+	/**
1486
+	 * Prepare and json_encode post content
1487
+	 *
1488
+	 * @since 2.0
1489
+	 *
1490
+	 * @param array $post_content
1491
+	 * @return string $post_content ( json encoded array )
1492
+	 */
1493
+	public static function prepare_and_encode( $post_content ) {
1494
+		//Loop through array to strip slashes and add only the needed ones
1495 1495
 		foreach ( $post_content as $key => $val ) {
1496 1496
 			// Replace problematic characters (like &quot;)
1497 1497
 			$val = str_replace( '&quot;', '"', $val );
1498 1498
 
1499 1499
 			self::prepare_action_slashes( $val, $key, $post_content );
1500
-            unset( $key, $val );
1501
-        }
1500
+			unset( $key, $val );
1501
+		}
1502 1502
 
1503
-        // json_encode the array
1504
-        $post_content = json_encode( $post_content );
1503
+		// json_encode the array
1504
+		$post_content = json_encode( $post_content );
1505 1505
 
1506
-	    // add extra slashes for \r\n since WP strips them
1506
+		// add extra slashes for \r\n since WP strips them
1507 1507
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1508 1508
 
1509
-        // allow for &quot
1510
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1509
+		// allow for &quot
1510
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1511 1511
 
1512
-        return $post_content;
1513
-    }
1512
+		return $post_content;
1513
+	}
1514 1514
 
1515 1515
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1516 1516
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1533,63 +1533,63 @@  discard block
 block discarded – undo
1533 1533
 
1534 1534
 	public static function maybe_json_decode( $string ) {
1535 1535
 		if ( is_array( $string ) ) {
1536
-            return $string;
1537
-        }
1536
+			return $string;
1537
+		}
1538 1538
 
1539 1539
 		$new_string = json_decode( $string, true );
1540 1540
 		if ( function_exists( 'json_last_error' ) ) {
1541 1541
 			// php 5.3+
1542
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1543
-                $string = $new_string;
1544
-            }
1542
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1543
+				$string = $new_string;
1544
+			}
1545 1545
 		} elseif ( isset( $new_string ) ) {
1546 1546
 			// php < 5.3 fallback
1547
-            $string = $new_string;
1548
-        }
1549
-        return $string;
1550
-    }
1551
-
1552
-    /**
1553
-     * @since 1.07.10
1554
-     *
1555
-     * @param string $post_type The name of the post type that may need to be highlighted
1556
-     * echo The javascript to open and highlight the Formidable menu
1557
-     */
1547
+			$string = $new_string;
1548
+		}
1549
+		return $string;
1550
+	}
1551
+
1552
+	/**
1553
+	 * @since 1.07.10
1554
+	 *
1555
+	 * @param string $post_type The name of the post type that may need to be highlighted
1556
+	 * echo The javascript to open and highlight the Formidable menu
1557
+	 */
1558 1558
 	public static function maybe_highlight_menu( $post_type ) {
1559
-        global $post;
1559
+		global $post;
1560 1560
 
1561 1561
 		if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1562
-            return;
1563
-        }
1562
+			return;
1563
+		}
1564 1564
 
1565 1565
 		if ( is_object( $post ) && $post->post_type != $post_type ) {
1566
-            return;
1567
-        }
1566
+			return;
1567
+		}
1568 1568
 
1569
-        self::load_admin_wide_js();
1570
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1571
-    }
1569
+		self::load_admin_wide_js();
1570
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1571
+	}
1572 1572
 
1573
-    /**
1574
-     * Load the JS file on non-Formidable pages in the admin area
1575
-     * @since 2.0
1576
-     */
1573
+	/**
1574
+	 * Load the JS file on non-Formidable pages in the admin area
1575
+	 * @since 2.0
1576
+	 */
1577 1577
 	public static function load_admin_wide_js( $load = true ) {
1578
-        $version = FrmAppHelper::plugin_version();
1578
+		$version = FrmAppHelper::plugin_version();
1579 1579
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1580 1580
 
1581
-        wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1581
+		wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1582 1582
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1583
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1583
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1584 1584
 			'url'          => FrmAppHelper::plugin_url(),
1585 1585
 			'loading'      => __( 'Loading&hellip;' ),
1586 1586
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
1587
-        ) );
1587
+		) );
1588 1588
 
1589 1589
 		if ( $load ) {
1590 1590
 			wp_enqueue_script( 'formidable_admin_global' );
1591 1591
 		}
1592
-    }
1592
+	}
1593 1593
 
1594 1594
 	/**
1595 1595
 	 * @since 2.0.9
@@ -1598,9 +1598,9 @@  discard block
 block discarded – undo
1598 1598
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1599 1599
 	}
1600 1600
 
1601
-    /**
1602
-     * @param string $location
1603
-     */
1601
+	/**
1602
+	 * @param string $location
1603
+	 */
1604 1604
 	public static function localize_script( $location ) {
1605 1605
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1606 1606
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1661,27 +1661,27 @@  discard block
 block discarded – undo
1661 1661
 		}
1662 1662
 	}
1663 1663
 
1664
-    /**
1664
+	/**
1665 1665
 	 * echo the message on the plugins listing page
1666
-     * @since 1.07.10
1667
-     *
1668
-     * @param float $min_version The version the add-on requires
1669
-     */
1666
+	 * @since 1.07.10
1667
+	 *
1668
+	 * @param float $min_version The version the add-on requires
1669
+	 */
1670 1670
 	public static function min_version_notice( $min_version ) {
1671
-        $frm_version = self::plugin_version();
1671
+		$frm_version = self::plugin_version();
1672 1672
 
1673
-        // check if Formidable meets minimum requirements
1673
+		// check if Formidable meets minimum requirements
1674 1674
 		if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1675
-            return;
1676
-        }
1675
+			return;
1676
+		}
1677 1677
 
1678 1678
 		$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1679 1679
 		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">' .
1680
-        esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1681
-        '</div></td></tr>';
1682
-    }
1680
+		esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1681
+		'</div></td></tr>';
1682
+	}
1683 1683
 
1684
-    public static function locales( $type = 'date' ) {
1684
+	public static function locales( $type = 'date' ) {
1685 1685
 		$locales = array(
1686 1686
 			'en' => __( 'English', 'formidable' ),
1687 1687
 			''   => __( 'English/Western', 'formidable' ),
@@ -1760,8 +1760,8 @@  discard block
 block discarded – undo
1760 1760
 		$locales = array_diff_key( $locales, array_flip( $unset ) );
1761 1761
 		$locales = apply_filters( 'frm_locales', $locales );
1762 1762
 
1763
-        return $locales;
1764
-    }
1763
+		return $locales;
1764
+	}
1765 1765
 
1766 1766
 	/**
1767 1767
 	 * Prepare and save settings in styles and actions
Please login to merge, or discard this patch.