Completed
Push — master ( f78dd2...073371 )
by Stephanie
03:36 queued 48s
created
classes/helpers/FrmAppHelper.php 1 patch
Indentation   +548 added lines, -548 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.06.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
 	}
@@ -107,14 +107,14 @@  discard block
 block discarded – undo
107 107
 		return add_query_arg( $query_args, $page ) . $anchor;
108 108
 	}
109 109
 
110
-    /**
111
-     * Get the Formidable settings
112
-     *
113
-     * @since 2.0
114
-     *
115
-     * @param array $args - May include the form id when values need translation.
116
-     * @return FrmSettings $frm_setings
117
-     */
110
+	/**
111
+	 * Get the Formidable settings
112
+	 *
113
+	 * @since 2.0
114
+	 *
115
+	 * @param array $args - May include the form id when values need translation.
116
+	 * @return FrmSettings $frm_setings
117
+	 */
118 118
 	public static function get_settings( $args = array() ) {
119 119
 		global $frm_settings;
120 120
 		if ( empty( $frm_settings ) ) {
@@ -179,50 +179,50 @@  discard block
 block discarded – undo
179 179
 		return $is_formidable;
180 180
 	}
181 181
 
182
-    /**
183
-     * Check for certain page in Formidable settings
184
-     *
185
-     * @since 2.0
186
-     *
187
-     * @param string $page The name of the page to check
188
-     * @return boolean
189
-     */
182
+	/**
183
+	 * Check for certain page in Formidable settings
184
+	 *
185
+	 * @since 2.0
186
+	 *
187
+	 * @param string $page The name of the page to check
188
+	 * @return boolean
189
+	 */
190 190
 	public static function is_admin_page( $page = 'formidable' ) {
191
-        global $pagenow;
191
+		global $pagenow;
192 192
 		$get_page = self::simple_get( 'page', 'sanitize_title' );
193
-        if ( $pagenow ) {
193
+		if ( $pagenow ) {
194 194
 			// allow this to be true during ajax load i.e. ajax form builder loading
195 195
 			return ( $pagenow == 'admin.php' || $pagenow == 'admin-ajax.php' ) && $get_page == $page;
196
-        }
196
+		}
197 197
 
198 198
 		return is_admin() && $get_page == $page;
199
-    }
200
-
201
-    /**
202
-     * Check for the form preview page
203
-     *
204
-     * @since 2.0
205
-     *
206
-     * @param None
207
-     * @return boolean
208
-     */
209
-    public static function is_preview_page() {
210
-        global $pagenow;
199
+	}
200
+
201
+	/**
202
+	 * Check for the form preview page
203
+	 *
204
+	 * @since 2.0
205
+	 *
206
+	 * @param None
207
+	 * @return boolean
208
+	 */
209
+	public static function is_preview_page() {
210
+		global $pagenow;
211 211
 		$action = self::simple_get( 'action', 'sanitize_title' );
212 212
 		return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
213
-    }
214
-
215
-    /**
216
-     * Check for ajax except the form preview page
217
-     *
218
-     * @since 2.0
219
-     *
220
-     * @param None
221
-     * @return boolean
222
-     */
223
-    public static function doing_ajax() {
224
-        return self::wp_doing_ajax() && ! self::is_preview_page();
225
-    }
213
+	}
214
+
215
+	/**
216
+	 * Check for ajax except the form preview page
217
+	 *
218
+	 * @since 2.0
219
+	 *
220
+	 * @param None
221
+	 * @return boolean
222
+	 */
223
+	public static function doing_ajax() {
224
+		return self::wp_doing_ajax() && ! self::is_preview_page();
225
+	}
226 226
 
227 227
 	public static function js_suffix() {
228 228
 		return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
@@ -250,81 +250,81 @@  discard block
 block discarded – undo
250 250
 		return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
251 251
 	}
252 252
 
253
-    /**
254
-     * Check if on an admin page
255
-     *
256
-     * @since 2.0
257
-     *
258
-     * @param None
259
-     * @return boolean
260
-     */
261
-    public static function is_admin() {
262
-        return is_admin() && ! self::wp_doing_ajax();
263
-    }
264
-
265
-    /**
266
-     * Check if value contains blank value or empty array
267
-     *
268
-     * @since 2.0
269
-     * @param mixed $value - value to check
253
+	/**
254
+	 * Check if on an admin page
255
+	 *
256
+	 * @since 2.0
257
+	 *
258
+	 * @param None
259
+	 * @return boolean
260
+	 */
261
+	public static function is_admin() {
262
+		return is_admin() && ! self::wp_doing_ajax();
263
+	}
264
+
265
+	/**
266
+	 * Check if value contains blank value or empty array
267
+	 *
268
+	 * @since 2.0
269
+	 * @param mixed $value - value to check
270 270
 	 * @param string
271
-     * @return boolean
272
-     */
273
-    public static function is_empty_value( $value, $empty = '' ) {
274
-        return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
275
-    }
276
-
277
-    public static function is_not_empty_value( $value, $empty = '' ) {
278
-        return ! self::is_empty_value( $value, $empty );
279
-    }
280
-
281
-    /**
282
-     * Get any value from the $_SERVER
283
-     *
284
-     * @since 2.0
285
-     * @param string $value
286
-     * @return string
287
-     */
271
+	 * @return boolean
272
+	 */
273
+	public static function is_empty_value( $value, $empty = '' ) {
274
+		return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
275
+	}
276
+
277
+	public static function is_not_empty_value( $value, $empty = '' ) {
278
+		return ! self::is_empty_value( $value, $empty );
279
+	}
280
+
281
+	/**
282
+	 * Get any value from the $_SERVER
283
+	 *
284
+	 * @since 2.0
285
+	 * @param string $value
286
+	 * @return string
287
+	 */
288 288
 	public static function get_server_value( $value ) {
289
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
290
-    }
291
-
292
-    /**
293
-     * Check for the IP address in several places
294
-     * Used by [ip] shortcode
295
-     *
296
-     * @return string The IP address of the current user
297
-     */
298
-    public static function get_ip_address() {
289
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
290
+	}
291
+
292
+	/**
293
+	 * Check for the IP address in several places
294
+	 * Used by [ip] shortcode
295
+	 *
296
+	 * @return string The IP address of the current user
297
+	 */
298
+	public static function get_ip_address() {
299 299
 		$ip = '';
300 300
 		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 ) {
301
-            if ( ! isset( $_SERVER[ $key ] ) ) {
302
-                continue;
303
-            }
301
+			if ( ! isset( $_SERVER[ $key ] ) ) {
302
+				continue;
303
+			}
304 304
 
305
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
305
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
306 306
 				$ip = trim( $ip ); // just to be safe
307 307
 
308 308
 				if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
309
-                    return sanitize_text_field( $ip );
310
-                }
311
-            }
312
-        }
309
+					return sanitize_text_field( $ip );
310
+				}
311
+			}
312
+		}
313 313
 
314 314
 		return sanitize_text_field( $ip );
315
-    }
315
+	}
316 316
 
317
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
317
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
318 318
 		if ( strpos( $param, '[' ) ) {
319 319
 			$params = explode( '[', $param );
320
-            $param = $params[0];
321
-        }
320
+			$param = $params[0];
321
+		}
322 322
 
323 323
 		if ( $src == 'get' ) {
324
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
325
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
326
-                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
327
-            }
324
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
325
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
326
+				$value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
327
+			}
328 328
 			self::sanitize_value( $sanitize, $value );
329 329
 		} else {
330 330
 			$value = self::get_simple_request(
@@ -348,8 +348,8 @@  discard block
 block discarded – undo
348 348
 			}
349 349
 		}
350 350
 
351
-        return $value;
352
-    }
351
+		return $value;
352
+	}
353 353
 
354 354
 	public static function get_post_param( $param, $default = '', $sanitize = '' ) {
355 355
 		return self::get_simple_request(
@@ -417,12 +417,12 @@  discard block
 block discarded – undo
417 417
 	}
418 418
 
419 419
 	/**
420
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
421
-	*
422
-	* @since 2.0.8
423
-	* @param string $value
424
-	* @return string $value
425
-	*/
420
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
421
+	 *
422
+	 * @since 2.0.8
423
+	 * @param string $value
424
+	 * @return string $value
425
+	 */
426 426
 	public static function preserve_backslashes( $value ) {
427 427
 		// If backslashes have already been added, don't add them again
428 428
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -444,14 +444,14 @@  discard block
 block discarded – undo
444 444
 		}
445 445
 	}
446 446
 
447
-    public static function sanitize_request( $sanitize_method, &$values ) {
448
-        $temp_values = $values;
449
-        foreach ( $temp_values as $k => $val ) {
450
-            if ( isset( $sanitize_method[ $k ] ) ) {
447
+	public static function sanitize_request( $sanitize_method, &$values ) {
448
+		$temp_values = $values;
449
+		foreach ( $temp_values as $k => $val ) {
450
+			if ( isset( $sanitize_method[ $k ] ) ) {
451 451
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
452
-            }
453
-        }
454
-    }
452
+			}
453
+		}
454
+	}
455 455
 
456 456
 	/**
457 457
 	 * Sanitize the value, and allow some HTML
@@ -588,40 +588,40 @@  discard block
 block discarded – undo
588 588
 		);
589 589
 	}
590 590
 
591
-    /**
592
-     * Used when switching the action for a bulk action
591
+	/**
592
+	 * Used when switching the action for a bulk action
593 593
 	 *
594
-     * @since 2.0
595
-     */
594
+	 * @since 2.0
595
+	 */
596 596
 	public static function remove_get_action() {
597 597
 		if ( ! isset( $_GET ) ) {
598 598
 			return;
599 599
 		}
600 600
 
601
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
602
-        if ( ! empty( $new_action ) ) {
601
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
602
+		if ( ! empty( $new_action ) ) {
603 603
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', self::get_server_value( 'REQUEST_URI' ) );
604
-        }
605
-    }
604
+		}
605
+	}
606 606
 
607
-    /**
608
-     * Check the WP query for a parameter
609
-     *
610
-     * @since 2.0
611
-     * @return string|array
612
-     */
613
-    public static function get_query_var( $value, $param ) {
614
-        if ( $value != '' ) {
615
-            return $value;
616
-        }
607
+	/**
608
+	 * Check the WP query for a parameter
609
+	 *
610
+	 * @since 2.0
611
+	 * @return string|array
612
+	 */
613
+	public static function get_query_var( $value, $param ) {
614
+		if ( $value != '' ) {
615
+			return $value;
616
+		}
617 617
 
618
-        global $wp_query;
619
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
620
-            $value = $wp_query->query_vars[ $param ];
621
-        }
618
+		global $wp_query;
619
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
620
+			$value = $wp_query->query_vars[ $param ];
621
+		}
622 622
 
623
-        return $value;
624
-    }
623
+		return $value;
624
+	}
625 625
 
626 626
 	/**
627 627
 	 * @since 3.0
@@ -673,16 +673,16 @@  discard block
 block discarded – undo
673 673
 		<?php
674 674
 	}
675 675
 
676
-    /**
677
-     * @param string $type
678
-     */
679
-    public static function trigger_hook_load( $type, $object = null ) {
680
-        // only load the form hooks once
676
+	/**
677
+	 * @param string $type
678
+	 */
679
+	public static function trigger_hook_load( $type, $object = null ) {
680
+		// only load the form hooks once
681 681
 		$hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
682
-        if ( ! $hooks_loaded ) {
682
+		if ( ! $hooks_loaded ) {
683 683
 			do_action( 'frm_load_' . $type . '_hooks' );
684
-        }
685
-    }
684
+		}
685
+	}
686 686
 
687 687
 	/**
688 688
 	 * Save all front-end js scripts into a single file
@@ -707,18 +707,18 @@  discard block
 block discarded – undo
707 707
 		$new_file->combine_files( $files );
708 708
 	}
709 709
 
710
-    /**
711
-     * Check a value from a shortcode to see if true or false.
712
-     * True when value is 1, true, 'true', 'yes'
713
-     *
714
-     * @since 1.07.10
715
-     *
716
-     * @param string $value The value to compare
717
-     * @return boolean True or False
718
-     */
710
+	/**
711
+	 * Check a value from a shortcode to see if true or false.
712
+	 * True when value is 1, true, 'true', 'yes'
713
+	 *
714
+	 * @since 1.07.10
715
+	 *
716
+	 * @param string $value The value to compare
717
+	 * @return boolean True or False
718
+	 */
719 719
 	public static function is_true( $value ) {
720
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
721
-    }
720
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
721
+	}
722 722
 
723 723
 	public static function get_pages() {
724 724
 		$query = array(
@@ -731,10 +731,10 @@  discard block
 block discarded – undo
731 731
 		return get_posts( $query );
732 732
 	}
733 733
 
734
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
735
-        $pages = self::get_pages();
734
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
735
+		$pages = self::get_pages();
736 736
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
737
-    ?>
737
+	?>
738 738
 		<select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
739 739
             <option value=""> </option>
740 740
             <?php foreach ( $pages as $page ) { ?>
@@ -744,16 +744,16 @@  discard block
 block discarded – undo
744 744
             <?php } ?>
745 745
         </select>
746 746
     <?php
747
-    }
747
+	}
748 748
 
749 749
 	public static function post_edit_link( $post_id ) {
750 750
 		$post = get_post( $post_id );
751
-        if ( $post ) {
751
+		if ( $post ) {
752 752
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
753 753
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
754
-        }
755
-        return '';
756
-    }
754
+		}
755
+		return '';
756
+	}
757 757
 
758 758
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
759 759
 		?>
@@ -764,73 +764,73 @@  discard block
 block discarded – undo
764 764
 	}
765 765
 
766 766
 	public static function roles_options( $capability ) {
767
-        global $frm_vars;
767
+		global $frm_vars;
768 768
 		if ( isset( $frm_vars['editable_roles'] ) ) {
769
-            $editable_roles = $frm_vars['editable_roles'];
770
-        } else {
771
-            $editable_roles = get_editable_roles();
772
-            $frm_vars['editable_roles'] = $editable_roles;
773
-        }
769
+			$editable_roles = $frm_vars['editable_roles'];
770
+		} else {
771
+			$editable_roles = get_editable_roles();
772
+			$frm_vars['editable_roles'] = $editable_roles;
773
+		}
774 774
 
775
-        foreach ( $editable_roles as $role => $details ) {
775
+		foreach ( $editable_roles as $role => $details ) {
776 776
 			$name = translate_user_role( $details['name'] );
777 777
 			?>
778 778
 		<option value="<?php echo esc_attr( $role ); ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ); ?> </option>
779 779
 <?php
780 780
 			unset( $role, $details );
781
-        }
782
-    }
781
+		}
782
+	}
783 783
 
784 784
 	public static function frm_capabilities( $type = 'auto' ) {
785
-        $cap = array(
786
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
787
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
788
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
789
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
790
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
791
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
792
-        );
785
+		$cap = array(
786
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
787
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
788
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
789
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
790
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
791
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
792
+		);
793 793
 
794 794
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
795
-            return $cap;
796
-        }
795
+			return $cap;
796
+		}
797 797
 
798
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
799
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
800
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
801
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
798
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
799
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
800
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
801
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
802 802
 
803
-        return $cap;
804
-    }
803
+		return $cap;
804
+	}
805 805
 
806 806
 	public static function user_has_permission( $needed_role ) {
807
-        if ( $needed_role == '-1' ) {
808
-            return false;
807
+		if ( $needed_role == '-1' ) {
808
+			return false;
809 809
 		}
810 810
 
811
-        // $needed_role will be equal to blank if "Logged-in users" is selected
812
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
813
-            return true;
814
-        }
811
+		// $needed_role will be equal to blank if "Logged-in users" is selected
812
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
813
+			return true;
814
+		}
815 815
 
816
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
817
-        foreach ( $roles as $role ) {
816
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
817
+		foreach ( $roles as $role ) {
818 818
 			if ( current_user_can( $role ) ) {
819
-        		return true;
819
+				return true;
820 820
 			}
821
-        	if ( $role == $needed_role ) {
822
-        		break;
821
+			if ( $role == $needed_role ) {
822
+				break;
823 823
 			}
824
-        }
825
-        return false;
826
-    }
827
-
828
-    /**
829
-     * Make sure administrators can see Formidable menu
830
-     *
831
-     * @since 2.0
832
-     */
833
-    public static function maybe_add_permissions() {
824
+		}
825
+		return false;
826
+	}
827
+
828
+	/**
829
+	 * Make sure administrators can see Formidable menu
830
+	 *
831
+	 * @since 2.0
832
+	 */
833
+	public static function maybe_add_permissions() {
834 834
 		self::force_capability( 'frm_view_entries' );
835 835
 
836 836
 		if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
@@ -839,12 +839,12 @@  discard block
 block discarded – undo
839 839
 
840 840
 		$user_id = get_current_user_id();
841 841
 		$user = new WP_User( $user_id );
842
-        $frm_roles = self::frm_capabilities();
843
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
842
+		$frm_roles = self::frm_capabilities();
843
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
844 844
 			$user->add_cap( $frm_role );
845 845
 			unset( $frm_role, $frm_role_description );
846
-        }
847
-    }
846
+		}
847
+	}
848 848
 
849 849
 	/**
850 850
 	 * Make sure admins have permission to see the menu items
@@ -861,30 +861,30 @@  discard block
 block discarded – undo
861 861
 		}
862 862
 	}
863 863
 
864
-    /**
865
-     * Check if the user has permision for action.
866
-     * Return permission message and stop the action if no permission
864
+	/**
865
+	 * Check if the user has permision for action.
866
+	 * Return permission message and stop the action if no permission
867 867
 	 *
868
-     * @since 2.0
869
-     * @param string $permission
870
-     */
868
+	 * @since 2.0
869
+	 * @param string $permission
870
+	 */
871 871
 	public static function permission_check( $permission, $show_message = 'show' ) {
872 872
 		$permission_error = self::permission_nonce_error( $permission );
873
-        if ( $permission_error !== false ) {
874
-            if ( 'hide' == $show_message ) {
875
-                $permission_error = '';
876
-            }
873
+		if ( $permission_error !== false ) {
874
+			if ( 'hide' == $show_message ) {
875
+				$permission_error = '';
876
+			}
877 877
 			wp_die( esc_html( $permission_error ) );
878
-        }
879
-    }
878
+		}
879
+	}
880 880
 
881
-    /**
882
-     * Check user permission and nonce
881
+	/**
882
+	 * Check user permission and nonce
883 883
 	 *
884
-     * @since 2.0
885
-     * @param string $permission
886
-     * @return false|string The permission message or false if allowed
887
-     */
884
+	 * @since 2.0
885
+	 * @param string $permission
886
+	 * @return false|string The permission message or false if allowed
887
+	 */
888 888
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
889 889
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
890 890
 			$frm_settings = self::get_settings();
@@ -893,22 +893,22 @@  discard block
 block discarded – undo
893 893
 
894 894
 		$error = false;
895 895
 		if ( empty( $nonce_name ) ) {
896
-            return $error;
897
-        }
896
+			return $error;
897
+		}
898 898
 
899
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
900
-            $frm_settings = self::get_settings();
901
-            $error = $frm_settings->admin_permission;
902
-        }
899
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
900
+			$frm_settings = self::get_settings();
901
+			$error = $frm_settings->admin_permission;
902
+		}
903 903
 
904
-        return $error;
905
-    }
904
+		return $error;
905
+	}
906 906
 
907
-    public static function checked( $values, $current ) {
907
+	public static function checked( $values, $current ) {
908 908
 		if ( self::check_selected( $values, $current ) ) {
909
-            echo ' checked="checked"';
909
+			echo ' checked="checked"';
910 910
 		}
911
-    }
911
+	}
912 912
 
913 913
 	public static function check_selected( $values, $current ) {
914 914
 		$values = self::recursive_function_map( $values, 'trim' );
@@ -946,24 +946,24 @@  discard block
 block discarded – undo
946 946
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
947 947
 	}
948 948
 
949
-    /**
950
-     * Flatten a multi-dimensional array
951
-     */
949
+	/**
950
+	 * Flatten a multi-dimensional array
951
+	 */
952 952
 	public static function array_flatten( $array, $keys = 'keep' ) {
953
-        $return = array();
954
-        foreach ( $array as $key => $value ) {
953
+		$return = array();
954
+		foreach ( $array as $key => $value ) {
955 955
 			if ( is_array( $value ) ) {
956 956
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
957
-            } else {
957
+			} else {
958 958
 				if ( $keys == 'keep' ) {
959 959
 					$return[ $key ] = $value;
960 960
 				} else {
961 961
 					$return[] = $value;
962 962
 				}
963
-            }
964
-        }
965
-        return $return;
966
-    }
963
+			}
964
+		}
965
+		return $return;
966
+	}
967 967
 
968 968
 	public static function esc_textarea( $text, $is_rich_text = false ) {
969 969
 		$safe_text = str_replace( '&quot;', '"', $text );
@@ -974,11 +974,11 @@  discard block
 block discarded – undo
974 974
 		return apply_filters( 'esc_textarea', $safe_text, $text );
975 975
 	}
976 976
 
977
-    /**
978
-     * Add auto paragraphs to text areas
977
+	/**
978
+	 * Add auto paragraphs to text areas
979 979
 	 *
980
-     * @since 2.0
981
-     */
980
+	 * @since 2.0
981
+	 */
982 982
 	public static function use_wpautop( $content ) {
983 983
 		if ( apply_filters( 'frm_use_wpautop', true ) ) {
984 984
 			$content = wpautop( str_replace( '<br>', '<br />', $content ) );
@@ -987,26 +987,26 @@  discard block
 block discarded – undo
987 987
 	}
988 988
 
989 989
 	public static function replace_quotes( $val ) {
990
-        //Replace double quotes
990
+		//Replace double quotes
991 991
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
992
-        //Replace single quotes
993
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
994
-        return $val;
995
-    }
996
-
997
-    /**
998
-     * @since 2.0
999
-     * @return string The base Google APIS url for the current version of jQuery UI
1000
-     */
1001
-    public static function jquery_ui_base_url() {
992
+		//Replace single quotes
993
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
994
+		return $val;
995
+	}
996
+
997
+	/**
998
+	 * @since 2.0
999
+	 * @return string The base Google APIS url for the current version of jQuery UI
1000
+	 */
1001
+	public static function jquery_ui_base_url() {
1002 1002
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
1003 1003
 		$url = apply_filters( 'frm_jquery_ui_base_url', $url );
1004
-        return $url;
1005
-    }
1004
+		return $url;
1005
+	}
1006 1006
 
1007
-    /**
1008
-     * @param string $handle
1009
-     */
1007
+	/**
1008
+	 * @param string $handle
1009
+	 */
1010 1010
 	public static function script_version( $handle, $default = 0 ) {
1011 1011
 		global $wp_scripts;
1012 1012
 		if ( ! $wp_scripts ) {
@@ -1028,12 +1028,12 @@  discard block
 block discarded – undo
1028 1028
 
1029 1029
 	public static function js_redirect( $url ) {
1030 1030
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
1031
-    }
1031
+	}
1032 1032
 
1033 1033
 	public static function get_user_id_param( $user_id ) {
1034 1034
 		if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
1035
-            return $user_id;
1036
-        }
1035
+			return $user_id;
1036
+		}
1037 1037
 
1038 1038
 		$user_id = sanitize_text_field( $user_id );
1039 1039
 		if ( $user_id == 'current' ) {
@@ -1045,14 +1045,14 @@  discard block
 block discarded – undo
1045 1045
 				$user = get_user_by( 'login', $user_id );
1046 1046
 			}
1047 1047
 
1048
-            if ( $user ) {
1049
-                $user_id = $user->ID;
1050
-            }
1048
+			if ( $user ) {
1049
+				$user_id = $user->ID;
1050
+			}
1051 1051
 			unset( $user );
1052
-        }
1052
+		}
1053 1053
 
1054
-        return $user_id;
1055
-    }
1054
+		return $user_id;
1055
+	}
1056 1056
 
1057 1057
 	public static function get_file_contents( $filename, $atts = array() ) {
1058 1058
 		if ( ! is_file( $filename ) ) {
@@ -1067,28 +1067,28 @@  discard block
 block discarded – undo
1067 1067
 		return $contents;
1068 1068
 	}
1069 1069
 
1070
-    /**
1071
-     * @param string $table_name
1072
-     * @param string $column
1070
+	/**
1071
+	 * @param string $table_name
1072
+	 * @param string $column
1073 1073
 	 * @param int $id
1074 1074
 	 * @param int $num_chars
1075
-     */
1076
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
1077
-        $key = '';
1075
+	 */
1076
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
1077
+		$key = '';
1078 1078
 
1079
-        if ( ! empty( $name ) ) {
1079
+		if ( ! empty( $name ) ) {
1080 1080
 			$key = sanitize_key( $name );
1081
-        }
1081
+		}
1082 1082
 
1083 1083
 		if ( empty( $key ) ) {
1084 1084
 			$max_slug_value = pow( 36, $num_chars );
1085
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
1085
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
1086 1086
 			$key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
1087
-        }
1087
+		}
1088 1088
 
1089 1089
 		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
1090 1090
 			$key = $key . 'a';
1091
-        }
1091
+		}
1092 1092
 
1093 1093
 		$key_check = FrmDb::get_var(
1094 1094
 			$table_name,
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
 		);
1101 1101
 
1102 1102
 		if ( $key_check || is_numeric( $key_check ) ) {
1103
-            $suffix = 2;
1103
+			$suffix = 2;
1104 1104
 			do {
1105 1105
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
1106 1106
 				$key_check = FrmDb::get_var(
@@ -1114,20 +1114,20 @@  discard block
 block discarded – undo
1114 1114
 				$suffix++;
1115 1115
 			} while ( $key_check || is_numeric( $key_check ) );
1116 1116
 			$key = $alt_post_name;
1117
-        }
1118
-        return $key;
1119
-    }
1117
+		}
1118
+		return $key;
1119
+	}
1120 1120
 
1121
-    /**
1122
-     * Editing a Form or Entry
1121
+	/**
1122
+	 * Editing a Form or Entry
1123 1123
 	 *
1124
-     * @param string $table
1125
-     * @return bool|array
1126
-     */
1127
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1128
-        if ( ! $record ) {
1129
-            return false;
1130
-        }
1124
+	 * @param string $table
1125
+	 * @return bool|array
1126
+	 */
1127
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1128
+		if ( ! $record ) {
1129
+			return false;
1130
+		}
1131 1131
 
1132 1132
 		if ( empty( $post_values ) ) {
1133 1133
 			$post_values = stripslashes_deep( $_POST );
@@ -1150,14 +1150,14 @@  discard block
 block discarded – undo
1150 1150
 
1151 1151
 		self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) );
1152 1152
 
1153
-        if ( $table == 'entries' ) {
1154
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1155
-        } else if ( $table == 'forms' ) {
1156
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1157
-        }
1153
+		if ( $table == 'entries' ) {
1154
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1155
+		} else if ( $table == 'forms' ) {
1156
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1157
+		}
1158 1158
 
1159
-        return $values;
1160
-    }
1159
+		return $values;
1160
+	}
1161 1161
 
1162 1162
 	private static function prepare_field_arrays( $fields, $record, array &$values, $args ) {
1163 1163
 		if ( ! empty( $fields ) ) {
@@ -1170,15 +1170,15 @@  discard block
 block discarded – undo
1170 1170
 	}
1171 1171
 
1172 1172
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
1173
-        $post_values = $args['post_values'];
1173
+		$post_values = $args['post_values'];
1174 1174
 
1175
-        if ( $args['default'] ) {
1176
-            $meta_value = $field->default_value;
1177
-        } else {
1175
+		if ( $args['default'] ) {
1176
+			$meta_value = $field->default_value;
1177
+		} else {
1178 1178
 			if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
1179 1179
 				if ( ! isset( $field->field_options['custom_field'] ) ) {
1180
-                    $field->field_options['custom_field'] = '';
1181
-                }
1180
+					$field->field_options['custom_field'] = '';
1181
+				}
1182 1182
 				$meta_value = FrmProEntryMetaHelper::get_post_value(
1183 1183
 					$record->post_id,
1184 1184
 					$field->field_options['post_field'],
@@ -1190,31 +1190,31 @@  discard block
 block discarded – undo
1190 1190
 						'field' => $field,
1191 1191
 					)
1192 1192
 				);
1193
-            } else {
1193
+			} else {
1194 1194
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1195
-            }
1196
-        }
1195
+			}
1196
+		}
1197 1197
 
1198 1198
 		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1199
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1199
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1200 1200
 
1201 1201
 		$field_array = self::start_field_array( $field );
1202 1202
 		$field_array['value'] = $new_value;
1203 1203
 		$field_array['type']  = apply_filters( 'frm_field_type', $field_type, $field, $new_value );
1204 1204
 		$field_array['parent_form_id'] = $args['parent_form_id'];
1205 1205
 
1206
-        $args['field_type'] = $field_type;
1206
+		$args['field_type'] = $field_type;
1207 1207
 
1208 1208
 		FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args );
1209 1209
 
1210 1210
 		if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1211
-            $field_array['unique_msg'] = '';
1212
-        }
1211
+			$field_array['unique_msg'] = '';
1212
+		}
1213 1213
 
1214
-        $field_array = array_merge( $field->field_options, $field_array );
1214
+		$field_array = array_merge( $field->field_options, $field_array );
1215 1215
 
1216
-        $values['fields'][ $field->id ] = $field_array;
1217
-    }
1216
+		$values['fields'][ $field->id ] = $field_array;
1217
+	}
1218 1218
 
1219 1219
 	/**
1220 1220
 	 * @since 3.0
@@ -1235,20 +1235,20 @@  discard block
 block discarded – undo
1235 1235
 		);
1236 1236
 	}
1237 1237
 
1238
-    /**
1239
-     * @param string $table
1240
-     */
1238
+	/**
1239
+	 * @param string $table
1240
+	 */
1241 1241
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1242
-        if ( $table == 'entries' ) {
1243
-            $form = $record->form_id;
1242
+		if ( $table == 'entries' ) {
1243
+			$form = $record->form_id;
1244 1244
 			FrmForm::maybe_get_form( $form );
1245
-        } else {
1246
-            $form = $record;
1247
-        }
1245
+		} else {
1246
+			$form = $record;
1247
+		}
1248 1248
 
1249
-        if ( ! $form ) {
1250
-            return;
1251
-        }
1249
+		if ( ! $form ) {
1250
+			return;
1251
+		}
1252 1252
 
1253 1253
 		$values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1254 1254
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
@@ -1257,26 +1257,26 @@  discard block
 block discarded – undo
1257 1257
 			return;
1258 1258
 		}
1259 1259
 
1260
-        foreach ( $form->options as $opt => $value ) {
1261
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1262
-        }
1260
+		foreach ( $form->options as $opt => $value ) {
1261
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1262
+		}
1263 1263
 
1264 1264
 		self::fill_form_defaults( $post_values, $values );
1265
-    }
1265
+	}
1266 1266
 
1267
-    /**
1268
-     * Set to POST value or default
1269
-     */
1267
+	/**
1268
+	 * Set to POST value or default
1269
+	 */
1270 1270
 	private static function fill_form_defaults( $post_values, array &$values ) {
1271
-        $form_defaults = FrmFormsHelper::get_default_opts();
1271
+		$form_defaults = FrmFormsHelper::get_default_opts();
1272 1272
 
1273
-        foreach ( $form_defaults as $opt => $default ) {
1274
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1273
+		foreach ( $form_defaults as $opt => $default ) {
1274
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1275 1275
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1276
-            }
1276
+			}
1277 1277
 
1278 1278
 			unset( $opt, $default );
1279
-        }
1279
+		}
1280 1280
 
1281 1281
 		if ( ! isset( $values['custom_style'] ) ) {
1282 1282
 			$values['custom_style'] = self::custom_style_value( $post_values );
@@ -1285,10 +1285,10 @@  discard block
 block discarded – undo
1285 1285
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1286 1286
 			if ( ! isset( $values[ $h . '_html' ] ) ) {
1287 1287
 				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1288
-            }
1288
+			}
1289 1289
 			unset( $h );
1290
-        }
1291
-    }
1290
+		}
1291
+	}
1292 1292
 
1293 1293
 	/**
1294 1294
 	 * @since 2.2.10
@@ -1311,33 +1311,33 @@  discard block
 block discarded – undo
1311 1311
 		if ( $possible_email_field ) {
1312 1312
 			$class .= 'show_frm_not_email_to';
1313 1313
 		}
1314
-    ?>
1314
+	?>
1315 1315
 <li>
1316 1316
 	<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>
1317 1317
 	<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>
1318 1318
 	<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>
1319 1319
 </li>
1320 1320
     <?php
1321
-    }
1321
+	}
1322 1322
 
1323 1323
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1324
-        if ( is_array( $str ) ) {
1325
-            return '';
1324
+		if ( is_array( $str ) ) {
1325
+			return '';
1326 1326
 		}
1327 1327
 
1328
-        $length = (int) $length;
1328
+		$length = (int) $length;
1329 1329
 		$str = wp_strip_all_tags( $str );
1330 1330
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1331 1331
 
1332 1332
 		if ( $length == 0 ) {
1333
-            return '';
1334
-        } else if ( $length <= 10 ) {
1333
+			return '';
1334
+		} else if ( $length <= 10 ) {
1335 1335
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1336 1336
 			return $sub . ( ( $length < $original_len ) ? $continue : '' );
1337
-        }
1337
+		}
1338 1338
 
1339
-        $sub = '';
1340
-        $len = 0;
1339
+		$sub = '';
1340
+		$len = 0;
1341 1341
 
1342 1342
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1343 1343
 
@@ -1345,21 +1345,21 @@  discard block
 block discarded – undo
1345 1345
 			$part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1346 1346
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1347 1347
 			if ( $total_len > $length && substr_count( $sub, ' ' ) ) {
1348
-                break;
1349
-            }
1348
+				break;
1349
+			}
1350 1350
 
1351
-            $sub .= $part;
1351
+			$sub .= $part;
1352 1352
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1353 1353
 
1354 1354
 			if ( substr_count( $sub, ' ' ) > $minword && $total_len >= $length ) {
1355
-                break;
1356
-            }
1355
+				break;
1356
+			}
1357 1357
 
1358 1358
 			unset( $total_len, $word );
1359
-        }
1359
+		}
1360 1360
 
1361 1361
 		return $sub . ( ( $len < $original_len ) ? $continue : '' );
1362
-    }
1362
+	}
1363 1363
 
1364 1364
 	public static function mb_function( $function_names, $args ) {
1365 1365
 		$mb_function_name = $function_names[0];
@@ -1372,17 +1372,17 @@  discard block
 block discarded – undo
1372 1372
 
1373 1373
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1374 1374
 		if ( empty( $date ) ) {
1375
-            return $date;
1376
-        }
1375
+			return $date;
1376
+		}
1377 1377
 
1378 1378
 		if ( empty( $date_format ) ) {
1379 1379
 			$date_format = get_option( 'date_format' );
1380 1380
 		}
1381 1381
 
1382 1382
 		if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1383
-            $frmpro_settings = new FrmProSettings();
1383
+			$frmpro_settings = new FrmProSettings();
1384 1384
 			$date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1385
-        }
1385
+		}
1386 1386
 
1387 1387
 		$formatted = self::get_localized_date( $date_format, $date );
1388 1388
 
@@ -1391,8 +1391,8 @@  discard block
 block discarded – undo
1391 1391
 			$formatted .= self::add_time_to_date( $time_format, $date );
1392 1392
 		}
1393 1393
 
1394
-        return $formatted;
1395
-    }
1394
+		return $formatted;
1395
+	}
1396 1396
 
1397 1397
 	private static function add_time_to_date( $time_format, $date ) {
1398 1398
 		if ( empty( $time_format ) ) {
@@ -1474,32 +1474,32 @@  discard block
 block discarded – undo
1474 1474
 		);
1475 1475
 	}
1476 1476
 
1477
-    // Pagination Methods
1477
+	// Pagination Methods
1478 1478
 
1479
-    /**
1480
-     * @param integer $current_p
1481
-     */
1479
+	/**
1480
+	 * @param integer $current_p
1481
+	 */
1482 1482
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1483 1483
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1484 1484
 	}
1485 1485
 
1486
-    /**
1487
-     * @param integer $current_p
1488
-     */
1489
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1490
-        if ( $current_p == 1 ) {
1491
-            return 1;
1492
-        } else {
1493
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1494
-        }
1495
-    }
1486
+	/**
1487
+	 * @param integer $current_p
1488
+	 */
1489
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1490
+		if ( $current_p == 1 ) {
1491
+			return 1;
1492
+		} else {
1493
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1494
+		}
1495
+	}
1496 1496
 
1497 1497
 	/**
1498 1498
 	 * @return array
1499 1499
 	 */
1500 1500
 	public static function json_to_array( $json_vars ) {
1501
-        $vars = array();
1502
-        foreach ( $json_vars as $jv ) {
1501
+		$vars = array();
1502
+		foreach ( $json_vars as $jv ) {
1503 1503
 			$jv_name = explode( '[', $jv['name'] );
1504 1504
 			$last = count( $jv_name ) - 1;
1505 1505
 			foreach ( $jv_name as $p => $n ) {
@@ -1516,77 +1516,77 @@  discard block
 block discarded – undo
1516 1516
 					$l3 = $name;
1517 1517
 				}
1518 1518
 
1519
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1519
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1520 1520
 
1521
-                switch ( $p ) {
1522
-                    case 0:
1523
-                        $l1 = $name;
1524
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1521
+				switch ( $p ) {
1522
+					case 0:
1523
+						$l1 = $name;
1524
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1525 1525
 						break;
1526 1526
 
1527
-                    case 1:
1528
-                        $l2 = $name;
1529
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1527
+					case 1:
1528
+						$l2 = $name;
1529
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1530 1530
 						break;
1531 1531
 
1532
-                    case 2:
1533
-                        $l3 = $name;
1534
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1532
+					case 2:
1533
+						$l3 = $name;
1534
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1535 1535
 						break;
1536 1536
 
1537
-                    case 3:
1538
-                        $l4 = $name;
1539
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1540
-                }
1537
+					case 3:
1538
+						$l4 = $name;
1539
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1540
+				}
1541 1541
 
1542 1542
 				unset( $this_val, $n );
1543
-            }
1543
+			}
1544 1544
 
1545 1545
 			unset( $last, $jv );
1546
-        }
1547
-
1548
-        return $vars;
1549
-    }
1550
-
1551
-    /**
1552
-     * @param string $name
1553
-     * @param string $l1
1554
-     */
1555
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1556
-        if ( $name == '' ) {
1557
-            $vars[] = $val;
1558
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1559
-            $vars[ $l1 ] = $val;
1560
-        }
1561
-    }
1546
+		}
1547
+
1548
+		return $vars;
1549
+	}
1550
+
1551
+	/**
1552
+	 * @param string $name
1553
+	 * @param string $l1
1554
+	 */
1555
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1556
+		if ( $name == '' ) {
1557
+			$vars[] = $val;
1558
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1559
+			$vars[ $l1 ] = $val;
1560
+		}
1561
+	}
1562 1562
 
1563 1563
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1564
-        $tooltips = array(
1565
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1566
-            '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' ),
1567
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1568
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1569
-            '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' ),
1570
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1571
-            '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() ) ),
1572
-        );
1573
-
1574
-        if ( ! isset( $tooltips[ $name ] ) ) {
1575
-            return;
1576
-        }
1577
-
1578
-        if ( 'open' == $class ) {
1579
-            echo ' frm_help"';
1580
-        } else {
1581
-            echo ' class="frm_help"';
1582
-        }
1564
+		$tooltips = array(
1565
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1566
+			'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' ),
1567
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1568
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1569
+			'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' ),
1570
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1571
+			'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() ) ),
1572
+		);
1573
+
1574
+		if ( ! isset( $tooltips[ $name ] ) ) {
1575
+			return;
1576
+		}
1577
+
1578
+		if ( 'open' == $class ) {
1579
+			echo ' frm_help"';
1580
+		} else {
1581
+			echo ' class="frm_help"';
1582
+		}
1583 1583
 
1584 1584
 		echo ' title="' . esc_attr( $tooltips[ $name ] );
1585 1585
 
1586
-        if ( 'open' != $class ) {
1587
-            echo '"';
1588
-        }
1589
-    }
1586
+		if ( 'open' != $class ) {
1587
+			echo '"';
1588
+		}
1589
+	}
1590 1590
 
1591 1591
 	/**
1592 1592
 	 * Add the current_page class to that page in the form nav
@@ -1602,35 +1602,35 @@  discard block
 block discarded – undo
1602 1602
 		}
1603 1603
 	}
1604 1604
 
1605
-    /**
1606
-     * Prepare and json_encode post content
1607
-     *
1608
-     * @since 2.0
1609
-     *
1610
-     * @param array $post_content
1611
-     * @return string $post_content ( json encoded array )
1612
-     */
1613
-    public static function prepare_and_encode( $post_content ) {
1614
-        //Loop through array to strip slashes and add only the needed ones
1605
+	/**
1606
+	 * Prepare and json_encode post content
1607
+	 *
1608
+	 * @since 2.0
1609
+	 *
1610
+	 * @param array $post_content
1611
+	 * @return string $post_content ( json encoded array )
1612
+	 */
1613
+	public static function prepare_and_encode( $post_content ) {
1614
+		//Loop through array to strip slashes and add only the needed ones
1615 1615
 		foreach ( $post_content as $key => $val ) {
1616 1616
 			// Replace problematic characters (like &quot;)
1617 1617
 			$val = str_replace( '&quot;', '"', $val );
1618 1618
 
1619 1619
 			self::prepare_action_slashes( $val, $key, $post_content );
1620
-            unset( $key, $val );
1621
-        }
1620
+			unset( $key, $val );
1621
+		}
1622 1622
 
1623
-        // json_encode the array
1624
-        $post_content = json_encode( $post_content );
1623
+		// json_encode the array
1624
+		$post_content = json_encode( $post_content );
1625 1625
 
1626
-	    // add extra slashes for \r\n since WP strips them
1626
+		// add extra slashes for \r\n since WP strips them
1627 1627
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1628 1628
 
1629
-        // allow for &quot
1630
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1629
+		// allow for &quot
1630
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1631 1631
 
1632
-        return $post_content;
1633
-    }
1632
+		return $post_content;
1633
+	}
1634 1634
 
1635 1635
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1636 1636
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1653,55 +1653,55 @@  discard block
 block discarded – undo
1653 1653
 
1654 1654
 	public static function maybe_json_decode( $string ) {
1655 1655
 		if ( is_array( $string ) ) {
1656
-            return $string;
1657
-        }
1656
+			return $string;
1657
+		}
1658 1658
 
1659 1659
 		$new_string = json_decode( $string, true );
1660 1660
 		if ( function_exists( 'json_last_error' ) ) {
1661 1661
 			// php 5.3+
1662
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1663
-                $string = $new_string;
1664
-            }
1662
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1663
+				$string = $new_string;
1664
+			}
1665 1665
 		} elseif ( isset( $new_string ) ) {
1666 1666
 			// php < 5.3 fallback
1667
-            $string = $new_string;
1668
-        }
1669
-        return $string;
1670
-    }
1671
-
1672
-    /**
1673
-     * @since 1.07.10
1674
-     *
1675
-     * @param string $post_type The name of the post type that may need to be highlighted
1676
-     * echo The javascript to open and highlight the Formidable menu
1677
-     */
1667
+			$string = $new_string;
1668
+		}
1669
+		return $string;
1670
+	}
1671
+
1672
+	/**
1673
+	 * @since 1.07.10
1674
+	 *
1675
+	 * @param string $post_type The name of the post type that may need to be highlighted
1676
+	 * echo The javascript to open and highlight the Formidable menu
1677
+	 */
1678 1678
 	public static function maybe_highlight_menu( $post_type ) {
1679
-        global $post;
1679
+		global $post;
1680 1680
 
1681 1681
 		if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1682
-            return;
1683
-        }
1682
+			return;
1683
+		}
1684 1684
 
1685 1685
 		if ( is_object( $post ) && $post->post_type != $post_type ) {
1686
-            return;
1687
-        }
1686
+			return;
1687
+		}
1688 1688
 
1689
-        self::load_admin_wide_js();
1690
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1691
-    }
1689
+		self::load_admin_wide_js();
1690
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1691
+	}
1692 1692
 
1693
-    /**
1694
-     * Load the JS file on non-Formidable pages in the admin area
1693
+	/**
1694
+	 * Load the JS file on non-Formidable pages in the admin area
1695 1695
 	 *
1696
-     * @since 2.0
1697
-     */
1696
+	 * @since 2.0
1697
+	 */
1698 1698
 	public static function load_admin_wide_js( $load = true ) {
1699 1699
 		$version = self::plugin_version();
1700 1700
 		wp_register_script( 'formidable_admin_global', self::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1701 1701
 
1702 1702
 		$global_strings = array(
1703 1703
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1704
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1704
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1705 1705
 			'url'          => self::plugin_url(),
1706 1706
 			'loading'      => __( 'Loading&hellip;', 'formidable' ),
1707 1707
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
@@ -1711,7 +1711,7 @@  discard block
 block discarded – undo
1711 1711
 		if ( $load ) {
1712 1712
 			wp_enqueue_script( 'formidable_admin_global' );
1713 1713
 		}
1714
-    }
1714
+	}
1715 1715
 
1716 1716
 	/**
1717 1717
 	 * @since 2.0.9
@@ -1720,9 +1720,9 @@  discard block
 block discarded – undo
1720 1720
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1721 1721
 	}
1722 1722
 
1723
-    /**
1724
-     * @param string $location
1725
-     */
1723
+	/**
1724
+	 * @param string $location
1725
+	 */
1726 1726
 	public static function localize_script( $location ) {
1727 1727
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1728 1728
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1788,28 +1788,28 @@  discard block
 block discarded – undo
1788 1788
 		}
1789 1789
 	}
1790 1790
 
1791
-    /**
1791
+	/**
1792 1792
 	 * Echo the message on the plugins listing page
1793 1793
 	 *
1794
-     * @since 1.07.10
1795
-     *
1796
-     * @param float $min_version The version the add-on requires
1797
-     */
1794
+	 * @since 1.07.10
1795
+	 *
1796
+	 * @param float $min_version The version the add-on requires
1797
+	 */
1798 1798
 	public static function min_version_notice( $min_version ) {
1799
-        $frm_version = self::plugin_version();
1799
+		$frm_version = self::plugin_version();
1800 1800
 
1801
-        // check if Formidable meets minimum requirements
1801
+		// check if Formidable meets minimum requirements
1802 1802
 		if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1803
-            return;
1804
-        }
1803
+			return;
1804
+		}
1805 1805
 
1806 1806
 		$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1807 1807
 		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">' .
1808
-        esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1809
-        '</div></td></tr>';
1810
-    }
1808
+		esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1809
+		'</div></td></tr>';
1810
+	}
1811 1811
 
1812
-    public static function locales( $type = 'date' ) {
1812
+	public static function locales( $type = 'date' ) {
1813 1813
 		$locales = array(
1814 1814
 			'en' => __( 'English', 'formidable' ),
1815 1815
 			'af' => __( 'Afrikaans', 'formidable' ),
@@ -1887,8 +1887,8 @@  discard block
 block discarded – undo
1887 1887
 		$locales = array_diff_key( $locales, array_flip( $unset ) );
1888 1888
 		$locales = apply_filters( 'frm_locales', $locales );
1889 1889
 
1890
-        return $locales;
1891
-    }
1890
+		return $locales;
1891
+	}
1892 1892
 
1893 1893
 	/**
1894 1894
 	 * Used to filter shortcode in text widgets
Please login to merge, or discard this patch.